From 6c0413e39bce315a3465bd7c86b552c0040eae53 Mon Sep 17 00:00:00 2001 From: robert dennis <31261583+robertdrakedennis@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:10:18 -0400 Subject: [PATCH] Start 2.0 development Co-authored-by: Anthony Co-authored-by: Sky Mulley --- .dockerignore | 40 + .env.ci | 2 + .eslintignore | 6 - .eslintrc.js | 52 - .github/docker/README.md | 158 +- .github/docker/default.conf | 3 +- .github/docker/default_ssl.conf | 12 +- .github/docker/entrypoint.sh | 151 +- .github/docker/health.conf | 15 + .github/docker/healthcheck.sh | 17 + .github/docker/optimize.sh | 43 + .github/docker/php.ini | 10 + .github/docker/smoke-test.sh | 246 + .github/docker/supervisord.conf | 75 +- .github/docker/www.conf | 20 +- .github/workflows/build.yaml | 10 +- .github/workflows/ci.yaml | 71 +- .github/workflows/docker.yaml | 167 +- .github/workflows/release.yaml | 22 +- .github/workflows/staging.yaml | 21 + .gitignore | 18 +- .nvmrc | 1 + .oxfmtrc.json | 13 + .oxlintrc.json | 233 + .php-cs-fixer.dist.php | 58 - .prettierrc.json | 9 - BUILDING.md | 63 - CHANGELOG.md | 28 + CONTRIBUTING.md | 26 +- Dockerfile | 105 +- README.md | 16 +- app/Actions/Activity/IngestActivityLogs.php | 77 + app/Actions/Allocations/AssignAllocation.php | 31 + .../Allocations/AssignAvailableAllocation.php | 49 + app/Actions/Allocations/CreateAllocations.php | 97 + app/Actions/Allocations/DeleteAllocation.php | 26 + .../Allocations/SetPrimaryAllocation.php | 19 + .../Allocations/UnassignAllocation.php | 29 + app/Actions/Allocations/UpdateAllocation.php | 20 + .../Allocations/UpdateAllocationNotes.php | 18 + app/Actions/Api/CreateAccountApiKey.php | 25 + app/Actions/Api/CreateApiKey.php | 32 + app/Actions/Backups/CompleteBackup.php | 103 + .../Backups/DeleteBackup.php} | 54 +- .../Backups/GenerateBackupDownloadLink.php} | 33 +- app/Actions/Backups/InitiateBackup.php | 124 + app/Actions/Backups/PresignBackupUpload.php | 86 + app/Actions/Backups/RestoreBackup.php | 44 + app/Actions/Backups/RestoreBackupStatus.php | 24 + app/Actions/Backups/ToggleBackupLock.php | 18 + app/Actions/Databases/CreateDatabase.php | 108 + app/Actions/Databases/CreateDatabaseHost.php | 47 + app/Actions/Databases/DeleteDatabase.php | 31 + app/Actions/Databases/DeleteDatabaseHost.php | 26 + .../Databases/DeployServerDatabase.php | 57 + .../Databases/RotateDatabasePassword.php | 41 + app/Actions/Databases/UpdateDatabaseHost.php | 42 + app/Actions/Eggs/CreateEgg.php | 28 + app/Actions/Eggs/DeleteEgg.php | 33 + .../Eggs/Scripts/UpdateInstallScript.php | 37 + .../Eggs/Sharing/ExportEgg.php} | 55 +- app/Actions/Eggs/Sharing/ImportCatalogEgg.php | 41 + app/Actions/Eggs/Sharing/ImportEgg.php | 45 + .../Eggs/Sharing/UpdateEggFromImport.php | 44 + app/Actions/Eggs/UpdateEgg.php | 25 + .../Eggs/Variables/CreateEggVariable.php | 24 + .../Eggs/Variables/ReorderEggVariables.php | 23 + .../Eggs/Variables/UpdateEggVariable.php | 21 + app/Actions/Extensions/InstallExtension.php | 109 + app/Actions/Extensions/RemoveExtension.php | 62 + .../ReplaceExtensionSettingFile.php | 47 + .../Extensions/SetExtensionEnabled.php | 98 + .../Extensions/UpdateExtensionSettings.php | 22 + app/Actions/Files/ChangeFilePermissions.php | 18 + app/Actions/Files/CompressFiles.php | 21 + app/Actions/Files/CopyFile.php | 17 + app/Actions/Files/CreateDirectory.php | 17 + app/Actions/Files/DecompressFile.php | 18 + app/Actions/Files/DeleteFiles.php | 18 + app/Actions/Files/ListDirectory.php | 17 + app/Actions/Files/PullFile.php | 18 + app/Actions/Files/ReadFileContents.php | 21 + app/Actions/Files/RenameFiles.php | 18 + app/Actions/Files/WriteFileContents.php | 17 + app/Actions/Locations/CreateLocation.php | 21 + app/Actions/Locations/DeleteLocation.php | 26 + app/Actions/Locations/UpdateLocation.php | 23 + app/Actions/Nodes/CreateNode.php | 29 + app/Actions/Nodes/DeleteNode.php | 26 + app/Actions/Nodes/ResetServerStates.php | 55 + app/Actions/Nodes/UpdateNode.php | 73 + app/Actions/Schedules/CreateSchedule.php | 51 + app/Actions/Schedules/CreateScheduleTask.php | 53 + app/Actions/Schedules/DeleteSchedule.php | 16 + app/Actions/Schedules/DeleteScheduleTask.php | 33 + app/Actions/Schedules/ProcessSchedule.php | 109 + app/Actions/Schedules/UpdateSchedule.php | 58 + app/Actions/Schedules/UpdateScheduleTask.php | 54 + app/Actions/Servers/AttachMountToServer.php | 26 + app/Actions/Servers/ChangeServerEgg.php | 69 + app/Actions/Servers/CreateServer.php | 187 + app/Actions/Servers/DeleteServer.php | 72 + app/Actions/Servers/DetachMountFromServer.php | 18 + app/Actions/Servers/ReadServerLogs.php | 17 + app/Actions/Servers/ReadServerState.php | 27 + app/Actions/Servers/RebuildServer.php | 17 + .../Servers/RecordServerInstallResult.php | 44 + app/Actions/Servers/ReinstallServer.php | 31 + app/Actions/Servers/SendServerCommand.php | 26 + app/Actions/Servers/SendServerPower.php | 17 + .../Servers/ToggleServerSuspension.php | 48 + app/Actions/Servers/UpdateServerBuild.php | 106 + app/Actions/Servers/UpdateServerDetails.php | 40 + app/Actions/Servers/UpdateServerStartup.php | 72 + app/Actions/Subusers/CreateSubuser.php | 64 + app/Actions/Subusers/DeleteSubuser.php | 31 + app/Actions/Subusers/UpdateSubuser.php | 35 + app/Actions/Tags/SyncTags.php | 51 + app/Actions/Telemetry/SendTelemetry.php | 30 + app/Actions/Themes/ApplyTheme.php | 51 + app/Actions/Themes/ResetTheme.php | 23 + app/Actions/Transfers/CompleteTransfer.php | 55 + app/Actions/Transfers/FailTransfer.php | 34 + app/Actions/Transfers/InitiateTransfer.php | 81 + app/Actions/Users/CompleteLogin.php | 55 + app/Actions/Users/CreateUser.php | 45 + .../Users/DeleteUser.php} | 17 +- app/Actions/Users/DisableTwoFactor.php | 19 + app/Actions/Users/SetupTwoFactor.php | 50 + app/Actions/Users/ToggleTwoFactor.php | 90 + app/Actions/Users/UpdateUser.php | 37 + app/Actions/Users/UpdateUserEmail.php | 44 + app/Actions/Users/UpdateUserPassword.php | 29 + .../Environment/Addons/RunHooksCommand.php | 25 +- .../Environment/AppSettingsCommand.php | 164 +- .../Environment/DatabaseSettingsCommand.php | 60 +- .../Environment/EmailSettingsCommand.php | 135 +- .../Commands/Extensions/DevCommand.php | 78 + .../Commands/Extensions/DisableCommand.php | 31 + .../Commands/Extensions/DoctorCommand.php | 44 + .../Commands/Extensions/EnableCommand.php | 31 + .../Commands/Extensions/InstallCommand.php | 39 + .../Commands/Extensions/ListCommand.php | 54 + .../Commands/Extensions/MakeCommand.php | 68 + .../Commands/Extensions/PackCommand.php | 73 + .../Commands/Extensions/RemoveCommand.php | 40 + .../Commands/Extensions/TypesCommand.php | 57 + app/Console/Commands/InfoCommand.php | 30 +- .../Location/DeleteLocationCommand.php | 47 +- .../Commands/Location/MakeLocationCommand.php | 47 +- .../CleanServiceBackupFilesCommand.php | 28 +- .../PruneOrphanedBackupsCommand.php | 36 +- app/Console/Commands/Node/MakeNodeCommand.php | 138 +- .../Node/NodeConfigurationCommand.php | 29 +- app/Console/Commands/Node/NodeListCommand.php | 26 +- .../Commands/Overrides/KeyGenerateCommand.php | 10 +- .../Commands/Overrides/SeedCommand.php | 6 +- app/Console/Commands/Overrides/UpCommand.php | 6 +- .../Schedule/ProcessRunnableCommand.php | 29 +- .../Server/BulkPowerActionCommand.php | 67 +- app/Console/Commands/TelemetryCommand.php | 26 +- app/Console/Commands/Themes/ApplyCommand.php | 31 + app/Console/Commands/Themes/ListCommand.php | 37 + app/Console/Commands/Themes/ResetCommand.php | 24 + app/Console/Commands/UpgradeCommand.php | 198 +- .../Commands/User/DeleteUserCommand.php | 44 +- .../Commands/User/DisableTwoFactorCommand.php | 30 +- app/Console/Commands/User/MakeUserCommand.php | 60 +- app/Console/Kernel.php | 76 - app/Console/RequiresDatabaseMigrations.php | 18 +- app/Console/Scheduler.php | 71 + .../Activity/IngestsActivityLogs.php | 13 + .../Allocations/AssignsAllocations.php | 19 + .../AssignsAvailableAllocations.php | 15 + .../Allocations/CreatesAllocations.php | 26 + .../Allocations/DeletesAllocations.php | 18 + .../Allocations/SetsPrimaryAllocations.php | 13 + .../Allocations/UnassignsAllocations.php | 17 + .../Allocations/UpdatesAllocationNotes.php | 12 + .../Allocations/UpdatesAllocations.php | 12 + app/Contracts/Api/CreatesAccountApiKeys.php | 14 + app/Contracts/Api/CreatesApiKeys.php | 16 + app/Contracts/Backups/CompletesBackups.php | 18 + app/Contracts/Backups/DeletesBackups.php | 14 + .../Backups/GeneratesBackupDownloadLinks.php | 13 + app/Contracts/Backups/InitiatesBackups.php | 18 + .../Backups/PresignsBackupUploads.php | 16 + .../Backups/RestoresBackupStatuses.php | 13 + app/Contracts/Backups/RestoresBackups.php | 16 + app/Contracts/Backups/TogglesBackupLocks.php | 12 + app/Contracts/Core/ReceivesEvents.php | 2 + app/Contracts/Criteria/CriteriaInterface.php | 14 - .../Databases/CreatesDatabaseHosts.php | 16 + app/Contracts/Databases/CreatesDatabases.php | 23 + .../Databases/DeletesDatabaseHosts.php | 14 + app/Contracts/Databases/DeletesDatabases.php | 14 + .../Databases/DeploysServerDatabases.php | 25 + .../Databases/RotatesDatabasePasswords.php | 14 + .../Databases/UpdatesDatabaseHosts.php | 16 + app/Contracts/Eggs/CreatesEggVariables.php | 18 + app/Contracts/Eggs/CreatesEggs.php | 17 + app/Contracts/Eggs/DeletesEggs.php | 21 + app/Contracts/Eggs/ExportsEggs.php | 18 + app/Contracts/Eggs/ImportsCatalogEggs.php | 12 + app/Contracts/Eggs/ImportsEggs.php | 19 + app/Contracts/Eggs/ReordersEggVariables.php | 13 + .../Eggs/UpdatesEggInstallScripts.php | 20 + app/Contracts/Eggs/UpdatesEggVariables.php | 17 + app/Contracts/Eggs/UpdatesEggs.php | 17 + app/Contracts/Eggs/UpdatesEggsFromImports.php | 16 + app/Contracts/Extensions/HashidsInterface.php | 7 +- .../Extensions/InstallsExtensions.php | 12 + .../Extensions/RemovesExtensions.php | 10 + .../ReplacesExtensionSettingFiles.php | 19 + .../Extensions/SetsExtensionEnabled.php | 12 + .../Extensions/UpdatesExtensionSettings.php | 16 + .../Files/ChangesFilePermissions.php | 13 + app/Contracts/Files/CompressesFiles.php | 16 + app/Contracts/Files/CopiesFiles.php | 12 + app/Contracts/Files/CreatesDirectories.php | 12 + app/Contracts/Files/DecompressesFiles.php | 12 + app/Contracts/Files/DeletesFiles.php | 13 + app/Contracts/Files/ListsDirectories.php | 18 + app/Contracts/Files/PullsFiles.php | 13 + app/Contracts/Files/ReadsFileContents.php | 21 + app/Contracts/Files/RenamesFiles.php | 13 + app/Contracts/Files/WritesFileContents.php | 12 + .../Http/ClientPermissionsRequest.php | 2 + app/Contracts/Locations/CreatesLocations.php | 17 + app/Contracts/Locations/DeletesLocations.php | 18 + app/Contracts/Locations/UpdatesLocations.php | 17 + app/Contracts/Models/Identifiable.php | 8 +- app/Contracts/Nodes/CreatesNodes.php | 17 + app/Contracts/Nodes/DeletesNodes.php | 18 + app/Contracts/Nodes/ResetsServerStates.php | 19 + app/Contracts/Nodes/UpdatesNodes.php | 20 + .../AllocationRepositoryInterface.php | 19 - .../Repository/ApiKeyRepositoryInterface.php | 19 - .../ApiPermissionRepositoryInterface.php | 7 - .../DatabaseHostRepositoryInterface.php | 14 - .../DatabaseRepositoryInterface.php | 61 - .../Repository/EggRepositoryInterface.php | 38 - .../EggVariableRepositoryInterface.php | 14 - .../LocationRepositoryInterface.php | 33 - .../Repository/NestRepositoryInterface.php | 30 - .../Repository/NodeRepositoryInterface.php | 38 - .../PermissionRepositoryInterface.php | 7 - .../Repository/RepositoryInterface.php | 141 - .../ScheduleRepositoryInterface.php | 21 - .../Repository/ServerRepositoryInterface.php | 73 - .../ServerVariableRepositoryInterface.php | 7 - .../Repository/SessionRepositoryInterface.php | 18 - .../SettingsRepositoryInterface.php | 24 - .../Repository/SubuserRepositoryInterface.php | 25 - .../Repository/TaskRepositoryInterface.php | 20 - .../Repository/UserRepositoryInterface.php | 7 - .../Schedules/CreatesScheduleTasks.php | 24 + app/Contracts/Schedules/CreatesSchedules.php | 19 + .../Schedules/DeletesScheduleTasks.php | 19 + app/Contracts/Schedules/DeletesSchedules.php | 12 + .../Schedules/ProcessesSchedules.php | 18 + .../Schedules/UpdatesScheduleTasks.php | 22 + app/Contracts/Schedules/UpdatesSchedules.php | 18 + .../Servers/AttachesMountsToServers.php | 13 + app/Contracts/Servers/ChangesServerEgg.php | 23 + app/Contracts/Servers/CreatesServers.php | 27 + app/Contracts/Servers/DeletesServers.php | 20 + .../Servers/DetachesMountsFromServers.php | 13 + app/Contracts/Servers/ReadsServerLogs.php | 24 + app/Contracts/Servers/ReadsServerState.php | 21 + app/Contracts/Servers/RebuildsServers.php | 12 + .../Servers/RecordsServerInstallResults.php | 13 + app/Contracts/Servers/ReinstallsServers.php | 14 + app/Contracts/Servers/SendsServerCommands.php | 12 + app/Contracts/Servers/SendsServerPower.php | 12 + .../Servers/TogglesServerSuspension.php | 16 + app/Contracts/Servers/UpdatesServerBuild.php | 20 + .../Servers/UpdatesServerDetails.php | 18 + .../Servers/UpdatesServerStartup.php | 19 + app/Contracts/Subusers/CreatesSubusers.php | 28 + app/Contracts/Subusers/DeletesSubusers.php | 19 + app/Contracts/Subusers/UpdatesSubusers.php | 21 + app/Contracts/Tags/SyncsTags.php | 20 + app/Contracts/Telemetry/SendsTelemetry.php | 10 + app/Contracts/Themes/AppliesThemes.php | 10 + app/Contracts/Themes/ResetsThemes.php | 10 + .../Transfers/CompletesTransfers.php | 19 + app/Contracts/Transfers/FailsTransfers.php | 18 + .../Transfers/InitiatesTransfers.php | 25 + app/Contracts/Users/CompletesLogins.php | 37 + app/Contracts/Users/CreatesUsers.php | 24 + app/Contracts/Users/DeletesUsers.php | 18 + app/Contracts/Users/DisablesTwoFactor.php | 12 + app/Contracts/Users/SetsUpTwoFactor.php | 19 + app/Contracts/Users/TogglesTwoFactor.php | 29 + app/Contracts/Users/UpdatesUserEmails.php | 15 + app/Contracts/Users/UpdatesUserPasswords.php | 12 + app/Contracts/Users/UpdatesUsers.php | 21 + app/Data/AllocationRange.php | 49 + app/Data/EggCatalogEntry.php | 91 + app/Data/Extensions/ExtensionJobSnapshot.php | 44 + app/Data/LoginCheckpoint.php | 46 + app/Data/LoginResult.php | 52 + app/Data/ServerCreationData.php | 147 + app/Data/ServerState.php | 44 + app/Data/ValidatedEggVariable.php | 14 + app/Enum/EggSpecificTags.php | 127 + app/Enum/JwtScope.php | 2 + app/Enum/Permissions.php | 144 + app/Enum/ResourceLimit.php | 38 +- app/Events/ActivityLogged.php | 10 +- app/Events/Auth/DirectLogin.php | 8 +- app/Events/Auth/FailedCaptcha.php | 8 +- app/Events/Auth/FailedPasswordReset.php | 8 +- .../Auth/ProvidedAuthenticationToken.php | 8 +- app/Events/Event.php | 6 +- app/Events/Extensions/ExtensionDisabled.php | 13 + app/Events/Extensions/ExtensionDisabling.php | 13 + app/Events/Extensions/ExtensionEnabled.php | 13 + app/Events/Extensions/ExtensionEnabling.php | 13 + app/Events/Extensions/ExtensionInstalled.php | 13 + app/Events/Extensions/ExtensionInstalling.php | 16 + app/Events/Extensions/ExtensionLoadFailed.php | 18 + app/Events/Extensions/ExtensionRemoved.php | 12 + app/Events/Extensions/ExtensionRemoving.php | 13 + app/Events/Server/Created.php | 8 +- app/Events/Server/Creating.php | 8 +- app/Events/Server/Deleted.php | 8 +- app/Events/Server/Deleting.php | 8 +- app/Events/Server/Installed.php | 8 +- app/Events/Server/OperationCompleted.php | 25 + app/Events/Server/Saved.php | 8 +- app/Events/Server/Saving.php | 8 +- app/Events/Server/Updated.php | 8 +- app/Events/Server/Updating.php | 8 +- app/Events/Subuser/Created.php | 8 +- app/Events/Subuser/Creating.php | 8 +- app/Events/Subuser/Deleted.php | 8 +- app/Events/Subuser/Deleting.php | 8 +- app/Events/User/Created.php | 10 +- app/Events/User/Creating.php | 10 +- app/Events/User/Deleted.php | 10 +- app/Events/User/Deleting.php | 10 +- app/Events/User/PasswordChanged.php | 10 +- app/Exceptions/AccountNotFoundException.php | 7 - app/Exceptions/ApiErrorResponse.php | 193 + app/Exceptions/AutoDeploymentException.php | 7 - app/Exceptions/DisplayException.php | 58 +- .../Extensions/InvalidExtensionException.php | 9 + app/Exceptions/Handler.php | 283 - .../Base/InvalidPasswordProvidedException.php | 6 +- .../Connection/DaemonConnectionException.php | 105 +- .../Http/HttpForbiddenException.php | 5 +- .../Http/Server/FileSizeTooLargeException.php | 2 + .../Server/FileTypeNotEditableException.php | 9 - .../Server/ServerStateConflictException.php | 9 +- .../Http/TwoFactorAuthRequiredException.php | 5 +- .../ManifestDoesNotExistException.php | 11 +- .../Model/DataValidationException.php | 59 - app/Exceptions/PterodactylException.php | 8 +- .../Daemon/InvalidPowerSignalException.php | 9 - .../DuplicateDatabaseNameException.php | 6 +- .../Repository/RecordNotFoundException.php | 25 - .../Repository/RepositoryException.php | 9 - ...locationDoesNotBelongToServerException.php | 9 - .../AutoAllocationNotEnabledException.php | 2 + .../Allocation/CidrOutOfRangeException.php | 2 + .../InvalidPortMappingException.php | 6 +- ...oAutoAllocationSpaceAvailableException.php | 2 + .../Allocation/PortOutOfRangeException.php | 2 + .../ServerUsingAllocationException.php | 6 +- .../TooManyPortsInRangeException.php | 2 + .../Service/Backup/BackupLockedException.php | 5 +- .../Backup/TooManyBackupsException.php | 2 + ...tabaseClientFeatureNotEnabledException.php | 2 + .../NoSuitableDatabaseHostException.php | 2 + .../Database/TooManyDatabasesException.php | 2 + .../NoViableAllocationException.php | 6 +- .../Deployment/NoViableNodeException.php | 6 +- .../Service/Egg/BadJsonFormatException.php | 9 - .../Service/Egg/HasChildrenException.php | 6 +- .../Service/Egg/InvalidCopyFromException.php | 6 +- .../NoParentConfigurationFoundException.php | 9 - .../Variable/BadValidationRuleException.php | 9 - .../ReservedVariableNameException.php | 9 - .../Service/HasActiveServersException.php | 2 + .../Helper/CdnVersionFetchingException.php | 8 +- .../Service/InvalidFileUploadException.php | 6 +- .../Location/HasActiveNodesException.php | 2 + .../ConfigurationNotPersistedException.php | 6 +- .../Task/TaskIntervalTooLongException.php | 9 - .../RequiredVariableMissingException.php | 9 - .../Service/ServiceLimitExceededException.php | 5 +- .../Subuser/ServerSubuserExistsException.php | 6 +- .../Subuser/UserIsServerOwnerException.php | 6 +- .../TwoFactorAuthenticationTokenInvalid.php | 2 + .../ManifestDoesNotExistSolution.php | 25 - .../InvalidTransformerLevelException.php | 6 +- app/Extensions/Backups/BackupManager.php | 228 +- app/Extensions/DynamicDatabaseConnection.php | 28 +- app/Extensions/ExtensionProvider.php | 364 + app/Extensions/Facades/Theme.php | 13 - app/Extensions/Filesystem/S3Filesystem.php | 9 +- app/Extensions/Hashids.php | 6 +- .../Illuminate/Database/Eloquent/Builder.php | 10 + .../Events/Contracts/SubscribesToEvents.php | 2 + .../Laravel/Sanctum/NewAccessToken.php | 23 +- .../Lcobucci/JWT/Encoding/TimestampDates.php | 16 +- .../Serializers/PterodactylSerializer.php | 25 +- .../Scribe/Attributes/ResponseField.php | 37 + .../Attributes/ResponseFromTransformer.php | 42 + .../OpenApi/PterodactylOpenApiGenerator.php | 2668 +++ .../InferPterodactylBodyParameters.php | 169 + .../Strategies/InferPterodactylResponses.php | 136 + .../InferPterodactylUrlParameters.php | 55 + .../UsePterodactylResponseAttributes.php | 185 + .../Support/PterodactylDocumentation.php | 361 + .../Spatie/Fractalistic/Fractal.php | 76 +- app/Extensions/Themes/Theme.php | 21 - app/Facades/Activity.php | 2 + app/Facades/Alert.php | 24 + app/Facades/Daemon.php | 26 + app/Facades/Fractal.php | 29 + app/Facades/Hashids.php | 23 + app/Facades/LogBatch.php | 2 + app/Facades/LogTarget.php | 4 +- app/Helpers/Time.php | 2 + app/Helpers/Utilities.php | 22 +- app/Http/Concerns/ResolvesRequestContext.php | 27 + app/Http/Controllers/Admin/ApiController.php | 86 - app/Http/Controllers/Admin/BaseController.php | 25 - .../Controllers/Admin/DatabaseController.php | 126 - .../Controllers/Admin/LocationController.php | 103 - .../Controllers/Admin/MountController.php | 165 - .../Controllers/Admin/Nests/EggController.php | 128 - .../Admin/Nests/EggScriptController.php | 65 - .../Admin/Nests/EggShareController.php | 74 - .../Admin/Nests/EggVariableController.php | 90 - .../Admin/Nests/NestController.php | 102 - .../Admin/NodeAutoDeployController.php | 53 - .../Admin/Nodes/NodeController.php | 27 - .../Admin/Nodes/NodeViewController.php | 98 - .../Nodes/SystemInformationController.php | 40 - .../Controllers/Admin/NodesController.php | 183 - .../Admin/Servers/CreateServerController.php | 84 - .../Admin/Servers/ServerController.php | 30 - .../Servers/ServerTransferController.php | 119 - .../Admin/Servers/ServerViewController.php | 150 - .../Controllers/Admin/ServersController.php | 273 - .../Admin/Settings/AdvancedController.php | 60 - .../Admin/Settings/IndexController.php | 58 - .../Admin/Settings/MailController.php | 88 - app/Http/Controllers/Admin/UserController.php | 156 - .../Api/Admin/ActivityController.php | 62 + .../Api/Admin/ActivityFilterController.php | 40 + .../Api/Admin/AdminApiController.php | 26 + .../Api/Admin/ApiKeys/ApiKeyController.php | 155 + .../DatabaseHosts/DatabaseHostController.php | 250 + .../Api/Admin/Eggs/EggCatalogController.php | 57 + .../Api/Admin/Eggs/EggController.php | 144 + .../Api/Admin/Eggs/EggScriptController.php | 75 + .../Api/Admin/Eggs/EggVariableController.php | 121 + .../Api/Admin/Eggs/ExportEggController.php | 53 + .../Admin/Eggs/ImportCatalogEggController.php | 45 + .../Api/Admin/Eggs/ImportEggController.php | 48 + .../Admin/Eggs/ReorderVariablesController.php | 48 + .../Admin/Eggs/UpdateImportEggController.php | 43 + .../ExtensionAdminSettingsController.php | 42 + .../Admin/Extensions/ExtensionController.php | 300 + .../Api/Admin/LanguagesController.php | 34 + .../Locations/EligibleNodesController.php | 35 + .../Admin/Locations/LocationController.php | 144 + .../Api/Admin/Mounts/AttachEggsController.php | 46 + .../Admin/Mounts/AttachNodesController.php | 46 + .../Api/Admin/Mounts/DetachEggController.php | 38 + .../Api/Admin/Mounts/DetachNodeController.php | 38 + .../Api/Admin/Mounts/MountController.php | 156 + .../Api/Admin/Nodes/AllocationController.php | 182 + .../Nodes/AvailableAllocationsController.php | 53 + .../Nodes/BulkDeleteAllocationsController.php | 46 + .../Admin/Nodes/ConfigurationController.php | 54 + .../Nodes/DeleteAllocationBlockController.php | 39 + .../Api/Admin/Nodes/DeployTokenController.php | 71 + .../Api/Admin/Nodes/NodeController.php | 156 + .../Nodes/SystemInformationController.php | 48 + .../Api/Admin/Nodes/UniqueIpsController.php | 42 + .../Api/Admin/Nodes/UtilizationController.php | 44 + .../Api/Admin/Servers/BuildController.php | 43 + .../Api/Admin/Servers/DatabaseController.php | 152 + .../Api/Admin/Servers/DetailsController.php | 46 + .../Api/Admin/Servers/ExternalController.php | 37 + .../Api/Admin/Servers/RebuildController.php | 38 + .../Api/Admin/Servers/ReinstallController.php | 39 + .../RotateDatabasePasswordController.php | 48 + .../Admin/Servers/ServerBackupController.php | 47 + .../Api/Admin/Servers/ServerController.php | 314 + .../Admin/Servers/ServerMountController.php | 131 + .../Api/Admin/Servers/StartupController.php | 44 + .../Admin/Servers/SuspensionController.php | 43 + .../Admin/Servers/ToggleBackupController.php | 48 + .../Admin/Servers/ToggleInstallController.php | 56 + .../Api/Admin/Servers/TransferController.php | 58 + .../Servers/TransferProgressController.php | 44 + .../Api/Admin/Settings/AdvancedController.php | 37 + .../Api/Admin/Settings/GeneralController.php | 37 + .../Api/Admin/Settings/MailController.php | 64 + .../Api/Admin/Settings/SettingsController.php | 94 + .../Api/Admin/Settings/TestMailController.php | 50 + .../Api/Admin/Tags/TagController.php | 245 + .../Users/DisableTwoFactorController.php | 41 + .../Api/Admin/Users/ExternalController.php | 37 + .../Api/Admin/Users/UserController.php | 181 + .../Api/Admin/VersionController.php | 44 + .../Application/ApplicationApiController.php | 69 +- .../Api/Application/Eggs/EggController.php | 67 + .../Locations/LocationController.php | 104 +- .../Api/Application/Nests/EggController.php | 33 - .../Api/Application/Nests/NestController.php | 42 - .../Nodes/AllocationController.php | 126 +- .../Nodes/NodeConfigurationController.php | 41 +- .../Api/Application/Nodes/NodeController.php | 128 +- .../Nodes/NodeDeploymentController.php | 64 +- .../Servers/DatabaseController.php | 86 +- .../Servers/ExternalServerController.php | 26 +- .../Application/Servers/ServerController.php | 123 +- .../Servers/ServerDetailsController.php | 76 +- .../Servers/ServerManagementController.php | 77 +- .../Application/Servers/StartupController.php | 58 +- .../Api/Application/Tags/TagController.php | 63 + .../Users/ExternalUserController.php | 26 +- .../Api/Application/Users/UserController.php | 113 +- .../Api/Client/AccountController.php | 109 +- .../Api/Client/ActivityLogController.php | 47 +- .../Client/ActivityLogFilterController.php | 31 + .../Api/Client/ApiKeyController.php | 69 +- .../Api/Client/ClientApiController.php | 68 +- .../Api/Client/ClientController.php | 86 +- .../Client/ExtensionProgressController.php | 50 + .../Api/Client/SSHKeyController.php | 44 +- .../Client/Servers/ActivityLogController.php | 79 +- .../Servers/ActivityLogFilterController.php | 35 + .../Api/Client/Servers/BackupController.php | 249 +- .../Api/Client/Servers/CommandController.php | 55 +- .../Api/Client/Servers/DatabaseController.php | 114 +- .../Api/Client/Servers/FileController.php | 330 +- .../Client/Servers/FileUploadController.php | 42 +- .../Api/Client/Servers/LogController.php | 65 + .../Servers/NetworkAllocationController.php | 139 +- .../Api/Client/Servers/PowerController.php | 32 +- .../Servers/ResourceUtilizationController.php | 71 +- .../Api/Client/Servers/ScheduleController.php | 183 +- .../Client/Servers/ScheduleTaskController.php | 185 +- .../Api/Client/Servers/ServerController.php | 35 +- .../Api/Client/Servers/SettingsController.php | 89 +- .../Api/Client/Servers/StartupController.php | 101 +- .../Api/Client/Servers/SubuserController.php | 194 +- .../Client/Servers/WebsocketController.php | 57 +- .../Api/Client/TwoFactorController.php | 131 +- .../Remote/ActivityProcessingController.php | 83 +- .../Backups/BackupRemoteUploadController.php | 126 +- .../Remote/Backups/BackupStatusController.php | 154 +- .../Api/Remote/EggInstallController.php | 51 - .../Servers/ServerDetailsController.php | 102 +- .../Servers/ServerInstallController.php | 79 +- .../Servers/ServerTransferController.php | 133 +- .../Remote/SftpAuthenticationController.php | 109 +- .../Auth/AbstractLoginController.php | 82 +- .../Auth/ForgotPasswordController.php | 54 +- .../Auth/LoginCheckpointController.php | 157 +- app/Http/Controllers/Auth/LoginController.php | 130 +- .../Auth/ResetPasswordController.php | 90 +- .../Base/ExtensionFileController.php | 34 + app/Http/Controllers/Base/IndexController.php | 13 +- .../Controllers/Base/LocaleController.php | 34 +- app/Http/Controllers/Controller.php | 8 +- app/Http/Kernel.php | 107 - .../Middleware/Activity/AccountSubject.php | 17 +- .../Middleware/Activity/ServerSubject.php | 19 +- app/Http/Middleware/Activity/TrackAPIKey.php | 16 +- .../Admin/Servers/ServerInstalled.php | 31 - app/Http/Middleware/AdminAuthenticate.php | 23 - .../Api/Admin/AuthenticateAdmin.php | 38 + .../AuthenticateApplicationUser.php | 15 +- .../Middleware/Api/AuthenticateIPAccess.php | 39 +- .../Api/Client/RequireClientApiKey.php | 24 +- .../Server/AuthenticateServerAccess.php | 49 +- .../Client/Server/ResourceBelongsToServer.php | 59 +- .../Api/Client/SubstituteClientBindings.php | 49 +- .../Api/Daemon/DaemonAuthenticate.php | 52 +- app/Http/Middleware/Api/IsValidJson.php | 17 +- app/Http/Middleware/EncryptCookies.php | 13 - .../Middleware/EnsureExtensionIsAvailable.php | 27 + .../Middleware/EnsureStatefulRequests.php | 17 +- app/Http/Middleware/LanguageMiddleware.php | 21 +- app/Http/Middleware/MaintenanceMiddleware.php | 23 +- .../Middleware/RedirectIfAuthenticated.php | 18 +- .../RequireTwoFactorAuthentication.php | 46 +- app/Http/Middleware/SetSecurityHeaders.php | 16 +- app/Http/Middleware/TrimStrings.php | 16 - app/Http/Middleware/VerifyCsrfToken.php | 15 - app/Http/Middleware/VerifyReCaptcha.php | 63 +- app/Http/Requests/Admin/AdminFormRequest.php | 35 - .../Api/StoreApplicationApiKeyRequest.php | 37 - app/Http/Requests/Admin/BaseFormRequest.php | 13 - .../Admin/DatabaseHostFormRequest.php | 30 - .../Requests/Admin/Egg/EggFormRequest.php | 49 - .../Admin/Egg/EggImportFormRequest.php | 21 - .../Admin/Egg/EggScriptFormRequest.php | 22 - .../Admin/Egg/EggVariableFormRequest.php | 24 - .../Requests/Admin/LocationFormRequest.php | 20 - app/Http/Requests/Admin/MountFormRequest.php | 20 - .../Admin/Nest/StoreNestFormRequest.php | 16 - .../Requests/Admin/NewUserFormRequest.php | 28 - .../Admin/Node/AllocationAliasFormRequest.php | 16 - .../Admin/Node/AllocationFormRequest.php | 17 - .../Requests/Admin/Node/NodeFormRequest.php | 25 - app/Http/Requests/Admin/ServerFormRequest.php | 58 - .../Databases/StoreServerDatabaseRequest.php | 31 - .../Settings/AdvancedSettingsFormRequest.php | 50 - .../Settings/BaseSettingsFormRequest.php | 30 - .../Settings/MailSettingsFormRequest.php | 40 - app/Http/Requests/Admin/UserFormRequest.php | 28 - .../Admin/Activity/GetActivityLogsRequest.php | 22 + .../Requests/Api/Admin/AdminApiRequest.php | 37 + .../Api/Admin/ApiKeys/DeleteApiKeyRequest.php | 16 + .../Api/Admin/ApiKeys/GetApiKeysRequest.php | 16 + .../Api/Admin/ApiKeys/StoreApiKeyRequest.php | 65 + .../Api/Admin/ApiKeys/UpdateApiKeyRequest.php | 17 + .../DeleteDatabaseHostRequest.php | 16 + .../DatabaseHosts/GetDatabaseHostRequest.php | 16 + .../DatabaseHosts/GetDatabaseHostsRequest.php | 16 + .../StoreDatabaseHostRequest.php | 48 + .../UpdateDatabaseHostRequest.php | 15 + .../Api/Admin/Eggs/DeleteEggRequest.php | 16 + .../Requests/Api/Admin/Eggs/GetEggRequest.php | 16 + .../Api/Admin/Eggs/GetEggScriptRequest.php | 16 + .../Api/Admin/Eggs/GetEggsRequest.php | 16 + .../Admin/Eggs/ImportCatalogEggRequest.php | 29 + .../Api/Admin/Eggs/ImportEggRequest.php | 28 + .../Api/Admin/Eggs/StoreEggRequest.php | 118 + .../Api/Admin/Eggs/UpdateEggRequest.php | 17 + .../Api/Admin/Eggs/UpdateEggScriptRequest.php | 32 + .../Api/Admin/Eggs/UpdateImportEggRequest.php | 28 + .../Eggs/Variables/DeleteVariableRequest.php | 16 + .../Eggs/Variables/GetVariablesRequest.php | 16 + .../Variables/ReorderVariablesRequest.php | 37 + .../Eggs/Variables/StoreVariableRequest.php | 100 + .../Eggs/Variables/UpdateVariableRequest.php | 22 + .../Extensions/DeleteExtensionRequest.php | 16 + .../Admin/Extensions/GetExtensionsRequest.php | 16 + .../Extensions/InstallExtensionRequest.php | 50 + .../Extensions/UpdateExtensionRequest.php | 16 + .../UpdateExtensionSettingsRequest.php | 34 + .../UploadExtensionSettingFileRequest.php | 31 + .../Api/Admin/GetLanguagesRequest.php | 13 + .../Requests/Api/Admin/GetVersionRequest.php | 15 + .../Admin/Locations/DeleteLocationRequest.php | 16 + .../Admin/Locations/GetLocationRequest.php | 16 + .../Admin/Locations/GetLocationsRequest.php | 16 + .../Admin/Locations/StoreLocationRequest.php | 45 + .../Admin/Locations/UpdateLocationRequest.php | 27 + .../Api/Admin/Mounts/AttachEggsRequest.php | 51 + .../Api/Admin/Mounts/AttachNodesRequest.php | 51 + .../Api/Admin/Mounts/DeleteMountRequest.php | 16 + .../Api/Admin/Mounts/DetachEggRequest.php | 16 + .../Api/Admin/Mounts/DetachNodeRequest.php | 16 + .../Api/Admin/Mounts/GetMountRequest.php | 16 + .../Api/Admin/Mounts/GetMountsRequest.php | 16 + .../Api/Admin/Mounts/StoreMountRequest.php | 27 + .../Api/Admin/Mounts/UpdateMountRequest.php | 27 + .../BlockDeleteAllocationRequest.php | 28 + .../BulkDeleteAllocationRequest.php | 29 + .../Allocations/DeleteAllocationRequest.php | 26 + .../Allocations/GetAllocationsRequest.php | 16 + .../Allocations/StoreAllocationRequest.php | 42 + .../Allocations/UpdateAllocationRequest.php | 36 + .../Api/Admin/Nodes/DeleteNodeRequest.php | 16 + .../Api/Admin/Nodes/DeployTokenRequest.php | 16 + .../Api/Admin/Nodes/GetNodeRequest.php | 15 + .../Api/Admin/Nodes/GetNodesRequest.php | 16 + .../Nodes/GetSystemInformationRequest.php | 16 + .../Api/Admin/Nodes/GetUtilizationRequest.php | 16 + .../Api/Admin/Nodes/StoreNodeRequest.php | 133 + .../Api/Admin/Nodes/UpdateNodeRequest.php | 42 + .../Servers/Backups/ListBackupsRequest.php | 18 + .../Servers/Backups/ToggleBackupRequest.php | 18 + .../Servers/Databases/GetDatabasesRequest.php | 16 + .../Databases/ServerDatabaseWriteRequest.php | 16 + .../Databases/StoreDatabaseRequest.php | 80 + .../Servers/DeleteServerMountRequest.php | 15 + .../Api/Admin/Servers/DeleteServerRequest.php | 15 + .../Admin/Servers/GetServerMountsRequest.php | 15 + .../Api/Admin/Servers/GetServerRequest.php | 15 + .../Api/Admin/Servers/GetServersRequest.php | 16 + .../Api/Admin/Servers/ServerWriteRequest.php | 16 + .../Admin/Servers/StoreServerMountRequest.php | 27 + .../Api/Admin/Servers/StoreServerRequest.php | 142 + .../Admin/Servers/ToggleInstallRequest.php | 15 + .../Admin/Servers/TransferServerRequest.php | 95 + .../UpdateServerBuildConfigurationRequest.php | 141 + .../Servers/UpdateServerDetailsRequest.php | 58 + .../Servers/UpdateServerStartupRequest.php | 48 + .../Servers/UpdateServerSuspensionRequest.php | 27 + .../Api/Admin/Settings/GetSettingsRequest.php | 16 + .../Admin/Settings/SendTestMailRequest.php | 16 + .../UpdateAdvancedSettingsRequest.php | 85 + .../Settings/UpdateGeneralSettingsRequest.php | 59 + .../Settings/UpdateMailSettingsRequest.php | 59 + .../Api/Admin/Tags/DeleteTagRequest.php | 16 + .../Requests/Api/Admin/Tags/GetTagRequest.php | 15 + .../Api/Admin/Tags/GetTagsRequest.php | 16 + .../Api/Admin/Tags/StoreTagRequest.php | 43 + .../Api/Admin/Tags/SyncTagsRequest.php | 63 + .../Api/Admin/Tags/UpdateTagRequest.php | 25 + .../Api/Admin/Users/DeleteUserRequest.php | 16 + .../Admin/Users/DisableTwoFactorRequest.php | 18 + .../Api/Admin/Users/GetUserRequest.php | 16 + .../Api/Admin/Users/GetUsersRequest.php | 16 + .../Api/Admin/Users/StoreUserRequest.php | 90 + .../Api/Admin/Users/UpdateUserRequest.php | 28 + app/Http/Requests/Api/ApiRequest.php | 72 + .../Allocations/DeleteAllocationRequest.php | 4 +- .../Allocations/GetAllocationsRequest.php | 4 +- .../Allocations/StoreAllocationRequest.php | 41 +- .../Api/Application/ApplicationApiRequest.php | 68 +- .../{Nests => }/Eggs/GetEggRequest.php | 6 +- .../{Nests => }/Eggs/GetEggsRequest.php | 6 +- .../Locations/DeleteLocationRequest.php | 4 +- .../Locations/GetLocationRequest.php | 6 +- .../Locations/GetLocationsRequest.php | 4 +- .../Locations/StoreLocationRequest.php | 22 +- .../Locations/UpdateLocationRequest.php | 12 +- .../Api/Application/Nests/GetNestsRequest.php | 13 - .../Application/Nodes/DeleteNodeRequest.php | 4 +- .../Nodes/GetDeployableNodesRequest.php | 44 +- .../Nodes/GetNodeConfigurationRequest.php | 15 + .../Api/Application/Nodes/GetNodeRequest.php | 6 +- .../Api/Application/Nodes/GetNodesRequest.php | 4 +- .../Application/Nodes/StoreNodeRequest.php | 68 +- .../Application/Nodes/UpdateNodeRequest.php | 14 +- .../Databases/GetServerDatabaseRequest.php | 4 +- .../Databases/GetServerDatabasesRequest.php | 4 +- .../Databases/ServerDatabaseWriteRequest.php | 2 + .../Databases/StoreServerDatabaseRequest.php | 36 +- .../Servers/GetExternalServerRequest.php | 4 +- .../Application/Servers/GetServerRequest.php | 4 +- .../Application/Servers/GetServersRequest.php | 7 +- .../Servers/ServerWriteRequest.php | 4 +- .../Servers/StoreServerRequest.php | 161 +- .../UpdateServerBuildConfigurationRequest.php | 98 +- .../Servers/UpdateServerDetailsRequest.php | 19 +- .../Servers/UpdateServerStartupRequest.php | 27 +- .../Api/Application/Tags/GetTagRequest.php | 15 + .../Api/Application/Tags/GetTagsRequest.php | 15 + .../Application/Users/DeleteUserRequest.php | 4 +- .../Users/GetExternalUserRequest.php | 4 +- .../Api/Application/Users/GetUsersRequest.php | 4 +- .../Application/Users/StoreUserRequest.php | 49 +- .../Application/Users/UpdateUserRequest.php | 10 +- .../Client/Account/DeleteSSHKeyRequest.php | 20 + .../Account/DisableTwoFactorRequest.php | 20 + .../Client/Account/EnableTwoFactorRequest.php | 21 + .../Api/Client/Account/StoreApiKeyRequest.php | 42 +- .../Api/Client/Account/StoreSSHKeyRequest.php | 70 +- .../Api/Client/Account/UpdateEmailRequest.php | 38 +- .../Client/Account/UpdatePasswordRequest.php | 35 +- .../Requests/Api/Client/ClientApiRequest.php | 19 +- .../Api/Client/GetActivityLogsRequest.php | 15 + .../Client/GetExtensionProgressRequest.php | 14 + .../Requests/Api/Client/GetServersRequest.php | 14 + .../Servers/Backups/DeleteBackupRequest.php | 15 + .../Servers/Backups/DownloadBackupRequest.php | 15 + .../Servers/Backups/ListBackupsRequest.php | 43 + .../Servers/Backups/RestoreBackupRequest.php | 28 +- .../Servers/Backups/StoreBackupRequest.php | 34 +- .../Backups/ToggleBackupLockRequest.php | 15 + .../Servers/Backups/ViewBackupRequest.php | 39 + .../Databases/DeleteDatabaseRequest.php | 6 +- .../Servers/Databases/GetDatabasesRequest.php | 6 +- .../Databases/RotatePasswordRequest.php | 9 +- .../Databases/StoreDatabaseRequest.php | 42 +- .../Servers/Files/ChmodFilesRequest.php | 17 +- .../Servers/Files/CompressFilesRequest.php | 18 +- .../Client/Servers/Files/CopyFileRequest.php | 11 +- .../Servers/Files/CreateFolderRequest.php | 16 +- .../Servers/Files/DecompressFilesRequest.php | 16 +- .../Servers/Files/DeleteFileRequest.php | 15 +- .../Servers/Files/DownloadFileRequest.php | 18 - .../Servers/Files/GetFileContentsRequest.php | 11 +- .../Client/Servers/Files/ListFilesRequest.php | 14 +- .../Client/Servers/Files/PullFileRequest.php | 19 +- .../Servers/Files/RenameFileRequest.php | 19 +- .../Servers/Files/UploadFileRequest.php | 9 +- .../Servers/Files/WriteFileContentRequest.php | 10 +- .../Client/Servers/GetServerLogsRequest.php | 32 + .../Api/Client/Servers/GetServerRequest.php | 7 +- .../Network/DeleteAllocationRequest.php | 9 +- .../Servers/Network/GetNetworkRequest.php | 9 +- .../Servers/Network/NewAllocationRequest.php | 9 +- .../Network/SetPrimaryAllocationRequest.php | 5 + .../Network/UpdateAllocationRequest.php | 18 +- .../Schedules/DeleteScheduleRequest.php | 6 +- .../Servers/Schedules/DeleteTaskRequest.php | 15 + .../Schedules/StoreScheduleRequest.php | 36 +- .../Servers/Schedules/StoreTaskRequest.php | 66 +- .../Schedules/TriggerScheduleRequest.php | 12 +- .../Schedules/UpdateScheduleRequest.php | 6 +- .../Servers/Schedules/ViewScheduleRequest.php | 34 +- .../Api/Client/Servers/SendCommandRequest.php | 13 +- .../Api/Client/Servers/SendPowerRequest.php | 24 +- .../Settings/ReinstallServerRequest.php | 9 +- .../Servers/Settings/RenameServerRequest.php | 23 +- .../Settings/SetDockerImageRequest.php | 24 +- .../Servers/Startup/GetStartupRequest.php | 9 +- .../Startup/UpdateStartupVariableRequest.php | 55 +- .../Servers/Subusers/DeleteSubuserRequest.php | 6 +- .../Servers/Subusers/GetSubuserRequest.php | 6 +- .../Servers/Subusers/StoreSubuserRequest.php | 16 +- .../Servers/Subusers/SubuserRequest.php | 81 +- .../Servers/Subusers/UpdateSubuserRequest.php | 13 +- .../Api/Remote/ActivityEventRequest.php | 76 +- .../AuthenticateWebsocketDetailsRequest.php | 20 - .../Api/Remote/InstallationDataRequest.php | 9 +- .../Requests/Api/Remote/RemoteRequestNode.php | 20 + .../Remote/ReportBackupCompleteRequest.php | 60 +- .../Api/Remote/ReportBackupRestoreRequest.php | 39 + .../Remote/SftpAuthenticationFormRequest.php | 14 +- .../Requests/Auth/LoginCheckpointRequest.php | 16 +- app/Http/Requests/Auth/LoginRequest.php | 21 - .../Requests/Auth/ResetPasswordRequest.php | 12 +- app/Http/Requests/Base/LocaleRequest.php | 7 +- .../Requests/Concerns/FiltersDeployTags.php | 108 + .../Concerns/ParsesServerStartupData.php | 32 + .../Concerns/ValidatesArrayExistence.php | 45 + app/Http/Requests/FrontendUserFormRequest.php | 29 - .../Wings/ServerConfigurationCollection.php | 36 +- app/Http/ViewComposers/AssetComposer.php | 43 +- app/Jobs/RevokeSftpAccessJob.php | 30 +- app/Jobs/Schedule/RunTaskJob.php | 96 +- app/Listeners/AuthenticationListener.php | 16 +- app/Listeners/RevocationListener.php | 17 +- app/Listeners/TwoFactorListener.php | 4 +- app/Models/APILog.php | 30 - app/Models/ActivityLog.php | 133 +- app/Models/ActivityLogSubject.php | 33 +- app/Models/Allocation.php | 199 +- app/Models/ApiKey.php | 269 +- app/Models/Attributes/Identifiable.php | 10 +- app/Models/AuditLog.php | 79 +- app/Models/Backup.php | 86 +- app/Models/Database.php | 79 +- app/Models/DatabaseHost.php | 72 +- app/Models/Egg.php | 467 +- app/Models/EggMount.php | 12 - app/Models/EggVariable.php | 83 +- app/Models/Extension.php | 35 + app/Models/ExtensionSetting.php | 37 + app/Models/Filters/AdminServerFilter.php | 21 +- app/Models/Filters/MultiFieldServerFilter.php | 38 +- app/Models/Location.php | 42 +- app/Models/Model.php | 182 +- app/Models/Mount.php | 115 +- app/Models/MountNode.php | 10 +- app/Models/MountServer.php | 14 +- app/Models/Nest.php | 68 - app/Models/Node.php | 303 +- app/Models/Objects/DeploymentObject.php | 52 + app/Models/Permission.php | 122 +- app/Models/RecoveryToken.php | 13 +- app/Models/Schedule.php | 125 +- app/Models/Server.php | 409 +- app/Models/ServerTransfer.php | 78 +- app/Models/ServerVariable.php | 41 +- app/Models/Session.php | 21 - app/Models/Setting.php | 29 +- app/Models/Subuser.php | 67 +- app/Models/Tag.php | 165 + app/Models/Task.php | 141 +- app/Models/TaskLog.php | 30 - app/Models/Traits/HasAccessTokens.php | 36 +- app/Models/Traits/HasHashid.php | 27 + app/Models/Traits/HasRealtimeIdentifier.php | 61 +- app/Models/User.php | 266 +- app/Models/UserSSHKey.php | 70 +- app/Notifications/AccountCreated.php | 24 +- app/Notifications/AddedToServer.php | 25 +- app/Notifications/MailTested.php | 19 +- app/Notifications/RemovedFromServer.php | 23 +- app/Notifications/SendPasswordReset.php | 16 +- app/Notifications/ServerInstalled.php | 30 +- app/Observers/EggVariableObserver.php | 24 - app/Observers/ServerObserver.php | 32 +- app/Observers/SubuserObserver.php | 19 +- app/Observers/UserObserver.php | 15 +- app/Policies/ServerPolicy.php | 31 +- app/Providers/ActionServiceProvider.php | 325 + app/Providers/ActivityLogServiceProvider.php | 4 +- app/Providers/AppServiceProvider.php | 177 +- app/Providers/AuthServiceProvider.php | 9 +- app/Providers/BackupsServiceProvider.php | 12 +- app/Providers/BladeServiceProvider.php | 9 +- app/Providers/BroadcastServiceProvider.php | 11 +- app/Providers/EventServiceProvider.php | 26 +- app/Providers/ExtensionServiceProvider.php | 89 + app/Providers/HashidsServiceProvider.php | 18 +- app/Providers/RepositoryServiceProvider.php | 67 - app/Providers/RouteServiceProvider.php | 113 - app/Providers/SettingsServiceProvider.php | 52 +- app/Providers/ViewComposerServiceProvider.php | 5 +- .../Eloquent/AllocationRepository.php | 100 - .../Eloquent/ApiKeyRepository.php | 40 - .../Eloquent/BackupRepository.php | 47 - .../Eloquent/DatabaseHostRepository.php | 27 - .../Eloquent/DatabaseRepository.php | 136 - app/Repositories/Eloquent/EggRepository.php | 86 - .../Eloquent/EggVariableRepository.php | 31 - .../Eloquent/EloquentRepository.php | 288 - .../Eloquent/LocationRepository.php | 64 - app/Repositories/Eloquent/MountRepository.php | 57 - app/Repositories/Eloquent/NestRepository.php | 80 - app/Repositories/Eloquent/NodeRepository.php | 152 - .../Eloquent/PermissionRepository.php | 18 - .../Eloquent/RecoveryTokenRepository.php | 13 - .../Eloquent/ScheduleRepository.php | 42 - .../Eloquent/ServerRepository.php | 179 - .../Eloquent/ServerVariableRepository.php | 17 - .../Eloquent/SessionRepository.php | 34 - .../Eloquent/SettingsRepository.php | 75 - .../Eloquent/SubuserRepository.php | 69 - app/Repositories/Eloquent/TaskRepository.php | 44 - app/Repositories/Eloquent/UserRepository.php | 17 - app/Repositories/Repository.php | 102 - .../Wings/DaemonBackupRepository.php | 97 - .../Wings/DaemonCommandRepository.php | 37 - .../Wings/DaemonConfigurationRepository.php | 50 - .../Wings/DaemonFileRepository.php | 301 - .../Wings/DaemonPowerRepository.php | 35 - app/Repositories/Wings/DaemonRepository.php | 65 - .../Wings/DaemonRevocationRepository.php | 27 - .../Wings/DaemonServerRepository.php | 165 - .../Wings/DaemonTransferRepository.php | 37 - app/Rules/Fqdn.php | 83 +- app/Rules/TagSlug.php | 41 + app/Rules/UserEmail.php | 27 + app/Rules/Username.php | 35 +- app/Rules/ValidExtensionSettingColor.php | 25 + app/Rules/ValidExtensionSettings.php | 28 + app/Rules/ValidRuleSet.php | 35 + app/Services/Acl/Api/AdminAcl.php | 64 +- .../Activity/ActivityLogBatchService.php | 13 +- .../Activity/ActivityLogFacetService.php | 48 + .../Activity/ActivityLogQueryService.php | 36 + app/Services/Activity/ActivityLogService.php | 112 +- .../Activity/ActivityLogTargetableService.php | 2 + .../Allocations/AllocationDeletionService.php | 32 - .../Allocations/AssignmentService.php | 109 - .../FindAssignableAllocationService.php | 113 - app/Services/Api/KeyCreationService.php | 52 - app/Services/Backups/BackupListService.php | 23 + .../Backups/InitiateBackupService.php | 127 - app/Services/Daemon/BackupsClient.php | 41 + app/Services/Daemon/DaemonConnection.php | 73 + app/Services/Daemon/DaemonManager.php | 21 + app/Services/Daemon/FilesClient.php | 156 + app/Services/Daemon/NodeClient.php | 42 + app/Services/Daemon/ServerClient.php | 125 + .../Databases/DatabaseHostGateway.php | 104 + .../Databases/DatabaseManagementService.php | 177 - .../Databases/DatabasePasswordService.php | 51 - .../Databases/DeployServerDatabaseService.php | 49 - .../Databases/Hosts/HostCreationService.php | 51 - .../Databases/Hosts/HostDeletionService.php | 35 - .../Databases/Hosts/HostUpdateService.php | 47 - .../Deployment/AllocationSelectionService.php | 56 +- .../Deployment/FindViableNodesService.php | 100 +- app/Services/Deployment/NodeTagGate.php | 84 + app/Services/Eggs/EggCatalogService.php | 54 + app/Services/Eggs/EggConfigurationService.php | 216 +- app/Services/Eggs/EggCreationService.php | 46 - app/Services/Eggs/EggDeletionService.php | 41 - app/Services/Eggs/EggImportData.php | 225 + app/Services/Eggs/EggImportVariable.php | 42 + app/Services/Eggs/EggParserService.php | 88 +- app/Services/Eggs/EggUpdateService.php | 44 - .../Eggs/Scripts/InstallScriptService.php | 41 - .../Eggs/Sharing/EggImporterService.php | 50 - .../Eggs/Sharing/EggUpdateImporterService.php | 50 - .../Variables/VariableCreationService.php | 61 - .../Eggs/Variables/VariableUpdateService.php | 79 - .../Contracts/ManagesExtensionSettings.php | 17 + .../Extensions/ExtensionActionDecorators.php | 107 + .../Extensions/ExtensionActionExtender.php | 29 + .../Extensions/ExtensionAssetPublisher.php | 166 + .../Extensions/ExtensionCompatibility.php | 136 + .../Extensions/ExtensionConsoleRegistry.php | 112 + .../Extensions/ExtensionFailureAttributor.php | 73 + app/Services/Extensions/ExtensionHeadTag.php | 149 + app/Services/Extensions/ExtensionHeadTags.php | 176 + .../Extensions/ExtensionIconCatalog.php | 41 + .../Extensions/ExtensionJobProgress.php | 80 + app/Services/Extensions/ExtensionLock.php | 68 + app/Services/Extensions/ExtensionManager.php | 88 + app/Services/Extensions/ExtensionManifest.php | 164 + .../Extensions/ExtensionManifestValidator.php | 257 + .../Extensions/ExtensionPackageFiles.php | 35 + .../Extensions/ExtensionPackageLocator.php | 88 + .../ExtensionPermissionRegistry.php | 54 + .../Extensions/ExtensionProviderLoader.php | 142 + .../Extensions/ExtensionRegistration.php | 121 + .../Extensions/ExtensionRepository.php | 247 + .../Extensions/ExtensionRuntimeRefresher.php | 20 + .../Extensions/ExtensionSettingDefinition.php | 423 + .../Extensions/ExtensionSettingFiles.php | 238 + .../Extensions/ExtensionSettingValueGuard.php | 160 + app/Services/Extensions/ExtensionSettings.php | 199 + .../ExtensionSettingsDefinition.php | 227 + .../Extensions/ExtensionSettingsRegistry.php | 37 + .../ExtensionStylesheetInspector.php | 154 + .../Scaffolding/ExtensionScaffolder.php | 199 + .../Extensions/Scaffolding/stubs/ci.stub | 21 + .../Scaffolding/stubs/client-index.stub | 10 + .../stubs/client-server-screen.stub | 13 + .../Scaffolding/stubs/client-styles.stub | 4 + .../Scaffolding/stubs/client-test.stub | 12 + .../Scaffolding/stubs/controller.stub | 23 + .../Scaffolding/stubs/externalize-api.stub | 3 + .../Scaffolding/stubs/gitignore.stub | 2 + .../Scaffolding/stubs/openapi.config.stub | 12 + .../Extensions/Scaffolding/stubs/package.stub | 43 + .../Scaffolding/stubs/postcss.config.stub | 1 + .../Scaffolding/stubs/provider.stub | 29 + .../Scaffolding/stubs/readme-frontend.stub | 55 + .../Extensions/Scaffolding/stubs/readme.stub | 22 + .../Scaffolding/stubs/routes-client.stub | 7 + .../Scaffolding/stubs/tsconfig.stub | 15 + .../Scaffolding/stubs/vite.config.stub | 3 + .../Scaffolding/stubs/vitest.config.stub | 8 + app/Services/FilesystemChanges.php | 84 + app/Services/Helpers/AssetHashService.php | 212 +- .../Helpers/SoftwareVersionService.php | 71 +- .../Locations/LocationCreationService.php | 26 - .../Locations/LocationDeletionService.php | 37 - .../Locations/LocationUpdateService.php | 29 - app/Services/Nests/NestCreationService.php | 33 - app/Services/Nests/NestDeletionService.php | 34 - app/Services/Nests/NestUpdateService.php | 30 - app/Services/Nodes/NodeCreationService.php | 33 - app/Services/Nodes/NodeDeletionService.php | 41 - app/Services/Nodes/NodeJWTService.php | 53 +- app/Services/Nodes/NodeUpdateService.php | 80 - .../Schedules/ProcessScheduleService.php | 86 - .../Servers/BuildModificationService.php | 131 - .../Servers/DetailsModificationService.php | 54 - app/Services/Servers/EnvironmentService.php | 94 +- .../Servers/GetUserPermissionsService.php | 7 +- app/Services/Servers/MountListService.php | 20 + .../Servers/ReinstallServerService.php | 35 - .../ServerConfigurationStructureService.php | 73 +- .../Servers/ServerCreationService.php | 216 - .../Servers/ServerDeletionService.php | 87 - app/Services/Servers/ServerFinderService.php | 15 + app/Services/Servers/ServerInstallService.php | 40 + .../Servers/StartupCommandService.php | 20 +- .../Servers/StartupModificationService.php | 88 - .../Servers/SubuserPermissionCatalog.php | 42 + app/Services/Servers/SuspensionService.php | 61 - .../Servers/VariableValidatorService.php | 56 +- .../Subusers/SubuserCreationService.php | 74 - app/Services/Tags/TagBackfiller.php | 222 + app/Services/Tags/TagResolutionService.php | 64 + .../Telemetry/TelemetryCollectionService.php | 107 +- app/Services/Themes/ThemeService.php | 65 + app/Services/Users/ToggleTwoFactorService.php | 89 - app/Services/Users/TwoFactorSetupService.php | 59 - app/Services/Users/UserCreationService.php | 58 - app/Services/Users/UserFinderService.php | 15 + app/Services/Users/UserUpdateService.php | 42 - app/Support/ActivityLogFilters.php | 39 + app/Support/Alerts/AlertsMessageBag.php | 82 + app/Support/DatabaseName.php | 13 + app/Support/JsonEmptyObject.php | 9 + app/Support/JsonValueGuard.php | 318 + app/Support/JsonValueTree.php | 77 + app/Support/ValidationRuleSubset.php | 25 + .../Commands/EnvironmentWriterTrait.php | 29 +- .../Controllers/JavascriptInjection.php | 28 - app/Traits/Helpers/AvailableLanguages.php | 40 +- app/Traits/Helpers/ThrottlesLogins.php | 78 + app/Traits/Services/HasUserLevels.php | 2 + app/Traits/Services/ReturnsUpdatedModels.php | 25 - .../Services/ValidatesValidationRules.php | 32 - .../Api/Admin/ActivityLogTransformer.php | 54 + .../Api/Admin/AllocationTransformer.php | 76 + .../Api/Admin/ApiKeyTransformer.php | 52 + .../Api/Admin/BackupTransformer.php | 33 + .../Api/Admin/BaseAdminTransformer.php | 26 + .../Api/Admin/DatabaseHostTransformer.php | 93 + app/Transformers/Api/Admin/EggTransformer.php | 123 + .../Api/Admin/EggVariableTransformer.php | 38 + .../Api/Admin/LocationTransformer.php | 67 + .../Api/Admin/MountTransformer.php | 88 + .../Api/Admin/NodeTransformer.php | 96 + .../Api/Admin/ServerDatabaseTransformer.php | 57 + .../Api/Admin/ServerTransferTransformer.php | 34 + .../Api/Admin/ServerTransformer.php | 205 + .../Api/Admin/ServerVariableTransformer.php | 29 + .../Api/Admin/SubuserTransformer.php | 30 + app/Transformers/Api/Admin/TagTransformer.php | 77 + .../Api/Admin/UserTransformer.php | 64 + .../Api/Application/AllocationTransformer.php | 28 +- .../Api/Application/BaseTransformer.php | 134 +- .../Application/DatabaseHostTransformer.php | 20 +- .../Api/Application/EggTransformer.php | 124 +- .../Application/EggVariableTransformer.php | 13 +- .../Api/Application/LocationTransformer.php | 25 +- .../Api/Application/NestTransformer.php | 74 - .../Api/Application/NodeTransformer.php | 58 +- .../Application/ServerDatabaseTransformer.php | 38 +- .../Application/ServerTransferTransformer.php | 34 + .../Api/Application/ServerTransformer.php | 124 +- .../Application/ServerVariableTransformer.php | 23 +- .../Api/Application/SubuserTransformer.php | 22 +- .../Api/Application/TagTransformer.php | 93 + .../Api/Application/UserTransformer.php | 18 +- .../Api/Client/AccountTransformer.php | 4 + .../Api/Client/ActivityLogTransformer.php | 126 +- .../Api/Client/AllocationTransformer.php | 15 +- .../Api/Client/ApiKeyTransformer.php | 8 +- .../Api/Client/BackupTransformer.php | 8 + .../Api/Client/BaseClientTransformer.php | 24 +- .../Api/Client/DatabaseTransformer.php | 46 +- .../Api/Client/EggTransformer.php | 5 + .../Api/Client/EggVariableTransformer.php | 12 +- .../Api/Client/FileObjectTransformer.php | 26 +- .../Api/Client/ScheduleTransformer.php | 23 +- .../Api/Client/ServerTransformer.php | 94 +- .../Api/Client/StatsTransformer.php | 28 +- .../Api/Client/SubuserTransformer.php | 13 +- .../Api/Client/TaskTransformer.php | 6 + .../Api/Client/UserSSHKeyTransformer.php | 6 +- .../Api/Client/UserTransformer.php | 8 +- .../Concerns/FormatsActivityLogs.php | 106 + app/Validation/ActivityLogRules.php | 23 + app/Validation/AllocationRules.php | 40 + app/Validation/ApiKeyRules.php | 38 + app/Validation/DatabaseHostRules.php | 25 + app/Validation/DatabaseRules.php | 26 + app/Validation/LocationRules.php | 25 + app/Validation/MountRules.php | 30 + app/Validation/NodeRules.php | 35 + app/Validation/ScheduleRules.php | 31 + app/Validation/ServerRules.php | 44 + app/Validation/TagRules.php | 29 + app/Validation/UserRules.php | 40 + app/Validation/UserSSHKeyRules.php | 67 + app/helpers.php | 35 - artisan | 53 +- babel.config.js | 34 - bootstrap/app.php | 178 +- bootstrap/providers.php | 17 + bootstrap/tests.php | 37 +- composer.json | 99 +- composer.lock | 7209 +++++--- config/activity.php | 2 + config/addons.php | 4 +- config/app.php | 80 +- config/auth.php | 6 +- config/backups.php | 4 +- config/broadcasting.php | 4 +- config/cache.php | 4 +- config/compile.php | 2 + config/cors.php | 4 +- config/database.php | 4 +- config/egg_features/eula.php | 2 + config/extensions.php | 39 + config/filesystems.php | 4 +- config/fractal.php | 6 +- config/hashids.php | 2 + config/hashing.php | 2 + config/http.php | 5 + config/ide-helper.php | 17 +- config/javascript.php | 30 - config/logging.php | 4 +- config/mail.php | 2 + config/prologue/alerts.php | 37 - config/pterodactyl.php | 2 + config/queue.php | 2 + config/recaptcha.php | 2 + config/sanctum.php | 15 +- config/scribe.php | 291 + config/services.php | 2 + config/session.php | 4 +- config/trustedproxy.php | 9 +- config/view.php | 2 + database/Factories/ActivityLogFactory.php | 51 + database/Factories/AllocationFactory.php | 30 +- database/Factories/ApiKeyFactory.php | 25 +- database/Factories/BackupFactory.php | 14 +- database/Factories/DatabaseFactory.php | 25 +- database/Factories/DatabaseHostFactory.php | 19 +- database/Factories/EggFactory.php | 22 +- database/Factories/EggVariableFactory.php | 36 +- database/Factories/LocationFactory.php | 7 +- database/Factories/MountFactory.php | 39 + database/Factories/NestFactory.php | 30 - database/Factories/NodeFactory.php | 23 +- database/Factories/ScheduleFactory.php | 11 +- database/Factories/ServerFactory.php | 48 +- database/Factories/ServerTransferFactory.php | 15 +- database/Factories/SubuserFactory.php | 15 +- database/Factories/TagFactory.php | 51 + database/Factories/TaskFactory.php | 6 +- database/Factories/UserFactory.php | 24 +- database/Factories/UserSSHKeyFactory.php | 8 +- database/Seeders/DatabaseSeeder.php | 5 +- database/Seeders/EggSeeder.php | 67 +- database/Seeders/NestSeeder.php | 108 - ...uire_complete_legacy_migration_history.php | 42 + ..._add_sort_order_to_egg_variables_table.php | 29 + ..._07_06_000001_create_extensions_tables.php | 38 + ...00001_drop_extension_quarantine_column.php | 32 + .../2026_08_20_000001_create_tags_tables.php | 73 + ..._08_20_000002_backfill_tags_from_nests.php | 33 + ...8_20_000003_make_eggs_nest_id_nullable.php | 35 + ..._000004_relax_nest_id_on_servers_table.php | 49 + ...cope_and_secrets_to_extension_settings.php | 38 + ...d_unique_server_user_to_subusers_table.php | 24 + ...016_01_23_195641_add_allocations_table.php | 8 +- .../2016_01_23_195851_add_api_keys.php | 8 +- .../2016_01_23_200044_add_api_permissions.php | 8 +- .../2016_01_23_200159_add_downloads.php | 8 +- ..._01_23_200421_create_failed_jobs_table.php | 8 +- .../2016_01_23_200440_create_jobs_table.php | 8 +- .../2016_01_23_200528_add_locations.php | 8 +- .../{ => old}/2016_01_23_200648_add_nodes.php | 8 +- .../2016_01_23_201433_add_password_resets.php | 8 +- .../2016_01_23_201531_add_permissions.php | 8 +- ...2016_01_23_201649_add_server_variables.php | 8 +- .../2016_01_23_201748_add_servers.php | 8 +- .../2016_01_23_202544_add_service_options.php | 8 +- ...2016_01_23_202731_add_service_varibles.php | 8 +- .../2016_01_23_202943_add_services.php | 8 +- ...016_01_23_203119_create_settings_table.php | 8 +- .../2016_01_23_203150_add_subusers.php | 8 +- .../{ => old}/2016_01_23_203159_add_users.php | 8 +- ...016_01_23_203947_create_sessions_table.php | 8 +- ...01_25_234418_rename_permissions_column.php | 11 +- ...2016_02_07_172148_add_databases_tables.php | 8 +- ...2_07_181319_add_database_servers_table.php | 8 +- ...306_add_service_option_default_startup.php | 10 +- ..._02_20_155318_add_unique_service_field.php | 10 +- .../2016_02_27_163411_add_tasks_table.php | 8 +- .../2016_02_27_163447_add_tasks_log_table.php | 8 +- ...3_18_155649_add_nullable_field_lastrun.php | 10 +- .../2016_08_30_212718_add_ip_alias.php | 10 +- ..._08_30_213301_modify_ip_storage_method.php | 14 +- ...9_01_193520_add_suspension_for_servers.php | 10 +- ...2016_09_01_211924_remove_active_column.php | 10 +- ...09_02_190647_add_sftp_password_storage.php | 10 +- .../2016_09_04_171338_update_jobs_tables.php | 10 +- ..._09_04_172028_update_failed_jobs_table.php | 10 +- ...9_04_182835_create_notifications_table.php | 8 +- ...016_09_07_163017_add_unique_identifier.php | 10 +- ..._09_14_145945_allow_longer_regex_field.php | 10 +- ...6_09_17_194246_add_docker_image_column.php | 12 +- ...9_21_165554_update_servers_column_name.php | 10 +- ..._09_29_213518_rename_double_insurgency.php | 8 +- .../2016_10_07_152117_build_api_log_table.php | 8 +- .../2016_10_14_164802_update_api_keys.php | 10 +- ...16_10_23_181719_update_misnamed_bungee.php | 6 +- ..._10_23_193810_add_foreign_keys_servers.php | 10 +- ...6_10_23_201624_add_foreign_allocations.php | 10 +- ...2016_10_23_202222_add_foreign_api_keys.php | 10 +- ..._23_202703_add_foreign_api_permissions.php | 10 +- ...23_202953_add_foreign_database_servers.php | 10 +- ...016_10_23_203105_add_foreign_databases.php | 10 +- .../2016_10_23_203335_add_foreign_nodes.php | 10 +- ...6_10_23_203522_add_foreign_permissions.php | 10 +- ...23_203857_add_foreign_server_variables.php | 10 +- ..._23_204157_add_foreign_service_options.php | 10 +- ...3_204321_add_foreign_service_variables.php | 10 +- ...2016_10_23_204454_add_foreign_subusers.php | 10 +- .../2016_10_23_204610_add_foreign_tasks.php | 10 +- ...04_000949_add_ark_service_option_fixed.php | 8 +- .../2016_11_11_220649_add_pack_support.php | 8 +- ...6_11_11_231731_set_service_name_unique.php | 10 +- .../2016_11_27_142519_add_pack_column.php | 10 +- ...1_173018_add_configurable_upload_limit.php | 10 +- ...12_02_185206_correct_service_variables.php | 4 +- ...7_01_03_150436_fix_misnamed_option_tag.php | 4 +- ...create_node_configuration_tokens_table.php | 8 +- .../2017_01_12_135449_add_more_user_data.php | 16 +- .../2017_02_02_175548_UpdateColumnNames.php | 10 +- .../2017_02_03_140948_UpdateNodesTable.php | 10 +- .../2017_02_03_155554_RenameColumns.php | 10 +- .../2017_02_05_164123_AdjustColumnNames.php | 10 +- ...64516_AdjustColumnNamesForServicePacks.php | 10 +- ...2_09_174834_SetupPermissionsPivotTable.php | 22 +- ...7_02_10_171858_UpdateAPIKeyColumnNames.php | 10 +- ...3_224254_UpdateNodeConfigTokensColumns.php | 10 +- ...5_212803_DeleteServiceExecutableOption.php | 10 +- ..._10_162934_AddNewServiceOptionsColumns.php | 10 +- ...03_10_173607_MigrateToNewServiceSystem.php | 9 +- ..._ChangeServiceVariablesValidationRules.php | 18 +- ...150648_MoveFunctionsFromFileToDatabase.php | 16 +- ...5631_RenameServicePacksToSingluarPacks.php | 14 +- ...17_03_14_200326_AddLockedStatusToTable.php | 10 +- ...eOrganizeDatabaseServersToDatabaseHost.php | 14 +- ..._03_16_181515_CleanupDatabasesDatabase.php | 10 +- ...2017_03_18_204953_AddForeignKeyToPacks.php | 10 +- ...3_31_221948_AddServerDescriptionColumn.php | 10 +- ..._163232_DropDeletedAtColumnFromServers.php | 10 +- .../2017_04_15_125021_UpgradeTaskSystem.php | 14 +- ...4_20_171943_AddScriptsToServiceOptions.php | 10 +- ...1432_AddServiceScriptTrackingToServers.php | 10 +- ...7_04_27_145300_AddCopyScriptFromColumn.php | 10 +- ...ConnectionOverSSLWithDaemonBehindProxy.php | 10 +- .../2017_05_01_141528_DeleteDownloadTable.php | 8 +- ...01_141559_DeleteNodeConfigurationTable.php | 10 +- ..._06_10_152951_add_external_id_to_users.php | 10 +- ...23_ChangeForeignKeyToBeOnCascadeDelete.php | 10 +- ...eUserPermissionsToDeleteOnUserDeletion.php | 14 +- ...llocationToReferenceNullOnServerDelete.php | 10 +- ...DeletionWhenAServerOrVariableIsDeleted.php | 10 +- ...33_DeleteTaskWhenParentServerIsDeleted.php | 12 +- ...ValuesForDatabaseHostWhenNodeIsDeleted.php | 10 +- ...4_AllowNegativeValuesForOverallocation.php | 10 +- ...SetAllocationUnqiueUsingMultipleFields.php | 10 +- ...adeDeletionWhenAParentServiceIsDeleted.php | 10 +- ...vePackWhenParentServiceOptionIsDeleted.php | 10 +- ...9_RenameTasksTableForStructureRefactor.php | 4 +- ...2017_09_10_225941_CreateSchedulesTable.php | 8 +- ...230309_CreateNewTasksTableForSchedules.php | 8 +- ..._002938_TransferOldTasksToNewScheduler.php | 12 +- ...dPermissionsToPointToNewScheduleSystem.php | 13 +- ...017_09_23_170933_CreateDaemonKeysTable.php | 8 +- ...628_RemoveDaemonSecretFromServersTable.php | 17 +- ...22_RemoveDaemonSecretFromSubusersTable.php | 21 +- ...angeServicesToUseAMoreUniqueIdentifier.php | 16 +- ...ngeToABetterUniqueServiceConfiguration.php | 25 +- ...cadeDeletionWhenServiceOptionIsDeleted.php | 10 +- ...10_06_214026_ServicesToNestsConversion.php | 14 +- ..._214053_ServiceOptionsToEggsConversion.php | 26 +- ...rviceVariablesToEggVariablesConversion.php | 10 +- ..._24_222238_RemoveLegacySFTPInformation.php | 10 +- ...1922_Add2FaLastAuthorizationTimeColumn.php | 22 +- ...122708_MigratePubPrivFormatToSingleKey.php | 34 +- ...84012_DropAllocationsWhenNodeIsDeleted.php | 10 +- ...220426_MigrateSettingsTableToNewFormat.php | 10 +- ...22821_AllowNegativeValuesForServerSwap.php | 10 +- ...1_11_213943_AddApiKeyPermissionColumns.php | 12 +- ...1_13_142012_SetupTableForKeyEncryption.php | 12 +- .../2018_01_13_145209_AddLastUsedAtColumn.php | 14 +- ...02_04_145617_AllowTextInUserExternalId.php | 10 +- ...ove_unique_index_on_external_id_column.php | 10 +- ..._unique_allocation_id_on_servers_table.php | 10 +- ...dd_external_id_column_to_servers_table.php | 10 +- ...152_remove_default_null_value_on_table.php | 10 +- ...fine_unique_index_on_users_external_id.php | 10 +- ...nd_port_limit_columns_to_servers_table.php | 10 +- ..._03_15_124536_add_description_to_nodes.php | 10 +- ..._05_04_123826_add_maintenance_to_nodes.php | 10 +- ...ow_egg_variables_to_have_longer_values.php | 10 +- ...server_variables_to_have_longer_values.php | 10 +- ...2328_set_allocation_limit_default_null.php | 10 +- ...1_fix_unique_index_to_account_for_host.php | 10 +- ..._merge_permissions_table_into_subusers.php | 35 +- ...20_03_22_164814_drop_permissions_table.php | 8 +- ...24_add_threads_column_to_servers_table.php | 10 +- ...2020_04_03_230614_create_backups_table.php | 12 +- ...4_04_131016_add_table_server_transfers.php | 8 +- ...4_store_node_tokens_as_encrypted_value.php | 34 +- ..._17_203438_allow_nullable_descriptions.php | 22 +- ...4_22_055500_add_max_connections_column.php | 10 +- ..._26_111208_add_backup_limit_to_servers.php | 14 +- .../2020_05_20_234655_add_mounts_table.php | 12 +- ...20_05_21_192756_add_mount_server_table.php | 8 +- ...3612_create_user_recovery_tokens_table.php | 8 +- ...01845_add_notes_column_for_allocations.php | 10 +- ...533_add_backup_state_column_to_backups.php | 10 +- ...132500_update_bytes_to_unsigned_bigint.php | 10 +- ...31_modify_checksums_column_for_backups.php | 16 +- ...0_09_13_110007_drop_packs_from_servers.php | 10 +- ...21_drop_packs_from_api_key_permissions.php | 10 +- .../2020_09_13_110047_drop_packs_table.php | 10 +- ...020_09_13_113503_drop_daemon_key_table.php | 10 +- ...ue_database_name_to_account_for_server.php | 14 +- ...move_nullable_from_schedule_name_field.php | 10 +- ..._02_201014_add_features_column_to_eggs.php | 10 +- ...ort_multiple_docker_images_and_updates.php | 14 +- ...uccessful_nullable_in_server_transfers.php | 10 +- ...chived_field_to_server_transfers_table.php | 10 +- ..._24_092449_make_allocation_fields_json.php | 18 +- ..._add_upload_id_column_to_backups_table.php | 10 +- ...53937_add_file_denylist_to_egg_configs.php | 10 +- .../2021_01_13_013420_add_cron_month.php | 10 +- ...1_01_17_102401_create_audit_logs_table.php | 8 +- ...52623_add_generic_server_status_column.php | 14 +- ...26_210502_update_file_denylist_to_json.php | 14 +- ...205021_add_index_for_server_and_action.php | 10 +- ..._23_212657_make_sftp_port_unsigned_int.php | 10 +- ...n_month_field_to_have_value_if_missing.php | 4 +- ...dd_continue_on_failure_option_to_tasks.php | 10 +- ...when_server_online_option_to_schedules.php | 10 +- ...01016_add_support_for_locking_a_backup.php | 10 +- ...21_07_12_013420_remove_userinteraction.php | 6 +- ...7_17_211512_create_user_ssh_keys_table.php | 8 +- ...d_to_default_to_false_on_backups_table.php | 10 +- ...1_add_foreign_keys_to_mount_node_table.php | 12 +- ...add_foreign_keys_to_mount_server_table.php | 12 +- ...21_add_foreign_keys_to_egg_mount_table.php | 12 +- ...022_01_25_030847_drop_google_analytics.php | 4 +- ...migrate_egg_images_array_to_new_format.php | 8 +- ...5_28_135717_create_activity_logs_table.php | 8 +- ...40349_create_activity_log_actors_table.php | 8 +- ...rack_api_key_usage_for_activity_events.php | 15 +- ...force_outgoing_ip_column_to_eggs_table.php | 10 +- ...d_installed_at_column_to_servers_table.php | 10 +- ...937_update_mail_settings_to_new_format.php | 33 +- ...1_add_uuid_column_to_failed_jobs_table.php | 18 +- ...dd_expires_at_column_to_api_keys_table.php | 15 +- ...3_091852_clear_unused_allocation_notes.php | 9 +- database/schema/mariadb-schema.sql | 886 + database/schema/mysql-schema.sql | 470 +- docker-compose.example.yml | 135 +- doctor.config.json | 11 + flake.nix | 6 +- jest.config.js | 28 - openapi-ts.config.ts | 34 + package-lock.json | 6265 +++++++ package.json | 212 +- packages/hello-world/.gitignore | 2 + packages/hello-world/extension.json | 26 + packages/hello-world/package.json | 11 + packages/hello-world/postcss.config.mjs | 1 + .../hello-world/src/client/FileDetails.tsx | 8 + .../hello-world/src/client/FileEditor.tsx | 15 + .../hello-world/src/client/HelloWorldCard.tsx | 58 + .../src/client/HelloWorldScreen.tsx | 18 + .../hello-world/src/client/ServerCard.tsx | 5 + .../hello-world/src/client/SubuserPresets.tsx | 71 + .../hello-world/src/client/examples.spec.tsx | 198 + packages/hello-world/src/client/index.tsx | 24 + packages/hello-world/src/client/styles.css | 10 + packages/hello-world/tsconfig.json | 19 + packages/hello-world/vite.config.mjs | 3 + packages/hello-world/vitest.config.ts | 18 + packages/sdk/README.md | 579 + packages/sdk/api-runtime-stub.mjs | 8 + packages/sdk/icons.json | 1 + packages/sdk/manifest.schema.json | 564 + packages/sdk/openapi.mjs | 39 + packages/sdk/openapi.spec.ts | 135 + packages/sdk/package.json | 59 + packages/sdk/prefix.spec.ts | 86 + packages/sdk/prepack.mjs | 4 + packages/sdk/runtime-stub.mjs | 9 + packages/sdk/slot-coverage.spec.ts | 74 + packages/sdk/theme-tokens.css | 63 + packages/sdk/theme-tokens.spec.ts | 71 + packages/sdk/theme.css | 23 + packages/sdk/theme.spec.ts | 133 + packages/sdk/types-drift.spec.ts | 312 + packages/sdk/types/api.d.ts | 2 + packages/sdk/types/api/account/types.d.ts | 15 + packages/sdk/types/api/admin/users/types.d.ts | 10 + packages/sdk/types/api/extensionTypes.d.ts | 4 + .../sdk/types/api/generated/client.gen.d.ts | 13 + .../api/generated/client/client.gen.d.ts | 3 + .../sdk/types/api/generated/client/index.d.ts | 11 + .../types/api/generated/client/types.gen.d.ts | 88 + .../types/api/generated/client/utils.gen.d.ts | 15 + .../types/api/generated/core/auth.gen.d.ts | 26 + .../generated/core/bodySerializer.gen.d.ts | 26 + .../types/api/generated/core/params.gen.d.ts | 44 + .../generated/core/pathSerializer.gen.d.ts | 34 + .../core/queryKeySerializer.gen.d.ts | 19 + .../generated/core/serverSentEvents.gen.d.ts | 72 + .../types/api/generated/core/types.gen.d.ts | 84 + .../sdk/types/api/generated/types.gen.d.ts | 13448 ++++++++++++++ packages/sdk/types/api/hey-api-runtime.d.ts | 3 + packages/sdk/types/api/http.d.ts | 5 + packages/sdk/types/api/queryClient.d.ts | 3 + .../sdk/types/api/server/queryDomains.d.ts | 4 + packages/sdk/types/api/server/types.d.ts | 2 + packages/sdk/types/api/settings/types.d.ts | 9 + .../sdk/types/components/elements/Button.d.ts | 41 + .../sdk/types/components/elements/Can.d.ts | 10 + .../types/components/elements/ContentBox.d.ts | 9 + .../components/elements/CopyOnClick.d.ts | 10 + .../sdk/types/components/elements/Icon.d.ts | 9 + .../sdk/types/components/elements/Label.d.ts | 8 + .../types/components/elements/NamedIcon.d.ts | 13 + .../components/elements/PageContentBlock.d.ts | 9 + .../types/components/elements/Pagination.d.ts | 28 + .../components/elements/ScreenBlock.d.ts | 27 + .../elements/ServerContentBlock.d.ts | 8 + .../types/components/elements/Spinner.d.ts | 18 + .../components/elements/TitledGreyBox.d.ts | 12 + .../components/elements/alert/Alert.d.ts | 11 + .../components/elements/alert/index.d.ts | 3 + .../elements/dialog/ConfirmationDialog.d.ts | 12 + .../dialog/ConfirmationDialogTrigger.d.ts | 14 + .../components/elements/dialog/Dialog.d.ts | 4 + .../elements/dialog/DialogTrigger.d.ts | 15 + .../components/elements/dialog/context.d.ts | 4 + .../components/elements/dialog/index.d.ts | 18 + .../components/elements/dialog/types.d.ts | 30 + .../elements/dialog/useDialogState.d.ts | 8 + .../elements/dropdown/DropdownMenu.d.ts | 31 + packages/sdk/types/components/form/Form.d.ts | 10 + .../types/components/form/SubmitButton.d.ts | 7 + .../sdk/types/components/form/context.d.ts | 2 + .../sdk/types/components/form/controls.d.ts | 18 + .../sdk/types/components/form/fields.d.ts | 57 + packages/sdk/types/components/form/index.d.ts | 35 + .../sdk/types/components/server/events.d.ts | 21 + .../sdk/types/components/ui/Checkbox.d.ts | 9 + packages/sdk/types/components/ui/Select.d.ts | 42 + packages/sdk/types/components/ui/Switch.d.ts | 18 + packages/sdk/types/components/ui/empty.d.ts | 12 + .../sdk/types/extensions/componentTypes.d.ts | 153 + packages/sdk/types/extensions/context.d.ts | 6 + packages/sdk/types/extensions/registry.d.ts | 223 + .../sdk/types/extensions/resourceContext.d.ts | 17 + packages/sdk/types/extensions/tableTypes.d.ts | 20 + packages/sdk/types/index.d.ts | 2 + .../types/plugins/useNavigationBlocker.d.ts | 22 + .../sdk/types/plugins/usePermissions.d.ts | 3 + packages/sdk/types/sdk/api.d.ts | 10 + packages/sdk/types/sdk/index.d.ts | 111 + packages/sdk/types/sdk/localization.d.ts | 8 + packages/sdk/types/sdk/mutations.d.ts | 51 + packages/sdk/types/sdk/navigation.d.ts | 46 + packages/sdk/types/sdk/progress.d.ts | 11 + packages/sdk/types/sdk/server.d.ts | 34 + packages/sdk/types/sdk/testing.d.ts | 73 + packages/sdk/types/sdk/theme.d.ts | 10 + packages/sdk/types/sdk/ui.d.ts | 30 + packages/sdk/types/testing.d.ts | 2 + packages/sdk/vite.mjs | 89 + packages/sdk/vite.spec.ts | 58 + packages/sdk/vitest-setup.mjs | 9 + packages/sdk/vitest.mjs | 25 + phpstan-rules.neon | 29 + phpstan.neon | 122 +- phpunit.xml | 2 +- pint.json | 56 + postcss.config.js | 21 +- public/index.php | 79 +- public/js/autocomplete.js | 6 - public/js/keyboard.polyfill.js | 121 - public/js/laroute.js | 195 - public/themes/pterodactyl/css/checkbox.css | 232 - public/themes/pterodactyl/css/pterodactyl.css | 855 - public/themes/pterodactyl/css/terminal.css | 105 - .../themes/pterodactyl/js/admin/functions.js | 23 - .../themes/pterodactyl/js/admin/new-server.js | 222 - .../pterodactyl/js/admin/server/transfer.js | 65 - .../pterodactyl/js/plugins/minecraft/eula.js | 65 - public/themes/pterodactyl/vendor/ace/ace.js | 14 - .../vendor/ace/ext-elastic_tabstops_lite.js | 5 - .../vendor/ace/ext-error_marker.js | 5 - .../pterodactyl/vendor/ace/ext-linking.js | 5 - .../pterodactyl/vendor/ace/ext-modelist.js | 5 - .../pterodactyl/vendor/ace/ext-old_ie.js | 5 - .../pterodactyl/vendor/ace/ext-searchbox.js | 5 - .../vendor/ace/ext-settings_menu.js | 5 - .../pterodactyl/vendor/ace/ext-spellcheck.js | 5 - .../pterodactyl/vendor/ace/ext-split.js | 5 - .../vendor/ace/ext-static_highlight.js | 5 - .../pterodactyl/vendor/ace/ext-textarea.js | 5 - .../pterodactyl/vendor/ace/ext-themelist.js | 5 - .../pterodactyl/vendor/ace/ext-whitespace.js | 5 - .../vendor/ace/keybinding-emacs.js | 1 - .../pterodactyl/vendor/ace/keybinding-vim.js | 1 - .../vendor/ace/mode-assembly_x86.js | 1 - .../pterodactyl/vendor/ace/mode-c_cpp.js | 1 - .../pterodactyl/vendor/ace/mode-coffee.js | 1 - .../pterodactyl/vendor/ace/mode-csharp.js | 1 - .../themes/pterodactyl/vendor/ace/mode-css.js | 1 - .../pterodactyl/vendor/ace/mode-golang.js | 1 - .../pterodactyl/vendor/ace/mode-haml.js | 1 - .../pterodactyl/vendor/ace/mode-html.js | 1 - .../themes/pterodactyl/vendor/ace/mode-ini.js | 1 - .../pterodactyl/vendor/ace/mode-java.js | 1 - .../pterodactyl/vendor/ace/mode-javascript.js | 1 - .../pterodactyl/vendor/ace/mode-json.js | 1 - .../pterodactyl/vendor/ace/mode-kotlin.js | 1 - .../themes/pterodactyl/vendor/ace/mode-lua.js | 1 - .../pterodactyl/vendor/ace/mode-markdown.js | 1 - .../pterodactyl/vendor/ace/mode-mysql.js | 1 - .../pterodactyl/vendor/ace/mode-objectivec.js | 1 - .../pterodactyl/vendor/ace/mode-perl.js | 1 - .../themes/pterodactyl/vendor/ace/mode-php.js | 1 - .../pterodactyl/vendor/ace/mode-plain_text.js | 1 - .../pterodactyl/vendor/ace/mode-properties.js | 1 - .../pterodactyl/vendor/ace/mode-python.js | 1 - .../pterodactyl/vendor/ace/mode-ruby.js | 1 - .../pterodactyl/vendor/ace/mode-rust.js | 1 - .../themes/pterodactyl/vendor/ace/mode-sh.js | 1 - .../pterodactyl/vendor/ace/mode-smarty.js | 1 - .../themes/pterodactyl/vendor/ace/mode-sql.js | 1 - .../themes/pterodactyl/vendor/ace/mode-xml.js | 1 - .../pterodactyl/vendor/ace/mode-yaml.js | 1 - .../pterodactyl/vendor/ace/theme-chrome.js | 1 - .../pterodactyl/vendor/ace/worker-css.js | 1 - .../pterodactyl/vendor/ace/worker-html.js | 1 - .../vendor/ace/worker-javascript.js | 1 - .../pterodactyl/vendor/ace/worker-json.js | 1 - .../pterodactyl/vendor/ace/worker-lua.js | 1 - .../pterodactyl/vendor/ace/worker-php.js | 1 - .../pterodactyl/vendor/ace/worker-xml.js | 1 - .../pterodactyl/vendor/adminlte/admin.min.css | 7 - .../vendor/adminlte/adminlte.min.css.map | 140 - .../pterodactyl/vendor/adminlte/app.min.js | 14 - .../vendor/adminlte/colors/skin-blue.min.css | 1 - .../vendor/animate/animate.min.css | 7 - .../themes/pterodactyl/vendor/ansi/ansi_up.js | 335 - .../pterodactyl/vendor/async/async.min.js | 2 - .../pterodactyl/vendor/async/async.min.map | 1 - .../bootstrap-notify/bootstrap-notify.min.js | 2 - .../vendor/bootstrap/bootstrap-theme.min.css | 6 - .../bootstrap/bootstrap-theme.min.css.map | 1 - .../vendor/bootstrap/bootstrap.min.css | 6 - .../vendor/bootstrap/bootstrap.min.css.map | 1 - .../vendor/bootstrap/bootstrap.min.js | 7 - .../pterodactyl/vendor/chartjs/chart.min.js | 14 - .../vendor/fontawesome/animation.min.css | 6 - .../vendor/jquery/date-format.min.js | 2 - .../pterodactyl/vendor/jquery/jquery.js | 10220 ----------- .../pterodactyl/vendor/jquery/jquery.min.js | 4 - .../pterodactyl/vendor/jquery/jquery.min.map | 1 - .../pterodactyl/vendor/lodash/lodash.js | 132 - .../mousewheel/jquery.mousewheel-min.js | 2 - .../vendor/particlesjs/particles.json | 110 - .../vendor/particlesjs/particles.min.js | 9 - .../vendor/select2/select2.full.min.js | 3 - .../vendor/select2/select2.min.css | 1 - .../pterodactyl/vendor/siofu/client.min.js | 15 - .../slimscroll/jquery.slimscroll.min.js | 16 - .../vendor/socketio/socket.io.js.map | 1 - .../vendor/socketio/socket.io.v203.min.js | 3 - .../vendor/sweetalert/sweetalert.min.css | 25 - .../vendor/sweetalert/sweetalert.min.js | 21 - rector.php | 74 + resources/lang/en/activity.php | 106 +- resources/lang/en/admin/nests.php | 26 - resources/lang/en/admin/node.php | 2 + resources/lang/en/admin/server.php | 7 +- resources/lang/en/admin/user.php | 2 + resources/lang/en/auth.php | 2 + resources/lang/en/command/messages.php | 4 +- resources/lang/en/dashboard/account.php | 2 + resources/lang/en/dashboard/index.php | 2 + resources/lang/en/exceptions.php | 15 +- resources/lang/en/pagination.php | 2 + resources/lang/en/passwords.php | 2 + resources/lang/en/server/users.php | 2 + resources/lang/en/strings.php | 2 + resources/lang/en/validation.php | 2 + resources/scripts/TransitionRouter.tsx | 30 - resources/scripts/__mocks__/file.ts | 1 - resources/scripts/api/account/activity.ts | 33 - .../scripts/api/account/activity/queries.ts | 29 + .../api/account/api-keys/queries.spec.tsx | 128 + .../scripts/api/account/api-keys/queries.ts | 80 + resources/scripts/api/account/createApiKey.ts | 19 - resources/scripts/api/account/deleteApiKey.ts | 9 - .../api/account/disableAccountTwoFactor.ts | 11 - .../api/account/enableAccountTwoFactor.ts | 7 - resources/scripts/api/account/getApiKeys.ts | 25 - .../api/account/getTwoFactorTokenData.ts | 15 - .../scripts/api/account/queries.spec.tsx | 170 + resources/scripts/api/account/queries.ts | 75 + .../scripts/api/account/servers/queries.ts | 68 + resources/scripts/api/account/ssh-keys.ts | 32 - .../scripts/api/account/ssh-keys/queries.ts | 84 + .../scripts/api/account/two-factor/queries.ts | 38 + resources/scripts/api/account/types.ts | 15 + .../scripts/api/account/updateAccountEmail.ts | 9 - .../api/account/updateAccountPassword.ts | 19 - resources/scripts/api/activity.ts | 30 + resources/scripts/api/activityFacets.ts | 24 + .../api/admin/activity/queries.spec.tsx | 61 + .../scripts/api/admin/activity/queries.ts | 21 + .../scripts/api/admin/api-keys/queries.ts | 125 + .../scripts/api/admin/completeLists.spec.ts | 121 + .../api/admin/database-hosts/queries.ts | 184 + resources/scripts/api/admin/eggs/catalog.ts | 47 + .../scripts/api/admin/eggs/queries.spec.tsx | 151 + resources/scripts/api/admin/eggs/queries.ts | 304 + .../scripts/api/admin/extensions/queries.ts | 203 + .../scripts/api/admin/languages/queries.ts | 13 + .../scripts/api/admin/locations/queries.ts | 151 + resources/scripts/api/admin/mounts/queries.ts | 273 + .../scripts/api/admin/nodes/invalidation.ts | 32 + resources/scripts/api/admin/nodes/queries.ts | 476 + .../api/admin/servers/queries.spec.tsx | 145 + .../scripts/api/admin/servers/queries.ts | 708 + .../api/admin/settings/queries.spec.tsx | 46 + .../scripts/api/admin/settings/queries.ts | 180 + .../scripts/api/admin/tags/queries.spec.ts | 118 + resources/scripts/api/admin/tags/queries.ts | 148 + resources/scripts/api/admin/users/queries.ts | 171 + resources/scripts/api/admin/users/types.ts | 9 + .../scripts/api/admin/version/queries.ts | 15 + resources/scripts/api/auth/login.ts | 38 - resources/scripts/api/auth/loginCheckpoint.ts | 19 - .../scripts/api/auth/performPasswordReset.ts | 30 - resources/scripts/api/auth/queries.ts | 47 + .../api/auth/requestPasswordResetEmail.ts | 9 - resources/scripts/api/client-meta.d.ts | 9 + resources/scripts/api/definitions/helpers.ts | 55 - resources/scripts/api/definitions/index.d.ts | 34 - .../scripts/api/definitions/user/index.ts | 2 - .../scripts/api/definitions/user/models.d.ts | 35 - .../api/definitions/user/transformers.ts | 50 - resources/scripts/api/extensionProgress.ts | 17 + resources/scripts/api/extensionTypes.ts | 18 + .../generated/@tanstack/react-query.gen.ts | 5758 ++++++ resources/scripts/api/generated/client.gen.ts | 19 + .../api/generated/client/client.gen.ts | 162 + .../scripts/api/generated/client/index.ts | 26 + .../scripts/api/generated/client/types.gen.ts | 170 + .../scripts/api/generated/client/utils.gen.ts | 207 + .../scripts/api/generated/core/auth.gen.ts | 49 + .../api/generated/core/bodySerializer.gen.ts | 83 + .../scripts/api/generated/core/params.gen.ts | 179 + .../api/generated/core/pathSerializer.gen.ts | 172 + .../generated/core/queryKeySerializer.gen.ts | 118 + .../generated/core/serverSentEvents.gen.ts | 243 + .../scripts/api/generated/core/types.gen.ts | 111 + .../scripts/api/generated/core/utils.gen.ts | 141 + resources/scripts/api/generated/index.ts | 5 + resources/scripts/api/generated/sdk.gen.ts | 3213 ++++ resources/scripts/api/generated/types.gen.ts | 15277 ++++++++++++++++ resources/scripts/api/getServers.ts | 26 - resources/scripts/api/getSystemPermissions.ts | 10 - resources/scripts/api/hey-api-runtime.ts | 9 + resources/scripts/api/http.ts | 148 +- resources/scripts/api/interceptors.ts | 16 +- resources/scripts/api/mutationUtils.spec.ts | 75 + resources/scripts/api/mutationUtils.ts | 69 + resources/scripts/api/pagination.spec.ts | 75 + resources/scripts/api/pagination.spec.tsx | 144 + resources/scripts/api/pagination.ts | 59 + resources/scripts/api/queryClient.ts | 12 + resources/scripts/api/queryData.spec.ts | 83 + resources/scripts/api/queryData.ts | 39 + resources/scripts/api/queryKeyGuards.ts | 21 + resources/scripts/api/queryLifecycle.spec.tsx | 185 + resources/scripts/api/queryParameters.spec.ts | 52 + resources/scripts/api/queryParameters.ts | 87 + resources/scripts/api/queryRetry.spec.ts | 98 + resources/scripts/api/queryRetry.ts | 12 + resources/scripts/api/relationships.ts | 13 + resources/scripts/api/resourceQuery.ts | 13 + resources/scripts/api/server/activity.ts | 35 - .../scripts/api/server/activity/queries.ts | 48 + .../api/server/backups/createServerBackup.ts | 19 - .../api/server/backups/deleteBackup.ts | 9 - .../server/backups/getBackupDownloadUrl.ts | 9 - resources/scripts/api/server/backups/index.ts | 7 - .../api/server/backups/queries.spec.tsx | 106 + .../scripts/api/server/backups/queries.ts | 167 + .../server/databases/createServerDatabase.ts | 19 - .../server/databases/deleteServerDatabase.ts | 9 - .../server/databases/getServerDatabases.ts | 31 - .../scripts/api/server/databases/queries.ts | 126 + .../databases/rotateDatabasePassword.ts | 10 - .../scripts/api/server/files/chmodFiles.ts | 14 - .../scripts/api/server/files/compressFiles.ts | 17 - .../scripts/api/server/files/copyFile.ts | 9 - .../api/server/files/createDirectory.ts | 9 - .../api/server/files/decompressFiles.ts | 13 - .../scripts/api/server/files/deleteFiles.ts | 9 - .../api/server/files/getFileContents.ts | 13 - .../api/server/files/getFileDownloadUrl.ts | 9 - .../api/server/files/getFileUploadUrl.ts | 9 - .../scripts/api/server/files/loadDirectory.ts | 25 - .../scripts/api/server/files/queries.spec.tsx | 169 + resources/scripts/api/server/files/queries.ts | 499 + .../scripts/api/server/files/renameFiles.ts | 14 - .../api/server/files/saveFileContents.ts | 10 - resources/scripts/api/server/getServer.ts | 106 - .../api/server/getServerResourceUsage.ts | 33 - .../scripts/api/server/getWebsocketToken.ts | 19 - resources/scripts/api/server/logs/queries.ts | 17 + .../server/network/createServerAllocation.ts | 9 - .../server/network/deleteServerAllocation.ts | 5 - .../scripts/api/server/network/queries.ts | 144 + .../network/setPrimaryServerAllocation.ts | 9 - .../network/setServerAllocationNotes.ts | 9 - resources/scripts/api/server/power/queries.ts | 38 + resources/scripts/api/server/queries.ts | 143 + resources/scripts/api/server/queryDomains.ts | 28 + .../scripts/api/server/reinstallServer.ts | 9 - resources/scripts/api/server/renameServer.ts | 9 - .../schedules/createOrUpdateSchedule.ts | 19 - .../schedules/createOrUpdateScheduleTask.ts | 23 - .../api/server/schedules/deleteSchedule.ts | 9 - .../server/schedules/deleteScheduleTask.ts | 9 - .../api/server/schedules/getServerSchedule.ts | 14 - .../server/schedules/getServerSchedules.ts | 77 - .../scripts/api/server/schedules/queries.ts | 319 + .../schedules/triggerScheduleExecution.ts | 4 - .../api/server/setSelectedDockerImage.ts | 5 - .../api/server/startup/queries.spec.tsx | 163 + .../scripts/api/server/startup/queries.ts | 90 + resources/scripts/api/server/types.d.ts | 29 - resources/scripts/api/server/types.ts | 1 + .../api/server/updateStartupVariable.ts | 9 - .../api/server/users/createOrUpdateSubuser.ts | 18 - .../scripts/api/server/users/deleteSubuser.ts | 9 - .../api/server/users/getServerSubusers.ts | 21 - resources/scripts/api/server/users/queries.ts | 111 + resources/scripts/api/settings/queries.ts | 32 + resources/scripts/api/settings/types.ts | 8 + .../scripts/api/swr/getServerAllocations.ts | 19 - resources/scripts/api/swr/getServerBackups.ts | 30 - resources/scripts/api/swr/getServerStartup.ts | 27 - resources/scripts/api/system/queries.ts | 10 + resources/scripts/api/transformers.ts | 77 - .../scripts/assets/css/GlobalStylesheet.ts | 77 - .../ibm-plex-sans-latin-wght-normal.woff2 | Bin 0 -> 45712 bytes resources/scripts/assets/tailwind.css | 336 +- resources/scripts/bootstrap.ts | 47 + resources/scripts/components/App.tsx | 103 +- resources/scripts/components/Avatar.tsx | 18 +- .../scripts/components/FlashMessageRender.tsx | 30 - resources/scripts/components/MessageBox.tsx | 67 - .../scripts/components/NavigationBar.tsx | 109 +- .../components/admin/AdminContentBlock.tsx | 17 + .../components/admin/AdminListEmpty.spec.tsx | 49 + .../components/admin/AdminListEmpty.tsx | 54 + .../admin/AdminResourceTables.spec.tsx | 163 + .../components/admin/AdminSidebar.spec.tsx | 81 + .../scripts/components/admin/AdminSidebar.tsx | 126 + resources/scripts/components/admin/README.md | 29 + .../admin/activity/ActivityContainer.tsx | 40 + .../components/admin/api/ApiKeyTable.tsx | 123 + .../components/admin/api/ApiKeysContainer.tsx | 155 + .../admin/api/CreateApiKeyButton.tsx | 156 + .../databases/CreateDatabaseHostButton.tsx | 5 + .../databases/CreateDatabaseHostForm.tsx | 122 + .../databases/DatabaseHostDetailContainer.tsx | 312 + .../databases/DatabaseHostNodeSelect.tsx | 44 + .../admin/databases/DatabaseHostTable.tsx | 183 + .../databases/DatabaseHostsContainer.tsx | 157 + .../admin/databases/databaseHostForm.spec.ts | 80 + .../admin/databases/databaseHostForm.ts | 76 + .../components/admin/eggs/CreateEggForm.tsx | 85 + .../admin/eggs/CreateEggVariableButton.tsx | 143 + .../components/admin/eggs/DeleteEggButton.tsx | 96 + .../admin/eggs/EggCatalogContainer.spec.tsx | 151 + .../admin/eggs/EggCatalogContainer.tsx | 255 + .../admin/eggs/EggConfigurationForm.tsx | 237 + .../admin/eggs/EggConfigurationTab.tsx | 69 + .../admin/eggs/EggDetailContainer.tsx | 86 + .../components/admin/eggs/EggFileDialog.tsx | 91 + .../components/admin/eggs/EggScriptTab.tsx | 186 + .../components/admin/eggs/EggTagsTab.tsx | 105 + .../components/admin/eggs/EggVariableBox.tsx | 173 + .../admin/eggs/EggVariablesTab.spec.tsx | 69 + .../components/admin/eggs/EggVariablesTab.tsx | 61 + .../admin/eggs/EggsContainer.spec.tsx | 180 + .../components/admin/eggs/EggsContainer.tsx | 128 + .../components/admin/eggs/ExportEggButton.tsx | 46 + .../components/admin/eggs/ImportEggButton.tsx | 38 + .../admin/eggs/UpdateEggFromFileButton.tsx | 42 + .../scripts/components/admin/eggs/helpers.ts | 125 + .../components/admin/eggs/useEggDetail.ts | 11 + .../admin/extensions/ExtensionsContainer.tsx | 672 + .../admin/extensions/SettingField.spec.tsx | 154 + .../admin/extensions/SettingField.tsx | 373 + .../extensions/SettingsSections.spec.tsx | 86 + .../admin/extensions/SettingsSections.tsx | 78 + .../components/admin/languageOptions.ts | 12 + .../admin/locations/CreateLocationButton.tsx | 100 + .../locations/LocationDetailContainer.tsx | 246 + .../admin/locations/LocationTable.tsx | 150 + .../admin/locations/LocationsContainer.tsx | 156 + .../admin/mounts/AttachEggsModal.tsx | 120 + .../admin/mounts/AttachNodesModal.tsx | 137 + .../admin/mounts/CreateMountButton.tsx | 5 + .../admin/mounts/CreateMountForm.tsx | 59 + .../admin/mounts/MountDetailContainer.tsx | 545 + .../admin/mounts/MountFormFields.tsx | 120 + .../components/admin/mounts/MountTable.tsx | 154 + .../admin/mounts/MountsContainer.tsx | 149 + .../admin/nodes/CreateNodeButton.tsx | 5 + .../components/admin/nodes/CreateNodeForm.tsx | 52 + .../components/admin/nodes/NodeAboutTab.tsx | 161 + .../admin/nodes/NodeAllocationTab.spec.tsx | 130 + .../admin/nodes/NodeAllocationTab.tsx | 571 + .../admin/nodes/NodeConfigurationTab.tsx | 131 + .../admin/nodes/NodeDetailContainer.tsx | 81 + .../components/admin/nodes/NodeFormFields.tsx | 223 + .../components/admin/nodes/NodeServersTab.tsx | 178 + .../admin/nodes/NodeSettingsTab.tsx | 239 + .../admin/nodes/NodeStatusBadge.tsx | 40 + .../components/admin/nodes/NodeTable.spec.tsx | 71 + .../components/admin/nodes/NodeTable.tsx | 296 + .../components/admin/nodes/NodesContainer.tsx | 183 + .../admin/nodes/nodeConfigurationYaml.spec.ts | 110 + .../admin/nodes/nodeConfigurationYaml.ts | 77 + .../components/admin/nodes/nodeForm.spec.ts | 24 + .../components/admin/nodes/nodeForm.ts | 91 + .../components/admin/nodes/useNodeDetail.ts | 13 + .../components/admin/numberInput.spec.ts | 33 + .../scripts/components/admin/numberInput.ts | 15 + .../admin/overview/OverviewContainer.tsx | 90 + .../overview/OverviewVersionCard.spec.tsx | 40 + .../admin/overview/OverviewVersionCard.tsx | 41 + .../admin/servers/CreateServerButton.tsx | 5 + .../servers/CreateServerDatabaseButton.tsx | 146 + .../admin/servers/CreateServerForm.tsx | 632 + .../admin/servers/ServerAboutTab.tsx | 282 + .../admin/servers/ServerBuildTab.tsx | 319 + .../admin/servers/ServerDatabaseRow.tsx | 216 + .../admin/servers/ServerDatabaseTab.tsx | 160 + .../admin/servers/ServerDeleteTab.spec.tsx | 76 + .../admin/servers/ServerDeleteTab.tsx | 186 + .../admin/servers/ServerDetailContainer.tsx | 105 + .../admin/servers/ServerDetailsTab.spec.tsx | 94 + .../admin/servers/ServerDetailsTab.tsx | 206 + .../admin/servers/ServerEditAction.tsx | 20 + .../admin/servers/ServerManageTab.tsx | 272 + .../admin/servers/ServerMountsTab.tsx | 181 + .../admin/servers/ServerStartupTab.spec.tsx | 141 + .../admin/servers/ServerStartupTab.tsx | 349 + .../admin/servers/ServerStatusBadge.tsx | 38 + .../admin/servers/ServerTable.spec.tsx | 35 + .../components/admin/servers/ServerTable.tsx | 239 + .../admin/servers/ServersContainer.tsx | 176 + .../admin/servers/TransferServerModal.tsx | 175 + .../components/admin/servers/helpers.spec.ts | 29 + .../components/admin/servers/helpers.ts | 166 + .../admin/servers/useServerDetail.ts | 18 + .../admin/settings/AdvancedSettingsForm.tsx | 174 + .../admin/settings/GeneralSettingsForm.tsx | 85 + .../admin/settings/MailSettingsForm.tsx | 187 + .../admin/settings/SettingsContainer.tsx | 91 + .../admin/settings/SettingsForms.spec.tsx | 100 + .../admin/settings/SettingsTabButton.tsx | 22 + .../components/admin/tags/CreateTagButton.tsx | 11 + .../components/admin/tags/TagBadge.tsx | 29 + .../components/admin/tags/TagFormDialog.tsx | 147 + .../components/admin/tags/TagTable.tsx | 84 + .../components/admin/tags/TagsContainer.tsx | 155 + .../admin/users/CreateUserButton.tsx | 5 + .../components/admin/users/CreateUserForm.tsx | 71 + .../admin/users/UserDetailContainer.tsx | 403 + .../components/admin/users/UserFormFields.tsx | 166 + .../components/admin/users/UserTable.tsx | 230 + .../components/admin/users/UsersContainer.tsx | 158 + .../auth/ForgotPasswordContainer.tsx | 170 +- .../auth/LoginCheckpointContainer.tsx | 160 +- .../components/auth/LoginContainer.tsx | 188 +- .../components/auth/LoginFormContainer.tsx | 88 +- .../auth/ResetPasswordContainer.tsx | 165 +- .../dashboard/AccountApiContainer.tsx | 125 +- .../components/dashboard/AccountApiTable.tsx | 51 + .../dashboard/AccountOverviewCardGrid.tsx | 6 + .../dashboard/AccountOverviewContainer.tsx | 51 +- .../components/dashboard/ApiKeyModal.tsx | 43 +- .../dashboard/ApiKeyModalContent.tsx | 28 + .../dashboard/DashboardContainer.tsx | 161 +- .../dashboard/SearchServerResult.tsx | 23 + .../components/dashboard/ServerCardView.tsx | 130 + .../components/dashboard/ServerRow.spec.tsx | 65 + .../components/dashboard/ServerRow.tsx | 269 +- .../components/dashboard/ServerRowMetrics.tsx | 11 + .../activity/ActivityLogContainer.tsx | 93 +- .../forms/ConfigureTwoFactorForm.tsx | 35 +- .../dashboard/forms/CreateApiKeyForm.tsx | 129 +- .../dashboard/forms/DisableTOTPDialog.tsx | 82 +- .../dashboard/forms/RecoveryTokensDialog.tsx | 18 +- .../dashboard/forms/SetupTOTPDialog.tsx | 132 +- .../forms/UpdateEmailAddressForm.tsx | 123 +- .../dashboard/forms/UpdatePasswordForm.tsx | 174 +- .../dashboard/search/SearchContainer.tsx | 34 +- .../dashboard/search/SearchModal.tsx | 236 +- .../dashboard/ssh/AccountSSHContainer.tsx | 91 +- .../dashboard/ssh/AccountSSHTable.tsx | 52 + .../dashboard/ssh/CreateSSHKeyForm.tsx | 111 +- .../dashboard/ssh/DeleteSSHKeyButton.tsx | 54 +- .../components/elements/AppToaster.tsx | 38 + .../elements/AuthenticatedRoute.tsx | 16 - .../components/elements/Button.spec.tsx | 52 + .../scripts/components/elements/Button.tsx | 249 +- resources/scripts/components/elements/Can.tsx | 9 +- .../scripts/components/elements/Checkbox.tsx | 45 - .../scripts/components/elements/Code.tsx | 26 +- .../elements/CodemirrorEditor.spec.tsx | 56 + .../components/elements/CodemirrorEditor.tsx | 434 +- .../components/elements/ConfirmationModal.tsx | 37 - .../components/elements/ContentBox.tsx | 14 +- .../components/elements/ContentContainer.tsx | 16 +- .../components/elements/CopyOnClick.spec.tsx | 92 + .../components/elements/CopyOnClick.tsx | 98 +- .../components/elements/DropdownMenu.tsx | 107 - .../elements/ErrorBoundary.spec.tsx | 80 + .../components/elements/ErrorBoundary.tsx | 42 +- .../scripts/components/elements/Fade.tsx | 47 - .../scripts/components/elements/Field.tsx | 48 - .../elements/FormikFieldWrapper.tsx | 30 - .../components/elements/FormikSwitch.tsx | 27 - .../components/elements/GreyRowBox.tsx | 32 +- .../scripts/components/elements/Icon.tsx | 31 +- .../scripts/components/elements/Input.tsx | 88 - .../components/elements/InputError.tsx | 24 - .../components/elements/InputSpinner.tsx | 28 +- .../elements/InvisibleRecaptcha.spec.tsx | 159 + .../elements/InvisibleRecaptcha.tsx | 144 + .../scripts/components/elements/Label.tsx | 27 +- .../elements/LazyCodemirrorEditor.tsx | 23 + .../components/elements/ListToolbar.tsx | 20 + .../scripts/components/elements/Modal.tsx | 149 - .../components/elements/NamedIcon.spec.tsx | 39 + .../scripts/components/elements/NamedIcon.tsx | 85 + .../scripts/components/elements/NewButton.tsx | 45 + .../components/elements/PageContentBlock.tsx | 49 +- .../components/elements/PageHeading.tsx | 22 + .../components/elements/Pagination.tsx | 71 +- .../components/elements/PermissionRoute.tsx | 38 +- .../scripts/components/elements/Portal.tsx | 10 +- .../components/elements/ProgressBar.tsx | 77 +- .../components/elements/ScreenBlock.spec.tsx | 41 + .../components/elements/ScreenBlock.tsx | 56 +- .../scripts/components/elements/Select.tsx | 41 - .../elements/ServerContentBlock.tsx | 15 +- .../scripts/components/elements/Spinner.tsx | 78 +- .../components/elements/SpinnerOverlay.tsx | 37 +- .../components/elements/SubNavigation.tsx | 59 +- .../elements/SubNavigationLayout.tsx | 20 + .../scripts/components/elements/Switch.tsx | 81 - .../components/elements/TitledGreyBox.tsx | 32 +- .../scripts/components/elements/Translate.tsx | 23 +- .../elements/activity/ActivityLogEntry.tsx | 107 +- .../activity/ActivityLogMetaButton.tsx | 60 +- .../activity/ActivityLogView.spec.tsx | 34 + .../elements/activity/ActivityLogView.tsx | 212 + .../elements/activity/style.module.css | 15 - .../components/elements/alert/Alert.tsx | 60 +- .../components/elements/alert/index.ts | 1 + .../components/elements/button/Button.tsx | 48 - .../components/elements/button/index.ts | 2 - .../elements/button/style.module.css | 73 - .../components/elements/button/types.ts | 23 - .../elements/codemirror/languages.spec.ts | 29 + .../elements/codemirror/languages.ts | 86 + .../components/elements/codemirror/layout.ts | 5 + .../dialog/ConfirmationDialog.spec.tsx | 162 + .../elements/dialog/ConfirmationDialog.tsx | 66 +- .../dialog/ConfirmationDialogTrigger.tsx | 59 + .../components/elements/dialog/Dialog.tsx | 207 +- .../elements/dialog/DialogFooter.tsx | 18 +- .../components/elements/dialog/DialogIcon.tsx | 41 +- .../elements/dialog/DialogTrigger.spec.tsx | 77 + .../elements/dialog/DialogTrigger.tsx | 51 + .../components/elements/dialog/context.ts | 9 +- .../components/elements/dialog/index.ts | 6 +- .../elements/dialog/style.module.css | 36 - .../components/elements/dialog/types.d.ts | 15 +- .../elements/dialog/useDialogState.ts | 10 + .../components/elements/dropdown/Dropdown.tsx | 60 - .../elements/dropdown/DropdownButton.tsx | 24 - .../elements/dropdown/DropdownItem.tsx | 42 - .../elements/dropdown/DropdownMenu.tsx | 124 + .../components/elements/dropdown/index.ts | 2 - .../elements/dropdown/style.module.css | 58 - .../components/elements/iconCatalog.ts | 14 + .../components/elements/inputs/Checkbox.tsx | 14 - .../components/elements/inputs/InputField.tsx | 28 - .../components/elements/inputs/index.ts | 13 - .../elements/inputs/styles.module.css | 25 - .../elements/table/DataTable.spec.tsx | 144 + .../components/elements/table/DataTable.tsx | 111 + .../elements/table/DataTableColumnHeader.tsx | 48 + .../elements/table/DataTablePagination.tsx | 94 + .../elements/table/PaginationFooter.spec.tsx | 78 + .../elements/table/PaginationFooter.tsx | 92 +- .../elements/table/RowActions.spec.tsx | 120 + .../components/elements/table/RowActions.tsx | 111 + .../elements/tooltip/Tooltip.spec.tsx | 64 + .../components/elements/tooltip/Tooltip.tsx | 96 +- .../elements/transitions/FadeTransition.tsx | 33 - .../components/elements/transitions/index.ts | 8 - resources/scripts/components/form/Form.tsx | 22 + .../scripts/components/form/SubmitButton.tsx | 20 + resources/scripts/components/form/context.ts | 3 + .../scripts/components/form/controls.spec.tsx | 33 + .../scripts/components/form/controls.tsx | 92 + resources/scripts/components/form/errors.ts | 23 + .../scripts/components/form/fields.spec.tsx | 93 + resources/scripts/components/form/fields.tsx | 321 + resources/scripts/components/form/index.ts | 57 + resources/scripts/components/history.ts | 3 - .../server/ConflictStateRenderer.tsx | 101 +- .../server/InstallListener.spec.tsx | 43 + .../components/server/InstallListener.tsx | 40 +- .../server/ServerActivityLogContainer.tsx | 96 +- .../server/TransferListener.spec.tsx | 67 + .../components/server/TransferListener.tsx | 51 +- .../components/server/UptimeDuration.tsx | 6 +- .../server/WebsocketHandler.spec.tsx | 65 + .../components/server/WebsocketHandler.tsx | 265 +- .../server/backups/BackupContainer.tsx | 195 +- .../server/backups/BackupContextMenu.tsx | 224 +- .../components/server/backups/BackupRow.tsx | 102 - .../components/server/backups/BackupTable.tsx | 85 + .../server/backups/CreateBackupButton.tsx | 187 +- .../server/backups/backupCompletion.spec.ts | 108 + .../server/backups/backupCompletion.ts | 66 + .../components/server/console/AreaChart.tsx | 157 + .../components/server/console/ChartBlock.tsx | 24 +- .../components/server/console/Console.tsx | 279 +- .../server/console/PowerButtons.tsx | 90 +- .../server/console/ServerConsoleContainer.tsx | 40 +- .../server/console/ServerDetailsBlock.tsx | 105 +- .../components/server/console/StatBlock.tsx | 66 +- .../components/server/console/StatGraphs.tsx | 126 +- .../components/server/console/chart.spec.tsx | 99 + .../components/server/console/chart.ts | 225 +- .../components/server/console/stats.ts | 41 + .../server/console/style.module.css | 63 - .../components/server/console/types.ts | 6 + .../console/useConsoleCommandHistory.ts | 37 + .../console/useConsoleSocketLogs.spec.tsx | 92 + .../server/console/useConsoleSocketLogs.ts | 100 + .../server/console/useTerminal.spec.tsx | 148 + .../components/server/console/useTerminal.ts | 194 + .../server/databases/CreateDatabaseButton.tsx | 206 +- .../server/databases/DatabaseRow.tsx | 180 - .../server/databases/DatabaseTable.tsx | 228 + .../server/databases/DatabasesContainer.tsx | 128 +- .../server/databases/RotatePasswordButton.tsx | 41 +- resources/scripts/components/server/events.ts | 1 + .../components/server/features/Features.tsx | 15 +- .../server/features/GSLTokenModalFeature.tsx | 154 +- .../features/HytaleOauthRequireFeature.tsx | 72 +- .../features/JavaVersionModalFeature.tsx | 111 +- .../server/features/PIDLimitModalFeature.tsx | 115 +- .../server/features/SteamDiskSpaceFeature.tsx | 83 +- .../server/features/eula/EulaModalFeature.tsx | 92 +- .../server/features/hytaleOauth.spec.ts | 26 + .../components/server/features/hytaleOauth.ts | 22 + .../components/server/features/index.ts | 13 +- .../features/useConsolePatternTrigger.ts | 50 + .../server/files/ChmodFileModal.tsx | 104 +- .../server/files/FileActionItems.tsx | 82 + .../server/files/FileDetailsView.tsx | 61 + .../server/files/FileDropdownMenu.tsx | 197 - .../server/files/FileEditContainer.spec.tsx | 291 + .../server/files/FileEditContainer.tsx | 311 +- .../server/files/FileEditorView.tsx | 109 + .../server/files/FileManagerBreadcrumbs.tsx | 69 +- .../files/FileManagerContainer.spec.tsx | 258 + .../server/files/FileManagerContainer.tsx | 174 +- .../server/files/FileManagerStatus.tsx | 116 +- .../server/files/FileManagerView.tsx | 135 + .../components/server/files/FileNameModal.tsx | 78 +- .../server/files/FileObjectRow.spec.tsx | 111 + .../components/server/files/FileObjectRow.tsx | 169 +- .../server/files/MassActionsBar.tsx | 153 +- .../server/files/NewDirectoryButton.tsx | 168 +- .../server/files/RenameFileModal.tsx | 131 +- .../server/files/SelectFileCheckbox.tsx | 48 +- .../components/server/files/UploadButton.tsx | 123 +- .../components/server/files/style.module.css | 28 - .../server/files/useFileActions.tsx | 149 + .../files/useFileManagerExtensionData.ts | 8 + .../server/files/useFileManagerModel.ts | 207 + .../server/files/useFileUploader.ts | 68 + .../server/network/AllocationRow.tsx | 119 - .../server/network/AllocationTable.spec.tsx | 95 + .../server/network/AllocationTable.tsx | 108 + .../server/network/DeleteAllocationButton.tsx | 71 +- .../server/network/NetworkContainer.tsx | 127 +- .../server/schedules/DeleteScheduleButton.tsx | 76 +- .../server/schedules/EditScheduleModal.tsx | 242 +- .../server/schedules/NewTaskButton.tsx | 30 +- .../server/schedules/RunScheduleButton.tsx | 47 +- .../schedules/ScheduleCheatsheetCards.tsx | 146 +- .../server/schedules/ScheduleContainer.tsx | 126 +- .../server/schedules/ScheduleCronRow.tsx | 23 +- .../schedules/ScheduleEditContainer.tsx | 296 +- .../server/schedules/ScheduleRow.tsx | 42 - .../server/schedules/ScheduleTable.tsx | 86 + .../server/schedules/ScheduleTaskRow.tsx | 143 - .../server/schedules/ScheduleTaskTable.tsx | 126 + .../server/schedules/TaskDetailsModal.tsx | 335 +- .../server/settings/ReinstallServerBox.tsx | 85 +- .../server/settings/RenameServerBox.tsx | 106 +- .../server/settings/SettingsContainer.tsx | 66 +- .../server/startup/StartupContainer.tsx | 175 +- .../server/startup/VariableBox.spec.tsx | 69 + .../components/server/startup/VariableBox.tsx | 140 +- .../components/server/transfer.spec.ts | 37 + .../scripts/components/server/transfer.ts | 22 + .../server/users/AddSubuserButton.tsx | 18 +- .../server/users/CreateSubuserContainer.tsx | 40 + .../server/users/EditSubuserModal.tsx | 373 +- .../components/server/users/PermissionRow.tsx | 72 +- .../server/users/PermissionRowContainer.tsx | 22 + .../server/users/PermissionTitleBox.tsx | 52 +- .../server/users/RemoveSubuserButton.tsx | 85 +- .../components/server/users/SubuserTable.tsx | 74 + .../components/server/users/UserRow.tsx | 66 - .../server/users/UsersContainer.tsx | 119 +- .../server/users/permissionSelection.spec.ts | 58 + .../server/users/permissionSelection.ts | 36 + .../scripts/components/ui/Checkbox.spec.tsx | 32 + resources/scripts/components/ui/Checkbox.tsx | 42 + .../scripts/components/ui/Select.spec.tsx | 54 + resources/scripts/components/ui/Select.tsx | 561 + resources/scripts/components/ui/Switch.tsx | 99 + .../scripts/components/ui/empty.spec.tsx | 60 + resources/scripts/components/ui/empty.tsx | 90 + resources/scripts/components/ui/styles.ts | 5 + resources/scripts/components/ui/typography.ts | 4 + resources/scripts/context/ModalContext.ts | 21 - resources/scripts/easy-peasy.d.ts | 10 - .../scripts/ext-runtime/react-dom-client.ts | 3 + resources/scripts/ext-runtime/react-dom.ts | 16 + .../scripts/ext-runtime/react-jsx-runtime.ts | 2 + resources/scripts/ext-runtime/react.ts | 42 + .../ext-runtime/tanstack-react-query.ts | 1 + .../scripts/extensions/ComponentView.spec.tsx | 254 + .../scripts/extensions/ComponentView.tsx | 58 + .../scripts/extensions/ExtensionBoundary.tsx | 41 + .../scripts/extensions/ExtensionMount.tsx | 119 + .../scripts/extensions/NavigationLabel.tsx | 18 + .../extensions/ResourceExtensionTabs.tsx | 19 + resources/scripts/extensions/Slot.spec.tsx | 171 + resources/scripts/extensions/Slot.tsx | 37 + .../scripts/extensions/componentSession.tsx | 133 + .../scripts/extensions/componentTypes.ts | 171 + resources/scripts/extensions/context.spec.tsx | 103 + resources/scripts/extensions/context.ts | 28 + .../scripts/extensions/development.spec.ts | 56 + resources/scripts/extensions/development.ts | 60 + resources/scripts/extensions/loader.spec.ts | 355 + resources/scripts/extensions/loader.ts | 164 + .../scripts/extensions/nativeForm.spec.tsx | 98 + resources/scripts/extensions/registry.spec.ts | 309 + resources/scripts/extensions/registry.ts | 766 + .../scripts/extensions/resourceContext.ts | 14 + resources/scripts/extensions/screen.spec.tsx | 173 + resources/scripts/extensions/screen.tsx | 65 + .../extensions/screenNavigation.spec.tsx | 357 + .../scripts/extensions/screenNavigation.tsx | 156 + resources/scripts/extensions/tableColumns.tsx | 36 + resources/scripts/extensions/tableTypes.ts | 18 + resources/scripts/helpers.spec.ts | 42 + resources/scripts/helpers.ts | 19 +- .../scripts/hoc/RequireServerPermission.tsx | 22 - resources/scripts/hoc/asDialog.tsx | 23 - resources/scripts/hoc/asModal.tsx | 101 - resources/scripts/i18n.spec.ts | 67 + resources/scripts/i18n.ts | 45 +- resources/scripts/index.tsx | 28 +- resources/scripts/lib/clipboard.ts | 35 + resources/scripts/lib/cn.spec.ts | 57 + resources/scripts/lib/cn.ts | 42 + resources/scripts/lib/databases.spec.ts | 13 + resources/scripts/lib/databases.ts | 22 + resources/scripts/lib/dayjs.ts | 9 + resources/scripts/lib/fileDrafts.spec.ts | 41 + resources/scripts/lib/fileDrafts.ts | 23 + resources/scripts/lib/formatters.spec.ts | 1 + resources/scripts/lib/formatters.ts | 11 +- resources/scripts/lib/helpers.spec.ts | 1 + resources/scripts/lib/helpers.ts | 11 +- resources/scripts/lib/objects.spec.ts | 1 + resources/scripts/lib/objects.ts | 37 +- resources/scripts/lib/serverStatus.spec.ts | 20 + resources/scripts/lib/serverStatus.ts | 10 + resources/scripts/lib/strings.spec.ts | 8 +- resources/scripts/lib/strings.ts | 2 +- resources/scripts/lib/theme.spec.ts | 151 + resources/scripts/lib/theme.ts | 106 + resources/scripts/macros.d.ts | 29 - resources/scripts/plugins/Websocket.spec.ts | 267 + resources/scripts/plugins/Websocket.ts | 296 +- .../plugins/XtermScrollDownHelperAddon.ts | 69 - resources/scripts/plugins/notifications.ts | 25 + .../plugins/useDebouncedCallback.spec.ts | 80 + .../scripts/plugins/useDebouncedCallback.ts | 50 + .../scripts/plugins/useDebouncedValue.ts | 15 + .../scripts/plugins/useDeepCompareEffect.ts | 5 - .../scripts/plugins/useDeepCompareMemo.ts | 5 - resources/scripts/plugins/useDeepMemoize.ts | 12 - resources/scripts/plugins/useEventListener.ts | 28 +- .../scripts/plugins/useFileManagerSwr.ts | 22 - .../scripts/plugins/useFilteredObject.ts | 22 - resources/scripts/plugins/useFlash.ts | 26 - resources/scripts/plugins/useLocationHash.ts | 32 - .../plugins/useNavigationBlocker.spec.tsx | 122 + .../scripts/plugins/useNavigationBlocker.ts | 66 + .../scripts/plugins/usePermissions.spec.ts | 20 + resources/scripts/plugins/usePermissions.ts | 35 +- .../scripts/plugins/usePersistedState.ts | 81 +- resources/scripts/plugins/useSWRKey.ts | 33 - .../scripts/plugins/useWebsocketEvent.ts | 11 +- resources/scripts/router/NavLink.tsx | 16 + resources/scripts/router/RootNotFound.ts | 6 + resources/scripts/router/RouteError.spec.tsx | 98 + resources/scripts/router/RouteError.tsx | 54 + .../scripts/router/layouts/AccountLayout.tsx | 32 + .../scripts/router/layouts/AdminLayout.tsx | 13 + .../scripts/router/layouts/AuthLayout.tsx | 9 + .../router/layouts/AuthenticatedLayout.tsx | 11 + .../scripts/router/layouts/RootLayout.tsx | 13 + .../scripts/router/layouts/ServerLayout.tsx | 117 + resources/scripts/router/nav.ts | 45 + resources/scripts/router/params.spec.ts | 29 + resources/scripts/router/params.ts | 38 + resources/scripts/router/routeSlots.tsx | 46 + resources/scripts/router/routeTree.spec.ts | 211 + resources/scripts/router/routeTree.ts | 1212 ++ resources/scripts/router/router.tsx | 34 + resources/scripts/router/search.spec.ts | 89 + resources/scripts/router/search.ts | 246 + resources/scripts/router/searchHooks.spec.tsx | 44 + resources/scripts/router/serverScreen.ts | 46 + resources/scripts/router/view-transitions.css | 35 + .../scripts/routers/AuthenticationRouter.tsx | 29 - resources/scripts/routers/DashboardRouter.tsx | 50 - resources/scripts/routers/ServerRouter.tsx | 128 - resources/scripts/routers/routes.ts | 144 - resources/scripts/sdk/api.ts | 20 + resources/scripts/sdk/index.spec.ts | 14 + resources/scripts/sdk/index.ts | 221 + resources/scripts/sdk/localization.spec.tsx | 31 + resources/scripts/sdk/localization.ts | 19 + .../scripts/sdk/loginCheckpoint.spec.tsx | 31 + resources/scripts/sdk/mutations.spec.tsx | 64 + resources/scripts/sdk/mutations.ts | 126 + resources/scripts/sdk/navigation.spec.ts | 47 + resources/scripts/sdk/navigation.tsx | 122 + resources/scripts/sdk/progress.spec.tsx | 87 + resources/scripts/sdk/progress.ts | 37 + resources/scripts/sdk/queryOptions.ts | 18 + resources/scripts/sdk/server.spec.ts | 191 + resources/scripts/sdk/server.ts | 108 + resources/scripts/sdk/testing.spec.tsx | 93 + resources/scripts/sdk/testing.tsx | 439 + resources/scripts/sdk/theme.ts | 19 + resources/scripts/sdk/ui.tsx | 52 + resources/scripts/setup-tests.ts | 11 +- resources/scripts/state/flashes.ts | 54 - resources/scripts/state/hooks.ts | 9 - resources/scripts/state/httpProgress.spec.tsx | 37 + resources/scripts/state/httpProgress.ts | 46 + resources/scripts/state/index.ts | 24 - resources/scripts/state/permissions.ts | 31 - resources/scripts/state/progress.ts | 33 - resources/scripts/state/server/context.ts | 5 + resources/scripts/state/server/databases.ts | 31 - resources/scripts/state/server/files.spec.tsx | 42 + resources/scripts/state/server/files.ts | 183 +- resources/scripts/state/server/index.ts | 123 - resources/scripts/state/server/index.tsx | 118 + resources/scripts/state/server/schedules.ts | 31 - resources/scripts/state/server/socket.ts | 44 +- resources/scripts/state/server/subusers.ts | 81 - resources/scripts/state/server/types.ts | 5 + resources/scripts/state/settings.ts | 25 - resources/scripts/state/user.ts | 40 - resources/scripts/theme.ts | 10 - resources/scripts/vite-env.d.ts | 6 + resources/views/admin/api/index.blade.php | 113 - resources/views/admin/api/new.blade.php | 70 - .../views/admin/databases/index.blade.php | 130 - .../views/admin/databases/view.blade.php | 135 - resources/views/admin/eggs/new.blade.php | 178 - resources/views/admin/eggs/scripts.blade.php | 118 - .../views/admin/eggs/variables.blade.php | 156 - resources/views/admin/eggs/view.blade.php | 222 - resources/views/admin/index.blade.php | 53 - .../views/admin/locations/index.blade.php | 81 - .../views/admin/locations/view.blade.php | 69 - resources/views/admin/mounts/index.blade.php | 144 - resources/views/admin/mounts/view.blade.php | 314 - resources/views/admin/nests/index.blade.php | 102 - resources/views/admin/nests/new.blade.php | 47 - resources/views/admin/nests/view.blade.php | 117 - resources/views/admin/nodes/index.blade.php | 107 - resources/views/admin/nodes/new.blade.php | 175 - .../admin/nodes/view/allocation.blade.php | 356 - .../admin/nodes/view/configuration.blade.php | 88 - .../views/admin/nodes/view/index.blade.php | 170 - .../views/admin/nodes/view/servers.blade.php | 63 - .../views/admin/nodes/view/settings.blade.php | 240 - resources/views/admin/servers/index.blade.php | 89 - resources/views/admin/servers/new.blade.php | 395 - .../servers/partials/navigation.blade.php | 40 - .../views/admin/servers/view/build.blade.php | 187 - .../admin/servers/view/database.blade.php | 169 - .../views/admin/servers/view/delete.blade.php | 91 - .../admin/servers/view/details.blade.php | 121 - .../views/admin/servers/view/index.blade.php | 178 - .../views/admin/servers/view/manage.blade.php | 202 - .../views/admin/servers/view/mounts.blade.php | 78 - .../admin/servers/view/startup.blade.php | 192 - .../views/admin/settings/advanced.blade.php | 127 - .../views/admin/settings/index.blade.php | 75 - resources/views/admin/settings/mail.blade.php | 202 - resources/views/admin/users/index.blade.php | 79 - resources/views/admin/users/new.blade.php | 128 - resources/views/admin/users/view.blade.php | 123 - resources/views/layouts/admin.blade.php | 214 - resources/views/layouts/scripts.blade.php | 1 - .../partials/admin/settings/nav.blade.php | 16 - .../partials/admin/settings/notice.blade.php | 11 - .../schedules/task-template.blade.php | 42 - resources/views/templates/auth/core.blade.php | 2 +- resources/views/templates/base/core.blade.php | 2 +- resources/views/templates/wrapper.blade.php | 53 +- routes/admin.php | 228 - routes/api-admin.php | 452 + routes/api-application.php | 151 +- routes/api-client.php | 199 +- routes/api-remote.php | 38 +- routes/auth.php | 29 +- routes/base.php | 32 +- scripts/build-sdk-testing.mjs | 22 + scripts/check-extension-runtime.mjs | 84 + scripts/externalize-extension-api-runtime.mjs | 11 + scripts/generate-extension-api.mjs | 25 + scripts/generate-extension-openapi.php | 147 + scripts/generate-sdk-icons.mjs | 23 + scripts/generate-sdk-types.mjs | 128 + shell.nix | 3 +- tailwind.config.js | 51 - tests/Architecture/OpenApiContractTest.php | 175 + tests/Assertions/AssertsActivityLogged.php | 12 +- .../MiddlewareAttributeAssertionsTrait.php | 6 +- tests/Fixtures/assets/manifest.json | 62 + tests/Fixtures/keys/x509-certificate.pem | 16 + .../Admin/Activity/ActivityControllerTest.php | 190 + .../Api/Admin/AdminApiIntegrationTestCase.php | 56 + .../Api/Admin/ApiKeyAccessTest.php | 54 + .../Admin/ApiKeys/ApiKeyControllerTest.php | 108 + .../DatabaseHostControllerTest.php | 169 + .../Admin/Eggs/EggCatalogControllerTest.php | 190 + .../Api/Admin/Eggs/EggControllerTest.php | 40 + .../Api/Admin/Eggs/EggCrudControllerTest.php | 125 + .../Admin/Eggs/EggScriptControllerTest.php | 70 + .../Api/Admin/Eggs/EggShareControllerTest.php | 85 + .../Admin/Eggs/EggVariableControllerTest.php | 217 + .../Extensions/ExtensionControllerTest.php | 322 + tests/Integration/Api/Admin/IncludesTest.php | 147 + .../Locations/LocationControllerTest.php | 120 + .../Api/Admin/Mounts/MountAttachmentTest.php | 208 + .../Api/Admin/Mounts/MountControllerTest.php | 87 + .../Admin/Nodes/AllocationControllerTest.php | 213 + .../Api/Admin/Nodes/NodeControllerTest.php | 126 + .../Nodes/NodeIntrospectionControllerTest.php | 96 + .../Api/Admin/PaginationValidationTest.php | 58 + .../Admin/Servers/DatabaseControllerTest.php | 152 + .../Servers/ServerBackupControllerTest.php | 58 + .../Admin/Servers/ServerControllerTest.php | 149 + .../Servers/ServerInstallControllerTest.php | 39 + .../Admin/Servers/ServerManagementTest.php | 136 + .../Servers/ServerMountControllerTest.php | 81 + .../Servers/ServerTransferControllerTest.php | 133 + .../Admin/Settings/SettingsControllerTest.php | 95 + .../Api/Admin/Tags/TagControllerTest.php | 84 + .../Api/Admin/Users/UserControllerTest.php | 161 + .../Api/Admin/VersionControllerTest.php | 34 + .../ApplicationApiIntegrationTestCase.php | 37 +- .../Application/Eggs/EggControllerTest.php | 93 + .../Location/LocationControllerTest.php | 339 +- .../Application/Nests/EggControllerTest.php | 123 - .../Application/Nests/NestControllerTest.php | 127 - .../Nodes/NodeController/UpdateNodeTest.php | 65 +- .../Application/Nodes/NodeControllerTest.php | 33 + .../Api/Application/Nodes/NodeCrudTest.php | 85 + .../Nodes/NodeDeploymentControllerTest.php | 20 + .../Application/PaginationValidationTest.php | 23 + .../Servers/ServerControllerTest.php | 174 + .../Servers/ServerManagementTest.php | 152 + .../Application/Tags/TagControllerTest.php | 75 + .../Users/ExternalUserControllerTest.php | 86 +- .../Application/Users/UserControllerTest.php | 413 +- .../Api/Client/AccountControllerTest.php | 337 +- .../Api/Client/ActivityLogControllerTest.php | 208 + .../Api/Client/ApiKeyControllerTest.php | 363 +- .../Client/ClientApiIntegrationTestCase.php | 54 +- .../Api/Client/ClientControllerTest.php | 533 +- .../ExtensionProgressControllerTest.php | 58 + .../Api/Client/SSHKeyControllerTest.php | 214 +- .../AllocationAuthorizationTest.php | 87 +- .../Allocation/CreateNewAllocationTest.php | 135 +- .../Allocation/DeleteAllocationTest.php | 145 +- .../Server/Backup/BackupAuthorizationTest.php | 92 +- .../Server/Backup/BackupControllerTest.php | 102 + .../Client/Server/Backup/DeleteBackupTest.php | 83 +- .../Client/Server/CommandControllerTest.php | 122 +- .../Database/DatabaseAuthorizationTest.php | 106 +- .../Database/DatabaseControllerTest.php | 50 + .../Client/Server/Files/CompressFilesTest.php | 72 +- .../Server/Files/FileControllerTest.php | 125 + .../Api/Client/Server/GetServerTest.php | 33 + .../Api/Client/Server/LogControllerTest.php | 81 + .../NetworkAllocationControllerTest.php | 201 +- .../Api/Client/Server/PowerControllerTest.php | 131 +- .../ResourceUtilizationControllerTest.php | 86 +- .../Schedule/CreateServerScheduleTest.php | 140 +- .../Schedule/DeleteServerScheduleTest.php | 110 +- .../Server/Schedule/ExecuteScheduleTest.php | 96 +- .../Schedule/GetServerSchedulesTest.php | 160 +- .../Schedule/ScheduleAuthorizationTest.php | 107 +- .../Schedule/UpdateServerScheduleTest.php | 171 +- .../CreateServerScheduleTaskTest.php | 269 +- .../ScheduleTask/DeleteScheduleTaskTest.php | 117 +- .../ScheduleTask/UpdateScheduleTaskTest.php | 78 + .../Client/Server/SettingsControllerTest.php | 193 +- .../Startup/GetStartupAndVariablesTest.php | 98 +- .../Startup/UpdateStartupVariableTest.php | 225 +- .../Subuser/CreateServerSubuserTest.php | 248 +- .../Server/Subuser/DeleteSubuserTest.php | 79 +- .../ExtensionSubuserPermissionsTest.php | 35 + .../Client/Server/Subuser/GetSubusersTest.php | 27 + .../Subuser/SubuserAuthorizationTest.php | 92 +- .../Server/Subuser/UpdateSubuserTest.php | 193 +- .../Client/Server/WebsocketControllerTest.php | 186 +- .../Api/Client/TwoFactorControllerTest.php | 292 +- .../ActivityProcessingControllerTest.php | 73 + .../Api/Remote/RemoteServersApiTest.php | 179 + .../Remote/ServerTransferControllerTest.php | 172 +- .../SftpAuthenticationControllerTest.php | 341 +- .../Location/LocationCommandsTest.php | 32 + .../Server/BulkPowerActionCommandTest.php | 32 + .../Commands/Themes/ThemeCommandsTest.php | 102 + .../Console/Commands/UpgradeCommandTest.php | 51 + .../Commands/User/MakeUserCommandTest.php | 56 + tests/Integration/Console/SchedulerTest.php | 53 + .../LegacyMigrationHistoryGuardTest.php | 32 + .../Database/LegacyNestSchemaTest.php | 29 + .../SubuserGrantUniquenessMigrationTest.php | 68 + .../Admin/UserController/DeleteUserTest.php | 37 - .../Auth/LoginCheckpointControllerTest.php | 281 +- .../Controllers/Auth/LoginControllerTest.php | 97 + .../Auth/PasswordResetActivityTest.php | 23 + .../Controllers/Auth/PasswordResetTest.php | 67 + .../Http/Controllers/Base/BaseRoutesTest.php | 26 + .../Http/ExtensionFrontendConfigTest.php | 68 + tests/Integration/Http/HttpTestCase.php | 6 +- .../Api/Daemon/DaemonAuthenticateTest.php | 78 + tests/Integration/IntegrationTestCase.php | 28 +- .../Jobs/RevokeSftpAccessJobTest.php | 107 +- .../Jobs/Schedule/RunTaskJobTest.php | 274 +- .../Providers/ActionServiceProviderTest.php | 36 + .../FindAssignableAllocationServiceTest.php | 279 +- .../Services/BackendWriteConsistencyTest.php | 196 + .../Backups/DeleteBackupServiceTest.php | 172 +- .../Backups/DownloadLinkServiceTest.php | 75 +- .../Services/Daemon/DaemonClientTest.php | 227 + .../DatabaseManagementServiceTest.php | 346 +- .../Databases/DatabasePasswordServiceTest.php | 112 +- .../DeployServerDatabaseServiceTest.php | 231 +- .../Deployment/FindViableNodesServiceTest.php | 303 +- .../Services/Eggs/EggImporterServiceTest.php | 32 + .../Extensions/ExtensionInstallerTest.php | 517 + .../ExtensionProviderLoaderTest.php | 331 + .../ExtensionScopedSettingsTest.php | 79 + .../Extensions/ServerOperationEventTest.php | 40 + .../Schedules/ProcessScheduleServiceTest.php | 328 +- .../Servers/BuildModificationServiceTest.php | 378 +- .../Services/Servers/ChangeServerEggTest.php | 146 + .../Servers/ServerCreationServiceTest.php | 311 +- .../Servers/ServerDeletionServiceTest.php | 285 +- .../StartupModificationServiceTest.php | 259 +- .../Servers/SuspensionServiceTest.php | 138 +- .../Servers/VariableValidatorServiceTest.php | 215 +- .../Services/Users/CompleteLoginTest.php | 75 + .../Users/UserDeletionServiceTest.php | 94 +- tests/Integration/TestResponse.php | 10 +- tests/Pest.php | 17 + tests/Support/Fakes/FakeBackupManager.php | 23 + tests/Support/Fakes/FakeDaemonBackup.php | 89 + tests/Support/Fakes/FakeDaemonCommand.php | 37 + .../Support/Fakes/FakeDaemonConfiguration.php | 43 + tests/Support/Fakes/FakeDaemonFile.php | 263 + tests/Support/Fakes/FakeDaemonHttpClient.php | 68 + tests/Support/Fakes/FakeDaemonPower.php | 60 + tests/Support/Fakes/FakeDaemonRevocation.php | 45 + tests/Support/Fakes/FakeDaemonServer.php | 119 + tests/Support/Fakes/FakeDaemonTransfer.php | 28 + .../Support/Fakes/FakeDatabaseHostGateway.php | 188 + .../Fakes/FakeDynamicDatabaseConnection.php | 32 + tests/Support/Fakes/FakeResponseFactory.php | 102 + tests/Support/Fakes/FakeS3Client.php | 38 + tests/Support/Fakes/FakeS3Filesystem.php | 55 + .../Fakes/FakeSoftwareVersionService.php | 62 + tests/Support/Fakes/ThrowingDispatcher.php | 156 + tests/Support/OpenApiSpecValidator.php | 241 + tests/TestCase.php | 69 +- .../Http/IntegrationJsonRequestAssertions.php | 2 + tests/Traits/Http/MocksMiddlewareClosure.php | 9 +- tests/Traits/Http/RequestMockHelpers.php | 44 +- .../Traits/Integration/CreatesTestModels.php | 36 +- tests/Traits/MocksPdoConnection.php | 48 - tests/Traits/MocksRequestException.php | 31 - tests/Traits/MocksUuids.php | 36 - tests/Unit/Actions/Files/ReadFilesTest.php | 87 + .../Actions/Servers/ReadServerLogsTest.php | 69 + .../Actions/Servers/ReadServerStateTest.php | 90 + .../Unit/Actions/Users/CompleteLoginTest.php | 121 + tests/Unit/ActivityLogTranslationTest.php | 82 + tests/Unit/ArchTest.php | 181 + .../Addons/RunHooksCommandTest.php | 181 +- .../Environment/AppSettingsCommandTest.php | 57 + .../Console/GenerateKeyWithoutAppKeyTest.php | 19 + tests/Unit/Database/SchemaDumpTest.php | 17 + tests/Unit/DocumentationLinksTest.php | 21 + tests/Unit/EggConfigurationServiceTest.php | 56 + tests/Unit/Enum/EggSpecificTagsTest.php | 43 + tests/Unit/EnvironmentServiceTest.php | 66 + .../Unit/Exceptions/ApiErrorResponseTest.php | 50 + .../DaemonConnectionExceptionTest.php | 40 + .../Extensions/Backups/BackupManagerTest.php | 24 + .../ExtensionProviderRuntimeTest.php | 457 + .../Unit/Extensions/ExtensionProviderTest.php | 213 + .../JWT/Encoding/TimestampDatesTest.php | 19 + .../Helpers/EnvironmentWriterTraitTest.php | 47 +- tests/Unit/Helpers/IsDigitTest.php | 47 - .../Api/Client/ClientApiControllerTest.php | 37 + .../Controllers/Base/LocaleControllerTest.php | 26 + tests/Unit/Http/ExtensionFileRouteTest.php | 52 + .../Http/Middleware/AdminAuthenticateTest.php | 56 - .../Api/Application/AuthenticateUserTest.php | 68 +- .../Api/Daemon/DaemonAuthenticateTest.php | 160 - .../Middleware/LanguageMiddlewareTest.php | 70 +- .../Middleware/MaintenanceMiddlewareTest.php | 110 +- .../Http/Middleware/MiddlewareTestCase.php | 10 +- .../RedirectIfAuthenticatedTest.php | 66 +- .../Servers/StoreServerRequestTest.php | 22 + .../Api/Remote/RemoteRequestNodeTest.php | 23 + tests/Unit/JsonValueGuardTest.php | 73 + tests/Unit/JsonValueTreeTest.php | 25 + tests/Unit/Lang/ActivityTranslationsTest.php | 70 + tests/Unit/Rules/UsernameTest.php | 91 +- tests/Unit/ServerCreationDataTest.php | 57 + tests/Unit/Services/Acl/Api/AdminAclTest.php | 59 +- .../Services/Deployment/NodeTagGateTest.php | 47 + .../Services/Eggs/EggParserServiceTest.php | 41 + .../Extensions/ExtensionCompatibilityTest.php | 145 + .../ExtensionFailureAttributorTest.php | 100 + .../Extensions/ExtensionHeadTagTest.php | 78 + .../Extensions/ExtensionJobProgressTest.php | 42 + .../Extensions/ExtensionManagerTest.php | 112 + .../Extensions/ExtensionManifestTest.php | 360 + .../ExtensionPermissionRegistryTest.php | 27 + .../ExtensionProviderLoaderTest.php | 44 + .../Extensions/ExtensionRuntimeTest.php | 73 + .../Extensions/ExtensionScaffolderTest.php | 141 + .../ExtensionSettingFieldTypesTest.php | 244 + .../Extensions/ExtensionSettingFilesTest.php | 159 + .../ExtensionSettingValueGuardTest.php | 73 + .../ExtensionSettingsDefinitionTest.php | 110 + .../ExtensionSettingsRegistryTest.php | 22 + .../ExtensionStylesheetInspectorTest.php | 168 + .../Extensions/ExtensionToolingTest.php | 135 + .../Services/Helpers/AssetHashServiceTest.php | 39 + .../Helpers/SoftwareVersionServiceTest.php | 38 + tests/Unit/WingsJsonResponseTest.php | 63 + tools/oxlint/rules/design-tokens.spec.ts | 41 + tools/oxlint/rules/index.ts | 39 + tools/oxlint/rules/lint.spec.ts | 172 + tools/oxlint/rules/package.json | 4 + tools/oxlint/rules/rules/design-tokens.ts | 54 + .../rules/rules/generated-api-imports.ts | 39 + .../rules/rules/generated-api-mutations.ts | 22 + .../oxlint/rules/rules/generated-api-types.ts | 23 + .../rules/rules/no-chained-type-assertions.ts | 76 + .../no-conditional-empty-object-spread.ts | 46 + .../rules/rules/no-known-value-widening.ts | 218 + .../rules/rules/no-object-parameters.ts | 110 + tools/oxlint/rules/rules/no-runtime-typeof.ts | 25 + .../rules/rules/no-shape-in-symbol-names.ts | 39 + .../rules/rules/no-unknown-parameters.ts | 81 + .../rules/rules/no-unknown-type-aliases.ts | 62 + .../rules/rules/no-unsafe-dictionary-type.ts | 86 + .../rules/rules/no-widen-then-assert.ts | 340 + tools/oxlint/rules/shared/dictionary-types.ts | 398 + tools/oxlint/rules/tsconfig.json | 9 + tools/phpstan/rules/README.md | 199 + tools/phpstan/rules/extension.neon | 225 + tools/phpstan/rules/install.php | 112 + tools/phpstan/rules/laravel/extension.neon | 40 + tools/phpstan/rules/phpstan.neon | 30 + tools/phpstan/rules/phpunit.xml | 13 + .../Rules/NoServiceConstructionRule.php | 152 + .../src/Rules/NoChainedAssertionsRule.php | 43 + .../rules/src/Rules/NoChainedVarTagsRule.php | 78 + .../src/Rules/NoClassLoadingMocksRule.php | 132 + .../NoConditionalEmptyArraySpreadRule.php | 90 + .../NoForbiddenTermsInSymbolNamesRule.php | 126 + .../src/Rules/NoInstanceofOnMixedRule.php | 75 + .../NoKnownValueWideningPropertyRule.php | 80 + .../Rules/NoKnownValueWideningReturnRule.php | 87 + .../rules/src/Rules/NoMixedParametersRule.php | 90 + .../rules/src/Rules/NoMixedReturnsRule.php | 87 + .../src/Rules/NoMixedTypeAliasesRule.php | 56 + .../src/Rules/NoObjectParametersRule.php | 58 + .../Rules/NoUnsafeDictionaryPropertyRule.php | 59 + .../src/Rules/NoUnsafeDictionaryTypeRule.php | 72 + .../rules/src/Rules/NoWidenThenAssertRule.php | 198 + .../RequireSafetyCommentForAssertionRule.php | 67 + .../rules/src/Support/AssertionForms.php | 157 + .../rules/src/Support/NodeChildren.php | 66 + .../rules/src/Support/ResolvedParameter.php | 21 + .../rules/src/Support/ResolvedSignature.php | 24 + .../rules/src/Support/SignatureResolver.php | 129 + .../rules/src/Support/TypeAliasDocblock.php | 87 + .../rules/src/Support/TypeClassifier.php | 153 + .../tests/Integration/PackageCoverageTest.php | 64 + .../Integration/data/package-coverage.php | 41 + .../rules/tests/Integration/integration.neon | 7 + .../Rules/NoChainedAssertionsRuleTest.php | 32 + .../tests/Rules/NoChainedVarTagsRuleTest.php | 28 + .../Rules/NoClassLoadingMocksRuleTest.php | 36 + .../NoConditionalEmptyArraySpreadRuleTest.php | 32 + .../NoForbiddenTermsInSymbolNamesRuleTest.php | 37 + .../Rules/NoInstanceofOnMixedRuleTest.php | 28 + .../NoKnownValueWideningReturnRuleTest.php | 28 + .../Rules/NoKnownValueWideningRuleTest.php | 31 + .../tests/Rules/NoMixedParametersRuleTest.php | 40 + .../tests/Rules/NoMixedReturnsRuleTest.php | 40 + .../Rules/NoMixedTypeAliasesRuleTest.php | 33 + .../Rules/NoObjectParametersRuleTest.php | 38 + .../Rules/NoServiceConstructionRuleTest.php | 31 + .../NoUnsafeDictionaryPropertyRuleTest.php | 30 + .../Rules/NoUnsafeDictionaryTypeRuleTest.php | 41 + .../tests/Rules/NoWidenThenAssertRuleTest.php | 32 + ...quireSafetyCommentForAssertionRuleTest.php | 34 + .../Rules/data/no-chained-assertions.php | 16 + .../tests/Rules/data/no-chained-var-tags.php | 23 + .../Rules/data/no-class-loading-mocks.php | 57 + .../no-conditional-empty-array-spread.php | 25 + .../no-forbidden-terms-in-symbol-names.php | 31 + .../Rules/data/no-instanceof-on-mixed.php | 23 + .../Rules/data/no-known-value-widening.php | 53 + .../tests/Rules/data/no-mixed-parameters.php | 69 + .../tests/Rules/data/no-mixed-returns.php | 72 + .../Rules/data/no-mixed-type-aliases.php | 26 + .../tests/Rules/data/no-object-parameters.php | 29 + .../Rules/data/no-service-construction.php | 47 + .../data/no-unsafe-dictionary-property.php | 28 + .../Rules/data/no-unsafe-dictionary-type.php | 55 + .../tests/Rules/data/no-widen-then-assert.php | 56 + .../Rules/data/require-safety-comment.php | 35 + .../phpstan/stubs/EloquentHasAttributes.stub | 16 + tsconfig.json | 47 +- vite.config.mts | 130 + vitest.config.ts | 29 + webpack.config.js | 161 - yarn.lock | 9856 ---------- 2764 files changed, 176950 insertions(+), 72961 deletions(-) create mode 100644 .dockerignore delete mode 100644 .eslintignore delete mode 100644 .eslintrc.js create mode 100644 .github/docker/health.conf create mode 100644 .github/docker/healthcheck.sh create mode 100644 .github/docker/optimize.sh create mode 100644 .github/docker/php.ini create mode 100755 .github/docker/smoke-test.sh create mode 100644 .github/workflows/staging.yaml create mode 100644 .nvmrc create mode 100644 .oxfmtrc.json create mode 100644 .oxlintrc.json delete mode 100644 .php-cs-fixer.dist.php delete mode 100644 .prettierrc.json delete mode 100644 BUILDING.md create mode 100644 app/Actions/Activity/IngestActivityLogs.php create mode 100644 app/Actions/Allocations/AssignAllocation.php create mode 100644 app/Actions/Allocations/AssignAvailableAllocation.php create mode 100644 app/Actions/Allocations/CreateAllocations.php create mode 100644 app/Actions/Allocations/DeleteAllocation.php create mode 100644 app/Actions/Allocations/SetPrimaryAllocation.php create mode 100644 app/Actions/Allocations/UnassignAllocation.php create mode 100644 app/Actions/Allocations/UpdateAllocation.php create mode 100644 app/Actions/Allocations/UpdateAllocationNotes.php create mode 100644 app/Actions/Api/CreateAccountApiKey.php create mode 100644 app/Actions/Api/CreateApiKey.php create mode 100644 app/Actions/Backups/CompleteBackup.php rename app/{Services/Backups/DeleteBackupService.php => Actions/Backups/DeleteBackup.php} (56%) rename app/{Services/Backups/DownloadLinkService.php => Actions/Backups/GenerateBackupDownloadLink.php} (63%) create mode 100644 app/Actions/Backups/InitiateBackup.php create mode 100644 app/Actions/Backups/PresignBackupUpload.php create mode 100644 app/Actions/Backups/RestoreBackup.php create mode 100644 app/Actions/Backups/RestoreBackupStatus.php create mode 100644 app/Actions/Backups/ToggleBackupLock.php create mode 100644 app/Actions/Databases/CreateDatabase.php create mode 100644 app/Actions/Databases/CreateDatabaseHost.php create mode 100644 app/Actions/Databases/DeleteDatabase.php create mode 100644 app/Actions/Databases/DeleteDatabaseHost.php create mode 100644 app/Actions/Databases/DeployServerDatabase.php create mode 100644 app/Actions/Databases/RotateDatabasePassword.php create mode 100644 app/Actions/Databases/UpdateDatabaseHost.php create mode 100644 app/Actions/Eggs/CreateEgg.php create mode 100644 app/Actions/Eggs/DeleteEgg.php create mode 100644 app/Actions/Eggs/Scripts/UpdateInstallScript.php rename app/{Services/Eggs/Sharing/EggExporterService.php => Actions/Eggs/Sharing/ExportEgg.php} (55%) create mode 100644 app/Actions/Eggs/Sharing/ImportCatalogEgg.php create mode 100644 app/Actions/Eggs/Sharing/ImportEgg.php create mode 100644 app/Actions/Eggs/Sharing/UpdateEggFromImport.php create mode 100644 app/Actions/Eggs/UpdateEgg.php create mode 100644 app/Actions/Eggs/Variables/CreateEggVariable.php create mode 100644 app/Actions/Eggs/Variables/ReorderEggVariables.php create mode 100644 app/Actions/Eggs/Variables/UpdateEggVariable.php create mode 100644 app/Actions/Extensions/InstallExtension.php create mode 100644 app/Actions/Extensions/RemoveExtension.php create mode 100644 app/Actions/Extensions/ReplaceExtensionSettingFile.php create mode 100644 app/Actions/Extensions/SetExtensionEnabled.php create mode 100644 app/Actions/Extensions/UpdateExtensionSettings.php create mode 100644 app/Actions/Files/ChangeFilePermissions.php create mode 100644 app/Actions/Files/CompressFiles.php create mode 100644 app/Actions/Files/CopyFile.php create mode 100644 app/Actions/Files/CreateDirectory.php create mode 100644 app/Actions/Files/DecompressFile.php create mode 100644 app/Actions/Files/DeleteFiles.php create mode 100644 app/Actions/Files/ListDirectory.php create mode 100644 app/Actions/Files/PullFile.php create mode 100644 app/Actions/Files/ReadFileContents.php create mode 100644 app/Actions/Files/RenameFiles.php create mode 100644 app/Actions/Files/WriteFileContents.php create mode 100644 app/Actions/Locations/CreateLocation.php create mode 100644 app/Actions/Locations/DeleteLocation.php create mode 100644 app/Actions/Locations/UpdateLocation.php create mode 100644 app/Actions/Nodes/CreateNode.php create mode 100644 app/Actions/Nodes/DeleteNode.php create mode 100644 app/Actions/Nodes/ResetServerStates.php create mode 100644 app/Actions/Nodes/UpdateNode.php create mode 100644 app/Actions/Schedules/CreateSchedule.php create mode 100644 app/Actions/Schedules/CreateScheduleTask.php create mode 100644 app/Actions/Schedules/DeleteSchedule.php create mode 100644 app/Actions/Schedules/DeleteScheduleTask.php create mode 100644 app/Actions/Schedules/ProcessSchedule.php create mode 100644 app/Actions/Schedules/UpdateSchedule.php create mode 100644 app/Actions/Schedules/UpdateScheduleTask.php create mode 100644 app/Actions/Servers/AttachMountToServer.php create mode 100644 app/Actions/Servers/ChangeServerEgg.php create mode 100644 app/Actions/Servers/CreateServer.php create mode 100644 app/Actions/Servers/DeleteServer.php create mode 100644 app/Actions/Servers/DetachMountFromServer.php create mode 100644 app/Actions/Servers/ReadServerLogs.php create mode 100644 app/Actions/Servers/ReadServerState.php create mode 100644 app/Actions/Servers/RebuildServer.php create mode 100644 app/Actions/Servers/RecordServerInstallResult.php create mode 100644 app/Actions/Servers/ReinstallServer.php create mode 100644 app/Actions/Servers/SendServerCommand.php create mode 100644 app/Actions/Servers/SendServerPower.php create mode 100644 app/Actions/Servers/ToggleServerSuspension.php create mode 100644 app/Actions/Servers/UpdateServerBuild.php create mode 100644 app/Actions/Servers/UpdateServerDetails.php create mode 100644 app/Actions/Servers/UpdateServerStartup.php create mode 100644 app/Actions/Subusers/CreateSubuser.php create mode 100644 app/Actions/Subusers/DeleteSubuser.php create mode 100644 app/Actions/Subusers/UpdateSubuser.php create mode 100644 app/Actions/Tags/SyncTags.php create mode 100644 app/Actions/Telemetry/SendTelemetry.php create mode 100644 app/Actions/Themes/ApplyTheme.php create mode 100644 app/Actions/Themes/ResetTheme.php create mode 100644 app/Actions/Transfers/CompleteTransfer.php create mode 100644 app/Actions/Transfers/FailTransfer.php create mode 100644 app/Actions/Transfers/InitiateTransfer.php create mode 100644 app/Actions/Users/CompleteLogin.php create mode 100644 app/Actions/Users/CreateUser.php rename app/{Services/Users/UserDeletionService.php => Actions/Users/DeleteUser.php} (53%) create mode 100644 app/Actions/Users/DisableTwoFactor.php create mode 100644 app/Actions/Users/SetupTwoFactor.php create mode 100644 app/Actions/Users/ToggleTwoFactor.php create mode 100644 app/Actions/Users/UpdateUser.php create mode 100644 app/Actions/Users/UpdateUserEmail.php create mode 100644 app/Actions/Users/UpdateUserPassword.php create mode 100644 app/Console/Commands/Extensions/DevCommand.php create mode 100644 app/Console/Commands/Extensions/DisableCommand.php create mode 100644 app/Console/Commands/Extensions/DoctorCommand.php create mode 100644 app/Console/Commands/Extensions/EnableCommand.php create mode 100644 app/Console/Commands/Extensions/InstallCommand.php create mode 100644 app/Console/Commands/Extensions/ListCommand.php create mode 100644 app/Console/Commands/Extensions/MakeCommand.php create mode 100644 app/Console/Commands/Extensions/PackCommand.php create mode 100644 app/Console/Commands/Extensions/RemoveCommand.php create mode 100644 app/Console/Commands/Extensions/TypesCommand.php create mode 100644 app/Console/Commands/Themes/ApplyCommand.php create mode 100644 app/Console/Commands/Themes/ListCommand.php create mode 100644 app/Console/Commands/Themes/ResetCommand.php delete mode 100644 app/Console/Kernel.php create mode 100644 app/Console/Scheduler.php create mode 100644 app/Contracts/Activity/IngestsActivityLogs.php create mode 100644 app/Contracts/Allocations/AssignsAllocations.php create mode 100644 app/Contracts/Allocations/AssignsAvailableAllocations.php create mode 100644 app/Contracts/Allocations/CreatesAllocations.php create mode 100644 app/Contracts/Allocations/DeletesAllocations.php create mode 100644 app/Contracts/Allocations/SetsPrimaryAllocations.php create mode 100644 app/Contracts/Allocations/UnassignsAllocations.php create mode 100644 app/Contracts/Allocations/UpdatesAllocationNotes.php create mode 100644 app/Contracts/Allocations/UpdatesAllocations.php create mode 100644 app/Contracts/Api/CreatesAccountApiKeys.php create mode 100644 app/Contracts/Api/CreatesApiKeys.php create mode 100644 app/Contracts/Backups/CompletesBackups.php create mode 100644 app/Contracts/Backups/DeletesBackups.php create mode 100644 app/Contracts/Backups/GeneratesBackupDownloadLinks.php create mode 100644 app/Contracts/Backups/InitiatesBackups.php create mode 100644 app/Contracts/Backups/PresignsBackupUploads.php create mode 100644 app/Contracts/Backups/RestoresBackupStatuses.php create mode 100644 app/Contracts/Backups/RestoresBackups.php create mode 100644 app/Contracts/Backups/TogglesBackupLocks.php delete mode 100644 app/Contracts/Criteria/CriteriaInterface.php create mode 100644 app/Contracts/Databases/CreatesDatabaseHosts.php create mode 100644 app/Contracts/Databases/CreatesDatabases.php create mode 100644 app/Contracts/Databases/DeletesDatabaseHosts.php create mode 100644 app/Contracts/Databases/DeletesDatabases.php create mode 100644 app/Contracts/Databases/DeploysServerDatabases.php create mode 100644 app/Contracts/Databases/RotatesDatabasePasswords.php create mode 100644 app/Contracts/Databases/UpdatesDatabaseHosts.php create mode 100644 app/Contracts/Eggs/CreatesEggVariables.php create mode 100644 app/Contracts/Eggs/CreatesEggs.php create mode 100644 app/Contracts/Eggs/DeletesEggs.php create mode 100644 app/Contracts/Eggs/ExportsEggs.php create mode 100644 app/Contracts/Eggs/ImportsCatalogEggs.php create mode 100644 app/Contracts/Eggs/ImportsEggs.php create mode 100644 app/Contracts/Eggs/ReordersEggVariables.php create mode 100644 app/Contracts/Eggs/UpdatesEggInstallScripts.php create mode 100644 app/Contracts/Eggs/UpdatesEggVariables.php create mode 100644 app/Contracts/Eggs/UpdatesEggs.php create mode 100644 app/Contracts/Eggs/UpdatesEggsFromImports.php create mode 100644 app/Contracts/Extensions/InstallsExtensions.php create mode 100644 app/Contracts/Extensions/RemovesExtensions.php create mode 100644 app/Contracts/Extensions/ReplacesExtensionSettingFiles.php create mode 100644 app/Contracts/Extensions/SetsExtensionEnabled.php create mode 100644 app/Contracts/Extensions/UpdatesExtensionSettings.php create mode 100644 app/Contracts/Files/ChangesFilePermissions.php create mode 100644 app/Contracts/Files/CompressesFiles.php create mode 100644 app/Contracts/Files/CopiesFiles.php create mode 100644 app/Contracts/Files/CreatesDirectories.php create mode 100644 app/Contracts/Files/DecompressesFiles.php create mode 100644 app/Contracts/Files/DeletesFiles.php create mode 100644 app/Contracts/Files/ListsDirectories.php create mode 100644 app/Contracts/Files/PullsFiles.php create mode 100644 app/Contracts/Files/ReadsFileContents.php create mode 100644 app/Contracts/Files/RenamesFiles.php create mode 100644 app/Contracts/Files/WritesFileContents.php create mode 100644 app/Contracts/Locations/CreatesLocations.php create mode 100644 app/Contracts/Locations/DeletesLocations.php create mode 100644 app/Contracts/Locations/UpdatesLocations.php create mode 100644 app/Contracts/Nodes/CreatesNodes.php create mode 100644 app/Contracts/Nodes/DeletesNodes.php create mode 100644 app/Contracts/Nodes/ResetsServerStates.php create mode 100644 app/Contracts/Nodes/UpdatesNodes.php delete mode 100644 app/Contracts/Repository/AllocationRepositoryInterface.php delete mode 100644 app/Contracts/Repository/ApiKeyRepositoryInterface.php delete mode 100644 app/Contracts/Repository/ApiPermissionRepositoryInterface.php delete mode 100644 app/Contracts/Repository/DatabaseHostRepositoryInterface.php delete mode 100644 app/Contracts/Repository/DatabaseRepositoryInterface.php delete mode 100644 app/Contracts/Repository/EggRepositoryInterface.php delete mode 100644 app/Contracts/Repository/EggVariableRepositoryInterface.php delete mode 100644 app/Contracts/Repository/LocationRepositoryInterface.php delete mode 100644 app/Contracts/Repository/NestRepositoryInterface.php delete mode 100644 app/Contracts/Repository/NodeRepositoryInterface.php delete mode 100644 app/Contracts/Repository/PermissionRepositoryInterface.php delete mode 100644 app/Contracts/Repository/RepositoryInterface.php delete mode 100644 app/Contracts/Repository/ScheduleRepositoryInterface.php delete mode 100644 app/Contracts/Repository/ServerRepositoryInterface.php delete mode 100644 app/Contracts/Repository/ServerVariableRepositoryInterface.php delete mode 100644 app/Contracts/Repository/SessionRepositoryInterface.php delete mode 100644 app/Contracts/Repository/SettingsRepositoryInterface.php delete mode 100644 app/Contracts/Repository/SubuserRepositoryInterface.php delete mode 100644 app/Contracts/Repository/TaskRepositoryInterface.php delete mode 100644 app/Contracts/Repository/UserRepositoryInterface.php create mode 100644 app/Contracts/Schedules/CreatesScheduleTasks.php create mode 100644 app/Contracts/Schedules/CreatesSchedules.php create mode 100644 app/Contracts/Schedules/DeletesScheduleTasks.php create mode 100644 app/Contracts/Schedules/DeletesSchedules.php create mode 100644 app/Contracts/Schedules/ProcessesSchedules.php create mode 100644 app/Contracts/Schedules/UpdatesScheduleTasks.php create mode 100644 app/Contracts/Schedules/UpdatesSchedules.php create mode 100644 app/Contracts/Servers/AttachesMountsToServers.php create mode 100644 app/Contracts/Servers/ChangesServerEgg.php create mode 100644 app/Contracts/Servers/CreatesServers.php create mode 100644 app/Contracts/Servers/DeletesServers.php create mode 100644 app/Contracts/Servers/DetachesMountsFromServers.php create mode 100644 app/Contracts/Servers/ReadsServerLogs.php create mode 100644 app/Contracts/Servers/ReadsServerState.php create mode 100644 app/Contracts/Servers/RebuildsServers.php create mode 100644 app/Contracts/Servers/RecordsServerInstallResults.php create mode 100644 app/Contracts/Servers/ReinstallsServers.php create mode 100644 app/Contracts/Servers/SendsServerCommands.php create mode 100644 app/Contracts/Servers/SendsServerPower.php create mode 100644 app/Contracts/Servers/TogglesServerSuspension.php create mode 100644 app/Contracts/Servers/UpdatesServerBuild.php create mode 100644 app/Contracts/Servers/UpdatesServerDetails.php create mode 100644 app/Contracts/Servers/UpdatesServerStartup.php create mode 100644 app/Contracts/Subusers/CreatesSubusers.php create mode 100644 app/Contracts/Subusers/DeletesSubusers.php create mode 100644 app/Contracts/Subusers/UpdatesSubusers.php create mode 100644 app/Contracts/Tags/SyncsTags.php create mode 100644 app/Contracts/Telemetry/SendsTelemetry.php create mode 100644 app/Contracts/Themes/AppliesThemes.php create mode 100644 app/Contracts/Themes/ResetsThemes.php create mode 100644 app/Contracts/Transfers/CompletesTransfers.php create mode 100644 app/Contracts/Transfers/FailsTransfers.php create mode 100644 app/Contracts/Transfers/InitiatesTransfers.php create mode 100644 app/Contracts/Users/CompletesLogins.php create mode 100644 app/Contracts/Users/CreatesUsers.php create mode 100644 app/Contracts/Users/DeletesUsers.php create mode 100644 app/Contracts/Users/DisablesTwoFactor.php create mode 100644 app/Contracts/Users/SetsUpTwoFactor.php create mode 100644 app/Contracts/Users/TogglesTwoFactor.php create mode 100644 app/Contracts/Users/UpdatesUserEmails.php create mode 100644 app/Contracts/Users/UpdatesUserPasswords.php create mode 100644 app/Contracts/Users/UpdatesUsers.php create mode 100644 app/Data/AllocationRange.php create mode 100644 app/Data/EggCatalogEntry.php create mode 100644 app/Data/Extensions/ExtensionJobSnapshot.php create mode 100644 app/Data/LoginCheckpoint.php create mode 100644 app/Data/LoginResult.php create mode 100644 app/Data/ServerCreationData.php create mode 100644 app/Data/ServerState.php create mode 100644 app/Data/ValidatedEggVariable.php create mode 100644 app/Enum/EggSpecificTags.php create mode 100644 app/Enum/Permissions.php create mode 100644 app/Events/Extensions/ExtensionDisabled.php create mode 100644 app/Events/Extensions/ExtensionDisabling.php create mode 100644 app/Events/Extensions/ExtensionEnabled.php create mode 100644 app/Events/Extensions/ExtensionEnabling.php create mode 100644 app/Events/Extensions/ExtensionInstalled.php create mode 100644 app/Events/Extensions/ExtensionInstalling.php create mode 100644 app/Events/Extensions/ExtensionLoadFailed.php create mode 100644 app/Events/Extensions/ExtensionRemoved.php create mode 100644 app/Events/Extensions/ExtensionRemoving.php create mode 100644 app/Events/Server/OperationCompleted.php delete mode 100644 app/Exceptions/AccountNotFoundException.php create mode 100644 app/Exceptions/ApiErrorResponse.php delete mode 100644 app/Exceptions/AutoDeploymentException.php create mode 100644 app/Exceptions/Extensions/InvalidExtensionException.php delete mode 100644 app/Exceptions/Handler.php delete mode 100644 app/Exceptions/Http/Server/FileTypeNotEditableException.php delete mode 100644 app/Exceptions/Model/DataValidationException.php delete mode 100644 app/Exceptions/Repository/Daemon/InvalidPowerSignalException.php delete mode 100644 app/Exceptions/Repository/RecordNotFoundException.php delete mode 100644 app/Exceptions/Repository/RepositoryException.php delete mode 100644 app/Exceptions/Service/Allocation/AllocationDoesNotBelongToServerException.php delete mode 100644 app/Exceptions/Service/Egg/BadJsonFormatException.php delete mode 100644 app/Exceptions/Service/Egg/NoParentConfigurationFoundException.php delete mode 100644 app/Exceptions/Service/Egg/Variable/BadValidationRuleException.php delete mode 100644 app/Exceptions/Service/Egg/Variable/ReservedVariableNameException.php delete mode 100644 app/Exceptions/Service/Schedule/Task/TaskIntervalTooLongException.php delete mode 100644 app/Exceptions/Service/Server/RequiredVariableMissingException.php delete mode 100644 app/Exceptions/Solutions/ManifestDoesNotExistSolution.php create mode 100644 app/Extensions/ExtensionProvider.php delete mode 100644 app/Extensions/Facades/Theme.php create mode 100644 app/Extensions/Scribe/Attributes/ResponseField.php create mode 100644 app/Extensions/Scribe/Attributes/ResponseFromTransformer.php create mode 100644 app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php create mode 100644 app/Extensions/Scribe/Strategies/InferPterodactylBodyParameters.php create mode 100644 app/Extensions/Scribe/Strategies/InferPterodactylResponses.php create mode 100644 app/Extensions/Scribe/Strategies/InferPterodactylUrlParameters.php create mode 100644 app/Extensions/Scribe/Strategies/UsePterodactylResponseAttributes.php create mode 100644 app/Extensions/Scribe/Support/PterodactylDocumentation.php delete mode 100644 app/Extensions/Themes/Theme.php create mode 100644 app/Facades/Alert.php create mode 100644 app/Facades/Daemon.php create mode 100644 app/Facades/Fractal.php create mode 100644 app/Facades/Hashids.php create mode 100644 app/Http/Concerns/ResolvesRequestContext.php delete mode 100644 app/Http/Controllers/Admin/ApiController.php delete mode 100644 app/Http/Controllers/Admin/BaseController.php delete mode 100644 app/Http/Controllers/Admin/DatabaseController.php delete mode 100644 app/Http/Controllers/Admin/LocationController.php delete mode 100644 app/Http/Controllers/Admin/MountController.php delete mode 100644 app/Http/Controllers/Admin/Nests/EggController.php delete mode 100644 app/Http/Controllers/Admin/Nests/EggScriptController.php delete mode 100644 app/Http/Controllers/Admin/Nests/EggShareController.php delete mode 100644 app/Http/Controllers/Admin/Nests/EggVariableController.php delete mode 100644 app/Http/Controllers/Admin/Nests/NestController.php delete mode 100644 app/Http/Controllers/Admin/NodeAutoDeployController.php delete mode 100644 app/Http/Controllers/Admin/Nodes/NodeController.php delete mode 100644 app/Http/Controllers/Admin/Nodes/NodeViewController.php delete mode 100644 app/Http/Controllers/Admin/Nodes/SystemInformationController.php delete mode 100644 app/Http/Controllers/Admin/NodesController.php delete mode 100644 app/Http/Controllers/Admin/Servers/CreateServerController.php delete mode 100644 app/Http/Controllers/Admin/Servers/ServerController.php delete mode 100644 app/Http/Controllers/Admin/Servers/ServerTransferController.php delete mode 100644 app/Http/Controllers/Admin/Servers/ServerViewController.php delete mode 100644 app/Http/Controllers/Admin/ServersController.php delete mode 100644 app/Http/Controllers/Admin/Settings/AdvancedController.php delete mode 100644 app/Http/Controllers/Admin/Settings/IndexController.php delete mode 100644 app/Http/Controllers/Admin/Settings/MailController.php delete mode 100644 app/Http/Controllers/Admin/UserController.php create mode 100644 app/Http/Controllers/Api/Admin/ActivityController.php create mode 100644 app/Http/Controllers/Api/Admin/ActivityFilterController.php create mode 100644 app/Http/Controllers/Api/Admin/AdminApiController.php create mode 100644 app/Http/Controllers/Api/Admin/ApiKeys/ApiKeyController.php create mode 100644 app/Http/Controllers/Api/Admin/DatabaseHosts/DatabaseHostController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/EggCatalogController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/EggController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/EggScriptController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/EggVariableController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/ExportEggController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/ImportCatalogEggController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/ImportEggController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/ReorderVariablesController.php create mode 100644 app/Http/Controllers/Api/Admin/Eggs/UpdateImportEggController.php create mode 100644 app/Http/Controllers/Api/Admin/Extensions/ExtensionAdminSettingsController.php create mode 100644 app/Http/Controllers/Api/Admin/Extensions/ExtensionController.php create mode 100644 app/Http/Controllers/Api/Admin/LanguagesController.php create mode 100644 app/Http/Controllers/Api/Admin/Locations/EligibleNodesController.php create mode 100644 app/Http/Controllers/Api/Admin/Locations/LocationController.php create mode 100644 app/Http/Controllers/Api/Admin/Mounts/AttachEggsController.php create mode 100644 app/Http/Controllers/Api/Admin/Mounts/AttachNodesController.php create mode 100644 app/Http/Controllers/Api/Admin/Mounts/DetachEggController.php create mode 100644 app/Http/Controllers/Api/Admin/Mounts/DetachNodeController.php create mode 100644 app/Http/Controllers/Api/Admin/Mounts/MountController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/AllocationController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/AvailableAllocationsController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/BulkDeleteAllocationsController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/ConfigurationController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/DeleteAllocationBlockController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/DeployTokenController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/NodeController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/SystemInformationController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/UniqueIpsController.php create mode 100644 app/Http/Controllers/Api/Admin/Nodes/UtilizationController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/BuildController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/DatabaseController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/DetailsController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/ExternalController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/RebuildController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/ReinstallController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/RotateDatabasePasswordController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/ServerBackupController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/ServerController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/ServerMountController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/StartupController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/SuspensionController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/ToggleBackupController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/ToggleInstallController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/TransferController.php create mode 100644 app/Http/Controllers/Api/Admin/Servers/TransferProgressController.php create mode 100644 app/Http/Controllers/Api/Admin/Settings/AdvancedController.php create mode 100644 app/Http/Controllers/Api/Admin/Settings/GeneralController.php create mode 100644 app/Http/Controllers/Api/Admin/Settings/MailController.php create mode 100644 app/Http/Controllers/Api/Admin/Settings/SettingsController.php create mode 100644 app/Http/Controllers/Api/Admin/Settings/TestMailController.php create mode 100644 app/Http/Controllers/Api/Admin/Tags/TagController.php create mode 100644 app/Http/Controllers/Api/Admin/Users/DisableTwoFactorController.php create mode 100644 app/Http/Controllers/Api/Admin/Users/ExternalController.php create mode 100644 app/Http/Controllers/Api/Admin/Users/UserController.php create mode 100644 app/Http/Controllers/Api/Admin/VersionController.php create mode 100644 app/Http/Controllers/Api/Application/Eggs/EggController.php delete mode 100644 app/Http/Controllers/Api/Application/Nests/EggController.php delete mode 100644 app/Http/Controllers/Api/Application/Nests/NestController.php create mode 100644 app/Http/Controllers/Api/Application/Tags/TagController.php create mode 100644 app/Http/Controllers/Api/Client/ActivityLogFilterController.php create mode 100644 app/Http/Controllers/Api/Client/ExtensionProgressController.php create mode 100644 app/Http/Controllers/Api/Client/Servers/ActivityLogFilterController.php create mode 100644 app/Http/Controllers/Api/Client/Servers/LogController.php delete mode 100644 app/Http/Controllers/Api/Remote/EggInstallController.php create mode 100644 app/Http/Controllers/Base/ExtensionFileController.php delete mode 100644 app/Http/Kernel.php delete mode 100644 app/Http/Middleware/Admin/Servers/ServerInstalled.php delete mode 100644 app/Http/Middleware/AdminAuthenticate.php create mode 100644 app/Http/Middleware/Api/Admin/AuthenticateAdmin.php delete mode 100644 app/Http/Middleware/EncryptCookies.php create mode 100644 app/Http/Middleware/EnsureExtensionIsAvailable.php delete mode 100644 app/Http/Middleware/TrimStrings.php delete mode 100644 app/Http/Middleware/VerifyCsrfToken.php delete mode 100644 app/Http/Requests/Admin/AdminFormRequest.php delete mode 100644 app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php delete mode 100644 app/Http/Requests/Admin/BaseFormRequest.php delete mode 100644 app/Http/Requests/Admin/DatabaseHostFormRequest.php delete mode 100644 app/Http/Requests/Admin/Egg/EggFormRequest.php delete mode 100644 app/Http/Requests/Admin/Egg/EggImportFormRequest.php delete mode 100644 app/Http/Requests/Admin/Egg/EggScriptFormRequest.php delete mode 100644 app/Http/Requests/Admin/Egg/EggVariableFormRequest.php delete mode 100644 app/Http/Requests/Admin/LocationFormRequest.php delete mode 100644 app/Http/Requests/Admin/MountFormRequest.php delete mode 100644 app/Http/Requests/Admin/Nest/StoreNestFormRequest.php delete mode 100644 app/Http/Requests/Admin/NewUserFormRequest.php delete mode 100644 app/Http/Requests/Admin/Node/AllocationAliasFormRequest.php delete mode 100644 app/Http/Requests/Admin/Node/AllocationFormRequest.php delete mode 100644 app/Http/Requests/Admin/Node/NodeFormRequest.php delete mode 100644 app/Http/Requests/Admin/ServerFormRequest.php delete mode 100644 app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php delete mode 100644 app/Http/Requests/Admin/Settings/AdvancedSettingsFormRequest.php delete mode 100644 app/Http/Requests/Admin/Settings/BaseSettingsFormRequest.php delete mode 100644 app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php delete mode 100644 app/Http/Requests/Admin/UserFormRequest.php create mode 100644 app/Http/Requests/Api/Admin/Activity/GetActivityLogsRequest.php create mode 100644 app/Http/Requests/Api/Admin/AdminApiRequest.php create mode 100644 app/Http/Requests/Api/Admin/ApiKeys/DeleteApiKeyRequest.php create mode 100644 app/Http/Requests/Api/Admin/ApiKeys/GetApiKeysRequest.php create mode 100644 app/Http/Requests/Api/Admin/ApiKeys/StoreApiKeyRequest.php create mode 100644 app/Http/Requests/Api/Admin/ApiKeys/UpdateApiKeyRequest.php create mode 100644 app/Http/Requests/Api/Admin/DatabaseHosts/DeleteDatabaseHostRequest.php create mode 100644 app/Http/Requests/Api/Admin/DatabaseHosts/GetDatabaseHostRequest.php create mode 100644 app/Http/Requests/Api/Admin/DatabaseHosts/GetDatabaseHostsRequest.php create mode 100644 app/Http/Requests/Api/Admin/DatabaseHosts/StoreDatabaseHostRequest.php create mode 100644 app/Http/Requests/Api/Admin/DatabaseHosts/UpdateDatabaseHostRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/DeleteEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/GetEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/GetEggScriptRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/GetEggsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/ImportCatalogEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/ImportEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/StoreEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/UpdateEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/UpdateEggScriptRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/UpdateImportEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/Variables/DeleteVariableRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/Variables/GetVariablesRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/Variables/ReorderVariablesRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/Variables/StoreVariableRequest.php create mode 100644 app/Http/Requests/Api/Admin/Eggs/Variables/UpdateVariableRequest.php create mode 100644 app/Http/Requests/Api/Admin/Extensions/DeleteExtensionRequest.php create mode 100644 app/Http/Requests/Api/Admin/Extensions/GetExtensionsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Extensions/InstallExtensionRequest.php create mode 100644 app/Http/Requests/Api/Admin/Extensions/UpdateExtensionRequest.php create mode 100644 app/Http/Requests/Api/Admin/Extensions/UpdateExtensionSettingsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Extensions/UploadExtensionSettingFileRequest.php create mode 100644 app/Http/Requests/Api/Admin/GetLanguagesRequest.php create mode 100644 app/Http/Requests/Api/Admin/GetVersionRequest.php create mode 100644 app/Http/Requests/Api/Admin/Locations/DeleteLocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Locations/GetLocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Locations/GetLocationsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Locations/StoreLocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Locations/UpdateLocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/AttachEggsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/AttachNodesRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/DeleteMountRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/DetachEggRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/DetachNodeRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/GetMountRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/GetMountsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/StoreMountRequest.php create mode 100644 app/Http/Requests/Api/Admin/Mounts/UpdateMountRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/Allocations/BlockDeleteAllocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/Allocations/BulkDeleteAllocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/Allocations/DeleteAllocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/Allocations/GetAllocationsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/Allocations/StoreAllocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/Allocations/UpdateAllocationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/DeleteNodeRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/DeployTokenRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/GetNodeRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/GetNodesRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/GetSystemInformationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/GetUtilizationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/StoreNodeRequest.php create mode 100644 app/Http/Requests/Api/Admin/Nodes/UpdateNodeRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/Backups/ListBackupsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/Backups/ToggleBackupRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/Databases/GetDatabasesRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/Databases/ServerDatabaseWriteRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/Databases/StoreDatabaseRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/DeleteServerMountRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/DeleteServerRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/GetServerMountsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/GetServerRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/GetServersRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/ServerWriteRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/StoreServerMountRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/StoreServerRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/ToggleInstallRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/TransferServerRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/UpdateServerBuildConfigurationRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/UpdateServerDetailsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/UpdateServerStartupRequest.php create mode 100644 app/Http/Requests/Api/Admin/Servers/UpdateServerSuspensionRequest.php create mode 100644 app/Http/Requests/Api/Admin/Settings/GetSettingsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Settings/SendTestMailRequest.php create mode 100644 app/Http/Requests/Api/Admin/Settings/UpdateAdvancedSettingsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Settings/UpdateGeneralSettingsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Settings/UpdateMailSettingsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Tags/DeleteTagRequest.php create mode 100644 app/Http/Requests/Api/Admin/Tags/GetTagRequest.php create mode 100644 app/Http/Requests/Api/Admin/Tags/GetTagsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Tags/StoreTagRequest.php create mode 100644 app/Http/Requests/Api/Admin/Tags/SyncTagsRequest.php create mode 100644 app/Http/Requests/Api/Admin/Tags/UpdateTagRequest.php create mode 100644 app/Http/Requests/Api/Admin/Users/DeleteUserRequest.php create mode 100644 app/Http/Requests/Api/Admin/Users/DisableTwoFactorRequest.php create mode 100644 app/Http/Requests/Api/Admin/Users/GetUserRequest.php create mode 100644 app/Http/Requests/Api/Admin/Users/GetUsersRequest.php create mode 100644 app/Http/Requests/Api/Admin/Users/StoreUserRequest.php create mode 100644 app/Http/Requests/Api/Admin/Users/UpdateUserRequest.php create mode 100644 app/Http/Requests/Api/ApiRequest.php rename app/Http/Requests/Api/Application/{Nests => }/Eggs/GetEggRequest.php (77%) rename app/Http/Requests/Api/Application/{Nests => }/Eggs/GetEggsRequest.php (77%) delete mode 100644 app/Http/Requests/Api/Application/Nests/GetNestsRequest.php create mode 100644 app/Http/Requests/Api/Application/Nodes/GetNodeConfigurationRequest.php create mode 100644 app/Http/Requests/Api/Application/Tags/GetTagRequest.php create mode 100644 app/Http/Requests/Api/Application/Tags/GetTagsRequest.php create mode 100644 app/Http/Requests/Api/Client/Account/DeleteSSHKeyRequest.php create mode 100644 app/Http/Requests/Api/Client/Account/DisableTwoFactorRequest.php create mode 100644 app/Http/Requests/Api/Client/Account/EnableTwoFactorRequest.php create mode 100644 app/Http/Requests/Api/Client/GetActivityLogsRequest.php create mode 100644 app/Http/Requests/Api/Client/GetExtensionProgressRequest.php create mode 100644 app/Http/Requests/Api/Client/Servers/Backups/DeleteBackupRequest.php create mode 100644 app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php create mode 100644 app/Http/Requests/Api/Client/Servers/Backups/ListBackupsRequest.php create mode 100644 app/Http/Requests/Api/Client/Servers/Backups/ToggleBackupLockRequest.php create mode 100644 app/Http/Requests/Api/Client/Servers/Backups/ViewBackupRequest.php delete mode 100644 app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php create mode 100644 app/Http/Requests/Api/Client/Servers/GetServerLogsRequest.php create mode 100644 app/Http/Requests/Api/Client/Servers/Schedules/DeleteTaskRequest.php delete mode 100644 app/Http/Requests/Api/Remote/AuthenticateWebsocketDetailsRequest.php create mode 100644 app/Http/Requests/Api/Remote/RemoteRequestNode.php create mode 100644 app/Http/Requests/Api/Remote/ReportBackupRestoreRequest.php delete mode 100644 app/Http/Requests/Auth/LoginRequest.php create mode 100644 app/Http/Requests/Concerns/FiltersDeployTags.php create mode 100644 app/Http/Requests/Concerns/ParsesServerStartupData.php create mode 100644 app/Http/Requests/Concerns/ValidatesArrayExistence.php delete mode 100644 app/Http/Requests/FrontendUserFormRequest.php delete mode 100644 app/Models/APILog.php delete mode 100644 app/Models/EggMount.php create mode 100644 app/Models/Extension.php create mode 100644 app/Models/ExtensionSetting.php delete mode 100644 app/Models/Nest.php delete mode 100644 app/Models/Session.php create mode 100644 app/Models/Tag.php delete mode 100644 app/Models/TaskLog.php create mode 100644 app/Models/Traits/HasHashid.php delete mode 100644 app/Observers/EggVariableObserver.php create mode 100644 app/Providers/ActionServiceProvider.php create mode 100644 app/Providers/ExtensionServiceProvider.php delete mode 100644 app/Providers/RepositoryServiceProvider.php delete mode 100644 app/Providers/RouteServiceProvider.php delete mode 100644 app/Repositories/Eloquent/AllocationRepository.php delete mode 100644 app/Repositories/Eloquent/ApiKeyRepository.php delete mode 100644 app/Repositories/Eloquent/BackupRepository.php delete mode 100644 app/Repositories/Eloquent/DatabaseHostRepository.php delete mode 100644 app/Repositories/Eloquent/DatabaseRepository.php delete mode 100644 app/Repositories/Eloquent/EggRepository.php delete mode 100644 app/Repositories/Eloquent/EggVariableRepository.php delete mode 100644 app/Repositories/Eloquent/EloquentRepository.php delete mode 100644 app/Repositories/Eloquent/LocationRepository.php delete mode 100644 app/Repositories/Eloquent/MountRepository.php delete mode 100644 app/Repositories/Eloquent/NestRepository.php delete mode 100644 app/Repositories/Eloquent/NodeRepository.php delete mode 100644 app/Repositories/Eloquent/PermissionRepository.php delete mode 100644 app/Repositories/Eloquent/RecoveryTokenRepository.php delete mode 100644 app/Repositories/Eloquent/ScheduleRepository.php delete mode 100644 app/Repositories/Eloquent/ServerRepository.php delete mode 100644 app/Repositories/Eloquent/ServerVariableRepository.php delete mode 100644 app/Repositories/Eloquent/SessionRepository.php delete mode 100644 app/Repositories/Eloquent/SettingsRepository.php delete mode 100644 app/Repositories/Eloquent/SubuserRepository.php delete mode 100644 app/Repositories/Eloquent/TaskRepository.php delete mode 100644 app/Repositories/Eloquent/UserRepository.php delete mode 100644 app/Repositories/Repository.php delete mode 100644 app/Repositories/Wings/DaemonBackupRepository.php delete mode 100644 app/Repositories/Wings/DaemonCommandRepository.php delete mode 100644 app/Repositories/Wings/DaemonConfigurationRepository.php delete mode 100644 app/Repositories/Wings/DaemonFileRepository.php delete mode 100644 app/Repositories/Wings/DaemonPowerRepository.php delete mode 100644 app/Repositories/Wings/DaemonRepository.php delete mode 100644 app/Repositories/Wings/DaemonRevocationRepository.php delete mode 100644 app/Repositories/Wings/DaemonServerRepository.php delete mode 100644 app/Repositories/Wings/DaemonTransferRepository.php create mode 100644 app/Rules/TagSlug.php create mode 100644 app/Rules/UserEmail.php create mode 100644 app/Rules/ValidExtensionSettingColor.php create mode 100644 app/Rules/ValidExtensionSettings.php create mode 100644 app/Rules/ValidRuleSet.php create mode 100644 app/Services/Activity/ActivityLogFacetService.php create mode 100644 app/Services/Activity/ActivityLogQueryService.php delete mode 100644 app/Services/Allocations/AllocationDeletionService.php delete mode 100644 app/Services/Allocations/AssignmentService.php delete mode 100644 app/Services/Allocations/FindAssignableAllocationService.php delete mode 100644 app/Services/Api/KeyCreationService.php create mode 100644 app/Services/Backups/BackupListService.php delete mode 100644 app/Services/Backups/InitiateBackupService.php create mode 100644 app/Services/Daemon/BackupsClient.php create mode 100644 app/Services/Daemon/DaemonConnection.php create mode 100644 app/Services/Daemon/DaemonManager.php create mode 100644 app/Services/Daemon/FilesClient.php create mode 100644 app/Services/Daemon/NodeClient.php create mode 100644 app/Services/Daemon/ServerClient.php create mode 100644 app/Services/Databases/DatabaseHostGateway.php delete mode 100644 app/Services/Databases/DatabaseManagementService.php delete mode 100644 app/Services/Databases/DatabasePasswordService.php delete mode 100644 app/Services/Databases/DeployServerDatabaseService.php delete mode 100644 app/Services/Databases/Hosts/HostCreationService.php delete mode 100644 app/Services/Databases/Hosts/HostDeletionService.php delete mode 100644 app/Services/Databases/Hosts/HostUpdateService.php create mode 100644 app/Services/Deployment/NodeTagGate.php create mode 100644 app/Services/Eggs/EggCatalogService.php delete mode 100644 app/Services/Eggs/EggCreationService.php delete mode 100644 app/Services/Eggs/EggDeletionService.php create mode 100644 app/Services/Eggs/EggImportData.php create mode 100644 app/Services/Eggs/EggImportVariable.php delete mode 100644 app/Services/Eggs/EggUpdateService.php delete mode 100644 app/Services/Eggs/Scripts/InstallScriptService.php delete mode 100644 app/Services/Eggs/Sharing/EggImporterService.php delete mode 100644 app/Services/Eggs/Sharing/EggUpdateImporterService.php delete mode 100644 app/Services/Eggs/Variables/VariableCreationService.php delete mode 100644 app/Services/Eggs/Variables/VariableUpdateService.php create mode 100644 app/Services/Extensions/Contracts/ManagesExtensionSettings.php create mode 100644 app/Services/Extensions/ExtensionActionDecorators.php create mode 100644 app/Services/Extensions/ExtensionActionExtender.php create mode 100644 app/Services/Extensions/ExtensionAssetPublisher.php create mode 100644 app/Services/Extensions/ExtensionCompatibility.php create mode 100644 app/Services/Extensions/ExtensionConsoleRegistry.php create mode 100644 app/Services/Extensions/ExtensionFailureAttributor.php create mode 100644 app/Services/Extensions/ExtensionHeadTag.php create mode 100644 app/Services/Extensions/ExtensionHeadTags.php create mode 100644 app/Services/Extensions/ExtensionIconCatalog.php create mode 100644 app/Services/Extensions/ExtensionJobProgress.php create mode 100644 app/Services/Extensions/ExtensionLock.php create mode 100644 app/Services/Extensions/ExtensionManager.php create mode 100644 app/Services/Extensions/ExtensionManifest.php create mode 100644 app/Services/Extensions/ExtensionManifestValidator.php create mode 100644 app/Services/Extensions/ExtensionPackageFiles.php create mode 100644 app/Services/Extensions/ExtensionPackageLocator.php create mode 100644 app/Services/Extensions/ExtensionPermissionRegistry.php create mode 100644 app/Services/Extensions/ExtensionProviderLoader.php create mode 100644 app/Services/Extensions/ExtensionRegistration.php create mode 100644 app/Services/Extensions/ExtensionRepository.php create mode 100644 app/Services/Extensions/ExtensionRuntimeRefresher.php create mode 100644 app/Services/Extensions/ExtensionSettingDefinition.php create mode 100644 app/Services/Extensions/ExtensionSettingFiles.php create mode 100644 app/Services/Extensions/ExtensionSettingValueGuard.php create mode 100644 app/Services/Extensions/ExtensionSettings.php create mode 100644 app/Services/Extensions/ExtensionSettingsDefinition.php create mode 100644 app/Services/Extensions/ExtensionSettingsRegistry.php create mode 100755 app/Services/Extensions/ExtensionStylesheetInspector.php create mode 100644 app/Services/Extensions/Scaffolding/ExtensionScaffolder.php create mode 100644 app/Services/Extensions/Scaffolding/stubs/ci.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/client-index.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/client-server-screen.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/client-styles.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/client-test.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/controller.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/externalize-api.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/gitignore.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/openapi.config.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/package.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/postcss.config.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/provider.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/readme-frontend.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/readme.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/routes-client.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/tsconfig.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/vite.config.stub create mode 100644 app/Services/Extensions/Scaffolding/stubs/vitest.config.stub create mode 100644 app/Services/FilesystemChanges.php delete mode 100644 app/Services/Locations/LocationCreationService.php delete mode 100644 app/Services/Locations/LocationDeletionService.php delete mode 100644 app/Services/Locations/LocationUpdateService.php delete mode 100644 app/Services/Nests/NestCreationService.php delete mode 100644 app/Services/Nests/NestDeletionService.php delete mode 100644 app/Services/Nests/NestUpdateService.php delete mode 100644 app/Services/Nodes/NodeCreationService.php delete mode 100644 app/Services/Nodes/NodeDeletionService.php delete mode 100644 app/Services/Nodes/NodeUpdateService.php delete mode 100644 app/Services/Schedules/ProcessScheduleService.php delete mode 100644 app/Services/Servers/BuildModificationService.php delete mode 100644 app/Services/Servers/DetailsModificationService.php create mode 100644 app/Services/Servers/MountListService.php delete mode 100644 app/Services/Servers/ReinstallServerService.php delete mode 100644 app/Services/Servers/ServerCreationService.php delete mode 100644 app/Services/Servers/ServerDeletionService.php create mode 100644 app/Services/Servers/ServerFinderService.php create mode 100644 app/Services/Servers/ServerInstallService.php delete mode 100644 app/Services/Servers/StartupModificationService.php create mode 100644 app/Services/Servers/SubuserPermissionCatalog.php delete mode 100644 app/Services/Servers/SuspensionService.php delete mode 100644 app/Services/Subusers/SubuserCreationService.php create mode 100644 app/Services/Tags/TagBackfiller.php create mode 100644 app/Services/Tags/TagResolutionService.php create mode 100644 app/Services/Themes/ThemeService.php delete mode 100644 app/Services/Users/ToggleTwoFactorService.php delete mode 100644 app/Services/Users/TwoFactorSetupService.php delete mode 100644 app/Services/Users/UserCreationService.php create mode 100644 app/Services/Users/UserFinderService.php delete mode 100644 app/Services/Users/UserUpdateService.php create mode 100644 app/Support/ActivityLogFilters.php create mode 100644 app/Support/Alerts/AlertsMessageBag.php create mode 100644 app/Support/DatabaseName.php create mode 100644 app/Support/JsonEmptyObject.php create mode 100644 app/Support/JsonValueGuard.php create mode 100644 app/Support/JsonValueTree.php create mode 100644 app/Support/ValidationRuleSubset.php delete mode 100644 app/Traits/Controllers/JavascriptInjection.php create mode 100644 app/Traits/Helpers/ThrottlesLogins.php delete mode 100644 app/Traits/Services/ReturnsUpdatedModels.php delete mode 100644 app/Traits/Services/ValidatesValidationRules.php create mode 100644 app/Transformers/Api/Admin/ActivityLogTransformer.php create mode 100644 app/Transformers/Api/Admin/AllocationTransformer.php create mode 100644 app/Transformers/Api/Admin/ApiKeyTransformer.php create mode 100644 app/Transformers/Api/Admin/BackupTransformer.php create mode 100644 app/Transformers/Api/Admin/BaseAdminTransformer.php create mode 100644 app/Transformers/Api/Admin/DatabaseHostTransformer.php create mode 100644 app/Transformers/Api/Admin/EggTransformer.php create mode 100644 app/Transformers/Api/Admin/EggVariableTransformer.php create mode 100644 app/Transformers/Api/Admin/LocationTransformer.php create mode 100644 app/Transformers/Api/Admin/MountTransformer.php create mode 100644 app/Transformers/Api/Admin/NodeTransformer.php create mode 100644 app/Transformers/Api/Admin/ServerDatabaseTransformer.php create mode 100644 app/Transformers/Api/Admin/ServerTransferTransformer.php create mode 100644 app/Transformers/Api/Admin/ServerTransformer.php create mode 100644 app/Transformers/Api/Admin/ServerVariableTransformer.php create mode 100644 app/Transformers/Api/Admin/SubuserTransformer.php create mode 100644 app/Transformers/Api/Admin/TagTransformer.php create mode 100644 app/Transformers/Api/Admin/UserTransformer.php delete mode 100644 app/Transformers/Api/Application/NestTransformer.php create mode 100644 app/Transformers/Api/Application/ServerTransferTransformer.php create mode 100644 app/Transformers/Api/Application/TagTransformer.php create mode 100644 app/Transformers/Concerns/FormatsActivityLogs.php create mode 100644 app/Validation/ActivityLogRules.php create mode 100644 app/Validation/AllocationRules.php create mode 100644 app/Validation/ApiKeyRules.php create mode 100644 app/Validation/DatabaseHostRules.php create mode 100644 app/Validation/DatabaseRules.php create mode 100644 app/Validation/LocationRules.php create mode 100644 app/Validation/MountRules.php create mode 100644 app/Validation/NodeRules.php create mode 100644 app/Validation/ScheduleRules.php create mode 100644 app/Validation/ServerRules.php create mode 100644 app/Validation/TagRules.php create mode 100644 app/Validation/UserRules.php create mode 100644 app/Validation/UserSSHKeyRules.php delete mode 100644 app/helpers.php delete mode 100644 babel.config.js create mode 100644 bootstrap/providers.php create mode 100644 config/extensions.php delete mode 100644 config/javascript.php delete mode 100644 config/prologue/alerts.php create mode 100644 config/scribe.php create mode 100644 database/Factories/ActivityLogFactory.php create mode 100644 database/Factories/MountFactory.php delete mode 100644 database/Factories/NestFactory.php create mode 100644 database/Factories/TagFactory.php delete mode 100644 database/Seeders/NestSeeder.php create mode 100644 database/migrations/2026_05_30_000000_require_complete_legacy_migration_history.php create mode 100644 database/migrations/2026_05_31_000000_add_sort_order_to_egg_variables_table.php create mode 100644 database/migrations/2026_07_06_000001_create_extensions_tables.php create mode 100644 database/migrations/2026_07_07_000001_drop_extension_quarantine_column.php create mode 100644 database/migrations/2026_08_20_000001_create_tags_tables.php create mode 100644 database/migrations/2026_08_20_000002_backfill_tags_from_nests.php create mode 100644 database/migrations/2026_08_20_000003_make_eggs_nest_id_nullable.php create mode 100644 database/migrations/2026_08_20_000004_relax_nest_id_on_servers_table.php create mode 100644 database/migrations/2026_10_02_215043_add_scope_and_secrets_to_extension_settings.php create mode 100644 database/migrations/2026_10_04_090113_add_unique_server_user_to_subusers_table.php rename database/migrations/{ => old}/2016_01_23_195641_add_allocations_table.php (95%) rename database/migrations/{ => old}/2016_01_23_195851_add_api_keys.php (86%) rename database/migrations/{ => old}/2016_01_23_200044_add_api_permissions.php (93%) rename database/migrations/{ => old}/2016_01_23_200159_add_downloads.php (86%) rename database/migrations/{ => old}/2016_01_23_200421_create_failed_jobs_table.php (94%) rename database/migrations/{ => old}/2016_01_23_200440_create_jobs_table.php (90%) rename database/migrations/{ => old}/2016_01_23_200528_add_locations.php (85%) rename database/migrations/{ => old}/2016_01_23_200648_add_nodes.php (93%) rename database/migrations/{ => old}/2016_01_23_201433_add_password_resets.php (93%) rename database/migrations/{ => old}/2016_01_23_201531_add_permissions.php (95%) rename database/migrations/{ => old}/2016_01_23_201649_add_server_variables.php (94%) rename database/migrations/{ => old}/2016_01_23_201748_add_servers.php (94%) rename database/migrations/{ => old}/2016_01_23_202544_add_service_options.php (95%) rename database/migrations/{ => old}/2016_01_23_202731_add_service_varibles.php (96%) rename database/migrations/{ => old}/2016_01_23_202943_add_services.php (87%) rename database/migrations/{ => old}/2016_01_23_203119_create_settings_table.php (83%) rename database/migrations/{ => old}/2016_01_23_203150_add_subusers.php (87%) rename database/migrations/{ => old}/2016_01_23_203159_add_users.php (90%) rename database/migrations/{ => old}/2016_01_23_203947_create_sessions_table.php (87%) rename database/migrations/{ => old}/2016_01_25_234418_rename_permissions_column.php (92%) rename database/migrations/{ => old}/2016_02_07_172148_add_databases_tables.php (88%) rename database/migrations/{ => old}/2016_02_07_181319_add_database_servers_table.php (95%) rename database/migrations/{ => old}/2016_02_13_154306_add_service_option_default_startup.php (93%) rename database/migrations/{ => old}/2016_02_20_155318_add_unique_service_field.php (74%) rename database/migrations/{ => old}/2016_02_27_163411_add_tasks_table.php (92%) rename database/migrations/{ => old}/2016_02_27_163447_add_tasks_log_table.php (87%) rename database/migrations/{ => old}/2016_03_18_155649_add_nullable_field_lastrun.php (55%) rename database/migrations/{ => old}/2016_08_30_212718_add_ip_alias.php (95%) rename database/migrations/{ => old}/2016_08_30_213301_modify_ip_storage_method.php (88%) rename database/migrations/{ => old}/2016_09_01_193520_add_suspension_for_servers.php (76%) rename database/migrations/{ => old}/2016_09_01_211924_remove_active_column.php (75%) rename database/migrations/{ => old}/2016_09_02_190647_add_sftp_password_storage.php (75%) rename database/migrations/{ => old}/2016_09_04_171338_update_jobs_tables.php (82%) rename database/migrations/{ => old}/2016_09_04_172028_update_failed_jobs_table.php (93%) rename database/migrations/{ => old}/2016_09_04_182835_create_notifications_table.php (95%) rename database/migrations/{ => old}/2016_09_07_163017_add_unique_identifier.php (74%) rename database/migrations/{ => old}/2016_09_14_145945_allow_longer_regex_field.php (91%) rename database/migrations/{ => old}/2016_09_17_194246_add_docker_image_column.php (82%) rename database/migrations/{ => old}/2016_09_21_165554_update_servers_column_name.php (75%) rename database/migrations/{ => old}/2016_09_29_213518_rename_double_insurgency.php (82%) rename database/migrations/{ => old}/2016_10_07_152117_build_api_log_table.php (89%) rename database/migrations/{ => old}/2016_10_14_164802_update_api_keys.php (80%) rename database/migrations/{ => old}/2016_10_23_181719_update_misnamed_bungee.php (86%) rename database/migrations/{ => old}/2016_10_23_193810_add_foreign_keys_servers.php (92%) rename database/migrations/{ => old}/2016_10_23_201624_add_foreign_allocations.php (96%) rename database/migrations/{ => old}/2016_10_23_202222_add_foreign_api_keys.php (76%) rename database/migrations/{ => old}/2016_10_23_202703_add_foreign_api_permissions.php (94%) rename database/migrations/{ => old}/2016_10_23_202953_add_foreign_database_servers.php (92%) rename database/migrations/{ => old}/2016_10_23_203105_add_foreign_databases.php (81%) rename database/migrations/{ => old}/2016_10_23_203335_add_foreign_nodes.php (81%) rename database/migrations/{ => old}/2016_10_23_203522_add_foreign_permissions.php (95%) rename database/migrations/{ => old}/2016_10_23_203857_add_foreign_server_variables.php (95%) rename database/migrations/{ => old}/2016_10_23_204157_add_foreign_service_options.php (94%) rename database/migrations/{ => old}/2016_10_23_204321_add_foreign_service_variables.php (93%) rename database/migrations/{ => old}/2016_10_23_204454_add_foreign_subusers.php (81%) rename database/migrations/{ => old}/2016_10_23_204610_add_foreign_tasks.php (75%) rename database/migrations/{ => old}/2016_11_04_000949_add_ark_service_option_fixed.php (96%) rename database/migrations/{ => old}/2016_11_11_220649_add_pack_support.php (96%) rename database/migrations/{ => old}/2016_11_11_231731_set_service_name_unique.php (74%) rename database/migrations/{ => old}/2016_11_27_142519_add_pack_column.php (78%) rename database/migrations/{ => old}/2016_12_01_173018_add_configurable_upload_limit.php (76%) rename database/migrations/{ => old}/2016_12_02_185206_correct_service_variables.php (97%) rename database/migrations/{ => old}/2017_01_03_150436_fix_misnamed_option_tag.php (92%) rename database/migrations/{ => old}/2017_01_07_154228_create_node_configuration_tokens_table.php (94%) rename database/migrations/{ => old}/2017_01_12_135449_add_more_user_data.php (80%) rename database/migrations/{ => old}/2017_02_02_175548_UpdateColumnNames.php (93%) rename database/migrations/{ => old}/2017_02_03_140948_UpdateNodesTable.php (82%) rename database/migrations/{ => old}/2017_02_03_155554_RenameColumns.php (96%) rename database/migrations/{ => old}/2017_02_05_164123_AdjustColumnNames.php (94%) rename database/migrations/{ => old}/2017_02_05_164516_AdjustColumnNamesForServicePacks.php (95%) rename database/migrations/{ => old}/2017_02_09_174834_SetupPermissionsPivotTable.php (93%) rename database/migrations/{ => old}/2017_02_10_171858_UpdateAPIKeyColumnNames.php (81%) rename database/migrations/{ => old}/2017_03_03_224254_UpdateNodeConfigTokensColumns.php (93%) rename database/migrations/{ => old}/2017_03_05_212803_DeleteServiceExecutableOption.php (83%) rename database/migrations/{ => old}/2017_03_10_162934_AddNewServiceOptionsColumns.php (96%) rename database/migrations/{ => old}/2017_03_10_173607_MigrateToNewServiceSystem.php (87%) rename database/migrations/{ => old}/2017_03_11_215455_ChangeServiceVariablesValidationRules.php (85%) rename database/migrations/{ => old}/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php (92%) rename database/migrations/{ => old}/2017_03_14_175631_RenameServicePacksToSingluarPacks.php (83%) rename database/migrations/{ => old}/2017_03_14_200326_AddLockedStatusToTable.php (75%) rename database/migrations/{ => old}/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php (93%) rename database/migrations/{ => old}/2017_03_16_181515_CleanupDatabasesDatabase.php (82%) rename database/migrations/{ => old}/2017_03_18_204953_AddForeignKeyToPacks.php (75%) rename database/migrations/{ => old}/2017_03_31_221948_AddServerDescriptionColumn.php (75%) rename database/migrations/{ => old}/2017_04_02_163232_DropDeletedAtColumnFromServers.php (75%) rename database/migrations/{ => old}/2017_04_15_125021_UpgradeTaskSystem.php (85%) rename database/migrations/{ => old}/2017_04_20_171943_AddScriptsToServiceOptions.php (95%) rename database/migrations/{ => old}/2017_04_21_151432_AddServiceScriptTrackingToServers.php (76%) rename database/migrations/{ => old}/2017_04_27_145300_AddCopyScriptFromColumn.php (93%) rename database/migrations/{ => old}/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php (77%) rename database/migrations/{ => old}/2017_05_01_141528_DeleteDownloadTable.php (86%) rename database/migrations/{ => old}/2017_05_01_141559_DeleteNodeConfigurationTable.php (91%) rename database/migrations/{ => old}/2017_06_10_152951_add_external_id_to_users.php (76%) rename database/migrations/{ => old}/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php (93%) rename database/migrations/{ => old}/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php (88%) rename database/migrations/{ => old}/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php (94%) rename database/migrations/{ => old}/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php (95%) rename database/migrations/{ => old}/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php (79%) rename database/migrations/{ => old}/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php (94%) rename database/migrations/{ => old}/2017_08_05_144104_AllowNegativeValuesForOverallocation.php (82%) rename database/migrations/{ => old}/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php (94%) rename database/migrations/{ => old}/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php (93%) rename database/migrations/{ => old}/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php (81%) rename database/migrations/{ => old}/2017_09_10_225749_RenameTasksTableForStructureRefactor.php (94%) rename database/migrations/{ => old}/2017_09_10_225941_CreateSchedulesTable.php (91%) rename database/migrations/{ => old}/2017_09_10_230309_CreateNewTasksTableForSchedules.php (90%) rename database/migrations/{ => old}/2017_09_11_002938_TransferOldTasksToNewScheduler.php (93%) rename database/migrations/{ => old}/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php (76%) rename database/migrations/{ => old}/2017_09_23_170933_CreateDaemonKeysTable.php (96%) rename database/migrations/{ => old}/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php (79%) rename database/migrations/{ => old}/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php (76%) rename database/migrations/{ => old}/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php (85%) rename database/migrations/{ => old}/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php (83%) rename database/migrations/{ => old}/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php (93%) rename database/migrations/{ => old}/2017_10_06_214026_ServicesToNestsConversion.php (89%) rename database/migrations/{ => old}/2017_10_06_214053_ServiceOptionsToEggsConversion.php (85%) rename database/migrations/{ => old}/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php (95%) rename database/migrations/{ => old}/2017_10_24_222238_RemoveLegacySFTPInformation.php (80%) rename database/migrations/{ => old}/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php (79%) rename database/migrations/{ => old}/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php (72%) rename database/migrations/{ => old}/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php (94%) rename database/migrations/{ => old}/2017_12_12_220426_MigrateSettingsTableToNewFormat.php (77%) rename database/migrations/{ => old}/2018_01_01_122821_AllowNegativeValuesForServerSwap.php (75%) rename database/migrations/{ => old}/2018_01_11_213943_AddApiKeyPermissionColumns.php (90%) rename database/migrations/{ => old}/2018_01_13_142012_SetupTableForKeyEncryption.php (77%) rename database/migrations/{ => old}/2018_01_13_145209_AddLastUsedAtColumn.php (76%) rename database/migrations/{ => old}/2018_02_04_145617_AllowTextInUserExternalId.php (76%) rename database/migrations/{ => old}/2018_02_10_151150_remove_unique_index_on_external_id_column.php (75%) rename database/migrations/{ => old}/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php (79%) rename database/migrations/{ => old}/2018_02_24_112356_add_external_id_column_to_servers_table.php (76%) rename database/migrations/{ => old}/2018_02_25_160152_remove_default_null_value_on_table.php (84%) rename database/migrations/{ => old}/2018_02_25_160604_define_unique_index_on_users_external_id.php (75%) rename database/migrations/{ => old}/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php (80%) rename database/migrations/{ => old}/2018_03_15_124536_add_description_to_nodes.php (75%) rename database/migrations/{ => old}/2018_05_04_123826_add_maintenance_to_nodes.php (76%) rename database/migrations/{ => old}/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php (93%) rename database/migrations/{ => old}/2018_09_03_144005_allow_server_variables_to_have_longer_values.php (92%) rename database/migrations/{ => old}/2019_03_02_142328_set_allocation_limit_default_null.php (77%) rename database/migrations/{ => old}/2019_03_02_151321_fix_unique_index_to_account_for_host.php (84%) rename database/migrations/{ => old}/2020_03_22_163911_merge_permissions_table_into_subusers.php (82%) rename database/migrations/{ => old}/2020_03_22_164814_drop_permissions_table.php (95%) rename database/migrations/{ => old}/2020_04_03_203624_add_threads_column_to_servers_table.php (75%) rename database/migrations/{ => old}/2020_04_03_230614_create_backups_table.php (89%) rename database/migrations/{ => old}/2020_04_04_131016_add_table_server_transfers.php (97%) rename database/migrations/{ => old}/2020_04_10_141024_store_node_tokens_as_encrypted_value.php (73%) rename database/migrations/{ => old}/2020_04_17_203438_allow_nullable_descriptions.php (63%) rename database/migrations/{ => old}/2020_04_22_055500_add_max_connections_column.php (76%) rename database/migrations/{ => old}/2020_04_26_111208_add_backup_limit_to_servers.php (82%) rename database/migrations/{ => old}/2020_05_20_234655_add_mounts_table.php (87%) rename database/migrations/{ => old}/2020_05_21_192756_add_mount_server_table.php (94%) rename database/migrations/{ => old}/2020_07_02_213612_create_user_recovery_tokens_table.php (94%) rename database/migrations/{ => old}/2020_07_09_201845_add_notes_column_for_allocations.php (93%) rename database/migrations/{ => old}/2020_08_20_205533_add_backup_state_column_to_backups.php (76%) rename database/migrations/{ => old}/2020_08_22_132500_update_bytes_to_unsigned_bigint.php (76%) rename database/migrations/{ => old}/2020_08_23_175331_modify_checksums_column_for_backups.php (63%) rename database/migrations/{ => old}/2020_09_13_110007_drop_packs_from_servers.php (79%) rename database/migrations/{ => old}/2020_09_13_110021_drop_packs_from_api_key_permissions.php (75%) rename database/migrations/{ => old}/2020_09_13_110047_drop_packs_table.php (85%) rename database/migrations/{ => old}/2020_09_13_113503_drop_daemon_key_table.php (95%) rename database/migrations/{ => old}/2020_10_10_165437_change_unique_database_name_to_account_for_server.php (69%) rename database/migrations/{ => old}/2020_10_26_194904_remove_nullable_from_schedule_name_field.php (79%) rename database/migrations/{ => old}/2020_11_02_201014_add_features_column_to_eggs.php (76%) rename database/migrations/{ => old}/2020_12_12_102435_support_multiple_docker_images_and_updates.php (85%) rename database/migrations/{ => old}/2020_12_14_013707_make_successful_nullable_in_server_transfers.php (92%) rename database/migrations/{ => old}/2020_12_17_014330_add_archived_field_to_server_transfers_table.php (94%) rename database/migrations/{ => old}/2020_12_24_092449_make_allocation_fields_json.php (86%) rename database/migrations/{ => old}/2020_12_26_184914_add_upload_id_column_to_backups_table.php (75%) rename database/migrations/{ => old}/2021_01_10_153937_add_file_denylist_to_egg_configs.php (76%) rename database/migrations/{ => old}/2021_01_13_013420_add_cron_month.php (74%) rename database/migrations/{ => old}/2021_01_17_102401_create_audit_logs_table.php (96%) rename database/migrations/{ => old}/2021_01_17_152623_add_generic_server_status_column.php (81%) rename database/migrations/{ => old}/2021_01_26_210502_update_file_denylist_to_json.php (69%) rename database/migrations/{ => old}/2021_02_23_205021_add_index_for_server_and_action.php (84%) rename database/migrations/{ => old}/2021_02_23_212657_make_sftp_port_unsigned_int.php (77%) rename database/migrations/{ => old}/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php (94%) rename database/migrations/{ => old}/2021_05_01_092457_add_continue_on_failure_option_to_tasks.php (77%) rename database/migrations/{ => old}/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php (77%) rename database/migrations/{ => old}/2021_05_03_201016_add_support_for_locking_a_backup.php (76%) rename database/migrations/{ => old}/2021_07_12_013420_remove_userinteraction.php (92%) rename database/migrations/{ => old}/2021_07_17_211512_create_user_ssh_keys_table.php (95%) rename database/migrations/{ => old}/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php (84%) rename database/migrations/{ => old}/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php (86%) rename database/migrations/{ => old}/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php (96%) rename database/migrations/{ => old}/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php (86%) rename database/migrations/{ => old}/2022_01_25_030847_drop_google_analytics.php (95%) rename database/migrations/{ => old}/2022_05_07_165334_migrate_egg_images_array_to_new_format.php (93%) rename database/migrations/{ => old}/2022_05_28_135717_create_activity_logs_table.php (95%) rename database/migrations/{ => old}/2022_05_29_140349_create_activity_log_actors_table.php (93%) rename database/migrations/{ => old}/2022_06_18_112822_track_api_key_usage_for_activity_events.php (87%) rename database/migrations/{ => old}/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php (76%) rename database/migrations/{ => old}/2022_08_16_230204_add_installed_at_column_to_servers_table.php (75%) rename database/migrations/{ => old}/2022_12_12_213937_update_mail_settings_to_new_format.php (82%) rename database/migrations/{ => old}/2023_01_24_210051_add_uuid_column_to_failed_jobs_table.php (79%) rename database/migrations/{ => old}/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php (69%) rename database/migrations/{ => old}/2024_07_13_091852_clear_unused_allocation_notes.php (86%) create mode 100644 database/schema/mariadb-schema.sql create mode 100644 doctor.config.json delete mode 100644 jest.config.js create mode 100644 openapi-ts.config.ts create mode 100644 package-lock.json create mode 100644 packages/hello-world/.gitignore create mode 100644 packages/hello-world/extension.json create mode 100644 packages/hello-world/package.json create mode 100644 packages/hello-world/postcss.config.mjs create mode 100644 packages/hello-world/src/client/FileDetails.tsx create mode 100755 packages/hello-world/src/client/FileEditor.tsx create mode 100644 packages/hello-world/src/client/HelloWorldCard.tsx create mode 100644 packages/hello-world/src/client/HelloWorldScreen.tsx create mode 100644 packages/hello-world/src/client/ServerCard.tsx create mode 100644 packages/hello-world/src/client/SubuserPresets.tsx create mode 100644 packages/hello-world/src/client/examples.spec.tsx create mode 100644 packages/hello-world/src/client/index.tsx create mode 100644 packages/hello-world/src/client/styles.css create mode 100644 packages/hello-world/tsconfig.json create mode 100644 packages/hello-world/vite.config.mjs create mode 100644 packages/hello-world/vitest.config.ts create mode 100644 packages/sdk/README.md create mode 100644 packages/sdk/api-runtime-stub.mjs create mode 100644 packages/sdk/icons.json create mode 100644 packages/sdk/manifest.schema.json create mode 100644 packages/sdk/openapi.mjs create mode 100644 packages/sdk/openapi.spec.ts create mode 100644 packages/sdk/package.json create mode 100644 packages/sdk/prefix.spec.ts create mode 100644 packages/sdk/prepack.mjs create mode 100644 packages/sdk/runtime-stub.mjs create mode 100644 packages/sdk/slot-coverage.spec.ts create mode 100644 packages/sdk/theme-tokens.css create mode 100644 packages/sdk/theme-tokens.spec.ts create mode 100644 packages/sdk/theme.css create mode 100755 packages/sdk/theme.spec.ts create mode 100644 packages/sdk/types-drift.spec.ts create mode 100644 packages/sdk/types/api.d.ts create mode 100644 packages/sdk/types/api/account/types.d.ts create mode 100644 packages/sdk/types/api/admin/users/types.d.ts create mode 100644 packages/sdk/types/api/extensionTypes.d.ts create mode 100644 packages/sdk/types/api/generated/client.gen.d.ts create mode 100644 packages/sdk/types/api/generated/client/client.gen.d.ts create mode 100644 packages/sdk/types/api/generated/client/index.d.ts create mode 100644 packages/sdk/types/api/generated/client/types.gen.d.ts create mode 100644 packages/sdk/types/api/generated/client/utils.gen.d.ts create mode 100644 packages/sdk/types/api/generated/core/auth.gen.d.ts create mode 100644 packages/sdk/types/api/generated/core/bodySerializer.gen.d.ts create mode 100644 packages/sdk/types/api/generated/core/params.gen.d.ts create mode 100644 packages/sdk/types/api/generated/core/pathSerializer.gen.d.ts create mode 100644 packages/sdk/types/api/generated/core/queryKeySerializer.gen.d.ts create mode 100644 packages/sdk/types/api/generated/core/serverSentEvents.gen.d.ts create mode 100644 packages/sdk/types/api/generated/core/types.gen.d.ts create mode 100644 packages/sdk/types/api/generated/types.gen.d.ts create mode 100644 packages/sdk/types/api/hey-api-runtime.d.ts create mode 100644 packages/sdk/types/api/http.d.ts create mode 100644 packages/sdk/types/api/queryClient.d.ts create mode 100644 packages/sdk/types/api/server/queryDomains.d.ts create mode 100644 packages/sdk/types/api/server/types.d.ts create mode 100644 packages/sdk/types/api/settings/types.d.ts create mode 100644 packages/sdk/types/components/elements/Button.d.ts create mode 100644 packages/sdk/types/components/elements/Can.d.ts create mode 100644 packages/sdk/types/components/elements/ContentBox.d.ts create mode 100644 packages/sdk/types/components/elements/CopyOnClick.d.ts create mode 100644 packages/sdk/types/components/elements/Icon.d.ts create mode 100644 packages/sdk/types/components/elements/Label.d.ts create mode 100644 packages/sdk/types/components/elements/NamedIcon.d.ts create mode 100644 packages/sdk/types/components/elements/PageContentBlock.d.ts create mode 100644 packages/sdk/types/components/elements/Pagination.d.ts create mode 100644 packages/sdk/types/components/elements/ScreenBlock.d.ts create mode 100644 packages/sdk/types/components/elements/ServerContentBlock.d.ts create mode 100644 packages/sdk/types/components/elements/Spinner.d.ts create mode 100644 packages/sdk/types/components/elements/TitledGreyBox.d.ts create mode 100644 packages/sdk/types/components/elements/alert/Alert.d.ts create mode 100644 packages/sdk/types/components/elements/alert/index.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/ConfirmationDialog.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/ConfirmationDialogTrigger.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/Dialog.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/DialogTrigger.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/context.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/index.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/types.d.ts create mode 100644 packages/sdk/types/components/elements/dialog/useDialogState.d.ts create mode 100644 packages/sdk/types/components/elements/dropdown/DropdownMenu.d.ts create mode 100644 packages/sdk/types/components/form/Form.d.ts create mode 100644 packages/sdk/types/components/form/SubmitButton.d.ts create mode 100644 packages/sdk/types/components/form/context.d.ts create mode 100644 packages/sdk/types/components/form/controls.d.ts create mode 100644 packages/sdk/types/components/form/fields.d.ts create mode 100644 packages/sdk/types/components/form/index.d.ts create mode 100644 packages/sdk/types/components/server/events.d.ts create mode 100644 packages/sdk/types/components/ui/Checkbox.d.ts create mode 100644 packages/sdk/types/components/ui/Select.d.ts create mode 100644 packages/sdk/types/components/ui/Switch.d.ts create mode 100644 packages/sdk/types/components/ui/empty.d.ts create mode 100644 packages/sdk/types/extensions/componentTypes.d.ts create mode 100644 packages/sdk/types/extensions/context.d.ts create mode 100644 packages/sdk/types/extensions/registry.d.ts create mode 100644 packages/sdk/types/extensions/resourceContext.d.ts create mode 100644 packages/sdk/types/extensions/tableTypes.d.ts create mode 100644 packages/sdk/types/index.d.ts create mode 100644 packages/sdk/types/plugins/useNavigationBlocker.d.ts create mode 100644 packages/sdk/types/plugins/usePermissions.d.ts create mode 100644 packages/sdk/types/sdk/api.d.ts create mode 100644 packages/sdk/types/sdk/index.d.ts create mode 100644 packages/sdk/types/sdk/localization.d.ts create mode 100644 packages/sdk/types/sdk/mutations.d.ts create mode 100644 packages/sdk/types/sdk/navigation.d.ts create mode 100644 packages/sdk/types/sdk/progress.d.ts create mode 100644 packages/sdk/types/sdk/server.d.ts create mode 100644 packages/sdk/types/sdk/testing.d.ts create mode 100644 packages/sdk/types/sdk/theme.d.ts create mode 100644 packages/sdk/types/sdk/ui.d.ts create mode 100644 packages/sdk/types/testing.d.ts create mode 100644 packages/sdk/vite.mjs create mode 100644 packages/sdk/vite.spec.ts create mode 100644 packages/sdk/vitest-setup.mjs create mode 100644 packages/sdk/vitest.mjs create mode 100644 phpstan-rules.neon create mode 100644 pint.json delete mode 100644 public/js/autocomplete.js delete mode 100644 public/js/keyboard.polyfill.js delete mode 100644 public/js/laroute.js delete mode 100644 public/themes/pterodactyl/css/checkbox.css delete mode 100644 public/themes/pterodactyl/css/pterodactyl.css delete mode 100644 public/themes/pterodactyl/css/terminal.css delete mode 100644 public/themes/pterodactyl/js/admin/functions.js delete mode 100644 public/themes/pterodactyl/js/admin/new-server.js delete mode 100644 public/themes/pterodactyl/js/admin/server/transfer.js delete mode 100644 public/themes/pterodactyl/js/plugins/minecraft/eula.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ace.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-elastic_tabstops_lite.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-error_marker.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-linking.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-modelist.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-old_ie.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-searchbox.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-settings_menu.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-spellcheck.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-split.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-static_highlight.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-textarea.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-themelist.js delete mode 100644 public/themes/pterodactyl/vendor/ace/ext-whitespace.js delete mode 100644 public/themes/pterodactyl/vendor/ace/keybinding-emacs.js delete mode 100644 public/themes/pterodactyl/vendor/ace/keybinding-vim.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-assembly_x86.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-c_cpp.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-coffee.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-csharp.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-css.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-golang.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-haml.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-html.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-ini.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-java.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-javascript.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-json.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-kotlin.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-lua.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-markdown.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-mysql.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-objectivec.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-perl.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-php.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-plain_text.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-properties.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-python.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-ruby.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-rust.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-sh.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-smarty.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-sql.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-xml.js delete mode 100644 public/themes/pterodactyl/vendor/ace/mode-yaml.js delete mode 100644 public/themes/pterodactyl/vendor/ace/theme-chrome.js delete mode 100644 public/themes/pterodactyl/vendor/ace/worker-css.js delete mode 100644 public/themes/pterodactyl/vendor/ace/worker-html.js delete mode 100644 public/themes/pterodactyl/vendor/ace/worker-javascript.js delete mode 100644 public/themes/pterodactyl/vendor/ace/worker-json.js delete mode 100644 public/themes/pterodactyl/vendor/ace/worker-lua.js delete mode 100644 public/themes/pterodactyl/vendor/ace/worker-php.js delete mode 100644 public/themes/pterodactyl/vendor/ace/worker-xml.js delete mode 100755 public/themes/pterodactyl/vendor/adminlte/admin.min.css delete mode 100755 public/themes/pterodactyl/vendor/adminlte/adminlte.min.css.map delete mode 100755 public/themes/pterodactyl/vendor/adminlte/app.min.js delete mode 100755 public/themes/pterodactyl/vendor/adminlte/colors/skin-blue.min.css delete mode 100644 public/themes/pterodactyl/vendor/animate/animate.min.css delete mode 100644 public/themes/pterodactyl/vendor/ansi/ansi_up.js delete mode 100755 public/themes/pterodactyl/vendor/async/async.min.js delete mode 100755 public/themes/pterodactyl/vendor/async/async.min.map delete mode 100644 public/themes/pterodactyl/vendor/bootstrap-notify/bootstrap-notify.min.js delete mode 100755 public/themes/pterodactyl/vendor/bootstrap/bootstrap-theme.min.css delete mode 100755 public/themes/pterodactyl/vendor/bootstrap/bootstrap-theme.min.css.map delete mode 100755 public/themes/pterodactyl/vendor/bootstrap/bootstrap.min.css delete mode 100755 public/themes/pterodactyl/vendor/bootstrap/bootstrap.min.css.map delete mode 100755 public/themes/pterodactyl/vendor/bootstrap/bootstrap.min.js delete mode 100644 public/themes/pterodactyl/vendor/chartjs/chart.min.js delete mode 100644 public/themes/pterodactyl/vendor/fontawesome/animation.min.css delete mode 100644 public/themes/pterodactyl/vendor/jquery/date-format.min.js delete mode 100644 public/themes/pterodactyl/vendor/jquery/jquery.js delete mode 100644 public/themes/pterodactyl/vendor/jquery/jquery.min.js delete mode 100644 public/themes/pterodactyl/vendor/jquery/jquery.min.map delete mode 100644 public/themes/pterodactyl/vendor/lodash/lodash.js delete mode 100755 public/themes/pterodactyl/vendor/mousewheel/jquery.mousewheel-min.js delete mode 100644 public/themes/pterodactyl/vendor/particlesjs/particles.json delete mode 100644 public/themes/pterodactyl/vendor/particlesjs/particles.min.js delete mode 100755 public/themes/pterodactyl/vendor/select2/select2.full.min.js delete mode 100755 public/themes/pterodactyl/vendor/select2/select2.min.css delete mode 100755 public/themes/pterodactyl/vendor/siofu/client.min.js delete mode 100755 public/themes/pterodactyl/vendor/slimscroll/jquery.slimscroll.min.js delete mode 100644 public/themes/pterodactyl/vendor/socketio/socket.io.js.map delete mode 100644 public/themes/pterodactyl/vendor/socketio/socket.io.v203.min.js delete mode 100644 public/themes/pterodactyl/vendor/sweetalert/sweetalert.min.css delete mode 100644 public/themes/pterodactyl/vendor/sweetalert/sweetalert.min.js create mode 100644 rector.php delete mode 100644 resources/lang/en/admin/nests.php delete mode 100644 resources/scripts/TransitionRouter.tsx delete mode 100644 resources/scripts/__mocks__/file.ts delete mode 100644 resources/scripts/api/account/activity.ts create mode 100644 resources/scripts/api/account/activity/queries.ts create mode 100644 resources/scripts/api/account/api-keys/queries.spec.tsx create mode 100644 resources/scripts/api/account/api-keys/queries.ts delete mode 100644 resources/scripts/api/account/createApiKey.ts delete mode 100644 resources/scripts/api/account/deleteApiKey.ts delete mode 100644 resources/scripts/api/account/disableAccountTwoFactor.ts delete mode 100644 resources/scripts/api/account/enableAccountTwoFactor.ts delete mode 100644 resources/scripts/api/account/getApiKeys.ts delete mode 100644 resources/scripts/api/account/getTwoFactorTokenData.ts create mode 100644 resources/scripts/api/account/queries.spec.tsx create mode 100644 resources/scripts/api/account/queries.ts create mode 100644 resources/scripts/api/account/servers/queries.ts delete mode 100644 resources/scripts/api/account/ssh-keys.ts create mode 100644 resources/scripts/api/account/ssh-keys/queries.ts create mode 100644 resources/scripts/api/account/two-factor/queries.ts create mode 100644 resources/scripts/api/account/types.ts delete mode 100644 resources/scripts/api/account/updateAccountEmail.ts delete mode 100644 resources/scripts/api/account/updateAccountPassword.ts create mode 100644 resources/scripts/api/activity.ts create mode 100644 resources/scripts/api/activityFacets.ts create mode 100644 resources/scripts/api/admin/activity/queries.spec.tsx create mode 100644 resources/scripts/api/admin/activity/queries.ts create mode 100644 resources/scripts/api/admin/api-keys/queries.ts create mode 100644 resources/scripts/api/admin/completeLists.spec.ts create mode 100644 resources/scripts/api/admin/database-hosts/queries.ts create mode 100644 resources/scripts/api/admin/eggs/catalog.ts create mode 100644 resources/scripts/api/admin/eggs/queries.spec.tsx create mode 100644 resources/scripts/api/admin/eggs/queries.ts create mode 100644 resources/scripts/api/admin/extensions/queries.ts create mode 100644 resources/scripts/api/admin/languages/queries.ts create mode 100644 resources/scripts/api/admin/locations/queries.ts create mode 100644 resources/scripts/api/admin/mounts/queries.ts create mode 100644 resources/scripts/api/admin/nodes/invalidation.ts create mode 100644 resources/scripts/api/admin/nodes/queries.ts create mode 100644 resources/scripts/api/admin/servers/queries.spec.tsx create mode 100644 resources/scripts/api/admin/servers/queries.ts create mode 100644 resources/scripts/api/admin/settings/queries.spec.tsx create mode 100644 resources/scripts/api/admin/settings/queries.ts create mode 100644 resources/scripts/api/admin/tags/queries.spec.ts create mode 100644 resources/scripts/api/admin/tags/queries.ts create mode 100644 resources/scripts/api/admin/users/queries.ts create mode 100644 resources/scripts/api/admin/users/types.ts create mode 100644 resources/scripts/api/admin/version/queries.ts delete mode 100644 resources/scripts/api/auth/login.ts delete mode 100644 resources/scripts/api/auth/loginCheckpoint.ts delete mode 100644 resources/scripts/api/auth/performPasswordReset.ts create mode 100644 resources/scripts/api/auth/queries.ts delete mode 100644 resources/scripts/api/auth/requestPasswordResetEmail.ts create mode 100644 resources/scripts/api/client-meta.d.ts delete mode 100644 resources/scripts/api/definitions/helpers.ts delete mode 100644 resources/scripts/api/definitions/index.d.ts delete mode 100644 resources/scripts/api/definitions/user/index.ts delete mode 100644 resources/scripts/api/definitions/user/models.d.ts delete mode 100644 resources/scripts/api/definitions/user/transformers.ts create mode 100644 resources/scripts/api/extensionProgress.ts create mode 100644 resources/scripts/api/extensionTypes.ts create mode 100644 resources/scripts/api/generated/@tanstack/react-query.gen.ts create mode 100644 resources/scripts/api/generated/client.gen.ts create mode 100644 resources/scripts/api/generated/client/client.gen.ts create mode 100644 resources/scripts/api/generated/client/index.ts create mode 100644 resources/scripts/api/generated/client/types.gen.ts create mode 100644 resources/scripts/api/generated/client/utils.gen.ts create mode 100644 resources/scripts/api/generated/core/auth.gen.ts create mode 100644 resources/scripts/api/generated/core/bodySerializer.gen.ts create mode 100644 resources/scripts/api/generated/core/params.gen.ts create mode 100644 resources/scripts/api/generated/core/pathSerializer.gen.ts create mode 100644 resources/scripts/api/generated/core/queryKeySerializer.gen.ts create mode 100644 resources/scripts/api/generated/core/serverSentEvents.gen.ts create mode 100644 resources/scripts/api/generated/core/types.gen.ts create mode 100644 resources/scripts/api/generated/core/utils.gen.ts create mode 100644 resources/scripts/api/generated/index.ts create mode 100644 resources/scripts/api/generated/sdk.gen.ts create mode 100644 resources/scripts/api/generated/types.gen.ts delete mode 100644 resources/scripts/api/getServers.ts delete mode 100644 resources/scripts/api/getSystemPermissions.ts create mode 100644 resources/scripts/api/hey-api-runtime.ts create mode 100644 resources/scripts/api/mutationUtils.spec.ts create mode 100644 resources/scripts/api/mutationUtils.ts create mode 100644 resources/scripts/api/pagination.spec.ts create mode 100644 resources/scripts/api/pagination.spec.tsx create mode 100644 resources/scripts/api/pagination.ts create mode 100644 resources/scripts/api/queryClient.ts create mode 100644 resources/scripts/api/queryData.spec.ts create mode 100644 resources/scripts/api/queryData.ts create mode 100644 resources/scripts/api/queryKeyGuards.ts create mode 100644 resources/scripts/api/queryLifecycle.spec.tsx create mode 100644 resources/scripts/api/queryParameters.spec.ts create mode 100644 resources/scripts/api/queryParameters.ts create mode 100644 resources/scripts/api/queryRetry.spec.ts create mode 100644 resources/scripts/api/queryRetry.ts create mode 100644 resources/scripts/api/relationships.ts create mode 100644 resources/scripts/api/resourceQuery.ts delete mode 100644 resources/scripts/api/server/activity.ts create mode 100644 resources/scripts/api/server/activity/queries.ts delete mode 100644 resources/scripts/api/server/backups/createServerBackup.ts delete mode 100644 resources/scripts/api/server/backups/deleteBackup.ts delete mode 100644 resources/scripts/api/server/backups/getBackupDownloadUrl.ts delete mode 100644 resources/scripts/api/server/backups/index.ts create mode 100644 resources/scripts/api/server/backups/queries.spec.tsx create mode 100644 resources/scripts/api/server/backups/queries.ts delete mode 100644 resources/scripts/api/server/databases/createServerDatabase.ts delete mode 100644 resources/scripts/api/server/databases/deleteServerDatabase.ts delete mode 100644 resources/scripts/api/server/databases/getServerDatabases.ts create mode 100644 resources/scripts/api/server/databases/queries.ts delete mode 100644 resources/scripts/api/server/databases/rotateDatabasePassword.ts delete mode 100644 resources/scripts/api/server/files/chmodFiles.ts delete mode 100644 resources/scripts/api/server/files/compressFiles.ts delete mode 100644 resources/scripts/api/server/files/copyFile.ts delete mode 100644 resources/scripts/api/server/files/createDirectory.ts delete mode 100644 resources/scripts/api/server/files/decompressFiles.ts delete mode 100644 resources/scripts/api/server/files/deleteFiles.ts delete mode 100644 resources/scripts/api/server/files/getFileContents.ts delete mode 100644 resources/scripts/api/server/files/getFileDownloadUrl.ts delete mode 100644 resources/scripts/api/server/files/getFileUploadUrl.ts delete mode 100644 resources/scripts/api/server/files/loadDirectory.ts create mode 100644 resources/scripts/api/server/files/queries.spec.tsx create mode 100644 resources/scripts/api/server/files/queries.ts delete mode 100644 resources/scripts/api/server/files/renameFiles.ts delete mode 100644 resources/scripts/api/server/files/saveFileContents.ts delete mode 100644 resources/scripts/api/server/getServer.ts delete mode 100644 resources/scripts/api/server/getServerResourceUsage.ts delete mode 100644 resources/scripts/api/server/getWebsocketToken.ts create mode 100755 resources/scripts/api/server/logs/queries.ts delete mode 100644 resources/scripts/api/server/network/createServerAllocation.ts delete mode 100644 resources/scripts/api/server/network/deleteServerAllocation.ts create mode 100644 resources/scripts/api/server/network/queries.ts delete mode 100644 resources/scripts/api/server/network/setPrimaryServerAllocation.ts delete mode 100644 resources/scripts/api/server/network/setServerAllocationNotes.ts create mode 100644 resources/scripts/api/server/power/queries.ts create mode 100644 resources/scripts/api/server/queries.ts create mode 100644 resources/scripts/api/server/queryDomains.ts delete mode 100644 resources/scripts/api/server/reinstallServer.ts delete mode 100644 resources/scripts/api/server/renameServer.ts delete mode 100644 resources/scripts/api/server/schedules/createOrUpdateSchedule.ts delete mode 100644 resources/scripts/api/server/schedules/createOrUpdateScheduleTask.ts delete mode 100644 resources/scripts/api/server/schedules/deleteSchedule.ts delete mode 100644 resources/scripts/api/server/schedules/deleteScheduleTask.ts delete mode 100644 resources/scripts/api/server/schedules/getServerSchedule.ts delete mode 100644 resources/scripts/api/server/schedules/getServerSchedules.ts create mode 100644 resources/scripts/api/server/schedules/queries.ts delete mode 100644 resources/scripts/api/server/schedules/triggerScheduleExecution.ts delete mode 100644 resources/scripts/api/server/setSelectedDockerImage.ts create mode 100644 resources/scripts/api/server/startup/queries.spec.tsx create mode 100644 resources/scripts/api/server/startup/queries.ts delete mode 100644 resources/scripts/api/server/types.d.ts create mode 100644 resources/scripts/api/server/types.ts delete mode 100644 resources/scripts/api/server/updateStartupVariable.ts delete mode 100644 resources/scripts/api/server/users/createOrUpdateSubuser.ts delete mode 100644 resources/scripts/api/server/users/deleteSubuser.ts delete mode 100644 resources/scripts/api/server/users/getServerSubusers.ts create mode 100644 resources/scripts/api/server/users/queries.ts create mode 100644 resources/scripts/api/settings/queries.ts create mode 100644 resources/scripts/api/settings/types.ts delete mode 100644 resources/scripts/api/swr/getServerAllocations.ts delete mode 100644 resources/scripts/api/swr/getServerBackups.ts delete mode 100644 resources/scripts/api/swr/getServerStartup.ts create mode 100644 resources/scripts/api/system/queries.ts delete mode 100644 resources/scripts/api/transformers.ts delete mode 100644 resources/scripts/assets/css/GlobalStylesheet.ts create mode 100644 resources/scripts/assets/fonts/ibm-plex-sans-latin-wght-normal.woff2 create mode 100644 resources/scripts/bootstrap.ts delete mode 100644 resources/scripts/components/FlashMessageRender.tsx delete mode 100644 resources/scripts/components/MessageBox.tsx create mode 100644 resources/scripts/components/admin/AdminContentBlock.tsx create mode 100644 resources/scripts/components/admin/AdminListEmpty.spec.tsx create mode 100644 resources/scripts/components/admin/AdminListEmpty.tsx create mode 100644 resources/scripts/components/admin/AdminResourceTables.spec.tsx create mode 100644 resources/scripts/components/admin/AdminSidebar.spec.tsx create mode 100644 resources/scripts/components/admin/AdminSidebar.tsx create mode 100644 resources/scripts/components/admin/README.md create mode 100644 resources/scripts/components/admin/activity/ActivityContainer.tsx create mode 100644 resources/scripts/components/admin/api/ApiKeyTable.tsx create mode 100644 resources/scripts/components/admin/api/ApiKeysContainer.tsx create mode 100644 resources/scripts/components/admin/api/CreateApiKeyButton.tsx create mode 100644 resources/scripts/components/admin/databases/CreateDatabaseHostButton.tsx create mode 100644 resources/scripts/components/admin/databases/CreateDatabaseHostForm.tsx create mode 100644 resources/scripts/components/admin/databases/DatabaseHostDetailContainer.tsx create mode 100644 resources/scripts/components/admin/databases/DatabaseHostNodeSelect.tsx create mode 100644 resources/scripts/components/admin/databases/DatabaseHostTable.tsx create mode 100644 resources/scripts/components/admin/databases/DatabaseHostsContainer.tsx create mode 100644 resources/scripts/components/admin/databases/databaseHostForm.spec.ts create mode 100644 resources/scripts/components/admin/databases/databaseHostForm.ts create mode 100644 resources/scripts/components/admin/eggs/CreateEggForm.tsx create mode 100644 resources/scripts/components/admin/eggs/CreateEggVariableButton.tsx create mode 100644 resources/scripts/components/admin/eggs/DeleteEggButton.tsx create mode 100644 resources/scripts/components/admin/eggs/EggCatalogContainer.spec.tsx create mode 100644 resources/scripts/components/admin/eggs/EggCatalogContainer.tsx create mode 100644 resources/scripts/components/admin/eggs/EggConfigurationForm.tsx create mode 100644 resources/scripts/components/admin/eggs/EggConfigurationTab.tsx create mode 100644 resources/scripts/components/admin/eggs/EggDetailContainer.tsx create mode 100644 resources/scripts/components/admin/eggs/EggFileDialog.tsx create mode 100644 resources/scripts/components/admin/eggs/EggScriptTab.tsx create mode 100644 resources/scripts/components/admin/eggs/EggTagsTab.tsx create mode 100644 resources/scripts/components/admin/eggs/EggVariableBox.tsx create mode 100644 resources/scripts/components/admin/eggs/EggVariablesTab.spec.tsx create mode 100644 resources/scripts/components/admin/eggs/EggVariablesTab.tsx create mode 100644 resources/scripts/components/admin/eggs/EggsContainer.spec.tsx create mode 100644 resources/scripts/components/admin/eggs/EggsContainer.tsx create mode 100644 resources/scripts/components/admin/eggs/ExportEggButton.tsx create mode 100644 resources/scripts/components/admin/eggs/ImportEggButton.tsx create mode 100644 resources/scripts/components/admin/eggs/UpdateEggFromFileButton.tsx create mode 100644 resources/scripts/components/admin/eggs/helpers.ts create mode 100644 resources/scripts/components/admin/eggs/useEggDetail.ts create mode 100644 resources/scripts/components/admin/extensions/ExtensionsContainer.tsx create mode 100644 resources/scripts/components/admin/extensions/SettingField.spec.tsx create mode 100644 resources/scripts/components/admin/extensions/SettingField.tsx create mode 100644 resources/scripts/components/admin/extensions/SettingsSections.spec.tsx create mode 100644 resources/scripts/components/admin/extensions/SettingsSections.tsx create mode 100644 resources/scripts/components/admin/languageOptions.ts create mode 100644 resources/scripts/components/admin/locations/CreateLocationButton.tsx create mode 100644 resources/scripts/components/admin/locations/LocationDetailContainer.tsx create mode 100644 resources/scripts/components/admin/locations/LocationTable.tsx create mode 100644 resources/scripts/components/admin/locations/LocationsContainer.tsx create mode 100644 resources/scripts/components/admin/mounts/AttachEggsModal.tsx create mode 100644 resources/scripts/components/admin/mounts/AttachNodesModal.tsx create mode 100644 resources/scripts/components/admin/mounts/CreateMountButton.tsx create mode 100644 resources/scripts/components/admin/mounts/CreateMountForm.tsx create mode 100644 resources/scripts/components/admin/mounts/MountDetailContainer.tsx create mode 100644 resources/scripts/components/admin/mounts/MountFormFields.tsx create mode 100644 resources/scripts/components/admin/mounts/MountTable.tsx create mode 100644 resources/scripts/components/admin/mounts/MountsContainer.tsx create mode 100644 resources/scripts/components/admin/nodes/CreateNodeButton.tsx create mode 100644 resources/scripts/components/admin/nodes/CreateNodeForm.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeAboutTab.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeAllocationTab.spec.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeAllocationTab.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeConfigurationTab.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeDetailContainer.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeFormFields.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeServersTab.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeSettingsTab.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeStatusBadge.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeTable.spec.tsx create mode 100644 resources/scripts/components/admin/nodes/NodeTable.tsx create mode 100644 resources/scripts/components/admin/nodes/NodesContainer.tsx create mode 100644 resources/scripts/components/admin/nodes/nodeConfigurationYaml.spec.ts create mode 100644 resources/scripts/components/admin/nodes/nodeConfigurationYaml.ts create mode 100644 resources/scripts/components/admin/nodes/nodeForm.spec.ts create mode 100644 resources/scripts/components/admin/nodes/nodeForm.ts create mode 100644 resources/scripts/components/admin/nodes/useNodeDetail.ts create mode 100644 resources/scripts/components/admin/numberInput.spec.ts create mode 100644 resources/scripts/components/admin/numberInput.ts create mode 100644 resources/scripts/components/admin/overview/OverviewContainer.tsx create mode 100644 resources/scripts/components/admin/overview/OverviewVersionCard.spec.tsx create mode 100644 resources/scripts/components/admin/overview/OverviewVersionCard.tsx create mode 100644 resources/scripts/components/admin/servers/CreateServerButton.tsx create mode 100644 resources/scripts/components/admin/servers/CreateServerDatabaseButton.tsx create mode 100644 resources/scripts/components/admin/servers/CreateServerForm.tsx create mode 100644 resources/scripts/components/admin/servers/ServerAboutTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerBuildTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerDatabaseRow.tsx create mode 100644 resources/scripts/components/admin/servers/ServerDatabaseTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerDeleteTab.spec.tsx create mode 100644 resources/scripts/components/admin/servers/ServerDeleteTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerDetailContainer.tsx create mode 100644 resources/scripts/components/admin/servers/ServerDetailsTab.spec.tsx create mode 100644 resources/scripts/components/admin/servers/ServerDetailsTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerEditAction.tsx create mode 100644 resources/scripts/components/admin/servers/ServerManageTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerMountsTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerStartupTab.spec.tsx create mode 100644 resources/scripts/components/admin/servers/ServerStartupTab.tsx create mode 100644 resources/scripts/components/admin/servers/ServerStatusBadge.tsx create mode 100644 resources/scripts/components/admin/servers/ServerTable.spec.tsx create mode 100644 resources/scripts/components/admin/servers/ServerTable.tsx create mode 100644 resources/scripts/components/admin/servers/ServersContainer.tsx create mode 100644 resources/scripts/components/admin/servers/TransferServerModal.tsx create mode 100644 resources/scripts/components/admin/servers/helpers.spec.ts create mode 100644 resources/scripts/components/admin/servers/helpers.ts create mode 100644 resources/scripts/components/admin/servers/useServerDetail.ts create mode 100644 resources/scripts/components/admin/settings/AdvancedSettingsForm.tsx create mode 100644 resources/scripts/components/admin/settings/GeneralSettingsForm.tsx create mode 100644 resources/scripts/components/admin/settings/MailSettingsForm.tsx create mode 100644 resources/scripts/components/admin/settings/SettingsContainer.tsx create mode 100644 resources/scripts/components/admin/settings/SettingsForms.spec.tsx create mode 100644 resources/scripts/components/admin/settings/SettingsTabButton.tsx create mode 100644 resources/scripts/components/admin/tags/CreateTagButton.tsx create mode 100644 resources/scripts/components/admin/tags/TagBadge.tsx create mode 100644 resources/scripts/components/admin/tags/TagFormDialog.tsx create mode 100644 resources/scripts/components/admin/tags/TagTable.tsx create mode 100644 resources/scripts/components/admin/tags/TagsContainer.tsx create mode 100644 resources/scripts/components/admin/users/CreateUserButton.tsx create mode 100644 resources/scripts/components/admin/users/CreateUserForm.tsx create mode 100644 resources/scripts/components/admin/users/UserDetailContainer.tsx create mode 100644 resources/scripts/components/admin/users/UserFormFields.tsx create mode 100644 resources/scripts/components/admin/users/UserTable.tsx create mode 100644 resources/scripts/components/admin/users/UsersContainer.tsx create mode 100644 resources/scripts/components/dashboard/AccountApiTable.tsx create mode 100644 resources/scripts/components/dashboard/AccountOverviewCardGrid.tsx create mode 100644 resources/scripts/components/dashboard/ApiKeyModalContent.tsx create mode 100644 resources/scripts/components/dashboard/SearchServerResult.tsx create mode 100644 resources/scripts/components/dashboard/ServerCardView.tsx create mode 100644 resources/scripts/components/dashboard/ServerRow.spec.tsx create mode 100644 resources/scripts/components/dashboard/ServerRowMetrics.tsx create mode 100644 resources/scripts/components/dashboard/ssh/AccountSSHTable.tsx create mode 100644 resources/scripts/components/elements/AppToaster.tsx delete mode 100644 resources/scripts/components/elements/AuthenticatedRoute.tsx create mode 100644 resources/scripts/components/elements/Button.spec.tsx delete mode 100644 resources/scripts/components/elements/Checkbox.tsx create mode 100644 resources/scripts/components/elements/CodemirrorEditor.spec.tsx delete mode 100644 resources/scripts/components/elements/ConfirmationModal.tsx create mode 100644 resources/scripts/components/elements/CopyOnClick.spec.tsx delete mode 100644 resources/scripts/components/elements/DropdownMenu.tsx create mode 100644 resources/scripts/components/elements/ErrorBoundary.spec.tsx delete mode 100644 resources/scripts/components/elements/Fade.tsx delete mode 100644 resources/scripts/components/elements/Field.tsx delete mode 100644 resources/scripts/components/elements/FormikFieldWrapper.tsx delete mode 100644 resources/scripts/components/elements/FormikSwitch.tsx delete mode 100644 resources/scripts/components/elements/Input.tsx delete mode 100644 resources/scripts/components/elements/InputError.tsx create mode 100644 resources/scripts/components/elements/InvisibleRecaptcha.spec.tsx create mode 100644 resources/scripts/components/elements/InvisibleRecaptcha.tsx create mode 100644 resources/scripts/components/elements/LazyCodemirrorEditor.tsx create mode 100644 resources/scripts/components/elements/ListToolbar.tsx delete mode 100644 resources/scripts/components/elements/Modal.tsx create mode 100644 resources/scripts/components/elements/NamedIcon.spec.tsx create mode 100644 resources/scripts/components/elements/NamedIcon.tsx create mode 100644 resources/scripts/components/elements/NewButton.tsx create mode 100644 resources/scripts/components/elements/PageHeading.tsx create mode 100644 resources/scripts/components/elements/ScreenBlock.spec.tsx delete mode 100644 resources/scripts/components/elements/Select.tsx create mode 100644 resources/scripts/components/elements/SubNavigationLayout.tsx delete mode 100644 resources/scripts/components/elements/Switch.tsx create mode 100644 resources/scripts/components/elements/activity/ActivityLogView.spec.tsx create mode 100644 resources/scripts/components/elements/activity/ActivityLogView.tsx delete mode 100644 resources/scripts/components/elements/activity/style.module.css delete mode 100644 resources/scripts/components/elements/button/Button.tsx delete mode 100644 resources/scripts/components/elements/button/index.ts delete mode 100644 resources/scripts/components/elements/button/style.module.css delete mode 100644 resources/scripts/components/elements/button/types.ts create mode 100644 resources/scripts/components/elements/codemirror/languages.spec.ts create mode 100644 resources/scripts/components/elements/codemirror/languages.ts create mode 100644 resources/scripts/components/elements/codemirror/layout.ts create mode 100644 resources/scripts/components/elements/dialog/ConfirmationDialog.spec.tsx create mode 100644 resources/scripts/components/elements/dialog/ConfirmationDialogTrigger.tsx create mode 100644 resources/scripts/components/elements/dialog/DialogTrigger.spec.tsx create mode 100644 resources/scripts/components/elements/dialog/DialogTrigger.tsx delete mode 100644 resources/scripts/components/elements/dialog/style.module.css create mode 100644 resources/scripts/components/elements/dialog/useDialogState.ts delete mode 100644 resources/scripts/components/elements/dropdown/Dropdown.tsx delete mode 100644 resources/scripts/components/elements/dropdown/DropdownButton.tsx delete mode 100644 resources/scripts/components/elements/dropdown/DropdownItem.tsx create mode 100644 resources/scripts/components/elements/dropdown/DropdownMenu.tsx delete mode 100644 resources/scripts/components/elements/dropdown/index.ts delete mode 100644 resources/scripts/components/elements/dropdown/style.module.css create mode 100644 resources/scripts/components/elements/iconCatalog.ts delete mode 100644 resources/scripts/components/elements/inputs/Checkbox.tsx delete mode 100644 resources/scripts/components/elements/inputs/InputField.tsx delete mode 100644 resources/scripts/components/elements/inputs/index.ts delete mode 100644 resources/scripts/components/elements/inputs/styles.module.css create mode 100644 resources/scripts/components/elements/table/DataTable.spec.tsx create mode 100644 resources/scripts/components/elements/table/DataTable.tsx create mode 100644 resources/scripts/components/elements/table/DataTableColumnHeader.tsx create mode 100644 resources/scripts/components/elements/table/DataTablePagination.tsx create mode 100644 resources/scripts/components/elements/table/PaginationFooter.spec.tsx create mode 100644 resources/scripts/components/elements/table/RowActions.spec.tsx create mode 100644 resources/scripts/components/elements/table/RowActions.tsx create mode 100644 resources/scripts/components/elements/tooltip/Tooltip.spec.tsx delete mode 100644 resources/scripts/components/elements/transitions/FadeTransition.tsx delete mode 100644 resources/scripts/components/elements/transitions/index.ts create mode 100644 resources/scripts/components/form/Form.tsx create mode 100644 resources/scripts/components/form/SubmitButton.tsx create mode 100644 resources/scripts/components/form/context.ts create mode 100644 resources/scripts/components/form/controls.spec.tsx create mode 100644 resources/scripts/components/form/controls.tsx create mode 100644 resources/scripts/components/form/errors.ts create mode 100644 resources/scripts/components/form/fields.spec.tsx create mode 100644 resources/scripts/components/form/fields.tsx create mode 100644 resources/scripts/components/form/index.ts delete mode 100644 resources/scripts/components/history.ts create mode 100644 resources/scripts/components/server/InstallListener.spec.tsx create mode 100644 resources/scripts/components/server/TransferListener.spec.tsx create mode 100644 resources/scripts/components/server/WebsocketHandler.spec.tsx delete mode 100644 resources/scripts/components/server/backups/BackupRow.tsx create mode 100644 resources/scripts/components/server/backups/BackupTable.tsx create mode 100644 resources/scripts/components/server/backups/backupCompletion.spec.ts create mode 100644 resources/scripts/components/server/backups/backupCompletion.ts create mode 100644 resources/scripts/components/server/console/AreaChart.tsx create mode 100644 resources/scripts/components/server/console/chart.spec.tsx create mode 100644 resources/scripts/components/server/console/stats.ts delete mode 100644 resources/scripts/components/server/console/style.module.css create mode 100644 resources/scripts/components/server/console/types.ts create mode 100644 resources/scripts/components/server/console/useConsoleCommandHistory.ts create mode 100644 resources/scripts/components/server/console/useConsoleSocketLogs.spec.tsx create mode 100644 resources/scripts/components/server/console/useConsoleSocketLogs.ts create mode 100644 resources/scripts/components/server/console/useTerminal.spec.tsx create mode 100644 resources/scripts/components/server/console/useTerminal.ts delete mode 100644 resources/scripts/components/server/databases/DatabaseRow.tsx create mode 100644 resources/scripts/components/server/databases/DatabaseTable.tsx create mode 100644 resources/scripts/components/server/features/hytaleOauth.spec.ts create mode 100644 resources/scripts/components/server/features/hytaleOauth.ts create mode 100644 resources/scripts/components/server/features/useConsolePatternTrigger.ts create mode 100644 resources/scripts/components/server/files/FileActionItems.tsx create mode 100644 resources/scripts/components/server/files/FileDetailsView.tsx delete mode 100644 resources/scripts/components/server/files/FileDropdownMenu.tsx create mode 100644 resources/scripts/components/server/files/FileEditContainer.spec.tsx create mode 100644 resources/scripts/components/server/files/FileEditorView.tsx create mode 100644 resources/scripts/components/server/files/FileManagerContainer.spec.tsx create mode 100644 resources/scripts/components/server/files/FileManagerView.tsx create mode 100644 resources/scripts/components/server/files/FileObjectRow.spec.tsx delete mode 100644 resources/scripts/components/server/files/style.module.css create mode 100644 resources/scripts/components/server/files/useFileActions.tsx create mode 100644 resources/scripts/components/server/files/useFileManagerExtensionData.ts create mode 100644 resources/scripts/components/server/files/useFileManagerModel.ts create mode 100644 resources/scripts/components/server/files/useFileUploader.ts delete mode 100644 resources/scripts/components/server/network/AllocationRow.tsx create mode 100644 resources/scripts/components/server/network/AllocationTable.spec.tsx create mode 100644 resources/scripts/components/server/network/AllocationTable.tsx delete mode 100644 resources/scripts/components/server/schedules/ScheduleRow.tsx create mode 100644 resources/scripts/components/server/schedules/ScheduleTable.tsx delete mode 100644 resources/scripts/components/server/schedules/ScheduleTaskRow.tsx create mode 100644 resources/scripts/components/server/schedules/ScheduleTaskTable.tsx create mode 100644 resources/scripts/components/server/startup/VariableBox.spec.tsx create mode 100644 resources/scripts/components/server/transfer.spec.ts create mode 100644 resources/scripts/components/server/transfer.ts create mode 100644 resources/scripts/components/server/users/CreateSubuserContainer.tsx create mode 100644 resources/scripts/components/server/users/PermissionRowContainer.tsx create mode 100644 resources/scripts/components/server/users/SubuserTable.tsx delete mode 100644 resources/scripts/components/server/users/UserRow.tsx create mode 100644 resources/scripts/components/server/users/permissionSelection.spec.ts create mode 100644 resources/scripts/components/server/users/permissionSelection.ts create mode 100644 resources/scripts/components/ui/Checkbox.spec.tsx create mode 100644 resources/scripts/components/ui/Checkbox.tsx create mode 100644 resources/scripts/components/ui/Select.spec.tsx create mode 100644 resources/scripts/components/ui/Select.tsx create mode 100644 resources/scripts/components/ui/Switch.tsx create mode 100644 resources/scripts/components/ui/empty.spec.tsx create mode 100644 resources/scripts/components/ui/empty.tsx create mode 100644 resources/scripts/components/ui/styles.ts create mode 100644 resources/scripts/components/ui/typography.ts delete mode 100644 resources/scripts/context/ModalContext.ts delete mode 100644 resources/scripts/easy-peasy.d.ts create mode 100644 resources/scripts/ext-runtime/react-dom-client.ts create mode 100644 resources/scripts/ext-runtime/react-dom.ts create mode 100644 resources/scripts/ext-runtime/react-jsx-runtime.ts create mode 100644 resources/scripts/ext-runtime/react.ts create mode 100644 resources/scripts/ext-runtime/tanstack-react-query.ts create mode 100644 resources/scripts/extensions/ComponentView.spec.tsx create mode 100644 resources/scripts/extensions/ComponentView.tsx create mode 100644 resources/scripts/extensions/ExtensionBoundary.tsx create mode 100644 resources/scripts/extensions/ExtensionMount.tsx create mode 100644 resources/scripts/extensions/NavigationLabel.tsx create mode 100644 resources/scripts/extensions/ResourceExtensionTabs.tsx create mode 100644 resources/scripts/extensions/Slot.spec.tsx create mode 100644 resources/scripts/extensions/Slot.tsx create mode 100644 resources/scripts/extensions/componentSession.tsx create mode 100644 resources/scripts/extensions/componentTypes.ts create mode 100644 resources/scripts/extensions/context.spec.tsx create mode 100644 resources/scripts/extensions/context.ts create mode 100644 resources/scripts/extensions/development.spec.ts create mode 100644 resources/scripts/extensions/development.ts create mode 100644 resources/scripts/extensions/loader.spec.ts create mode 100644 resources/scripts/extensions/loader.ts create mode 100644 resources/scripts/extensions/nativeForm.spec.tsx create mode 100644 resources/scripts/extensions/registry.spec.ts create mode 100644 resources/scripts/extensions/registry.ts create mode 100644 resources/scripts/extensions/resourceContext.ts create mode 100644 resources/scripts/extensions/screen.spec.tsx create mode 100644 resources/scripts/extensions/screen.tsx create mode 100644 resources/scripts/extensions/screenNavigation.spec.tsx create mode 100644 resources/scripts/extensions/screenNavigation.tsx create mode 100644 resources/scripts/extensions/tableColumns.tsx create mode 100644 resources/scripts/extensions/tableTypes.ts create mode 100644 resources/scripts/helpers.spec.ts delete mode 100644 resources/scripts/hoc/RequireServerPermission.tsx delete mode 100644 resources/scripts/hoc/asDialog.tsx delete mode 100644 resources/scripts/hoc/asModal.tsx create mode 100644 resources/scripts/i18n.spec.ts create mode 100644 resources/scripts/lib/clipboard.ts create mode 100644 resources/scripts/lib/cn.spec.ts create mode 100644 resources/scripts/lib/cn.ts create mode 100644 resources/scripts/lib/databases.spec.ts create mode 100644 resources/scripts/lib/databases.ts create mode 100644 resources/scripts/lib/dayjs.ts create mode 100644 resources/scripts/lib/fileDrafts.spec.ts create mode 100644 resources/scripts/lib/fileDrafts.ts create mode 100644 resources/scripts/lib/serverStatus.spec.ts create mode 100644 resources/scripts/lib/serverStatus.ts create mode 100644 resources/scripts/lib/theme.spec.ts create mode 100644 resources/scripts/lib/theme.ts delete mode 100644 resources/scripts/macros.d.ts create mode 100644 resources/scripts/plugins/Websocket.spec.ts delete mode 100644 resources/scripts/plugins/XtermScrollDownHelperAddon.ts create mode 100644 resources/scripts/plugins/notifications.ts create mode 100644 resources/scripts/plugins/useDebouncedCallback.spec.ts create mode 100644 resources/scripts/plugins/useDebouncedCallback.ts create mode 100644 resources/scripts/plugins/useDebouncedValue.ts delete mode 100644 resources/scripts/plugins/useDeepCompareEffect.ts delete mode 100644 resources/scripts/plugins/useDeepCompareMemo.ts delete mode 100644 resources/scripts/plugins/useDeepMemoize.ts delete mode 100644 resources/scripts/plugins/useFileManagerSwr.ts delete mode 100644 resources/scripts/plugins/useFilteredObject.ts delete mode 100644 resources/scripts/plugins/useFlash.ts delete mode 100644 resources/scripts/plugins/useLocationHash.ts create mode 100644 resources/scripts/plugins/useNavigationBlocker.spec.tsx create mode 100644 resources/scripts/plugins/useNavigationBlocker.ts create mode 100644 resources/scripts/plugins/usePermissions.spec.ts delete mode 100644 resources/scripts/plugins/useSWRKey.ts create mode 100644 resources/scripts/router/NavLink.tsx create mode 100644 resources/scripts/router/RootNotFound.ts create mode 100644 resources/scripts/router/RouteError.spec.tsx create mode 100644 resources/scripts/router/RouteError.tsx create mode 100644 resources/scripts/router/layouts/AccountLayout.tsx create mode 100644 resources/scripts/router/layouts/AdminLayout.tsx create mode 100644 resources/scripts/router/layouts/AuthLayout.tsx create mode 100644 resources/scripts/router/layouts/AuthenticatedLayout.tsx create mode 100644 resources/scripts/router/layouts/RootLayout.tsx create mode 100644 resources/scripts/router/layouts/ServerLayout.tsx create mode 100644 resources/scripts/router/nav.ts create mode 100644 resources/scripts/router/params.spec.ts create mode 100644 resources/scripts/router/params.ts create mode 100644 resources/scripts/router/routeSlots.tsx create mode 100644 resources/scripts/router/routeTree.spec.ts create mode 100644 resources/scripts/router/routeTree.ts create mode 100644 resources/scripts/router/router.tsx create mode 100644 resources/scripts/router/search.spec.ts create mode 100644 resources/scripts/router/search.ts create mode 100644 resources/scripts/router/searchHooks.spec.tsx create mode 100644 resources/scripts/router/serverScreen.ts create mode 100644 resources/scripts/router/view-transitions.css delete mode 100644 resources/scripts/routers/AuthenticationRouter.tsx delete mode 100644 resources/scripts/routers/DashboardRouter.tsx delete mode 100644 resources/scripts/routers/ServerRouter.tsx delete mode 100644 resources/scripts/routers/routes.ts create mode 100644 resources/scripts/sdk/api.ts create mode 100644 resources/scripts/sdk/index.spec.ts create mode 100644 resources/scripts/sdk/index.ts create mode 100644 resources/scripts/sdk/localization.spec.tsx create mode 100644 resources/scripts/sdk/localization.ts create mode 100644 resources/scripts/sdk/loginCheckpoint.spec.tsx create mode 100644 resources/scripts/sdk/mutations.spec.tsx create mode 100644 resources/scripts/sdk/mutations.ts create mode 100644 resources/scripts/sdk/navigation.spec.ts create mode 100644 resources/scripts/sdk/navigation.tsx create mode 100644 resources/scripts/sdk/progress.spec.tsx create mode 100644 resources/scripts/sdk/progress.ts create mode 100644 resources/scripts/sdk/queryOptions.ts create mode 100644 resources/scripts/sdk/server.spec.ts create mode 100644 resources/scripts/sdk/server.ts create mode 100644 resources/scripts/sdk/testing.spec.tsx create mode 100644 resources/scripts/sdk/testing.tsx create mode 100644 resources/scripts/sdk/theme.ts create mode 100644 resources/scripts/sdk/ui.tsx delete mode 100644 resources/scripts/state/flashes.ts delete mode 100644 resources/scripts/state/hooks.ts create mode 100644 resources/scripts/state/httpProgress.spec.tsx create mode 100644 resources/scripts/state/httpProgress.ts delete mode 100644 resources/scripts/state/index.ts delete mode 100644 resources/scripts/state/permissions.ts delete mode 100644 resources/scripts/state/progress.ts create mode 100644 resources/scripts/state/server/context.ts delete mode 100644 resources/scripts/state/server/databases.ts create mode 100644 resources/scripts/state/server/files.spec.tsx delete mode 100644 resources/scripts/state/server/index.ts create mode 100644 resources/scripts/state/server/index.tsx delete mode 100644 resources/scripts/state/server/schedules.ts delete mode 100644 resources/scripts/state/server/subusers.ts create mode 100644 resources/scripts/state/server/types.ts delete mode 100644 resources/scripts/state/settings.ts delete mode 100644 resources/scripts/state/user.ts delete mode 100644 resources/scripts/theme.ts create mode 100644 resources/scripts/vite-env.d.ts delete mode 100644 resources/views/admin/api/index.blade.php delete mode 100644 resources/views/admin/api/new.blade.php delete mode 100644 resources/views/admin/databases/index.blade.php delete mode 100644 resources/views/admin/databases/view.blade.php delete mode 100644 resources/views/admin/eggs/new.blade.php delete mode 100644 resources/views/admin/eggs/scripts.blade.php delete mode 100644 resources/views/admin/eggs/variables.blade.php delete mode 100644 resources/views/admin/eggs/view.blade.php delete mode 100644 resources/views/admin/index.blade.php delete mode 100644 resources/views/admin/locations/index.blade.php delete mode 100644 resources/views/admin/locations/view.blade.php delete mode 100644 resources/views/admin/mounts/index.blade.php delete mode 100644 resources/views/admin/mounts/view.blade.php delete mode 100644 resources/views/admin/nests/index.blade.php delete mode 100644 resources/views/admin/nests/new.blade.php delete mode 100644 resources/views/admin/nests/view.blade.php delete mode 100644 resources/views/admin/nodes/index.blade.php delete mode 100644 resources/views/admin/nodes/new.blade.php delete mode 100644 resources/views/admin/nodes/view/allocation.blade.php delete mode 100644 resources/views/admin/nodes/view/configuration.blade.php delete mode 100644 resources/views/admin/nodes/view/index.blade.php delete mode 100644 resources/views/admin/nodes/view/servers.blade.php delete mode 100644 resources/views/admin/nodes/view/settings.blade.php delete mode 100644 resources/views/admin/servers/index.blade.php delete mode 100644 resources/views/admin/servers/new.blade.php delete mode 100644 resources/views/admin/servers/partials/navigation.blade.php delete mode 100644 resources/views/admin/servers/view/build.blade.php delete mode 100644 resources/views/admin/servers/view/database.blade.php delete mode 100644 resources/views/admin/servers/view/delete.blade.php delete mode 100644 resources/views/admin/servers/view/details.blade.php delete mode 100644 resources/views/admin/servers/view/index.blade.php delete mode 100644 resources/views/admin/servers/view/manage.blade.php delete mode 100644 resources/views/admin/servers/view/mounts.blade.php delete mode 100644 resources/views/admin/servers/view/startup.blade.php delete mode 100644 resources/views/admin/settings/advanced.blade.php delete mode 100644 resources/views/admin/settings/index.blade.php delete mode 100644 resources/views/admin/settings/mail.blade.php delete mode 100644 resources/views/admin/users/index.blade.php delete mode 100644 resources/views/admin/users/new.blade.php delete mode 100644 resources/views/admin/users/view.blade.php delete mode 100644 resources/views/layouts/admin.blade.php delete mode 100644 resources/views/layouts/scripts.blade.php delete mode 100644 resources/views/partials/admin/settings/nav.blade.php delete mode 100644 resources/views/partials/admin/settings/notice.blade.php delete mode 100644 resources/views/partials/schedules/task-template.blade.php delete mode 100644 routes/admin.php create mode 100644 routes/api-admin.php create mode 100644 scripts/build-sdk-testing.mjs create mode 100644 scripts/check-extension-runtime.mjs create mode 100644 scripts/externalize-extension-api-runtime.mjs create mode 100644 scripts/generate-extension-api.mjs create mode 100644 scripts/generate-extension-openapi.php create mode 100644 scripts/generate-sdk-icons.mjs create mode 100644 scripts/generate-sdk-types.mjs delete mode 100644 tailwind.config.js create mode 100644 tests/Architecture/OpenApiContractTest.php create mode 100644 tests/Fixtures/assets/manifest.json create mode 100644 tests/Fixtures/keys/x509-certificate.pem create mode 100644 tests/Integration/Api/Admin/Activity/ActivityControllerTest.php create mode 100644 tests/Integration/Api/Admin/AdminApiIntegrationTestCase.php create mode 100644 tests/Integration/Api/Admin/ApiKeyAccessTest.php create mode 100644 tests/Integration/Api/Admin/ApiKeys/ApiKeyControllerTest.php create mode 100644 tests/Integration/Api/Admin/DatabaseHosts/DatabaseHostControllerTest.php create mode 100644 tests/Integration/Api/Admin/Eggs/EggCatalogControllerTest.php create mode 100644 tests/Integration/Api/Admin/Eggs/EggControllerTest.php create mode 100644 tests/Integration/Api/Admin/Eggs/EggCrudControllerTest.php create mode 100644 tests/Integration/Api/Admin/Eggs/EggScriptControllerTest.php create mode 100644 tests/Integration/Api/Admin/Eggs/EggShareControllerTest.php create mode 100644 tests/Integration/Api/Admin/Eggs/EggVariableControllerTest.php create mode 100644 tests/Integration/Api/Admin/Extensions/ExtensionControllerTest.php create mode 100644 tests/Integration/Api/Admin/IncludesTest.php create mode 100644 tests/Integration/Api/Admin/Locations/LocationControllerTest.php create mode 100644 tests/Integration/Api/Admin/Mounts/MountAttachmentTest.php create mode 100644 tests/Integration/Api/Admin/Mounts/MountControllerTest.php create mode 100644 tests/Integration/Api/Admin/Nodes/AllocationControllerTest.php create mode 100644 tests/Integration/Api/Admin/Nodes/NodeControllerTest.php create mode 100644 tests/Integration/Api/Admin/Nodes/NodeIntrospectionControllerTest.php create mode 100644 tests/Integration/Api/Admin/PaginationValidationTest.php create mode 100644 tests/Integration/Api/Admin/Servers/DatabaseControllerTest.php create mode 100644 tests/Integration/Api/Admin/Servers/ServerBackupControllerTest.php create mode 100644 tests/Integration/Api/Admin/Servers/ServerControllerTest.php create mode 100644 tests/Integration/Api/Admin/Servers/ServerInstallControllerTest.php create mode 100644 tests/Integration/Api/Admin/Servers/ServerManagementTest.php create mode 100644 tests/Integration/Api/Admin/Servers/ServerMountControllerTest.php create mode 100644 tests/Integration/Api/Admin/Servers/ServerTransferControllerTest.php create mode 100644 tests/Integration/Api/Admin/Settings/SettingsControllerTest.php create mode 100644 tests/Integration/Api/Admin/Tags/TagControllerTest.php create mode 100644 tests/Integration/Api/Admin/Users/UserControllerTest.php create mode 100644 tests/Integration/Api/Admin/VersionControllerTest.php create mode 100644 tests/Integration/Api/Application/Eggs/EggControllerTest.php delete mode 100644 tests/Integration/Api/Application/Nests/EggControllerTest.php delete mode 100644 tests/Integration/Api/Application/Nests/NestControllerTest.php create mode 100644 tests/Integration/Api/Application/Nodes/NodeControllerTest.php create mode 100644 tests/Integration/Api/Application/Nodes/NodeCrudTest.php create mode 100644 tests/Integration/Api/Application/Nodes/NodeDeploymentControllerTest.php create mode 100644 tests/Integration/Api/Application/PaginationValidationTest.php create mode 100644 tests/Integration/Api/Application/Servers/ServerControllerTest.php create mode 100644 tests/Integration/Api/Application/Servers/ServerManagementTest.php create mode 100644 tests/Integration/Api/Application/Tags/TagControllerTest.php create mode 100644 tests/Integration/Api/Client/ActivityLogControllerTest.php create mode 100644 tests/Integration/Api/Client/ExtensionProgressControllerTest.php create mode 100644 tests/Integration/Api/Client/Server/Backup/BackupControllerTest.php create mode 100644 tests/Integration/Api/Client/Server/Database/DatabaseControllerTest.php create mode 100644 tests/Integration/Api/Client/Server/Files/FileControllerTest.php create mode 100644 tests/Integration/Api/Client/Server/GetServerTest.php create mode 100644 tests/Integration/Api/Client/Server/LogControllerTest.php create mode 100644 tests/Integration/Api/Client/Server/ScheduleTask/UpdateScheduleTaskTest.php create mode 100644 tests/Integration/Api/Client/Server/Subuser/ExtensionSubuserPermissionsTest.php create mode 100644 tests/Integration/Api/Client/Server/Subuser/GetSubusersTest.php create mode 100644 tests/Integration/Api/Remote/ActivityProcessingControllerTest.php create mode 100644 tests/Integration/Api/Remote/RemoteServersApiTest.php create mode 100644 tests/Integration/Console/Commands/Location/LocationCommandsTest.php create mode 100644 tests/Integration/Console/Commands/Server/BulkPowerActionCommandTest.php create mode 100644 tests/Integration/Console/Commands/Themes/ThemeCommandsTest.php create mode 100644 tests/Integration/Console/Commands/UpgradeCommandTest.php create mode 100644 tests/Integration/Console/Commands/User/MakeUserCommandTest.php create mode 100644 tests/Integration/Console/SchedulerTest.php create mode 100644 tests/Integration/Database/LegacyMigrationHistoryGuardTest.php create mode 100644 tests/Integration/Database/LegacyNestSchemaTest.php create mode 100644 tests/Integration/Database/SubuserGrantUniquenessMigrationTest.php delete mode 100644 tests/Integration/Http/Controllers/Admin/UserController/DeleteUserTest.php create mode 100644 tests/Integration/Http/Controllers/Auth/LoginControllerTest.php create mode 100644 tests/Integration/Http/Controllers/Auth/PasswordResetActivityTest.php create mode 100644 tests/Integration/Http/Controllers/Auth/PasswordResetTest.php create mode 100644 tests/Integration/Http/Controllers/Base/BaseRoutesTest.php create mode 100644 tests/Integration/Http/ExtensionFrontendConfigTest.php create mode 100644 tests/Integration/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php create mode 100644 tests/Integration/Providers/ActionServiceProviderTest.php create mode 100644 tests/Integration/Services/BackendWriteConsistencyTest.php create mode 100644 tests/Integration/Services/Daemon/DaemonClientTest.php create mode 100644 tests/Integration/Services/Eggs/EggImporterServiceTest.php create mode 100644 tests/Integration/Services/Extensions/ExtensionInstallerTest.php create mode 100644 tests/Integration/Services/Extensions/ExtensionProviderLoaderTest.php create mode 100644 tests/Integration/Services/Extensions/ExtensionScopedSettingsTest.php create mode 100644 tests/Integration/Services/Extensions/ServerOperationEventTest.php create mode 100644 tests/Integration/Services/Servers/ChangeServerEggTest.php create mode 100644 tests/Integration/Services/Users/CompleteLoginTest.php create mode 100644 tests/Pest.php create mode 100644 tests/Support/Fakes/FakeBackupManager.php create mode 100644 tests/Support/Fakes/FakeDaemonBackup.php create mode 100644 tests/Support/Fakes/FakeDaemonCommand.php create mode 100644 tests/Support/Fakes/FakeDaemonConfiguration.php create mode 100644 tests/Support/Fakes/FakeDaemonFile.php create mode 100644 tests/Support/Fakes/FakeDaemonHttpClient.php create mode 100644 tests/Support/Fakes/FakeDaemonPower.php create mode 100644 tests/Support/Fakes/FakeDaemonRevocation.php create mode 100644 tests/Support/Fakes/FakeDaemonServer.php create mode 100644 tests/Support/Fakes/FakeDaemonTransfer.php create mode 100644 tests/Support/Fakes/FakeDatabaseHostGateway.php create mode 100644 tests/Support/Fakes/FakeDynamicDatabaseConnection.php create mode 100644 tests/Support/Fakes/FakeResponseFactory.php create mode 100644 tests/Support/Fakes/FakeS3Client.php create mode 100644 tests/Support/Fakes/FakeS3Filesystem.php create mode 100644 tests/Support/Fakes/FakeSoftwareVersionService.php create mode 100644 tests/Support/Fakes/ThrowingDispatcher.php create mode 100644 tests/Support/OpenApiSpecValidator.php delete mode 100644 tests/Traits/MocksPdoConnection.php delete mode 100644 tests/Traits/MocksRequestException.php delete mode 100644 tests/Traits/MocksUuids.php create mode 100644 tests/Unit/Actions/Files/ReadFilesTest.php create mode 100644 tests/Unit/Actions/Servers/ReadServerLogsTest.php create mode 100644 tests/Unit/Actions/Servers/ReadServerStateTest.php create mode 100644 tests/Unit/Actions/Users/CompleteLoginTest.php create mode 100644 tests/Unit/ActivityLogTranslationTest.php create mode 100644 tests/Unit/ArchTest.php create mode 100644 tests/Unit/Console/Commands/Environment/AppSettingsCommandTest.php create mode 100644 tests/Unit/Console/GenerateKeyWithoutAppKeyTest.php create mode 100644 tests/Unit/Database/SchemaDumpTest.php create mode 100644 tests/Unit/DocumentationLinksTest.php create mode 100644 tests/Unit/EggConfigurationServiceTest.php create mode 100644 tests/Unit/Enum/EggSpecificTagsTest.php create mode 100644 tests/Unit/EnvironmentServiceTest.php create mode 100644 tests/Unit/Exceptions/ApiErrorResponseTest.php create mode 100644 tests/Unit/Exceptions/Http/Connection/DaemonConnectionExceptionTest.php create mode 100644 tests/Unit/Extensions/Backups/BackupManagerTest.php create mode 100644 tests/Unit/Extensions/ExtensionProviderRuntimeTest.php create mode 100644 tests/Unit/Extensions/ExtensionProviderTest.php create mode 100644 tests/Unit/Extensions/Lcobucci/JWT/Encoding/TimestampDatesTest.php delete mode 100644 tests/Unit/Helpers/IsDigitTest.php create mode 100644 tests/Unit/Http/Controllers/Api/Client/ClientApiControllerTest.php create mode 100644 tests/Unit/Http/Controllers/Base/LocaleControllerTest.php create mode 100644 tests/Unit/Http/ExtensionFileRouteTest.php delete mode 100644 tests/Unit/Http/Middleware/AdminAuthenticateTest.php delete mode 100644 tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php create mode 100644 tests/Unit/Http/Requests/Api/Application/Servers/StoreServerRequestTest.php create mode 100644 tests/Unit/Http/Requests/Api/Remote/RemoteRequestNodeTest.php create mode 100644 tests/Unit/JsonValueGuardTest.php create mode 100644 tests/Unit/JsonValueTreeTest.php create mode 100644 tests/Unit/Lang/ActivityTranslationsTest.php create mode 100644 tests/Unit/ServerCreationDataTest.php create mode 100644 tests/Unit/Services/Deployment/NodeTagGateTest.php create mode 100644 tests/Unit/Services/Eggs/EggParserServiceTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionCompatibilityTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionFailureAttributorTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionHeadTagTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionJobProgressTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionManagerTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionManifestTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionPermissionRegistryTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionProviderLoaderTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionRuntimeTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionScaffolderTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionSettingFieldTypesTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionSettingFilesTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionSettingValueGuardTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionSettingsDefinitionTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionSettingsRegistryTest.php create mode 100755 tests/Unit/Services/Extensions/ExtensionStylesheetInspectorTest.php create mode 100644 tests/Unit/Services/Extensions/ExtensionToolingTest.php create mode 100644 tests/Unit/Services/Helpers/AssetHashServiceTest.php create mode 100644 tests/Unit/Services/Helpers/SoftwareVersionServiceTest.php create mode 100644 tests/Unit/WingsJsonResponseTest.php create mode 100644 tools/oxlint/rules/design-tokens.spec.ts create mode 100644 tools/oxlint/rules/index.ts create mode 100644 tools/oxlint/rules/lint.spec.ts create mode 100644 tools/oxlint/rules/package.json create mode 100644 tools/oxlint/rules/rules/design-tokens.ts create mode 100644 tools/oxlint/rules/rules/generated-api-imports.ts create mode 100644 tools/oxlint/rules/rules/generated-api-mutations.ts create mode 100644 tools/oxlint/rules/rules/generated-api-types.ts create mode 100644 tools/oxlint/rules/rules/no-chained-type-assertions.ts create mode 100644 tools/oxlint/rules/rules/no-conditional-empty-object-spread.ts create mode 100644 tools/oxlint/rules/rules/no-known-value-widening.ts create mode 100644 tools/oxlint/rules/rules/no-object-parameters.ts create mode 100644 tools/oxlint/rules/rules/no-runtime-typeof.ts create mode 100644 tools/oxlint/rules/rules/no-shape-in-symbol-names.ts create mode 100644 tools/oxlint/rules/rules/no-unknown-parameters.ts create mode 100644 tools/oxlint/rules/rules/no-unknown-type-aliases.ts create mode 100644 tools/oxlint/rules/rules/no-unsafe-dictionary-type.ts create mode 100644 tools/oxlint/rules/rules/no-widen-then-assert.ts create mode 100644 tools/oxlint/rules/shared/dictionary-types.ts create mode 100644 tools/oxlint/rules/tsconfig.json create mode 100644 tools/phpstan/rules/README.md create mode 100644 tools/phpstan/rules/extension.neon create mode 100644 tools/phpstan/rules/install.php create mode 100644 tools/phpstan/rules/laravel/extension.neon create mode 100644 tools/phpstan/rules/phpstan.neon create mode 100644 tools/phpstan/rules/phpunit.xml create mode 100644 tools/phpstan/rules/src/Laravel/Rules/NoServiceConstructionRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoChainedAssertionsRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoChainedVarTagsRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoClassLoadingMocksRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoConditionalEmptyArraySpreadRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoForbiddenTermsInSymbolNamesRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoInstanceofOnMixedRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoKnownValueWideningPropertyRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoKnownValueWideningReturnRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoMixedParametersRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoMixedReturnsRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoMixedTypeAliasesRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoObjectParametersRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoUnsafeDictionaryPropertyRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoUnsafeDictionaryTypeRule.php create mode 100644 tools/phpstan/rules/src/Rules/NoWidenThenAssertRule.php create mode 100644 tools/phpstan/rules/src/Rules/RequireSafetyCommentForAssertionRule.php create mode 100644 tools/phpstan/rules/src/Support/AssertionForms.php create mode 100644 tools/phpstan/rules/src/Support/NodeChildren.php create mode 100644 tools/phpstan/rules/src/Support/ResolvedParameter.php create mode 100644 tools/phpstan/rules/src/Support/ResolvedSignature.php create mode 100644 tools/phpstan/rules/src/Support/SignatureResolver.php create mode 100644 tools/phpstan/rules/src/Support/TypeAliasDocblock.php create mode 100644 tools/phpstan/rules/src/Support/TypeClassifier.php create mode 100644 tools/phpstan/rules/tests/Integration/PackageCoverageTest.php create mode 100644 tools/phpstan/rules/tests/Integration/data/package-coverage.php create mode 100644 tools/phpstan/rules/tests/Integration/integration.neon create mode 100644 tools/phpstan/rules/tests/Rules/NoChainedAssertionsRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoChainedVarTagsRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoClassLoadingMocksRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoConditionalEmptyArraySpreadRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoForbiddenTermsInSymbolNamesRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoInstanceofOnMixedRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoKnownValueWideningReturnRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoKnownValueWideningRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoMixedParametersRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoMixedReturnsRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoMixedTypeAliasesRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoObjectParametersRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoServiceConstructionRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryPropertyRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryTypeRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/NoWidenThenAssertRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/RequireSafetyCommentForAssertionRuleTest.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-chained-assertions.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-chained-var-tags.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-class-loading-mocks.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-conditional-empty-array-spread.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-forbidden-terms-in-symbol-names.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-instanceof-on-mixed.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-known-value-widening.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-mixed-parameters.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-mixed-returns.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-mixed-type-aliases.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-object-parameters.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-service-construction.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-property.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-type.php create mode 100644 tools/phpstan/rules/tests/Rules/data/no-widen-then-assert.php create mode 100644 tools/phpstan/rules/tests/Rules/data/require-safety-comment.php create mode 100644 tools/phpstan/stubs/EloquentHasAttributes.stub create mode 100644 vite.config.mts create mode 100644 vitest.config.ts delete mode 100644 webpack.config.js delete mode 100644 yarn.lock diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..e46a18e46 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,40 @@ +.git +.agents +.ai +.claude +.codex +.mcp.json +.github/workflows +.github/docker/smoke-test.sh +.idea +.vscode +.DS_Store +**/.DS_Store +.env* +!.env.example +**/node_modules +/vendor +/var +/extensions +/public/assets/* +!/public/assets/favicons +!/public/assets/js +!/public/assets/svgs +!/public/assets/themes +!/public/assets/vendor +!/public/assets/theme.css +/public/build +/public/hot +/public/vendor/scribe +/resources/views/scribe +/.scribe +/bootstrap/cache/* +!/bootstrap/cache/.gitignore +/storage +*.log +.phpunit* +.pint.cache +/coverage* +/result +/tests +/tools diff --git a/.env.ci b/.env.ci index 1a9e848e3..04dfa5375 100644 --- a/.env.ci +++ b/.env.ci @@ -18,3 +18,5 @@ MAIL_DRIVER=array QUEUE_DRIVER=sync HASHIDS_SALT=test123 + +RECAPTCHA_ENABLED=false diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 01050140a..000000000 --- a/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -public -node_modules -resources/views -babel.config.js -tailwind.config.js -webpack.config.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index ad11a0bca..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,52 +0,0 @@ -/** @type {import('eslint').Linter.Config} */ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 6, - ecmaFeatures: { - jsx: true, - }, - project: './tsconfig.json', - tsconfigRootDir: './', - }, - settings: { - react: { - pragma: 'React', - version: 'detect', - }, - linkComponents: [ - { name: 'Link', linkAttribute: 'to' }, - { name: 'NavLink', linkAttribute: 'to' }, - ], - }, - env: { - browser: true, - es6: true, - }, - plugins: ['react', 'react-hooks', 'prettier', '@typescript-eslint'], - extends: [ - // 'standard', - 'eslint:recommended', - 'plugin:react/recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:jest-dom/recommended', - ], - rules: { - eqeqeq: 'error', - 'prettier/prettier': ['error', {}, { usePrettierrc: true }], - // TypeScript can infer this significantly better than eslint ever can. - 'react/prop-types': 0, - 'react/display-name': 0, - '@typescript-eslint/no-explicit-any': 0, - '@typescript-eslint/no-non-null-assertion': 0, - // This setup is required to avoid a spam of errors when running eslint about React being - // used before it is defined. - // - // @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md#how-to-use - 'no-use-before-define': 0, - '@typescript-eslint/no-use-before-define': 'warn', - '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], - '@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }], - 'react/no-unknown-property': ['error', { ignore: ['css'] }], - }, -}; diff --git a/.github/docker/README.md b/.github/docker/README.md index 5cf97de44..989222e35 100644 --- a/.github/docker/README.md +++ b/.github/docker/README.md @@ -1,76 +1,110 @@ -# Pterodactyl Panel - Docker Image -This is a ready to use docker image for the panel. +# Pterodactyl Panel Docker image -## Requirements -This docker image requires some additional software to function. The software can either be provided in other containers (see the [docker-compose.yml](https://github.com/pterodactyl/panel/blob/develop/docker-compose.example.yml) as an example) or as existing instances. +The image includes PHP 8.4, Nginx, a queue worker, a supervised scheduler, and Composer with production dependencies. Node is used only to build frontend assets. Scribe and its required dependencies are included so API attributes and documentation commands work with `--no-dev`. -A mysql database is required. We recommend the stock [MariaDB Image](https://hub.docker.com/_/mariadb/) image if you prefer to run it in a docker container. As a non-containerized option we recommend mariadb. +## Install and upgrade -A caching software is required as well. We recommend the stock [Redis Image](https://hub.docker.com/_/redis/) image. You can choose any of the [supported options](#cache-drivers). +Use `docker-compose.example.yml` as your Compose file. Set the database password, application URL, and mail configuration before starting. Use a versioned image tag or digest for controlled production upgrades. -You can provide additional settings using a custom `.env` file or by setting the appropriate environment variables in the docker-compose file. +Start the dependencies, then run migrations as an explicit release step: -## Setup - -Start the docker container and the required dependencies (either provide existing ones or start containers as well, see the [docker-compose.yml](https://github.com/pterodactyl/panel/blob/develop/docker-compose.example.yml) file as an example. - -After the startup is complete you'll need to create a user. -If you are running the docker container without docker-compose, use: -``` -docker exec -it php artisan p:user:make -``` -If you are using docker compose use -``` -docker-compose exec panel php artisan p:user:make +```sh +docker compose up -d --wait database cache +docker compose run --rm panel php artisan migrate --seed --force --isolated=1 --no-interaction +docker compose up -d --wait panel +docker compose exec panel php artisan p:user:make ``` -## Environment Variables -There are multiple environment variables to configure the panel when not providing your own `.env` file, see the following table for details on each available option. +For upgrades, back up the database and `/app/var/.env`, pull the selected image, stop the panel, run the migration command once, and start the panel again. Migrations and seeders never run automatically on container startup. A failed or competing migration exits nonzero; resolve it before starting the new release. Isolation requires the shared Redis cache configured in the example. -Note: If your `APP_URL` starts with `https://` you need to provide an `LE_EMAIL` as well so Certificates can be generated. +Application commands can also be run with `docker exec`, or through the image entrypoint with `docker run IMAGE php artisan ...`. One-off commands do not start web services or request certificates. -| Variable | Description | Required | -| ------------------- | ------------------------------------------------------------------------------ | -------- | -| `APP_URL` | The URL the panel will be reachable with (including protocol) | yes | -| `APP_TIMEZONE` | The timezone to use for the panel | yes | -| `LE_EMAIL` | The email used for letsencrypt certificate generation | yes | -| `DB_HOST` | The host of the mysql instance | yes | -| `DB_PORT` | The port of the mysql instance | yes | -| `DB_DATABASE` | The name of the mysql database | yes | -| `DB_USERNAME` | The mysql user | yes | -| `DB_PASSWORD` | The mysql password for the specified user | yes | -| `CACHE_DRIVER` | The cache driver (see [Cache drivers](#cache-drivers) for detais) | yes | -| `SESSION_DRIVER` | | yes | -| `QUEUE_DRIVER` | | yes | -| `REDIS_HOST` | The hostname or IP address of the redis database | yes | -| `REDIS_PASSWORD` | The password used to secure the redis database | maybe | -| `REDIS_PORT` | The port the redis database is using on the host | maybe | -| `MAIL_DRIVER` | The email driver (see [Mail drivers](#mail-drivers) for details) | yes | -| `MAIL_FROM` | The email that should be used as the sender email | yes | -| `MAIL_HOST` | The host of your mail driver instance | maybe | -| `MAIL_PORT` | The port of your mail driver instance | maybe | -| `MAIL_USERNAME` | The username for your mail driver | maybe | -| `MAIL_PASSWORD` | The password for your mail driver | maybe | +## Persistent data and secrets +| Container path | Purpose | +| --- | --- | +| `/app/var` | Application key, Hashids salt, and optional custom `.env` | +| `/etc/nginx/http.d` | Nginx configuration | +| `/etc/letsencrypt` | Certificates and renewal configuration | +| `/app/storage/logs` | Application and scheduled-task logs | +| `/app/extensions` | Installed extensions | +| `/app/public/assets/extensions` | Published extension browser assets; persist alongside installed extensions | -### Cache drivers -You can choose between different cache drivers depending on what you prefer. -We recommend redis when using docker as it can be started in a container easily. +The first start atomically creates `/app/var/.env` with cryptographically random secrets unless that file already exists. Environment variables override file values. Supplied `APP_KEY` and `HASHIDS_SALT` are persisted on first creation. Keep those values stable across upgrades; losing the application key makes existing encrypted data unreadable. Container logs never print these secrets. -| Driver | Description | Required variables | -| -------- | ------------------------------------ | ------------------------------------------------------ | -| redis | host where redis is running | `REDIS_HOST` | -| redis | port redis is running on | `REDIS_PORT` | -| redis | redis database password | `REDIS_PASSWORD` | +Use the same `APP_KEY`, `HASHIDS_SALT`, database, Redis, and extension files for every replica. Set `SCHEDULER_ENABLED=false` on all but one replica to avoid duplicate scheduled work. Persistent filesystem volumes must support file locking and Unix ownership. Application commands run as root by default; use `docker compose exec --user nginx panel ...` for normal application maintenance where possible. -### Mail drivers -You can choose between different mail drivers according to your needs. -Every driver requires `MAIL_FROM` to be set. +## Environment -| Driver | Description | Required variables | -| -------- | ------------------------------------ | ------------------------------------------------------------- | -| mail | uses the installed php mail | | -| mandrill | [Mandrill](http://www.mandrill.com/) | `MAIL_USERNAME` | -| postmark | [Postmark](https://postmarkapp.com/) | `MAIL_USERNAME` | -| mailgun | [Mailgun](https://www.mailgun.com/) | `MAIL_USERNAME`, `MAIL_HOST` | -| smtp | Any SMTP server can be configured | `MAIL_USERNAME`, `MAIL_HOST`, `MAIL_PASSWORD`, `MAIL_PORT` | +| Variable | Purpose / default | +| --- | --- | +| `APP_URL` | Public URL, including scheme | +| `APP_TIMEZONE` | Application timezone, normally `UTC` | +| `APP_KEY`, `HASHIDS_SALT` | Stable shared secrets; generated on first start if absent | +| `APP_ENV` / `APP_DEBUG` | Image defaults: `production` / `false` | +| `APP_ENVIRONMENT_ONLY` | Set `true` to manage application settings through environment variables | +| `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` | MySQL/MariaDB connection | +| `CACHE_STORE`, `SESSION_DRIVER`, `QUEUE_CONNECTION` | Use `redis` for the example deployment | +| `SESSION_CONNECTION` | Set `sessions` to use the separate Redis session database | +| `REDIS_HOST`, `REDIS_PORT`, `REDIS_PASSWORD` | Shared Redis connection | +| `REDIS_QUEUE_RETRY_AFTER` | Must exceed the worker's 60-second timeout; default `90` | +| `QUEUE_WORKER_ENABLED` | `true` (default) or `false` | +| `SCHEDULER_ENABLED` | `true` (default) or `false`; enable on exactly one replica | +| `MAIL_MAILER`, `MAIL_FROM_ADDRESS` | Mail transport and sender address | +| `MAIL_HOST`, `MAIL_PORT`, `MAIL_USERNAME`, `MAIL_PASSWORD`, `MAIL_ENCRYPTION` | SMTP settings | +| `LE_EMAIL` | Optional email for direct Let's Encrypt HTTPS | + +The application also accepts the legacy `CACHE_DRIVER`, `QUEUE_DRIVER`, and `MAIL_DRIVER` names. The newer names take precedence. Use the configured mail transport's own requirements for non-SMTP mail. + +## HTTPS + +For direct Let's Encrypt HTTPS, set an `https://` `APP_URL` and `LE_EMAIL`, point DNS to this host, and expose ports 80 and 443. Initial issuance uses the standalone HTTP challenge before Nginx starts. Existing certificates are reused on restart; the supervised cron service runs renewal daily. Certificate renewal therefore needs `SCHEDULER_ENABLED=true` on the container managing those certificates. + +For your own certificates, mount a `panel.conf` with the correct certificate paths. Existing `panel.conf` files are preserved, including on upgrades: update their TLS and location settings yourself using the bundled templates as a reference. New HTTPS configurations enable only TLS 1.2 and TLS 1.3. + +Behind a TLS-terminating reverse proxy, leave `LE_EMAIL` unset, keep the public `https://` `APP_URL`, and forward requests to container port 80. Configure the application's trusted proxies for your proxy network. The image reserves `127.0.0.1:8080` internally for the Nginx/PHP health probe; it is not published. + +## Health and shutdown + +The health check verifies Nginx, PHP-FPM, and each enabled background service. It is a process/liveness check; monitor database and Redis availability separately. Supervisor sends graceful shutdown signals and allows the queue worker 70 seconds to finish a job. Keep Docker's stop timeout at least 90 seconds (`stop_grace_period: 90s` in Compose). Custom job timeouts must remain below the queue retry interval, and longer jobs require adjusting the worker and stop timeouts together. + +Supervisor and PHP worker output go to container logs. Application and scheduler output remain under `/app/storage/logs`; arrange log rotation for the persisted directory. + +## API documentation + +Run generation against a disposable database with the panel schema, using the production image and its normal database/environment configuration: + +```sh +docker compose run --rm -e PTERODACTYL_EXTENSIONS_ENABLED=false panel composer docs:openapi:verify +``` + +Scribe executes factories while generating response examples. Use an isolated documentation environment, not the live production database. The command generates the Blade documentation and OpenAPI/Postman files, then verifies route coverage and the client contract. Generated files live in the command's container unless you mount an output directory or copy them out before removing the container. The image does not embed documentation generated from a developer's database. + +## Build + +```sh +docker build -t pterodactyl-panel:local . +docker buildx build --platform linux/amd64,linux/arm64 -t REGISTRY/panel:VERSION --push . +``` + +BuildKit caches npm and Composer downloads. `.dockerignore` excludes local secrets, installed dependencies, storage data, and generated bundles while preserving static assets. The repository lockfiles determine package versions. + +Run `bash .github/docker/smoke-test.sh pterodactyl-panel:local` to test the image with disposable MariaDB and Redis containers. The suite checks startup without migrations, Redis sessions/cache/queue processing, documentation generation, scheduler execution, graceful shutdown, restart, HTTPS, and disabled services. CI builds each platform on a native amd64 or arm64 runner, runs this suite against that image, pushes it by digest, and then joins both digests into one multi-platform tag. + +## Laravel deployment caches and PHP sizing + +Startup rebuilds Laravel caches as the application user after reading the deployment environment. It clears only framework files and compiled views, never Redis keys. These generated files stay inside each container; do not share `bootstrap/cache` between replicas. Configuration snapshots may contain secrets and are created with restrictive permissions. + +| Deployment | Caches prepared | +| --- | --- | +| `APP_ENVIRONMENT_ONLY=true`, `PTERODACTYL_EXTENSIONS_ENABLED=false` | Configuration, events, routes, and views | +| Database-managed settings, extensions disabled | Events, routes, and views; settings continue loading dynamically | +| Extension system enabled (the application default) | Views; provider configuration, events, and routes remain dynamic | + +The policy depends on whether the extension system is enabled, even if no extensions are currently installed, so installing or enabling one later cannot leave a stale route snapshot. Database-backed settings are never baked into configuration caches. View timestamp checks and OPcache timestamp validation stay enabled for live changes. Restart long-running queue workers when changing their configuration or extension code, as with any Laravel deployment. + +Set `LARAVEL_OPTIMIZE=false` to disable deployment caching for diagnostics; startup still removes old snapshots. Changing `.env` requires a container restart; changing Compose environment variables requires recreating the container. One-off entrypoint commands do not rebuild caches. Run documentation generation in a fresh, isolated command container as described above. + +`PHP_FPM_MAX_CHILDREN` (default `9`) and `PHP_FPM_MAX_REQUESTS` (default `200`) configure the existing on-demand pool. `PHP_OPCACHE_MEMORY_CONSUMPTION` controls shared OPcache memory in MiB (default `128`). OPcache retains comments for reflection/documentation and disables JIT. The image does not disable timestamp checks because extensions and framework cache files can change at runtime. + +These are starting values, not workload-specific tuning. Size the worker pool from measured busy-worker memory and the container's memory limit, leaving room for the queue worker, scheduler, OPcache, and Nginx. Increase concurrency only after measuring request latency, CPU use, and memory under representative load. Recreate the container after changing PHP sizing variables. diff --git a/.github/docker/default.conf b/.github/docker/default.conf index b6105e5fa..e49e267af 100644 --- a/.github/docker/default.conf +++ b/.github/docker/default.conf @@ -29,6 +29,7 @@ server { sendfile off; location ~ \.php$ { + try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # the fastcgi_pass path needs to be changed accordingly when using CentOS fastcgi_pass 127.0.0.1:9000; @@ -45,7 +46,7 @@ server { fastcgi_read_timeout 300; } - location ~ /\.ht { + location ~ /\. { deny all; } } diff --git a/.github/docker/default_ssl.conf b/.github/docker/default_ssl.conf index 9ec5c10db..708de98dc 100644 --- a/.github/docker/default_ssl.conf +++ b/.github/docker/default_ssl.conf @@ -8,7 +8,8 @@ server { } server { - listen 443 ssl http2; + listen 443 ssl; + http2 on; server_name ; root /app/public; @@ -26,10 +27,10 @@ server { # strengthen ssl security ssl_certificate /etc/letsencrypt/live//fullchain.pem; ssl_certificate_key /etc/letsencrypt/live//privkey.pem; - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; - ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; + ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384; # See the link below for more SSL information: # https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html @@ -48,6 +49,7 @@ server { } location ~ \.php$ { + try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; @@ -64,7 +66,7 @@ server { include /etc/nginx/fastcgi_params; } - location ~ /\.ht { + location ~ /\. { deny all; } -} \ No newline at end of file +} diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index 858a6fd12..484b4a5f2 100644 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -1,99 +1,74 @@ -#!/bin/ash -e +#!/bin/ash +set -eu cd /app -mkdir -p /var/log/panel/logs/ /var/log/supervisord/ /var/log/nginx/ /var/log/php7/ \ - && chmod 777 /var/log/panel/logs/ \ - && ln -s /app/storage/logs/ /var/log/panel/ +mkdir -p /app/var /app/extensions /app/public/assets/extensions /app/storage/logs /app/storage/framework/cache/data \ + /app/storage/framework/sessions /app/storage/framework/views /app/bootstrap/cache \ + /var/log/panel /var/log/supervisord /var/log/nginx +ln -sfn /app/storage/logs /var/log/panel/logs -## check for .env file and generate app keys if missing -if [ -f /app/var/.env ]; then - echo "external vars exist." - rm -rf /app/.env - ln -s /app/var/.env /app/ -else - echo "external vars don't exist." - rm -rf /app/.env - touch /app/var/.env - - ## manually generate a key because key generate --force fails - if [ -z $APP_KEY ]; then - echo -e "Generating key." - APP_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) - echo -e "Generated app key: $APP_KEY" - echo -e "APP_KEY=$APP_KEY" > /app/var/.env - else - echo -e "APP_KEY exists in environment, using that." - echo -e "APP_KEY=$APP_KEY" > /app/var/.env +# Serialize first-start key creation when containers share the persistent volume. +( + flock -x 9 + if [ ! -f /app/var/.env ]; then + umask 027 + php -r ' + $values = [ + "APP_KEY" => getenv("APP_KEY") ?: "base64:".base64_encode(random_bytes(32)), + "HASHIDS_SALT" => getenv("HASHIDS_SALT") ?: bin2hex(random_bytes(32)), + ]; + $contents = ""; + foreach ($values as $name => $value) { + $contents .= $name."=\"".addcslashes($value, "\\\"\$\r\n")."\"\n"; + } + if (file_put_contents("/app/var/.env.tmp", $contents) === false || !rename("/app/var/.env.tmp", "/app/var/.env")) { + exit(1); + } + ' + chown nginx:nginx /app/var/.env fi +) 9>/app/var/.env.lock +ln -sfn /app/var/.env /app/.env +chown -R nginx:nginx /app/storage /app/bootstrap/cache /app/extensions /app/public/assets/extensions - ## generate a random salt for hashids if not provided - if [ -z $HASHIDS_SALT ]; then - echo -e "Generating hashids salt." - HASHIDS_SALT=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9!@#$%^&*()_+?><~' | fold -w 20 | head -n 1) - echo -e "Generated hashids salt: $HASHIDS_SALT" - echo -e "HASHIDS_SALT=$HASHIDS_SALT" >> /app/var/.env - else - echo -e "HASHIDS_SALT exists in environment, using that." - echo -e "HASHIDS_SALT=$HASHIDS_SALT" >> /app/var/.env - fi - - ln -s /app/var/.env /app/ +# One-off release and documentation commands use the same persisted environment. +# Migrations are deliberately explicit: never change the schema on replica startup. +if [ "${1:-}" != "supervisord" ]; then + exec "$@" fi -echo "Checking if https is required." -if [ -f /etc/nginx/http.d/panel.conf ]; then - echo "Using nginx config already in place." - if [ $LE_EMAIL ]; then - echo "Checking for cert update" - certbot certonly -d $(echo $APP_URL | sed 's~http[s]*://~~g') --standalone -m $LE_EMAIL --agree-tos -n - else - echo "No letsencrypt email is set" - fi -else - echo "Checking if letsencrypt email is set." - if [ -z $LE_EMAIL ]; then - echo "No letsencrypt email is set using http config." - cp .github/docker/default.conf /etc/nginx/http.d/panel.conf - else - echo "writing ssl config" - cp .github/docker/default_ssl.conf /etc/nginx/http.d/panel.conf - echo "updating ssl config for domain" - sed -i "s||$(echo $APP_URL | sed 's~http[s]*://~~g')|g" /etc/nginx/http.d/panel.conf - echo "generating certs" - certbot certonly -d $(echo $APP_URL | sed 's~http[s]*://~~g') --standalone -m $LE_EMAIL --agree-tos -n - fi - echo "Removing the default nginx config" - rm -rf /etc/nginx/http.d/default.conf -fi - -if [[ -z $DB_PORT ]]; then - echo -e "DB_PORT not specified, defaulting to 3306" - DB_PORT=3306 -fi - -## check log folder permissions -echo "Checking log folder permissions." -if [ "$(stat -c %U:%G /app/storage/logs)" != "nginx" ]; then - echo "Fixing log folder permissions." - chown -R nginx: /app/storage/logs/ -fi - -## check for DB up before starting the panel -echo "Checking database status." -until nc -z -v -w30 $DB_HOST $DB_PORT -do - echo "Waiting for database connection..." - # wait for 1 seconds before check again - sleep 1 +for enabled in "$QUEUE_WORKER_ENABLED" "$SCHEDULER_ENABLED"; do + case "$enabled" in + true|false) ;; + *) echo 'QUEUE_WORKER_ENABLED and SCHEDULER_ENABLED must be true or false.' >&2; exit 1 ;; + esac done -## make sure the db is set up -echo -e "Migrating and Seeding D.B" -php artisan migrate --seed --force +if [ ! -f /etc/nginx/http.d/panel.conf ]; then + if [ -n "${LE_EMAIL:-}" ]; then + domain=$(php -r ' + $url = parse_url(getenv("APP_URL") ?: ""); + $host = $url["host"] ?? ""; + if (($url["scheme"] ?? "") !== "https" || !filter_var($host, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { + fwrite(STDERR, "LE_EMAIL requires an https APP_URL with a valid hostname.\n"); + exit(1); + } + echo $host; + ') + if [ ! -s "/etc/letsencrypt/live/$domain/fullchain.pem" ] || [ ! -s "/etc/letsencrypt/live/$domain/privkey.pem" ]; then + certbot certonly --standalone --non-interactive --agree-tos --email "$LE_EMAIL" --domains "$domain" + fi + sed "s||$domain|g" .github/docker/default_ssl.conf > /etc/nginx/http.d/panel.conf.tmp + else + cp .github/docker/default.conf /etc/nginx/http.d/panel.conf.tmp + fi + mv /etc/nginx/http.d/panel.conf.tmp /etc/nginx/http.d/panel.conf +fi +rm -f /etc/nginx/http.d/default.conf +cp .github/docker/health.conf /etc/nginx/http.d/health.conf -## start cronjobs for the queue -echo -e "Starting cron jobs." -crond -L /var/log/crond -l 5 - -echo -e "Starting supervisord." +# Catch configuration and application boot failures before starting background services. +nginx -t +php-fpm -t +su-exec nginx /bin/ash /app/.github/docker/optimize.sh exec "$@" diff --git a/.github/docker/health.conf b/.github/docker/health.conf new file mode 100644 index 000000000..0314339e3 --- /dev/null +++ b/.github/docker/health.conf @@ -0,0 +1,15 @@ +server { + listen 127.0.0.1:8080; + server_name localhost; + access_log off; + + location = /ping { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /ping; + fastcgi_pass 127.0.0.1:9000; + } + + location / { + return 404; + } +} diff --git a/.github/docker/healthcheck.sh b/.github/docker/healthcheck.sh new file mode 100644 index 000000000..2e212d39c --- /dev/null +++ b/.github/docker/healthcheck.sh @@ -0,0 +1,17 @@ +#!/bin/ash +set -eu + +check_process() { + status=$(supervisorctl status "$1") + printf '%s\n' "$status" | awk '$2 != "RUNNING" { exit 1 }' +} + +check_process nginx +check_process php-fpm +if [ "$QUEUE_WORKER_ENABLED" = true ]; then + check_process queue-worker +fi +if [ "$SCHEDULER_ENABLED" = true ]; then + check_process scheduler +fi +curl --fail --silent --show-error --max-time 5 http://127.0.0.1:8080/ping | grep -qx pong diff --git a/.github/docker/optimize.sh b/.github/docker/optimize.sh new file mode 100644 index 000000000..62c885d43 --- /dev/null +++ b/.github/docker/optimize.sh @@ -0,0 +1,43 @@ +#!/bin/ash +set -eu +cd /app +umask 077 + +# Remove bootstrap snapshots before Laravel boots with this container's environment. +# optimize:clear also flushes the shared application cache, so do not use it here. +php -r ' + require "vendor/autoload.php"; + $app = require "bootstrap/app.php"; + foreach ([$app->getCachedConfigPath(), $app->getCachedRoutesPath(), $app->getCachedEventsPath()] as $path) { + if (is_file($path) && !unlink($path)) { + exit(1); + } + } +' +php artisan view:clear --no-interaction +php artisan package:discover --no-interaction + +case "$LARAVEL_OPTIMIZE" in + false) exit 0 ;; + true) ;; + *) echo 'LARAVEL_OPTIMIZE must be true or false.' >&2; exit 1 ;; +esac + +mode=$(php -r ' + require "vendor/autoload.php"; + $app = require "bootstrap/app.php"; + $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); + echo config("extensions.enabled") ? "dynamic" : (config("pterodactyl.load_environment_only") ? "full" : "database-settings"); +') + +# Extension providers and database settings mutate configuration during boot. +# Freeze only snapshots whose inputs cannot change while this container is running. +if [ "$mode" = full ]; then + php artisan config:cache --no-interaction +fi +if [ "$mode" != dynamic ]; then + php artisan event:cache --no-interaction + php artisan route:cache --no-interaction +fi +php artisan view:cache --no-interaction +printf 'Laravel deployment caches prepared (%s).\n' "$mode" diff --git a/.github/docker/php.ini b/.github/docker/php.ini new file mode 100644 index 000000000..9bd5c05a2 --- /dev/null +++ b/.github/docker/php.ini @@ -0,0 +1,10 @@ +; Keep timestamp checks for runtime-generated caches and live extension updates. +opcache.enable=1 +opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION} +opcache.interned_strings_buffer=16 +opcache.max_accelerated_files=20000 +opcache.validate_timestamps=1 +opcache.revalidate_freq=0 +opcache.save_comments=1 +opcache.jit=disable +opcache.jit_buffer_size=0 diff --git a/.github/docker/smoke-test.sh b/.github/docker/smoke-test.sh new file mode 100755 index 000000000..b5ad73949 --- /dev/null +++ b/.github/docker/smoke-test.sh @@ -0,0 +1,246 @@ +#!/usr/bin/env bash +set -euo pipefail +trap 'echo "Smoke test failed at line $LINENO." >&2' ERR + +image=${1:?Usage: smoke-test.sh IMAGE} +script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) +prefix="panel-smoke-$$" +app="$prefix-app" +tls="$prefix-tls" +dynamic="$prefix-dynamic" +database="$prefix-db" +redis="$prefix-redis" +workdir=$(mktemp -d) + +cleanup() { + status=$? + if [ "$status" -ne 0 ]; then + docker logs --tail 60 "$app" 2>/dev/null || true + docker logs --tail 30 "$tls" 2>/dev/null || true + docker logs --tail 40 "$dynamic" 2>/dev/null || true + cat "$workdir/docs.log" 2>/dev/null | tail -n 30 || true + fi + docker rm -fv "$app" "$tls" "$dynamic" "$database" "$redis" >/dev/null 2>&1 || true + docker network rm "$prefix" >/dev/null 2>&1 || true + rm -rf "$workdir" + exit "$status" +} +trap cleanup EXIT + +wait_for() { + for ((attempt=0; attempt<90; attempt++)); do + if "$@" > "$workdir/wait.log" 2>&1; then + return 0 + fi + sleep 1 + done + echo "Timed out: $*" >&2 + cat "$workdir/wait.log" >&2 + return 1 +} + +healthy() { + docker exec "$1" /bin/ash /app/.github/docker/healthcheck.sh >/dev/null 2>&1 +} + +run_php() { + docker exec -i "$app" php +} + +docker network create "$prefix" >/dev/null +docker run -d --name "$database" --network "$prefix" \ + -e MARIADB_RANDOM_ROOT_PASSWORD=yes -e MARIADB_DATABASE=panel \ + -e MARIADB_USER=panel -e MARIADB_PASSWORD=smoke-test-only mariadb:11.4 >/dev/null +docker run -d --name "$redis" --network "$prefix" redis:7.4-alpine >/dev/null +wait_for docker exec "$database" healthcheck.sh --connect --innodb_initialized +wait_for docker exec "$redis" redis-cli ping + +environment=( + -e APP_ENVIRONMENT_ONLY=true -e APP_URL=http://panel.example -e APP_TIMEZONE=UTC + -e APP_KEY=base64:MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY= + -e HASHIDS_SALT=smoke-test-only -e DB_HOST="$database" -e DB_DATABASE=panel + -e DB_USERNAME=panel -e DB_PASSWORD=smoke-test-only -e CACHE_STORE=redis + -e SESSION_DRIVER=redis -e SESSION_CONNECTION=sessions -e QUEUE_CONNECTION=redis -e REDIS_HOST="$redis" + -e PTERODACTYL_EXTENSIONS_ENABLED=false + -e MAIL_MAILER=array +) + +docker run -d --name "$app" --network "$prefix" "${environment[@]}" "$image" >/dev/null +wait_for healthy "$app" +docker exec "$app" supervisorctl stop scheduler >/dev/null +if docker exec "$app" /bin/ash /app/.github/docker/healthcheck.sh >/dev/null 2>&1; then + echo 'Health check accepted a stopped scheduler.' >&2 + exit 1 +fi +docker exec "$app" supervisorctl start scheduler >/dev/null +# Starting a replica must not create the schema. +tables=$(docker exec -e MYSQL_PWD=smoke-test-only "$database" \ + mariadb -upanel -N -e 'SELECT COUNT(*) FROM information_schema.tables WHERE table_schema="panel"') +test "$tables" = 0 + +docker exec "$app" php artisan migrate --seed --force --isolated=1 --no-interaction > "$workdir/migrations.log" +docker exec "$app" /bin/ash -ec ' + test -s bootstrap/cache/config.php + test -s bootstrap/cache/routes-v7.php + test -s bootstrap/cache/events.php + set -- storage/framework/views/*.php + test -f "$1" + php-fpm -t + nginx -t + composer check-platform-reqs --no-dev + test ! -d vendor/pestphp + test ! -d vendor/phpstan + test ! -d vendor/laravel/boost + test -s public/assets/manifest.json + test -s public/assets/svgs/pterodactyl.svg + curl -fsS -c /tmp/smoke-cookies http://127.0.0.1/auth/login >/dev/null +' +test "$(docker exec "$redis" redis-cli -n 1 dbsize)" -gt 0 +run_php <<'PHP' +make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); +Illuminate\Support\Facades\Cache::put('docker-smoke-cache', 'ok', 60); +if (Illuminate\Support\Facades\Cache::get('docker-smoke-cache') !== 'ok') { + exit(1); +} +PHP + +docker exec "$app" composer docs:openapi:verify > "$workdir/docs.log" 2>&1 +tail -n 2 "$workdir/docs.log" + +# Exercise the installed scheduler as its configured Unix user. +docker exec "$app" /bin/ash -ec ' + cp /var/spool/cron/crontabs/nginx /tmp/smoke-crontab + cp /tmp/smoke-crontab /tmp/smoke-crontab-updated + echo "* * * * * id > /app/storage/logs/cron-smoke" >> /tmp/smoke-crontab-updated + crontab -u nginx /tmp/smoke-crontab-updated +' +wait_for docker exec "$app" test -s /app/storage/logs/cron-smoke +docker exec "$app" grep -q '(nginx)' /app/storage/logs/cron-smoke +docker exec "$app" crontab -u nginx /tmp/smoke-crontab + +# A real queued closure must finish during a graceful container stop. +docker exec -i "$app" /bin/ash -c 'cat > /tmp/smoke-queue.php' <<'PHP' +make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); +Illuminate\Support\Facades\Queue::push(Illuminate\Queue\CallQueuedClosure::create(function () { + file_put_contents('/app/storage/logs/queue-started', 'started'); + $deadline = microtime(true) + 8; + while (microtime(true) < $deadline) { + usleep(100000); + } + file_put_contents('/app/storage/logs/queue-finished', 'finished'); +})); +PHP +docker exec "$app" php /tmp/smoke-queue.php +wait_for docker exec "$app" test -s /app/storage/logs/queue-started +docker exec "$app" /bin/ash -ec 'sha256sum /app/var/.env > /tmp/smoke-env-checksum' +docker exec "$redis" redis-cli set smoke-preserved yes >/dev/null +docker exec "$app" /bin/ash -ec 'echo "APP_NAME=restart-cache-probe" >> /app/var/.env; sha256sum /app/var/.env > /tmp/smoke-env-checksum' +docker stop --time 90 "$app" >/dev/null +test "$(docker inspect -f '{{.State.ExitCode}}' "$app")" = 0 +docker cp "$app:/app/storage/logs/queue-finished" "$workdir/queue-finished" +grep -qx finished "$workdir/queue-finished" +docker start "$app" >/dev/null +wait_for healthy "$app" +docker exec "$app" /bin/ash -ec 'sha256sum -c /tmp/smoke-env-checksum; test -L /var/log/panel/logs' + +docker exec "$app" php -r '$config = require "bootstrap/cache/config.php"; exit($config["app"]["name"] === "restart-cache-probe" ? 0 : 1);' +test "$(docker exec "$redis" redis-cli get smoke-preserved)" = yes + +# Dynamic settings and extension state must remain live with optimization enabled. +docker run -d --name "$dynamic" --network "$prefix" "${environment[@]}" \ + -e APP_ENVIRONMENT_ONLY=false -e PTERODACTYL_EXTENSIONS_ENABLED=true \ + -e QUEUE_WORKER_ENABLED=false -e SCHEDULER_ENABLED=false \ + -e PHP_FPM_MAX_CHILDREN=3 -e PHP_OPCACHE_MEMORY_CONSUMPTION=192 \ + "$image" >/dev/null +wait_for healthy "$dynamic" +docker exec "$dynamic" /bin/ash -ec ' + test ! -f bootstrap/cache/config.php + test ! -f bootstrap/cache/routes-v7.php + test ! -f bootstrap/cache/events.php + php-fpm -tt 2>&1 | grep -q "pm.max_children = 3" + php -r '\''exit(ini_get("opcache.memory_consumption") === "192" ? 0 : 1);'\'' +' +for name in 'First live name' 'Second live name'; do + docker exec -i -e SMOKE_NAME="$name" "$dynamic" php <<'PHP' +make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); +Pterodactyl\Models\Setting::put('settings::app:name', getenv('SMOKE_NAME')); +PHP + docker exec "$dynamic" curl -fsS http://127.0.0.1/auth/login | grep -q "$name" +done + +docker exec "$dynamic" mkdir -p /app/extensions/cache-probe/src /app/extensions/cache-probe/dist +docker exec -i "$dynamic" /bin/ash -c 'cat > /app/extensions/cache-probe/extension.json' <<'JSON' +{"id":"cache-probe","name":"Cache probe","version":"1.0.0","provider":"CacheProbe\\Provider","autoload":{"CacheProbe\\":"src/"},"ui":{"entry":"dist/client.js"}} +JSON +docker exec -i "$dynamic" /bin/ash -c 'cat > /app/extensions/cache-probe/src/Provider.php' <<'PHP' + 'extension-enabled'); + } +} +PHP +docker exec "$dynamic" /bin/ash -ec 'echo "export const smoke = true;" > /app/extensions/cache-probe/dist/client.js' +for enabled in true false true; do + docker exec -i --user nginx -e SMOKE_ENABLED="$enabled" "$dynamic" php <<'PHP' +make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); +$app->make(Pterodactyl\Contracts\Extensions\SetsExtensionEnabled::class) + ->setEnabled('cache-probe', getenv('SMOKE_ENABLED') === 'true'); +PHP + if [ "$enabled" = true ]; then + docker exec "$dynamic" curl -fsS http://127.0.0.1/api/cache-extension-probe | grep -qx extension-enabled + version=$(docker exec "$dynamic" cat /app/public/assets/extensions/cache-probe/_current) + [[ "$version" =~ ^[a-f0-9]{64}$ ]] + docker exec "$dynamic" curl -fsS "http://127.0.0.1/assets/extensions/cache-probe/$version/client.js" | grep -qx "export const smoke = true;" + else + test "$(docker exec "$dynamic" curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1/api/cache-extension-probe)" = 404 + fi +done + +# Check the preserved custom-config path with a disposable trusted certificate. +mkdir -p "$workdir/certs/live/panel.example" +openssl req -x509 -newkey rsa:2048 -nodes -days 1 -subj /CN=panel.example \ + -addext subjectAltName=DNS:panel.example \ + -keyout "$workdir/certs/live/panel.example/privkey.pem" \ + -out "$workdir/certs/live/panel.example/fullchain.pem" > "$workdir/openssl.log" 2>&1 +sed 's//panel.example/g' "$script_dir/default_ssl.conf" > "$workdir/panel.conf" +docker create --name "$tls" --network "$prefix" "${environment[@]}" \ + -e APP_URL=https://panel.example -e LE_EMAIL=smoke@example.test \ + -e QUEUE_WORKER_ENABLED=false -e SCHEDULER_ENABLED=false \ + "$image" >/dev/null +docker cp "$workdir/certs/." "$tls:/etc/letsencrypt/" +docker cp "$workdir/panel.conf" "$tls:/etc/nginx/http.d/panel.conf" +docker start "$tls" >/dev/null +wait_for healthy "$tls" +for version in 1.2 1.3; do + docker exec "$tls" curl -fsS --tlsv"$version" --tls-max "$version" \ + --cacert /etc/letsencrypt/live/panel.example/fullchain.pem \ + --resolve panel.example:443:127.0.0.1 https://panel.example/auth/login >/dev/null +done +# Regenerate the bundled TLS config using the existing certificate, without ACME traffic. +docker exec "$tls" rm /etc/nginx/http.d/panel.conf +docker restart --time 90 "$tls" >/dev/null +wait_for healthy "$tls" +docker exec "$tls" curl -fsS \ + --cacert /etc/letsencrypt/live/panel.example/fullchain.pem \ + --resolve panel.example:443:127.0.0.1 https://panel.example/auth/login >/dev/null +docker exec "$tls" /bin/ash -ec ' + supervisorctl status queue-worker | grep -q STOPPED + supervisorctl status scheduler | grep -q STOPPED +' +echo 'PASS: no startup migrations; Redis sessions/cache/queue; docs; scheduler; graceful stop; restart; TLS 1.2/1.3; service toggles; deployment caches; live settings/extensions.' diff --git a/.github/docker/supervisord.conf b/.github/docker/supervisord.conf index da6823aeb..99058e2a2 100644 --- a/.github/docker/supervisord.conf +++ b/.github/docker/supervisord.conf @@ -1,39 +1,70 @@ [unix_http_server] -file=/tmp/supervisor.sock ; path to your socket file +file=/tmp/supervisor.sock +chmod=0700 [supervisord] -logfile=/var/log/supervisord/supervisord.log ; supervisord log file -logfile_maxbytes=50MB ; maximum size of logfile before rotation -logfile_backups=2 ; number of backed up logfiles -loglevel=error ; info, debug, warn, trace -pidfile=/var/run/supervisord.pid ; pidfile location -nodaemon=false ; run supervisord as a daemon -minfds=1024 ; number of startup file descriptors -minprocs=200 ; number of process descriptors -user=root ; default user -childlogdir=/var/log/supervisord/ ; where child log files will live +logfile=/dev/null +logfile_maxbytes=0 +loglevel=info +pidfile=/var/run/supervisord.pid +nodaemon=true +user=root [rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface +supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] -serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket +serverurl=unix:///tmp/supervisor.sock [program:php-fpm] command=/usr/local/sbin/php-fpm -F +priority=10 autostart=true autorestart=true - -[program:queue-worker] -command=/usr/local/bin/php /app/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 -user=nginx -autostart=true -autorestart=true +stopsignal=QUIT +stopwaitsecs=70 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 [program:nginx] command=/usr/sbin/nginx -g 'daemon off;' +priority=20 autostart=true autorestart=true -priority=10 -stdout_events_enabled=true -stderr_events_enabled=true \ No newline at end of file +stopsignal=QUIT +stopwaitsecs=70 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:queue-worker] +command=/usr/local/bin/php /app/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 --timeout=60 +user=nginx +priority=30 +autostart=%(ENV_QUEUE_WORKER_ENABLED)s +autorestart=true +stopsignal=TERM +stopwaitsecs=70 +stopasgroup=true +killasgroup=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:scheduler] +command=/usr/sbin/crond -f -L /dev/stdout -l 5 +priority=30 +autostart=%(ENV_SCHEDULER_ENABLED)s +autorestart=true +stopsignal=TERM +stopwaitsecs=70 +stopasgroup=true +killasgroup=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/.github/docker/www.conf b/.github/docker/www.conf index c0c17903f..53b604038 100644 --- a/.github/docker/www.conf +++ b/.github/docker/www.conf @@ -1,16 +1,16 @@ -[www] +[global] +error_log = /proc/self/fd/2 +daemonize = no +[www] user = nginx group = nginx - listen = 127.0.0.1:9000 -listen.owner = nginx -listen.group = nginx -listen.mode = 0750 - pm = ondemand -pm.max_children = 9 +pm.max_children = ${PHP_FPM_MAX_CHILDREN} pm.process_idle_timeout = 10s -pm.max_requests = 200 - -clear_env = no \ No newline at end of file +pm.max_requests = ${PHP_FPM_MAX_REQUESTS} +clear_env = no +catch_workers_output = yes +decorate_workers_output = no +ping.path = /ping diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 73e3f74f7..9b18844e7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -23,10 +23,10 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: yarn + cache: npm - name: Install dependencies - run: yarn install --frozen-lockfile - - run: yarn tsc - - run: yarn lint - - run: yarn build:production + run: npm ci + - run: npm run tsc + - run: npm run lint + - run: npm run build:production diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5268cf3ae..6ce40c887 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,8 +4,60 @@ on: pull_request: branches: - "1.0-develop" + - "2.0-develop" jobs: + frontend: + name: Frontend + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + # SDK tests exercise the PHP extension OpenAPI generator. + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + extensions: mbstring + coverage: none + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - run: npm ci + - run: npm run api:check + - run: npm test + - run: npm run build:vite + + static-analysis: + name: Static Analysis + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-8.4-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-8.4- + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + extensions: bcmath, cli, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip + tools: composer:v2 + coverage: none + - run: cp .env.ci .env + - run: composer install --no-interaction --no-progress --no-suggest --prefer-dist + - run: vendor/bin/phpstan analyse -c phpstan-rules.neon --no-progress --memory-limit=2G + - run: vendor/bin/rector --dry-run --no-progress-bar + - run: vendor/bin/phpstan analyse -c tools/phpstan/rules/phpstan.neon --no-progress --memory-limit=2G + - run: vendor/bin/phpunit -c tools/phpstan/rules/phpunit.xml + tests: name: Tests runs-on: ubuntu-24.04 @@ -15,8 +67,8 @@ jobs: fail-fast: false matrix: php: - - 8.2 - 8.3 + - 8.4 database: - mariadb:10 - mariadb:11 @@ -49,11 +101,22 @@ jobs: coverage: none - run: cp .env.ci .env - run: composer install --no-interaction --no-progress --no-suggest --prefer-dist - - run: vendor/bin/php-cs-fixer fix --dry-run --diff - - run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit + - run: vendor/bin/pint --test --parallel --cache-file=.pint.cache app bootstrap/app.php bootstrap/tests.php config database routes tests + - run: vendor/bin/pest --bootstrap vendor/autoload.php tests/Unit env: DB_HOST: UNIT_NO_DB - - run: vendor/bin/phpunit tests/Integration + - run: php -d variables_order=EGPCS vendor/bin/pest --type-coverage --min=100 + env: + __PEST_PLUGIN_ENV: 1 + - run: vendor/bin/pest tests/Integration env: DB_PORT: ${{ job.services.database.ports[3306] }} DB_USERNAME: root + - run: composer docs:openapi:verify + if: matrix.php == '8.4' && matrix.database == 'mysql:8' + env: + APP_ENV: testing + CACHE_STORE: array + PTERODACTYL_EXTENSIONS_ENABLED: 'false' + DB_PORT: ${{ job.services.database.ports[3306] }} + DB_USERNAME: root diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index afab3248a..ffd2bab2e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,6 +1,15 @@ name: Docker on: + pull_request: + paths: + - Dockerfile + - .dockerignore + - .github/docker/** + - .github/workflows/docker.yaml + - docker-compose.example.yml + - composer.json + - composer.lock push: branches: - 1.0-develop @@ -8,44 +17,30 @@ on: types: - published +env: + IMAGE: ghcr.io/pterodactyl/panel + PUBLISH: ${{ github.event_name != 'pull_request' && !contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip') }} + jobs: - push: - name: Push - runs-on: ubuntu-24.04 - if: "!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip')" + build: + name: Build (${{ matrix.platform }}) + runs-on: ${{ matrix.runner }} + timeout-minutes: 20 permissions: contents: read packages: write + strategy: + fail-fast: false + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + - platform: linux/arm64 + runner: ubuntu-24.04-arm steps: - name: Code checkout uses: actions/checkout@v4 - - name: Docker metadata - id: docker_meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/pterodactyl/panel - flavor: | - latest=false - tags: | - type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.action == 'published' && github.event.release.prerelease == false }} - type=ref,event=tag - type=ref,event=branch - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - - - name: Setup Docker buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - if: "github.event_name != 'pull_request'" - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Update version if: "github.event_name == 'release' && github.event.action == 'published'" env: @@ -53,14 +48,112 @@ jobs: run: | sed -i "s/ 'version' => 'canary',/ 'version' => '${REF:1}',/" config/app.php - - name: Build and Push + - name: Docker metadata + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + - name: Build production image uses: docker/build-push-action@v6 with: context: . - file: ./Dockerfile - push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64,linux/arm64 + platforms: ${{ matrix.platform }} + load: true + tags: panel:smoke labels: ${{ steps.docker_meta.outputs.labels }} - tags: ${{ steps.docker_meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=${{ matrix.runner }} + cache-to: type=gha,mode=max,scope=${{ matrix.runner }} + + - name: Check Compose configuration + run: docker compose -f docker-compose.example.yml config --quiet + + - name: Exercise production services + run: bash .github/docker/smoke-test.sh panel:smoke + + - name: Login to GitHub Container Registry + if: env.PUBLISH == 'true' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push image by digest + id: push + if: env.PUBLISH == 'true' + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.platform }} + labels: ${{ steps.docker_meta.outputs.labels }} + outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=${{ matrix.runner }} + + - name: Export digest + if: env.PUBLISH == 'true' + env: + DIGEST: ${{ steps.push.outputs.digest }} + run: | + mkdir -p "$RUNNER_TEMP/digests" + touch "$RUNNER_TEMP/digests/${DIGEST#sha256:}" + + - name: Upload digest + if: env.PUBLISH == 'true' + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.runner }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + push: + name: Push + needs: build + runs-on: ubuntu-24.04 + if: "github.event_name != 'pull_request' && !contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip')" + permissions: + contents: read + packages: write + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-* + merge-multiple: true + + - name: Docker metadata + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + flavor: | + latest=false + tags: | + type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.action == 'published' && github.event.release.prerelease == false }} + type=ref,event=tag + type=ref,event=branch + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create multi-platform manifest + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf "$IMAGE@sha256:%s " *) + + - name: Inspect manifest + run: docker buildx imagetools inspect "$IMAGE:$DOCKER_METADATA_OUTPUT_VERSION" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 708aa22b5..aae83dd26 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,10 +14,10 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 - cache: yarn - - run: yarn install --frozen-lockfile - - run: yarn tsc - - run: yarn build:production + cache: npm + - run: npm ci + - run: npm run tsc + - run: npm run build:production - name: create release branch and bump version env: VERSION: ${{ github.ref_name }} @@ -34,7 +34,7 @@ jobs: - name: create release archive run: | rm -rf node_modules tests CONTRIBUTING.md flake.lock flake.nix phpunit.xml shell.nix - tar -czf panel.tar.gz * .editorconfig .env.example .eslintignore .eslintrc.js .gitignore .prettierrc.json + tar -czf panel.tar.gz * .editorconfig .env.example .gitignore .oxfmtrc.json - name: write changelog run: | sed -n "/^## ${{ github.ref_name }}/,/^## /{/^## /b;p}" CHANGELOG.md > ./RELEASE_CHANGELOG @@ -47,3 +47,15 @@ jobs: body_path: ./RELEASE_CHANGELOG files: | panel.tar.gz + + # Publishes the tagged version to https://cdn.pterodactyl.io/releases/latest.json + # through pterodactyl/pterodactyl-cdn, which every panel polls for updates. + - name: Update CDN release manifest + if: ${{ !contains(github.ref_name, 'rc') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'alpha') }} + env: + GH_TOKEN: ${{ secrets.CDN_DISPATCH_TOKEN }} + VERSION: ${{ github.ref_name }} + run: | + jq -n --arg version "$VERSION" \ + '{event_type: "release-tagged", client_payload: {component: "panel", version: $version}}' \ + | gh api repos/pterodactyl/pterodactyl-cdn/dispatches --input - diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml new file mode 100644 index 000000000..b4475438d --- /dev/null +++ b/.github/workflows/staging.yaml @@ -0,0 +1,21 @@ +name: Staging + +on: + push: + branches: + - 2.0-develop + +concurrency: + group: staging-dispatch + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Notify staging deployment + run: | + curl -sf -X POST \ + -H "Authorization: Bearer ${{ secrets.STAGING_DISPATCH_TOKEN }}" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/${{ secrets.STAGING_DISPATCH_REPO }}/dispatches" \ + -d "{\"event_type\":\"panel-next-push\",\"client_payload\":{\"sha\":\"${GITHUB_SHA}\",\"ref\":\"${GITHUB_REF_NAME}\"}}" diff --git a/.gitignore b/.gitignore index f59b05d1f..cbe6712ef 100644 --- a/.gitignore +++ b/.gitignore @@ -20,18 +20,32 @@ public/assets/manifest.json # For local development with docker # Remove if we ever put the Dockerfile in the repo -.dockerignore docker-compose.* !docker-compose.example.yml !docker-compose.example.yaml # for image related files misc -.php-cs-fixer.cache +.pint.cache coverage.xml resources/lang/locales.js .phpunit.result.cache +.phpunit.cache/ /public/build /public/hot result + +# Scribe generated output +.scribe/ +/public/vendor/scribe/ +/resources/views/scribe/ + +# Extension example build output +/examples/*/dist + +# Local extension development checkouts +/extensions/ + +# Generated SDK test host bundles +/packages/sdk/testing-runtime/ diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..2bd5a0a98 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 000000000..4d2b37b4f --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,13 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "printWidth": 120, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": true, + "jsxSingleQuote": true, + "endOfLine": "lf", + "trailingComma": "es5", + "sortPackageJson": false, + "ignorePatterns": ["resources/scripts/api/generated/**"] +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 000000000..5ea6ffb4d --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,233 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["eslint", "typescript", "react", "oxc"], + "jsPlugins": [ + { + "name": "rules", + "specifier": "./tools/oxlint/rules/index.ts" + } + ], + "categories": { + "correctness": "error", + "suspicious": "off", + "perf": "warn", + "style": "off", + "pedantic": "off", + "restriction": "off", + "nursery": "off" + }, + "env": { + "builtin": true, + "browser": true, + "es2022": true + }, + "settings": { + "react": { + "version": "19.0.0", + "linkComponents": [ + { + "name": "Link", + "linkAttribute": "to" + }, + { + "name": "NavLink", + "linkAttribute": "to" + } + ] + } + }, + "options": { + "reportUnusedDisableDirectives": "warn", + "respectEslintDisableDirectives": true + }, + "ignorePatterns": [ + "public/**", + "resources/views/**", + ".claude/**", + "**/generated/*", + "!resources/scripts/api/generated/types.gen.ts" + ], + "overrides": [ + { + "files": ["**/*.{ts,tsx,js,jsx,mjs}"], + "excludeFiles": ["**/generated/**"], + "rules": { + "rules/no-chained-type-assertions": "error", + "rules/no-conditional-empty-object-spread": "error", + "rules/no-known-value-widening": "error", + "rules/no-object-parameters": "error", + "rules/no-runtime-typeof": "error", + "rules/no-shape-in-symbol-names": "error", + "rules/no-unknown-parameters": "error", + "rules/no-unknown-type-aliases": "error", + "rules/no-unsafe-dictionary-type": "error", + "rules/no-widen-then-assert": "error", + "eqeqeq": "error", + "no-use-before-define": "warn", + "no-unused-expressions": [ + "error", + { + "allowShortCircuit": true, + "allowTernary": true + } + ], + "no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_" + } + ], + "react/display-name": "off", + "react/react-in-jsx-scope": "off", + "react/rules-of-hooks": "error", + "react/exhaustive-deps": "warn", + "typescript/no-explicit-any": "error", + "typescript/no-non-null-assertion": "off", + "typescript/consistent-type-imports": [ + "error", + { + "fixStyle": "inline-type-imports" + } + ], + "typescript/ban-ts-comment": [ + "error", + { + "ts-expect-error": "allow-with-description" + } + ] + } + }, + { + "files": ["resources/scripts/**"], + "excludeFiles": ["resources/scripts/state/**", "**/generated/**"], + "rules": { + "no-restricted-imports": [ + "error", + { + "patterns": [ + { + "group": ["zustand", "zustand/*"], + "message": "Access state through resources/scripts/state." + }, + { + "group": ["@/state/hooks", "@/api/useGeneratedMutation"], + "message": "Use the current state and generated API interfaces." + } + ] + } + ] + } + }, + { + "files": ["resources/scripts/**"], + "excludeFiles": ["**/generated/**"], + "rules": { + "rules/generated-api-imports": "error" + } + }, + { + "files": ["resources/scripts/**", "packages/hello-world/src/client/**"], + "excludeFiles": ["**/generated/**", "**/*.spec.{ts,tsx}"], + "rules": { + "rules/design-tokens": "error" + } + }, + { + "files": ["resources/scripts/api/**", "packages/hello-world/src/client/**"], + "excludeFiles": ["**/generated/**", "**/*.spec.{ts,tsx}"], + "rules": { + "rules/generated-api-mutations": "error", + "no-restricted-properties": [ + "error", + { + "object": "http", + "property": "get", + "message": "Use the generated API client." + }, + { + "object": "http", + "property": "post", + "message": "Use the generated API client." + }, + { + "object": "http", + "property": "put", + "message": "Use the generated API client." + }, + { + "object": "http", + "property": "patch", + "message": "Use the generated API client." + }, + { + "object": "http", + "property": "delete", + "message": "Use the generated API client." + }, + { + "object": "http", + "property": "request", + "message": "Use the generated API client." + }, + { + "object": "axios", + "property": "get", + "message": "Use the generated API client." + }, + { + "object": "axios", + "property": "post", + "message": "Use the generated API client." + }, + { + "object": "axios", + "property": "put", + "message": "Use the generated API client." + }, + { + "object": "axios", + "property": "patch", + "message": "Use the generated API client." + }, + { + "object": "axios", + "property": "delete", + "message": "Use the generated API client." + }, + { + "object": "axios", + "property": "request", + "message": "Use the generated API client." + } + ] + } + }, + { + "files": [ + "resources/scripts/api/server/backups/queries.ts", + "resources/scripts/api/server/files/queries.ts" + ], + "rules": { + "rules/generated-api-mutations": "off" + } + }, + { + "files": [ + "resources/scripts/api/http.ts", + "resources/scripts/api/interceptors.ts", + "resources/scripts/api/server/files/queries.ts" + ], + "rules": { + "no-restricted-properties": "off" + } + }, + { + "files": ["resources/scripts/api/generated/types.gen.ts"], + "rules": { + "rules/generated-api-types": "error", + "typescript/no-empty-object-type": "error" + } + } + ] +} diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index 75a609e96..000000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,58 +0,0 @@ -name('*.php') - ->ignoreVCSIgnored(true) - ->exclude([__DIR__ . '/bootstrap/cache']) - ->in([ - __DIR__ . '/app', - __DIR__ . '/bootstrap', - __DIR__ . '/config', - __DIR__ . '/database', - __DIR__ . '/routes', - __DIR__ . '/tests', - ]); - -return (new Config()) - ->setFinder($finder) - ->setUsingCache(true) - ->setParallelConfig(ParallelConfigFactory::detect()) - ->setRules([ - '@Symfony' => true, - '@PSR1' => true, - '@PSR2' => true, - '@PSR12' => true, - 'align_multiline_comment' => ['comment_type' => 'phpdocs_like'], - 'combine_consecutive_unsets' => true, - 'concat_space' => ['spacing' => 'one'], - 'heredoc_to_nowdoc' => true, - // 'no_alias_functions' => true, - // 'no_unreachable_default_argument_value' => true, - 'no_useless_return' => true, - 'ordered_imports' => [ - 'sort_algorithm' => 'length', - ], - 'phpdoc_align' => [ - 'align' => 'left', - 'tags' => [ - 'param', - 'property', - 'return', - 'throws', - 'type', - 'var', - ], - ], - 'phpdoc_no_alias_tag' => false, - // 'random_api_migration' => true, - 'ternary_to_null_coalescing' => true, - 'yoda_style' => [ - 'equal' => false, - 'identical' => false, - 'less_and_greater' => false, - ], - ]); diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index d000a2241..000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "printWidth": 120, - "tabWidth": 4, - "useTabs": false, - "semi": true, - "singleQuote": true, - "jsxSingleQuote": true, - "endOfLine": "lf" -} diff --git a/BUILDING.md b/BUILDING.md deleted file mode 100644 index d8b703338..000000000 --- a/BUILDING.md +++ /dev/null @@ -1,63 +0,0 @@ -# Local Development -Pterodactyl is now powered by React, Typescript, and Tailwindcss using webpack at its core to generate compiled assets. -Release versions of Pterodactyl will include pre-compiled, minified, and hashed assets ready-to-go. - -However, if you are interested in running custom themes or making modifications to the React files you'll need a build -system in place to generate these compiled assets. To get your environment setup you'll need at minimum: - -* [Node.js](https://nodejs.org/en/) v14.x.x -* [Yarn](https://classic.yarnpkg.com/lang/en/) v1.x.x -* [Go](https://golang.org/) 1.17.x - -### Install Dependencies -```bash -yarn install -``` - -The command above will download all of the dependencies necessary to get Pterodactyl assets building. After that, its as -simple as running the command below to generate assets while you're developing. Until you've run this command at least -once you'll likely see a 500 error on your Panel about a missing `manifest.json` file. This is generated by the commands -below. - -```bash -# Build the compiled set of assets for development. -yarn run build - -# Build the assets automatically as they are changed. This allows you to refresh -# the page and see the changes immediately. -yarn run watch -``` - -### Hot Module Reloading -For more advanced users, we also support 'Hot Module Reloading', allowing you to quickly see changes you're making -to the Vue template files without having to reload the page you're on. To Get started with this, you just need -to run the command below. - -```bash -PUBLIC_PATH=http://192.168.1.1:8080 yarn run serve --host 192.168.1.1 -``` - -There are two _very important_ parts of this command to take note of and change for your specific environment. The first -is the `--host` flag, which is required and should point to the machine where the `webpack-serve` server will be running. -The second is the `PUBLIC_PATH` environment variable which is the URL pointing to the HMR server and is appended to all of -the asset URLs used in Pterodactyl. - -#### Development Environment -If you're using the [`pterodactyl/development`](https://github.com/pterodactyl/development) environments, which are -highly recommended, you can just run `yarn run serve` to run the HMR server, no additional configuration is necessary. - -### Building for Production -Once you have your files squared away and ready for the live server, you'll be needing to generate compiled, minified, -and hashed assets to push live. To do so, run the command below: - -```bash -yarn run build:production -``` - -This will generate a production JS bundle and associated assets, all located in `public/assets/` which will need to -be uploaded to your server or CDN for clients to use. - -### Running Wings -To run `wings` in development all you need to do is set up the configuration file as normal when adding a new node, and -then you can build and run a local version of Wings by executing `make debug` in the Wings code directory. This must -be run on a Linux VM of some sort, you cannot run this locally on macOS or Windows. diff --git a/CHANGELOG.md b/CHANGELOG.md index 55aa8ab7e..f46535a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,34 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. +## v2.0.0 (unreleased) +Extension SDK `2.0.0-beta.4`. + +### Fixed +* Extension web routes under `/extensions/` are now matched before the SPA catch-all route, which previously answered them. +* A `theme-color` meta tag registered by an extension is no longer overwritten by the `--theme-color` theme token. +* An enabled extension's Tailwind utilities no longer override the panel's own or another extension's, which showed the mobile menu button beside the admin sidebar and collapsed one extension's responsive grid when a second was enabled. + +### Changed +* Core file reads, directory listings, live server state and login completion now run through action contracts that extensions can call and wrap. +* `nav.icon` in an extension manifest accepts any lucide icon name instead of a fixed list of nine. +* `ExtensionRepository::frontendPayload()` takes whether the viewer is authenticated; guests only receive settings marked `->public()`. +* The client API server resource includes `egg_tags`. +* Each extension builds Tailwind with its own prefix, declared as `ui.prefix` in the manifest (2-12 lowercase letters; `hw` gives `hw:flex`, `hw:lg:hidden` and theme variables under `--hw-*`). Tailwind variant names, theme namespaces and panel names are reserved, two enabled extensions cannot share a prefix, and `p:extension:doctor`, `p:extension:pack`, install and enable reject a build whose utilities or theme variables do not carry the declared prefix. `p:extension:make` derives a prefix from the id or takes `--prefix`. +* `@pterodactyl/sdk/theme.css` points prefixed extension builds at the panel's live `--spacing` and font tokens; the panel imports the shared mapping from `packages/sdk/theme-tokens.css`. +* Class names passed to core components resolve the prefixed utilities of every enabled extension against the panel utility they replace; the SDK test hosts take the `prefix` to do the same. + +### Added +* Adds `ReadsFileContents`, `ListsDirectories`, `ReadsServerLogs`, `ReadsServerState`, `ChangesServerEgg` and `CompletesLogins` action contracts. +* Adds `GET /api/client/servers/{server}/logs` and the SDK `serverLogsQueryOptions` to read recent console output. +* Adds `wrapAction`, `registerCommands`, `registerSchedule`, `registerHeadTags` and `registerRootRoutes` (with the manifest's `routes.root`) to extension providers. +* `OperationCompleted` now also reports `delete`, `suspend`, `unsuspend` and `transfer`. +* Adds public extension settings (`->frontend()->public()`) and the `color`, `textarea`, `multiselect`, `list` and `file` setting fields, with uploads served from `/extension-files//`. +* Adds conditional extension screens (`ui.screens[].when` and a runtime `visible` predicate), live navigation badges, `NamedIcon` and `@pterodactyl/sdk/icons.json`. +* Adds the replaceable `server.files.editor` and `server.files.manager` components, `useNavigationBlocker`, `serverResourcesQueryOptions`, `useServerResources`, `useSendServerPower` and `useSendServerCommand` to the SDK. +* Adds layout, terminal, selection, scrollbar and browser chrome theme tokens, a sidebar sub-navigation mode (`data-sub-navigation="side"`), and `onThemeChange`, `notifyThemeChange` and `readThemeToken`. +* Scaffolded extensions set `preserveSymlinks` so a linked SDK resolves its peer types from the extension. + ## v1.12.3 ### Fixed * Adds a rate limit when changing email addresses on an account to prevent account enumeration. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 99f8ff018..6ee466c36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,33 +1,25 @@ # Contributing -**Pterodactyl does not accept Pull Requests (PRs) _for new functionality_** that was not previously approved by project -maintainers on GitHub discussions. It has become overwhelming to try and give the proper time and attention that such -complicated PRs tend to require. As a result, it is in the project's best interest to limit the scope of work on new -functionality to work done within the core project team. - -PRs that address existing bugs or features **with a corresponding issue opened in our issue tracker** will continue to -be accepted and reviewed. Their scope is often significantly more targeted, and simply improving upon existing and well -defined logic. - -## AI Assistance - -If you use any type of AI assistance while developing for Pterodactyl **it must be disclosed** within the -corresponding review PR and you must identify what it was used for. All interaction with the community must be written -by a human. **You MUST NOT use AI to compose any PR titles, descriptions, or comments**, and must not use AI to -interact with the GitHub Discussions community. +Pterodactyl is a community project. All contributions to both Panel and Wings are welcome, whether it's new features or bug fixes. ## Responsible Disclosure - This is an in-depth project making use of many moving pieces. While we strive to keep everything as secure as possible and welcome you to take a look at the code provided in this project yourself. We do ask that you be considerate of others who are using the software and not publicly disclose security issues. Please see [`SECURITY.md`](/SECURITY.md) for information on how to report security issues to the team. ## Contact Us - You can find us in a couple places online. First and foremost, we're active right here on GitHub. If you encounter a bug or other problems, open an issue on here for us to take a look at it. Please make use of our [GitHub Discussions](https://github.com/orgs/pterodactyl/discussions/categories/feature-requests) for any feature requests, general questions, or help with the software. You can also find us on [Discord](https://discord.gg/pterodactyl). + +## AI-assisted contributions +AI and LLMs are awesome, they can truly 10x your productivity, help explore a large codebase, help with large changes, and write lots of test coverage. That said, they do not replace your responsibility for the result and output of an LLM tool. + +- Please keep the conversation in your own voice. Review, rewrite generated code comments, issue reports, and pull requests descriptions so they reflect the intent of what you mean. +- Keep ownership of the of all decisions made, you have to understand every change, and you must verify the behavior with appropriate test coverage at the bare minimum, your code should reflect the style of the codebase. +- Do not copy paste LLM output verbatim into the codebase and expect a contribution, you will treat generated output as a draft, and you, the human, are expected to check it's claims, adapt it to the repository, and remove anything that you yourself cannot justify. Issues that are entirely unreviewed LLM output will be closed without review. +- AI-assisted contributions follow the same standards for quality, correctness, testing, etc as any other contribution. diff --git a/Dockerfile b/Dockerfile index d7ddd49b5..65eba2e04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,41 +1,82 @@ -# Stage 0: -# Build the assets that are needed for the frontend. This build stage is then discarded -# since we won't need NodeJS anymore in the future. This Docker image ships a final production -# level distribution of Pterodactyl. -FROM --platform=$TARGETOS/$TARGETARCH node:22-alpine -WORKDIR /app -COPY . ./ -RUN yarn install --frozen-lockfile \ - && yarn run build:production +# syntax=docker/dockerfile:1 -# Stage 1: -# Build the actual container with all of the needed PHP dependencies that will run the application. -FROM --platform=$TARGETOS/$TARGETARCH php:8.3-fpm-alpine +FROM --platform=$BUILDPLATFORM node:22-alpine3.23 AS assets WORKDIR /app -COPY . ./ -COPY --from=0 /app/public/assets ./public/assets -RUN apk add --no-cache --update ca-certificates dcron curl git supervisor tar unzip nginx libpng-dev libxml2-dev libzip-dev certbot certbot-nginx mysql-client \ - && docker-php-ext-configure zip \ - && docker-php-ext-install bcmath gd pdo_mysql zip \ - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ - && cp .env.example .env \ - && mkdir -p bootstrap/cache/ storage/logs storage/framework/sessions storage/framework/views storage/framework/cache \ - && chmod 777 -R bootstrap storage \ - && composer install --no-dev --optimize-autoloader \ - && rm -rf .env bootstrap/cache/*.php \ - && mkdir -p /app/storage/logs/ \ - && chown -R nginx:nginx . -RUN rm /usr/local/etc/php-fpm.conf \ - && echo "* * * * * /usr/local/bin/php /app/artisan schedule:run >> /dev/null 2>&1" >> /var/spool/cron/crontabs/root \ - && echo "0 23 * * * certbot renew --nginx --quiet" >> /var/spool/cron/crontabs/root \ - && sed -i s/ssl_session_cache/#ssl_session_cache/g /etc/nginx/nginx.conf \ - && mkdir -p /var/run/php /var/run/nginx +COPY package.json package-lock.json ./ +RUN --mount=type=cache,target=/root/.npm npm ci --no-audit --no-fund + +COPY . . +RUN npm run build:force + +FROM php:8.4-fpm-alpine3.23 AS php-base +WORKDIR /app + +RUN apk add --no-cache \ + ca-certificates certbot certbot-nginx curl dcron freetype icu-libs \ + libjpeg-turbo libpng libwebp libzip mysql-client nginx supervisor tzdata \ + && apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS freetype-dev icu-dev libjpeg-turbo-dev libpng-dev libwebp-dev libzip-dev \ + && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \ + && docker-php-ext-install -j"$(nproc)" bcmath gd intl opcache pcntl pdo_mysql zip \ + && apk del .build-deps \ + && mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +FROM php-base AS dependencies +COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer + +ENV COMPOSER_ALLOW_SUPERUSER=1 \ + COMPOSER_CACHE_DIR=/tmp/composer-cache + +COPY composer.json composer.lock ./ +RUN --mount=type=cache,target=/tmp/composer-cache \ + composer install --no-dev --prefer-dist --no-interaction --no-progress --no-scripts --no-plugins --no-autoloader + +COPY . . +RUN composer dump-autoload --no-dev --optimize --no-interaction --no-scripts --no-plugins \ + && composer check-platform-reqs --no-dev \ + && mkdir -p bootstrap/cache storage/app/private storage/framework/cache/data \ + storage/framework/sessions storage/framework/views storage/logs \ + && APP_KEY="$(php -r 'echo "base64:".base64_encode(random_bytes(32));')" \ + APP_ENV=production APP_DEBUG=false APP_ENVIRONMENT_ONLY=true \ + CACHE_DRIVER=array SESSION_DRIVER=array QUEUE_DRIVER=sync \ + PTERODACTYL_EXTENSIONS_ENABLED=false php artisan package:discover --ansi \ + && rm -f bootstrap/cache/*.php + +FROM php-base AS runtime + +ENV APP_ENV=production \ + APP_DEBUG=false \ + QUEUE_WORKER_ENABLED=true \ + SCHEDULER_ENABLED=true \ + LARAVEL_OPTIMIZE=true \ + PHP_FPM_MAX_CHILDREN=9 \ + PHP_FPM_MAX_REQUESTS=200 \ + PHP_OPCACHE_MEMORY_CONSUMPTION=128 + +COPY --from=dependencies /app /app +COPY --from=dependencies /usr/local/bin/composer /usr/local/bin/composer +COPY --from=assets /app/public/assets /app/public/assets + +RUN apk add --no-cache su-exec icu-data-full \ + && mkdir -p /app/var /app/extensions /app/public/assets/extensions /var/run/php /var/run/nginx /var/log/supervisord \ + && chown -R nginx:nginx /app/bootstrap/cache /app/storage /app/var /app/extensions /app/public/assets/extensions \ + && chmod -R u=rwX,g=rwX,o= /app/bootstrap/cache /app/storage /app/var /app/extensions /app/public/assets/extensions \ + && printf '%s\n' \ + '* * * * * /usr/local/bin/php /app/artisan schedule:run >> /app/storage/logs/scheduler.log 2>&1' > /var/spool/cron/crontabs/nginx \ + && printf '%s\n' '0 23 * * * certbot renew --nginx --quiet' > /var/spool/cron/crontabs/root \ + && chmod 600 /var/spool/cron/crontabs/root /var/spool/cron/crontabs/nginx \ + && sed -i 's/ssl_session_cache/#ssl_session_cache/g' /etc/nginx/nginx.conf COPY .github/docker/default.conf /etc/nginx/http.d/default.conf +COPY .github/docker/php.ini /usr/local/etc/php/conf.d/zz-panel.ini COPY .github/docker/www.conf /usr/local/etc/php-fpm.conf COPY .github/docker/supervisord.conf /etc/supervisord.conf +STOPSIGNAL SIGTERM +HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ + CMD ["/bin/ash", "/app/.github/docker/healthcheck.sh"] + EXPOSE 80 443 -ENTRYPOINT [ "/bin/ash", ".github/docker/entrypoint.sh" ] -CMD [ "supervisord", "-n", "-c", "/etc/supervisord.conf" ] +ENTRYPOINT ["/bin/ash", "/app/.github/docker/entrypoint.sh"] +CMD ["supervisord", "-n", "-c", "/etc/supervisord.conf"] diff --git a/README.md b/README.md index cee480ac2..85a3deea7 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,14 @@ I would like to extend my sincere thanks to the following sponsors for helping f | Company | About | |-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [**Aussie Server Hosts**](https://aussieserverhosts.com/) | No frills Australian Owned and operated High Performance Server hosting for some of the most demanding games serving Australia and New Zealand. | -| [**BisectHosting**](https://www.bisecthosting.com/) | BisectHosting provides Minecraft, Valheim and other server hosting services with the highest reliability and lightning fast support since 2012. | -| [**MineStrator**](https://minestrator.com/) | Looking for the most highend French hosting company for your minecraft server? More than 24,000 members on our discord trust us. Give us a try! | -| [**HostEZ**](https://hostez.io) | US & EU Rust & Minecraft Hosting. DDoS Protected bare metal, VPS and colocation with low latency, high uptime and maximum availability. EZ! | -| [**Blueprint**](https://blueprint.zip/?utm_source=pterodactyl&utm_medium=sponsor) | Create and install Pterodactyl addons and themes with the growing Blueprint framework - the package-manager for Pterodactyl. Use multiple modifications at once without worrying about conflicts and make use of the large extension ecosystem. | -| [**indifferent broccoli**](https://indifferentbroccoli.com/) | indifferent broccoli is a game server hosting and rental company. With us, you get top-notch computer power for your gaming sessions. We destroy lag, latency, and complexity--letting you focus on the fun stuff. | +| [**Buildurly**](https://buildurly.com/) | Buildurly is a hardware procurement company. They deliver tailored, enterprise-grade hardware solutions designed around your unique needs. From sourcing to delivery, Buildurly's white-glove service ensures a seamless, worry-free, professional experience. | +| [**Hosturly**](https://hosturly.com/) | Hosturly is an enterprise hosting provider. They provide cost-effective, high-performance, and reliable services, including VPS, Web, Dedicated, and Colocation. | +| [**indifferent broccoli**](https://indifferentbroccoli.com/) | indifferent broccoli is a game server hosting and rental company. With them, you get top-notch computer power for your gaming sessions. They destroy lag, latency, and complexity--letting you focus on the fun stuff. | +| [**Infraly, LLC**](https://infraly.co/) | Infraly is an infrastructure company powering the next generation of online services. Through their brands, Infraly delivers cutting-edge solutions across multiple markets. Their vertically integrated approach provides unmatched performance, scalability, and reliability, giving our customers full control. | +| [**MineStrator**](https://minestrator.com/) | MineStrator is a game server hosting provider. Looking for the most high-end French hosting company for your Minecraft server? More than 24,000 members on our Discord trust us. Give us a try! | +| [**Physgun**](https://physgun.com/) | Physgun is a game server hosting provider. Most providers rent rack space and rebrand a panel. At Physgun, they engineer the performance, write the features, and staff the support. Physgun truly is game hosting perfected! | +| [**WISP**](https://wisp.gg/) | WISP is an industry-leading SaaS platform for game server management, designed for hosting companies, gaming organizations, and enthusiasts. WISP combines modern, intuitive interfaces with powerful tools, making server deployment and administration seamless, scalable, and efficient. | + ### Supported Games @@ -63,7 +65,7 @@ and there are plenty more games available provided by the community. Some of the * Xonotic * Starmade * Discord ATLBot, and most other Node.js/Python discord bots -* [and many more...](https://pterodactyleggs.com) +* [and many more...](https://eggs.pterodactyl.io) ## License diff --git a/app/Actions/Activity/IngestActivityLogs.php b/app/Actions/Activity/IngestActivityLogs.php new file mode 100644 index 000000000..14774f638 --- /dev/null +++ b/app/Actions/Activity/IngestActivityLogs.php @@ -0,0 +1,77 @@ +getTimezone(); + $servers = $node->servers()->whereIn('uuid', array_column($events, 'server'))->get()->keyBy('uuid'); + $users = User::query()->whereIn('uuid', array_filter(array_column($events, 'user')))->get()->keyBy('uuid'); + $logs = []; + + foreach ($events as $datum) { + $server = $servers->get($datum['server']); + if ($server === null || ! Str::startsWith($datum['event'], 'server:')) { + continue; + } + + try { + $when = Date::createFromFormat(DateTimeInterface::RFC3339, preg_replace('/(\.\d+)Z$/', 'Z', $datum['timestamp']) ?? $datum['timestamp'], 'UTC') + ?? throw new InvalidArgumentException('The activity timestamp could not be parsed.'); + } catch (Exception $exception) { + Log::warning($exception->getMessage(), ['exception' => $exception, 'timestamp' => $datum['timestamp']]); + $when = now(); + $datum['metadata'] = array_merge($datum['metadata'], ['original_timestamp' => $datum['timestamp']]); + } + + $log = [ + 'ip' => empty($datum['ip']) ? '127.0.0.1' : $datum['ip'], + 'event' => $datum['event'], + 'properties' => json_encode($datum['metadata']), + 'timestamp' => $when->setTimezone($tz), + ]; + + if ($user = $users->get($datum['user'] ?? null)) { + $log['actor_id'] = $user->id; + $log['actor_type'] = $user->getMorphClass(); + } + + $logs[$datum['server']][] = $log; + } + + foreach ($logs as $key => $data) { + $server = $servers->get($key); + throw_unless($server instanceof Server, InvalidArgumentException::class, "Server [$key] was not found while processing activity."); + $batch = []; + + foreach ($data as $datum) { + $id = ActivityLog::query()->insertGetId($datum); + $batch[] = [ + 'activity_log_id' => $id, + 'subject_id' => $server->id, + 'subject_type' => $server->getMorphClass(), + ]; + } + + ActivityLogSubject::query()->insert($batch); + } + } +} diff --git a/app/Actions/Allocations/AssignAllocation.php b/app/Actions/Allocations/AssignAllocation.php new file mode 100644 index 000000000..45b6bc330 --- /dev/null +++ b/app/Actions/Allocations/AssignAllocation.php @@ -0,0 +1,31 @@ +allocations()->lockForUpdate()->count() >= $server->allocation_limit, DisplayException::class, 'Cannot assign additional allocations to this server: limit has been reached.'); + + return $this->assignable->assignAvailable($server)->refresh(); + }); + } +} diff --git a/app/Actions/Allocations/AssignAvailableAllocation.php b/app/Actions/Allocations/AssignAvailableAllocation.php new file mode 100644 index 000000000..649ef797b --- /dev/null +++ b/app/Actions/Allocations/AssignAvailableAllocation.php @@ -0,0 +1,49 @@ +allocation ?? throw new UnexpectedValueException('The server does not have a primary allocation.'); + $allocation = $server->node->allocations()->lockForUpdate()->where('ip', $primaryAllocation->ip)->whereNull('server_id')->inRandomOrder()->first(); + + if ($allocation === null) { + $start = config('pterodactyl.client_features.allocations.range_start'); + $end = config('pterodactyl.client_features.allocations.range_end'); + JsonValueGuard::assertValue($start); + JsonValueGuard::assertValue($end); + $range = AllocationRange::fromConfig($start, $end); + throw_unless($range instanceof AllocationRange, NoAutoAllocationSpaceAvailableException::class); + $ports = $server->node->allocations()->where('ip', $primaryAllocation->ip)->whereBetween('port', [$range->start, $range->end])->get(['port'])->map(fn (Allocation $allocation): int => $allocation->port)->all(); + $available = array_diff(range($range->start, $range->end), $ports); + throw_if($available === [], NoAutoAllocationSpaceAvailableException::class); + $port = Collection::make($available)->random(); + $this->allocations->create($server->node, ['allocation_ip' => $primaryAllocation->ip, 'allocation_ports' => [$port]]); + $allocation = $server->node->allocations()->lockForUpdate()->where('ip', $primaryAllocation->ip)->where('port', $port)->firstOrFail(); + } + + $allocation->update(['server_id' => $server->id]); + + return $allocation->refresh(); + } +} diff --git a/app/Actions/Allocations/CreateAllocations.php b/app/Actions/Allocations/CreateAllocations.php new file mode 100644 index 000000000..96c064269 --- /dev/null +++ b/app/Actions/Allocations/CreateAllocations.php @@ -0,0 +1,97 @@ + self::CIDR_MIN_BITS || $segments[1] < self::CIDR_MAX_BITS), CidrOutOfRangeException::class); + } + + $underlying = $data['allocation_ip']; + try { + $underlying = gethostbyname($data['allocation_ip']); + $parsed = Network::parse($underlying); + } catch (Exception $exception) { + throw new DisplayException("Could not parse provided allocation IP address ({$underlying}): {$exception->getMessage()}", $exception); + } + + DB::transaction(function () use ($node, $data, $parsed): void { + foreach ($parsed as $ip) { + foreach ($data['allocation_ports'] as $port) { + // SAFETY: the allocation contract limits ports to integers and strings before this syntax parser. + $portText = (string) $port; + $isPort = ctype_digit($portText); + $isRange = preg_match(self::PORT_RANGE_REGEX, $portText, $matches) === 1; + throw_if(! $isPort && ! $isRange, InvalidPortMappingException::class, $port); + + if ($isRange) { + // SAFETY: PORT_RANGE_REGEX captures two decimal integer strings. + $start = (int) $matches[1]; + // SAFETY: PORT_RANGE_REGEX captures two decimal integer strings. + $end = (int) $matches[2]; + $block = range($start, $end); + throw_if(count($block) > self::PORT_RANGE_LIMIT, TooManyPortsInRangeException::class); + throw_if($start <= self::PORT_FLOOR || $end > self::PORT_CEIL, PortOutOfRangeException::class); + } else { + // SAFETY: ctype_digit() above proves a decimal port string in the non-range branch. + $portNumber = (int) $portText; + throw_if($portNumber <= self::PORT_FLOOR || $portNumber > self::PORT_CEIL, PortOutOfRangeException::class); + $block = [$portNumber]; + } + + $insertData = []; + foreach ($block as $unit) { + $insertData[] = [ + 'node_id' => $node->id, + 'ip' => $ip->__toString(), + 'port' => $unit, + 'ip_alias' => $data['allocation_alias'] ?? null, + 'server_id' => null, + ]; + } + + Allocation::query()->insertOrIgnore($insertData); + } + } + }); + } +} diff --git a/app/Actions/Allocations/DeleteAllocation.php b/app/Actions/Allocations/DeleteAllocation.php new file mode 100644 index 000000000..82321e380 --- /dev/null +++ b/app/Actions/Allocations/DeleteAllocation.php @@ -0,0 +1,26 @@ +server_id !== null) { + throw new ServerUsingAllocationException(trans('exceptions.allocations.server_using')); + } + + $allocation->delete(); + } +} diff --git a/app/Actions/Allocations/SetPrimaryAllocation.php b/app/Actions/Allocations/SetPrimaryAllocation.php new file mode 100644 index 000000000..7846b5c49 --- /dev/null +++ b/app/Actions/Allocations/SetPrimaryAllocation.php @@ -0,0 +1,19 @@ +update(['allocation_id' => $allocation->id]); + + return $allocation->refresh(); + } +} diff --git a/app/Actions/Allocations/UnassignAllocation.php b/app/Actions/Allocations/UnassignAllocation.php new file mode 100644 index 000000000..b0941967c --- /dev/null +++ b/app/Actions/Allocations/UnassignAllocation.php @@ -0,0 +1,29 @@ +allocation_limit), DisplayException::class, 'You cannot delete allocations for this server: no allocation limit is set.'); + throw_if($allocation->id === $server->allocation_id, DisplayException::class, 'You cannot delete the primary allocation for this server.'); + + Allocation::query()->where('id', $allocation->id)->update([ + 'notes' => null, + 'server_id' => null, + ]); + + return $allocation->refresh(); + } +} diff --git a/app/Actions/Allocations/UpdateAllocation.php b/app/Actions/Allocations/UpdateAllocation.php new file mode 100644 index 000000000..e04b0537f --- /dev/null +++ b/app/Actions/Allocations/UpdateAllocation.php @@ -0,0 +1,20 @@ +forceFill([ + 'ip_alias' => empty($alias) ? null : $alias, + ])->saveOrFail(); + + return $allocation->refresh(); + } +} diff --git a/app/Actions/Allocations/UpdateAllocationNotes.php b/app/Actions/Allocations/UpdateAllocationNotes.php new file mode 100644 index 000000000..756d3cace --- /dev/null +++ b/app/Actions/Allocations/UpdateAllocationNotes.php @@ -0,0 +1,18 @@ +forceFill(['notes' => $notes])->save(); + + return $allocation->refresh(); + } +} diff --git a/app/Actions/Api/CreateAccountApiKey.php b/app/Actions/Api/CreateAccountApiKey.php new file mode 100644 index 000000000..109fce1fb --- /dev/null +++ b/app/Actions/Api/CreateAccountApiKey.php @@ -0,0 +1,25 @@ +|null $allowedIps */ + public function create(User $user, ?string $description, ?array $allowedIps): NewAccessToken + { + return DB::transaction(function () use ($user, $description, $allowedIps): NewAccessToken { + $user = User::query()->lockForUpdate()->findOrFail($user->id); + throw_if($user->apiKeys()->count() >= 25, DisplayException::class, 'You have reached the account limit for number of API keys.'); + + return $user->createToken($description, $allowedIps); + }); + } +} diff --git a/app/Actions/Api/CreateApiKey.php b/app/Actions/Api/CreateApiKey.php new file mode 100644 index 000000000..4b761554a --- /dev/null +++ b/app/Actions/Api/CreateApiKey.php @@ -0,0 +1,32 @@ + $permissions The r_* ACL columns, only applied to application keys. + */ + public function create(int $keyType, array $data, array $permissions = []): ApiKey + { + $data = array_merge($data, [ + 'key_type' => $keyType, + 'identifier' => ApiKey::generateTokenIdentifier($keyType), + 'token' => Crypt::encrypt(Str::random(ApiKey::KEY_LENGTH)), + ]); + + if ($keyType === ApiKey::TYPE_APPLICATION) { + $data = array_merge($data, $permissions); + } + + return ApiKey::query()->forceCreate($data)->refresh(); + } +} diff --git a/app/Actions/Backups/CompleteBackup.php b/app/Actions/Backups/CompleteBackup.php new file mode 100644 index 000000000..956d20f07 --- /dev/null +++ b/app/Actions/Backups/CompleteBackup.php @@ -0,0 +1,103 @@ +fill([ + 'is_successful' => $successful, + // A failed backup is unlocked so it can be deleted easily. + 'is_locked' => $successful && $backup->is_locked, + 'checksum' => $successful ? ($data['checksum_type'].':'.$data['checksum']) : null, + 'bytes' => $successful ? $data['size'] : 0, + 'completed_at' => CarbonImmutable::now(), + ])->save(); + + $adapter = $this->backupManager->adapter(); + if ($adapter instanceof S3Filesystem) { + $this->completeMultipartUpload($backup, $adapter, $successful, $data['parts']); + } + + Event::dispatch(new OperationCompleted($backup->server->uuid, 'backup', $successful, $backup->uuid)); + }); + } + + /** + * Marks a multipart upload in a given S3-compatible instance as failed or successful for + * the given backup. + * + * @param list|null $parts + * + * @throws DisplayException + */ + private function completeMultipartUpload(Backup $backup, S3Filesystem $adapter, bool $successful, ?array $parts): void + { + // A failed backup may never have started its upload, so there is nothing to abort. + if (empty($backup->upload_id)) { + if (! $successful) { + return; + } + + throw new DisplayException('Cannot complete backup request: no upload_id present on model.'); + } + + $params = [ + 'Bucket' => $adapter->getBucket(), + 'Key' => sprintf('%s/%s.tar.gz', $backup->server->uuid, $backup->uuid), + 'UploadId' => $backup->upload_id, + ]; + + $client = $adapter->getClient(); + if (! $successful) { + $client->execute($client->getCommand('AbortMultipartUpload', $params)); + + return; + } + + $params['MultipartUpload'] = [ + 'Parts' => [], + ]; + + if (($parts) === null) { + $params['MultipartUpload']['Parts'] = $client->execute($client->getCommand('ListParts', $params))['Parts']; + } else { + foreach ($parts as $part) { + $params['MultipartUpload']['Parts'][] = [ + 'ETag' => $part['etag'], + 'PartNumber' => $part['part_number'], + ]; + } + } + + $client->execute($client->getCommand('CompleteMultipartUpload', $params)); + } +} diff --git a/app/Services/Backups/DeleteBackupService.php b/app/Actions/Backups/DeleteBackup.php similarity index 56% rename from app/Services/Backups/DeleteBackupService.php rename to app/Actions/Backups/DeleteBackup.php index ce7cdfcd2..261f24e82 100644 --- a/app/Services/Backups/DeleteBackupService.php +++ b/app/Actions/Backups/DeleteBackup.php @@ -1,32 +1,34 @@ is_locked && ($backup->is_successful && !is_null($backup->completed_at))) { - throw new BackupLockedException(); - } + throw_if($backup->is_locked && ($backup->is_successful && ($backup->completed_at) !== null), BackupLockedException::class); if ($backup->disk === Backup::ADAPTER_AWS_S3) { $this->deleteFromS3($backup); @@ -44,16 +44,13 @@ class DeleteBackupService return; } - $this->connection->transaction(function () use ($backup) { + DB::transaction(function () use ($backup): void { try { - $this->daemonBackupRepository->setServer($backup->server)->delete($backup); - } catch (DaemonConnectionException $exception) { - $previous = $exception->getPrevious(); + Daemon::server($backup->server)->backups()->delete($backup); + } catch (DaemonConnectionException $daemonConnectionException) { // Don't fail the request if the Daemon responds with a 404, just assume the backup // doesn't actually exist and remove its reference from the Panel as well. - if (!$previous instanceof ClientException || $previous->getResponse()->getStatusCode() !== Response::HTTP_NOT_FOUND) { - throw $exception; - } + throw_if($daemonConnectionException->getStatusCode() !== Response::HTTP_NOT_FOUND, $daemonConnectionException); } $backup->delete(); @@ -63,17 +60,16 @@ class DeleteBackupService /** * Deletes a backup from an S3 disk. * - * @throws \Throwable + * @throws Throwable */ - protected function deleteFromS3(Backup $backup): void + private function deleteFromS3(Backup $backup): void { - $this->connection->transaction(function () use ($backup) { + DB::transaction(function () use ($backup): void { $backup->delete(); - /** @var \Pterodactyl\Extensions\Filesystem\S3Filesystem $adapter */ $adapter = $this->manager->adapter(Backup::ADAPTER_AWS_S3); + throw_unless($adapter instanceof S3Filesystem, LogicException::class, 'The S3 backup adapter is not configured correctly.'); - // @phpstan-ignore-next-line method.notFound $adapter->getClient()->deleteObject([ 'Bucket' => $adapter->getBucket(), 'Key' => sprintf('%s/%s.tar.gz', $backup->server->uuid, $backup->uuid), diff --git a/app/Services/Backups/DownloadLinkService.php b/app/Actions/Backups/GenerateBackupDownloadLink.php similarity index 63% rename from app/Services/Backups/DownloadLinkService.php rename to app/Actions/Backups/GenerateBackupDownloadLink.php index f27d747c3..6f0e90512 100644 --- a/app/Services/Backups/DownloadLinkService.php +++ b/app/Actions/Backups/GenerateBackupDownloadLink.php @@ -1,29 +1,32 @@ disk !== Backup::ADAPTER_AWS_S3 && $backup->disk !== Backup::ADAPTER_WINGS, BadRequestHttpException::class, 'The backup requested references an unknown disk driver type and cannot be downloaded.'); + if ($backup->disk === Backup::ADAPTER_AWS_S3) { return $this->getS3BackupUrl($backup); } @@ -36,7 +39,7 @@ class DownloadLinkService 'server_uuid' => $backup->server->uuid, ]) ->setScopes(JwtScope::BackupDownload) - ->handle($backup->server->node, $user->id . $backup->server->uuid); + ->handle($backup->server->node, $user->id.$backup->server->uuid); return sprintf('%s/download/backup?token=%s', $backup->server->node->getConnectionAddress(), $token->toString()); } @@ -45,10 +48,10 @@ class DownloadLinkService * Returns a signed URL that allows us to download a file directly out of a non-public * S3 bucket by using a signed URL. */ - protected function getS3BackupUrl(Backup $backup): string + private function getS3BackupUrl(Backup $backup): string { - /** @var \Pterodactyl\Extensions\Filesystem\S3Filesystem $adapter */ $adapter = $this->backupManager->adapter(Backup::ADAPTER_AWS_S3); + throw_unless($adapter instanceof S3Filesystem, LogicException::class, 'The S3 backup adapter is not configured correctly.'); $request = $adapter->getClient()->createPresignedRequest( $adapter->getClient()->getCommand('GetObject', [ diff --git a/app/Actions/Backups/InitiateBackup.php b/app/Actions/Backups/InitiateBackup.php new file mode 100644 index 000000000..1b4961955 --- /dev/null +++ b/app/Actions/Backups/InitiateBackup.php @@ -0,0 +1,124 @@ + */ + private array $ignoredFiles = []; + + private bool $isLocked = false; + + public function __construct( + private readonly DeletesBackups $deleteBackup, + private readonly BackupManager $backupManager, + ) {} + + /** + * Set if the backup should be locked once it is created which will prevent + * its deletion by users or automated system processes. + */ + public function setIsLocked(bool $isLocked): InitiatesBackups + { + $this->isLocked = $isLocked; + + return $this; + } + + /** + * Sets the files to be ignored by this backup. + * + * @param list|null $ignored + */ + public function setIgnoredFiles(?array $ignored): InitiatesBackups + { + // Set the ignored files to be any values that are not empty in the array. Don't use + // the PHP empty function here incase anything that is "empty" by default (0, false, etc.) + // were passed as a file or folder name. + $this->ignoredFiles = ($ignored) === null ? [] : array_filter($ignored, fn (string $value): bool => $value !== ''); + + return $this; + } + + /** + * Initiates the backup process for a server on Wings. + * + * @throws Throwable + * @throws TooManyBackupsException + * @throws TooManyRequestsHttpException + */ + public function initiate(Server $server, ?string $name = null, bool $override = false): Backup + { + return DB::transaction(function () use ($server, $name, $override): Backup { + $limit = JsonValueGuard::integer(config('backups.throttles.limit')); + $period = JsonValueGuard::integer(config('backups.throttles.period')); + if ($period > 0) { + $previousCount = $server->backups() + ->withTrashed() + ->nonFailed() + ->where('created_at', '>=', CarbonImmutable::now()->subSeconds($period)) + ->lockForUpdate() + ->count(); + if ($previousCount >= $limit) { + $message = sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period); + $latest = $server->backups() + ->withTrashed() + ->nonFailed() + ->where('created_at', '>=', CarbonImmutable::now()->subSeconds($period)) + ->orderByDesc('created_at') + ->first() ?? throw new UnexpectedValueException('The backup throttle query returned an empty result set.'); + + // SAFETY: HTTP Retry-After uses whole seconds, so truncating Carbon's fractional difference is intentional. + throw new TooManyRequestsHttpException((int) CarbonImmutable::now()->diffInSeconds($latest->created_at->addSeconds($period)), $message); + } + } + + $successful = $server->backups()->nonFailed(); + if (! $server->backup_limit || $successful->lockForUpdate()->count() >= $server->backup_limit) { + // Do not allow the user to continue if this server is already at its limit and can't override. + if (! $override || $server->backup_limit <= 0) { + throw new TooManyBackupsException($server->backup_limit); + } + + // Get the oldest backup the server has that is not "locked" (indicating a backup that should + // never be automatically purged). If we find a backup we will delete it and then continue with + // this process. If no backup is found that can be used an exception is thrown. + $oldest = $successful->where('is_locked', false)->orderBy('created_at')->first(); + if (! $oldest) { + throw new TooManyBackupsException($server->backup_limit); + } + + $this->deleteBackup->delete($oldest); + } + + $backup = $server->backups()->create([ + 'uuid' => Uuid::uuid4()->toString(), + 'name' => mb_trim($name) ?: sprintf('Backup at %s', CarbonImmutable::now()->toDateTimeString()), + 'ignored_files' => array_values($this->ignoredFiles), + 'disk' => $this->backupManager->getDefaultAdapter(), + 'is_locked' => $this->isLocked, + ]); + + Daemon::server($server)->backups()->create($backup); + + return $backup->refresh(); + }); + } +} diff --git a/app/Actions/Backups/PresignBackupUpload.php b/app/Actions/Backups/PresignBackupUpload.php new file mode 100644 index 000000000..ab92e48ab --- /dev/null +++ b/app/Actions/Backups/PresignBackupUpload.php @@ -0,0 +1,86 @@ +backupManager->adapter(); + throw_unless($adapter instanceof S3Filesystem, BadRequestHttpException::class, 'The configured backup adapter is not an S3 compatible adapter.'); + + $client = $adapter->getClient(); + $expires = CarbonImmutable::now()->addMinutes(JsonValueGuard::integer(config('backups.presigned_url_lifespan', 60))); + + $params = [ + 'Bucket' => $adapter->getBucket(), + 'Key' => sprintf('%s/%s.tar.gz', $backup->server->uuid, $backup->uuid), + 'ContentType' => 'application/x-gzip', + ]; + + $storageClass = config('backups.disks.s3.storage_class'); + if (($storageClass) !== null) { + $params['StorageClass'] = $storageClass; + } + + $result = $client->execute($client->getCommand('CreateMultipartUpload', $params)); + + $params['UploadId'] = $result->get('UploadId'); + + $maxPartSize = $this->maxPartSize(); + + $parts = []; + for ($i = 0; $i < ($size / $maxPartSize); $i++) { + $parts[] = $client->createPresignedRequest( + $client->getCommand('UploadPart', array_merge($params, ['PartNumber' => $i + 1])), + $expires + )->getUri()->__toString(); + } + + $backup->update(['upload_id' => $params['UploadId']]); + + return [ + 'parts' => $parts, + 'part_size' => $maxPartSize, + ]; + } + + /** + * The configured maximum size of a single multipart upload part, falling back to + * DEFAULT_MAX_PART_SIZE when the configured value is missing, non-numeric, zero, or negative. + */ + private function maxPartSize(): int + { + $maxPartSize = filter_var( + config('backups.max_part_size', self::DEFAULT_MAX_PART_SIZE), + FILTER_VALIDATE_INT, + ); + if ($maxPartSize === false || $maxPartSize <= 0) { + return self::DEFAULT_MAX_PART_SIZE; + } + + return $maxPartSize; + } +} diff --git a/app/Actions/Backups/RestoreBackup.php b/app/Actions/Backups/RestoreBackup.php new file mode 100644 index 000000000..9d0c408df --- /dev/null +++ b/app/Actions/Backups/RestoreBackup.php @@ -0,0 +1,44 @@ +status) !== null, BadRequestHttpException::class, 'This server is not currently in a state that allows for a backup to be restored.'); + throw_if(! $backup->is_successful || ($backup->completed_at) === null, BadRequestHttpException::class, 'This backup cannot be restored at this time: not completed or failed.'); + + DB::transaction(function () use ($server, $backup, $user, $truncate): void { + $url = $backup->disk === Backup::ADAPTER_AWS_S3 + ? $this->downloadLink->generate($backup, $user) + : null; + + $server->update(['status' => Server::STATUS_RESTORING_BACKUP]); + + Daemon::server($server)->backups()->restore($backup, $url, $truncate); + }); + } +} diff --git a/app/Actions/Backups/RestoreBackupStatus.php b/app/Actions/Backups/RestoreBackupStatus.php new file mode 100644 index 000000000..290e4469e --- /dev/null +++ b/app/Actions/Backups/RestoreBackupStatus.php @@ -0,0 +1,24 @@ +where('uuid', $backupUuid)->firstOrFail(); + + throw_unless($model->server->node->is($node), HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); + + $model->server->update(['status' => null]); + + return $model->refresh(); + } +} diff --git a/app/Actions/Backups/ToggleBackupLock.php b/app/Actions/Backups/ToggleBackupLock.php new file mode 100644 index 000000000..663632d5b --- /dev/null +++ b/app/Actions/Backups/ToggleBackupLock.php @@ -0,0 +1,18 @@ +update(['is_locked' => ! $backup->is_locked]); + + return $backup->refresh(); + } +} diff --git a/app/Actions/Databases/CreateDatabase.php b/app/Actions/Databases/CreateDatabase.php new file mode 100644 index 000000000..04be0c30f --- /dev/null +++ b/app/Actions/Databases/CreateDatabase.php @@ -0,0 +1,108 @@ +validateDatabaseLimit = $validate; + + return $this; + } + + /** @param DatabaseCreationData $data + * @throws Throwable + * @throws TooManyDatabasesException + * @throws DatabaseClientFeatureNotEnabledException + */ + public function create(Server $server, array $data): Database + { + throw_unless(config('pterodactyl.client_features.databases.enabled'), DatabaseClientFeatureNotEnabledException::class); + + if ($this->validateDatabaseLimit) { + throw_if(($server->database_limit) !== null && $server->databases()->count() >= $server->database_limit, TooManyDatabasesException::class); + } + + throw_if(empty($data['database']) || ! preg_match(self::MATCH_NAME_REGEX, $data['database']), InvalidArgumentException::class, 'The database name passed to CreateDatabase::create MUST be prefixed with "s{server_id}_".'); + + $data = [ + ...$data, + 'server_id' => $server->id, + 'username' => sprintf('u%d_%s', $server->id, Str::random(10)), + 'password' => Crypt::encrypt(Utilities::randomStringWithSpecialCharacters(24)), + ]; + + $database = null; + + try { + return DB::transaction(function () use ($data, &$database): Database { + $this->dynamic->set('dynamic', $data['database_host_id']); + $database = $this->createModel($data); + $this->gateway->createDatabase($database->database); + $this->gateway->createUser( + $database->username, + $database->remote, + JsonValueGuard::string(Crypt::decrypt($database->password)), + $database->max_connections + ); + $this->gateway->assignUserToDatabase($database->database, $database->username, $database->remote); + $this->gateway->flush(); + + return $database; + }); + } catch (Throwable $throwable) { + // The model row may have been created before provisioning failed, so clean up any host state that exists. + if ($database instanceof Database) { + rescue(fn (): bool => $this->gateway->dropDatabase($database->database)); + rescue(fn (): bool => $this->gateway->dropUser($database->username, $database->remote)); + rescue(fn (): bool => $this->gateway->flush()); + } + + throw $throwable; + } + } + + /** @param DatabaseModelCreationData $data */ + private function createModel(array $data): Database + { + $exists = Database::query()->where('server_id', $data['server_id']) + ->where('database', $data['database']) + ->exists(); + + throw_if($exists, DuplicateDatabaseNameException::class, 'A database with that name already exists for this server.'); + + $database = (new Database)->forceFill($data); + $database->saveOrFail(); + + return $database; + } +} diff --git a/app/Actions/Databases/CreateDatabaseHost.php b/app/Actions/Databases/CreateDatabaseHost.php new file mode 100644 index 000000000..873fae553 --- /dev/null +++ b/app/Actions/Databases/CreateDatabaseHost.php @@ -0,0 +1,47 @@ +create([ + 'password' => Crypt::encrypt(Arr::get($data, 'password')), + 'name' => JsonValueGuard::string(Arr::get($data, 'name')), + 'host' => JsonValueGuard::string(Arr::get($data, 'host')), + 'port' => JsonValueGuard::integer(Arr::get($data, 'port')), + 'username' => JsonValueGuard::string(Arr::get($data, 'username')), + 'max_databases' => null, + 'node_id' => JsonValueGuard::nullableInteger(Arr::get($data, 'node_id')), + ]); + + // Confirm access using the provided credentials before saving data. + $this->dynamic->set('dynamic', $host); + DB::connection('dynamic')->select('SELECT 1 FROM dual'); + + return $host->refresh(); + }); + } +} diff --git a/app/Actions/Databases/DeleteDatabase.php b/app/Actions/Databases/DeleteDatabase.php new file mode 100644 index 000000000..4717fae67 --- /dev/null +++ b/app/Actions/Databases/DeleteDatabase.php @@ -0,0 +1,31 @@ +dynamic->set('dynamic', $database->relationLoaded('host') ? $database->host : $database->database_host_id); + + $this->gateway->dropDatabase($database->database); + $this->gateway->dropUser($database->username, $database->remote); + $this->gateway->flush(); + + return $database->delete(); + } +} diff --git a/app/Actions/Databases/DeleteDatabaseHost.php b/app/Actions/Databases/DeleteDatabaseHost.php new file mode 100644 index 000000000..2d3b0a087 --- /dev/null +++ b/app/Actions/Databases/DeleteDatabaseHost.php @@ -0,0 +1,26 @@ +databases()->exists()) { + throw new HasActiveServersException(trans('exceptions.databases.delete_has_databases')); + } + + $host->delete(); + } +} diff --git a/app/Actions/Databases/DeployServerDatabase.php b/app/Actions/Databases/DeployServerDatabase.php new file mode 100644 index 000000000..0d0d997ca --- /dev/null +++ b/app/Actions/Databases/DeployServerDatabase.php @@ -0,0 +1,57 @@ +databases()->lockForUpdate()->count() >= $server->database_limit, DisplayException::class, 'Cannot create additional databases on this server: limit has been reached.'); + + $hosts = DatabaseHost::query()->get()->toBase(); + throw_if($hosts->isEmpty(), NoSuitableDatabaseHostException::class); + + $nodeHosts = $hosts->where('node_id', $server->node_id)->toBase(); + throw_if($nodeHosts->isEmpty() && ! config('pterodactyl.client_features.databases.allow_random'), NoSuitableDatabaseHostException::class); + + $hostId = $data['database_host_id'] ?? null; + + return $this->createDatabase->create($server, [ + 'database_host_id' => $hostId + ? (int) $hostId + : ($nodeHosts->isEmpty() ? $hosts->random()->id : $nodeHosts->random()->id), + 'database' => DatabaseName::generateUnique($data['database'], $server->id), + 'remote' => $data['remote'], + 'max_connections' => $data['max_connections'] ?? null, + ]); + }); + } +} diff --git a/app/Actions/Databases/RotateDatabasePassword.php b/app/Actions/Databases/RotateDatabasePassword.php new file mode 100644 index 000000000..0403f035f --- /dev/null +++ b/app/Actions/Databases/RotateDatabasePassword.php @@ -0,0 +1,41 @@ +newQuery()->whereKey($database->getKey())->lockForUpdate()->firstOrFail(); + $database->update(['password' => Crypt::encrypt($password)]); + + $this->dynamic->set('dynamic', $database->database_host_id); + $this->gateway->dropUser($database->username, $database->remote); + $this->gateway->createUser($database->username, $database->remote, $password, $database->max_connections); + $this->gateway->assignUserToDatabase($database->database, $database->username, $database->remote); + $this->gateway->flush(); + }); + + return $password; + } +} diff --git a/app/Actions/Databases/UpdateDatabaseHost.php b/app/Actions/Databases/UpdateDatabaseHost.php new file mode 100644 index 000000000..d4f72440c --- /dev/null +++ b/app/Actions/Databases/UpdateDatabaseHost.php @@ -0,0 +1,42 @@ +update($data); + $this->dynamic->set('dynamic', $host); + DB::connection('dynamic')->select('SELECT 1 FROM dual'); + + return $host; + }); + } +} diff --git a/app/Actions/Eggs/CreateEgg.php b/app/Actions/Eggs/CreateEgg.php new file mode 100644 index 000000000..f128dff86 --- /dev/null +++ b/app/Actions/Eggs/CreateEgg.php @@ -0,0 +1,28 @@ +forceCreate([ + ...$data, + 'author' => JsonValueGuard::string(Config::get('pterodactyl.service.author')), + ]); + + return $egg->refresh(); + } +} diff --git a/app/Actions/Eggs/DeleteEgg.php b/app/Actions/Eggs/DeleteEgg.php new file mode 100644 index 000000000..fff16ab95 --- /dev/null +++ b/app/Actions/Eggs/DeleteEgg.php @@ -0,0 +1,33 @@ +servers()->exists()) { + throw new HasActiveServersException(trans('exceptions.egg.delete_has_servers')); + } + + if ($egg->configuredChildren()->exists()) { + throw new HasChildrenException(trans('exceptions.egg.has_children')); + } + + $egg->delete(); + } +} diff --git a/app/Actions/Eggs/Scripts/UpdateInstallScript.php b/app/Actions/Eggs/Scripts/UpdateInstallScript.php new file mode 100644 index 000000000..ac5e22dca --- /dev/null +++ b/app/Actions/Eggs/Scripts/UpdateInstallScript.php @@ -0,0 +1,37 @@ +scriptSources()->whereKey($copyFrom)->exists()) { + throw new InvalidCopyFromException(trans('exceptions.egg.invalid_copy_id')); + } + + $egg->update([ + 'script_install' => JsonValueGuard::nullableString(Arr::get($data, 'script_install')), + 'script_is_privileged' => JsonValueGuard::boolean(Arr::get($data, 'script_is_privileged', true)), + 'script_entry' => JsonValueGuard::string(Arr::get($data, 'script_entry')), + 'script_container' => JsonValueGuard::string(Arr::get($data, 'script_container')), + 'copy_script_from' => $copyFrom, + ]); + } +} diff --git a/app/Services/Eggs/Sharing/EggExporterService.php b/app/Actions/Eggs/Sharing/ExportEgg.php similarity index 55% rename from app/Services/Eggs/Sharing/EggExporterService.php rename to app/Actions/Eggs/Sharing/ExportEgg.php index 706297b3d..ca46a9819 100644 --- a/app/Services/Eggs/Sharing/EggExporterService.php +++ b/app/Actions/Eggs/Sharing/ExportEgg.php @@ -1,30 +1,38 @@ repository->getWithExportAttributes($egg); + $egg->loadMissing('scriptFrom', 'configFrom', 'variables'); + + $variables = []; + foreach ($egg->variables as $item) { + $variables[] = [ + 'name' => $item->name, + 'description' => $item->description, + 'env_variable' => $item->env_variable, + 'default_value' => $item->default_value, + 'user_viewable' => $item->user_viewable, + 'user_editable' => $item->user_editable, + 'rules' => $item->rules, + 'field_type' => 'text', + ]; + } $struct = [ '_comment' => 'DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO', @@ -32,15 +40,13 @@ class EggExporterService 'version' => Egg::EXPORT_VERSION, 'update_url' => $egg->update_url, ], - 'exported_at' => Carbon::now()->toAtomString(), + 'exported_at' => now()->toAtomString(), 'name' => $egg->name, 'author' => $egg->author, 'description' => $egg->description, 'features' => $egg->features, 'docker_images' => $egg->docker_images, - 'file_denylist' => Collection::make($egg->inherit_file_denylist)->filter(function ($value) { - return !empty($value); - }), + 'file_denylist' => Collection::make($egg->inherit_file_denylist)->filter(fn (string $value): bool => $value !== ''), 'startup' => $egg->startup, 'config' => [ 'files' => $egg->inherit_config_files, @@ -55,14 +61,9 @@ class EggExporterService 'entrypoint' => $egg->copy_script_entry, ], ], - 'variables' => $egg->variables->transform(function (EggVariable $item) { - return Collection::make($item->toArray()) - ->except(['id', 'egg_id', 'created_at', 'updated_at']) - ->merge(['field_type' => 'text']) - ->toArray(); - }), + 'variables' => $variables, ]; - return json_encode($struct, JSON_PRETTY_PRINT); + return json_encode($struct, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); } } diff --git a/app/Actions/Eggs/Sharing/ImportCatalogEgg.php b/app/Actions/Eggs/Sharing/ImportCatalogEgg.php new file mode 100644 index 000000000..e1d263c77 --- /dev/null +++ b/app/Actions/Eggs/Sharing/ImportCatalogEgg.php @@ -0,0 +1,41 @@ +catalog->all() as $entry) { + if ($entry->id !== $id) { + continue; + } + + $contents = $this->catalog->download($entry); + try { + $parsed = EggImportData::fromJson($contents); + } catch (JsonException|UnexpectedValueException|InvalidFileUploadException $exception) { + throw new HttpException(502, 'The selected catalog egg contains an invalid definition.', $exception); + } + + return $this->importer->importParsed($parsed); + } + + throw new NotFoundHttpException('The selected egg is no longer in the Pterodactyl catalog. Refresh the catalog and try again.'); + } +} diff --git a/app/Actions/Eggs/Sharing/ImportEgg.php b/app/Actions/Eggs/Sharing/ImportEgg.php new file mode 100644 index 000000000..3f49c8663 --- /dev/null +++ b/app/Actions/Eggs/Sharing/ImportEgg.php @@ -0,0 +1,45 @@ +importParsed($this->parser->handle($file)); + } + + public function importParsed(EggImportData $parsed): Egg + { + return DB::transaction(function () use ($parsed): Egg { + $egg = (new Egg)->forceFill([ + 'uuid' => Uuid::uuid4()->toString(), + 'author' => $parsed->author, + 'copy_script_from' => null, + ]); + $egg = $this->parser->fillFromParsed($egg, $parsed); + $egg->save(); + foreach ($parsed->variables as $variable) { + EggVariable::query()->forceCreate($variable->attributesForEgg($egg->id)); + } + + return $egg; + }); + } +} diff --git a/app/Actions/Eggs/Sharing/UpdateEggFromImport.php b/app/Actions/Eggs/Sharing/UpdateEggFromImport.php new file mode 100644 index 000000000..06e8aa890 --- /dev/null +++ b/app/Actions/Eggs/Sharing/UpdateEggFromImport.php @@ -0,0 +1,44 @@ +parser->handle($file); + + return DB::transaction(function () use ($egg, $parsed): Egg { + $egg = $this->parser->fillFromParsed($egg, $parsed); + $egg->save(); + + foreach ($parsed->variables as $variable) { + EggVariable::unguarded(function () use ($egg, $variable): void { + $egg->variables()->updateOrCreate([ + 'env_variable' => $variable->environmentVariable, + ], $variable->attributes()); + }); + } + + $imported = array_map(fn (EggImportVariable $variable): string => $variable->environmentVariable, $parsed->variables); + $egg->variables()->whereNotIn('env_variable', $imported)->delete(); + + return $egg->refresh(); + }); + } +} diff --git a/app/Actions/Eggs/UpdateEgg.php b/app/Actions/Eggs/UpdateEgg.php new file mode 100644 index 000000000..742a90f41 --- /dev/null +++ b/app/Actions/Eggs/UpdateEgg.php @@ -0,0 +1,25 @@ +update($data); + } +} diff --git a/app/Actions/Eggs/Variables/CreateEggVariable.php b/app/Actions/Eggs/Variables/CreateEggVariable.php new file mode 100644 index 000000000..9ac496dda --- /dev/null +++ b/app/Actions/Eggs/Variables/CreateEggVariable.php @@ -0,0 +1,24 @@ +variables()->create($data); + + return $variable->refresh(); + } +} diff --git a/app/Actions/Eggs/Variables/ReorderEggVariables.php b/app/Actions/Eggs/Variables/ReorderEggVariables.php new file mode 100644 index 000000000..cc8449f1c --- /dev/null +++ b/app/Actions/Eggs/Variables/ReorderEggVariables.php @@ -0,0 +1,23 @@ + $order */ + public function reorder(Egg $egg, array $order): void + { + DB::transaction(function () use ($egg, $order): void { + $egg = Egg::query()->lockForUpdate()->findOrFail($egg->id); + foreach ($order as $index => $variableId) { + $egg->variables()->whereKey($variableId)->update(['sort_order' => $index]); + } + }); + } +} diff --git a/app/Actions/Eggs/Variables/UpdateEggVariable.php b/app/Actions/Eggs/Variables/UpdateEggVariable.php new file mode 100644 index 000000000..794860261 --- /dev/null +++ b/app/Actions/Eggs/Variables/UpdateEggVariable.php @@ -0,0 +1,21 @@ +update($data); + } +} diff --git a/app/Actions/Extensions/InstallExtension.php b/app/Actions/Extensions/InstallExtension.php new file mode 100644 index 000000000..5019b81b1 --- /dev/null +++ b/app/Actions/Extensions/InstallExtension.php @@ -0,0 +1,109 @@ +packages->using($source, fn (string $directory): ExtensionManifest => $this->installFromDirectory($directory, $source, $enable)); + } + + private function installFromDirectory(string $directory, string $source, bool $enable): ExtensionManifest + { + $manifest = $this->validator->fromDirectory($directory); + + return $this->lock->run($manifest->id, fn (): ExtensionManifest => $this->installPackage($manifest, $source, $enable)); + } + + private function installPackage(ExtensionManifest $manifest, string $source, bool $enable): ExtensionManifest + { + $previous = Extension::query()->where('identifier', $manifest->id)->first(); + $activate = $enable || ($previous->enabled ?? false); + $this->checkCompatibility($manifest, $activate); + $this->assets->stage($manifest); + Event::dispatch(new ExtensionInstalling($manifest, $source)); + + try { + $installed = $this->files->replace( + $manifest, + $this->extensions->directory().DIRECTORY_SEPARATOR.$manifest->id, + fn (string $directory): ExtensionManifest => $this->registerPackage($directory, $activate), + ); + } finally { + $this->extensions->flushDiscovery(); + } + + DB::afterCommit(function () use ($installed, $activate): void { + if (! $activate) { + rescue(fn () => $this->runtime->refresh()); + } + + rescue(fn () => Event::dispatch(new ExtensionInstalled($installed))); + }); + + return $installed; + } + + private function checkCompatibility(ExtensionManifest $manifest, bool $activate): void + { + if ($activate) { + $this->compatibility->assertCompatible($manifest, $this->extensions->configuredEnabled()); + + return; + } + + $this->compatibility->assertRuntimeCompatible($manifest); + } + + private function registerPackage(string $directory, bool $activate): ExtensionManifest + { + $manifest = $this->validator->fromDirectory($directory); + + if ($activate) { + $this->state->setEnabled($manifest->id, true, $manifest); + + return $manifest; + } + + $this->assets->publishWith($manifest, function () use ($manifest): void { + DB::transaction(fn (): Extension => Extension::query()->updateOrCreate( + ['identifier' => $manifest->id], + ['version' => $manifest->version, 'error' => null], + )); + }); + + return $manifest; + } +} diff --git a/app/Actions/Extensions/RemoveExtension.php b/app/Actions/Extensions/RemoveExtension.php new file mode 100644 index 000000000..d8beca672 --- /dev/null +++ b/app/Actions/Extensions/RemoveExtension.php @@ -0,0 +1,62 @@ +lock->run($identifier, fn () => $this->removePackage($identifier)); + } + + private function removePackage(string $identifier): void + { + $manifest = $this->extensions->discovered()->get($identifier); + throw_if($manifest === null, InvalidExtensionException::class, "Extension \"{$identifier}\" is not installed."); + $this->compatibility->assertCanDisable($identifier, $this->extensions->enabled()); + Event::dispatch(new ExtensionRemoving($manifest)); + $this->files->run([ + $this->extensions->directory().DIRECTORY_SEPARATOR.$identifier => null, + $this->assets->publishedPath($identifier) => null, + ], static function () use ($identifier): void { + DB::transaction(static function () use ($identifier): void { + Extension::query()->where('identifier', $identifier)->delete(); + }); + }); + $this->extensions->flushDiscovery(); + DB::afterCommit(function () use ($identifier): void { + rescue(fn () => $this->settingFiles->purge($identifier)); + rescue(fn () => $this->runtime->refresh()); + rescue(fn () => Event::dispatch(new ExtensionRemoved($identifier))); + }); + } +} diff --git a/app/Actions/Extensions/ReplaceExtensionSettingFile.php b/app/Actions/Extensions/ReplaceExtensionSettingFile.php new file mode 100644 index 000000000..cb2523ad8 --- /dev/null +++ b/app/Actions/Extensions/ReplaceExtensionSettingFile.php @@ -0,0 +1,47 @@ + + */ + public function replace(ExtensionSettingsDefinition $definition, string $input, ?UploadedFile $upload): array + { + $field = $definition->fileField($input); + throw_unless($field instanceof ExtensionSettingDefinition, ValidationException::withMessages(['file' => sprintf('Setting "%s" does not accept a file.', $input)])); + + $extension = $definition->extension(); + $constraints = $field->fileConstraints(); + $name = $upload instanceof UploadedFile ? $this->files->store($extension, $upload, $constraints['mimes'], $constraints['max_kilobytes']) : null; + + try { + $previous = $definition->replaceFile($input, $name); + } catch (Throwable $throwable) { + if ($name !== null) { + rescue(fn () => $this->files->delete($extension, $name)); + } + + throw $throwable; + } + + if ($previous !== null) { + rescue(fn () => $this->files->delete($extension, $previous)); + } + + return $definition->schema(); + } +} diff --git a/app/Actions/Extensions/SetExtensionEnabled.php b/app/Actions/Extensions/SetExtensionEnabled.php new file mode 100644 index 000000000..46ef6882f --- /dev/null +++ b/app/Actions/Extensions/SetExtensionEnabled.php @@ -0,0 +1,98 @@ +lock->run($identifier, fn () => $this->changeState($identifier, $enabled, $manifest)); + } + + private function changeState(string $identifier, bool $enabled, ?ExtensionManifest $manifest): void + { + $manifest ??= $this->extensions->discovered()->get($identifier); + throw_if($manifest === null, InvalidExtensionException::class, "Extension \"{$identifier}\" is not installed."); + $this->checkStateChange($manifest, $enabled); + Event::dispatch($enabled ? new ExtensionEnabling($manifest) : new ExtensionDisabling($manifest)); + + if ($enabled) { + $this->activate($manifest); + } else { + $this->persist($manifest, false); + } + + $this->extensions->flushDiscovery(); + DB::afterCommit(function () use ($manifest, $enabled): void { + rescue(fn () => $this->runtime->refresh()); + rescue(fn () => Event::dispatch($enabled ? new ExtensionEnabled($manifest) : new ExtensionDisabled($manifest))); + }); + } + + private function checkStateChange(ExtensionManifest $manifest, bool $enabled): void + { + if (! $enabled) { + $this->compatibility->assertCanDisable($manifest->id, $this->extensions->enabled()); + + return; + } + + $this->compatibility->assertCompatible($manifest, $this->extensions->configuredEnabled()); + throw_if($reason = $this->assets->unusableBuildReason($manifest), InvalidExtensionException::class, $reason); + } + + private function activate(ExtensionManifest $manifest): void + { + $this->runMigrations($manifest); + $this->assets->publishWith($manifest, fn () => $this->persist($manifest, true)); + } + + private function persist(ExtensionManifest $manifest, bool $enabled): void + { + DB::transaction(fn (): Extension => Extension::query()->updateOrCreate( + ['identifier' => $manifest->id], + ['version' => $manifest->version, 'enabled' => $enabled, 'error' => null], + )); + } + + private function runMigrations(ExtensionManifest $manifest): void + { + $migrations = $manifest->path('database', 'migrations'); + if (! is_dir($migrations)) { + return; + } + + $this->migrator->path($migrations); + $exitCode = Artisan::call('migrate', ['--force' => true, '--path' => $migrations, '--realpath' => true]); + throw_if($exitCode !== 0, InvalidExtensionException::class, "Extension \"{$manifest->id}\" migrations failed. Completed database changes may require manual recovery."); + } +} diff --git a/app/Actions/Extensions/UpdateExtensionSettings.php b/app/Actions/Extensions/UpdateExtensionSettings.php new file mode 100644 index 000000000..4a9a8e021 --- /dev/null +++ b/app/Actions/Extensions/UpdateExtensionSettings.php @@ -0,0 +1,22 @@ + + */ + public function update(ExtensionSettingsDefinition $definition, array $settings): array + { + $definition->update($settings); + + return $definition->schema(); + } +} diff --git a/app/Actions/Files/ChangeFilePermissions.php b/app/Actions/Files/ChangeFilePermissions.php new file mode 100644 index 000000000..9f7546ef9 --- /dev/null +++ b/app/Actions/Files/ChangeFilePermissions.php @@ -0,0 +1,18 @@ + $files */ + public function change(Server $server, ?string $root, array $files): void + { + Daemon::server($server)->files()->chmodFiles($root, $files); + } +} diff --git a/app/Actions/Files/CompressFiles.php b/app/Actions/Files/CompressFiles.php new file mode 100644 index 000000000..5cd1b4131 --- /dev/null +++ b/app/Actions/Files/CompressFiles.php @@ -0,0 +1,21 @@ + $files + * @return DaemonFileObject + */ + public function compress(Server $server, ?string $root, array $files): array + { + return Daemon::server($server)->files()->compressFiles($root, $files); + } +} diff --git a/app/Actions/Files/CopyFile.php b/app/Actions/Files/CopyFile.php new file mode 100644 index 000000000..a6dff4cbb --- /dev/null +++ b/app/Actions/Files/CopyFile.php @@ -0,0 +1,17 @@ +files()->copyFile($location); + } +} diff --git a/app/Actions/Files/CreateDirectory.php b/app/Actions/Files/CreateDirectory.php new file mode 100644 index 000000000..80751fbf0 --- /dev/null +++ b/app/Actions/Files/CreateDirectory.php @@ -0,0 +1,17 @@ +files()->createDirectory($name, $root); + } +} diff --git a/app/Actions/Files/DecompressFile.php b/app/Actions/Files/DecompressFile.php new file mode 100644 index 000000000..a3a863818 --- /dev/null +++ b/app/Actions/Files/DecompressFile.php @@ -0,0 +1,18 @@ +files()->decompressFile($root, $file); + } +} diff --git a/app/Actions/Files/DeleteFiles.php b/app/Actions/Files/DeleteFiles.php new file mode 100644 index 000000000..5f76e4801 --- /dev/null +++ b/app/Actions/Files/DeleteFiles.php @@ -0,0 +1,18 @@ + $files */ + public function delete(Server $server, ?string $root, array $files): void + { + Daemon::server($server)->files()->deleteFiles($root, $files); + } +} diff --git a/app/Actions/Files/ListDirectory.php b/app/Actions/Files/ListDirectory.php new file mode 100644 index 000000000..dd3d95d31 --- /dev/null +++ b/app/Actions/Files/ListDirectory.php @@ -0,0 +1,17 @@ +files()->getDirectory($directory); + } +} diff --git a/app/Actions/Files/PullFile.php b/app/Actions/Files/PullFile.php new file mode 100644 index 000000000..92a692e83 --- /dev/null +++ b/app/Actions/Files/PullFile.php @@ -0,0 +1,18 @@ + $options */ + public function pull(Server $server, string $url, ?string $directory, array $options): void + { + Daemon::server($server)->files()->pull($url, $directory, $options); + } +} diff --git a/app/Actions/Files/ReadFileContents.php b/app/Actions/Files/ReadFileContents.php new file mode 100644 index 000000000..6d884763c --- /dev/null +++ b/app/Actions/Files/ReadFileContents.php @@ -0,0 +1,21 @@ +files()->getContent( + $path, + $maxBytes ?? JsonValueGuard::nullableInteger(config('pterodactyl.files.max_edit_size')) + ); + } +} diff --git a/app/Actions/Files/RenameFiles.php b/app/Actions/Files/RenameFiles.php new file mode 100644 index 000000000..33d1b87da --- /dev/null +++ b/app/Actions/Files/RenameFiles.php @@ -0,0 +1,18 @@ + $files */ + public function rename(Server $server, ?string $root, array $files): void + { + Daemon::server($server)->files()->renameFiles($root, $files); + } +} diff --git a/app/Actions/Files/WriteFileContents.php b/app/Actions/Files/WriteFileContents.php new file mode 100644 index 000000000..91e267c0f --- /dev/null +++ b/app/Actions/Files/WriteFileContents.php @@ -0,0 +1,17 @@ +files()->putContent($path, $contents); + } +} diff --git a/app/Actions/Locations/CreateLocation.php b/app/Actions/Locations/CreateLocation.php new file mode 100644 index 000000000..8e69a6fc4 --- /dev/null +++ b/app/Actions/Locations/CreateLocation.php @@ -0,0 +1,21 @@ +create($data); + } +} diff --git a/app/Actions/Locations/DeleteLocation.php b/app/Actions/Locations/DeleteLocation.php new file mode 100644 index 000000000..6f7d1eea6 --- /dev/null +++ b/app/Actions/Locations/DeleteLocation.php @@ -0,0 +1,26 @@ +nodes()->exists()) { + throw new HasActiveNodesException(trans('exceptions.locations.has_nodes')); + } + + $location->delete(); + } +} diff --git a/app/Actions/Locations/UpdateLocation.php b/app/Actions/Locations/UpdateLocation.php new file mode 100644 index 000000000..6a617deaa --- /dev/null +++ b/app/Actions/Locations/UpdateLocation.php @@ -0,0 +1,23 @@ +update($data); + + return $location; + } +} diff --git a/app/Actions/Nodes/CreateNode.php b/app/Actions/Nodes/CreateNode.php new file mode 100644 index 000000000..2dbf5e26f --- /dev/null +++ b/app/Actions/Nodes/CreateNode.php @@ -0,0 +1,29 @@ +forceCreate([ + ...$data, + 'daemon_token' => Crypt::encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)), + 'daemon_token_id' => Str::random(Node::DAEMON_TOKEN_ID_LENGTH), + ]); + + return $node->refresh(); + } +} diff --git a/app/Actions/Nodes/DeleteNode.php b/app/Actions/Nodes/DeleteNode.php new file mode 100644 index 000000000..3f28aa79f --- /dev/null +++ b/app/Actions/Nodes/DeleteNode.php @@ -0,0 +1,26 @@ +servers()->exists()) { + throw new HasActiveServersException(trans('exceptions.node.servers_attached')); + } + + $node->delete(); + } +} diff --git a/app/Actions/Nodes/ResetServerStates.php b/app/Actions/Nodes/ResetServerStates.php new file mode 100644 index 000000000..c32b19ec5 --- /dev/null +++ b/app/Actions/Nodes/ResetServerStates.php @@ -0,0 +1,55 @@ +with([ + 'activity' => function (Relation $relation): void { + $relation->getQuery() + ->with('subjects.subject') + ->where('activity_logs.event', 'server:backup.restore') + ->latest('timestamp'); + }, + ]) + ->where('node_id', $node->id) + ->where('status', Server::STATUS_RESTORING_BACKUP) + ->get(); + + DB::transaction(function () use ($node, $servers): void { + foreach ($servers as $server) { + $subject = $server->activity->first()?->subjects->where('subject_type', 'backup')->first(); + if ($subject !== null && $subject->subject instanceof Backup) { + Activity::event('server:backup.restore-failed') + ->subject($server, $subject->subject) + ->property('name', $subject->subject->name) + ->log(); + } + } + + Server::query()->where('node_id', $node->id) + ->whereIn('status', [Server::STATUS_INSTALLING, Server::STATUS_RESTORING_BACKUP]) + ->update(['status' => null]); + }); + } +} diff --git a/app/Actions/Nodes/UpdateNode.php b/app/Actions/Nodes/UpdateNode.php new file mode 100644 index 000000000..d5b2327bf --- /dev/null +++ b/app/Actions/Nodes/UpdateNode.php @@ -0,0 +1,73 @@ +forceFill($data)->save(); + $updated = $node->refresh(); + + try { + $daemon->fqdn = $updated->fqdn; + + Daemon::node($daemon)->update($updated); + } catch (DaemonConnectionException $daemonConnectionException) { + Log::warning($daemonConnectionException->getMessage(), ['exception' => $daemonConnectionException, 'node_id' => $node->id]); + + // Never actually throw these exceptions up the stack. If we were able to change the settings + // but something went wrong with Wings we just want to store the update and let the user manually + // make changes as needed. + // + // This avoids issues with proxies such as Cloudflare which will see Wings as offline and then + // inject their own response pages, causing this logic to get fucked up. + // + // @see https://github.com/pterodactyl/panel/issues/2712 + return [$updated, true]; + } + + return [$updated, false]; + }); + + if ($exception) { + throw new ConfigurationNotPersistedException(trans('exceptions.node.daemon_off_config_updated')); + } + + return $updated; + } +} diff --git a/app/Actions/Schedules/CreateSchedule.php b/app/Actions/Schedules/CreateSchedule.php new file mode 100644 index 000000000..df94a3ab6 --- /dev/null +++ b/app/Actions/Schedules/CreateSchedule.php @@ -0,0 +1,51 @@ +schedules()->create([ + 'name' => JsonValueGuard::string(Arr::get($data, 'name')), + 'cron_day_of_week' => $dayOfWeek, + 'cron_month' => $month, + 'cron_day_of_month' => $dayOfMonth, + 'cron_hour' => $hour, + 'cron_minute' => $minute, + 'is_active' => JsonValueGuard::boolean(Arr::get($data, 'is_active')), + 'only_when_online' => JsonValueGuard::boolean(Arr::get($data, 'only_when_online')), + 'next_run_at' => $nextRunAt, + ]); + + return $schedule->refresh(); + } +} diff --git a/app/Actions/Schedules/CreateScheduleTask.php b/app/Actions/Schedules/CreateScheduleTask.php new file mode 100644 index 000000000..db368ab62 --- /dev/null +++ b/app/Actions/Schedules/CreateScheduleTask.php @@ -0,0 +1,53 @@ +newQuery()->whereKey($schedule->getKey())->lockForUpdate()->firstOrFail(); + $limit = JsonValueGuard::integer(config('pterodactyl.client_features.schedules.per_schedule_task_limit', 10)); + throw_if($schedule->tasks()->count() >= $limit, ServiceLimitExceededException::class, "Schedules may not have more than $limit tasks associated with them. Creating this task would put this schedule over the limit."); + + $next = ($schedule->tasks()->orderByDesc('sequence_id')->first()->sequence_id ?? 0) + 1; + $requested = max(1, $data['sequence_id'] ?? $next); + + $sequenceId = $next; + if ($requested < $next) { + $schedule->tasks() + ->where('sequence_id', '>=', $requested) + ->increment('sequence_id'); + $sequenceId = $requested; + } + + return $schedule->tasks()->create([ + 'sequence_id' => $sequenceId, + 'action' => $data['action'], + 'payload' => $data['payload'], + 'time_offset' => $data['time_offset'], + 'continue_on_failure' => $data['continue_on_failure'], + ])->refresh(); + }); + } +} diff --git a/app/Actions/Schedules/DeleteSchedule.php b/app/Actions/Schedules/DeleteSchedule.php new file mode 100644 index 000000000..281b92d01 --- /dev/null +++ b/app/Actions/Schedules/DeleteSchedule.php @@ -0,0 +1,16 @@ +delete(); + } +} diff --git a/app/Actions/Schedules/DeleteScheduleTask.php b/app/Actions/Schedules/DeleteScheduleTask.php new file mode 100644 index 000000000..d37bb27da --- /dev/null +++ b/app/Actions/Schedules/DeleteScheduleTask.php @@ -0,0 +1,33 @@ +newQuery()->whereKey($schedule->getKey())->lockForUpdate()->firstOrFail(); + $task = $schedule->tasks()->whereKey($task->getKey())->firstOrFail(); + + $schedule->tasks() + ->where('sequence_id', '>', $task->sequence_id) + ->decrement('sequence_id'); + + $task->delete(); + }); + } +} diff --git a/app/Actions/Schedules/ProcessSchedule.php b/app/Actions/Schedules/ProcessSchedule.php new file mode 100644 index 000000000..320b5e84b --- /dev/null +++ b/app/Actions/Schedules/ProcessSchedule.php @@ -0,0 +1,109 @@ +claim($schedule, $now); + $job = $run['job']; + + try { + if (! $this->canRun($job)) { + $job->failed(); + + return; + } + + if ($now) { + Bus::dispatchNow($job); + + return; + } + } catch (Throwable $throwable) { + rescue(fn () => $job->failed($throwable)); + + throw $throwable; + } + + DB::afterCommit(fn () => $this->publish($run)); + } + + private function canRun(RunTaskJob $job): bool + { + if (! $job->task->schedule->only_when_online) { + return true; + } + + try { + $details = Daemon::server($job->task->schedule->server)->details(); + + return ! in_array($details['state'] ?? 'offline', ['offline', 'stopping'], true); + } catch (DaemonConnectionException) { + return false; + } + } + + /** @param array{job: RunTaskJob, next_run_at: CarbonInterface|null, last_run_at: CarbonInterface|null} $run */ + private function publish(array $run): void + { + try { + Bus::dispatch($run['job']->delay($run['job']->task->time_offset)); + } catch (Throwable $throwable) { + rescue(fn () => $this->release($run)); + + throw $throwable; + } + } + + /** @return array{job: RunTaskJob, next_run_at: CarbonInterface|null, last_run_at: CarbonInterface|null} */ + private function claim(Schedule $schedule, bool $now): array + { + return DB::transaction(function () use ($schedule, $now): array { + $claimed = Schedule::query()->without('tasks')->lockForUpdate()->findOrFail($schedule->id); + throw_if($claimed->is_processing, DisplayException::class, 'This schedule is already being processed.'); + + $task = $claimed->tasks()->orderBy('sequence_id')->first(); + throw_if($task === null, DisplayException::class, 'Cannot process schedule for task execution: no tasks are registered.'); + + $run = ['job' => new RunTaskJob($task->setRelation('schedule', $claimed), $now), 'next_run_at' => $claimed->next_run_at, 'last_run_at' => $claimed->last_run_at]; + $claimed->forceFill(['is_processing' => true, 'next_run_at' => $claimed->getNextRunDate()])->saveOrFail(); + $task->update(['is_queued' => true]); + + return $run; + }); + } + + /** @param array{job: RunTaskJob, next_run_at: CarbonInterface|null, last_run_at: CarbonInterface|null} $run */ + private function release(array $run): void + { + DB::transaction(function () use ($run): void { + $schedule = Schedule::query()->without('tasks')->lockForUpdate()->findOrFail($run['job']->task->schedule_id); + $run['job']->task->update(['is_queued' => false]); + $schedule->forceFill([ + 'is_processing' => false, + 'next_run_at' => $run['next_run_at'], + 'last_run_at' => $run['last_run_at'], + ])->saveOrFail(); + }); + } +} diff --git a/app/Actions/Schedules/UpdateSchedule.php b/app/Actions/Schedules/UpdateSchedule.php new file mode 100644 index 000000000..a6c101b68 --- /dev/null +++ b/app/Actions/Schedules/UpdateSchedule.php @@ -0,0 +1,58 @@ + JsonValueGuard::string(Arr::get($data, 'name')), + 'cron_day_of_week' => $dayOfWeek, + 'cron_month' => $month, + 'cron_day_of_month' => $dayOfMonth, + 'cron_hour' => $hour, + 'cron_minute' => $minute, + 'is_active' => $active, + 'only_when_online' => JsonValueGuard::boolean(Arr::get($data, 'only_when_online')), + 'next_run_at' => $nextRunAt, + ]; + + if ($schedule->is_active !== $active) { + $attributes['is_processing'] = false; + } + + $schedule->update($attributes); + + return $schedule->refresh(); + } +} diff --git a/app/Actions/Schedules/UpdateScheduleTask.php b/app/Actions/Schedules/UpdateScheduleTask.php new file mode 100644 index 000000000..575019517 --- /dev/null +++ b/app/Actions/Schedules/UpdateScheduleTask.php @@ -0,0 +1,54 @@ +newQuery()->whereKey($schedule->getKey())->lockForUpdate()->firstOrFail(); + $task = $schedule->tasks()->whereKey($task->getKey())->firstOrFail(); + + $sequenceId = max(1, $data['sequence_id'] ?? $task->sequence_id); + + if ($sequenceId < $task->sequence_id) { + $schedule->tasks() + ->where('sequence_id', '>=', $sequenceId) + ->where('sequence_id', '<', $task->sequence_id) + ->increment('sequence_id'); + } elseif ($sequenceId > $task->sequence_id) { + $schedule->tasks() + ->where('sequence_id', '>', $task->sequence_id) + ->where('sequence_id', '<=', $sequenceId) + ->decrement('sequence_id'); + } + + $task->update([ + 'sequence_id' => $sequenceId, + 'action' => $data['action'], + 'payload' => $data['payload'], + 'time_offset' => $data['time_offset'], + 'continue_on_failure' => $data['continue_on_failure'], + ]); + + return $task->refresh(); + }); + } +} diff --git a/app/Actions/Servers/AttachMountToServer.php b/app/Actions/Servers/AttachMountToServer.php new file mode 100644 index 000000000..6fd3a36f8 --- /dev/null +++ b/app/Actions/Servers/AttachMountToServer.php @@ -0,0 +1,26 @@ +availableToServer($server)->whereKey($mountId)->first(); + if ($mount === null) { + throw (new ModelNotFoundException)->setModel(Mount::class); + } + + (new MountServer)->forceFill(['mount_id' => $mount->id, 'server_id' => $server->id])->saveOrFail(); + + return $mount->refresh(); + } +} diff --git a/app/Actions/Servers/ChangeServerEgg.php b/app/Actions/Servers/ChangeServerEgg.php new file mode 100644 index 000000000..4dcb2acfc --- /dev/null +++ b/app/Actions/Servers/ChangeServerEgg.php @@ -0,0 +1,69 @@ +storedValues($server) : []; + + // Stored values point at the previous egg's variables, which the + // server can no longer see once it has moved. + ServerVariable::query()->where('server_id', $server->id)->delete(); + + foreach ($egg->variables()->get() as $variable) { + $value = $carried[$variable->env_variable] ?? null; + if ($value === null || Validator::make(['value' => $value], ['value' => $variable->rules])->fails()) { + continue; + } + + ServerVariable::query()->create([ + 'server_id' => $server->id, + 'variable_id' => $variable->id, + 'variable_value' => $value, + ]); + } + + $server->forceFill([ + 'egg_id' => $egg->id, + 'startup' => $egg->startup ?? $server->startup, + 'image' => Arr::first($egg->docker_images) ?? $server->image, + ])->save(); + + $fresh = $server->fresh(); + throw_if($fresh === null, LogicException::class, 'The modified server no longer exists.'); + + return $fresh; + }); + } + + /** + * @return array environment variable name => stored value + */ + private function storedValues(Server $server): array + { + return ServerVariable::query() + ->where('server_id', $server->id) + ->with('variable') + ->get() + ->mapWithKeys(fn (ServerVariable $stored): array => [$stored->variable->env_variable => $stored->variable_value]) + ->all(); + } +} diff --git a/app/Actions/Servers/CreateServer.php b/app/Actions/Servers/CreateServer.php new file mode 100644 index 000000000..598f81cd9 --- /dev/null +++ b/app/Actions/Servers/CreateServer.php @@ -0,0 +1,187 @@ + $data + * + * @throws Throwable + * @throws DisplayException + * @throws ValidationException + * @throws NoViableNodeException + * @throws NoViableAllocationException + */ + public function create(array $data, ?DeploymentObject $deployment = null): Server + { + // Normalize the validated request once before applying any deployment rules. + $data = ServerCreationData::parse($data); + throw_if(empty($data['egg_id']), InvalidArgumentException::class, 'Expected a non-empty egg_id in server creation data.'); + + $egg = Egg::query()->with('tags')->findOrFail((int) $data['egg_id']); + + // Resolve the egg first because its tags constrain which nodes are viable. + if ($deployment instanceof DeploymentObject) { + $allocation = $this->configureDeployment($data, $deployment, $egg); + $data['allocation_id'] = $allocation->id; + $data['node_id'] = $allocation->node_id; + } + + if (empty($data['node_id'])) { + throw_if(empty($data['allocation_id']), InvalidArgumentException::class, 'Expected a non-empty allocation_id in server creation data.'); + $data['node_id'] = Allocation::query()->findOrFail((int) $data['allocation_id'])->node_id; + } + + $eggVariableData = $this->validatorService + ->setUserLevel(User::USER_LEVEL_ADMIN) + ->handle($egg, $data['environment']); + + // Wings requires the server to exist in the Panel before it can start creation. + $server = DB::transaction(function () use ($data, $eggVariableData): Server { + $server = $this->createModel($data); + $this->storeAssignedAllocations($server, $data); + $this->storeEggVariables($server, $eggVariableData); + + return $server; + }, 5); + + try { + Daemon::server($server)->create($data['start_on_completion']); + } catch (DaemonConnectionException $daemonConnectionException) { + // Remove the persisted record even when Wings could not be reached. + $this->deleteServer->withForce()->delete($server); + throw $daemonConnectionException; + } + + Event::dispatch(new OperationCompleted($server->uuid, 'provision', true, $server->uuid)); + + return $server; + } + + /** @param ServerCreationAttributes $data */ + private function configureDeployment(array $data, DeploymentObject $deployment, Egg $egg): Allocation + { + // Egg tags are matched against accepted game tags on viable nodes. + $nodes = $this->findViableNodesService->setLocations($deployment->getLocations()) + ->setDisk($data['disk']) + ->setMemory($data['memory']) + ->setEggTags($egg->tagSlugs()) + ->setDeployTags($deployment->getTags()) + ->handle(); + + $nodeIds = []; + foreach ($nodes as $node) { + $nodeIds[] = $node->id; + } + + return $this->allocationSelectionService->setDedicated($deployment->isDedicated()) + ->setNodes($nodeIds) + ->setPorts($deployment->getPorts()) + ->handle(); + } + + /** @param ServerCreationAttributes $data */ + private function createModel(array $data): Server + { + $uuid = $this->generateUniqueUuidCombo(); + + return Server::query()->create([ + 'external_id' => $data['external_id'], + 'uuid' => $uuid, + 'uuidShort' => mb_substr($uuid, 0, 8), + 'node_id' => $data['node_id'] ?? throw new InvalidArgumentException('Expected node_id in server creation data.'), + 'name' => $data['name'], + 'description' => $data['description'] ?? '', + 'status' => Server::STATUS_INSTALLING, + 'skip_scripts' => $data['skip_scripts'], + 'owner_id' => $data['owner_id'], + 'memory' => $data['memory'], + 'swap' => $data['swap'], + 'disk' => $data['disk'], + 'io' => $data['io'], + 'cpu' => $data['cpu'], + 'threads' => $data['threads'], + 'oom_disabled' => $data['oom_disabled'] ?? true, + 'allocation_id' => $data['allocation_id'], + 'egg_id' => $data['egg_id'], + 'startup' => $data['startup'], + 'image' => $data['image'], + 'database_limit' => $data['database_limit'] ?? 0, + 'allocation_limit' => $data['allocation_limit'] ?? 0, + 'backup_limit' => $data['backup_limit'] ?? 0, + ])->refresh(); + } + + /** @param ServerCreationAttributes $data */ + private function storeAssignedAllocations(Server $server, array $data): void + { + $allocationId = $data['allocation_id']; + throw_if($allocationId === null, InvalidArgumentException::class, 'Expected an allocation_id before storing server allocations.'); + $records = [$allocationId]; + if ($data['allocation_additional'] !== null) { + $records = array_merge($records, $data['allocation_additional']); + } + + Allocation::query()->whereIn('id', $records)->update(['server_id' => $server->id]); + } + + /** @param Collection $variables */ + private function storeEggVariables(Server $server, Collection $variables): void + { + $records = []; + foreach ($variables as $result) { + $records[] = ['server_id' => $server->id, 'variable_id' => $result->id, 'variable_value' => $result->value ?? '']; + } + + if ($records !== []) { + ServerVariable::query()->insert($records); + } + } + + private function generateUniqueUuidCombo(): string + { + $uuid = Uuid::uuid4()->toString(); + if (Server::query()->where('uuid', $uuid)->orWhere('uuidShort', mb_substr($uuid, 0, 8))->exists()) { + return $this->generateUniqueUuidCombo(); + } + + return $uuid; + } +} diff --git a/app/Actions/Servers/DeleteServer.php b/app/Actions/Servers/DeleteServer.php new file mode 100644 index 000000000..91b08a06b --- /dev/null +++ b/app/Actions/Servers/DeleteServer.php @@ -0,0 +1,72 @@ +force = $bool; + + return $this; + } + + /** + * @throws Throwable + * @throws DisplayException + */ + public function delete(Server $server): void + { + try { + Daemon::server($server)->delete(); + } catch (DaemonConnectionException $daemonConnectionException) { + // A missing Wings record is safe to treat as already deleted. Force mode also + // tolerates other Wings and database-host cleanup failures. + throw_if(! $this->force && $daemonConnectionException->getStatusCode() !== Response::HTTP_NOT_FOUND, $daemonConnectionException); + Log::warning($daemonConnectionException->getMessage(), ['exception' => $daemonConnectionException]); + } + + DB::transaction(function () use ($server): void { + foreach ($server->loadMissing('databases.host')->databases as $database) { + try { + $this->deleteDatabase->delete($database); + } catch (Exception $exception) { + throw_unless($this->force, $exception); + // The host entry could not be removed, so remove the Panel record and + // report the orphan for later cleanup rather than blocking server deletion. + $database->delete(); + Log::warning($exception->getMessage(), ['exception' => $exception]); + } + } + + // Clear notes before releasing the allocations back to the unassigned pool. + $server->allocations()->update(['notes' => null]); + $server->delete(); + }); + + // The row is gone, so only the uuid travels. Dispatched after any outer transaction commits. + Event::dispatch(new OperationCompleted($server->uuid, 'delete', true, $server->uuid)); + } +} diff --git a/app/Actions/Servers/DetachMountFromServer.php b/app/Actions/Servers/DetachMountFromServer.php new file mode 100644 index 000000000..b1024cb00 --- /dev/null +++ b/app/Actions/Servers/DetachMountFromServer.php @@ -0,0 +1,18 @@ +where('mount_id', $mount->id)->where('server_id', $server->id)->delete(); + } +} diff --git a/app/Actions/Servers/ReadServerLogs.php b/app/Actions/Servers/ReadServerLogs.php new file mode 100644 index 000000000..0512512dd --- /dev/null +++ b/app/Actions/Servers/ReadServerLogs.php @@ -0,0 +1,17 @@ +logs(max(1, min($lines, self::MAX_LINES))); + } +} diff --git a/app/Actions/Servers/ReadServerState.php b/app/Actions/Servers/ReadServerState.php new file mode 100644 index 000000000..2bef62085 --- /dev/null +++ b/app/Actions/Servers/ReadServerState.php @@ -0,0 +1,27 @@ +uuid", + now()->addSeconds(self::CACHE_SECONDS), + fn (): array => Daemon::server($server)->details(), + ); + + return ServerState::fromDaemon($stats); + } +} diff --git a/app/Actions/Servers/RebuildServer.php b/app/Actions/Servers/RebuildServer.php new file mode 100644 index 000000000..8cea18422 --- /dev/null +++ b/app/Actions/Servers/RebuildServer.php @@ -0,0 +1,17 @@ +sync(); + } +} diff --git a/app/Actions/Servers/RecordServerInstallResult.php b/app/Actions/Servers/RecordServerInstallResult.php new file mode 100644 index 000000000..ddc9f4ef4 --- /dev/null +++ b/app/Actions/Servers/RecordServerInstallResult.php @@ -0,0 +1,44 @@ +serverInstallService->resolveForNode($request, $uuid); + $status = null; + if (! $successful) { + $status = $reinstall ? Server::STATUS_REINSTALL_FAILED : Server::STATUS_INSTALL_FAILED; + } + + if ($server->status === Server::STATUS_SUSPENDED) { + $status = Server::STATUS_SUSPENDED; + } + + $isInitialInstall = $server->installed_at === null; + $server->forceFill(['status' => $status, 'installed_at' => CarbonImmutable::now()])->saveOrFail(); + if ($isInitialInstall && config()->get('pterodactyl.email.send_install_notification', true)) { + Event::dispatch(new ServerInstalled($server)); + } elseif (! $isInitialInstall && config()->get('pterodactyl.email.send_reinstall_notification', true)) { + Event::dispatch(new ServerInstalled($server)); + } + + Event::dispatch(new OperationCompleted($server->uuid, $reinstall ? 'reinstall' : 'install', $successful, $server->uuid)); + + return $server->refresh(); + } +} diff --git a/app/Actions/Servers/ReinstallServer.php b/app/Actions/Servers/ReinstallServer.php new file mode 100644 index 000000000..a69bb1601 --- /dev/null +++ b/app/Actions/Servers/ReinstallServer.php @@ -0,0 +1,31 @@ +canBeReinstalled(), DisplayException::class, trans('admin/server.exceptions.skipping_install_script')); + + return DB::transaction(function () use ($server): Server { + $server->fill(['status' => Server::STATUS_INSTALLING])->save(); + Daemon::server($server)->reinstall(); + + return $server->refresh(); + }); + } +} diff --git a/app/Actions/Servers/SendServerCommand.php b/app/Actions/Servers/SendServerCommand.php new file mode 100644 index 000000000..8998b2c49 --- /dev/null +++ b/app/Actions/Servers/SendServerCommand.php @@ -0,0 +1,26 @@ +commands($command); + } catch (DaemonConnectionException $daemonConnectionException) { + throw_if($daemonConnectionException->getStatusCode() === Response::HTTP_BAD_GATEWAY, HttpException::class, Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $daemonConnectionException); + + throw $daemonConnectionException; + } + } +} diff --git a/app/Actions/Servers/SendServerPower.php b/app/Actions/Servers/SendServerPower.php new file mode 100644 index 000000000..6e036c3ad --- /dev/null +++ b/app/Actions/Servers/SendServerPower.php @@ -0,0 +1,17 @@ +power($signal); + } +} diff --git a/app/Actions/Servers/ToggleServerSuspension.php b/app/Actions/Servers/ToggleServerSuspension.php new file mode 100644 index 000000000..2eca508de --- /dev/null +++ b/app/Actions/Servers/ToggleServerSuspension.php @@ -0,0 +1,48 @@ +isSuspended()) { + return; + } + + // A transfer can race with Wings state synchronization, so reject it first. + throw_if($server->transfer !== null, ConflictHttpException::class, 'Cannot toggle suspension status on a server that is currently being transferred.'); + $server->update(['status' => $isSuspending ? Server::STATUS_SUSPENDED : null]); + + try { + Daemon::server($server)->sync(); + } catch (Exception $exception) { + // Restore the Panel state if Wings could not accept the update. + $server->update(['status' => $isSuspending ? null : Server::STATUS_SUSPENDED]); + throw $exception; + } + + // Only a state change Wings accepted is reported; repeats and reverted attempts are not. + Event::dispatch(new OperationCompleted($server->uuid, $isSuspending ? 'suspend' : 'unsuspend', true, $server->uuid)); + } +} diff --git a/app/Actions/Servers/UpdateServerBuild.php b/app/Actions/Servers/UpdateServerBuild.php new file mode 100644 index 000000000..3afb685e1 --- /dev/null +++ b/app/Actions/Servers/UpdateServerBuild.php @@ -0,0 +1,106 @@ +processAllocations($server, $data); + if (isset($data['allocation_id']) && $data['allocation_id'] !== $server->allocation_id) { + $allocationExists = Allocation::query()->where('id', $data['allocation_id']) + ->where('server_id', $server->id)->exists(); + throw_if(! $allocationExists, DisplayException::class, 'The requested default allocation is not currently assigned to this server.'); + } + + // Only values present in the validated payload are changed. The three + // feature limits keep their historical default behavior. + $attributes = [ + 'database_limit' => $data['database_limit'] ?? null, + 'allocation_limit' => $data['allocation_limit'] ?? null, + 'backup_limit' => $data['backup_limit'] ?? 0, + ]; + foreach (['oom_disabled', 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', 'allocation_id'] as $key) { + if (array_key_exists($key, $data)) { + $attributes[$key] = $data[$key]; + } + } + + $server->forceFill($attributes)->saveOrFail(); + + return $server->refresh(); + }); + + $updateData = $this->structureService->handle($server); + if (! empty($updateData['build'])) { + try { + Daemon::server($server)->sync(); + } catch (DaemonConnectionException $exception) { + // Wings fetches fresh Panel configuration when the server boots, so a + // failed live sync can be logged without undoing the committed change. + Log::warning($exception->getMessage(), ['exception' => $exception, 'server_id' => $server->id]); + } + } + + return $server; + } + + /** @param ServerBuildModificationData $data */ + private function processAllocations(Server $server, array &$data): void + { + if (empty($data['add_allocations']) && empty($data['remove_allocations'])) { + return; + } + + if (! empty($data['add_allocations'])) { + // Assign only currently unassigned allocations on this server's node. + $query = Allocation::query()->where('node_id', $server->node_id) + ->whereIn('id', $data['add_allocations'])->whereNull('server_id'); + // If the default allocation is removed below, use the first newly assigned + // allocation as its replacement. + $freshlyAllocated = $query->first(['id'])?->id; + $query->update(['server_id' => $server->id, 'notes' => null]); + } + + if (! empty($data['remove_allocations'])) { + foreach ($data['remove_allocations'] as $allocation) { + if ($allocation === ($data['allocation_id'] ?? $server->allocation_id)) { + throw_if(empty($freshlyAllocated), DisplayException::class, 'You are attempting to delete the default allocation for this server but there is no fallback allocation to use.'); + $data['allocation_id'] = $freshlyAllocated; + } + } + + // Release allocations after clearing notes so they do not leak to a future server. + // Do not remove an allocation also requested in add_allocations. + Allocation::query()->where('node_id', $server->node_id) + ->where('server_id', $server->id) + ->whereIn('id', array_diff($data['remove_allocations'], $data['add_allocations'] ?? [])) + ->update(['notes' => null, 'server_id' => null]); + } + } +} diff --git a/app/Actions/Servers/UpdateServerDetails.php b/app/Actions/Servers/UpdateServerDetails.php new file mode 100644 index 000000000..a00866aa2 --- /dev/null +++ b/app/Actions/Servers/UpdateServerDetails.php @@ -0,0 +1,40 @@ +user; + $server->forceFill([ + 'external_id' => Arr::get($data, 'external_id'), + 'owner_id' => Arr::get($data, 'owner_id'), + 'name' => Arr::get($data, 'name'), + 'description' => Arr::get($data, 'description') ?? '', + ])->saveOrFail(); + + // Revoke the previous owner's Wings SFTP token after an ownership change. + if (! $server->refresh()->user->is($original)) { + dispatch(new RevokeSftpAccessJob($original->uuid, $server)); + } + + return $server->refresh(); + }); + } +} diff --git a/app/Actions/Servers/UpdateServerStartup.php b/app/Actions/Servers/UpdateServerStartup.php new file mode 100644 index 000000000..77d22a75b --- /dev/null +++ b/app/Actions/Servers/UpdateServerStartup.php @@ -0,0 +1,72 @@ +egg_id !== $eggId) { + // Only administrators may move a server to another egg. Values the + // new egg still accepts are kept, and anything submitted below + // replaces the defaults the move resets. + $server = $this->eggs->change($server, Egg::query()->findOrFail($eggId), keepVariables: true); + } + + if (! empty($data['environment'])) { + $egg = $server->relationLoaded('egg') && $server->egg instanceof Egg + ? $server->egg + : Egg::query()->findOrFail($server->egg_id); + + $results = $this->validatorService->setUserLevel($userLevel)->handle($egg, $data['environment']); + foreach ($results as $result) { + ServerVariable::query()->updateOrCreate( + ['server_id' => $server->id, 'variable_id' => $result->id], + ['variable_value' => $result->value ?? ''] + ); + } + } + + if ($userLevel === User::USER_LEVEL_ADMIN) { + $server->fill([ + 'startup' => $data['startup'] ?? $server->startup, + 'skip_scripts' => $data['skip_scripts'] ?? isset($data['skip_scripts']), + 'image' => $data['docker_image'] ?? $server->image, + ])->save(); + } + + // Calling ->refresh() rather than ->fresh() here causes the + // variables as triplicates for some reason. Not entirely sure why, + // but this operation test covers the behavior and keeps it stable. + $fresh = $server->fresh(); + throw_if($fresh === null, LogicException::class, 'The modified server no longer exists.'); + + return $fresh; + }); + } +} diff --git a/app/Actions/Subusers/CreateSubuser.php b/app/Actions/Subusers/CreateSubuser.php new file mode 100644 index 000000000..474b6efd2 --- /dev/null +++ b/app/Actions/Subusers/CreateSubuser.php @@ -0,0 +1,64 @@ + $permissions The permission keys to grant, deduplicated + * before they are stored. + * + * @throws ServerSubuserExistsException + * @throws UserIsServerOwnerException + * @throws Throwable + */ + public function create(Server $server, string $email, array $permissions): Subuser + { + return DB::transaction(function () use ($server, $email, $permissions): Subuser { + $server = $server->newQuery()->whereKey($server->getKey())->lockForUpdate()->firstOrFail(); + $user = User::query()->where('email', $email)->first() ?? $this->createUser($email); + + throw_if($server->owner_id === $user->id, UserIsServerOwnerException::class, trans('exceptions.subusers.user_is_owner')); + throw_if($server->subusers()->where('user_id', $user->id)->exists(), ServerSubuserExistsException::class, trans('exceptions.subusers.subuser_exists')); + + return Subuser::query()->create([ + 'user_id' => $user->id, + 'server_id' => $server->id, + 'permissions' => array_values(array_unique($permissions)), + ])->refresh()->setRelation('user', $user); + }); + } + + private function createUser(string $email): User + { + $localPart = strtok($email, '@') ?: $email; + $username = mb_substr(preg_replace('/([^\w\.-]+)/', '', $localPart) ?? '', 0, 64).Str::random(3); + + return $this->users->create([ + 'email' => $email, + 'username' => $username, + 'name_first' => 'Server', + 'name_last' => 'Subuser', + 'root_admin' => false, + ]); + } +} diff --git a/app/Actions/Subusers/DeleteSubuser.php b/app/Actions/Subusers/DeleteSubuser.php new file mode 100644 index 000000000..e8e6ea7f4 --- /dev/null +++ b/app/Actions/Subusers/DeleteSubuser.php @@ -0,0 +1,31 @@ +delete(); + + $job = new RevokeSftpAccessJob($subuser->user->uuid, $server); + DB::afterCommit(fn (): PendingDispatch => dispatch($job)); + }); + } +} diff --git a/app/Actions/Subusers/UpdateSubuser.php b/app/Actions/Subusers/UpdateSubuser.php new file mode 100644 index 000000000..4a8f1c530 --- /dev/null +++ b/app/Actions/Subusers/UpdateSubuser.php @@ -0,0 +1,35 @@ + $permissions + * + * @throws Throwable + */ + public function update(Server $server, Subuser $subuser, array $permissions): Subuser + { + return DB::transaction(function () use ($server, $subuser, $permissions): Subuser { + $subuser->update(['permissions' => $permissions]); + + $job = new RevokeSftpAccessJob($subuser->user->uuid, $server); + DB::afterCommit(fn (): PendingDispatch => dispatch($job)); + + return $subuser->refresh(); + }); + } +} diff --git a/app/Actions/Tags/SyncTags.php b/app/Actions/Tags/SyncTags.php new file mode 100644 index 000000000..96a7255b4 --- /dev/null +++ b/app/Actions/Tags/SyncTags.php @@ -0,0 +1,51 @@ + $values */ + public function syncEgg(Egg $egg, array $values): void + { + $this->sync($egg, $egg->tags(), $values); + } + + /** @param list $values */ + public function syncNodeGames(Node $node, array $values): void + { + $this->sync($node, $node->eggTags(), $values); + } + + /** @param list $values */ + public function syncNodeDeployments(Node $node, array $values): void + { + $this->sync($node, $node->deploymentTags(), $values); + } + + /** + * @template T of Egg|Node + * + * @param T $parent + * @param MorphToMany $tags + * @param list $values + */ + private function sync(Egg|Node $parent, MorphToMany $tags, array $values): void + { + DB::transaction(function () use ($parent, $tags, $values): void { + $parent->newQuery()->lockForUpdate()->findOrFail($parent->id); + $tags->sync($this->resolver->resolve($values)); + }); + } +} diff --git a/app/Actions/Telemetry/SendTelemetry.php b/app/Actions/Telemetry/SendTelemetry.php new file mode 100644 index 000000000..71a533afd --- /dev/null +++ b/app/Actions/Telemetry/SendTelemetry.php @@ -0,0 +1,30 @@ +telemetry->collect(); + } catch (Exception) { + return; + } + + try { + Http::timeout(5)->post('https://telemetry.pterodactyl.io', $data); + } catch (Exception) { + return; + } + } +} diff --git a/app/Actions/Themes/ApplyTheme.php b/app/Actions/Themes/ApplyTheme.php new file mode 100644 index 000000000..519a8c764 --- /dev/null +++ b/app/Actions/Themes/ApplyTheme.php @@ -0,0 +1,51 @@ +themes->discovered()[$id] ?? null; + if ($theme === null) { + throw new InvalidExtensionException("Theme \"{$id}\" was not found in {$this->themes->directory()}."); + } + + $tokens = $theme['directory'].DIRECTORY_SEPARATOR.'tokens.css'; + throw_unless(is_file($tokens), InvalidExtensionException::class, "Theme \"{$id}\" has no tokens.css."); + + $stylesheet = $this->themes->publishedStylesheet(); + $publishedAssets = $this->themes->publishedAssetsDirectory(); + File::ensureDirectoryExists(dirname($stylesheet)); + $stagedTokens = dirname($stylesheet).'/.staging-'.Str::random(12); + $stagedAssets = dirname($publishedAssets).'/.staging-'.Str::random(12); + $assets = $theme['directory'].DIRECTORY_SEPARATOR.'assets'; + + try { + throw_unless(File::copy($tokens, $stagedTokens), InvalidExtensionException::class, 'Unable to stage theme stylesheet.'); + if (is_dir($assets)) { + throw_unless(File::copyDirectory($assets, $stagedAssets), InvalidExtensionException::class, 'Unable to stage theme assets.'); + } + + $this->files->run([ + $stylesheet => $stagedTokens, + $publishedAssets => is_dir($assets) ? $stagedAssets : null, + ], static function (): void {}); + } finally { + rescue(fn () => $this->files->delete($stagedTokens)); + rescue(fn () => $this->files->delete($stagedAssets)); + } + } +} diff --git a/app/Actions/Themes/ResetTheme.php b/app/Actions/Themes/ResetTheme.php new file mode 100644 index 000000000..ccf5a4e33 --- /dev/null +++ b/app/Actions/Themes/ResetTheme.php @@ -0,0 +1,23 @@ +files->run([ + $this->themes->publishedStylesheet() => null, + $this->themes->publishedAssetsDirectory() => null, + ], static function (): void {}); + } +} diff --git a/app/Actions/Transfers/CompleteTransfer.php b/app/Actions/Transfers/CompleteTransfer.php new file mode 100644 index 000000000..0c8488f8d --- /dev/null +++ b/app/Actions/Transfers/CompleteTransfer.php @@ -0,0 +1,55 @@ +whereIn('id', [$transfer->old_allocation, ...($transfer->old_additional_allocations ?? [])]) + ->update(['server_id' => null]); + + $server = $transfer->server; + $server->update([ + 'allocation_id' => $transfer->new_allocation, + 'node_id' => $transfer->new_node, + ]); + + $transfer->update(['successful' => true]); + Event::dispatch(new OperationCompleted($server->uuid, 'transfer', true, $server->uuid)); + + return $server->refresh(); + }); + + // Point the delete at the old node so the freshly transferred copy is left alone. + try { + Daemon::server($server, $transfer->oldNode) + ->delete(); + } catch (DaemonConnectionException $daemonConnectionException) { + Log::warning($daemonConnectionException->getMessage(), ['exception' => $daemonConnectionException, 'transfer_id' => $transfer->id]); + } + + return $server; + } +} diff --git a/app/Actions/Transfers/FailTransfer.php b/app/Actions/Transfers/FailTransfer.php new file mode 100644 index 000000000..52b59e0c4 --- /dev/null +++ b/app/Actions/Transfers/FailTransfer.php @@ -0,0 +1,34 @@ +forceFill(['successful' => false])->saveOrFail(); + + Allocation::query() + ->whereIn('id', [$transfer->new_allocation, ...($transfer->new_additional_allocations ?? [])]) + ->update(['server_id' => null]); + + Event::dispatch(new OperationCompleted($transfer->server->uuid, 'transfer', false, $transfer->server->uuid)); + }); + } +} diff --git a/app/Actions/Transfers/InitiateTransfer.php b/app/Actions/Transfers/InitiateTransfer.php new file mode 100644 index 000000000..ad75e1764 --- /dev/null +++ b/app/Actions/Transfers/InitiateTransfer.php @@ -0,0 +1,81 @@ + $additionalAllocations + * + * @throws DisplayException + * @throws Throwable + */ + public function initiate(Server $server, Node $node, int $allocationId, array $additionalAllocations): ServerTransfer + { + return DB::transaction(function () use ($server, $node, $allocationId, $additionalAllocations): ServerTransfer { + $server = $server->newQuery()->whereKey($server->getKey())->lockForUpdate()->firstOrFail(); + throw_unless($node->isViable($server->memory, $server->disk), DisplayException::class, trans('admin/server.alerts.transfer_not_viable')); + $server->validateTransferState(); + + $allocationIds = array_values(array_unique([$allocationId, ...$additionalAllocations])); + $allocations = Allocation::query() + ->whereKey($allocationIds) + ->where('node_id', $node->id) + ->unassigned() + ->orderBy('id') + ->lockForUpdate() + ->get(); + + throw_unless($allocations->count() === count($allocationIds), DisplayException::class, 'The selected allocations are no longer available on the target node.'); + + $transfer = ServerTransfer::query()->create([ + 'server_id' => $server->id, + 'old_node' => $server->node_id, + 'new_node' => $node->id, + 'old_allocation' => $server->allocation_id, + 'new_allocation' => $allocationId, + 'old_additional_allocations' => $server->allocations + ->reject(fn (Allocation $allocation): bool => $allocation->id === $server->allocation_id) + ->pluck('id') + ->values() + ->all(), + 'new_additional_allocations' => $additionalAllocations, + ]); + + // Assign now so another server can't claim these allocations mid-transfer. + Allocation::query()->whereKey($allocationIds)->update(['server_id' => $server->id]); + + $token = $this->nodeJWTService + ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) + ->setSubject($server->uuid) + ->setScopes(JwtScope::ServerTransfer) + ->handle($node, $server->uuid); + + Daemon::server($server)->transfer($node, $token); + + return $transfer->refresh(); + }); + } +} diff --git a/app/Actions/Users/CompleteLogin.php b/app/Actions/Users/CompleteLogin.php new file mode 100644 index 000000000..8d0fbedf8 --- /dev/null +++ b/app/Actions/Users/CompleteLogin.php @@ -0,0 +1,55 @@ +use_totp) { + return $this->establish($user); + } + + Activity::event('auth:checkpoint')->withRequestMetadata()->subject($user)->log(); + + $checkpoint = LoginCheckpoint::issue($user->id); + Session::put(self::CHECKPOINT_KEY, $checkpoint); + + return LoginResult::checkpoint($user, $checkpoint, self::INTENDED); + } + + public function establish(User $user): LoginResult + { + Session::remove(self::CHECKPOINT_KEY); + Session::regenerate(); + + Auth::guard()->login($user, true); + + Event::dispatch(new DirectLogin($user, true)); + + return LoginResult::established($user, self::INTENDED); + } + + public function pendingCheckpoint(): ?LoginCheckpoint + { + $checkpoint = Session::get(self::CHECKPOINT_KEY); + + return LoginCheckpoint::isPending($checkpoint) ? $checkpoint : null; + } +} diff --git a/app/Actions/Users/CreateUser.php b/app/Actions/Users/CreateUser.php new file mode 100644 index 000000000..6a26d127f --- /dev/null +++ b/app/Actions/Users/CreateUser.php @@ -0,0 +1,45 @@ +create($data); + + return [$user->refresh(), $generateResetToken ? Password::createToken($user) : null]; + }); + + $user->notify(new AccountCreated($user, $token)); + + return $user; + } +} diff --git a/app/Services/Users/UserDeletionService.php b/app/Actions/Users/DeleteUser.php similarity index 53% rename from app/Services/Users/UserDeletionService.php rename to app/Actions/Users/DeleteUser.php index b58d89d4c..e65f96a6f 100644 --- a/app/Services/Users/UserDeletionService.php +++ b/app/Actions/Users/DeleteUser.php @@ -1,24 +1,23 @@ findOrFail($user); - - $servers = Server::query()->where('owner_id', $user->id)->count(); - if ($servers > 0) { + if ($user->servers()->exists()) { throw new DisplayException(trans('admin/user.exceptions.user_has_servers')); } diff --git a/app/Actions/Users/DisableTwoFactor.php b/app/Actions/Users/DisableTwoFactor.php new file mode 100644 index 000000000..cb6bd6a7c --- /dev/null +++ b/app/Actions/Users/DisableTwoFactor.php @@ -0,0 +1,19 @@ +update([ + 'totp_authenticated_at' => now(), + 'use_totp' => false, + ]); + } +} diff --git a/app/Actions/Users/SetupTwoFactor.php b/app/Actions/Users/SetupTwoFactor.php new file mode 100644 index 000000000..d7bc513c4 --- /dev/null +++ b/app/Actions/Users/SetupTwoFactor.php @@ -0,0 +1,50 @@ +getMessage(), 0, $exception); + } + + $user->update(['totp_secret' => Crypt::encrypt($secret)]); + + $company = urlencode(preg_replace('/\s/', '', JsonValueGuard::string(config('app.name'))) ?? ''); + + return [ + 'image_url_data' => sprintf( + 'otpauth://totp/%1$s:%2$s?secret=%3$s&issuer=%1$s', + rawurlencode($company), + rawurlencode($user->email), + rawurlencode($secret), + ), + 'secret' => $secret, + ]; + } +} diff --git a/app/Actions/Users/ToggleTwoFactor.php b/app/Actions/Users/ToggleTwoFactor.php new file mode 100644 index 000000000..619154c8c --- /dev/null +++ b/app/Actions/Users/ToggleTwoFactor.php @@ -0,0 +1,90 @@ + The plaintext recovery tokens generated for the account, + * empty when 2FA is being turned off. + * + * @throws Throwable + * @throws IncompatibleWithGoogleAuthenticatorException + * @throws InvalidCharactersException + * @throws SecretKeyTooShortException + * @throws TwoFactorAuthenticationTokenInvalid + */ + public function toggle(User $user, string $token, ?bool $toggleState = null): array + { + $encryptedSecret = $user->totp_secret; + throw_if($encryptedSecret === null, TwoFactorAuthenticationTokenInvalid::class); + + $secret = JsonValueGuard::string(Crypt::decrypt($encryptedSecret)); + + $isValidToken = $this->google2FA->verifyKey($secret, $token, JsonValueGuard::integer(config()->get('pterodactyl.auth.2fa.window'))); + + throw_unless($isValidToken, TwoFactorAuthenticationTokenInvalid::class); + + return DB::transaction(function () use ($user, $toggleState): array { + // Now that we're enabling 2FA on the account, generate 10 recovery tokens for the account + // and store them hashed in the database. We'll return them to the caller so that the user + // can see and save them. + // + // If a user is unable to login with a 2FA token they can provide one of these backup codes + // which will then be marked as deleted from the database and will also bypass 2FA protections + // on their account. + $tokens = []; + if ((! $toggleState && ! $user->use_totp) || $toggleState) { + $inserts = []; + for ($i = 0; $i < 10; $i++) { + $token = Str::random(10); + + $inserts[] = [ + 'user_id' => $user->id, + 'token' => Hash::make($token), + // insert() won't actually set the time on the models, so make sure we do this + // manually here. + 'created_at' => now(), + ]; + + $tokens[] = $token; + } + + // Before inserting any new records make sure all of the old ones are deleted to avoid + // any issues or storing an unnecessary number of tokens in the database. + $user->recoveryTokens()->delete(); + + // Bulk insert the hashed tokens. + RecoveryToken::query()->insert($inserts); + } + + $user->update([ + 'totp_authenticated_at' => null, + 'use_totp' => ($toggleState ?? ! $user->use_totp), + ]); + + return $tokens; + }); + } +} diff --git a/app/Actions/Users/UpdateUser.php b/app/Actions/Users/UpdateUser.php new file mode 100644 index 000000000..af8a30066 --- /dev/null +++ b/app/Actions/Users/UpdateUser.php @@ -0,0 +1,37 @@ +forceFill($data)->saveOrFail(); + + if (isset($data['password'])) { + event(new PasswordChanged($user)); + } + + return $user->refresh(); + } +} diff --git a/app/Actions/Users/UpdateUserEmail.php b/app/Actions/Users/UpdateUserEmail.php new file mode 100644 index 000000000..fe6e69d93 --- /dev/null +++ b/app/Actions/Users/UpdateUserEmail.php @@ -0,0 +1,44 @@ +throttleKey($user), self::THROTTLE_MAX), TooManyRequestsHttpException::class, 'Your email address has been changed too many times today. Please try again later.'); + + $original = $user->email; + if (mb_strtolower($original) === mb_strtolower($email)) { + return ['user' => $user, 'original' => $original, 'email' => $email, 'changed' => false]; + } + + RateLimiter::hit($key, self::THROTTLE_DECAY); + + $user = $this->users->update($user, ['email' => $email]); + + return ['user' => $user, 'original' => $original, 'email' => $email, 'changed' => true]; + } + + private function throttleKey(User $user): string + { + return "user:update-email:{$user->uuid}"; + } +} diff --git a/app/Actions/Users/UpdateUserPassword.php b/app/Actions/Users/UpdateUserPassword.php new file mode 100644 index 000000000..f4849aabf --- /dev/null +++ b/app/Actions/Users/UpdateUserPassword.php @@ -0,0 +1,29 @@ +users->update($user, ['password' => $password]); + + $guard = Auth::guard(Auth::getDefaultDriver()); + $guard->setUser($user); + + if (method_exists($guard, 'logoutOtherDevices')) { + $guard->logoutOtherDevices($password); + } + + return $user; + } +} diff --git a/app/Console/Commands/Environment/Addons/RunHooksCommand.php b/app/Console/Commands/Environment/Addons/RunHooksCommand.php index a2d21c59f..bf5d3d273 100644 --- a/app/Console/Commands/Environment/Addons/RunHooksCommand.php +++ b/app/Console/Commands/Environment/Addons/RunHooksCommand.php @@ -1,45 +1,46 @@ /hooks/" script for the given lifecycle event when addon hooks are enabled. */ public function handle(): int { - if (!config('addons.hooks_enabled')) { + if (! config('addons.hooks_enabled')) { return self::SUCCESS; } $event = $this->argument('event'); - if (!Str::isMatch('/^[a-z0-9-]+$/', $event)) { + if (! Str::isMatch('/^[a-z0-9-]+$/', $event)) { $this->components->error("Invalid hook event name: {$event}"); return self::INVALID; } - $hooks = Collection::make(File::glob(base_path("addons/*/hooks/{$event}")) ?: []) - ->filter(fn (string $hook) => is_executable($hook)) + $hooks = Collection::make(glob(base_path("addons/*/hooks/{$event}")) ?: []) + ->filter(fn (string $hook): bool => is_executable($hook)) ->values(); if ($hooks->isEmpty()) { return self::SUCCESS; } - if ($this->input->isInteractive() && !$this->confirm( + if ($this->input->isInteractive() && ! $this->confirm( sprintf('Execute %d addon hook script(s) for the "%s" event? They run with the privileges of this process.', $hooks->count(), $event) )) { return self::SUCCESS; diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index b143719fe..828b2ff7d 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -1,38 +1,22 @@ 'Redis (recommended)', - 'memcached' => 'Memcached', - 'file' => 'Filesystem', - ]; - - public const SESSION_DRIVERS = [ - 'redis' => 'Redis (recommended)', - 'memcached' => 'Memcached', - 'database' => 'MySQL Database', - 'file' => 'Filesystem', - 'cookie' => 'Cookie', - ]; - - public const QUEUE_DRIVERS = [ - 'redis' => 'Redis (recommended)', - 'database' => 'MySQL Database', - 'sync' => 'Sync', - ]; - - protected $description = 'Configure basic environment settings for the Panel.'; - - protected $signature = 'p:environment:setup +#[Description('Configure basic environment settings for the Panel.')] +#[Signature('p:environment:setup {--new-salt : Whether or not to generate a new salt for Hashids.} {--author= : The email that services created on this instance should be linked to.} {--url= : The URL that this Panel is running on.} @@ -44,8 +28,32 @@ class AppSettingsCommand extends Command {--redis-pass= : Password used to connect to redis.} {--redis-port= : Port to connect to redis over.} {--settings-ui= : Enable or disable the settings UI.} - {--telemetry= : Enable or disable anonymous telemetry.}'; + {--telemetry= : Enable or disable anonymous telemetry.}')] +class AppSettingsCommand extends Command +{ + use EnvironmentWriterTrait; + public const array CACHE_DRIVERS = [ + 'redis' => 'Redis (recommended)', + 'memcached' => 'Memcached', + 'file' => 'Filesystem', + ]; + + public const array SESSION_DRIVERS = [ + 'redis' => 'Redis (recommended)', + 'memcached' => 'Memcached', + 'database' => 'MySQL Database', + 'file' => 'Filesystem', + 'cookie' => 'Cookie', + ]; + + public const array QUEUE_DRIVERS = [ + 'redis' => 'Redis (recommended)', + 'database' => 'MySQL Database', + 'sync' => 'Sync', + ]; + + /** @var array */ protected array $variables = []; /** @@ -59,71 +67,81 @@ class AppSettingsCommand extends Command /** * Handle command execution. * - * @throws \Pterodactyl\Exceptions\PterodactylException + * @throws PterodactylException */ public function handle(): int { if (empty(config('hashids.salt')) || $this->option('new-salt')) { - $this->variables['HASHIDS_SALT'] = str_random(20); + $this->variables['HASHIDS_SALT'] = Str::random(20); } $this->output->comment('Provide the email address that eggs exported by this Panel should be from. This should be a valid email address.'); - $this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask( + $this->variables['APP_SERVICE_AUTHOR'] = JsonValueGuard::string($this->option('author') ?? $this->ask( 'Egg Author Email', - config('pterodactyl.service.author', 'unknown@unknown.com') - ); + JsonValueGuard::nullableString(config('pterodactyl.service.author', 'unknown@unknown.com')) + )); - if (!filter_var($this->variables['APP_SERVICE_AUTHOR'], FILTER_VALIDATE_EMAIL)) { + if (! filter_var($this->variables['APP_SERVICE_AUTHOR'], FILTER_VALIDATE_EMAIL)) { $this->output->error('The service author email provided is invalid.'); return 1; } $this->output->comment('The application URL MUST begin with https:// or http:// depending on if you are using SSL or not. If you do not include the scheme your emails and other content will link to the wrong location.'); - $this->variables['APP_URL'] = $this->option('url') ?? $this->ask( + $this->variables['APP_URL'] = JsonValueGuard::string($this->option('url') ?? $this->ask( 'Application URL', - config('app.url', 'https://example.com') - ); + JsonValueGuard::nullableString(config('app.url', 'https://example.com')) + )); - $this->output->comment('The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference https://php.net/manual/en/timezones.php.'); - $this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate( + $this->output->comment("The timezone should match one of PHP's supported timezones. If you are unsure, please reference https://php.net/manual/en/timezones.php."); + $this->variables['APP_TIMEZONE'] = JsonValueGuard::string($this->option('timezone') ?? $this->anticipate( 'Application Timezone', - \DateTimeZone::listIdentifiers(), - config('app.timezone') - ); + DateTimeZone::listIdentifiers(), + JsonValueGuard::nullableString(config('app.timezone')) + )); - $selected = config('cache.default', 'redis'); - $this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice( + $selected = JsonValueGuard::string(config('cache.default', 'redis')); + $cacheDriver = $this->option('cache') ?? $this->choice( 'Cache Driver', self::CACHE_DRIVERS, array_key_exists($selected, self::CACHE_DRIVERS) ? $selected : null ); + JsonValueGuard::assertScalar($cacheDriver); + $this->variables['CACHE_DRIVER'] = $this->stringValue($cacheDriver); - $selected = config('session.driver', 'redis'); - $this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice( + $selected = JsonValueGuard::string(config('session.driver', 'redis')); + $sessionDriver = $this->option('session') ?? $this->choice( 'Session Driver', self::SESSION_DRIVERS, array_key_exists($selected, self::SESSION_DRIVERS) ? $selected : null ); + JsonValueGuard::assertScalar($sessionDriver); + $this->variables['SESSION_DRIVER'] = $this->stringValue($sessionDriver); - $selected = config('queue.default', 'redis'); - $this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice( + $selected = JsonValueGuard::string(config('queue.default', 'redis')); + $queueDriver = $this->option('queue') ?? $this->choice( 'Queue Driver', self::QUEUE_DRIVERS, array_key_exists($selected, self::QUEUE_DRIVERS) ? $selected : null ); + JsonValueGuard::assertScalar($queueDriver); + $this->variables['QUEUE_CONNECTION'] = $this->stringValue($queueDriver); - if (!is_null($this->option('settings-ui'))) { - $this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true'; + if (($this->option('settings-ui')) !== null) { + $this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') === 'true' ? 'false' : 'true'; } else { $this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm('Enable UI based settings editor?', true) ? 'false' : 'true'; } - $this->output->comment('Please reference https://pterodactyl.io/panel/1.0/additional_configuration.html#telemetry for more detailed information regarding telemetry data and collection.'); - $this->variables['PTERODACTYL_TELEMETRY_ENABLED'] = $this->option('telemetry') ?? $this->confirm( - 'Enable sending anonymous telemetry data?', - config('pterodactyl.telemetry.enabled', true) - ) ? 'true' : 'false'; + $this->output->comment('Please reference https://pterodactyl.io/docs/v2/panel/additional-configuration#telemetry for more detailed information regarding telemetry data and collection.'); + if (($this->option('telemetry')) !== null) { + $this->variables['PTERODACTYL_TELEMETRY_ENABLED'] = $this->option('telemetry') === 'true' ? 'true' : 'false'; + } else { + $this->variables['PTERODACTYL_TELEMETRY_ENABLED'] = $this->confirm( + 'Enable sending anonymous telemetry data?', + JsonValueGuard::boolean(config('pterodactyl.telemetry.enabled', true)) + ) ? 'true' : 'false'; + } // Make sure session cookies are set as "secure" when using HTTPS if (str_starts_with($this->variables['APP_URL'], 'https://')) { @@ -141,43 +159,49 @@ class AppSettingsCommand extends Command /** * Check if redis is selected, if so, request connection details and verify them. */ - private function checkForRedis() + private function checkForRedis(): void { - $items = collect($this->variables)->filter(function ($item) { - return $item === 'redis'; - }); + $items = collect($this->variables)->filter(fn (bool|float|int|string|null $item): bool => $item === 'redis'); // Redis was not selected, no need to continue. if (count($items) === 0) { return; } - $this->output->note('You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.'); - $this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask( + $this->output->note("You've selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup."); + $this->variables['REDIS_HOST'] = JsonValueGuard::string($this->option('redis-host') ?? $this->ask( 'Redis Host', - config('database.redis.default.host') - ); + JsonValueGuard::nullableScalarString(config('database.redis.default.host')) + )); $askForRedisPassword = true; - if (!empty(config('database.redis.default.password'))) { - $this->variables['REDIS_PASSWORD'] = config('database.redis.default.password'); + if (! empty(config('database.redis.default.password'))) { + $this->variables['REDIS_PASSWORD'] = JsonValueGuard::scalar(config('database.redis.default.password')); $askForRedisPassword = $this->confirm('It seems a password is already defined for Redis, would you like to change it?'); } if ($askForRedisPassword) { $this->output->comment('By default a Redis server instance has no password as it is running locally and inaccessible to the outside world. If this is the case, simply hit enter without entering a value.'); - $this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden( + $this->variables['REDIS_PASSWORD'] = JsonValueGuard::scalar($this->option('redis-pass') ?? $this->output->askHidden( 'Redis Password' - ); + )); } if (empty($this->variables['REDIS_PASSWORD'])) { $this->variables['REDIS_PASSWORD'] = 'null'; } - $this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask( + $this->variables['REDIS_PORT'] = JsonValueGuard::scalar($this->option('redis-port') ?? $this->ask( 'Redis Port', - config('database.redis.default.port') - ); + JsonValueGuard::nullableScalarString(config('database.redis.default.port')) + )); + } + + /** @param ApiScalar $value */ + private function stringValue(bool|float|int|string|null $value): string + { + throw_unless(is_string($value), InvalidArgumentException::class, 'Expected a single environment option value.'); + + return $value; } } diff --git a/app/Console/Commands/Environment/DatabaseSettingsCommand.php b/app/Console/Commands/Environment/DatabaseSettingsCommand.php index fb4a2e25b..1c3f8f52a 100644 --- a/app/Console/Commands/Environment/DatabaseSettingsCommand.php +++ b/app/Console/Commands/Environment/DatabaseSettingsCommand.php @@ -1,25 +1,31 @@ */ protected array $variables = []; /** @@ -33,46 +39,46 @@ class DatabaseSettingsCommand extends Command /** * Handle command execution. * - * @throws \Pterodactyl\Exceptions\PterodactylException + * @throws PterodactylException */ public function handle(): int { $this->output->note('It is highly recommended to not use "localhost" as your database host as we have seen frequent socket connection issues. If you want to use a local connection you should be using "127.0.0.1".'); - $this->variables['DB_HOST'] = $this->option('host') ?? $this->ask( + $this->variables['DB_HOST'] = JsonValueGuard::string($this->option('host') ?? $this->ask( 'Database Host', - config('database.connections.mysql.host', '127.0.0.1') - ); + JsonValueGuard::nullableScalarString(config('database.connections.mysql.host', '127.0.0.1')) + )); - $this->variables['DB_PORT'] = $this->option('port') ?? $this->ask( + $this->variables['DB_PORT'] = JsonValueGuard::scalar($this->option('port') ?? $this->ask( 'Database Port', - config('database.connections.mysql.port', 3306) - ); + JsonValueGuard::nullableScalarString(config('database.connections.mysql.port', 3306)) + )); - $this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask( + $this->variables['DB_DATABASE'] = JsonValueGuard::string($this->option('database') ?? $this->ask( 'Database Name', - config('database.connections.mysql.database', 'panel') - ); + JsonValueGuard::nullableScalarString(config('database.connections.mysql.database', 'panel')) + )); $this->output->note('Using the "root" account for MySQL connections is not only highly frowned upon, it is also not allowed by this application. You\'ll need to have created a MySQL user for this software.'); - $this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask( + $this->variables['DB_USERNAME'] = JsonValueGuard::string($this->option('username') ?? $this->ask( 'Database Username', - config('database.connections.mysql.username', 'pterodactyl') - ); + JsonValueGuard::nullableScalarString(config('database.connections.mysql.username', 'pterodactyl')) + )); $askForMySQLPassword = true; - if (!empty(config('database.connections.mysql.password')) && $this->input->isInteractive()) { - $this->variables['DB_PASSWORD'] = config('database.connections.mysql.password'); + if (! empty(config('database.connections.mysql.password')) && $this->input->isInteractive()) { + $this->variables['DB_PASSWORD'] = JsonValueGuard::scalar(config('database.connections.mysql.password')); $askForMySQLPassword = $this->confirm('It appears you already have a MySQL connection password defined, would you like to change it?'); } if ($askForMySQLPassword) { - $this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret('Database Password'); + $this->variables['DB_PASSWORD'] = JsonValueGuard::scalar($this->option('password') ?? $this->secret('Database Password')); } try { $this->testMySQLConnection(); - } catch (\PDOException $exception) { - $this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $exception->getMessage())); + } catch (PDOException $pdoException) { + $this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $pdoException->getMessage())); $this->output->error('Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.'); if ($this->confirm('Go back and try again?')) { @@ -94,7 +100,7 @@ class DatabaseSettingsCommand extends Command /** * Test that we can connect to the provided MySQL instance and perform a selection. */ - private function testMySQLConnection() + private function testMySQLConnection(): void { config()->set('database.connections._pterodactyl_command_test', [ 'driver' => 'mysql', diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index 3a211394c..e83ead17e 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -1,18 +1,19 @@ */ protected array $variables = []; /** @@ -36,11 +41,11 @@ class EmailSettingsCommand extends Command /** * Handle command execution. * - * @throws \Pterodactyl\Exceptions\PterodactylException + * @throws PterodactylException */ - public function handle() + public function handle(): void { - $this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice( + $driver = $this->option('driver') ?? $this->choice( trans('command/messages.environment.mail.ask_driver'), [ 'smtp' => 'SMTP Server', @@ -49,23 +54,37 @@ class EmailSettingsCommand extends Command 'mandrill' => 'Mandrill Transactional Email', 'postmark' => 'Postmark Transactional Email', ], - $this->config->get('mail.default', 'smtp') + JsonValueGuard::nullableScalarString($this->config->get('mail.default', 'smtp')) ); - $method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables'; - if (method_exists($this, $method)) { - $this->{$method}(); + throw_unless(is_string($driver), PterodactylException::class, 'The mail driver selection must resolve to a single value.'); + + $this->variables['MAIL_DRIVER'] = $driver; + + switch ($driver) { + case 'smtp': + $this->setupSmtpDriverVariables(); + break; + case 'mailgun': + $this->setupMailgunDriverVariables(); + break; + case 'mandrill': + $this->setupMandrillDriverVariables(); + break; + case 'postmark': + $this->setupPostmarkDriverVariables(); + break; } - $this->variables['MAIL_FROM_ADDRESS'] = $this->option('email') ?? $this->ask( + $this->variables['MAIL_FROM_ADDRESS'] = JsonValueGuard::scalar($this->option('email') ?? $this->ask( trans('command/messages.environment.mail.ask_mail_from'), - $this->config->get('mail.from.address') - ); + JsonValueGuard::nullableScalarString($this->config->get('mail.from.address')) + )); - $this->variables['MAIL_FROM_NAME'] = $this->option('from') ?? $this->ask( + $this->variables['MAIL_FROM_NAME'] = JsonValueGuard::scalar($this->option('from') ?? $this->ask( trans('command/messages.environment.mail.ask_mail_name'), - $this->config->get('mail.from.name') - ); + JsonValueGuard::nullableScalarString($this->config->get('mail.from.name')) + )); $this->writeToEnvironment($this->variables); @@ -76,77 +95,83 @@ class EmailSettingsCommand extends Command /** * Handle variables for SMTP driver. */ - private function setupSmtpDriverVariables() + private function setupSmtpDriverVariables(): void { - $this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask( + $this->variables['MAIL_HOST'] = JsonValueGuard::scalar($this->option('host') ?? $this->ask( trans('command/messages.environment.mail.ask_smtp_host'), - $this->config->get('mail.mailers.smtp.host') - ); + JsonValueGuard::nullableScalarString($this->config->get('mail.mailers.smtp.host')) + )); - $this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask( + $this->variables['MAIL_PORT'] = JsonValueGuard::scalar($this->option('port') ?? $this->ask( trans('command/messages.environment.mail.ask_smtp_port'), - $this->config->get('mail.mailers.smtp.port') - ); + JsonValueGuard::nullableScalarString($this->config->get('mail.mailers.smtp.port')) + )); - $this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask( + $this->variables['MAIL_USERNAME'] = JsonValueGuard::scalar($this->option('username') ?? $this->ask( trans('command/messages.environment.mail.ask_smtp_username'), - $this->config->get('mail.mailers.smtp.username') - ); + JsonValueGuard::nullableScalarString($this->config->get('mail.mailers.smtp.username')) + )); - $this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret( + $this->variables['MAIL_PASSWORD'] = JsonValueGuard::scalar($this->option('password') ?? $this->secret( trans('command/messages.environment.mail.ask_smtp_password') - ); + )); - $this->variables['MAIL_ENCRYPTION'] = $this->option('encryption') ?? $this->choice( + $encryption = $this->option('encryption') ?? $this->choice( trans('command/messages.environment.mail.ask_encryption'), ['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'], - $this->config->get('mail.mailers.smtp.encryption', 'tls') + JsonValueGuard::nullableScalarString($this->config->get('mail.mailers.smtp.encryption', 'tls')) ); + + throw_unless(is_string($encryption), PterodactylException::class, 'The mail encryption selection must resolve to a single value.'); + + $this->variables['MAIL_ENCRYPTION'] = $encryption; } /** * Handle variables for mailgun driver. */ - private function setupMailgunDriverVariables() + private function setupMailgunDriverVariables(): void { - $this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask( + $this->variables['MAILGUN_DOMAIN'] = JsonValueGuard::scalar($this->option('host') ?? $this->ask( trans('command/messages.environment.mail.ask_mailgun_domain'), - $this->config->get('services.mailgun.domain') - ); + JsonValueGuard::nullableScalarString($this->config->get('services.mailgun.domain')) + )); - $this->variables['MAILGUN_SECRET'] = $this->option('password') ?? $this->ask( + $this->variables['MAILGUN_SECRET'] = JsonValueGuard::scalar($this->option('password') ?? $this->ask( trans('command/messages.environment.mail.ask_mailgun_secret'), - $this->config->get('services.mailgun.secret') - ); + JsonValueGuard::nullableScalarString($this->config->get('services.mailgun.secret')) + )); - $this->variables['MAILGUN_ENDPOINT'] = $this->option('endpoint') ?? $this->ask( + $this->variables['MAILGUN_ENDPOINT'] = JsonValueGuard::scalar($this->option('endpoint') ?? $this->ask( trans('command/messages.environment.mail.ask_mailgun_endpoint'), - $this->config->get('services.mailgun.endpoint') - ); + JsonValueGuard::nullableScalarString($this->config->get('services.mailgun.endpoint')) + )); } /** * Handle variables for mandrill driver. */ - private function setupMandrillDriverVariables() + private function setupMandrillDriverVariables(): void { - $this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask( + $this->variables['MANDRILL_SECRET'] = JsonValueGuard::scalar($this->option('password') ?? $this->ask( trans('command/messages.environment.mail.ask_mandrill_secret'), - $this->config->get('services.mandrill.secret') - ); + JsonValueGuard::nullableScalarString($this->config->get('services.mandrill.secret')) + )); } /** * Handle variables for postmark driver. */ - private function setupPostmarkDriverVariables() + private function setupPostmarkDriverVariables(): void { $this->variables['MAIL_DRIVER'] = 'smtp'; $this->variables['MAIL_HOST'] = 'smtp.postmarkapp.com'; - $this->variables['MAIL_PORT'] = 587; - $this->variables['MAIL_USERNAME'] = $this->variables['MAIL_PASSWORD'] = $this->option('username') ?? $this->ask( + $this->variables['MAIL_PORT'] = '587'; + $credentials = JsonValueGuard::scalar($this->option('username') ?? $this->ask( trans('command/messages.environment.mail.ask_postmark_username'), - $this->config->get('mail.username') - ); + JsonValueGuard::nullableScalarString($this->config->get('mail.username')) + )); + $this->variables['MAIL_USERNAME'] = $credentials; + $this->variables['MAIL_PASSWORD'] = $credentials; } } diff --git a/app/Console/Commands/Extensions/DevCommand.php b/app/Console/Commands/Extensions/DevCommand.php new file mode 100644 index 000000000..06932d981 --- /dev/null +++ b/app/Console/Commands/Extensions/DevCommand.php @@ -0,0 +1,78 @@ +fromDirectory($this->argument('path')); + $publish = function () use ($installer, $manifest): void { + $installer->install($manifest->directory, (bool) $this->option('enable')); + $this->components->info('Published '.$manifest->id.'.'); + }; + if (! $manifest->hasUi()) { + $publish(); + + return self::SUCCESS; + } + + $build = Process::path($manifest->directory)->timeout(300)->run(['npm', 'run', 'build']); + if ($build->failed()) { + $this->error($build->output().$build->errorOutput()); + + return self::FAILURE; + } + + $publish(); + if ($this->option('watch')) { + $assets->watchDevelopment($manifest->id); + try { + $buffer = ''; + $process = Process::path($manifest->directory)->forever()->start(['npm', 'run', 'dev'], function (string $type, string $output) use (&$buffer, $publish): void { + $this->output->write($output); + $buffer .= $output; + if (preg_match('/built in [^\r\n]+[\r\n]/', $buffer)) { + $buffer = ''; + try { + $publish(); + } catch (InvalidExtensionException $exception) { + $this->components->error($exception->getMessage()); + } + } + + $buffer = mb_substr($buffer, -8192); + }); + + $this->trap([SIGINT, SIGTERM], function () use ($process): void { + $process->signal(SIGTERM); + }); + + return $process->wait()->exitCode() ?? self::FAILURE; + } finally { + $assets->stopDevelopment($manifest->id); + } + } + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/DisableCommand.php b/app/Console/Commands/Extensions/DisableCommand.php new file mode 100644 index 000000000..3098053f5 --- /dev/null +++ b/app/Console/Commands/Extensions/DisableCommand.php @@ -0,0 +1,31 @@ +setEnabled($this->argument('id'), false); + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + $this->components->info(sprintf('Extension "%s" disabled.', $this->argument('id'))); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/DoctorCommand.php b/app/Console/Commands/Extensions/DoctorCommand.php new file mode 100644 index 000000000..47f074d78 --- /dev/null +++ b/app/Console/Commands/Extensions/DoctorCommand.php @@ -0,0 +1,44 @@ +fromDirectory($this->argument('path')); + $compatibility->assertCompatible($manifest, $extensions->configuredEnabled()); + throw_if($reason = $assets->unusableBuildReason($manifest), InvalidExtensionException::class, $reason); + foreach ($manifest->autoload as $directory) { + throw_unless(is_dir($manifest->path($directory)), InvalidExtensionException::class, "Autoload directory \"{$directory}\" is missing."); + } + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + foreach ($icons->unknownIcons($manifest) as $icon) { + $this->components->warn("Navigation icon \"{$icon}\" is not a lucide icon this panel ships; the default icon is shown instead."); + } + + $this->components->info("{$manifest->id} v{$manifest->version}: manifest, compatibility, autoload directories, and build passed."); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/EnableCommand.php b/app/Console/Commands/Extensions/EnableCommand.php new file mode 100644 index 000000000..920b667af --- /dev/null +++ b/app/Console/Commands/Extensions/EnableCommand.php @@ -0,0 +1,31 @@ +setEnabled($this->argument('id'), true); + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + $this->components->info(sprintf('Extension "%s" enabled.', $this->argument('id'))); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/InstallCommand.php b/app/Console/Commands/Extensions/InstallCommand.php new file mode 100644 index 000000000..19949f764 --- /dev/null +++ b/app/Console/Commands/Extensions/InstallCommand.php @@ -0,0 +1,39 @@ +install($this->argument('path'), (bool) $this->option('enable')); + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + $this->components->info(sprintf( + 'Installed %s (%s) v%s%s.', + $manifest->name, + $manifest->id, + $manifest->version, + $this->option('enable') ? ' - enabled' : ' - enable it with p:extension:enable '.$manifest->id, + )); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/ListCommand.php b/app/Console/Commands/Extensions/ListCommand.php new file mode 100644 index 000000000..acdc1a4bd --- /dev/null +++ b/app/Console/Commands/Extensions/ListCommand.php @@ -0,0 +1,54 @@ +records(); + + $rows = $manager->discovered()->map(function (ExtensionManifest $manifest) use ($records): array { + $record = $records->get($manifest->id); + + $state = match (true) { + $record === null => 'not registered', + $record->enabled => 'enabled', + default => 'disabled', + }; + + return [ + $manifest->id, + $manifest->name, + $manifest->version, + $manifest->hasUi() ? 'yes' : 'no', + $state, + $record->error ?? '', + ]; + })->values()->all(); + + foreach ($manager->discoveryErrors() as $directory => $error) { + $rows[] = [$directory, '(invalid manifest)', '', '', 'error', $error]; + } + + if (empty($rows)) { + $this->components->info('No extensions installed. Install one with p:extension:install.'); + + return self::SUCCESS; + } + + $this->table(['ID', 'Name', 'Version', 'UI', 'State', 'Error'], $rows); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/MakeCommand.php b/app/Console/Commands/Extensions/MakeCommand.php new file mode 100644 index 000000000..b9e27bfab --- /dev/null +++ b/app/Console/Commands/Extensions/MakeCommand.php @@ -0,0 +1,68 @@ +scaffold( + id: $this->argument('id'), + name: $this->option('name'), + description: $this->option('description'), + author: $this->option('author'), + ui: ! $this->option('no-ui'), + outDir: $this->option('out'), + force: (bool) $this->option('force'), + prefix: $this->option('prefix'), + ); + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + $this->components->info("Extension scaffolded at {$target}."); + + foreach ($scaffolder->files() as $file) { + $this->components->twoColumnDetail($file, 'created'); + } + + $this->line(''); + $this->components->info('Next steps:'); + $this->components->bulletList(array_filter([ + $this->option('no-ui') ? null : "cd {$target} && npm install && npm run build", + "php artisan p:extension:install {$target} --enable", + ])); + + return self::SUCCESS; + } + + /** @return array> */ + protected function promptForMissingArgumentsUsing(): array + { + return [ + 'id' => ['What should the extension be identified as?', 'E.g. my-extension'], + ]; + } +} diff --git a/app/Console/Commands/Extensions/PackCommand.php b/app/Console/Commands/Extensions/PackCommand.php new file mode 100644 index 000000000..96a05851e --- /dev/null +++ b/app/Console/Commands/Extensions/PackCommand.php @@ -0,0 +1,73 @@ +fromDirectory($this->argument('path')); + throw_if($reason = $assets->unusableBuildReason($manifest), InvalidExtensionException::class, $reason); + $output = $this->option('output') ?: getcwd().DIRECTORY_SEPARATOR.$manifest->id.'-'.$manifest->version.'.pteroext'; + throw_if(is_file($output) && ! $this->option('force'), InvalidExtensionException::class, 'Archive exists; pass --force to overwrite it.'); + File::ensureDirectoryExists(dirname($output)); + $temporary = dirname($output).DIRECTORY_SEPARATOR.'.extension-'.Str::uuid(); + $zip = new ZipArchive; + $opened = false; + try { + throw_unless($zip->open($temporary, ZipArchive::CREATE | ZipArchive::EXCL) === true, InvalidExtensionException::class, 'Unable to open archive.'); + $opened = true; + throw_unless($zip->addFile($manifest->path(ExtensionManifest::FILENAME), ExtensionManifest::FILENAME), InvalidExtensionException::class, 'Unable to add extension manifest to archive.'); + $directories = array_unique(['routes', 'database', 'resources', 'dist', 'vendor', ...array_values($manifest->autoload)]); + foreach ($directories as $directory) { + if (! is_dir($manifest->path($directory))) { + continue; + } + + foreach (File::allFiles($manifest->path($directory)) as $file) { + if ($file->isLink() || array_any(explode('/', str_replace('\\', '/', $file->getRelativePathname())), fn (string $part): bool => str_starts_with($part, '.') || in_array($part, ['node_modules', 'tests', 'test', 'coverage'], true))) { + continue; + } + + $relative = $directory.'/'.$file->getRelativePathname(); + throw_unless($zip->addFile($file->getPathname(), $relative), InvalidExtensionException::class, "Unable to add {$relative} to archive."); + } + } + + throw_unless($zip->close(), InvalidExtensionException::class, 'Unable to finish archive.'); + $opened = false; + throw_unless(File::move($temporary, $output), InvalidExtensionException::class, 'Unable to save archive.'); + } finally { + if ($opened) { + $zip->close(); + } + + File::delete($temporary); + } + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + $this->components->info("Packaged {$manifest->id}: {$output}"); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/RemoveCommand.php b/app/Console/Commands/Extensions/RemoveCommand.php new file mode 100644 index 000000000..31b63d199 --- /dev/null +++ b/app/Console/Commands/Extensions/RemoveCommand.php @@ -0,0 +1,40 @@ +argument('id'); + + if ($this->input->isInteractive() && ! $this->confirm("Remove extension \"{$id}\"? Its files and published assets are deleted.")) { + return self::SUCCESS; + } + + try { + $installer->remove($id); + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + $this->components->info(sprintf( + 'Extension "%s" removed. Database tables it created and its settings were left in place.', + $id, + )); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Extensions/TypesCommand.php b/app/Console/Commands/Extensions/TypesCommand.php new file mode 100644 index 000000000..98b1a31e8 --- /dev/null +++ b/app/Console/Commands/Extensions/TypesCommand.php @@ -0,0 +1,57 @@ +fromDirectory($this->argument('path')); + $definition = $settings->get($manifest->id); + $names = array_map(fn (array $screen): string => json_encode($screen['id'], JSON_THROW_ON_ERROR), $manifest->screens); + $properties = []; + foreach ($definition?->frontendConfigTypes() ?? [] as $name => $type) { + $typescript = match ($type) { + 'array' => 'readonly ExtensionConfigValue[]', + 'object' => 'Readonly>', + 'json' => 'ExtensionConfigValue', + default => $type, + }; + $properties[] = ' readonly '.json_encode($name, JSON_THROW_ON_ERROR).': '.$typescript.';'; + } + + $source = "// Generated by p:extension:types. Do not edit.\nimport type { ExtensionConfig as SdkExtensionConfig, ExtensionConfigValue } from '@pterodactyl/sdk';\n\n"; + $source .= 'export type ExtensionId = '.json_encode($manifest->id, JSON_THROW_ON_ERROR).";\n"; + $source .= 'export type ExtensionScreenId = '.($names === [] ? 'never' : implode(' | ', $names)).";\n"; + $permissionNames = array_map(fn (string $key): string => json_encode('ext.'.$manifest->id.'.'.$key, JSON_THROW_ON_ERROR), array_keys($permissions->all()[ExtensionPermissionRegistry::group($manifest->id)]['keys'] ?? [])); + $source .= 'export type ExtensionPermission = '.($permissionNames === [] ? 'never' : implode(' | ', $permissionNames)).";\n"; + $source .= "export interface ExtensionConfig extends SdkExtensionConfig {\n".implode("\n", $properties)."\n}\n"; + $publicNames = array_map(fn (string $name): string => json_encode($name, JSON_THROW_ON_ERROR), $definition?->publicConfigKeys() ?? []); + $source .= "// Visitors who are not signed in receive only these keys; every other key is absent for them.\n"; + $source .= 'export type ExtensionPublicConfigKey = '.($publicNames === [] ? 'never' : implode(' | ', $publicNames)).";\n"; + $source .= "export type ExtensionPublicConfig = Pick;\n"; + $output = $this->option('output') ?: $manifest->path('src', 'client', 'extension-types.ts'); + File::ensureDirectoryExists(dirname($output)); + File::replace($output, $source); + if (! $definition instanceof ExtensionSettingsDefinition) { + $this->components->warn('No settings definition is loaded; enable the extension to include declared frontend configuration keys.'); + } + + $this->components->info("Generated extension types: {$output}"); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/InfoCommand.php b/app/Console/Commands/InfoCommand.php index 25c774405..546e04a0d 100644 --- a/app/Console/Commands/InfoCommand.php +++ b/app/Console/Commands/InfoCommand.php @@ -1,21 +1,21 @@ output->title('Version Information'); $this->table([], [ @@ -35,8 +35,8 @@ class InfoCommand extends Command $this->output->title('Application Configuration'); $this->table([], [ - ['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')], - ['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', !$this->config->get('app.debug') ?: 'bg=red')], + ['Environment', $this->formatText(JsonValueGuard::string($this->config->get('app.env')), $this->config->get('app.env') === 'production' ? '' : 'bg=red')], + ['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', $this->config->get('app.debug') ? 'bg=red' : '')], ['Installation URL', $this->config->get('app.url')], ['Installation Directory', base_path()], ['Timezone', $this->config->get('app.timezone')], @@ -49,7 +49,7 @@ class InfoCommand extends Command ], 'compact'); $this->output->title('Database Configuration'); - $driver = $this->config->get('database.default'); + $driver = JsonValueGuard::string($this->config->get('database.default')); $this->table([], [ ['Driver', $driver], ['Host', $this->config->get("database.connections.$driver.host")], @@ -76,6 +76,10 @@ class InfoCommand extends Command */ private function formatText(string $value, string $opts = ''): string { + if ($opts === '') { + return $value; + } + return sprintf('<%s>%s', $opts, $value); } } diff --git a/app/Console/Commands/Location/DeleteLocationCommand.php b/app/Console/Commands/Location/DeleteLocationCommand.php index ae9d11915..8bab2d4d4 100644 --- a/app/Console/Commands/Location/DeleteLocationCommand.php +++ b/app/Console/Commands/Location/DeleteLocationCommand.php @@ -1,55 +1,48 @@ */ + protected Collection $allLocations; /** * Respond to the command request. * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException + * @throws HasActiveNodesException */ - public function handle() + public function handle(DeletesLocations $locations): void { - $this->locations = $this->locations ?? $this->repository->all(); + $this->allLocations ??= Location::all(); $short = $this->option('short') ?? $this->anticipate( trans('command/messages.location.ask_short'), - $this->locations->pluck('short')->toArray() + $this->allLocations->pluck('short')->toArray() ); - $location = $this->locations->where('short', $short)->first(); - if (is_null($location)) { + $location = $this->allLocations->where('short', $short)->first(); + if ($location === null) { $this->error(trans('command/messages.location.no_location_found')); if ($this->input->isInteractive()) { - $this->handle(); + $this->handle($locations); } return; } - $this->deletionService->handle($location->id); + $locations->delete($location); $this->line(trans('command/messages.location.deleted')); } } diff --git a/app/Console/Commands/Location/MakeLocationCommand.php b/app/Console/Commands/Location/MakeLocationCommand.php index f09f1604e..5e21020bf 100644 --- a/app/Console/Commands/Location/MakeLocationCommand.php +++ b/app/Console/Commands/Location/MakeLocationCommand.php @@ -1,40 +1,49 @@ option('short') ?? $this->ask(trans('command/messages.location.ask_short')); $long = $this->option('long') ?? $this->ask(trans('command/messages.location.ask_long')); - $location = $this->creationService->handle(compact('short', 'long')); + $validator = Validator::make(['short' => $short, 'long' => $long], LocationRules::rules()); + if ($validator->fails()) { + foreach ($validator->errors()->all() as $error) { + $this->error($error); + } + + return 1; + } + + $location = $locations->create([ + 'short' => JsonValueGuard::string($short), + 'long' => JsonValueGuard::nullableString($long), + ]); $this->line(trans('command/messages.location.created', [ 'name' => $location->short, 'id' => $location->id, ])); + + return 0; } } diff --git a/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php b/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php index 5530014bb..5dd279b1a 100644 --- a/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php +++ b/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php @@ -1,19 +1,21 @@ disk->files('services/.bak'); - collect($files)->each(function (\SplFileInfo $file) { - $lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath())); - if ((int) $lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) { - $this->disk->delete($file->getPath()); - $this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file->getFilename()])); + collect($files)->each(function (string $file): void { + $lastModified = Date::createFromTimestamp($this->disk->lastModified($file)); + if ($lastModified->diffInMinutes(now()) > self::BACKUP_THRESHOLD_MINUTES) { + $this->disk->delete($file); + $this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => basename($file)])); } }); } diff --git a/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php b/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php index b7a04f8ee..522570b79 100644 --- a/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php +++ b/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php @@ -1,44 +1,38 @@ option('prune-age') ?? config('backups.prune_age', 360); - if (!$since || !is_digit($since)) { - throw new \InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.'); - } + $minutes = filter_var($since, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); + throw_if($minutes === false, InvalidArgumentException::class, 'The "--prune-age" argument must be a value greater than 0.'); - $query = $this->backupRepository->getBuilder() + $query = Backup::query() ->whereNull('completed_at') - ->where('created_at', '<=', CarbonImmutable::now()->subMinutes($since)->toDateTimeString()); + ->where('created_at', '<=', CarbonImmutable::now()->subMinutes($minutes)->toDateTimeString()); $count = $query->count(); - if (!$count) { + if (! $count) { $this->info('There are no orphaned backups to be marked as failed.'); return; } - $this->warn("Marking $count uncompleted backups that are older than $since minutes as failed."); + $this->warn("Marking $count uncompleted backups that are older than $minutes minutes as failed."); $query->update([ 'is_successful' => false, diff --git a/app/Console/Commands/Node/MakeNodeCommand.php b/app/Console/Commands/Node/MakeNodeCommand.php index 2d2623ad7..98efe4287 100644 --- a/app/Console/Commands/Node/MakeNodeCommand.php +++ b/app/Console/Commands/Node/MakeNodeCommand.php @@ -1,13 +1,20 @@ option('name') ?? $this->ask('Enter a short identifier used to distinguish this node from others'); - $data['description'] = $this->option('description') ?? $this->ask('Enter a description to identify the node'); - $data['location_id'] = $this->option('locationId') ?? $this->ask('Enter a valid location id'); - $data['scheme'] = $this->option('scheme') ?? $this->anticipate( - 'Please either enter https for SSL or http for a non-ssl connection', - ['https', 'http'], - 'https' - ); - $data['fqdn'] = $this->option('fqdn') ?? $this->ask('Enter a domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node'); - $data['public'] = $this->option('public') ?? $this->confirm('Should this node be public? As a note, setting a node to private you will be denying the ability to auto-deploy to this node.', true); - $data['behind_proxy'] = $this->option('proxy') ?? $this->confirm('Is your FQDN behind a proxy?'); - $data['maintenance_mode'] = $this->option('maintenance') ?? $this->confirm('Should maintenance mode be enabled?'); - $data['memory'] = $this->option('maxMemory') ?? $this->ask('Enter the maximum amount of memory'); - $data['memory_overallocate'] = $this->option('overallocateMemory') ?? $this->ask('Enter the amount of memory to over allocate by, -1 will disable checking and 0 will prevent creating new servers'); - $data['disk'] = $this->option('maxDisk') ?? $this->ask('Enter the maximum amount of disk space'); - $data['disk_overallocate'] = $this->option('overallocateDisk') ?? $this->ask('Enter the amount of memory to over allocate by, -1 will disable checking and 0 will prevent creating new server'); - $data['upload_size'] = $this->option('uploadSize') ?? $this->ask('Enter the maximum filesize upload', '100'); - $data['daemonListen'] = $this->option('daemonListeningPort') ?? $this->ask('Enter the wings listening port', '8080'); - $data['daemonSFTP'] = $this->option('daemonSFTPPort') ?? $this->ask('Enter the wings SFTP listening port', '2022'); - $data['daemonBase'] = $this->option('daemonBase') ?? $this->ask('Enter the base folder', '/var/lib/pterodactyl/volumes'); + $input = [ + 'name' => $this->option('name') ?? $this->ask('Enter a short identifier used to distinguish this node from others'), + 'description' => $this->option('description') ?? $this->ask('Enter a description to identify the node'), + 'location_id' => $this->option('locationId') ?? $this->ask('Enter a valid location id'), + 'scheme' => $this->option('scheme') ?? $this->anticipate( + 'Please either enter https for SSL or http for a non-ssl connection', + ['https', 'http'], + 'https' + ), + 'fqdn' => $this->option('fqdn') ?? $this->ask('Enter a domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node'), + 'public' => $this->option('public') ?? $this->confirm('Should this node be public? As a note, setting a node to private you will be denying the ability to auto-deploy to this node.', true), + 'behind_proxy' => $this->option('proxy') ?? $this->confirm('Is your FQDN behind a proxy?'), + 'maintenance_mode' => $this->option('maintenance') ?? $this->confirm('Should maintenance mode be enabled?'), + 'memory' => $this->option('maxMemory') ?? $this->ask('Enter the maximum amount of memory'), + 'memory_overallocate' => $this->option('overallocateMemory') ?? $this->ask('Enter the amount of memory to over allocate by, -1 will disable checking and 0 will prevent creating new servers'), + 'disk' => $this->option('maxDisk') ?? $this->ask('Enter the maximum amount of disk space'), + 'disk_overallocate' => $this->option('overallocateDisk') ?? $this->ask('Enter the amount of memory to over allocate by, -1 will disable checking and 0 will prevent creating new server'), + 'upload_size' => $this->option('uploadSize') ?? $this->ask('Enter the maximum filesize upload', '100'), + 'daemonListen' => $this->option('daemonListeningPort') ?? $this->ask('Enter the wings listening port', '8080'), + 'daemonSFTP' => $this->option('daemonSFTPPort') ?? $this->ask('Enter the wings SFTP listening port', '2022'), + 'daemonBase' => $this->option('daemonBase') ?? $this->ask('Enter the base folder', '/var/lib/pterodactyl/volumes'), + ]; + JsonValueGuard::assertScalarPayload($input); - $node = $this->creationService->handle($data); - $this->line('Successfully created a new node on the location ' . $data['location_id'] . ' with the name ' . $data['name'] . ' and has an id of ' . $node->id . '.'); + $data = [ + 'name' => $this->stringInput($input['name']), + 'description' => $this->stringInput($input['description']), + 'location_id' => $this->integerInput($input['location_id']), + 'scheme' => $this->stringInput($input['scheme']), + 'fqdn' => $this->stringInput($input['fqdn']), + 'public' => $this->booleanInput($input['public']), + 'behind_proxy' => $this->booleanInput($input['behind_proxy']), + 'maintenance_mode' => $this->booleanInput($input['maintenance_mode']), + 'memory' => $this->integerInput($input['memory']), + 'memory_overallocate' => $this->integerInput($input['memory_overallocate']), + 'disk' => $this->integerInput($input['disk']), + 'disk_overallocate' => $this->integerInput($input['disk_overallocate']), + 'upload_size' => $this->integerInput($input['upload_size']), + 'daemonListen' => $this->integerInput($input['daemonListen']), + 'daemonSFTP' => $this->integerInput($input['daemonSFTP']), + 'daemonBase' => $this->stringInput($input['daemonBase']), + ]; + + $validator = Validator::make($data, NodeRules::rules()); + if ($validator->fails()) { + foreach ($validator->errors()->all() as $error) { + $this->error($error); + } + + return 1; + } + + $node = $nodes->create($data); + $this->line('Successfully created a new node on the location '.$data['location_id'].' with the name '.$data['name'].' and has an id of '.$node->id.'.'); + + return 0; + } + + /** @param ApiScalar $value */ + private function stringInput(bool|float|int|string|null $value): string + { + throw_if(! is_string($value) && ! is_numeric($value), InvalidArgumentException::class, 'Expected a string console input.'); + + // SAFETY: the guards above reject arrays and objects before console input is converted. + return (string) $value; + } + + /** @param ApiScalar $value */ + private function integerInput(bool|float|int|string|null $value): int + { + $integer = filter_var($value, FILTER_VALIDATE_INT); + throw_if($integer === false, InvalidArgumentException::class, 'Expected an integer console input.'); + + return $integer; + } + + /** @param ApiScalar $value */ + private function booleanInput(bool|float|int|string|null $value): bool + { + $boolean = filter_var($value, FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE); + throw_if($boolean === null, InvalidArgumentException::class, 'Expected a boolean console input.'); + + return $boolean; } } diff --git a/app/Console/Commands/Node/NodeConfigurationCommand.php b/app/Console/Commands/Node/NodeConfigurationCommand.php index 83a25720b..b20e322f5 100644 --- a/app/Console/Commands/Node/NodeConfigurationCommand.php +++ b/app/Console/Commands/Node/NodeConfigurationCommand.php @@ -1,31 +1,34 @@ argument('node')) ? 'id' : 'uuid'; + $argument = $this->argument('node'); + $column = ctype_digit($argument) ? 'id' : 'uuid'; - /** @var Node $node */ - $node = Node::query()->where($column, $this->argument('node'))->firstOr(function () { + $node = Node::query()->where($column, $argument)->first(); + if ($node === null) { $this->error('The selected node does not exist.'); - exit(1); - }); + return 1; + } $format = $this->option('format'); - if (!in_array($format, ['yaml', 'yml', 'json'])) { + if (! in_array($format, ['yaml', 'yml', 'json'])) { $this->error('Invalid format specified. Valid options are "yaml" and "json".'); return 1; diff --git a/app/Console/Commands/Node/NodeListCommand.php b/app/Console/Commands/Node/NodeListCommand.php index 718ddd0d2..771b42a07 100644 --- a/app/Console/Commands/Node/NodeListCommand.php +++ b/app/Console/Commands/Node/NodeListCommand.php @@ -1,30 +1,30 @@ with('location')->get()->map(function (Node $node) { - return [ - 'id' => $node->id, - 'uuid' => $node->uuid, - 'name' => $node->name, - 'location' => $node->location->short, - 'host' => $node->getConnectionAddress(), - ]; - }); + $nodes = Node::query()->with('location')->get()->map(fn (Node $node): array => [ + 'id' => $node->id, + 'uuid' => $node->uuid, + 'name' => $node->name, + 'location' => $node->location->short, + 'host' => $node->getConnectionAddress(), + ]); if ($this->option('format') === 'json') { $this->output->write($nodes->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } else { - $this->table(['ID', 'UUID', 'Name', 'Location', 'Host'], $nodes->toArray()); + $this->table(['ID', 'UUID', 'Name', 'Location', 'Host'], $nodes->all()); } $this->output->newLine(); diff --git a/app/Console/Commands/Overrides/KeyGenerateCommand.php b/app/Console/Commands/Overrides/KeyGenerateCommand.php index bc8a4edb6..fe03d12b3 100644 --- a/app/Console/Commands/Overrides/KeyGenerateCommand.php +++ b/app/Console/Commands/Overrides/KeyGenerateCommand.php @@ -1,5 +1,7 @@ input->isInteractive()) { + if (! empty(config('app.key')) && $this->input->isInteractive()) { $this->output->warning('It appears you have already configured an application encryption key. Continuing with this process with overwrite that key and cause data corruption for any existing encrypted data. DO NOT CONTINUE UNLESS YOU KNOW WHAT YOU ARE DOING.'); - if (!$this->confirm('I understand the consequences of performing this command and accept all responsibility for the loss of encrypted data.')) { + if (! $this->confirm('I understand the consequences of performing this command and accept all responsibility for the loss of encrypted data.')) { return; } - if (!$this->confirm('Are you sure you wish to continue? Changing the application encryption key WILL CAUSE DATA LOSS.')) { + if (! $this->confirm('Are you sure you wish to continue? Changing the application encryption key WILL CAUSE DATA LOSS.')) { return; } } diff --git a/app/Console/Commands/Overrides/SeedCommand.php b/app/Console/Commands/Overrides/SeedCommand.php index 7b7b5edb7..4a2cb3422 100644 --- a/app/Console/Commands/Overrides/SeedCommand.php +++ b/app/Console/Commands/Overrides/SeedCommand.php @@ -1,9 +1,11 @@ hasCompletedMigrations()) { + if (! $this->hasCompletedMigrations()) { $this->showMigrationWarning(); return 1; diff --git a/app/Console/Commands/Overrides/UpCommand.php b/app/Console/Commands/Overrides/UpCommand.php index 0a7caaeb7..8a8baaea7 100644 --- a/app/Console/Commands/Overrides/UpCommand.php +++ b/app/Console/Commands/Overrides/UpCommand.php @@ -1,9 +1,11 @@ hasCompletedMigrations()) { + if (! $this->hasCompletedMigrations()) { $this->showMigrationWarning(); return 1; diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index 70fd4d0c7..1645177bb 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -1,26 +1,29 @@ with('tasks') + ->with(['tasks', 'server.node']) ->whereRelation('server', fn (Builder $builder) => $builder->whereNull('status')) ->where('is_active', true) ->where('is_processing', false) @@ -53,23 +56,23 @@ class ProcessRunnableCommand extends Command * * @see https://github.com/pterodactyl/panel/issues/2609 */ - protected function processSchedule(Schedule $schedule) + protected function processSchedule(Schedule $schedule): void { if ($schedule->tasks->isEmpty()) { return; } try { - $this->getLaravel()->make(ProcessScheduleService::class)->handle($schedule); + $this->getLaravel()->make(ProcessesSchedules::class)->process($schedule); $this->line(trans('command/messages.schedule.output_line', [ 'schedule' => $schedule->name, 'hash' => $schedule->hashid, ])); - } catch (\Throwable $exception) { - Log::error($exception, ['schedule_id' => $schedule->id]); + } catch (Throwable $throwable) { + Log::error($throwable->getMessage(), ['exception' => $throwable, 'schedule_id' => $schedule->id]); - $this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage()); + $this->error("An error was encountered while processing Schedule #$schedule->id: ".$throwable->getMessage()); } } } diff --git a/app/Console/Commands/Server/BulkPowerActionCommand.php b/app/Console/Commands/Server/BulkPowerActionCommand.php index 01a5f3c71..f521ab1c4 100644 --- a/app/Console/Commands/Server/BulkPowerActionCommand.php +++ b/app/Console/Commands/Server/BulkPowerActionCommand.php @@ -1,53 +1,47 @@ argument('action'); $nodes = empty($this->option('nodes')) ? [] : explode(',', $this->option('nodes')); $servers = empty($this->option('servers')) ? [] : explode(',', $this->option('servers')); - $validator = $this->validator->make([ + $validator = $validators->make([ 'action' => $action, 'nodes' => $nodes, 'servers' => $servers, ], [ - 'action' => 'string|in:start,stop,kill,restart', - 'nodes' => 'array', - 'nodes.*' => 'integer|min:1', - 'servers' => 'array', - 'servers.*' => 'integer|min:1', + 'action' => ['string', 'in:start,stop,kill,restart'], + 'nodes' => ['array'], + 'nodes.*' => ['integer', 'min:1'], + 'servers' => ['array'], + 'servers.*' => ['integer', 'min:1'], ]); if ($validator->fails()) { @@ -59,23 +53,22 @@ class BulkPowerActionCommand extends Command } $count = $this->getQueryBuilder($servers, $nodes)->count(); - if (!$this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count])) && $this->input->isInteractive()) { + if ($this->input->isInteractive() && ! $this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count]))) { return; } $bar = $this->output->createProgressBar($count); - $powerRepository = $this->powerRepository; - $this->getQueryBuilder($servers, $nodes)->each(function (Server $server) use ($action, $powerRepository, &$bar) { + $this->getQueryBuilder($servers, $nodes)->each(function (Server $server) use ($action, &$bar): void { $bar->clear(); try { - $powerRepository->setServer($server)->send($action); - } catch (DaemonConnectionException $exception) { + Daemon::server($server)->power($action); + } catch (DaemonConnectionException $daemonConnectionException) { $this->output->error(trans('command/messages.server.power.action_failed', [ 'name' => $server->name, 'id' => $server->id, 'node' => $server->node->name, - 'message' => $exception->getMessage(), + 'message' => $daemonConnectionException->getMessage(), ])); } @@ -88,16 +81,20 @@ class BulkPowerActionCommand extends Command /** * Returns the query builder instance that will return the servers that should be affected. + * + * @param list $servers + * @param list $nodes + * @return Builder */ protected function getQueryBuilder(array $servers, array $nodes): Builder { $instance = Server::query()->whereNull('status'); - if (!empty($nodes) && !empty($servers)) { - $instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes); - } elseif (empty($nodes) && !empty($servers)) { + if ($servers !== [] && $nodes !== []) { + $instance->where(fn (Builder $targets): Builder => $targets->whereIn('id', $servers)->orWhereIn('node_id', $nodes)); + } elseif ($servers !== []) { $instance->whereIn('id', $servers); - } elseif (!empty($nodes) && empty($servers)) { // @phpstan-ignore empty.variable + } elseif ($nodes !== []) { $instance->whereIn('node_id', $nodes); } diff --git a/app/Console/Commands/TelemetryCommand.php b/app/Console/Commands/TelemetryCommand.php index 3e1b0c2f8..891296772 100644 --- a/app/Console/Commands/TelemetryCommand.php +++ b/app/Console/Commands/TelemetryCommand.php @@ -1,34 +1,26 @@ output->info('Collecting telemetry data, this may take a while...'); - VarDumper::dump($this->telemetryCollectionService->collect()); + VarDumper::dump($telemetryCollectionService->collect()); } } diff --git a/app/Console/Commands/Themes/ApplyCommand.php b/app/Console/Commands/Themes/ApplyCommand.php new file mode 100644 index 000000000..2e49ec547 --- /dev/null +++ b/app/Console/Commands/Themes/ApplyCommand.php @@ -0,0 +1,31 @@ +apply($this->argument('id')); + } catch (InvalidExtensionException $invalidExtensionException) { + $this->components->error($invalidExtensionException->getMessage()); + + return self::FAILURE; + } + + $this->components->info(sprintf('Theme "%s" applied. Reload the panel to see it.', $this->argument('id'))); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Themes/ListCommand.php b/app/Console/Commands/Themes/ListCommand.php new file mode 100644 index 000000000..11c9f9a59 --- /dev/null +++ b/app/Console/Commands/Themes/ListCommand.php @@ -0,0 +1,37 @@ + [$theme['id'], $theme['name'], $theme['version']], + array_values($themes->discovered()), + ); + + if ($rows === []) { + $this->components->info('No themes installed. Drop one into '.$themes->directory().'.'); + } else { + $this->table(['ID', 'Name', 'Version'], $rows); + } + + $this->components->info( + is_file($themes->publishedStylesheet()) + ? 'A theme is currently applied (public/assets/theme.css).' + : 'No theme applied - the panel uses its stock tokens.', + ); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/Themes/ResetCommand.php b/app/Console/Commands/Themes/ResetCommand.php new file mode 100644 index 000000000..14cac5d24 --- /dev/null +++ b/app/Console/Commands/Themes/ResetCommand.php @@ -0,0 +1,24 @@ +reset(); + + $this->components->info('Theme removed - the panel is back on its stock tokens.'); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/UpgradeCommand.php b/app/Console/Commands/UpgradeCommand.php index 735427690..1e48f5cdc 100644 --- a/app/Console/Commands/UpgradeCommand.php +++ b/app/Console/Commands/UpgradeCommand.php @@ -1,24 +1,31 @@ option('skip-download'); - if (!$skipDownload) { + if (! $skipDownload) { $this->output->warning('This command does not verify the integrity of downloaded assets. Please ensure that you trust the download source before continuing. If you do not wish to download an archive, please indicate that using the --skip-download flag, or answering "no" to the question below.'); $this->output->comment('Download Source (set with --url=):'); $this->line($this->getUrl()); } - if (version_compare(PHP_VERSION, '8.2.0', '<')) { - $this->error('Cannot execute self-upgrade process. The minimum required PHP version required is 8.2.0, you have [' . PHP_VERSION . '].'); - } - - $user = 'www-data'; - $group = 'www-data'; + $userOption = $this->option('user'); + $groupOption = $this->option('group'); + $user = $userOption === null ? 'www-data' : JsonValueGuard::string($userOption); + $group = $groupOption === null ? 'www-data' : JsonValueGuard::string($groupOption); if ($this->input->isInteractive()) { - if (!$skipDownload) { - $skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true); + if (! $skipDownload) { + $skipDownload = ! $this->confirm('Would you like to download and unpack the archive files for the latest version?', true); } - if (is_null($this->option('user'))) { - $userDetails = posix_getpwuid(fileowner('public')); - $user = $userDetails['name'] ?? 'www-data'; + if (($this->option('user')) === null) { + $ownerId = fileowner('public'); + $userDetails = $ownerId !== false ? posix_getpwuid($ownerId) : false; + $user = $userDetails !== false ? $userDetails['name'] : 'www-data'; - if (!$this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) { - $user = $this->anticipate( + if (! $this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) { + $user = JsonValueGuard::string($this->anticipate( 'Please enter the name of the user running your webserver process. This varies from system to system, but is generally "www-data", "nginx", or "apache".', [ 'www-data', 'nginx', 'apache', ] - ); + )); } } - if (is_null($this->option('group'))) { - $groupDetails = posix_getgrgid(filegroup('public')); - $group = $groupDetails['name'] ?? 'www-data'; + if (($this->option('group')) === null) { + $groupId = filegroup('public'); + $groupDetails = $groupId !== false ? posix_getgrgid($groupId) : false; + $group = $groupDetails !== false ? $groupDetails['name'] : 'www-data'; - if (!$this->confirm("Your webserver group has been detected as [{$group}]: is this correct?", true)) { - $group = $this->anticipate( + if (! $this->confirm("Your webserver group has been detected as [{$group}]: is this correct?", true)) { + $group = JsonValueGuard::string($this->anticipate( 'Please enter the name of the group running your webserver process. Normally this is the same as your user.', [ 'www-data', 'nginx', 'apache', ] - ); + )); } } - if (!$this->confirm('Are you sure you want to run the upgrade process for your Panel?')) { + if (! $this->confirm('Are you sure you want to run the upgrade process for your Panel?')) { $this->warn('Upgrade process terminated by user.'); - return; + return self::SUCCESS; } } - ini_set('output_buffering', '0'); $bar = $this->output->createProgressBar($skipDownload ? 9 : 10); $bar->start(); - if (!$skipDownload) { - $this->withProgress($bar, function () { - $this->line("\$upgrader> curl -L \"{$this->getUrl()}\" | tar -xzv"); - $process = Process::fromShellCommandline("curl -L \"{$this->getUrl()}\" | tar -xzv"); - $process->run(function ($type, $buffer) { - $this->{$type === Process::ERR ? 'error' : 'line'}($buffer); - }); - }); + $this->withProgress($bar, fn () => $this->runArtisan('down')); + + if (! $skipDownload) { + $this->withProgress($bar, fn () => $this->download($files)); } - $this->withProgress($bar, function () { - $this->line('$upgrader> php artisan down'); - $this->call('down'); - }); + $this->withProgress($bar, fn () => $this->runProcess(['chmod', '-R', '755', 'storage', 'bootstrap/cache'])); - $this->withProgress($bar, function () { - $this->line('$upgrader> chmod -R 755 storage bootstrap/cache'); - $process = new Process(['chmod', '-R', '755', 'storage', 'bootstrap/cache']); - $process->run(function ($type, $buffer) { - $this->{$type === Process::ERR ? 'error' : 'line'}($buffer); - }); - }); - - $this->withProgress($bar, function () { + $this->withProgress($bar, function (): void { $command = ['composer', 'install', '--no-ansi']; - if (config('app.env') === 'production' && !config('app.debug')) { + if ($this->getLaravel()->isProduction() && ! config('app.debug')) { $command[] = '--optimize-autoloader'; $command[] = '--no-dev'; } - $this->line('$upgrader> ' . implode(' ', $command)); - $process = new Process($command); - $process->setTimeout(10 * 60); - $process->run(function ($type, $buffer) { - $this->line($buffer); - }); + $this->runProcess($command); }); - /** @var \Illuminate\Foundation\Application $app */ - $app = require __DIR__ . '/../../../bootstrap/app.php'; - /** @var Kernel $kernel */ - $kernel = $app->make(Kernel::class); - $kernel->bootstrap(); - $this->setLaravel($app); - - $this->withProgress($bar, function () { - $this->line('$upgrader> php artisan view:clear'); - $this->call('view:clear'); - }); - - $this->withProgress($bar, function () { - $this->line('$upgrader> php artisan config:clear'); - $this->call('config:clear'); - }); - - $this->withProgress($bar, function () { - $this->line('$upgrader> php artisan migrate --force --seed'); - $this->call('migrate', ['--force' => true, '--seed' => true]); - }); - - $this->withProgress($bar, function () use ($user, $group) { - $this->line("\$upgrader> chown -R {$user}:{$group} *"); - $process = Process::fromShellCommandline("chown -R {$user}:{$group} *", $this->getLaravel()->basePath()); - $process->setTimeout(10 * 60); - $process->run(function ($type, $buffer) { - $this->{$type === Process::ERR ? 'error' : 'line'}($buffer); - }); - }); - - $this->withProgress($bar, function () { - $this->line('$upgrader> php artisan queue:restart'); - $this->call('queue:restart'); - }); - - $this->withProgress($bar, function () { - $this->line('$upgrader> php artisan up'); - $this->call('up'); - }); + $this->withProgress($bar, fn () => $this->runArtisan('view:clear')); + $this->withProgress($bar, fn () => $this->runArtisan('config:clear')); + $this->withProgress($bar, fn () => $this->runArtisan('migrate', ['--force', '--seed'])); + $this->withProgress($bar, fn () => $this->runProcess(['chown', '-R', "{$user}:{$group}", $this->getLaravel()->basePath()])); + $this->withProgress($bar, fn () => $this->runArtisan('queue:restart')); + $this->withProgress($bar, fn () => $this->runArtisan('up')); $this->newLine(2); - $this->info('Panel has been successfully upgraded. Please ensure you also update any Wings instances: https://pterodactyl.io/wings/1.0/upgrading.html'); + $this->info('Panel has been successfully upgraded. Please ensure you also update any Wings instances: https://pterodactyl.io/docs/v2/wings/upgrading'); + + return self::SUCCESS; } - protected function withProgress(ProgressBar $bar, \Closure $callback) + protected function withProgress(ProgressBar $bar, Closure $callback): void { $bar->clear(); $callback(); @@ -190,6 +144,36 @@ class UpgradeCommand extends Command return $this->option('url'); } - return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download'); + return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v'.$this->option('release') : 'latest/download'); + } + + private function download(FilesystemChanges $files): void + { + $directory = storage_path('app/.upgrade-'.Str::uuid()); + throw_unless(File::makeDirectory($directory, 0700, true), Exception::class, 'Unable to create a temporary upgrade directory.'); + $archive = $directory.DIRECTORY_SEPARATOR.'panel.tar.gz'; + + try { + $this->runProcess(['curl', '--fail', '--location', '--output', $archive, $this->getUrl()]); + $this->runProcess(['tar', '-xzvf', $archive, '--directory', $this->getLaravel()->basePath()]); + } finally { + rescue(fn () => $files->delete($directory)); + } + } + + /** @param list $arguments */ + private function runArtisan(string $command, array $arguments = []): void + { + $this->runProcess([PHP_BINARY, 'artisan', $command, '--no-interaction', ...$arguments]); + } + + /** @param list $command */ + private function runProcess(array $command): void + { + $this->line('$upgrader> '.implode(' ', $command)); + Process::path($this->getLaravel()->basePath()) + ->timeout(10 * 60) + ->run($command, fn (string $type, string $output) => $this->output->write($output)) + ->throw(); } } diff --git a/app/Console/Commands/User/DeleteUserCommand.php b/app/Console/Commands/User/DeleteUserCommand.php index 2b13b4866..36b1f9e91 100644 --- a/app/Console/Commands/User/DeleteUserCommand.php +++ b/app/Console/Commands/User/DeleteUserCommand.php @@ -1,30 +1,29 @@ option('user') ?? $this->ask(trans('command/messages.user.search_users')); - Assert::notEmpty($search, 'Search term should be an email address, got: %s.'); + if (empty($search)) { + throw new InvalidArgumentException(sprintf('Search term should be an email address, got: %s.', get_debug_type($search))); + } + + $search = JsonValueGuard::string($search); $results = User::query() ->where('id', 'LIKE', "$search%") @@ -35,7 +34,7 @@ class DeleteUserCommand extends Command if (count($results) < 1) { $this->error(trans('command/messages.user.no_users_found')); if ($this->input->isInteractive()) { - return $this->handle(); + return $this->handle($users); } return 1; @@ -48,8 +47,8 @@ class DeleteUserCommand extends Command } $this->table(['User ID', 'Email', 'Name'], $tableValues); - if (!$deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) { - return $this->handle(); + if (! $deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) { + return $this->handle($users); } } else { if (count($results) > 1) { @@ -61,8 +60,9 @@ class DeleteUserCommand extends Command $deleteUser = $results->first(); } - if ($this->confirm(trans('command/messages.user.confirm_delete')) || !$this->input->isInteractive()) { - $this->deletionService->handle($deleteUser); + if ($this->confirm(trans('command/messages.user.confirm_delete')) || ! $this->input->isInteractive()) { + $user = $deleteUser instanceof User ? $deleteUser : User::query()->findOrFail(JsonValueGuard::integer($deleteUser)); + $users->delete($user); $this->info(trans('command/messages.user.deleted')); } diff --git a/app/Console/Commands/User/DisableTwoFactorCommand.php b/app/Console/Commands/User/DisableTwoFactorCommand.php index 052220114..0d6d2f293 100644 --- a/app/Console/Commands/User/DisableTwoFactorCommand.php +++ b/app/Console/Commands/User/DisableTwoFactorCommand.php @@ -1,43 +1,35 @@ input->isInteractive()) { $this->output->warning(trans('command/messages.user.2fa_help_text')); } $email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email')); - $user = $this->repository->setColumns(['id', 'email'])->findFirstWhere([['email', '=', $email]]); - $this->repository->withoutFreshModel()->update($user->id, [ + $user = User::query()->where('email', $email)->firstOrFail(); + $user->update([ 'use_totp' => false, 'totp_secret' => null, ]); + $this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email])); } } diff --git a/app/Console/Commands/User/MakeUserCommand.php b/app/Console/Commands/User/MakeUserCommand.php index 635a95646..270b95d71 100644 --- a/app/Console/Commands/User/MakeUserCommand.php +++ b/app/Console/Commands/User/MakeUserCommand.php @@ -1,31 +1,29 @@ option('admin') ?? $this->confirm(trans('command/messages.user.ask_admin')); $email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email')); @@ -33,13 +31,37 @@ class MakeUserCommand extends Command $name_first = $this->option('name-first') ?? $this->ask(trans('command/messages.user.ask_name_first')); $name_last = $this->option('name-last') ?? $this->ask(trans('command/messages.user.ask_name_last')); - if (is_null($password = $this->option('password')) && !$this->option('no-password')) { + if (($password = $this->option('password')) === null && ! $this->option('no-password')) { $this->warn(trans('command/messages.user.ask_password_help')); $this->line(trans('command/messages.user.ask_password_tip')); $password = $this->secret(trans('command/messages.user.ask_password')); } - $user = $this->creationService->handle(compact('email', 'username', 'name_first', 'name_last', 'password', 'root_admin')); + $data = ['email' => $email, 'username' => $username, 'name_first' => $name_first, 'name_last' => $name_last, 'password' => $password, 'root_admin' => $root_admin]; + + $validator = Validator::make($data, UserRules::rules()); + if ($validator->fails()) { + foreach ($validator->errors()->all() as $error) { + $this->error($error); + } + + return 1; + } + + $user = $users->create([ + 'email' => JsonValueGuard::string($email), + 'username' => JsonValueGuard::string($username), + 'name_first' => JsonValueGuard::string($name_first), + 'name_last' => JsonValueGuard::string($name_last), + 'password' => JsonValueGuard::nullableString($password), + 'root_admin' => filter_var($root_admin, FILTER_VALIDATE_BOOL), + ]); + + Activity::event('user:user.create') + ->subject($user) + ->property(['email' => $user->email, 'username' => $user->username, 'admin' => $user->root_admin]) + ->log(); + $this->table(['Field', 'Value'], [ ['UUID', $user->uuid], ['Email', $user->email], @@ -47,5 +69,7 @@ class MakeUserCommand extends Command ['Name', $user->name], ['Admin', $user->root_admin ? 'Yes' : 'No'], ]); + + return 0; } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php deleted file mode 100644 index 56343297c..000000000 --- a/app/Console/Kernel.php +++ /dev/null @@ -1,76 +0,0 @@ -load(__DIR__ . '/Commands'); - } - - /** - * Define the application's command schedule. - */ - protected function schedule(Schedule $schedule): void - { - // https://laravel.com/docs/10.x/upgrade#redis-cache-tags - $schedule->command('cache:prune-stale-tags')->hourly(); - - // Execute scheduled commands for servers every minute, as if there was a normal cron running. - $schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping(); - $schedule->command(CleanServiceBackupFilesCommand::class)->daily(); - - if (config('backups.prune_age')) { - // Every 30 minutes, run the backup pruning command so that any abandoned backups can be deleted. - $schedule->command(PruneOrphanedBackupsCommand::class)->everyThirtyMinutes(); - } - - if (config('activity.prune_days')) { - $schedule->command(PruneCommand::class, ['--model' => [ActivityLog::class]])->daily(); - } - - if (config('pterodactyl.telemetry.enabled')) { - $this->registerTelemetry($schedule); - } - } - - /** - * I wonder what this does. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Illuminate\Contracts\Container\BindingResolutionException - */ - private function registerTelemetry(Schedule $schedule): void - { - $settingsRepository = app()->make(SettingsRepository::class); - - $uuid = $settingsRepository->get('app:telemetry:uuid'); - if (is_null($uuid)) { - $uuid = Uuid::uuid4()->toString(); - $settingsRepository->set('app:telemetry:uuid', $uuid); - } - - // Calculate a fixed time to run the data push at, this will be the same time every day. - $time = hexdec(str_replace('-', '', substr($uuid, 27))) % 1440; - $hour = floor($time / 60); - $minute = $time % 60; - - // Run the telemetry collector. - $schedule->call(app()->make(TelemetryCollectionService::class))->description('Collect Telemetry')->dailyAt("$hour:$minute"); - } -} diff --git a/app/Console/RequiresDatabaseMigrations.php b/app/Console/RequiresDatabaseMigrations.php index 2e5ebe6b2..02b730f48 100644 --- a/app/Console/RequiresDatabaseMigrations.php +++ b/app/Console/RequiresDatabaseMigrations.php @@ -1,9 +1,14 @@ getLaravel()->make('migrator'); + $migrator = $this->getLaravel()->make(Migrator::class); $files = $migrator->getMigrationFiles(database_path('migrations')); - if (!$migrator->repositoryExists()) { + if (! $migrator->repositoryExists()) { return false; } - if (array_diff(array_keys($files), $migrator->getRepository()->getRan())) { - return false; - } - - return true; + return ! array_diff(array_keys($files), $migrator->getRepository()->getRan()); } /** diff --git a/app/Console/Scheduler.php b/app/Console/Scheduler.php new file mode 100644 index 000000000..d4f0fe436 --- /dev/null +++ b/app/Console/Scheduler.php @@ -0,0 +1,71 @@ +command('cache:prune-stale-tags')->hourly(); + + // Execute scheduled commands for servers every minute, as if there was a normal cron running. + $schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping(60)->onOneServer(); + $schedule->command(CleanServiceBackupFilesCommand::class)->daily()->withoutOverlapping(); + + if (config('backups.prune_age')) { + // Every 30 minutes, run the backup pruning command so that any abandoned backups can be deleted. + $schedule->command(PruneOrphanedBackupsCommand::class)->everyThirtyMinutes()->withoutOverlapping(); + } + + if (config('activity.prune_days')) { + $schedule->command(PruneCommand::class, ['--model' => [ActivityLog::class]])->daily()->withoutOverlapping(); + } + + if (config('pterodactyl.telemetry.enabled')) { + $this->scheduleTelemetry($schedule); + } + } + + /** + * Push telemetry daily at a time derived from the install uuid. + */ + private function scheduleTelemetry(Schedule $schedule): void + { + try { + $uuid = Setting::fetch('app:telemetry:uuid'); + } catch (QueryException) { + return; + } + + if ($uuid === null) { + try { + $uuid = Uuid::uuid4()->toString(); + Setting::put('app:telemetry:uuid', $uuid); + } catch (QueryException) { + return; + } + } + + $time = hexdec(str_replace('-', '', mb_substr($uuid, 27))) % 1440; + $hour = intdiv($time, 60); + $minute = $time % 60; + + $schedule->call(static function (SendsTelemetry $telemetry): void { + $telemetry->send(); + })->description('Collect Telemetry')->dailyAt(sprintf('%02d:%02d', $hour, $minute))->withoutOverlapping(); + } +} diff --git a/app/Contracts/Activity/IngestsActivityLogs.php b/app/Contracts/Activity/IngestsActivityLogs.php new file mode 100644 index 000000000..f82628692 --- /dev/null +++ b/app/Contracts/Activity/IngestsActivityLogs.php @@ -0,0 +1,13 @@ +|null $allowedIps */ + public function create(User $user, ?string $description, ?array $allowedIps): NewAccessToken; +} diff --git a/app/Contracts/Api/CreatesApiKeys.php b/app/Contracts/Api/CreatesApiKeys.php new file mode 100644 index 000000000..10ce6f9d2 --- /dev/null +++ b/app/Contracts/Api/CreatesApiKeys.php @@ -0,0 +1,16 @@ + $permissions The r_* ACL columns, only applied to application keys. + */ + public function create(int $keyType, array $data, array $permissions = []): ApiKey; +} diff --git a/app/Contracts/Backups/CompletesBackups.php b/app/Contracts/Backups/CompletesBackups.php new file mode 100644 index 000000000..79d460278 --- /dev/null +++ b/app/Contracts/Backups/CompletesBackups.php @@ -0,0 +1,18 @@ +|null $ignored */ + public function setIgnoredFiles(?array $ignored): self; + + public function initiate(Server $server, ?string $name = null, bool $override = false): Backup; +} diff --git a/app/Contracts/Backups/PresignsBackupUploads.php b/app/Contracts/Backups/PresignsBackupUploads.php new file mode 100644 index 000000000..4f11ccabf --- /dev/null +++ b/app/Contracts/Backups/PresignsBackupUploads.php @@ -0,0 +1,16 @@ + $order */ + public function reorder(Egg $egg, array $order): void; +} diff --git a/app/Contracts/Eggs/UpdatesEggInstallScripts.php b/app/Contracts/Eggs/UpdatesEggInstallScripts.php new file mode 100644 index 000000000..c85bfaf21 --- /dev/null +++ b/app/Contracts/Eggs/UpdatesEggInstallScripts.php @@ -0,0 +1,20 @@ + + */ + public function replace(ExtensionSettingsDefinition $definition, string $input, ?UploadedFile $upload): array; +} diff --git a/app/Contracts/Extensions/SetsExtensionEnabled.php b/app/Contracts/Extensions/SetsExtensionEnabled.php new file mode 100644 index 000000000..58983aad9 --- /dev/null +++ b/app/Contracts/Extensions/SetsExtensionEnabled.php @@ -0,0 +1,12 @@ + + */ + public function update(ExtensionSettingsDefinition $definition, array $settings): array; +} diff --git a/app/Contracts/Files/ChangesFilePermissions.php b/app/Contracts/Files/ChangesFilePermissions.php new file mode 100644 index 000000000..c187e6465 --- /dev/null +++ b/app/Contracts/Files/ChangesFilePermissions.php @@ -0,0 +1,13 @@ + $files */ + public function change(Server $server, ?string $root, array $files): void; +} diff --git a/app/Contracts/Files/CompressesFiles.php b/app/Contracts/Files/CompressesFiles.php new file mode 100644 index 000000000..9d5cd1ca5 --- /dev/null +++ b/app/Contracts/Files/CompressesFiles.php @@ -0,0 +1,16 @@ + $files + * @return DaemonFileObject + */ + public function compress(Server $server, ?string $root, array $files): array; +} diff --git a/app/Contracts/Files/CopiesFiles.php b/app/Contracts/Files/CopiesFiles.php new file mode 100644 index 000000000..50c101b55 --- /dev/null +++ b/app/Contracts/Files/CopiesFiles.php @@ -0,0 +1,12 @@ + $files */ + public function delete(Server $server, ?string $root, array $files): void; +} diff --git a/app/Contracts/Files/ListsDirectories.php b/app/Contracts/Files/ListsDirectories.php new file mode 100644 index 000000000..9c2d38cda --- /dev/null +++ b/app/Contracts/Files/ListsDirectories.php @@ -0,0 +1,18 @@ + + * + * @throws DaemonConnectionException + */ + public function list(Server $server, string $directory = '/'): array; +} diff --git a/app/Contracts/Files/PullsFiles.php b/app/Contracts/Files/PullsFiles.php new file mode 100644 index 000000000..de8a2f2d7 --- /dev/null +++ b/app/Contracts/Files/PullsFiles.php @@ -0,0 +1,13 @@ + $options */ + public function pull(Server $server, string $url, ?string $directory, array $options): void; +} diff --git a/app/Contracts/Files/ReadsFileContents.php b/app/Contracts/Files/ReadsFileContents.php new file mode 100644 index 000000000..08d875f50 --- /dev/null +++ b/app/Contracts/Files/ReadsFileContents.php @@ -0,0 +1,21 @@ + $files */ + public function rename(Server $server, ?string $root, array $files): void; +} diff --git a/app/Contracts/Files/WritesFileContents.php b/app/Contracts/Files/WritesFileContents.php new file mode 100644 index 000000000..8cf2a211f --- /dev/null +++ b/app/Contracts/Files/WritesFileContents.php @@ -0,0 +1,12 @@ + $builder + */ + public function whereIdentifier(Builder $builder, string $identifier): void; } diff --git a/app/Contracts/Nodes/CreatesNodes.php b/app/Contracts/Nodes/CreatesNodes.php new file mode 100644 index 000000000..01f45a794 --- /dev/null +++ b/app/Contracts/Nodes/CreatesNodes.php @@ -0,0 +1,17 @@ + $data + * + * @throws Throwable + * @throws DisplayException + * @throws ValidationException + * @throws NoViableNodeException + * @throws NoViableAllocationException + */ + public function create(array $data, ?DeploymentObject $deployment = null): Server; +} diff --git a/app/Contracts/Servers/DeletesServers.php b/app/Contracts/Servers/DeletesServers.php new file mode 100644 index 000000000..61da302ff --- /dev/null +++ b/app/Contracts/Servers/DeletesServers.php @@ -0,0 +1,20 @@ + + * + * @throws DaemonConnectionException + */ + public function read(Server $server, int $lines = self::MAX_LINES): array; +} diff --git a/app/Contracts/Servers/ReadsServerState.php b/app/Contracts/Servers/ReadsServerState.php new file mode 100644 index 000000000..9d891dea2 --- /dev/null +++ b/app/Contracts/Servers/ReadsServerState.php @@ -0,0 +1,21 @@ + $permissions The permission keys to grant, deduplicated + * before they are stored. + * + * @throws ServerSubuserExistsException + * @throws UserIsServerOwnerException + * @throws Throwable + */ + public function create(Server $server, string $email, array $permissions): Subuser; +} diff --git a/app/Contracts/Subusers/DeletesSubusers.php b/app/Contracts/Subusers/DeletesSubusers.php new file mode 100644 index 000000000..f1ec01f33 --- /dev/null +++ b/app/Contracts/Subusers/DeletesSubusers.php @@ -0,0 +1,19 @@ + $permissions + * + * @throws Throwable + */ + public function update(Server $server, Subuser $subuser, array $permissions): Subuser; +} diff --git a/app/Contracts/Tags/SyncsTags.php b/app/Contracts/Tags/SyncsTags.php new file mode 100644 index 000000000..25f0f4a2d --- /dev/null +++ b/app/Contracts/Tags/SyncsTags.php @@ -0,0 +1,20 @@ + $values */ + public function syncEgg(Egg $egg, array $values): void; + + /** @param list $values */ + public function syncNodeGames(Node $node, array $values): void; + + /** @param list $values */ + public function syncNodeDeployments(Node $node, array $values): void; +} diff --git a/app/Contracts/Telemetry/SendsTelemetry.php b/app/Contracts/Telemetry/SendsTelemetry.php new file mode 100644 index 000000000..d750c7347 --- /dev/null +++ b/app/Contracts/Telemetry/SendsTelemetry.php @@ -0,0 +1,10 @@ + $additionalAllocations + * + * @throws DisplayException + * @throws Throwable + */ + public function initiate(Server $server, Node $node, int $allocationId, array $additionalAllocations): ServerTransfer; +} diff --git a/app/Contracts/Users/CompletesLogins.php b/app/Contracts/Users/CompletesLogins.php new file mode 100644 index 000000000..2a8a85f20 --- /dev/null +++ b/app/Contracts/Users/CompletesLogins.php @@ -0,0 +1,37 @@ + The plaintext recovery tokens generated for the account, + * empty when 2FA is being turned off. + * + * @throws Throwable + * @throws IncompatibleWithGoogleAuthenticatorException + * @throws InvalidCharactersException + * @throws SecretKeyTooShortException + * @throws TwoFactorAuthenticationTokenInvalid + */ + public function toggle(User $user, string $token, ?bool $toggleState = null): array; +} diff --git a/app/Contracts/Users/UpdatesUserEmails.php b/app/Contracts/Users/UpdatesUserEmails.php new file mode 100644 index 000000000..cb552b859 --- /dev/null +++ b/app/Contracts/Users/UpdatesUserEmails.php @@ -0,0 +1,15 @@ + */ + public static function listFromJson(string $contents): array + { + try { + $data = JsonValueGuard::decodeArray8($contents); + } catch (JsonException|UnexpectedValueException $exception) { + throw new HttpException(502, 'Pterodactyl returned an invalid egg catalog. Please try again later.', $exception); + } + + throw_unless(array_is_list($data), HttpException::class, 502, 'Pterodactyl returned an invalid egg catalog. Please try again later.'); + + $entries = []; + foreach ($data as $value) { + $entry = self::fromValue($value); + if ($entry instanceof self) { + $entries[] = $entry; + } + } + + throw_if($data !== [] && $entries === [], HttpException::class, 502, 'Pterodactyl returned an invalid egg catalog. Please try again later.'); + + return $entries; + } + + /** @param JsonInputValue $value */ + public static function fromValue(mixed $value): ?self + { + if (! is_array($value) || ! is_string($value['id'] ?? null) || ! is_string($value['name'] ?? null) + || ! is_string($value['downloadUrl'] ?? null) || $value['id'] === '' || $value['name'] === '') { + return null; + } + + return new self( + $value['id'], + $value['name'], + is_string($value['description'] ?? null) ? $value['description'] : '', + is_string($value['category'] ?? null) ? $value['category'] : '', + $value['downloadUrl'], + ); + } + + public function downloadUrl(): string + { + try { + $uri = new Uri($this->downloadUrl); + } catch (InvalidArgumentException $invalidArgumentException) { + throw new HttpException(502, 'The catalog egg has an invalid download URL.', $invalidArgumentException); + } + + throw_if($uri->getScheme() !== 'https' || $uri->getHost() !== 'raw.githubusercontent.com' + || ! str_starts_with($uri->getPath(), '/pterodactyl/') || $uri->getUserInfo() !== '' + || $uri->getPort() !== null || $uri->getQuery() !== '' || $uri->getFragment() !== '', HttpException::class, 502, 'The catalog egg does not have an official Pterodactyl download URL.'); + + return $uri->__toString(); + } + + /** @return array{id: string, name: string, description: string, category: string, source_url: string} */ + public function toArray(): array + { + return [ + 'id' => $this->id, + 'name' => $this->name, + 'description' => $this->description, + 'category' => $this->category, + 'source_url' => 'https://eggs.pterodactyl.io/egg/'.rawurlencode($this->id), + ]; + } +} diff --git a/app/Data/Extensions/ExtensionJobSnapshot.php b/app/Data/Extensions/ExtensionJobSnapshot.php new file mode 100644 index 000000000..6ecc1fb2f --- /dev/null +++ b/app/Data/Extensions/ExtensionJobSnapshot.php @@ -0,0 +1,44 @@ + $this->id, + 'extension' => $this->extension, + 'status' => $this->status, + 'percent' => $this->percent, + 'message' => $this->message, + 'sequence' => $this->sequence, + 'updated_at' => $this->updatedAt, + ]; + } +} diff --git a/app/Data/LoginCheckpoint.php b/app/Data/LoginCheckpoint.php new file mode 100644 index 000000000..fe0b19d81 --- /dev/null +++ b/app/Data/LoginCheckpoint.php @@ -0,0 +1,46 @@ +addMinutes(self::LIFETIME_MINUTES)); + } + + /** + * Whether a value read back from the session is a checkpoint that can + * still be confirmed. Anything else is treated as if none had been issued. + * + * @phpstan-assert-if-true self $value + */ + public static function isPending(mixed $value): bool + { + return $value instanceof self && ! $value->expiresAt->isBefore(CarbonImmutable::now()); + } + + /** Compare a submitted confirmation token against this checkpoint in constant time. */ + public function matches(string $token): bool + { + return hash_equals($this->token, $token); + } +} diff --git a/app/Data/LoginResult.php b/app/Data/LoginResult.php new file mode 100644 index 000000000..64e571693 --- /dev/null +++ b/app/Data/LoginResult.php @@ -0,0 +1,52 @@ +token); + } + + /** + * The `data` payload the panel's login screens expect from a JSON login endpoint. + * + * @return array{complete: false, confirmation_token: string|null}|array{complete: true, intended: string, user: ApiPayload} + */ + public function toResponseData(): array + { + if (! $this->complete) { + return [ + 'complete' => false, + 'confirmation_token' => $this->confirmationToken, + ]; + } + + return [ + 'complete' => true, + 'intended' => $this->intended, + 'user' => $this->user->toVueObject(), + ]; + } +} diff --git a/app/Data/ServerCreationData.php b/app/Data/ServerCreationData.php new file mode 100644 index 000000000..313ad1746 --- /dev/null +++ b/app/Data/ServerCreationData.php @@ -0,0 +1,147 @@ + self::nullableString($value['external_id'] ?? null, 'external_id'), + 'name' => self::string($value['name'] ?? null, 'name'), + 'description' => self::nullableString($value['description'] ?? null, 'description'), + 'owner_id' => self::integer($value['owner_id'] ?? null, 'owner_id'), + 'egg_id' => self::integer($value['egg_id'] ?? null, 'egg_id'), + 'image' => self::string($value['image'] ?? null, 'image'), + 'startup' => self::string($value['startup'] ?? null, 'startup'), + 'environment' => self::environment($value['environment'] ?? []), + 'memory' => self::integer($value['memory'] ?? null, 'memory'), + 'swap' => self::integer($value['swap'] ?? null, 'swap'), + 'disk' => self::integer($value['disk'] ?? null, 'disk'), + 'io' => self::integer($value['io'] ?? null, 'io'), + 'cpu' => self::integer($value['cpu'] ?? null, 'cpu'), + 'threads' => self::nullableString($value['threads'] ?? null, 'threads'), + 'skip_scripts' => self::boolean($value['skip_scripts'] ?? false, 'skip_scripts'), + 'allocation_id' => self::nullableInteger($value['allocation_id'] ?? null, 'allocation_id'), + 'allocation_additional' => self::nullableIntegerList($value['allocation_additional'] ?? null, 'allocation_additional'), + 'start_on_completion' => self::boolean($value['start_on_completion'] ?? false, 'start_on_completion'), + 'database_limit' => self::nullableInteger($value['database_limit'] ?? null, 'database_limit'), + 'allocation_limit' => self::nullableInteger($value['allocation_limit'] ?? null, 'allocation_limit'), + 'backup_limit' => self::nullableInteger($value['backup_limit'] ?? null, 'backup_limit'), + 'oom_disabled' => self::nullableBoolean($value['oom_disabled'] ?? null, 'oom_disabled'), + ]; + } + + /** @param JsonInputValue $value */ + private static function string(mixed $value, string $key): string + { + if (! is_string($value)) { + throw self::invalid($key, 'a string'); + } + + return $value; + } + + /** @param JsonInputValue $value */ + private static function nullableString(mixed $value, string $key): ?string + { + return $value === null ? null : self::string($value, $key); + } + + /** @param JsonInputValue $value */ + private static function integer(mixed $value, string $key): int + { + if (is_int($value)) { + return $value; + } + + if (! is_string($value) || preg_match('/^-?\d+$/', $value) !== 1) { + throw self::invalid($key, 'an integer'); + } + + // SAFETY: the anchored decimal-integer pattern above proves this string has an integer representation. + return (int) $value; + } + + /** @param JsonInputValue $value */ + private static function nullableInteger(mixed $value, string $key): ?int + { + return $value === null ? null : self::integer($value, $key); + } + + /** @param JsonInputValue $value */ + private static function boolean(mixed $value, string $key): bool + { + return match ($value) { + true, 1, '1' => true, + false, 0, '0' => false, + default => throw self::invalid($key, 'a boolean'), + }; + } + + /** @param JsonInputValue $value */ + private static function nullableBoolean(mixed $value, string $key): ?bool + { + return $value === null ? null : self::boolean($value, $key); + } + + /** + * @param JsonInputValue $value + * @return array + */ + private static function environment(mixed $value): array + { + if (! is_array($value)) { + throw self::invalid('environment', 'an object of scalar values'); + } + + $environment = []; + foreach ($value as $key => $item) { + if (! is_string($key) || is_array($item) || $item instanceof JsonEmptyObject) { + throw self::invalid('environment', 'an object of scalar values'); + } + + $environment[$key] = $item; + } + + return $environment; + } + + /** + * @param JsonInputValue $value + * @return list|null + */ + private static function nullableIntegerList(mixed $value, string $key): ?array + { + if ($value === null) { + return null; + } + + if (! is_array($value) || ! array_is_list($value)) { + throw self::invalid($key, 'a list of integers'); + } + + $integers = []; + foreach ($value as $item) { + $integers[] = self::integer($item, $key); + } + + return $integers; + } + + private static function invalid(string $key, string $expected): UnexpectedValueException + { + return new UnexpectedValueException(sprintf('Validated server creation field "%s" must be %s.', $key, $expected)); + } +} diff --git a/app/Data/ServerState.php b/app/Data/ServerState.php new file mode 100644 index 000000000..4da28125b --- /dev/null +++ b/app/Data/ServerState.php @@ -0,0 +1,44 @@ +friendlyName()) === $slug) { + return $case; + } + } + + return null; + } + + /** + * The first case named by the given tag slugs, in declaration order, so a + * specific override (bedrock) wins over its umbrella (minecraft). + * + * @param string[] $slugs + */ + public static function caseFor(array $slugs): ?self + { + foreach (self::cases() as $case) { + if (in_array($case->value, $slugs, true)) { + return $case; + } + } + + return null; + } + + /** + * Every built-in tag as a presentation payload, for the frontend to decorate + * and auto-fill with. + * + * @return array + */ + public static function all(): array + { + return array_map(fn (self $case): array => [ + 'slug' => $case->value, + 'name' => $case->friendlyName(), + 'color' => $case->color(), + ], self::cases()); + } + + public function color(): string + { + return $this->meta()['color']; + } + + public function friendlyName(): string + { + return $this->meta()['name']; + } + + /** + * @return array{color: string, name: string} + */ + private function meta(): array + { + return match ($this) { + self::Srcds => ['color' => '#9AA0A6', 'name' => 'Source Engine'], + self::Bedrock => ['color' => '#7C6F58', 'name' => 'Minecraft: Bedrock'], + self::Minecraft => ['color' => '#5B8731', 'name' => 'Minecraft'], + self::Rust => ['color' => '#CD412B', 'name' => 'Rust'], + self::GarrysMod => ['color' => '#4B6F9C', 'name' => "Garry's Mod"], + self::Fivem => ['color' => '#F40552', 'name' => 'FiveM'], + self::Voice => ['color' => '#4C6EF5', 'name' => 'Voice Servers'], + }; + } +} diff --git a/app/Enum/JwtScope.php b/app/Enum/JwtScope.php index 210968977..f4dde9406 100644 --- a/app/Enum/JwtScope.php +++ b/app/Enum/JwtScope.php @@ -1,5 +1,7 @@ throttleKey(), function (Request $request) use ($case) { + $route = $request->route(); + throw_if($route === null, InvalidArgumentException::class, 'Expected an active route when applying a server resource limit.'); + + $server = $route->parameter('server'); + throw_unless($server instanceof Server, InvalidArgumentException::class, 'Expected route parameter [server] to be a server.'); + + return $case->limit()->by($server->uuid); + }); + } + } + public function throttleKey(): string { return mb_strtolower("api.client:server-resource:{$this->name}"); @@ -42,7 +59,7 @@ enum ResourceLimit public function limit(): Limit { - return match($this) { + return match ($this) { self::Backup => Limit::perMinutes(15, 3), self::Database => Limit::perMinute(2), self::FilePull => Limit::perMinutes(10, 5), @@ -51,15 +68,4 @@ enum ResourceLimit default => Limit::perMinute(2), }; } - - public static function boot(): void - { - foreach (self::cases() as $case) { - RateLimiter::for($case->throttleKey(), function (Request $request) use ($case) { - Assert::isInstanceOf($server = $request->route()->parameter('server'), Server::class); - - return $case->limit()->by($server->uuid); - }); - } - } } diff --git a/app/Events/ActivityLogged.php b/app/Events/ActivityLogged.php index ca9db7930..50d47d5f0 100644 --- a/app/Events/ActivityLogged.php +++ b/app/Events/ActivityLogged.php @@ -1,16 +1,16 @@ model->actor_id); + return $this->model->actor_id === null; } } diff --git a/app/Events/Auth/DirectLogin.php b/app/Events/Auth/DirectLogin.php index 99df4e100..1c5653761 100644 --- a/app/Events/Auth/DirectLogin.php +++ b/app/Events/Auth/DirectLogin.php @@ -1,13 +1,13 @@ getHeaders() : [], + JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES, + ); + } + + /** + * Render a validation failure as one envelope entry per message, each carrying the + * offending field and the rule that rejected it. + */ + public static function validation(ValidationException $exception): JsonResponse + { + $codes = self::validationRuleCodes($exception); + + $errors = []; + foreach ($exception->errors() as $field => $messages) { + throw_if(! is_string($field) || ! is_array($messages), UnexpectedValueException::class, 'Laravel returned malformed validation errors.'); + + foreach ($messages as $key => $message) { + throw_if(! is_int($key) || ! is_string($message), UnexpectedValueException::class, 'Laravel returned a malformed validation error message.'); + + $normalizedField = str_replace('.', '_', $field); + $meta = [ + 'source_field' => $field, + 'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', $codes[$normalizedField][$key] ?? ''), + ]; + + $converted = self::toArray($exception)['errors'][0]; + $converted['detail'] = $message; + $converted['meta'] = array_merge($converted['meta'] ?? [], $meta); + + $errors[] = $converted; + } + } + + return new JsonResponse(['errors' => $errors], $exception->status); + } + + /** + * The envelope for an exception; in debug mode it also carries the source + * location and argument-free traces of the exception and everything before it. + * + * @param ApiErrorOverride $override + * @return ApiErrorEnvelope + */ + public static function toArray(Throwable $e, array $override = []): array + { + $error = [ + 'code' => class_basename($e), + 'status' => (string) self::status($e), + 'detail' => $e instanceof HttpExceptionInterface || self::mappedStatus($e) !== null + ? $e->getMessage() + : 'An unexpected error was encountered while processing this request, please try again.', + ]; + + if ($e instanceof ModelNotFoundException || $e->getPrevious() instanceof ModelNotFoundException) { + // Show a nicer error message compared to the standard "No query results for model" + // response that is normally returned. If we are in debug mode this will get overwritten + // with a more specific error message to help narrow down things. + $error['detail'] = 'The requested resource could not be found on the server.'; + } + + if (config('app.debug')) { + $error = array_merge($error, [ + 'detail' => $e->getMessage(), + 'source' => [ + 'line' => $e->getLine(), + 'file' => str_replace(base_path(), '', $e->getFile()), + ], + 'meta' => [ + 'trace' => self::cleanTrace($e), + 'previous' => array_map(self::cleanTrace(...), self::extractPrevious($e)), + ], + ]); + } + + return ['errors' => [array_merge($error, $override)]]; + } + + private static function status(Throwable $e): int + { + if ($e instanceof HttpExceptionInterface) { + return $e->getStatusCode(); + } + + return self::mappedStatus($e) ?? 500; + } + + /** + * Exceptions that carry no HTTP status of their own but map to a fixed one. + */ + private static function mappedStatus(Throwable $e): ?int + { + return match (true) { + $e instanceof AuthenticationException => 401, + $e instanceof AuthorizationException => 403, + $e instanceof ValidationException, $e instanceof InvalidExtensionException => 422, + default => null, + }; + } + + /** + * Every exception that led to the given one being thrown, outermost first. + * + * @return list + */ + private static function extractPrevious(Throwable $e): array + { + $previous = []; + while ($value = $e->getPrevious()) { + $previous[] = $value; + $e = $value; + } + + return $previous; + } + + /** + * @return array> + */ + private static function validationRuleCodes(ValidationException $exception): array + { + $codes = []; + foreach ($exception->validator->failed() as $field => $reasons) { + throw_if(! is_string($field) || ! is_array($reasons), UnexpectedValueException::class, 'Laravel returned malformed failed validation rules.'); + + $cleaned = []; + foreach (array_keys($reasons) as $reason) { + throw_unless(is_string($reason), UnexpectedValueException::class, 'Laravel returned a malformed validation rule name.'); + + $cleaned[] = Str::snake($reason); + } + + $codes[str_replace('.', '_', $field)] = $cleaned; + } + + return $codes; + } + + /** @return list> */ + private static function cleanTrace(Throwable $exception): array + { + $cleaned = []; + foreach ($exception->getTrace() as $frame) { + $item = ['function' => $frame['function']]; + foreach (['file', 'line', 'class', 'type'] as $key) { + if (isset($frame[$key])) { + $item[$key] = $frame[$key]; + } + } + + $cleaned[] = $item; + } + + return $cleaned; + } +} diff --git a/app/Exceptions/AutoDeploymentException.php b/app/Exceptions/AutoDeploymentException.php deleted file mode 100644 index 20405fba2..000000000 --- a/app/Exceptions/AutoDeploymentException.php +++ /dev/null @@ -1,7 +0,0 @@ - + */ public function getHeaders(): array { return []; @@ -50,32 +58,32 @@ class DisplayException extends PterodactylException implements HttpExceptionInte public function render(Request $request): JsonResponse|RedirectResponse { if ($request->expectsJson()) { - return response()->json(Handler::toArray($this), $this->getStatusCode(), $this->getHeaders()); + return response()->json(ApiErrorResponse::toArray($this), $this->getStatusCode(), $this->getHeaders()); } - app(AlertsMessageBag::class)->danger($this->getMessage())->flash(); + Alert::danger($this->getMessage())->flash(); - return redirect()->back()->withInput(); + return back()->withInput(); } /** * Log the exception to the logs using the defined error level only if the previous * exception is set. - * - * @throws \Throwable */ - public function report() + public function report(): void { - if (!$this->getPrevious() instanceof \Exception || !Handler::isReportable($this->getPrevious())) { - return null; + $previous = $this->getPrevious(); + if (! $previous instanceof Throwable || ! Exceptions::shouldReport($previous)) { + return; } - try { - $logger = Container::getInstance()->make(LoggerInterface::class); - } catch (\Exception) { - throw $this->getPrevious(); - } + $context = ['exception' => $previous]; - return $logger->{$this->getErrorLevel()}($this->getPrevious()); + match ($this->getErrorLevel()) { + self::LEVEL_DEBUG => Log::debug($previous->getMessage(), $context), + self::LEVEL_INFO => Log::info($previous->getMessage(), $context), + self::LEVEL_WARNING => Log::warning($previous->getMessage(), $context), + default => Log::error($previous->getMessage(), $context), + }; } } diff --git a/app/Exceptions/Extensions/InvalidExtensionException.php b/app/Exceptions/Extensions/InvalidExtensionException.php new file mode 100644 index 000000000..7028e6b94 --- /dev/null +++ b/app/Exceptions/Extensions/InvalidExtensionException.php @@ -0,0 +1,9 @@ + 401, - AuthorizationException::class => 403, - ValidationException::class => 422, - ]; - - /** - * A list of the inputs that are never flashed for validation exceptions. - */ - protected $dontFlash = [ - 'token', - 'secret', - 'password', - 'password_confirmation', - ]; - - /** - * Registers the exception handling callbacks for the application. This - * will capture specific exception types that we do not want to include - * the detailed stack traces for since they could reveal credentials to - * whoever can read the logs. - * - * @noinspection PhpUnusedLocalVariableInspection - */ - public function register(): void - { - if (config('app.exceptions.report_all', false)) { - $this->dontReport = []; - } - - $this->reportable(function (\PDOException $ex) { - $ex = $this->generateCleanedExceptionStack($ex); - }); - - $this->reportable(function (TransportException $ex) { - $ex = $this->generateCleanedExceptionStack($ex); - }); - } - - private function generateCleanedExceptionStack(\Throwable $exception): string - { - $cleanedStack = ''; - foreach ($exception->getTrace() as $index => $item) { - $cleanedStack .= sprintf( - "#%d %s(%d): %s%s%s\n", - $index, - Arr::get($item, 'file'), - Arr::get($item, 'line'), - Arr::get($item, 'class'), - Arr::get($item, 'type'), - Arr::get($item, 'function') - ); - } - - $message = sprintf( - '%s: %s in %s:%d', - class_basename($exception), - $exception->getMessage(), - $exception->getFile(), - $exception->getLine() - ); - - return $message . "\nStack trace:\n" . trim($cleanedStack); - } - - /** - * Render an exception into an HTTP response. - * - * @param \Illuminate\Http\Request $request - * - * @throws \Throwable - */ - public function render($request, \Throwable $e): Response - { - $connections = $this->container->make(Connection::class); - - // If we are currently wrapped up inside a transaction, we will roll all the way - // back to the beginning. This needs to happen, otherwise session data does not - // get properly persisted. - // - // This is kind of a hack, and ideally things like this should be handled as - // much as possible at the code level, but there are a lot of spots that do a - // ton of actions and were written before this bug discovery was made. - // - // @see https://github.com/pterodactyl/panel/pull/1468 - if ($connections->transactionLevel()) { - $connections->rollBack(0); - } - - return parent::render($request, $e); - } - - /** - * Transform a validation exception into a consistent format to be returned for - * calls to the API. - * - * @param \Illuminate\Http\Request $request - */ - public function invalidJson($request, ValidationException $exception): JsonResponse - { - $codes = Collection::make($exception->validator->failed())->mapWithKeys(function ($reasons, $field) { - $cleaned = []; - foreach ($reasons as $reason => $attrs) { - $cleaned[] = Str::snake($reason); - } - - return [str_replace('.', '_', $field) => $cleaned]; - })->toArray(); - - $errors = Collection::make($exception->errors())->map(function ($errors, $field) use ($codes, $exception) { - $response = []; - foreach ($errors as $key => $error) { - $meta = [ - 'source_field' => $field, - 'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', Arr::get( - $codes, - str_replace('.', '_', $field) . '.' . $key - )), - ]; - - $converted = $this->convertExceptionToArray($exception)['errors'][0]; - $converted['detail'] = $error; - $converted['meta'] = array_merge($converted['meta'] ?? [], $meta); - - $response[] = $converted; - } - - return $response; - })->flatMap(function ($errors) { - return $errors; - })->toArray(); - - return response()->json(['errors' => $errors], $exception->status); - } - - /** - * Return the exception as a JSONAPI representation for use on API requests. - */ - protected function convertExceptionToArray(\Throwable $e, array $override = []): array - { - $match = self::$exceptionResponseCodes[get_class($e)] ?? null; - - $error = [ - 'code' => class_basename($e), - 'status' => method_exists($e, 'getStatusCode') - ? strval($e->getStatusCode()) - : strval($match ?? '500'), - 'detail' => $e instanceof HttpExceptionInterface || !is_null($match) - ? $e->getMessage() - : 'An unexpected error was encountered while processing this request, please try again.', - ]; - - if ($e instanceof ModelNotFoundException || $e->getPrevious() instanceof ModelNotFoundException) { - // Show a nicer error message compared to the standard "No query results for model" - // response that is normally returned. If we are in debug mode this will get overwritten - // with a more specific error message to help narrow down things. - $error['detail'] = 'The requested resource could not be found on the server.'; - } - - if (config('app.debug')) { - $error = array_merge($error, [ - 'detail' => $e->getMessage(), - 'source' => [ - 'line' => $e->getLine(), - 'file' => str_replace(Application::getInstance()->basePath(), '', $e->getFile()), - ], - 'meta' => [ - 'trace' => Collection::make($e->getTrace()) - ->map(fn ($trace) => Arr::except($trace, ['args'])) - ->all(), - 'previous' => Collection::make($this->extractPrevious($e)) - ->map(fn ($exception) => $e->getTrace()) - ->map(fn ($trace) => Arr::except($trace, ['args'])) - ->all(), - ], - ]); - } - - return ['errors' => [array_merge($error, $override)]]; - } - - /** - * Return an array of exceptions that should not be reported. - */ - public static function isReportable(\Exception $exception): bool - { - return (new self(Container::getInstance()))->shouldReport($exception); - } - - /** - * Convert an authentication exception into an unauthenticated response. - * - * @param \Illuminate\Http\Request $request - */ - protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse - { - if ($request->expectsJson()) { - return new JsonResponse($this->convertExceptionToArray($exception), JsonResponse::HTTP_UNAUTHORIZED); - } - - return redirect()->guest('/auth/login'); - } - - /** - * Extracts all the previous exceptions that lead to the one passed into this - * function being thrown. - * - * @return \Throwable[] - */ - protected function extractPrevious(\Throwable $e): array - { - $previous = []; - while ($value = $e->getPrevious()) { - if (!$value instanceof \Throwable) { // @phpstan-ignore instanceof.alwaysTrue - break; - } - $previous[] = $value; - $e = $value; - } - - return $previous; - } - - /** - * Helper method to allow reaching into the handler to convert an exception - * into the expected array response type. - */ - public static function toArray(\Throwable $e): array - { - return (new self(app()))->convertExceptionToArray($e); - } -} diff --git a/app/Exceptions/Http/Base/InvalidPasswordProvidedException.php b/app/Exceptions/Http/Base/InvalidPasswordProvidedException.php index bdcb8ec34..d0c40b432 100644 --- a/app/Exceptions/Http/Base/InvalidPasswordProvidedException.php +++ b/app/Exceptions/Http/Base/InvalidPasswordProvidedException.php @@ -1,9 +1,9 @@ getResponse() : null; - $this->requestId = $response?->getHeaderLine('X-Request-Id'); + $response ??= $previous instanceof RequestException ? $previous->response : null; + $this->requestId = $response?->header('X-Request-Id'); + $this->statusCode = $this->statusFor($response, $useStatusCode); + $level = $this->statusCode >= 500 && $this->statusCode !== Response::HTTP_GATEWAY_TIMEOUT + ? self::LEVEL_ERROR + : self::LEVEL_WARNING; - if ($useStatusCode) { - $this->statusCode = is_null($response) ? $this->statusCode : $response->getStatusCode(); - // There are rare conditions where wings encounters a panic condition and crashes the - // request being made after content has already been sent over the wire. In these cases - // you can end up with a "successful" response code that is actual an error. - // - // Handle those better here since we shouldn't ever end up in this exception state and - // be returning a 2XX level response. - if ($this->statusCode < 400) { - $this->statusCode = Response::HTTP_BAD_GATEWAY; - } - } - - if (is_null($response)) { - $message = 'Could not establish a connection to the machine running this server. Please try again.'; - } else { - $message = sprintf('There was an error while communicating with the machine running this server. This error has been logged, please try again. (code: %s) (request_id: %s)', $response->getStatusCode(), $this->requestId ?? ''); - } - - // Attempt to pull the actual error message off the response and return that if it is not - // a 500 level error. - if ($this->statusCode < 500 && !is_null($response)) { - $body = json_decode($response->getBody()->__toString(), true); - $message = sprintf('An error occurred on the remote host: %s. (request id: %s)', $body['error'] ?? $message, $this->requestId ?? ''); - } - - $level = $this->statusCode >= 500 && $this->statusCode !== 504 - ? DisplayException::LEVEL_ERROR - : DisplayException::LEVEL_WARNING; - - parent::__construct($message, $previous, $level); + parent::__construct($this->messageFor($response), $previous, $level); } - /** - * Override the default reporting method for DisplayException by just logging immediately - * here and including the specific X-Request-Id header that was returned by the call. - */ - public function report() + public function report(): void { - Log::{$this->getErrorLevel()}($this->getPrevious(), [ + Log::log($this->getErrorLevel(), $this->getPrevious()->getMessage(), [ 'request_id' => $this->requestId, + 'exception' => $this->getPrevious(), ]); } - /** - * Return the HTTP status code for this exception. - */ public function getStatusCode(): int { return $this->statusCode; @@ -87,4 +47,31 @@ class DaemonConnectionException extends DisplayException { return $this->requestId; } + + private function statusFor(?ClientResponse $response, bool $useStatusCode): int + { + if (! $useStatusCode || ! $response instanceof ClientResponse) { + return Response::HTTP_GATEWAY_TIMEOUT; + } + + // A truncated or malformed successful response is still an upstream failure. + return $response->status() < 400 ? Response::HTTP_BAD_GATEWAY : $response->status(); + } + + private function messageFor(?ClientResponse $response): string + { + if (! $response instanceof ClientResponse) { + return 'Could not establish a connection to the machine running this server. Please try again.'; + } + + $message = sprintf('There was an error while communicating with the machine running this server. This error has been logged, please try again. (code: %s) (request_id: %s)', $response->status(), $this->requestId ?? ''); + if ($this->statusCode >= 500) { + return $message; + } + + $body = $response->json(); + $remoteError = is_array($body) && is_string($body['error'] ?? null) ? $body['error'] : $message; + + return sprintf('An error occurred on the remote host: %s. (request id: %s)', $remoteError, $this->requestId ?? ''); + } } diff --git a/app/Exceptions/Http/HttpForbiddenException.php b/app/Exceptions/Http/HttpForbiddenException.php index 3fc8cb6d8..b5150cf32 100644 --- a/app/Exceptions/Http/HttpForbiddenException.php +++ b/app/Exceptions/Http/HttpForbiddenException.php @@ -1,16 +1,19 @@ isSuspended()) { $message = 'This server is currently suspended and the functionality requested is unavailable.'; } elseif ($server->node->isUnderMaintenance()) { $message = 'The node of this server is currently under maintenance and the functionality requested is unavailable.'; - } elseif (!$server->isInstalled()) { + } elseif (! $server->isInstalled()) { $message = 'This server has not yet completed its installation process, please try again later.'; } elseif ($server->status === Server::STATUS_RESTORING_BACKUP) { $message = 'This server is currently restoring from a backup, please try again later.'; - } elseif (!is_null($server->transfer)) { + } elseif (($server->transfer) !== null) { $message = 'This server is currently being transferred to a new machine, please try again later.'; } diff --git a/app/Exceptions/Http/TwoFactorAuthRequiredException.php b/app/Exceptions/Http/TwoFactorAuthRequiredException.php index 9689338c2..5f9d07f7b 100644 --- a/app/Exceptions/Http/TwoFactorAuthRequiredException.php +++ b/app/Exceptions/Http/TwoFactorAuthRequiredException.php @@ -1,17 +1,20 @@ getKey(), - $validator->errors()->toJson() - ); - - parent::__construct($message); - } - - /** - * Return the validator message bag. - */ - public function getMessageBag(): MessageBag - { - return $this->validator->errors(); - } - - /** - * Return the status code for this request. - */ - public function getStatusCode(): int - { - return 500; - } - - public function getHeaders(): array - { - return []; - } - - public function getValidator(): Validator - { - return $this->validator; - } - - public function getModel(): Model - { - return $this->model; - } -} diff --git a/app/Exceptions/PterodactylException.php b/app/Exceptions/PterodactylException.php index 451ae92cb..4230c3953 100644 --- a/app/Exceptions/PterodactylException.php +++ b/app/Exceptions/PterodactylException.php @@ -1,7 +1,9 @@ $port])); diff --git a/app/Exceptions/Service/Allocation/NoAutoAllocationSpaceAvailableException.php b/app/Exceptions/Service/Allocation/NoAutoAllocationSpaceAvailableException.php index 8e3c9b0a1..708d6dcae 100644 --- a/app/Exceptions/Service/Allocation/NoAutoAllocationSpaceAvailableException.php +++ b/app/Exceptions/Service/Allocation/NoAutoAllocationSpaceAvailableException.php @@ -1,5 +1,7 @@ 'https://github.com/pterodactyl/panel/blob/develop/package.json', - ]; - } -} diff --git a/app/Exceptions/Transformer/InvalidTransformerLevelException.php b/app/Exceptions/Transformer/InvalidTransformerLevelException.php index 3d4c24248..2470d811f 100644 --- a/app/Exceptions/Transformer/InvalidTransformerLevelException.php +++ b/app/Exceptions/Transformer/InvalidTransformerLevelException.php @@ -1,9 +1,9 @@ */ protected array $adapters = []; - /** - * The registered custom driver creators. - */ - protected array $customCreators; + /** @var array Registered custom driver creators. */ + protected array $customCreators = []; /** * BackupManager constructor. @@ -53,6 +55,76 @@ class BackupManager return $this; } + /** + * Creates a new Wings adapter. + * + * @param BackupDiskConfig $config + */ + public function createWingsAdapter(array $config): FilesystemAdapter + { + return new InMemoryFilesystemAdapter; + } + + /** + * Creates a new S3 adapter. + * + * @param S3BackupDiskConfig $config + */ + public function createS3Adapter(array $config): FilesystemAdapter + { + $config['version'] = 'latest'; + + if (! empty($config['key']) && ! empty($config['secret'])) { + $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']); + } + + $client = new S3Client($config); + + return new S3Filesystem($client, $config['bucket'], $config['prefix'] ?? '', $config['options'] ?? []); + } + + /** + * Get the default backup driver name. + */ + public function getDefaultAdapter(): string + { + return JsonValueGuard::string($this->config->get('backups.default')); + } + + /** + * Set the default session driver name. + */ + public function setDefaultAdapter(string $name): void + { + $this->config->set('backups.default', $name); + } + + /** + * Unset the given adapter instances. + * + * @param string|string[] $adapter + */ + public function forget(array|string $adapter): self + { + $adapters = is_string($adapter) ? [$adapter] : $adapter; + foreach ($adapters as $adapterName) { + unset($this->adapters[$adapterName]); + } + + return $this; + } + + /** + * Register a custom adapter creator closure. + */ + /** @param Closure(Application, BackupDiskConfig): FilesystemAdapter $callback */ + public function extend(string $adapter, Closure $callback): self + { + $this->customCreators[$adapter] = $callback; + + return $this; + } + /** * Gets a backup adapter. */ @@ -68,105 +140,93 @@ class BackupManager { $config = $this->getConfig($name); - if (empty($config['adapter'])) { - throw new \InvalidArgumentException("Backup disk [$name] does not have a configured adapter."); - } + throw_if(empty($config['adapter']), InvalidArgumentException::class, "Backup disk [$name] does not have a configured adapter."); $adapter = $config['adapter']; - if (isset($this->customCreators[$name])) { + if (isset($this->customCreators[$adapter])) { return $this->callCustomCreator($config); } - $adapterMethod = 'create' . Str::studly($adapter) . 'Adapter'; - if (method_exists($this, $adapterMethod)) { - $instance = $this->{$adapterMethod}($config); - - Assert::isInstanceOf($instance, FilesystemAdapter::class); - - return $instance; - } - - throw new \InvalidArgumentException("Adapter [$adapter] is not supported."); + return match ($adapter) { + 'wings' => $this->createWingsAdapter($config), + 's3' => $this->createS3Adapter($this->s3Config($config)), + default => throw new InvalidArgumentException("Adapter [$adapter] is not supported."), + }; } /** * Calls a custom creator for a given adapter type. + * + * @param BackupDiskConfig&array{adapter: string} $config */ - protected function callCustomCreator(array $config): mixed + protected function callCustomCreator(array $config): FilesystemAdapter { return $this->customCreators[$config['adapter']]($this->app, $config); } - /** - * Creates a new Wings adapter. - */ - public function createWingsAdapter(array $config): FilesystemAdapter - { - return new InMemoryFilesystemAdapter(); - } - - /** - * Creates a new S3 adapter. - */ - public function createS3Adapter(array $config): FilesystemAdapter - { - $config['version'] = 'latest'; - - if (!empty($config['key']) && !empty($config['secret'])) { - $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']); - } - - $client = new S3Client($config); - - return new S3Filesystem($client, $config['bucket'], $config['prefix'] ?? '', $config['options'] ?? []); - } - /** * Returns the configuration associated with a given backup type. + * + * @return BackupDiskConfig */ protected function getConfig(string $name): array { - return $this->config->get("backups.disks.$name") ?: []; - } - - /** - * Get the default backup driver name. - */ - public function getDefaultAdapter(): string - { - return $this->config->get('backups.default'); - } - - /** - * Set the default session driver name. - */ - public function setDefaultAdapter(string $name): void - { - $this->config->set('backups.default', $name); - } - - /** - * Unset the given adapter instances. - * - * @param string|string[] $adapter - */ - public function forget(array|string $adapter): self - { - foreach ((array) $adapter as $adapterName) { - unset($this->adapters[$adapterName]); + $config = $this->config->get("backups.disks.$name") ?: []; + JsonValueGuard::assertValue($config); + if (! is_array($config)) { + return []; } - return $this; + $adapter = $config['adapter'] ?? null; + if (! is_string($adapter) || $adapter === '') { + return []; + } + + $normalized = ['adapter' => $adapter]; + foreach ($config as $key => $value) { + if ($key === 'adapter') { + continue; + } + + if (in_array($key, ['key', 'secret', 'token', 'bucket', 'prefix'], true)) { + if (is_string($value)) { + $normalized[$key] = $value; + } + + continue; + } + + if ($key === 'options') { + if (is_array($value)) { + $options = []; + foreach ($value as $option => $optionValue) { + if (is_string($option)) { + $options[$option] = $optionValue; + } + } + + $normalized['options'] = $options; + } + + continue; + } + + $normalized[$key] = $value; + } + + return $normalized; } /** - * Register a custom adapter creator closure. + * @param BackupDiskConfig&array{adapter: string} $config + * @return S3BackupDiskConfig */ - public function extend(string $adapter, \Closure $callback): self + private function s3Config(array $config): array { - $this->customCreators[$adapter] = $callback; + $bucket = $config['bucket'] ?? null; + throw_if(! is_string($bucket) || $bucket === '', InvalidArgumentException::class, 'The S3 backup adapter requires a bucket.'); - return $this; + return array_merge($config, ['bucket' => $bucket]); } } diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index 2bed3436e..f1fdaf8a4 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -1,17 +1,21 @@ repository->find($host); + if (! $host instanceof DatabaseHost) { + $host = DatabaseHost::query()->findOrFail($host); } - $this->config->set('database.connections.' . $connection, [ + $this->config->set('database.connections.'.$connection, [ 'driver' => self::DB_DRIVER, 'host' => $host->host, 'port' => $host->port, diff --git a/app/Extensions/ExtensionProvider.php b/app/Extensions/ExtensionProvider.php new file mode 100644 index 000000000..965ff9ac0 --- /dev/null +++ b/app/Extensions/ExtensionProvider.php @@ -0,0 +1,364 @@ +registration()->begin(); + } + + final public function commitRegistration(): void + { + $this->registration()->commit($this->id()); + } + + final public function discardRegistration(): void + { + $this->registration()->discard(); + } + + protected function id(): string + { + return $this->extension->id; + } + + /** Absolute path inside the extension's package directory. */ + protected function extensionPath(string ...$parts): string + { + return $this->extension->path(...$parts); + } + + /** + * Mount a route file at /api/client/extensions/ with the client API + * middleware stack (session/API-key auth, 2FA requirement, client throttle). + */ + protected function registerClientApiRoutes(string $path): void + { + $this->registerRouteFile($path, ['api', RequireTwoFactorAuthentication::class, 'client-api', 'throttle:api.client'], '/api/client/extensions/'.$this->id(), 'client'); + } + + /** + * Mount a route file at /api/application/extensions/ with the application + * API middleware stack. + */ + protected function registerApplicationApiRoutes(string $path): void + { + $this->registerRouteFile($path, ['api', RequireTwoFactorAuthentication::class, 'application-api', 'throttle:api.application'], '/api/application/extensions/'.$this->id(), 'application'); + } + + /** + * Mount a route file at /api/client/servers/{server}/extensions/ with the + * full server-scoped client stack: the client API middleware plus the same + * server subject/access/scoping middleware core server routes use. Routes in + * the file receive the resolved server via route-model binding - type-hint + * Pterodactyl\Models\Server on controller actions. + */ + protected function registerServerApiRoutes(string $path): void + { + $this->registerRouteFile($path, [ + 'api', + RequireTwoFactorAuthentication::class, + 'client-api', + 'throttle:api.client', + ServerSubject::class, + AuthenticateServerAccess::class, + ResourceBelongsToServer::class, + ], '/api/client/servers/{server}/extensions/'.$this->id(), 'server'); + } + + /** + * Mount a route file at /api/admin/extensions/ with the admin API + * middleware stack (root administrator auth and admin throttle). + */ + protected function registerAdminApiRoutes(string $path): void + { + $this->registerRouteFile($path, ['api', RequireTwoFactorAuthentication::class, 'admin-api', 'throttle:api.admin'], '/api/admin/extensions/'.$this->id(), 'admin'); + } + + /** + * Register conventional API route files from routes/{client,server,admin,application}.php. + * Extensions with custom routing needs can keep calling the explicit helpers. + */ + protected function registerApiRoutes(?string $directory = null): void + { + $directory ??= $this->extensionPath('routes'); + + foreach ([ + 'client.php' => $this->registerClientApiRoutes(...), + 'server.php' => $this->registerServerApiRoutes(...), + 'admin.php' => $this->registerAdminApiRoutes(...), + 'application.php' => $this->registerApplicationApiRoutes(...), + ] as $file => $register) { + $path = mb_rtrim($directory, '/\\').DIRECTORY_SEPARATOR.$file; + if (is_file($path)) { + $register($path); + } + } + } + + /** + * Mount a route file at /extensions/ in the web group. Authentication is the + * extension's choice - add auth middleware inside the route file as needed. + */ + protected function registerWebRoutes(string $path): void + { + $this->registerRouteFile($path, ['web'], '/extensions/'.$this->id(), 'web', scopeBindings: false); + } + + /** + * Mount a route file at /extensions/ with the same authenticated web + * middleware stack core user routes use. + */ + protected function registerAuthenticatedWebRoutes(string $path): void + { + $this->registerRouteFile($path, ['web', 'auth', 'auth.session', RequireTwoFactorAuthentication::class], '/extensions/'.$this->id(), 'web', scopeBindings: false); + } + + /** + * Mount a route file under a top-level URL prefix the manifest claims in + * `routes.root`, e.g. `"routes": {"root": ["go"]}` serves the file at /go. Without + * `$prefix` the file is mounted under every claimed prefix; anything the manifest + * does not declare is refused. Routes run in the web group, are rate limited per + * client (`throttle:extensions.root`), and are public unless the route file adds + * auth middleware. They are named `extensions..root..`. + * + * @throws InvalidExtensionException + */ + protected function registerRootRoutes(string $path, ?string $prefix = null): void + { + $prefixes = $prefix === null ? $this->extension->rootPrefixes : [$prefix]; + throw_if($prefixes === [], InvalidExtensionException::class, sprintf('Extension "%s" declares no "routes.root" prefixes in its manifest.', $this->id())); + + foreach ($prefixes as $claimed) { + throw_unless(in_array($claimed, $this->extension->rootPrefixes, true), InvalidExtensionException::class, sprintf('Extension "%s" does not declare the root path prefix "%s" in its manifest.', $this->id(), $claimed)); + $this->registerRouteFile($path, ['web', 'throttle:extensions.root'], '/'.$claimed, 'root.'.$claimed, scopeBindings: false); + } + } + + /** Register the extension's database/migrations directory with the migrator. */ + protected function loadExtensionMigrations(): void + { + $this->loadMigrationsFrom($this->extensionPath('database', 'migrations')); + } + + /** Blade views under resources/views, namespaced as ext-::view. */ + protected function loadExtensionViews(): void + { + $this->loadViewsFrom($this->extensionPath('resources', 'views'), 'ext-'.$this->id()); + } + + /** Translations under resources/lang, namespaced as ext-::key. */ + protected function loadExtensionTranslations(): void + { + $this->loadTranslationsFrom($this->extensionPath('resources', 'lang'), 'ext-'.$this->id()); + } + + /** + * Listen for completed server operations: `provision`, `install`, `reinstall`, + * `backup`, `delete`, `suspend`, `unsuspend` and `transfer`. The event is immutable, + * carries identifiers only (after `delete` the server row is gone) and is dispatched + * once the surrounding transaction has committed. + * + * @param callable(OperationCompleted): void $listener + */ + protected function listenToServerOperations(callable $listener): void + { + $registration = $this->registration(); + $registration->defer(function () use ($listener, $registration): void { + Event::listen(OperationCompleted::class, function (OperationCompleted $event) use ($listener, $registration): void { + if (! $registration->isActive()) { + return; + } + + try { + $listener($event); + } catch (Throwable $throwable) { + $this->app->make(ExtensionRepository::class)->recordFailure($this->id(), $throwable->getMessage(), $throwable, 'event'); + } + }); + }); + } + + /** + * Run code around a core action. `$contract` is an action contract under + * `Pterodactyl\Contracts\` that the panel binds; `$decorator` receives the + * implementation that would otherwise be used and returns an implementation of the + * same contract, normally a small class of the extension that holds the inner action + * and calls it. Every caller that resolves the contract afterwards gets the wrapper. + * + * The wrapper owns the call: it decides whether and when to invoke the inner action + * and must forward the contract's fluent options itself (`DeletesServers::withForce()` + * returns the wrapper after passing the flag on to the inner action). Whatever it + * throws reaches the caller unchanged - the panel never swallows or rewrites it - and + * is recorded against the extension when it is reported. Exceptions of the inner + * action pass through the same way and stay core's own. + * + * The decorator is skipped while the extension is disabled or failed to boot, and a + * decorator that throws or returns anything else is recorded and skipped, so the core + * action always stays resolvable. Extensions wrap in load order; the last is outermost. + * + * @template TContract of object + * + * @param class-string $contract + * @param Closure(TContract): TContract $decorator + */ + protected function wrapAction(string $contract, Closure $decorator): void + { + $registration = $this->registration(); + $registration->defer(function () use ($contract, $decorator, $registration): void { + $this->app->make(ExtensionActionDecorators::class)->register($this->id(), $contract, $decorator, $registration); + }); + } + + /** + * Register artisan commands. They exist only while the extension is enabled and + * booted successfully; prefix their names with the extension id (`:clean`) so + * they cannot shadow a core command. + * + * @param list $classes + */ + protected function registerCommands(array $classes): void + { + $this->registration()->defer(function () use ($classes): void { + $this->app->make(ExtensionConsoleRegistry::class)->registerCommands($this->id(), $classes); + }); + } + + /** + * Define scheduled tasks on the panel's scheduler, exactly as core does: + * `$schedule->command(':clean')->daily()`. Tasks only run while the extension is + * enabled, and a failed run is recorded against the extension. + * + * @param Closure(Schedule): void $callback + */ + protected function registerSchedule(Closure $callback): void + { + $this->registration()->defer(function () use ($callback): void { + $this->app->make(ExtensionConsoleRegistry::class)->registerSchedule($this->id(), $callback); + }); + } + + /** + * Add `` and `` elements to the panel's document head, for guests and + * signed-in users alike. Each entry is `['tag' => 'meta'|'link', => ]` + * with attributes from a fixed allow-list (meta: name or property, content, media; + * link: rel, href, sizes, type, media, color, crossorigin, hreflang, title). `href` + * must be an http(s) URL or a path on this panel, `rel` is limited to relations that + * load nothing executable, and scripts, stylesheets, inline styles and event + * handlers cannot be expressed. An element the panel also ships (theme-color, the + * web app manifest, the favicons) replaces the panel's. + * + * Pass a closure for values that depend on settings: it runs when the layout renders + * and its result is cached for `extensions.head_tags_cache_seconds`. + * + * @param array>|(Closure(): array>) $tags + */ + protected function registerHeadTags(array|Closure $tags): void + { + $this->registration()->defer(function () use ($tags): void { + $this->app->make(ExtensionHeadTags::class)->register($this->id(), $this->extension->version, $tags); + }); + } + + /** Typed key/value settings scoped to this extension. */ + protected function settings(): ExtensionSettings + { + return $this->app->make(ExtensionManager::class)->settings($this->id()); + } + + /** + * Register the extension's typed settings definition with the panel. The + * admin Extensions UI auto-renders a settings form from it (labels, fields, + * validation - no extension frontend code needed), the panel serves + * GET/PATCH /api/admin/extensions//settings for it (that path segment + * is reserved under the admin prefix), and any definition marked + * ->frontend() is delivered to the extension bundle as ctx.config. + */ + protected function registerSettings(ExtensionSettingsDefinition $definition): void + { + $this->registration()->defer(function () use ($definition): void { + $this->app->make(ExtensionSettingsRegistry::class)->register($this->id(), $definition); + }); + } + + /** + * Register subuser permissions for this extension. Each key becomes the permission + * `ext..`: it appears in the server subuser editor under the given group + * description, can be granted to subusers, gates server screens through the manifest's + * `permission` list, and is checked on the backend with + * `$user->can('ext..', $server)`. + * + * @param array $keys permission key => description + */ + protected function registerPermissions(string $description, array $keys): void + { + $this->registration()->defer(function () use ($description, $keys): void { + $this->app->make(ExtensionPermissionRegistry::class)->register($this->id(), $description, $keys); + }); + } + + /** @param list $middleware */ + private function registerRouteFile(string $path, array $middleware, string $prefix, string $area, bool $scopeBindings = true): void + { + $this->registration()->defer(function () use ($path, $middleware, $prefix, $area, $scopeBindings): void { + $routes = Route::middleware([...$middleware, EnsureExtensionIsAvailable::class.':'.$this->id()]) + ->prefix($prefix) + ->name('extensions.'.$this->id().'.'.$area.'.'); + if ($scopeBindings) { + $routes->scopeBindings(); + } + + $routes->group(fn () => $this->loadRoutesFrom($path)); + }); + } + + private function registration(): ExtensionRegistration + { + return $this->registration ??= $this->app->make(ExtensionRegistration::class); + } +} diff --git a/app/Extensions/Facades/Theme.php b/app/Extensions/Facades/Theme.php deleted file mode 100644 index 55ebc1002..000000000 --- a/app/Extensions/Facades/Theme.php +++ /dev/null @@ -1,13 +0,0 @@ - $options + */ public function __construct( - private S3ClientInterface $client, - private string $bucket, + private readonly S3ClientInterface $client, + private readonly string $bucket, string $prefix = '', array $options = [], ) { diff --git a/app/Extensions/Hashids.php b/app/Extensions/Hashids.php index 8c18ada5c..5c45dc15e 100644 --- a/app/Extensions/Hashids.php +++ b/app/Extensions/Hashids.php @@ -1,14 +1,16 @@ decode($encoded); diff --git a/app/Extensions/Illuminate/Database/Eloquent/Builder.php b/app/Extensions/Illuminate/Database/Eloquent/Builder.php index 6ce63c2b6..f2e28a588 100644 --- a/app/Extensions/Illuminate/Database/Eloquent/Builder.php +++ b/app/Extensions/Illuminate/Database/Eloquent/Builder.php @@ -1,13 +1,23 @@ + */ class Builder extends EloquentBuilder { /** * Do nothing. + * + * @return self */ public function search(): self { diff --git a/app/Extensions/Illuminate/Events/Contracts/SubscribesToEvents.php b/app/Extensions/Illuminate/Events/Contracts/SubscribesToEvents.php index 9d78252c9..3765ad5ac 100644 --- a/app/Extensions/Illuminate/Events/Contracts/SubscribesToEvents.php +++ b/app/Extensions/Illuminate/Events/Contracts/SubscribesToEvents.php @@ -1,5 +1,7 @@ accessToken = $accessToken; - $this->plainTextToken = $plainTextToken; - } + public function __construct( + public ApiKey $accessToken, + public string $plainTextToken, + ) {} } diff --git a/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php b/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php index e47a3fda0..e29233887 100644 --- a/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php +++ b/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php @@ -1,9 +1,13 @@ getTimestamp(); + $date = $claims[$claim]; + throw_unless($date instanceof DateTimeImmutable, UnexpectedValueException::class, "JWT date claim [$claim] must be a DateTimeImmutable instance."); + + $claims[$claim] = $date->getTimestamp(); } return $claims; diff --git a/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php b/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php index 5b53a5ad7..70aaacd3a 100644 --- a/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php +++ b/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php @@ -1,5 +1,7 @@ $data + * @return array{object: string, data: list} */ public function collection(?string $resourceKey, array $data): array { @@ -35,6 +43,8 @@ class PterodactylSerializer extends ArraySerializer /** * Serialize a null resource. + * + * @return array{object: string, attributes: null} */ public function null(): ?array { @@ -46,13 +56,24 @@ class PterodactylSerializer extends ArraySerializer /** * Merge the included resources with the parent resource being serialized. + * + * @param FractalTransformedPayload $transformedData + * @param ApiPayload9 $includedData + * @return FractalTransformedPayload */ public function mergeIncludes(array $transformedData, array $includedData): array { - foreach ($includedData as $key => $datum) { - $transformedData['relationships'][$key] = $datum; + if ($includedData === []) { + return $transformedData; } + $relationships = $transformedData['relationships'] ?? []; + foreach ($includedData as $key => $datum) { + $relationships[$key] = $datum; + } + + $transformedData['relationships'] = $relationships; + return $transformedData; } } diff --git a/app/Extensions/Scribe/Attributes/ResponseField.php b/app/Extensions/Scribe/Attributes/ResponseField.php new file mode 100644 index 000000000..07e2c742a --- /dev/null +++ b/app/Extensions/Scribe/Attributes/ResponseField.php @@ -0,0 +1,37 @@ + $factoryStates Factory states applied to the example model. + * @param list $with Relationships eager loaded onto the example model. + * @param array{}|array{class-string, int} $paginate Format: [adapter, numberPerPage]. + * @param ApiPayload $meta Example values merged into the response envelope's + * top-level meta key, mirroring the controller's + * Fractal ->addMeta() output that transformer + * execution alone cannot reproduce. + * @param string[] $include Fractal includes to execute so the documented response + * carries the relationships the endpoint can embed. + * @param string[] $withCount Relationship counts to load on the example model, + * mirroring the controller's withCount() query. + */ + public function __construct( + string $name, + ?string $model = null, + int $status = 200, + ?string $description = '', + bool $collection = false, + array $factoryStates = [], + array $with = [], + ?string $resourceKey = null, + array $paginate = [], + public array $meta = [], + public array $include = [], + public array $withCount = [], + ) { + parent::__construct($name, $model, $status, $description, $collection, $factoryStates, $with, $resourceKey, $paginate); + } +} diff --git a/app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php b/app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php new file mode 100644 index 000000000..35f4011f1 --- /dev/null +++ b/app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php @@ -0,0 +1,2668 @@ +|null */ + private ?array $operationIds = null; + + /** @var array|null */ + private ?array $transformerClasses = null; + + /** @var OpenApiSchemaMap */ + private array $requestBodySchemas = []; + + /** @var OpenApiSchemaMap */ + private array $responseBodySchemas = []; + + /** @var OpenApiSchemaMap */ + private array $parameterSchemas = []; + + /** @var array */ + private array $operationSchemaRefs = []; + + /** + * @param OpenApiRoot $root + * @return OpenApiRoot + */ + public function root(array $root, array $groupedEndpoints): array + { + $root['components']['securitySchemes']['panelSession'] = [ + 'type' => 'apiKey', + 'in' => 'cookie', + 'name' => JsonValueGuard::string(config('session.cookie', 'pterodactyl_session')), + 'description' => 'Browser session cookie used by the panel frontend.', + ]; + + foreach ($this->componentSchemas($groupedEndpoints) as $name => $schema) { + $root['components']['schemas'][$name] = $schema; + } + + foreach ($this->requestBodySchemas as $name => $schema) { + $root['components']['schemas'][$name] = $schema; + } + + foreach ($this->responseBodySchemas as $name => $schema) { + $root['components']['schemas'][$name] = $schema; + } + + foreach ($this->parameterSchemas as $name => $schema) { + $root['components']['schemas'][$name] = $schema; + } + + $this->normalizeRootSchemas($root); + $this->pruneUnreferencedSchemas($root); + + return $root; + } + + /** + * @param OpenApiOperation $pathItem + * @return OpenApiOperation + */ + public function pathItem(array $pathItem, array $groupedEndpoints, OutputEndpointData $endpoint): array + { + $pathItem['operationId'] = $this->operationIds($groupedEndpoints)[$this->endpointKey($endpoint)] + ?? $this->baseOperationId($endpoint); + + $pathItem = $this->normalizeBrowserSessionOperation($pathItem, $endpoint); + $this->enforceKnownBodyParameterSchemas($pathItem, $endpoint); + $pathItem = $this->normalizeOperationRequestBody($pathItem, $endpoint); + $this->stripEmptySuccessResponseContent($pathItem); + $this->replaceSuccessResponseSchema($pathItem, $endpoint); + $this->replacePlainSuccessResponseSchema($pathItem); + $this->replaceErrorResponseSchemas($pathItem); + $pathItem = $this->normalizeSchemas($pathItem); + $this->applyResponseFieldsToInlineSchemas($pathItem, $endpoint); + $this->normalizeRawResponseMediaTypes($pathItem, $endpoint); + $this->extractRequestBodySchemas($pathItem); + $this->extractResponseBodySchemas($pathItem); + $this->extractOperationParameterSchemas($pathItem); + JsonValueGuard::assertValue($pathItem); + $this->collectComponentRefs($pathItem, $this->operationSchemaRefs); + + return $pathItem; + } + + /** + * @param list $parameters + * @return list + */ + public function pathParameters(array $parameters, array $endpoints, array $urlParameters): array + { + $endpoint = $endpoints[0] ?? null; + if (! $endpoint instanceof OutputEndpointData) { + return $parameters; + } + + foreach ($parameters as &$parameter) { + $this->extractParameterSchema($parameter, $this->pathParameterSchemaComponentName($endpoint, $parameter)); + } + + unset($parameter); + + JsonValueGuard::assertValue($parameters); + $this->collectComponentRefs($parameters, $this->operationSchemaRefs); + + return $parameters; + } + + /** + * @param array $groupedEndpoints + * @return OpenApiSchemaMap + */ + private function componentSchemas(array $groupedEndpoints): array + { + $schemas = [ + 'AdminEggConfigurationFile' => $this->adminEggConfigurationFileSchema(), + 'AdminEggConfigurationFiles' => $this->adminEggConfigurationFilesSchema(), + 'AdminEggConfigurationFind' => $this->adminEggConfigurationFindSchema(), + 'AdminExtensionSettingField' => $this->adminExtensionSettingFieldSchema(), + 'AdminExtensionSettingOption' => $this->adminExtensionSettingOptionSchema(), + 'AdminLanguagesResponse' => $this->adminLanguagesSchema(), + 'AdminNodeConfigurationResponse' => $this->adminNodeConfigurationSchema(), + 'AdminNodeDeployTokenResponse' => $this->adminNodeDeployTokenSchema(), + 'AdminNodeSystemInformationResponse' => $this->adminNodeSystemInformationSchema(), + 'AdminNodeUtilizationResponse' => $this->adminNodeUtilizationSchema(), + 'AdminServerVariableAttributes' => $this->adminServerVariableAttributesSchema(), + 'AdminServerVariableListResponse' => $this->fractalListSchema('AdminServerVariableResource'), + 'AdminServerVariablePaginatedResponse' => $this->fractalPaginatedSchema('AdminServerVariableResource'), + 'AdminServerVariableResource' => $this->fractalItemSchema('server_variable', 'AdminServerVariableAttributes'), + 'AdminSettingsResponse' => $this->adminSettingsSchema(), + 'AdminVersionInformationResponse' => $this->adminVersionInformationSchema(), + 'AuthLoginCheckpointResponse' => $this->authLoginCheckpointResponseSchema(), + 'AuthLoginCompleteResponse' => $this->authLoginCompleteResponseSchema(), + 'AuthLoginResponse' => $this->authLoginResponseSchema(), + 'AuthPasswordResetEmailResponse' => $this->authPasswordResetEmailResponseSchema(), + 'AuthResetPasswordResponse' => $this->authResetPasswordResponseSchema(), + 'AuthUser' => $this->authUserSchema(), + 'ClientSystemPermissionsResponse' => $this->clientSystemPermissionsSchema(), + 'ClientTwoFactorSetupResponse' => $this->clientTwoFactorSetupSchema(), + 'ErrorEnvelope' => $this->errorEnvelopeSchema(false), + 'NullResource' => $this->nullResourceSchema(), + 'ValidationErrorEnvelope' => $this->errorEnvelopeSchema(true), + 'PaginationMeta' => $this->paginationMetaSchema(), + ]; + + $knownComponents = [ + 'AdminServerVariableListResponse' => true, + 'AdminServerVariableResource' => true, + ]; + foreach ($groupedEndpoints as $group) { + foreach ($group['endpoints'] as $endpoint) { + $fractal = $this->fractalResponse($endpoint); + if ($fractal === null) { + continue; + } + + foreach ($this->fractalComponents($endpoint, $fractal['resource']) as $component) { + $knownComponents[$component] = true; + } + } + } + + foreach ($groupedEndpoints as $group) { + foreach ($group['endpoints'] as $endpoint) { + $fractal = $this->fractalResponse($endpoint); + if ($fractal === null) { + continue; + } + + $components = $this->fractalComponents($endpoint, $fractal['resource']); + $attributes = $components['attributes']; + if (! isset($schemas[$attributes])) { + $attributeValues = $fractal['attributes']; + if (str_ends_with($attributes, 'EggAttributes') && is_array($attributeValues['config'] ?? null)) { + foreach (['files', 'startup', 'logs', 'file_denylist'] as $declaredField) { + $attributeValues['config'][$declaredField] = []; + } + } + + try { + $schemas[$attributes] = PterodactylDocumentation::schemaForValue($attributeValues); + } catch (UnexpectedValueException $exception) { + throw new UnexpectedValueException("Unable to infer the {$attributes} schema for {$endpoint->uri}.", $exception->getCode(), previous: $exception); + } + } + + JsonValueGuard::assertOpenApiSchemaInput($schemas[$attributes]); + $this->applyDeclaredFieldMetadata($schemas[$attributes], $endpoint); + // The valid subuser permission values come from the runtime permission + // registry, so they cannot be declared as a constant attribute. + if ($attributes === 'ClientServerSubuserAttributes') { + $properties = $schemas[$attributes]['properties'] ?? null; + if (is_array($properties) && isset($properties['permissions'])) { + JsonValueGuard::assertOpenApiSchemaMap($properties); + $properties['permissions'] = $this->permissionsSchema(); + $schemas[$attributes]['properties'] = $properties; + } + } + + if (isset($fractal['relationships'])) { + JsonValueGuard::assertOpenApiSchemaInput($schemas[$attributes]); + $this->addRelationshipsToAttributesSchema($schemas[$attributes], $endpoint, $fractal['relationships'], $knownComponents); + } + + $schemas[$components['item']] ??= $this->fractalItemSchema($fractal['resource'], $attributes); + if (isset($fractal['meta'])) { + JsonValueGuard::assertOpenApiSchemaInput($schemas[$components['item']]); + $this->addMetaToItemSchema($schemas[$components['item']], $fractal['meta']); + } + + $schemas[$components['list']] ??= $this->fractalListSchema($components['item']); + $schemas[$components['page']] ??= $this->fractalPaginatedSchema($components['item']); + if (isset($fractal['top_meta'])) { + JsonValueGuard::assertOpenApiSchemaInput($schemas[$components['list']]); + JsonValueGuard::assertOpenApiSchemaInput($schemas[$components['page']]); + $this->addMetaToListSchema($schemas[$components['list']], $fractal['top_meta']); + JsonValueGuard::assertOpenApiSchemaInput($schemas[$components['page']]); + $this->addMetaToPaginatedSchema($schemas[$components['page']], $fractal['top_meta']); + } + } + } + + foreach ($schemas as &$schema) { + JsonValueGuard::assertPayload9($schema); + } + + unset($schema); + ksort($schemas); + + return $schemas; + } + + /** + * Applies field metadata declared as ResponseField attributes - on the + * endpoint's transformer class, or on the controller method itself - to a + * fractal attributes schema. This is how nullability, enums, and map/union + * shapes that cannot be inferred from a single example reach the spec. + * + * @param OpenApiSchemaInput $schema + * a reference into the schema and loses the key type + */ + private function applyDeclaredFieldMetadata(array &$schema, OutputEndpointData $endpoint): void + { + $transformer = $this->transformerClasses()[$this->anonymousEndpointKey(mb_strtoupper($endpoint->httpMethods[0]), $endpoint->uri)] ?? null; + if ($transformer !== null) { + foreach ((new ReflectionClass($transformer))->getAttributes(ResponseField::class) as $attribute) { + $field = $attribute->newInstance(); + $example = $field->example; + JsonValueGuard::assertValue($example); + $enum = $field->enum; + JsonValueGuard::assertValue($enum); + $schema = $this->applyFieldMetadata($schema, $field->name, [ + 'description' => $field->description, + 'type' => $field->type, + 'required' => $field->required, + 'example' => $this->arrayValue($example), + 'enum' => $this->arrayValue($enum), + 'nullable' => $field->nullable, + 'schema' => $field->name === 'config.files' + ? ['$ref' => '#/components/schemas/AdminEggConfigurationFiles'] + : $field->schema, + ]); + } + } + + foreach ($endpoint->responseFields as $field) { + if (! str_starts_with($field->name, 'attributes.')) { + continue; + } + + $enumValues = $field->enumValues; + JsonValueGuard::assertValue($enumValues); + $schema = $this->applyFieldMetadata($schema, mb_substr($field->name, mb_strlen('attributes.')), [ + 'description' => $field->description, + 'type' => $field->type, + 'required' => $field->required, + 'example' => null, + 'enum' => $enumValues, + 'nullable' => $field->nullable, + 'schema' => [], + ]); + } + } + + /** + * @param OpenApiSchemaInput $schema + * @param array{description: ?string, type: ?string, required: ?bool, example: JsonValue, enum: JsonValue, nullable: ?bool, schema: OpenApiSchema} $meta + * @return OpenApiSchemaInput + */ + private function applyFieldMetadata(array $schema, string $path, array $meta): array + { + $segments = explode('.', $path); + $leaf = array_pop($segments); + + $parent = &$schema; + foreach ($segments as $segment) { + if (! isset($parent['properties'][$segment]) || ! is_array($parent['properties'][$segment])) { + JsonValueGuard::assertOpenApiSchemaInput($schema); + + return $schema; + } + + $parent = &$parent['properties'][$segment]; + } + + if ($meta['required'] === false && isset($schema['required']) && is_array($schema['required']) && $segments === []) { + $schema['required'] = array_values(array_filter(JsonValueGuard::stringList($schema['required']), fn (string $key): bool => $key !== $leaf)); + } + + if (! isset($parent['properties'][$leaf]) || ! is_array($parent['properties'][$leaf])) { + JsonValueGuard::assertOpenApiSchemaInput($schema); + + return $schema; + } + + if ($meta['schema'] !== []) { + $parent['properties'][$leaf] = $meta['schema']; + } + + $property = &$parent['properties'][$leaf]; + + if (($type = $meta['type']) !== null && $type !== '' && $meta['schema'] === []) { + if (str_ends_with($type, '[]')) { + $property['type'] = 'array'; + $property['items'] = ['type' => mb_substr($type, 0, -2)]; + unset($property['example']); + } elseif (str_contains($type, '<')) { + $property['type'] = $type; + unset($property['items'], $property['properties'], $property['required']); + } else { + $property['type'] = $type; + } + } + + if (! empty($meta['description'])) { + $property['description'] = $meta['description']; + } + + if ($meta['nullable'] === true) { + $property['nullable'] = true; + } + + $enum = $meta['enum']; + if (is_string($enum) && enum_exists($enum)) { + $enum = array_map(fn (UnitEnum $case): int|string => $case instanceof BackedEnum ? $case->value : $case->name, $enum::cases()); + } + + if (is_array($enum) && $enum !== []) { + if (($property['type'] ?? null) === 'array' && isset($property['items']) && is_array($property['items'])) { + $property['items']['enum'] = $enum; + } else { + $property['enum'] = $enum; + } + } + + if ($meta['example'] !== null) { + $property['example'] = $meta['example']; + } + + JsonValueGuard::assertOpenApiSchemaInput($schema); + + return $schema; + } + + /** + * Applies method- and class-level ResponseField declarations to inline + * response schemas (endpoints documented with literal examples), matching + * properties by bare field name at any depth. + * + * @param OpenApiOperation $pathItem + */ + private function applyResponseFieldsToInlineSchemas(array &$pathItem, OutputEndpointData $endpoint): void + { + if ($endpoint->responseFields === [] || ! isset($pathItem['responses']) || ! is_array($pathItem['responses'])) { + return; + } + + foreach ($pathItem['responses'] as $status => &$response) { + if (! str_starts_with($this->arrayKeyString($status), '2') || ! isset($response['content']['application/json']['schema'])) { + continue; + } + + $schema = &$response['content']['application/json']['schema']; + if (is_array($schema) && ! isset($schema['$ref'])) { + $this->walkPropertiesApplyingResponseFields($schema, $endpoint); + } + } + + unset($response); + } + + /** + * @param OpenApiRecursiveNode $schema + * + * @param-out mixed $schema + */ + private function walkPropertiesApplyingResponseFields(array &$schema, OutputEndpointData $endpoint): void + { + // SAFETY: Scribe supplies a heterogeneous recursive OpenAPI tree; every node is narrowed before array access. + if (isset($schema['properties']) && is_array($schema['properties'])) { + foreach ($schema['properties'] as $name => &$property) { + if (! is_array($property)) { + continue; + } + + $field = $endpoint->responseFields[$name] ?? null; + if ($field !== null) { + if ($field->nullable) { + $property['nullable'] = true; + } + + if (! empty($field->description)) { + $property['description'] = $field->description; + } + + if ($field->enumValues !== []) { + $property['enum'] = $field->enumValues; + } + + if ($field->required === false && isset($schema['required']) && is_array($schema['required'])) { + $schema['required'] = array_values(array_filter(JsonValueGuard::stringList($schema['required']), fn (string $key): bool => $key !== $name)); + } + } + + JsonValueGuard::assertValue($property); + $this->walkPropertiesApplyingResponseFields($property, $endpoint); + } + + unset($property); + } + + foreach (['items', 'additionalProperties'] as $key) { + if (isset($schema[$key]) && is_array($schema[$key])) { + JsonValueGuard::assertValue($schema[$key]); + $this->walkPropertiesApplyingResponseFields($schema[$key], $endpoint); + } + } + } + + /** + * Scribe rewrites URL parameter names, so map keys anonymize them to match + * a Laravel route against its documented endpoint. + */ + private function anonymousEndpointKey(string $httpMethod, string $uri): string + { + return $httpMethod.' '.preg_replace('/\{[^}]+\}/', '{}', mb_trim($uri, '/')); + } + + /** + * @return array map of "METHOD uri" to the transformer class + * declared by the route action's attribute + */ + private function transformerClasses(): array + { + if ($this->transformerClasses !== null) { + return $this->transformerClasses; + } + + $map = []; + foreach (Route::getRoutes()->getRoutes() as $route) { + $action = $route->getActionName(); + [$class, $method] = str_contains($action, '@') ? explode('@', $action, 2) : [$action, '__invoke']; + if ($class === 'Closure' || ! class_exists($class) || ! method_exists($class, $method)) { + continue; + } + + $attributes = (new ReflectionMethod($class, $method))->getAttributes( + ResponseFromTransformer::class, + ReflectionAttribute::IS_INSTANCEOF, + ); + if ($attributes === []) { + continue; + } + + $transformer = $attributes[0]->newInstance()->name; + if (! class_exists($transformer)) { + continue; + } + + foreach ($route->methods() as $httpMethod) { + if (! is_string($httpMethod)) { + continue; + } + + if ($httpMethod !== 'HEAD' && $httpMethod !== 'OPTIONS') { + $map[$this->anonymousEndpointKey($httpMethod, $route->uri())] = $transformer; + } + } + } + + return $this->transformerClasses = $map; + } + + /** @return DeepOpenApiSchema */ + private function adminServerVariableAttributesSchema(): array + { + $schema = PterodactylDocumentation::schemaForValue([ + 'id' => 1, + 'egg_id' => 1, + 'name' => 'Server Jar File', + 'description' => 'The jar file to run.', + 'env_variable' => 'SERVER_JARFILE', + 'default_value' => 'server.jar', + 'server_value' => 'server.jar', + 'user_viewable' => true, + 'user_editable' => true, + 'rules' => 'required|string', + 'required' => true, + 'sort_order' => 1, + 'created_at' => '2026-01-01T00:00:00+00:00', + 'updated_at' => '2026-01-01T00:00:00+00:00', + ]); + + $properties = $schema['properties'] ?? null; + JsonValueGuard::assertOpenApiSchemaMap($properties); + $properties['server_value']['nullable'] = true; + $properties['sort_order']['nullable'] = true; + $schema['properties'] = $properties; + + $required = $schema['required'] ?? null; + JsonValueGuard::assertStringList($required); + $schema['required'] = array_values(array_diff($required, ['required'])); + + return $schema; + } + + /** @return OpenApiSchema */ + private function clientTwoFactorSetupSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['data'], + 'properties' => [ + 'data' => [ + 'type' => 'object', + 'required' => ['image_url_data', 'secret'], + 'properties' => [ + 'image_url_data' => [ + 'type' => 'string', + 'example' => 'otpauth://totp/Pterodactyl:user@example.com?secret=EXAMPLESECRET&issuer=Pterodactyl', + ], + 'secret' => [ + 'type' => 'string', + 'example' => 'EXAMPLESECRET', + ], + ], + ], + ], + ]; + } + + /** @return DeepOpenApiSchema */ + private function clientSystemPermissionsSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['object', 'attributes'], + 'properties' => [ + 'object' => [ + 'type' => 'string', + 'example' => 'system_permissions', + ], + 'attributes' => [ + 'type' => 'object', + 'required' => ['permissions'], + 'properties' => [ + 'permissions' => [ + 'type' => 'object', + 'additionalProperties' => [ + 'type' => 'object', + 'required' => ['description', 'keys'], + 'properties' => [ + 'description' => ['type' => 'string'], + 'keys' => [ + 'type' => 'object', + 'additionalProperties' => ['type' => 'string'], + ], + ], + ], + ], + ], + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function authLoginResponseSchema(): array + { + return [ + 'oneOf' => [ + ['$ref' => '#/components/schemas/AuthLoginCompleteResponse'], + ['$ref' => '#/components/schemas/AuthLoginCheckpointResponse'], + ], + ]; + } + + /** @return OpenApiSchema */ + private function authLoginCompleteResponseSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['data'], + 'properties' => [ + 'data' => [ + 'type' => 'object', + 'required' => ['complete', 'intended', 'user'], + 'properties' => [ + 'complete' => [ + 'type' => 'boolean', + 'enum' => [true], + 'example' => true, + ], + 'intended' => [ + 'type' => 'string', + 'example' => '/', + ], + 'user' => ['$ref' => '#/components/schemas/AuthUser'], + ], + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function authLoginCheckpointResponseSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['data'], + 'properties' => [ + 'data' => [ + 'type' => 'object', + 'required' => ['complete', 'confirmation_token'], + 'properties' => [ + 'complete' => [ + 'type' => 'boolean', + 'enum' => [false], + 'example' => false, + ], + 'confirmation_token' => [ + 'type' => 'string', + 'example' => 'b6e22f85d63c4d9db9739f9ab0a27a48f51f7ad38ef8c12fd157c4c6f4b2e51d', + ], + ], + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function authPasswordResetEmailResponseSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['status'], + 'properties' => [ + 'status' => [ + 'type' => 'string', + 'example' => 'We have emailed your password reset link.', + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function authResetPasswordResponseSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['success', 'redirect_to', 'send_to_login'], + 'properties' => [ + 'success' => [ + 'type' => 'boolean', + 'enum' => [true], + 'example' => true, + ], + 'redirect_to' => [ + 'type' => 'string', + 'nullable' => true, + 'example' => '/', + ], + 'send_to_login' => [ + 'type' => 'boolean', + 'example' => false, + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function authUserSchema(): array + { + return [ + 'type' => 'object', + 'required' => [ + 'uuid', + 'username', + 'email', + 'name_first', + 'name_last', + 'language', + 'root_admin', + 'use_totp', + 'gravatar', + 'created_at', + 'updated_at', + 'identifier', + ], + 'properties' => [ + 'uuid' => [ + 'type' => 'string', + 'format' => 'uuid', + 'example' => '9a8b7c6d-5e4f-4321-9876-123456789abc', + ], + 'username' => [ + 'type' => 'string', + 'example' => 'admin', + ], + 'email' => [ + 'type' => 'string', + 'format' => 'email', + 'example' => 'admin@example.com', + ], + 'name_first' => [ + 'type' => 'string', + 'nullable' => true, + 'example' => 'Admin', + ], + 'name_last' => [ + 'type' => 'string', + 'nullable' => true, + 'example' => 'User', + ], + 'language' => [ + 'type' => 'string', + 'example' => 'en', + ], + 'root_admin' => [ + 'type' => 'boolean', + 'example' => true, + ], + 'use_totp' => [ + 'type' => 'boolean', + 'example' => false, + ], + 'gravatar' => [ + 'type' => 'boolean', + 'example' => true, + ], + 'created_at' => [ + 'type' => 'string', + 'format' => 'date-time', + 'example' => '2026-06-29T12:00:00+00:00', + ], + 'updated_at' => [ + 'type' => 'string', + 'format' => 'date-time', + 'example' => '2026-06-29T12:00:00+00:00', + ], + 'identifier' => [ + 'type' => 'string', + 'pattern' => '^usr_[a-zA-Z0-9]+$', + 'example' => 'usr_1a2b3c4d', + ], + ], + ]; + } + + /** + * @param OpenApiOperation $pathItem + */ + private function replaceSuccessResponseSchema(array &$pathItem, OutputEndpointData $endpoint): void + { + $fractal = $this->fractalResponse($endpoint); + if ($fractal === null) { + return; + } + + $components = $this->fractalComponents($endpoint, $fractal['resource']); + $schema = match (true) { + $fractal['paginated'] => $components['page'], + $fractal['collection'] => $components['list'], + default => $components['item'], + }; + + if (! isset($pathItem['responses']) || ! is_array($pathItem['responses'])) { + return; + } + + foreach ($pathItem['responses'] as $status => &$response) { + if (! str_starts_with($this->arrayKeyString($status), '2') || $this->arrayKeyString($status) === '204') { + continue; + } + + if (isset($response['content']['application/json']['schema'])) { + $response['content']['application/json']['schema'] = ['$ref' => "#/components/schemas/{$schema}"]; + } + } + + unset($response); + } + + /** + * @param OpenApiOperation $pathItem + */ + private function replacePlainSuccessResponseSchema(array &$pathItem): void + { + if (in_array($pathItem['operationId'] ?? null, ['adminGetExtensionSettings', 'adminUpdateExtensionSettings', 'adminUploadExtensionSettingFile', 'adminClearExtensionSettingFile'], true)) { + if (! isset($pathItem['responses']) || ! is_array($pathItem['responses'])) { + return; + } + + foreach ($pathItem['responses'] as $status => &$response) { + if (str_starts_with($this->arrayKeyString($status), '2') && isset($response['content']['application/json']['schema'])) { + $response['content']['application/json']['schema'] = $this->adminExtensionSettingsSchema(); + } + } + + unset($response); + + return; + } + + $schema = match ($pathItem['operationId'] ?? null) { + 'adminListLanguages' => 'AdminLanguagesResponse', + 'adminGetNodeConfiguration' => 'AdminNodeConfigurationResponse', + 'adminCreateNodeDeployToken' => 'AdminNodeDeployTokenResponse', + 'adminGetNodeSystemInformation' => 'AdminNodeSystemInformationResponse', + 'adminGetNodeUtilization' => 'AdminNodeUtilizationResponse', + 'adminGetSettings' => 'AdminSettingsResponse', + 'adminGetVersionInformation' => 'AdminVersionInformationResponse', + 'authCompleteLoginCheckpoint' => 'AuthLoginCompleteResponse', + 'authLogin' => 'AuthLoginResponse', + 'authRequestPasswordResetEmail' => 'AuthPasswordResetEmailResponse', + 'authResetPassword' => 'AuthResetPasswordResponse', + 'clientListServerPermissions' => 'ClientSystemPermissionsResponse', + 'clientGetTwoFactorSetup' => 'ClientTwoFactorSetupResponse', + default => null, + }; + + if ($schema === null || ! isset($pathItem['responses']) || ! is_array($pathItem['responses'])) { + return; + } + + foreach ($pathItem['responses'] as $status => &$response) { + if (! str_starts_with($this->arrayKeyString($status), '2') || ! isset($response['content']['application/json']['schema'])) { + continue; + } + + $response['content']['application/json']['schema'] = ['$ref' => "#/components/schemas/{$schema}"]; + } + + unset($response); + } + + /** + * @param OpenApiOperation $pathItem + */ + private function stripEmptySuccessResponseContent(array &$pathItem): void + { + if (! isset($pathItem['responses']) || ! is_array($pathItem['responses'])) { + return; + } + + foreach ($pathItem['responses'] as $status => &$response) { + if (! str_starts_with($this->arrayKeyString($status), '2')) { + continue; + } + + $schema = $response['content']['application/json']['schema'] ?? null; + if (! is_array($schema)) { + continue; + } + + if (($schema['type'] ?? null) === 'object' && ($schema['nullable'] ?? false) === true && ! isset($schema['properties'])) { + unset($response['content']); + } + } + + unset($response); + } + + /** + * @param OpenApiOperation $pathItem + * @return OpenApiOperation + */ + private function normalizeBrowserSessionOperation(array $pathItem, OutputEndpointData $endpoint): array + { + if (! str_starts_with($endpoint->uri, 'auth/') && $endpoint->uri !== 'sanctum/csrf-cookie') { + return $pathItem; + } + + $pathItem['security'] = []; + + if (($pathItem['operationId'] ?? null) === 'authLogout') { + $pathItem['security'] = [['panelSession' => []]]; + } + + if (($pathItem['operationId'] ?? null) !== 'authGetCsrfCookie') { + return $pathItem; + } + + $pathItem['summary'] = 'Get CSRF cookie'; + $pathItem['description'] = 'Initializes the Laravel Sanctum CSRF cookie required before browser-session authentication requests.'; + $pathItem['responses'] = [ + 204 => [ + 'description' => 'The CSRF cookie was queued on the response.', + ], + ]; + + return $pathItem; + } + + /** + * @param OpenApiOperation $pathItem + */ + private function normalizeRawResponseMediaTypes(array &$pathItem, OutputEndpointData $endpoint): void + { + if (($pathItem['operationId'] ?? null) !== 'adminExportEgg' + && preg_match('#^api/admin/eggs/\{[^}]+\}/export$#', $endpoint->uri) !== 1 + ) { + return; + } + + if (! isset($pathItem['responses']) || ! is_array($pathItem['responses'])) { + return; + } + + foreach ($pathItem['responses'] as $status => &$response) { + if (! str_starts_with($this->arrayKeyString($status), '2') || ! isset($response['content']['application/json'])) { + continue; + } + + $media = $response['content']['application/json']; + $media['schema'] = [ + 'type' => 'string', + 'description' => 'Raw egg export JSON document returned as a text download.', + 'example' => '{"_comment":"DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PANEL","meta":{"version":"PTDL_v2"}}', + ]; + + $response['content'] = [ + 'text/plain' => $media, + ]; + } + + unset($response); + } + + /** + * @param OpenApiOperation $pathItem + */ + private function replaceErrorResponseSchemas(array &$pathItem): void + { + if (! isset($pathItem['responses']) || ! is_array($pathItem['responses'])) { + return; + } + + foreach ($pathItem['responses'] as $status => &$response) { + $schema = match ($this->arrayKeyString($status)) { + '400', '401', '403', '404', '409', '429', '500', '502', '504' => 'ErrorEnvelope', + '422' => 'ValidationErrorEnvelope', + default => null, + }; + + if ($schema !== null && isset($response['content']['application/json']['schema'])) { + $response['content']['application/json']['schema'] = ['$ref' => "#/components/schemas/{$schema}"]; + } + } + + unset($response); + } + + /** + * @param OpenApiOperation $pathItem + * @return OpenApiOperation + */ + private function normalizeSchemas(array $pathItem): array + { + // SAFETY: root path entries include non-operation OpenAPI values; every operation field is narrowed before use. + $parameters = $pathItem['parameters'] ?? null; + if (is_array($parameters)) { + foreach ($parameters as &$parameter) { + if (isset($parameter['schema']) && is_array($parameter['schema'])) { + JsonValueGuard::assertValue($parameter['schema']); + $this->normalizeSchema($parameter['schema']); + JsonValueGuard::assertPayload9($parameter['schema']); + } + } + + unset($parameter); + $pathItem['parameters'] = $parameters; + } + + if (isset($pathItem['requestBody'])) { + $requestBody = $this->openApiContainerValue($pathItem['requestBody']); + $content = is_array($requestBody) ? ($requestBody['content'] ?? null) : null; + if (is_array($content)) { + JsonValueGuard::assertOpenApiContent($content); + $requestBody['content'] = $this->normalizeContentSchemas($content); + } + + $pathItem['requestBody'] = $requestBody; + } + + $responses = $pathItem['responses'] ?? null; + if (is_array($responses)) { + foreach ($responses as &$response) { + $response = $this->openApiContainerValue($response); + if (! is_array($response)) { + continue; + } + + $content = $response['content'] ?? null; + if (is_array($content)) { + JsonValueGuard::assertOpenApiContent($content); + $response['content'] = $this->normalizeContentSchemas($content); + } + } + + unset($response); + $pathItem['responses'] = $responses; + } + + JsonValueGuard::assertOpenApiOperation($pathItem); + + return $pathItem; + } + + /** + * @param OpenApiRoot $root + */ + private function normalizeRootSchemas(array &$root): void + { + foreach ($root['paths'] ?? [] as &$pathItem) { + foreach ($pathItem as &$operation) { + if (is_array($operation)) { + JsonValueGuard::assertOpenApiOperation($operation); + $operation = $this->normalizeSchemas($operation); + } + } + + unset($operation); + } + + unset($pathItem); + + foreach ($root['components']['schemas'] as &$schema) { + $this->normalizeSchema($schema); + } + + unset($schema); + } + + /** + * @param OpenApiRoot $root + */ + private function pruneUnreferencedSchemas(array &$root): void + { + $schemas = &$root['components']['schemas']; + $reachable = $this->operationSchemaRefs; + $pending = array_keys($reachable); + + while ($pending !== []) { + $name = array_pop($pending); + if (! isset($schemas[$name])) { + continue; + } + + $refs = []; + $this->collectComponentRefs($schemas[$name], $refs); + foreach ($refs as $ref => $_) { + if (! isset($reachable[$ref])) { + $reachable[$ref] = true; + $pending[] = $ref; + } + } + } + + foreach (array_keys($schemas) as $name) { + if (! isset($reachable[$name])) { + unset($schemas[$name]); + } + } + } + + /** + * @param JsonInputValue $node + * @param array $refs + */ + private function collectComponentRefs(mixed $node, array &$refs): void + { + if (! is_array($node)) { + return; + } + + $ref = $node['$ref'] ?? null; + if (is_string($ref) && str_starts_with($ref, '#/components/schemas/')) { + $refs[mb_substr($ref, mb_strlen('#/components/schemas/'))] = true; + } + + foreach ($node as $value) { + JsonValueGuard::assertValue($value); + $this->collectComponentRefs($value, $refs); + } + } + + /** + * @param OpenApiOperation $operation + */ + private function extractResponseBodySchemas(array &$operation): void + { + $operationId = $operation['operationId'] ?? ''; + $operationId = is_string($operationId) ? $operationId : ''; + if ($operationId === '' || ! isset($operation['responses']) || ! is_array($operation['responses'])) { + return; + } + + $inlineSchemas = []; + foreach ($operation['responses'] as $status => $response) { + $content = $response['content'] ?? null; + if (! is_array($content)) { + continue; + } + + foreach ($content as $contentType => $media) { + if (isset($media['schema']) && is_array($media['schema']) && ! isset($media['schema']['$ref'])) { + $inlineSchemas[] = [$this->arrayKeyString($status), $this->arrayKeyString($contentType)]; + } + } + } + + $hasMultipleSchemas = count($inlineSchemas) > 1; + + foreach ($operation['responses'] as $status => &$response) { + if (! isset($response['content']) || ! is_array($response['content'])) { + continue; + } + + foreach ($response['content'] as $contentType => &$media) { + if (! isset($media['schema']) || ! is_array($media['schema']) || isset($media['schema']['$ref'])) { + continue; + } + + $this->normalizeNestedArrayItemSchemas($media['schema']); + JsonValueGuard::assertPayload9($media['schema']); + $this->normalizeSchema($media['schema']); + JsonValueGuard::assertPayload9($media['schema']); + + $component = $this->responseBodyComponentName($operationId, $this->arrayKeyString($status), $this->arrayKeyString($contentType), $hasMultipleSchemas); + $component = $this->availableComponentName($this->responseBodySchemas, $component, $media['schema']); + $this->responseBodySchemas[$component] = $media['schema']; + $media['schema'] = ['$ref' => "#/components/schemas/{$component}"]; + } + + unset($media); + } + + unset($response); + } + + /** + * @param OpenApiOperation $operation + */ + private function extractOperationParameterSchemas(array &$operation): void + { + $operationId = $operation['operationId'] ?? ''; + $operationId = is_string($operationId) ? $operationId : ''; + if ($operationId === '' || ! isset($operation['parameters']) || ! is_array($operation['parameters'])) { + return; + } + + foreach ($operation['parameters'] as &$parameter) { + $this->extractParameterSchema($parameter, $this->operationParameterSchemaComponentName($operationId, $parameter)); + } + + unset($parameter); + } + + /** + * @param ScribeParameter $parameter + */ + private function extractParameterSchema(array &$parameter, string $component): void + { + if (! isset($parameter['schema']) || ! is_array($parameter['schema']) || isset($parameter['schema']['$ref'])) { + return; + } + + JsonValueGuard::assertPayload9($parameter['schema']); + $component = $this->availableComponentName($this->parameterSchemas, $component, $parameter['schema']); + $this->parameterSchemas[$component] = $parameter['schema']; + $parameter['schema'] = ['$ref' => "#/components/schemas/{$component}"]; + } + + /** + * @param OpenApiOperation $operation + */ + private function extractRequestBodySchemas(array &$operation): void + { + $operationId = $operation['operationId'] ?? ''; + $operationId = is_string($operationId) ? $operationId : ''; + if ($operationId === '' || ! isset($operation['requestBody']['content']) || ! is_array($operation['requestBody']['content'])) { + return; + } + + $mediaWithSchemas = array_filter( + $operation['requestBody']['content'], + fn (array $media): bool => isset($media['schema']) && is_array($media['schema']) && ! isset($media['schema']['$ref']) + ); + $hasMultipleSchemas = count($mediaWithSchemas) > 1; + + foreach ($operation['requestBody']['content'] as $contentType => &$media) { + if (! isset($media['schema']) || ! is_array($media['schema']) || isset($media['schema']['$ref'])) { + continue; + } + + $component = $this->requestBodyComponentName($operationId, $this->arrayKeyString($contentType), $hasMultipleSchemas); + $component = $this->availableComponentName($this->requestBodySchemas, $component, $media['schema']); + $this->requestBodySchemas[$component] = $media['schema']; + $media['schema'] = ['$ref' => "#/components/schemas/{$component}"]; + } + + unset($media); + } + + /** + * @param OpenApiSchemaMap $schemas + * @param DeepOpenApiSchema $schema + */ + private function availableComponentName(array $schemas, string $name, array $schema): string + { + if (! isset($schemas[$name]) || $schemas[$name] === $schema) { + return $name; + } + + $index = 2; + while (isset($schemas["{$name}{$index}"]) && $schemas["{$name}{$index}"] !== $schema) { + $index++; + } + + return "{$name}{$index}"; + } + + private function requestBodyComponentName(string $operationId, string $contentType, bool $includeContentType): string + { + $name = Str::of($operationId)->studly()->append('Request'); + if (! $includeContentType) { + return $name->toString(); + } + + return $name + ->append(Str::of($contentType)->replace(['/', '+', '.', '-'], ' ')->studly()->toString()) + ->toString(); + } + + private function responseBodyComponentName(string $operationId, string $status, string $contentType, bool $includeStatusAndContentType): string + { + $name = Str::of($operationId)->studly(); + if ($includeStatusAndContentType) { + $name = $name + ->append($status) + ->append(Str::of($contentType)->replace(['/', '+', '.', '-'], ' ')->studly()->toString()); + } + + return $name->append('ResponseBody')->toString(); + } + + /** + * @param ScribeParameter $parameter + */ + private function operationParameterSchemaComponentName(string $operationId, array $parameter): string + { + $locationValue = $parameter['in'] ?? 'parameter'; + $location = Str::of(is_string($locationValue) ? $locationValue : 'parameter')->studly(); + $name = $this->parameterNameSegment($parameter); + + return Str::of($operationId) + ->studly() + ->append($name) + ->append($location->toString()) + ->append('Parameter') + ->toString(); + } + + /** + * @param ScribeParameter $parameter + */ + private function pathParameterSchemaComponentName(OutputEndpointData $endpoint, array $parameter): string + { + return Str::of($this->baseOperationId($endpoint)) + ->studly() + ->append($this->parameterNameSegment($parameter)) + ->append('PathParameter') + ->toString(); + } + + /** + * @param ScribeParameter $parameter + */ + private function parameterNameSegment(array $parameter): string + { + $name = $parameter['name'] ?? 'value'; + + return Str::of(is_string($name) ? $name : 'value') + ->replace('*', ' wildcard ') + ->replace(['[', ']', '/', '+', '.', '-', '_'], ' ') + ->studly() + ->toString(); + } + + /** + * @param OpenApiOperation $pathItem + */ + private function enforceKnownBodyParameterSchemas(array &$pathItem, OutputEndpointData $endpoint): void + { + if (! isset($pathItem['requestBody']['content']) || ! is_array($pathItem['requestBody']['content'])) { + return; + } + + $contentType = array_key_first($pathItem['requestBody']['content']); + if (! is_string($contentType)) { + return; + } + + $media = &$pathItem['requestBody']['content'][$contentType]; + $schema = $media['schema'] ?? null; + if (! is_array($schema)) { + return; + } + + $properties = $schema['properties']; + if (! is_array($properties)) { + return; + } + + $properties = $this->normalizeScribeValue($properties); + if (! is_array($properties)) { + return; + } + + JsonValueGuard::assertOpenApiSchemaMap($properties); + $schema['properties'] = &$properties; + $media['schema'] = &$schema; + + if (isset($endpoint->bodyParameters['environment'])) { + $properties['environment'] = [ + 'type' => 'object', + 'description' => PterodactylDocumentation::fieldDescription('environment'), + 'additionalProperties' => ['type' => 'string'], + 'example' => ['SERVER_JARFILE' => 'server.jar'], + ]; + } + + foreach (['features', 'file_denylist'] as $name) { + if (isset($endpoint->bodyParameters[$name])) { + $properties[$name] = [ + 'type' => 'array', + 'description' => PterodactylDocumentation::fieldDescription($name), + 'items' => ['type' => 'string'], + 'example' => PterodactylDocumentation::fieldExample($name, 'string[]'), + ]; + } + } + + if (isset($endpoint->bodyParameters['permissions'])) { + $properties['permissions'] = [ + ...$this->permissionsSchema(), + 'description' => PterodactylDocumentation::fieldDescription('permissions'), + ]; + } + + if (isset($endpoint->bodyParameters['preferences.language'])) { + $preferenceProperties = $properties['preferences']['properties'] ?? null; + if (is_array($preferenceProperties)) { + JsonValueGuard::assertOpenApiSchemaMap($preferenceProperties); + $preferenceProperties['language'] = [ + 'type' => 'string', + 'description' => PterodactylDocumentation::fieldDescription('preferences.language'), + 'example' => 'en', + ]; + $properties['preferences']['properties'] = $preferenceProperties; + } + } + + JsonValueGuard::assertOpenApiSchemaMap($properties); + match ($pathItem['operationId'] ?? null) { + 'applicationCreateServer' => $this->enforceApplicationCreateServerBodySchema($properties), + 'adminUpdateGeneralSettings' => $this->enforceAdminGeneralSettingsBodySchema($properties), + 'adminUpdateMailSettings' => $this->enforceAdminMailSettingsBodySchema($properties), + 'adminUpdateMinecraftVersionChangerSettings' => $this->enforceMinecraftVersionChangerSettingsBodySchema($properties), + 'adminUpdateExtensionSettings' => $this->enforceAdminExtensionSettingsBodySchema($properties), + default => null, + }; + } + + /** + * @param OpenApiSchemaMap $properties + */ + private function enforceApplicationCreateServerBodySchema(array &$properties): void + { + if (! isset($properties['deploy']['properties'])) { + return; + } + + $deploy = &$properties['deploy']['properties']; + JsonValueGuard::assertOpenApiSchemaMap($deploy); + $deploy['dedicated_ip'] = [ + 'type' => 'boolean', + 'description' => PterodactylDocumentation::fieldDescription('deploy.dedicated_ip'), + 'example' => false, + ]; + $deploy['tags'] = [ + 'type' => 'array', + 'description' => PterodactylDocumentation::fieldDescription('deploy.tags'), + 'items' => [ + 'oneOf' => [ + ['type' => 'integer'], + ['type' => 'string'], + ], + ], + 'example' => ['minecraft', 1], + ]; + } + + /** + * @param OpenApiSchemaMap $properties + */ + private function enforceAdminExtensionSettingsBodySchema(array &$properties): void + { + $properties['settings'] = [ + 'type' => 'object', + 'description' => 'Field values keyed by input name, as described by the settings schema.', + 'additionalProperties' => [ + ...$this->extensionSettingValueSchema(), + 'nullable' => true, + ], + 'example' => [ + 'curseforge_api_key' => 'cf-key', + 'enabled' => true, + 'result_limit' => 25, + ], + ]; + } + + /** + * @param OpenApiSchemaMap $properties + */ + private function enforceMinecraftVersionChangerSettingsBodySchema(array &$properties): void + { + if (isset($properties['typeCategories'])) { + $properties['typeCategories'] = [ + 'type' => 'object', + 'description' => 'Map of display category names to MCJars server type identifiers.', + 'additionalProperties' => [ + 'type' => 'array', + 'items' => ['type' => 'string'], + ], + 'example' => ['Recommended' => ['VANILLA', 'PAPER']], + ]; + } + } + + /** + * @param OpenApiSchemaMap $properties + */ + private function enforceAdminGeneralSettingsBodySchema(array &$properties): void + { + if (isset($properties['default_locale'])) { + $properties['default_locale'] = [ + 'type' => 'string', + 'description' => PterodactylDocumentation::fieldDescription('default_locale'), + 'example' => 'en', + ]; + } + } + + /** + * @param OpenApiSchemaMap $properties + */ + private function enforceAdminMailSettingsBodySchema(array &$properties): void + { + if (! isset($properties['smtp']['properties']['encryption'])) { + return; + } + + $properties['smtp']['properties']['encryption'] = [ + 'type' => 'string', + 'nullable' => true, + 'enum' => ['tls', 'ssl', null], + 'description' => PterodactylDocumentation::fieldDescription('smtp.encryption'), + 'example' => 'tls', + ]; + } + + /** + * @param OpenApiOperation $pathItem + * @return OpenApiOperation + */ + private function normalizeOperationRequestBody(array $pathItem, OutputEndpointData $endpoint): array + { + // SAFETY: Scribe supplies the operation tree; the value is narrowed before request-body mutation. + if (mb_strtoupper($endpoint->httpMethods[0]) === 'GET') { + $pathItem = array_diff_key($pathItem, ['requestBody' => true]); + JsonValueGuard::assertOpenApiOperation($pathItem); + + return $pathItem; + } + + if (($pathItem['operationId'] ?? null) !== 'clientWriteFileContents') { + return $pathItem; + } + + $pathItem['requestBody'] = [ + 'required' => true, + 'content' => [ + 'text/plain' => [ + 'schema' => [ + 'type' => 'string', + 'description' => 'Raw file contents to write.', + 'example' => "motd=A Minecraft Server\nserver-port=25565", + ], + ], + ], + ]; + + return $pathItem; + } + + /** + * @param OpenApiContent $content + * @return OpenApiContent + */ + private function normalizeContentSchemas(array $content): array + { + foreach ($content as &$media) { + if (isset($media['schema']) && is_array($media['schema'])) { + $media['schema'] = $this->normalizeScribeValue($media['schema']); + if (! is_array($media['schema'])) { + continue; + } + + $this->normalizeSchema($media['schema']); + JsonValueGuard::assertPayload9($media['schema']); + } + } + + unset($media); + + JsonValueGuard::assertOpenApiContent($content); + + return $content; + } + + /** + * @param OpenApiRecursiveNode $schema + * + * @param-out mixed $schema + */ + private function normalizeSchema(array &$schema): void + { + // SAFETY: recursive OpenAPI nodes have varying bounded depths; every value is narrowed before array access. + if (($schema['type'] ?? null) === 'object') { + $schema['type'] = 'object'; + $schema['additionalProperties'] = ['type' => 'string']; + } + + if (($schema['type'] ?? null) === 'object') { + $schema['type'] = 'object'; + $schema['additionalProperties'] = [ + 'type' => 'array', + 'items' => ['type' => 'string'], + ]; + } + + if ( + ($schema['type'] ?? null) === 'array' + && isset($schema['items']) + && is_array($schema['items']) + && ($schema['items']['type'] ?? null) === 'array' + && ! isset($schema['items']['items']) + && isset($schema['example'][0]) + ) { + $schema['items'] = PterodactylDocumentation::schemaForValue($schema['example'][0]); + } + + foreach (['properties', 'items', 'additionalProperties', 'oneOf', 'anyOf', 'allOf'] as $key) { + if (! isset($schema[$key]) || ! is_array($schema[$key])) { + continue; + } + + $child = &$schema[$key]; + if (array_is_list($child)) { + foreach ($child as &$item) { + if (is_array($item)) { + JsonValueGuard::assertValue($item); + $this->normalizeSchema($item); + } + } + + unset($item); + + continue; + } + + if (isset($child['type']) || isset($child['$ref'])) { + JsonValueGuard::assertValue($schema[$key]); + $this->normalizeSchema($schema[$key]); + + continue; + } + + foreach ($child as $name => &$item) { + if (is_array($item)) { + if ($name === 'installation' && ($item['type'] ?? null) === 'array') { + $item['items'] = [ + 'type' => 'array', + 'items' => ['type' => 'string'], + ]; + } + + JsonValueGuard::assertValue($item); + $this->normalizeSchema($item); + } + } + + unset($item); + unset($child); + } + } + + /** + * @param OpenApiRecursiveNode $schema + * + * @param-out mixed $schema + */ + private function normalizeNestedArrayItemSchemas(array &$schema): void + { + // SAFETY: recursive OpenAPI nodes have varying bounded depths; every value is narrowed before array access. + if ( + ($schema['type'] ?? null) === 'array' + && isset($schema['items']) + && is_array($schema['items']) + && ($schema['items']['type'] ?? null) === 'array' + && ! isset($schema['items']['items']) + && isset($schema['example'][0]) + && is_array($schema['example'][0]) + ) { + $schema['items'] = PterodactylDocumentation::schemaForValue($schema['example'][0]); + } + + foreach ($schema as &$value) { + if (is_array($value)) { + JsonValueGuard::assertValue($value); + $this->normalizeNestedArrayItemSchemas($value); + } + } + + unset($value); + } + + /** + * @param JsonInputValue|stdClass $value + * @return JsonValue + */ + private function arrayValue(bool|float|int|string|array|stdClass|null $value): bool|float|int|string|array|null + { + // SAFETY: Scribe exposes decoded values as mixed; this boundary rejects non-JSON values before returning them. + if ($value instanceof stdClass) { + return JsonValueGuard::decode(json_encode($value, JSON_THROW_ON_ERROR)); + } + + JsonValueGuard::assertValue($value); + + return $value; + } + + /** + * @param JsonValue|OpenApiRequestBody|OpenApiResponse|stdClass $value + * @return JsonValue|OpenApiRequestBody|OpenApiResponse + */ + private function openApiContainerValue(bool|float|int|string|array|stdClass|null $value): bool|float|int|string|array|null + { + if ($value instanceof stdClass) { + return JsonValueGuard::decode(json_encode($value, JSON_THROW_ON_ERROR)); + } + + return $value; + } + + /** + * @param JsonInputValue|stdClass $value + * @return JsonValue + */ + private function normalizeScribeValue(mixed $value): bool|float|int|string|array|null + { + return JsonValueGuard::decode(json_encode($value, JSON_THROW_ON_ERROR)); + } + + /** + * @return array{attributes: string, item: string, list: string, page: string} + */ + private function fractalComponents(OutputEndpointData $endpoint, string $resource): array + { + return $this->fractalComponentNames($this->surface($endpoint), $resource); + } + + /** + * @return array{attributes: string, item: string, list: string, page: string} + */ + private function fractalComponentNames(string $surface, string $resource): array + { + $name = Str::of(ucfirst($surface).' '.$resource) + ->studly() + ->toString(); + + return [ + 'attributes' => "{$name}Attributes", + 'item' => "{$name}Resource", + 'list' => "{$name}ListResponse", + 'page' => "{$name}PaginatedResponse", + ]; + } + + /** + * @param OpenApiSchemaInput $schema + * @param ApiPayload9 $relationships + * @param array $knownComponents + */ + private function addRelationshipsToAttributesSchema(array &$schema, OutputEndpointData $endpoint, array $relationships, array $knownComponents): void + { + // SAFETY: generated schemas vary in depth; the mutable object-schema fields are validated before use. + $properties = $schema['properties'] ?? null; + JsonValueGuard::assertOpenApiSchemaMap($properties); + $relationshipSchema = $this->relationshipsSchema($endpoint, $relationships, $knownComponents); + $existing = $properties['relationships'] ?? null; + + if (is_array($existing)) { + $existingProperties = $existing['properties'] ?? []; + JsonValueGuard::assertOpenApiSchemaMap($existingProperties); + $relationshipSchema['properties'] = [ + ...$existingProperties, + ...$relationshipSchema['properties'], + ]; + } + + $properties['relationships'] = $relationshipSchema; + $updatedSchema = $schema; + $updatedSchema['properties'] = $properties; + + if (isset($updatedSchema['required'])) { + JsonValueGuard::assertStringList($updatedSchema['required']); + $updatedSchema['required'] = array_values(array_filter( + $updatedSchema['required'], + fn (string $key): bool => $key !== 'relationships' + )); + } + + JsonValueGuard::assertOpenApiSchemaInput($updatedSchema); + $schema = $updatedSchema; + } + + /** + * @param ApiPayload9 $relationships + * @param array $knownComponents + * @return OpenApiObjectSchema + */ + private function relationshipsSchema(OutputEndpointData $endpoint, array $relationships, array $knownComponents): array + { + $properties = []; + + foreach ($relationships as $name => $relationship) { + $properties[$name] = $this->relationshipValueSchema($endpoint, $this->arrayKeyString($name), $relationship, $knownComponents); + } + + return [ + 'type' => 'object', + 'properties' => $properties, + ]; + } + + /** + * @param JsonInputValue $relationship + * @param array $knownComponents + * @return DeepOpenApiSchema + */ + private function relationshipValueSchema(OutputEndpointData $endpoint, string $name, mixed $relationship, array $knownComponents): array + { + if (! is_array($relationship)) { + return PterodactylDocumentation::schemaForValue($relationship); + } + + if (($relationship['object'] ?? null) === 'list') { + $item = $relationship['data'][0] ?? null; + if (is_array($item) && is_string($item['object'] ?? null)) { + return $this->relationshipRefSchema($endpoint, $knownComponents, 'list', $name, $item['object']) + ?? PterodactylDocumentation::schemaForValue($relationship); + } + + return $this->relationshipRefSchema($endpoint, $knownComponents, 'list', $name) + ?? PterodactylDocumentation::schemaForValue($relationship); + } + + if (is_string($relationship['object'] ?? null) && is_array($relationship['attributes'] ?? null)) { + return $this->relationshipRefSchema($endpoint, $knownComponents, 'item', $name, $relationship['object']) + ?? PterodactylDocumentation::schemaForValue($relationship); + } + + return PterodactylDocumentation::schemaForValue($relationship); + } + + /** + * @param array $knownComponents + * @param 'item'|'list' $kind + * @return DeepOpenApiSchema|null + */ + private function relationshipRefSchema(OutputEndpointData $endpoint, array $knownComponents, string $kind, string $relationship, ?string $resource = null): ?array + { + $componentKey = $kind === 'list' ? 'list' : 'item'; + + foreach ($this->relationshipResourceCandidates($relationship, $resource) as $candidate) { + $components = $this->fractalComponentNames($this->surface($endpoint), $candidate); + if (isset($knownComponents[$components[$componentKey]])) { + // Any include resolves to a null resource when the viewer lacks + // permission for it, so relationships are documented as a union. + return [ + 'oneOf' => [ + ['$ref' => "#/components/schemas/{$components[$componentKey]}"], + ['$ref' => '#/components/schemas/NullResource'], + ], + ]; + } + } + + return null; + } + + /** @return OpenApiSchema */ + private function nullResourceSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['object', 'attributes'], + 'properties' => [ + 'object' => ['type' => 'string', 'enum' => ['null_resource'], 'example' => 'null_resource'], + 'attributes' => ['nullable' => true, 'enum' => [null]], + ], + ]; + } + + /** + * @return string[] + */ + private function relationshipResourceCandidates(string $relationship, ?string $resource): array + { + $candidates = []; + + if ($resource !== null) { + $candidates[] = $resource; + } + + $candidates[] = Str::singular($relationship); + + $mapped = match ($relationship) { + 'allocations' => 'allocation', + 'tasks' => 'schedule_task', + 'variables' => 'egg_variable', + default => null, + }; + + if ($mapped !== null) { + $candidates[] = $mapped; + } + + return array_values(array_unique($candidates)); + } + + /** @return OpenApiSchema */ + private function fractalItemSchema(string $resource, string $attributesSchema): array + { + return [ + 'type' => 'object', + 'required' => ['object', 'attributes'], + 'properties' => [ + 'object' => [ + 'type' => 'string', + 'example' => $resource, + ], + 'attributes' => ['$ref' => "#/components/schemas/{$attributesSchema}"], + ], + ]; + } + + /** + * @param OpenApiSchemaInput $schema + * @param ApiPayload9 $meta + */ + private function addMetaToItemSchema(array &$schema, array $meta): void + { + $this->addMetaProperty($schema, $meta); + } + + /** + * @param OpenApiSchemaInput $schema + * @param ApiPayload9 $meta + */ + private function addMetaToListSchema(array &$schema, array $meta): void + { + $this->addMetaProperty($schema, $meta); + } + + /** + * @param OpenApiSchemaInput $schema + * @param ApiPayload9 $meta + */ + private function addMetaToPaginatedSchema(array &$schema, array $meta): void + { + // SAFETY: generated paginated schemas vary in depth; each mutable schema map and list is validated before use. + $properties = $schema['properties'] ?? null; + JsonValueGuard::assertOpenApiSchemaMap($properties); + $paginationMeta = $properties['meta'] ?? []; + $metaSchema = $this->metaSchema($meta); + $required = $paginationMeta['required'] ?? []; + JsonValueGuard::assertStringList($required); + $metaRequired = $metaSchema['required'] ?? []; + $paginationMeta['required'] = array_values(array_unique([ + ...$required, + ...$metaRequired, + ])); + $paginationProperties = $paginationMeta['properties'] ?? []; + JsonValueGuard::assertOpenApiSchemaMap($paginationProperties); + $paginationMeta['properties'] = [ + ...$paginationProperties, + ...$metaSchema['properties'], + ]; + $properties['meta'] = $paginationMeta; + $updatedSchema = $schema; + $updatedSchema['properties'] = $properties; + JsonValueGuard::assertOpenApiSchemaInput($updatedSchema); + $schema = $updatedSchema; + } + + /** + * @param OpenApiSchemaInput $schema + * @param ApiPayload9 $meta + */ + private function addMetaProperty(array &$schema, array $meta): void + { + // SAFETY: generated schemas vary in depth; the properties map is validated before mutation. + $properties = $schema['properties'] ?? null; + JsonValueGuard::assertOpenApiSchemaMap($properties); + $properties['meta'] = $this->metaSchema($meta); + $updatedSchema = $schema; + $updatedSchema['properties'] = $properties; + JsonValueGuard::assertOpenApiSchemaInput($updatedSchema); + $schema = $updatedSchema; + } + + /** + * @param array $meta + * @return OpenApiObjectSchema + */ + private function metaSchema(array $meta): array + { + $properties = []; + foreach ($meta as $key => $value) { + $properties[$key] = PterodactylDocumentation::schemaForValue($value); + } + + $schema = [ + 'type' => 'object', + 'required' => array_keys($properties), + 'properties' => $properties, + ]; + + if (isset($schema['properties']['docker_images'])) { + $schema['properties']['docker_images'] = [ + 'type' => 'object', + 'additionalProperties' => ['type' => 'string'], + 'example' => ['Java 23' => 'ghcr.io/pterodactyl/yolks:java_23'], + ]; + } + + return $schema; + } + + /** @return FractalListOpenApiSchema */ + private function fractalListSchema(string $itemSchema): array + { + return [ + 'type' => 'object', + 'required' => ['object', 'data'], + 'properties' => [ + 'object' => [ + 'type' => 'string', + 'example' => 'list', + ], + 'data' => [ + 'type' => 'array', + 'items' => ['$ref' => "#/components/schemas/{$itemSchema}"], + ], + ], + ]; + } + + /** @return FractalPaginatedOpenApiSchema */ + private function fractalPaginatedSchema(string $itemSchema): array + { + $schema = $this->fractalListSchema($itemSchema); + $schema['required'][] = 'meta'; + $schema['properties']['meta'] = [ + 'type' => 'object', + 'required' => ['pagination'], + 'properties' => [ + 'pagination' => ['$ref' => '#/components/schemas/PaginationMeta'], + ], + ]; + + return $schema; + } + + /** @return OpenApiSchema */ + private function paginationMetaSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['total', 'count', 'per_page', 'current_page', 'total_pages'], + 'properties' => [ + 'total' => ['type' => 'integer', 'example' => 1], + 'count' => ['type' => 'integer', 'example' => 1], + 'per_page' => ['type' => 'integer', 'example' => 50], + 'current_page' => ['type' => 'integer', 'example' => 1], + 'total_pages' => ['type' => 'integer', 'example' => 1], + 'links' => [ + 'type' => 'object', + 'additionalProperties' => ['type' => 'string'], + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function adminLanguagesSchema(): array + { + return [ + 'type' => 'object', + 'description' => 'Available panel locales keyed by locale code.', + 'additionalProperties' => ['type' => 'string'], + 'example' => ['en' => 'English'], + ]; + } + + /** @return OpenApiSchema */ + private function permissionsSchema(): array + { + $permissions = Permission::permissions() + ->map(fn (array $value, string $prefix): array => array_map( + fn (int|string $permission): string => "{$prefix}.{$permission}", + array_keys($value['keys']) + )) + ->flatten() + ->values() + ->all(); + JsonValueGuard::assertStringList($permissions); + + return [ + 'type' => 'array', + 'items' => [ + 'anyOf' => [ + ['type' => 'string', 'enum' => $permissions], + ['type' => 'string', 'pattern' => ExtensionPermissionRegistry::PERMISSION_PATTERN, 'description' => 'A permission registered by an enabled extension.'], + ], + ], + 'example' => ['websocket.connect', 'control.console'], + ]; + } + + /** @return OpenApiSchema */ + private function adminEggConfigurationFilesSchema(): array + { + return [ + 'type' => 'object', + 'additionalProperties' => ['$ref' => '#/components/schemas/AdminEggConfigurationFile'], + 'example' => ['server.properties' => ['parser' => 'properties', 'find' => ['server-port' => '{{server.build.default.port}}']]], + ]; + } + + /** @return OpenApiSchema */ + private function adminEggConfigurationFileSchema(): array + { + return [ + 'type' => 'object', + 'properties' => [ + 'parser' => ['type' => 'string'], + 'find' => ['$ref' => '#/components/schemas/AdminEggConfigurationFind'], + ], + ]; + } + + /** @return OpenApiSchema */ + private function adminEggConfigurationFindSchema(): array + { + return [ + 'type' => 'object', + 'additionalProperties' => [ + 'oneOf' => [ + ['type' => 'string'], + ['type' => 'number'], + ['type' => 'boolean'], + ['type' => 'object', 'additionalProperties' => ['type' => 'string']], + ], + ], + ]; + } + + /** @return DeepOpenApiSchema */ + private function adminNodeConfigurationSchema(): array + { + return PterodactylDocumentation::schemaForValue([ + 'debug' => false, + 'uuid' => '1b19cf3f-2f89-4f88-a81e-321e7fe326bc', + 'token_id' => 'abcd1234', + 'token' => 'secret', + 'api' => [ + 'host' => '0.0.0.0', + 'port' => 8080, + 'ssl' => [ + 'enabled' => true, + 'cert' => '/etc/letsencrypt/live/node.example.com/fullchain.pem', + 'key' => '/etc/letsencrypt/live/node.example.com/privkey.pem', + ], + 'upload_limit' => 100, + ], + 'system' => [ + 'data' => '/var/lib/pterodactyl/volumes', + 'sftp' => [ + 'bind_port' => 2022, + ], + ], + 'allowed_mounts' => ['/mnt/shared'], + 'remote' => 'https://panel.example.com', + ]); + } + + /** @return DeepOpenApiSchema */ + private function adminNodeDeployTokenSchema(): array + { + return PterodactylDocumentation::schemaForValue([ + 'node' => 1, + 'token' => 'ptla_1234567890abcdef', + 'panel_url' => 'https://panel.example.com', + 'allow_insecure' => false, + ]); + } + + /** @return DeepOpenApiSchema */ + private function adminNodeSystemInformationSchema(): array + { + return PterodactylDocumentation::schemaForValue([ + 'architecture' => 'amd64', + 'cpu_count' => 8, + 'kernel_version' => '6.8.0', + 'os' => 'linux', + 'version' => '1.11.0', + ]); + } + + /** @return DeepOpenApiSchema */ + private function adminNodeUtilizationSchema(): array + { + $metric = [ + 'value' => '1,024', + 'max' => '102,400', + 'percent' => 1.0, + 'css' => 'green', + ]; + + return PterodactylDocumentation::schemaForValue([ + 'disk' => $metric, + 'memory' => $metric, + ]); + } + + /** @return OpenApiSchema */ + private function adminExtensionSettingsSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['data'], + 'properties' => [ + 'data' => [ + 'type' => 'object', + 'required' => ['registered', 'schema'], + 'properties' => [ + 'registered' => ['type' => 'boolean', 'example' => true], + 'schema' => [ + 'type' => 'array', + 'items' => ['$ref' => '#/components/schemas/AdminExtensionSettingField'], + ], + ], + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function adminExtensionSettingFieldSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['input', 'label', 'help', 'tab', 'field', 'options', 'value', 'constraints', 'visibility'], + 'properties' => [ + 'input' => ['type' => 'string', 'example' => 'curseforge_api_key'], + 'label' => ['type' => 'string', 'example' => 'CurseForge API Key'], + 'help' => ['type' => 'string', 'nullable' => true, 'example' => 'Leave blank to keep the stored key.'], + 'tab' => ['type' => 'string', 'nullable' => true, 'example' => 'CurseForge'], + 'field' => [ + 'type' => 'string', + 'enum' => ExtensionSettingDefinition::FIELDS, + 'example' => 'password', + ], + 'options' => [ + 'type' => 'array', + 'items' => ['$ref' => '#/components/schemas/AdminExtensionSettingOption'], + ], + 'value' => [ + ...$this->extensionSettingValueSchema(), + 'nullable' => true, + ], + 'constraints' => [ + 'type' => 'object', + 'required' => ['max_length', 'max_items', 'max_kilobytes', 'accept'], + 'properties' => [ + 'max_length' => ['type' => 'integer', 'nullable' => true, 'example' => null], + 'max_items' => ['type' => 'integer', 'nullable' => true, 'example' => null], + 'max_kilobytes' => ['type' => 'integer', 'nullable' => true, 'example' => null], + 'accept' => ['type' => 'array', 'items' => ['type' => 'string', 'example' => 'image/png']], + ], + ], + 'visibility' => [ + 'type' => 'string', + 'enum' => ['admin', 'frontend', 'public'], + 'example' => 'admin', + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function adminExtensionSettingOptionSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['value', 'label'], + 'properties' => [ + 'value' => $this->extensionSettingScalarSchema(), + 'label' => ['type' => 'string', 'example' => 'Recommended'], + ], + ]; + } + + /** + * A setting's value: a scalar, or the list a multiselect or list field holds. + * + * @return array{oneOf: list}}>} + */ + private function extensionSettingValueSchema(): array + { + return [ + 'oneOf' => [ + ...$this->extensionSettingScalarSchema()['oneOf'], + ['type' => 'array', 'items' => ['oneOf' => [['type' => 'string'], ['type' => 'number']]]], + ], + ]; + } + + /** + * @return array{oneOf: list} + */ + private function extensionSettingScalarSchema(): array + { + return [ + 'oneOf' => [ + ['type' => 'string'], + ['type' => 'number'], + ['type' => 'boolean'], + ], + ]; + } + + /** @return OpenApiSchema */ + private function adminSettingsSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['general', 'mail', 'advanced', 'meta'], + 'properties' => [ + 'general' => [ + 'type' => 'object', + 'required' => ['app:name', 'pterodactyl:auth:2fa_required', 'app:locale'], + 'properties' => [ + 'app:name' => ['type' => 'string', 'example' => 'Pterodactyl'], + 'pterodactyl:auth:2fa_required' => ['type' => 'integer', 'enum' => [0, 1, 2], 'example' => 0], + 'app:locale' => ['type' => 'string', 'example' => 'en'], + ], + ], + 'mail' => [ + 'type' => 'object', + 'required' => [ + 'mail:default', + 'mail:mailers:smtp:host', + 'mail:mailers:smtp:port', + 'mail:mailers:smtp:encryption', + 'mail:mailers:smtp:username', + 'mail:mailers:smtp:password', + 'mail:from:address', + 'mail:from:name', + ], + 'properties' => [ + 'mail:default' => ['type' => 'string', 'example' => 'smtp'], + 'mail:mailers:smtp:host' => ['type' => 'string', 'example' => 'mail.example.com'], + 'mail:mailers:smtp:port' => ['type' => 'integer', 'example' => 587], + 'mail:mailers:smtp:encryption' => [ + 'type' => 'string', + 'nullable' => true, + 'enum' => ['tls', 'ssl', null], + 'example' => 'tls', + ], + 'mail:mailers:smtp:username' => ['type' => 'string', 'nullable' => true, 'example' => 'panel@example.com'], + 'mail:mailers:smtp:password' => ['type' => 'string', 'example' => ''], + 'mail:from:address' => ['type' => 'string', 'example' => 'panel@example.com'], + 'mail:from:name' => ['type' => 'string', 'nullable' => true, 'example' => 'Pterodactyl'], + ], + ], + 'advanced' => [ + 'type' => 'object', + 'required' => [ + 'recaptcha:enabled', + 'recaptcha:secret_key', + 'recaptcha:website_key', + 'pterodactyl:guzzle:timeout', + 'pterodactyl:guzzle:connect_timeout', + 'pterodactyl:client_features:allocations:enabled', + 'pterodactyl:client_features:allocations:range_start', + 'pterodactyl:client_features:allocations:range_end', + ], + 'properties' => [ + 'recaptcha:enabled' => ['type' => 'boolean', 'example' => false], + 'recaptcha:secret_key' => ['type' => 'string', 'example' => 'secret'], + 'recaptcha:website_key' => ['type' => 'string', 'example' => 'website'], + 'pterodactyl:guzzle:timeout' => ['type' => 'integer', 'example' => 15], + 'pterodactyl:guzzle:connect_timeout' => ['type' => 'integer', 'example' => 5], + 'pterodactyl:client_features:allocations:enabled' => ['type' => 'boolean', 'example' => false], + 'pterodactyl:client_features:allocations:range_start' => ['type' => 'integer', 'nullable' => true, 'example' => null], + 'pterodactyl:client_features:allocations:range_end' => ['type' => 'integer', 'nullable' => true, 'example' => null], + ], + ], + 'meta' => [ + 'type' => 'object', + 'required' => ['load_environment_only', 'show_recaptcha_warning'], + 'properties' => [ + 'load_environment_only' => ['type' => 'boolean', 'example' => false], + 'show_recaptcha_warning' => ['type' => 'boolean', 'example' => false], + ], + ], + ], + ]; + } + + /** @return OpenApiSchema */ + private function adminVersionInformationSchema(): array + { + return [ + 'type' => 'object', + 'required' => ['current', 'latest', 'is_latest', 'daemon', 'discord', 'donations'], + 'properties' => [ + 'current' => ['type' => 'string', 'example' => '1.0.0'], + 'latest' => ['type' => 'string', 'example' => '1.0.0'], + 'is_latest' => ['type' => 'boolean', 'example' => true], + 'daemon' => ['type' => 'string', 'example' => '1.0.0'], + 'discord' => ['type' => 'string', 'example' => 'https://pterodactyl.io/discord'], + 'donations' => ['type' => 'string', 'example' => 'https://github.com/sponsors/pterodactyl'], + ], + ]; + } + + /** @return OpenApiSchema */ + private function errorEnvelopeSchema(bool $validation): array + { + $error = [ + 'type' => 'object', + 'required' => ['code', 'status', 'detail'], + 'properties' => [ + 'code' => ['type' => 'string'], + 'status' => ['type' => 'string'], + 'detail' => ['type' => 'string'], + ], + ]; + + if ($validation) { + $error['properties']['source'] = [ + 'type' => 'object', + 'required' => ['field'], + 'properties' => [ + 'field' => ['type' => 'string'], + ], + ]; + } + + return [ + 'type' => 'object', + 'required' => ['errors'], + 'properties' => [ + 'errors' => [ + 'type' => 'array', + 'items' => $error, + ], + ], + ]; + } + + /** + * @param array $groupedEndpoints + * @return array + */ + private function operationIds(array $groupedEndpoints): array + { + if ($this->operationIds !== null) { + return $this->operationIds; + } + + $bases = []; + foreach ($groupedEndpoints as $group) { + foreach ($group['endpoints'] as $endpoint) { + $bases[$this->baseOperationId($endpoint)][] = $endpoint; + } + } + + $operationIds = []; + foreach ($bases as $base => $endpoints) { + foreach ($endpoints as $endpoint) { + $operationIds[$this->endpointKey($endpoint)] = count($endpoints) === 1 + ? $base + : $base.'For'.$this->pathSuffix($endpoint); + } + } + + return $this->operationIds = $operationIds; + } + + private function baseOperationId(OutputEndpointData $endpoint): string + { + $uri = preg_replace('/\{([^}:]+):[^}]+\}/', '{$1}', $endpoint->uri) ?: $endpoint->uri; + $uri = mb_trim($uri, '/'); + + $authOperation = match (mb_strtoupper($endpoint->httpMethods[0]).' '.$uri) { + 'GET sanctum/csrf-cookie' => 'authGetCsrfCookie', + 'POST auth/login' => 'authLogin', + 'POST auth/login/checkpoint' => 'authCompleteLoginCheckpoint', + 'POST auth/logout' => 'authLogout', + 'POST auth/password' => 'authRequestPasswordResetEmail', + 'POST auth/password/reset' => 'authResetPassword', + default => null, + }; + if ($authOperation !== null) { + return $authOperation; + } + + if (mb_strtoupper($endpoint->httpMethods[0]) === 'DELETE') { + if (preg_match('#^api/admin/servers/\{[^}]+\}$#', $uri) === 1) { + return 'adminDeleteServer'; + } + + if (preg_match('#^api/admin/servers/\{[^}]+\}/force$#', $uri) === 1) { + return 'adminForceDeleteServer'; + } + } + + return $this->operationIdFromTitle($endpoint); + } + + private function operationIdFromTitle(OutputEndpointData $endpoint): string + { + $title = $endpoint->metadata->title ?: $this->fallbackTitle($endpoint); + // Titles are free text (extension endpoints especially) - anything but + // word characters must not reach operationIds, which seed component + // names and therefore $ref paths ("mods/modpacks" would emit refs the + // client generator rejects). + $title = preg_replace('/[^A-Za-z0-9]+/', ' ', $title) ?? $title; + + return $this->surface($endpoint).ucfirst(Str::camel($title)); + } + + private function fallbackTitle(OutputEndpointData $endpoint): string + { + $path = preg_replace('/\{[^}]+\}/', '', $endpoint->uri) ?: $endpoint->uri; + + return mb_strtolower($endpoint->httpMethods[0]).' '.$path; + } + + private function surface(OutputEndpointData $endpoint): string + { + return match (true) { + str_starts_with($endpoint->uri, 'auth/') => 'auth', + $endpoint->uri === 'sanctum/csrf-cookie' => 'auth', + str_starts_with($endpoint->uri, 'api/admin') => 'admin', + str_starts_with($endpoint->uri, 'api/application') => 'application', + str_starts_with($endpoint->uri, 'api/client') => 'client', + default => 'api', + }; + } + + private function pathSuffix(OutputEndpointData $endpoint): string + { + $path = preg_replace('#^(api/(admin|application|client)|auth)/?#', '', $endpoint->uri) ?: $endpoint->uri; + $path = preg_replace('#^sanctum/#', '', $path) ?: $path; + $path = preg_replace('/[{}?]/', '', $path) ?: $path; + + $suffix = Str::studly(str_replace('/', ' ', $path)); + + return $suffix !== '' ? $suffix : ucfirst(mb_strtolower($endpoint->httpMethods[0])); + } + + private function endpointKey(OutputEndpointData $endpoint): string + { + return mb_strtoupper($endpoint->httpMethods[0]).' '.$endpoint->uri; + } + + private function arrayKeyString(int|string $key): string + { + // SAFETY: PHP array keys are restricted to integers and strings, both of which have lossless string forms for OpenAPI names. + return (string) $key; + } + + /** + * @return array{resource: string, attributes: ApiPayload9, relationships?: ApiPayload9, collection: bool, paginated: bool, meta?: ApiPayload9, top_meta?: ApiPayload9}|null + */ + private function fractalResponse(OutputEndpointData $endpoint): ?array + { + foreach ($endpoint->responses as $response) { + if (! $response instanceof ExtractedResponse) { + continue; + } + + $status = $response->status; + $status = $this->arrayKeyString($status); + if (! str_starts_with($status, '2') || $status === '204') { + continue; + } + + $content = $response->content; + if (! is_string($content)) { + continue; + } + + $decoded = json_decode($content, true); + if (! is_array($decoded)) { + continue; + } + + JsonValueGuard::assertPayload9($decoded); + + if (($decoded['object'] ?? null) === 'list') { + $item = $decoded['data'][0] ?? null; + if (! is_array($item) || ! is_array($item['attributes'] ?? null)) { + continue; + } + + $attributes = $item['attributes']; + JsonValueGuard::assertPayload9($attributes); + $relationships = $this->extractRelationships($attributes); + $pagination = $decoded['meta'] ?? null; + $fractal = [ + 'resource' => is_string($item['object'] ?? null) ? $item['object'] : 'resource', + 'attributes' => $attributes, + 'collection' => true, + 'paginated' => is_array($pagination) && isset($pagination['pagination']), + ]; + + if (isset($item['meta']) && is_array($item['meta'])) { + JsonValueGuard::assertPayload9($item['meta']); + $fractal['meta'] = $item['meta']; + } + + if (isset($decoded['meta']) && is_array($decoded['meta'])) { + $topMeta = $decoded['meta']; + unset($topMeta['pagination']); + if ($topMeta !== []) { + JsonValueGuard::assertPayload9($topMeta); + $fractal['top_meta'] = $topMeta; + } + } + + if ($relationships !== null) { + $fractal['relationships'] = $relationships; + } + + return $fractal; + } + + if (is_string($decoded['object'] ?? null) && is_array($decoded['attributes'] ?? null)) { + $attributes = $decoded['attributes']; + JsonValueGuard::assertPayload9($attributes); + $relationships = $this->extractRelationships($attributes); + $fractal = [ + 'resource' => $decoded['object'], + 'attributes' => $attributes, + 'collection' => false, + 'paginated' => false, + ]; + + if (isset($decoded['meta']) && is_array($decoded['meta'])) { + JsonValueGuard::assertPayload9($decoded['meta']); + $fractal['meta'] = $decoded['meta']; + } + + if ($relationships !== null) { + $fractal['relationships'] = $relationships; + } + + return $fractal; + } + } + + return null; + } + + /** + * @param ApiPayload9 $attributes + * @return ApiPayload9|null + */ + private function extractRelationships(array &$attributes): ?array + { + $relationships = $attributes['relationships'] ?? null; + unset($attributes['relationships']); + + if (! is_array($relationships) || $relationships === []) { + return null; + } + + JsonValueGuard::assertPayload9($relationships); + + return $relationships; + } +} diff --git a/app/Extensions/Scribe/Strategies/InferPterodactylBodyParameters.php b/app/Extensions/Scribe/Strategies/InferPterodactylBodyParameters.php new file mode 100644 index 000000000..37827be97 --- /dev/null +++ b/app/Extensions/Scribe/Strategies/InferPterodactylBodyParameters.php @@ -0,0 +1,169 @@ +getFormRequestReflectionClass($method)) instanceof ReflectionClass) { + return []; + } + + if (! $this->isFormRequestMeantForThisStrategy($formRequestReflectionClass)) { + return []; + } + + $className = $formRequestReflectionClass->getName(); + + $factory = Globals::$__instantiateFormRequestUsing; + if (is_callable($factory)) { + $formRequest = $factory($className, $route, $method); + } else { + $formRequest = new $className; + } + + if (! $formRequest instanceof FormRequest) { + return []; + } + + $formRequest->setRouteResolver(function () use ($formRequest, $method, $route) { + $boundRoute = $route->bind($formRequest); + $this->bindRouteModelPlaceholders($method, $boundRoute); + + return $boundRoute; + }); + $formRequest->server->set('REQUEST_METHOD', $route->methods()[0]); + + try { + $validationRules = $this->getRouteValidationRules($formRequest); + if (! is_array($validationRules)) { + return []; + } + + $parameters = $this->getParametersFromValidationRules( + $validationRules, + $this->getCustomParameterData($formRequest) + ); + } catch (Throwable) { + return []; + } + + $normalizable = []; + foreach ($parameters as $name => $parameter) { + if (is_array($parameter)) { + $normalizable[$name] = $parameter; + } + } + + $inferred = $this->normaliseArrayAndObjectParameters($normalizable); + $parameters = []; + foreach ($inferred as $name => $parameter) { + if (! is_string($name) || ! is_array($parameter)) { + continue; + } + + foreach ($parameter as $key => $value) { + if ($value instanceof UploadedFile) { + $parameter[$key] = $value->getClientOriginalName(); + } + } + + JsonValueGuard::assertPayload($parameter); + $parameters[$name] = $parameter; + } + + foreach ($parameters as $name => $parameter) { + if ($type = PterodactylDocumentation::fieldType($name)) { + $parameters[$name]['type'] = $type; + } + + if ($name === 'options') { + $parameters[$name]['type'] = 'string[]'; + } + + if ($name === 'order') { + $parameters[$name]['type'] = 'integer[]'; + } + + $type = $parameters[$name]['type'] ?? 'string'; + if (! is_string($type)) { + $type = 'string'; + $parameters[$name]['type'] = $type; + } + + $parameters[$name]['example'] = PterodactylDocumentation::fieldExample($name, $type); + } + + return $parameters; + } + + /** + * @return array + */ + protected function getCustomParameterData(FormRequest $formRequest): array + { + try { + $rules = method_exists($formRequest, 'rules') ? app()->call([$formRequest, 'rules']) : []; + } catch (Throwable) { + return []; + } + + if (! is_array($rules)) { + return []; + } + + $data = []; + + foreach (array_keys($rules) as $name) { + // Rule keys are ordinarily field names, but a purely numeric-looking key + // (e.g. "0") would be cast to an int by PHP's array key coercion -- skip + // it rather than pretend it is the string field name callers expect. + if (! is_string($name) || str_contains($name, '*')) { + continue; + } + + $data[$name] = [ + 'description' => PterodactylDocumentation::fieldDescription($name), + ]; + } + + return $data; + } + + private function bindRouteModelPlaceholders(ReflectionFunctionAbstract $method, Route $route): void + { + foreach ($method->getParameters() as $parameter) { + $type = $parameter->getType(); + + if (! $type instanceof ReflectionNamedType || ! is_subclass_of($type->getName(), Model::class)) { + continue; + } + + $modelClass = $type->getName(); + $model = new $modelClass; + $model->setAttribute($model->getKeyName(), 1); + $model->exists = true; + + $route->setParameter($parameter->getName(), $model); + } + } +} diff --git a/app/Extensions/Scribe/Strategies/InferPterodactylResponses.php b/app/Extensions/Scribe/Strategies/InferPterodactylResponses.php new file mode 100644 index 000000000..46a1d59ca --- /dev/null +++ b/app/Extensions/Scribe/Strategies/InferPterodactylResponses.php @@ -0,0 +1,136 @@ + $settings settings to be applied to this strategy + * @return list + */ + public function __invoke(ExtractedEndpointData $endpointData, array $settings = []): ?array + { + $responses = []; + $existingStatuses = []; + foreach ($endpointData->responses as $response) { + if ($response instanceof ExtractedResponse) { + $existingStatuses[] = $response->status; + } + } + + foreach ($this->standardErrorResponses($endpointData) as $response) { + if (! in_array($response['status'], $existingStatuses, true)) { + $responses[] = $response; + $existingStatuses[] = $response['status']; + } + } + + return $responses; + } + + /** + * @return list + */ + private function standardErrorResponses(ExtractedEndpointData $endpointData): array + { + $responses = [ + [ + 'status' => Response::HTTP_UNAUTHORIZED, + 'content' => PterodactylDocumentation::AUTHENTICATION_ERROR, + 'description' => 'Authentication credentials were missing or invalid.', + ], + ]; + + if ($this->usesApiRequest($endpointData) || $this->canReturnForbidden($endpointData)) { + $responses[] = [ + 'status' => Response::HTTP_FORBIDDEN, + 'content' => PterodactylDocumentation::FORBIDDEN_ERROR, + 'description' => 'The API key does not have permission to perform this action.', + ]; + } + + if ($this->hasRouteModelBinding($endpointData) || $endpointData->urlParameters !== []) { + $responses[] = [ + 'status' => Response::HTTP_NOT_FOUND, + 'content' => PterodactylDocumentation::NOT_FOUND_ERROR, + 'description' => 'The requested resource could not be found.', + ]; + } + + if ($endpointData->bodyParameters !== []) { + $responses[] = [ + 'status' => Response::HTTP_UNPROCESSABLE_ENTITY, + 'content' => PterodactylDocumentation::VALIDATION_ERROR, + 'description' => 'The submitted data is invalid.', + ]; + } + + return $responses; + } + + private function canReturnForbidden(ExtractedEndpointData $endpointData): bool + { + if (! $endpointData->method instanceof ReflectionMethod) { + return false; + } + + $source = PterodactylDocumentation::methodSource($endpointData->method); + + return str_contains($source, 'AuthorizationException') + || str_contains($source, 'AccessDeniedHttpException') + || str_contains($source, 'HTTP_FORBIDDEN') + || str_contains($source, 'Response::HTTP_FORBIDDEN') + || str_contains($source, 'abort(403') + || str_contains($source, '->authorize(') + || str_contains($source, '->can('); + } + + private function usesApiRequest(ExtractedEndpointData $endpointData): bool + { + if (! $endpointData->method instanceof ReflectionFunctionAbstract) { + return false; + } + + foreach ($endpointData->method->getParameters() as $parameter) { + $type = $parameter->getType(); + if ($type instanceof ReflectionNamedType + && ! $type->isBuiltin() + && (is_a($type->getName(), ApiRequest::class, true) || is_a($type->getName(), ApplicationApiRequest::class, true)) + ) { + return true; + } + } + + return false; + } + + private function hasRouteModelBinding(ExtractedEndpointData $endpointData): bool + { + if (! $endpointData->method instanceof ReflectionFunctionAbstract) { + return false; + } + + foreach ($endpointData->method->getParameters() as $parameter) { + $type = $parameter->getType(); + if ($type instanceof ReflectionNamedType && ! $type->isBuiltin() && is_a($type->getName(), Model::class, true)) { + return true; + } + } + + return false; + } +} diff --git a/app/Extensions/Scribe/Strategies/InferPterodactylUrlParameters.php b/app/Extensions/Scribe/Strategies/InferPterodactylUrlParameters.php new file mode 100644 index 000000000..ff3c08387 --- /dev/null +++ b/app/Extensions/Scribe/Strategies/InferPterodactylUrlParameters.php @@ -0,0 +1,55 @@ + $routeRules + * @return ScribeParameters + */ + public function __invoke(ExtractedEndpointData $endpointData, array $routeRules = []): ?array + { + $inferred = parent::__invoke($endpointData, $routeRules) ?? []; + $parameters = []; + foreach ($inferred as $name => $parameter) { + if (! is_string($name) || ! is_array($parameter)) { + continue; + } + + JsonValueGuard::assertPayload($parameter); + $parameters[$name] = $parameter; + } + + foreach ($parameters as $name => $parameter) { + $known = PterodactylDocumentation::urlParameter($name); + if ($known === null) { + continue; + } + + if ($name === 'user' && str_starts_with($endpointData->uri, 'api/client/servers/') && str_contains($endpointData->uri, '/users/{user}')) { + $known = [ + 'type' => 'string', + 'description' => 'The user UUID.', + 'example' => '0d1f6f4d-9f78-4cf9-9d5a-6f7f4c9f4d6a', + ]; + } + + $parameters[$name] = [ + ...$parameter, + ...$known, + 'name' => $name, + 'required' => $parameter['required'] ?? true, + ]; + } + + return $parameters; + } +} diff --git a/app/Extensions/Scribe/Strategies/UsePterodactylResponseAttributes.php b/app/Extensions/Scribe/Strategies/UsePterodactylResponseAttributes.php new file mode 100644 index 000000000..67f7b213a --- /dev/null +++ b/app/Extensions/Scribe/Strategies/UsePterodactylResponseAttributes.php @@ -0,0 +1,185 @@ +withCount : []; + $transformerClass = $this->transformerClass($attributeInstance); + $modelInstantiator = function () use ($attributeInstance, $withCount, $transformerClass) { + $factoryStates = $attributeInstance->factoryStates; + $relations = $attributeInstance->with; + JsonValueGuard::assertValue($factoryStates); + JsonValueGuard::assertValue($relations); + $model = $this->instantiateExampleModel( + $attributeInstance->model, + $this->stringList($factoryStates), + $this->stringList($relations), + (new ReflectionClass($transformerClass))->getMethod('transform'), + ); + + if ($withCount !== [] && $model instanceof Model && $model->exists) { + $model->loadCount($withCount); + } + + return $model; + }; + + $this->startDbTransaction(); + try { + $this->authenticateGenerationRequest(); + $content = $this->fetchTransformerContent($attributeInstance, $modelInstantiator); + } finally { + $this->endDbTransaction(); + } + + if ($attributeInstance instanceof ResponseFromTransformer && $attributeInstance->meta !== []) { + $decoded = json_decode($content, true); + if (is_array($decoded)) { + $existingMeta = $decoded['meta'] ?? null; + if (! is_array($existingMeta)) { + $existingMeta = []; + } + + $decoded['meta'] = array_merge($existingMeta, $attributeInstance->meta); + $content = json_encode($decoded); + } + } + + return [ + 'status' => $attributeInstance->status, + 'description' => $attributeInstance->description, + 'content' => $content, + ]; + } + + /** + * Transformers render user-dependent fields (ownership flags, permission-gated + * includes), so give the console request a root administrator for the duration + * of the fetch. The user row lives inside the surrounding transaction. + */ + private function authenticateGenerationRequest(): void + { + $user = User::factory()->create(['root_admin' => true]); + + resolve('request')->setUserResolver(fn () => $user); + } + + private function fetchTransformerContent(BaseResponseFromTransformer $attribute, Closure $modelInstantiator): string + { + $fractal = new Manager; + if ($serializer = $this->config->get('fractal.serializer')) { + throw_unless(is_string($serializer), InvalidArgumentException::class, 'The configured Fractal serializer must be a class name.'); + + $resolvedSerializer = resolve($serializer); + throw_unless($resolvedSerializer instanceof Serializer, InvalidArgumentException::class, 'The configured Fractal serializer must implement the serializer contract.'); + + $fractal->setSerializer($resolvedSerializer); + } + + if ($attribute instanceof ResponseFromTransformer && $attribute->include !== []) { + $fractal->parseIncludes($attribute->include); + } + + $transformerClass = $this->transformerClass($attribute); + $transformer = resolve($transformerClass); + throw_unless($transformer instanceof TransformerAbstract, InvalidArgumentException::class, "Transformer [$transformerClass] must extend ".TransformerAbstract::class.'.'); + + if (! $attribute->collection) { + $resource = new Item($modelInstantiator(), $transformer, $attribute->resourceKey); + + return $fractal->createData($resource)->toJson(); + } + + $models = [$modelInstantiator()]; + $resource = new Collection($models, $transformer, $attribute->resourceKey); + + if ($attribute->paginate !== []) { + $adapter = $attribute->paginate[0]; + $perPage = $attribute->paginate[1] ?? count($models); + + if (! is_string($adapter) || ! is_a($adapter, PaginatorInterface::class, true)) { + throw new InvalidArgumentException(sprintf( + 'The paginator adapter referenced by #[ResponseFromTransformer] must be a class-string implementing %s.', + PaginatorInterface::class, + )); + } + + throw_unless(is_int($perPage), InvalidArgumentException::class, 'The paginator page size must be an integer.'); + + $paginator = new LengthAwarePaginator($models, count($models), $perPage); + $resource->setPaginator(new $adapter($paginator)); + } + + return $fractal->createData($resource)->toJson(); + } + + /** + * Resolves and validates the Fractal transformer class referenced by a + * #[ResponseFromTransformer] attribute. + * + * @return class-string + */ + private function transformerClass(BaseResponseFromTransformer $attribute): string + { + if (! is_a($attribute->name, TransformerAbstract::class, true)) { + throw new InvalidArgumentException(sprintf( + 'The class [%s] referenced by #[ResponseFromTransformer] must extend %s.', + $attribute->name, + TransformerAbstract::class, + )); + } + + return $attribute->name; + } + + /** + * @param array $values + * @return list + */ + private function stringList(array $values): array + { + $strings = []; + foreach ($values as $value) { + if (is_string($value)) { + $strings[] = $value; + } + } + + return $strings; + } +} diff --git a/app/Extensions/Scribe/Support/PterodactylDocumentation.php b/app/Extensions/Scribe/Support/PterodactylDocumentation.php new file mode 100644 index 000000000..ba77298b6 --- /dev/null +++ b/app/Extensions/Scribe/Support/PterodactylDocumentation.php @@ -0,0 +1,361 @@ + [ + [ + 'code' => 'ValidationException', + 'status' => '422', + 'detail' => 'The submitted data is invalid.', + 'source' => ['field' => 'field'], + ], + ], + ]; + + public const array AUTHENTICATION_ERROR = [ + 'errors' => [ + [ + 'code' => 'Unauthenticated', + 'status' => '401', + 'detail' => 'Authentication credentials were missing or invalid.', + ], + ], + ]; + + public const array FORBIDDEN_ERROR = [ + 'errors' => [ + [ + 'code' => 'Forbidden', + 'status' => '403', + 'detail' => 'The API key does not have permission to perform this action.', + ], + ], + ]; + + public const array NOT_FOUND_ERROR = [ + 'errors' => [ + [ + 'code' => 'NotFoundHttpException', + 'status' => '404', + 'detail' => 'The requested resource could not be found.', + ], + ], + ]; + + private const array URL_PARAMETERS = [ + 'allocation' => ['integer', 'The allocation ID.', 1], + 'backup' => ['string', 'The backup UUID.', 'b6b9acf9-19b1-4bb1-8c75-4abac802c6cf'], + 'backup_uuid' => ['string', 'The backup UUID.', 'b6b9acf9-19b1-4bb1-8c75-4abac802c6cf'], + 'database' => ['string', 'The database ID.', 'Lk3jx4pQ'], + 'database_id' => ['string', 'The database ID.', 'Lk3jx4pQ'], + 'database_host' => ['integer', 'The database host ID.', 1], + 'databaseHost' => ['integer', 'The database host ID.', 1], + 'egg' => ['integer', 'The egg ID.', 1], + 'egg_id' => ['integer', 'The egg ID.', 1], + 'external_id' => ['string', 'The external ID.', 'external-identifier'], + 'extension' => ['string', 'The extension identifier.', 'probe'], + 'file' => ['string', 'The file path.', '/server.properties'], + 'force' => ['string', 'Whether to force the delete operation.', 'force'], + 'id' => ['integer', 'The resource ID.', 1], + 'identifier' => ['string', 'The server UUID or short UUID.', 'd3aac109'], + 'input' => ['string', 'The input name of the extension setting.', 'logo'], + 'job' => ['string', 'The progress job UUID.', '11111111-1111-4111-8111-111111111111'], + 'key' => ['string', 'The API key identifier.', 'ci0abc123def'], + 'location' => ['integer', 'The location ID.', 1], + 'location_id' => ['integer', 'The location ID.', 1], + 'mount' => ['integer', 'The mount ID.', 1], + 'mount_id' => ['integer', 'The mount ID.', 1], + 'node' => ['integer', 'The node ID.', 1], + 'node_id' => ['integer', 'The node ID.', 1], + 'schedule' => ['integer', 'The schedule ID.', 1], + 'schedule_id' => ['integer', 'The schedule ID.', 1], + 'server' => ['string', 'The server UUID.', 'd3aac109-e5a0-4331-b03e-3454f7e02bbe'], + 'server_id' => ['integer', 'The server ID.', 1], + 'server_uuid' => ['string', 'The server UUID.', 'd3aac109-e5a0-4331-b03e-3454f7e02bbe'], + 'server_admin_identifier' => ['string', 'The server ID or UUID.', '1'], + 'subuser' => ['integer', 'The subuser ID.', 1], + 'task' => ['integer', 'The task ID.', 1], + 'task_id' => ['integer', 'The task ID.', 1], + 'user' => ['integer', 'The user ID.', 1], + 'user_id' => ['integer', 'The user ID.', 1], + 'variable' => ['integer', 'The variable ID.', 1], + 'variable_id' => ['integer', 'The variable ID.', 1], + ]; + + private const array FIELD_DESCRIPTIONS = [ + 'action' => 'The action to perform.', + 'alias' => 'An optional alias for this resource.', + 'allocation' => 'The allocation ID.', + 'allocation_id' => 'The allocation ID.', + 'allocation_limit' => 'The maximum number of allocations allowed.', + 'allowed_ips' => 'IP addresses allowed to use this key.', + 'backup_limit' => 'The maximum number of backups allowed.', + 'behind_proxy' => 'Whether the node is behind a proxy.', + 'command' => 'The console command to send.', + 'contents' => 'The file contents.', + 'continue_on_failure' => 'Whether the schedule continues when this task fails.', + 'copy_script_from' => 'Another egg ID to copy the install script from.', + 'cpu' => 'The CPU limit percentage.', + 'current_password' => 'The current account password.', + 'database_host_id' => 'The database host ID.', + 'database_limit' => 'The maximum number of databases allowed.', + 'default_value' => 'The default value.', + 'directory' => 'The directory path.', + 'disk' => 'The disk limit in megabytes.', + 'description' => 'A description for this resource.', + 'docker_image' => 'The Docker image to use.', + 'docker_images' => 'Docker images available to this resource.', + 'egg_id' => 'The egg ID.', + 'email' => 'The user email address.', + 'env_variable' => 'The environment variable name.', + 'environment' => 'Environment variables for the server.', + 'external_id' => 'An external identifier for this resource.', + 'feature_limits.allocations' => 'The maximum number of allocations allowed.', + 'feature_limits.backups' => 'The maximum number of backups allowed.', + 'feature_limits.databases' => 'The maximum number of databases allowed.', + 'features' => 'Feature flags enabled for this resource.', + 'file' => 'The file path.', + 'file_denylist' => 'File patterns denied by the file manager.', + 'filename' => 'The file name.', + 'files' => 'File paths affected by the operation.', + 'fingerprint' => 'The SSH key fingerprint.', + 'force_outgoing_ip' => 'Whether servers should use their allocation IP for outgoing traffic.', + 'fqdn' => 'The fully qualified domain name.', + 'host' => 'The database host address.', + 'ignored' => 'Whether this item should be ignored.', + 'import_file' => 'The file to import.', + 'io' => 'The block IO weight.', + 'ip' => 'The IP address.', + 'is_active' => 'Whether the resource is active.', + 'is_locked' => 'Whether the resource is locked.', + 'language' => 'The locale code.', + 'location_id' => 'The location ID.', + 'max_connections' => 'The maximum number of connections allowed.', + 'memory' => 'The memory limit in megabytes.', + 'mount_id' => 'The mount ID.', + 'name' => 'The display name.', + 'node_id' => 'The node ID.', + 'notes' => 'Notes for this resource.', + 'oom_disabled' => 'Whether the OOM killer is disabled.', + 'options' => 'Additional options for this resource.', + 'order' => 'Resource IDs in the desired display order.', + 'owner_id' => 'The owner user ID.', + 'password' => 'The password.', + 'password_confirmation' => 'The password confirmation.', + 'permissions' => 'Permissions granted to the user.', + 'port' => 'The port number.', + 'ports' => 'Ports to allocate.', + 'primary_allocation_id' => 'The primary allocation ID.', + 'public_key' => 'The SSH public key.', + 'remote' => 'The remote database address.', + 'root_admin' => 'Whether the user has administrator privileges.', + 'rules' => 'Laravel validation rules applied to user-submitted values.', + 'script_container' => 'The install container image.', + 'script_entry' => 'The install container entrypoint.', + 'script_install' => 'The install script body.', + 'script_is_privileged' => 'Whether the install script runs in privileged mode.', + 'sequence_id' => 'The task execution order.', + 'signal' => 'The power signal.', + 'skip_scripts' => 'Whether install scripts should be skipped.', + 'source' => 'The source path.', + 'start_on_completion' => 'Whether the server should start when the operation completes.', + 'startup' => 'The startup command.', + 'swap' => 'The swap limit in megabytes.', + 'target' => 'The target path.', + 'threads' => 'CPU threads available to the server.', + 'time_offset' => 'The delay before this task runs.', + 'url' => 'The URL.', + 'user' => 'The user ID.', + 'user_mountable' => 'Whether users can mount this resource.', + 'username' => 'The username.', + ]; + + private const array FIELD_TYPES = [ + 'allocation_additional' => 'integer[]', + 'allocation_id' => 'integer', + 'archived' => 'boolean', + 'environment' => 'object', + 'extends' => 'integer', + 'egg_id' => 'integer', + 'features' => 'string[]', + 'file_denylist' => 'string[]', + 'location_id' => 'integer', + 'max_connections' => 'integer', + 'server_id' => 'integer', + 'primary_allocation_id' => 'integer', + 'secondary_allocations_ids' => 'integer[]', + 'successful' => 'boolean', + ]; + + /** + * @return array{type: string, description: string, example: int|string}|null + */ + public static function urlParameter(string $name): ?array + { + if (! isset(self::URL_PARAMETERS[$name])) { + return null; + } + + [$type, $description, $example] = self::URL_PARAMETERS[$name]; + + return ['type' => $type, 'description' => $description, 'example' => $example]; + } + + public static function fieldDescription(string $name): string + { + return self::FIELD_DESCRIPTIONS[$name] + ?? 'The '.str_replace(['_', '.'], ' ', $name).'.'; + } + + public static function fieldType(string $name): ?string + { + return self::FIELD_TYPES[$name] ?? null; + } + + /** @return ApiValue1 */ + public static function fieldExample(string $name, string $type): bool|float|int|string|array|null + { + return match (true) { + str_starts_with($name, 'feature_limits.'), str_starts_with($name, 'limits.') => 1, + str_starts_with($name, 'deploy.') && str_contains($name, 'locations') => [1], + str_starts_with($name, 'deploy.') && str_contains($name, 'port_range') => ['25565-25570'], + str_starts_with($name, 'smtp.') && str_contains($name, 'port') => 587, + str_starts_with($name, 'smtp.') && str_contains($name, 'host') => 'smtp.example.com', + $name === 'options' => ['user_viewable', 'user_editable'], + str_contains($type, '[]') && $name === 'order' => [3, 1, 2], + str_contains($type, '[]') && str_contains($name, 'location') => [1, 2], + str_contains($type, '[]') && str_contains($name, 'port') => ['25565-25570'], + str_contains($type, '[]') && str_contains($name, 'permission') => ['control.console', 'control.start'], + str_contains($type, '[]') && str_contains($name, 'file') => ['/server.properties'], + $type === 'object' => ['SERVER_JARFILE' => 'server.jar'], + str_contains($type, '[]') => ['example'], + str_contains($type, 'boolean') || $type === 'bool' => true, + str_contains($type, 'integer') || $type === 'int' => 1, + str_contains($type, 'number') || $type === 'float' => 1.5, + str_contains($name, 'allocation') => 1, + str_contains($name, 'cpu') => 100, + str_contains($name, 'disk') => 10240, + str_contains($name, 'email') => 'admin@example.com', + str_contains($name, 'memory') => 1024, + str_contains($name, 'password') => 'correct horse battery staple', + str_contains($name, 'port') => 25565, + str_contains($name, 'uuid') => 'd3aac109-e5a0-4331-b03e-3454f7e02bbe', + $name === 'command' => 'say Server restarting in 5 minutes', + $name === 'contents' => 'server-port=25565', + $name === 'default_value' => 'server.jar', + $name === 'description' => 'A short description.', + $name === 'directory' => '/config', + $name === 'docker_image' => 'ghcr.io/pterodactyl/yolks:java_21', + $name === 'env_variable' => 'SERVER_JARFILE', + $name === 'file' => '/server.properties', + $name === 'filename' => 'server.properties', + $name === 'fqdn' => 'node.example.com', + $name === 'host' || $name === 'remote' => '127.0.0.1', + $name === 'import_file' => 'egg-minecraft.json', + $name === 'ip' => '192.0.2.10', + $name === 'name' => 'Example Resource', + $name === 'public_key' => 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKey user@example.com', + $name === 'rules' => 'required|string|max:64', + $name === 'signal' => 'start', + $name === 'source' || $name === 'target' => '/server.properties', + $name === 'startup' => 'java -Xms128M -XX:MaxRAMPercentage=95.0 -jar {{SERVER_JARFILE}}', + $name === 'url' => 'https://example.com/server.jar', + default => 'example', + }; + } + + public static function methodSource(ReflectionMethod $method): string + { + $file = $method->getFileName(); + if ($file === false) { + return ''; + } + + $lines = file($file); + if ($lines === false) { + return ''; + } + + $start = max(0, $method->getStartLine() - 1); + $length = $method->getEndLine() - $method->getStartLine() + 1; + + return implode('', array_slice($lines, $start, $length)); + } + + /** + * @param JsonInputValue $value + * @return DeepOpenApiSchema an OpenAPI schema fragment describing the value + */ + public static function schemaForValue(mixed $value): array + { + if (is_array($value)) { + if (! array_is_list($value)) { + $properties = []; + foreach ($value as $key => $item) { + $properties[$key] = self::schemaForValue($item); + if ($item === null && is_string($key) && ($type = self::fieldType($key)) !== null) { + $properties[$key]['type'] = match ($type) { + 'integer', 'int' => 'integer', + 'number', 'float' => 'number', + 'boolean', 'bool' => 'boolean', + default => $type, + }; + } + } + + return self::openApiSchema([ + 'type' => 'object', + 'required' => array_keys($properties), + 'properties' => $properties, + ]); + } + + return self::openApiSchema([ + 'type' => 'array', + 'items' => isset($value[0]) ? self::schemaForValue($value[0]) : ['type' => 'string'], + ]); + } + + if ($value === null) { + return self::openApiSchema([ + 'type' => 'string', + 'nullable' => true, + ]); + } + + if ($value instanceof JsonEmptyObject) { + return self::openApiSchema([ + 'type' => 'object', + 'properties' => new JsonEmptyObject, + ]); + } + + return self::openApiSchema(match (gettype($value)) { + 'boolean' => ['type' => 'boolean', 'example' => $value], + 'integer' => ['type' => 'integer', 'example' => $value], + 'double' => ['type' => 'number', 'example' => $value], + default => ['type' => 'string', 'example' => (string) $value], + }); + } + + /** + * @phpstan-assert DeepOpenApiSchema $schema + * + * @return DeepOpenApiSchema + */ + private static function openApiSchema(mixed $schema): array + { + JsonValueGuard::assertPayload9($schema); + + return $schema; + } +} diff --git a/app/Extensions/Spatie/Fractalistic/Fractal.php b/app/Extensions/Spatie/Fractalistic/Fractal.php index 0c65d6e8e..3e5634d1a 100644 --- a/app/Extensions/Spatie/Fractalistic/Fractal.php +++ b/app/Extensions/Spatie/Fractalistic/Fractal.php @@ -1,45 +1,97 @@ + */ + public function requestedIncludes(): array + { + return array_values(JsonValueGuard::stringList($this->includes)); + } + + /** + * Serialize a non-null API resource. + * + * @return ApiPayload + * + * @throws InvalidTransformation + * @throws NoTransformerSpecified + */ + public function toResponseArray(): array + { + $payload = parent::toArray(); + + throw_if($payload === null, UnexpectedValueException::class, 'A Fractal API response cannot use a null resource.'); + + return $payload; + } + /** * Create fractal data. * - * @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation - * @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified + * @throws InvalidTransformation + * @throws NoTransformerSpecified */ public function createData(): Scope { - // Set the serializer by default. - if (is_null($this->serializer)) { - $this->serializer = new PterodactylSerializer(); - } + $this->serializer ??= new PterodactylSerializer; // Automatically set the paginator on the response object if the // data being provided implements a paginator. - if (is_null($this->paginator) && $this->data instanceof LengthAwarePaginator) { + if (($this->paginator) === null && $this->data instanceof LengthAwarePaginator) { $this->paginator = new IlluminatePaginatorAdapter($this->data); } // If the resource name is not set attempt to pull it off the transformer // itself and set it automatically. if ( - is_null($this->resourceName) + ($this->resourceName) === null && $this->transformer instanceof TransformerAbstract && method_exists($this->transformer, 'getResourceName') ) { $this->resourceName = $this->transformer->getResourceName(); } - return parent::createData(); + $scope = parent::createData(); + $data = $this->data instanceof LengthAwarePaginator ? $this->data->items() : $this->data; + if ($this->transformer instanceof BaseTransformer) { + if ($data instanceof Model) { + $this->transformer->prepareCollection(new ModelCollection([$data]), $scope); + } elseif (is_array($data) || $data instanceof \Illuminate\Support\Collection) { + $models = new ModelCollection; + foreach ($data as $model) { + if (! $model instanceof Model) { + return $scope; + } + + $models->push($model); + } + + $this->transformer->prepareCollection($models, $scope); + } + } + + return $scope; } } diff --git a/app/Extensions/Themes/Theme.php b/app/Extensions/Themes/Theme.php deleted file mode 100644 index fd65583e3..000000000 --- a/app/Extensions/Themes/Theme.php +++ /dev/null @@ -1,21 +0,0 @@ -' . PHP_EOL, $this->getUrl($path)); - } - - public function css($path): string - { - return sprintf('' . PHP_EOL, $this->getUrl($path)); - } - - protected function getUrl($path): string - { - return '/themes/pterodactyl/' . ltrim($path, '/'); - } -} diff --git a/app/Facades/Activity.php b/app/Facades/Activity.php index 564021001..ec3f1919d 100644 --- a/app/Facades/Activity.php +++ b/app/Facades/Activity.php @@ -1,5 +1,7 @@ > getMessages() + */ +class Alert extends Facade +{ + protected static function getFacadeAccessor(): string + { + return AlertsMessageBag::class; + } +} diff --git a/app/Facades/Daemon.php b/app/Facades/Daemon.php new file mode 100644 index 000000000..d9b4e8ca4 --- /dev/null +++ b/app/Facades/Daemon.php @@ -0,0 +1,26 @@ + requestedIncludes() + * + * @see Fractalistic + */ +class Fractal extends Facade +{ + protected static $cached = false; + + protected static function getFacadeAccessor(): string + { + return Fractalistic::class; + } +} diff --git a/app/Facades/Hashids.php b/app/Facades/Hashids.php new file mode 100644 index 000000000..9cf13968c --- /dev/null +++ b/app/Facades/Hashids.php @@ -0,0 +1,23 @@ + decode(string $hash) + * @method static int|string|null decodeFirst(string $encoded, ?string $default = null) + * + * @see HashidsInterface + */ +class Hashids extends Facade +{ + protected static function getFacadeAccessor(): string + { + return HashidsInterface::class; + } +} diff --git a/app/Facades/LogBatch.php b/app/Facades/LogBatch.php index 03d0de57a..7a2bc0cf3 100644 --- a/app/Facades/LogBatch.php +++ b/app/Facades/LogBatch.php @@ -1,5 +1,7 @@ getMessage(), ['exception' => $exception]); } return $string; @@ -35,15 +40,16 @@ class Utilities /** * Converts schedule cron data into a carbon object. * - * @throws \Exception + * @throws Exception */ - public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek): Carbon + public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek): CarbonImmutable { - return Carbon::instance((new CronExpression( + return Date::instance((new CronExpression( sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek) ))->getNextRunDate()); } + /** @param bool|int $default */ public static function checked(string $name, mixed $default): string { $errors = session('errors'); diff --git a/app/Http/Concerns/ResolvesRequestContext.php b/app/Http/Concerns/ResolvesRequestContext.php new file mode 100644 index 000000000..6c8b2103a --- /dev/null +++ b/app/Http/Concerns/ResolvesRequestContext.php @@ -0,0 +1,27 @@ +user() ?? throw new AuthenticationException('This endpoint requires an authenticated user.'); + } + + /** + * @return Route + */ + protected function resolvedRoute(Request $request) + { + return $request->route() ?? throw new LogicException('Request middleware requires a resolved route.'); + } +} diff --git a/app/Http/Controllers/Admin/ApiController.php b/app/Http/Controllers/Admin/ApiController.php deleted file mode 100644 index a8f87bf53..000000000 --- a/app/Http/Controllers/Admin/ApiController.php +++ /dev/null @@ -1,86 +0,0 @@ - ApiKey::query()->where('key_type', ApiKey::TYPE_APPLICATION)->get(), - ]); - } - - /** - * Render view allowing an admin to create a new application API key. - * - * @throws \ReflectionException - */ - public function create(): View - { - $resources = AdminAcl::getResourceList(); - sort($resources); - - return view('admin.api.new', [ - 'resources' => $resources, - 'permissions' => [ - 'r' => AdminAcl::READ, - 'rw' => AdminAcl::READ | AdminAcl::WRITE, - 'n' => AdminAcl::NONE, - ], - ]); - } - - /** - * Store the new key and redirect the user back to the application key listing. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - public function store(StoreApplicationApiKeyRequest $request): RedirectResponse - { - $this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([ - 'memo' => $request->input('memo'), - 'user_id' => $request->user()->id, - ], $request->getKeyPermissions()); - - $this->alert->success('A new application API key has been generated for your account.')->flash(); - - return redirect()->route('admin.api.index'); - } - - /** - * Delete an application API key from the database. - */ - public function delete(Request $request, string $identifier): Response - { - ApiKey::query() - ->where('key_type', ApiKey::TYPE_APPLICATION) - ->where('identifier', $identifier) - ->delete(); - - return response('', 204); - } -} diff --git a/app/Http/Controllers/Admin/BaseController.php b/app/Http/Controllers/Admin/BaseController.php deleted file mode 100644 index 2b6933074..000000000 --- a/app/Http/Controllers/Admin/BaseController.php +++ /dev/null @@ -1,25 +0,0 @@ - $this->version]); - } -} diff --git a/app/Http/Controllers/Admin/DatabaseController.php b/app/Http/Controllers/Admin/DatabaseController.php deleted file mode 100644 index b37a4dade..000000000 --- a/app/Http/Controllers/Admin/DatabaseController.php +++ /dev/null @@ -1,126 +0,0 @@ - $this->locationRepository->getAllWithNodes(), - 'hosts' => $this->repository->getWithViewDetails(), - ]); - } - - /** - * Display database host to user. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function view(int $host): View - { - return view('admin.databases.view', [ - 'locations' => $this->locationRepository->getAllWithNodes(), - 'host' => $this->repository->find($host), - 'databases' => $this->databaseRepository->getDatabasesForHost($host), - ]); - } - - /** - * Handle request to create a new database host. - * - * @throws \Throwable - */ - public function create(DatabaseHostFormRequest $request): RedirectResponse - { - try { - $host = $this->creationService->handle($request->normalize()); - } catch (\Exception $exception) { - if ($exception instanceof \PDOException || $exception->getPrevious() instanceof \PDOException) { - $this->alert->danger( - sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) - )->flash(); - - return redirect()->route('admin.databases')->withInput($request->validated()); - } else { - throw $exception; - } - } - - $this->alert->success('Successfully created a new database host on the system.')->flash(); - - return redirect()->route('admin.databases.view', $host->id); - } - - /** - * Handle updating database host. - * - * @throws \Throwable - */ - public function update(DatabaseHostFormRequest $request, DatabaseHost $host): RedirectResponse - { - $redirect = redirect()->route('admin.databases.view', $host->id); - - try { - $this->updateService->handle($host->id, $request->normalize()); - $this->alert->success('Database host was updated successfully.')->flash(); - } catch (\Exception $exception) { - // Catch any SQL related exceptions and display them back to the user, otherwise just - // throw the exception like normal and move on with it. - if ($exception instanceof \PDOException || $exception->getPrevious() instanceof \PDOException) { - $this->alert->danger( - sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) - )->flash(); - - return $redirect->withInput($request->normalize()); - } else { - throw $exception; - } - } - - return $redirect; - } - - /** - * Handle request to delete a database host. - * - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException - */ - public function delete(int $host): RedirectResponse - { - $this->deletionService->handle($host); - $this->alert->success('The requested database host has been deleted from the system.')->flash(); - - return redirect()->route('admin.databases'); - } -} diff --git a/app/Http/Controllers/Admin/LocationController.php b/app/Http/Controllers/Admin/LocationController.php deleted file mode 100644 index f97e55d6b..000000000 --- a/app/Http/Controllers/Admin/LocationController.php +++ /dev/null @@ -1,103 +0,0 @@ - $this->repository->getAllWithDetails(), - ]); - } - - /** - * Return the location view page. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function view(int $id): View - { - return view('admin.locations.view', [ - 'location' => $this->repository->getWithNodes($id), - ]); - } - - /** - * Handle request to create new location. - * - * @throws \Throwable - */ - public function create(LocationFormRequest $request): RedirectResponse - { - $location = $this->creationService->handle($request->normalize()); - $this->alert->success('Location was created successfully.')->flash(); - - return redirect()->route('admin.locations.view', $location->id); - } - - /** - * Handle request to update or delete location. - * - * @throws \Throwable - */ - public function update(LocationFormRequest $request, Location $location): RedirectResponse - { - if ($request->input('action') === 'delete') { - return $this->delete($location); - } - - $this->updateService->handle($location->id, $request->normalize()); - $this->alert->success('Location was updated successfully.')->flash(); - - return redirect()->route('admin.locations.view', $location->id); - } - - /** - * Delete a location from the system. - * - * @throws \Exception - * @throws DisplayException - */ - public function delete(Location $location): RedirectResponse - { - try { - $this->deletionService->handle($location->id); - - return redirect()->route('admin.locations'); - } catch (DisplayException $ex) { - $this->alert->danger($ex->getMessage())->flash(); - } - - return redirect()->route('admin.locations.view', $location->id); - } -} diff --git a/app/Http/Controllers/Admin/MountController.php b/app/Http/Controllers/Admin/MountController.php deleted file mode 100644 index a10e6b955..000000000 --- a/app/Http/Controllers/Admin/MountController.php +++ /dev/null @@ -1,165 +0,0 @@ - $this->repository->getAllWithDetails(), - ]); - } - - /** - * Return the mount view page. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function view(string $id): View - { - $nests = Nest::query()->with('eggs')->get(); - $locations = Location::query()->with('nodes')->get(); - - return view('admin.mounts.view', [ - 'mount' => $this->repository->getWithRelations($id), - 'nests' => $nests, - 'locations' => $locations, - ]); - } - - /** - * Handle request to create new mount. - * - * @throws \Throwable - */ - public function create(MountFormRequest $request): RedirectResponse - { - $model = (new Mount())->fill($request->validated()); - $model->forceFill(['uuid' => Uuid::uuid4()->toString()]); - - $model->saveOrFail(); - $mount = $model->fresh(); - - $this->alert->success('Mount was created successfully.')->flash(); - - return redirect()->route('admin.mounts.view', $mount->id); - } - - /** - * Handle request to update or delete location. - * - * @throws \Throwable - */ - public function update(MountFormRequest $request, Mount $mount): RedirectResponse - { - if ($request->input('action') === 'delete') { - return $this->delete($mount); - } - - $mount->forceFill($request->validated())->save(); - - $this->alert->success('Mount was updated successfully.')->flash(); - - return redirect()->route('admin.mounts.view', $mount->id); - } - - /** - * Delete a location from the system. - * - * @throws \Exception - */ - public function delete(Mount $mount): RedirectResponse - { - $mount->delete(); - - return redirect()->route('admin.mounts'); - } - - /** - * Adds eggs to the mount's many-to-many relation. - */ - public function addEggs(Request $request, Mount $mount): RedirectResponse - { - $validatedData = $request->validate([ - 'eggs' => 'required|exists:eggs,id', - ]); - - $eggs = $validatedData['eggs'] ?? []; - if (count($eggs) > 0) { - $mount->eggs()->attach($eggs); - } - - $this->alert->success('Mount was updated successfully.')->flash(); - - return redirect()->route('admin.mounts.view', $mount->id); - } - - /** - * Adds nodes to the mount's many-to-many relation. - */ - public function addNodes(Request $request, Mount $mount): RedirectResponse - { - $data = $request->validate(['nodes' => 'required|exists:nodes,id']); - - $nodes = $data['nodes'] ?? []; - if (count($nodes) > 0) { - $mount->nodes()->attach($nodes); - } - - $this->alert->success('Mount was updated successfully.')->flash(); - - return redirect()->route('admin.mounts.view', $mount->id); - } - - /** - * Deletes an egg from the mount's many-to-many relation. - */ - public function deleteEgg(Mount $mount, int $egg_id): Response - { - $mount->eggs()->detach($egg_id); - - return response('', 204); - } - - /** - * Deletes a node from the mount's many-to-many relation. - */ - public function deleteNode(Mount $mount, int $node_id): Response - { - $mount->nodes()->detach($node_id); - - return response('', 204); - } -} diff --git a/app/Http/Controllers/Admin/Nests/EggController.php b/app/Http/Controllers/Admin/Nests/EggController.php deleted file mode 100644 index 5df25590c..000000000 --- a/app/Http/Controllers/Admin/Nests/EggController.php +++ /dev/null @@ -1,128 +0,0 @@ -nestRepository->getWithEggs(); - \JavaScript::put(['nests' => $nests->keyBy('id')]); - - return view('admin.eggs.new', ['nests' => $nests]); - } - - /** - * Handle request to store a new Egg. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException - */ - public function store(EggFormRequest $request): RedirectResponse - { - $data = $request->validated(); - $data['docker_images'] = $this->normalizeDockerImages($data['docker_images'] ?? null); - - $egg = $this->creationService->handle($data); - $this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash(); - - return redirect()->route('admin.nests.egg.view', $egg->id); - } - - /** - * Handle request to view a single Egg. - */ - public function view(Egg $egg): View - { - return view('admin.eggs.view', [ - 'egg' => $egg, - 'images' => array_map( - fn ($key, $value) => $key === $value ? $value : "$key|$value", - array_keys($egg->docker_images), - $egg->docker_images, - ), - ]); - } - - /** - * Handle request to update an Egg. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException - */ - public function update(EggFormRequest $request, Egg $egg): RedirectResponse - { - $data = $request->validated(); - $data['docker_images'] = $this->normalizeDockerImages($data['docker_images'] ?? null); - - $this->updateService->handle($egg, $data); - $this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash(); - - return redirect()->route('admin.nests.egg.view', $egg->id); - } - - /** - * Handle request to destroy an egg. - * - * @throws \Pterodactyl\Exceptions\Service\Egg\HasChildrenException - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException - */ - public function destroy(Egg $egg): RedirectResponse - { - $this->deletionService->handle($egg->id); - $this->alert->success(trans('admin/nests.eggs.notices.deleted'))->flash(); - - return redirect()->route('admin.nests.view', $egg->nest_id); - } - - /** - * Normalizes a string of docker image data into the expected egg format. - */ - protected function normalizeDockerImages(?string $input = null): array - { - $data = array_map(fn ($value) => trim($value), explode("\n", $input ?? '')); - - $images = []; - // Iterate over the image data provided and convert it into a name => image - // pairing that is used to improve the display on the front-end. - foreach ($data as $value) { - $parts = explode('|', $value, 2); - $images[$parts[0]] = empty($parts[1]) ? $parts[0] : $parts[1]; - } - - return $images; - } -} diff --git a/app/Http/Controllers/Admin/Nests/EggScriptController.php b/app/Http/Controllers/Admin/Nests/EggScriptController.php deleted file mode 100644 index b01abc0ad..000000000 --- a/app/Http/Controllers/Admin/Nests/EggScriptController.php +++ /dev/null @@ -1,65 +0,0 @@ -repository->getWithCopyAttributes($egg); - $copy = $this->repository->findWhere([ - ['copy_script_from', '=', null], - ['nest_id', '=', $egg->nest_id], - ['id', '!=', $egg], - ]); - - $rely = $this->repository->findWhere([ - ['copy_script_from', '=', $egg->id], - ]); - - return view('admin.eggs.scripts', [ - 'copyFromOptions' => $copy, - 'relyOnScript' => $rely, - 'egg' => $egg, - ]); - } - - /** - * Handle a request to update the installation script for an Egg. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException - */ - public function update(EggScriptFormRequest $request, Egg $egg): RedirectResponse - { - $this->installScriptService->handle($egg, $request->normalize()); - $this->alert->success(trans('admin/nests.eggs.notices.script_updated'))->flash(); - - return redirect()->route('admin.nests.egg.scripts', $egg); - } -} diff --git a/app/Http/Controllers/Admin/Nests/EggShareController.php b/app/Http/Controllers/Admin/Nests/EggShareController.php deleted file mode 100644 index 85efa09a6..000000000 --- a/app/Http/Controllers/Admin/Nests/EggShareController.php +++ /dev/null @@ -1,74 +0,0 @@ -name)), '-'); - - return response($this->exporterService->handle($egg->id), 200, [ - 'Content-Transfer-Encoding' => 'binary', - 'Content-Description' => 'File Transfer', - 'Content-Disposition' => 'attachment; filename=egg-' . $filename . '.json', - 'Content-Type' => 'application/json', - ]); - } - - /** - * Import a new service option using an XML file. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException - * @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException - */ - public function import(EggImportFormRequest $request): RedirectResponse - { - $egg = $this->importerService->handle($request->file('import_file'), $request->input('import_to_nest')); - $this->alert->success(trans('admin/nests.eggs.notices.imported'))->flash(); - - return redirect()->route('admin.nests.egg.view', ['egg' => $egg->id]); - } - - /** - * Update an existing Egg using a new imported file. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException - * @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException - */ - public function update(EggImportFormRequest $request, Egg $egg): RedirectResponse - { - $this->updateImporterService->handle($egg, $request->file('import_file')); - $this->alert->success(trans('admin/nests.eggs.notices.updated_via_import'))->flash(); - - return redirect()->route('admin.nests.egg.view', ['egg' => $egg]); - } -} diff --git a/app/Http/Controllers/Admin/Nests/EggVariableController.php b/app/Http/Controllers/Admin/Nests/EggVariableController.php deleted file mode 100644 index 9c2466728..000000000 --- a/app/Http/Controllers/Admin/Nests/EggVariableController.php +++ /dev/null @@ -1,90 +0,0 @@ -repository->getWithVariables($egg); - - return view('admin.eggs.variables', ['egg' => $egg]); - } - - /** - * Handle a request to create a new Egg variable. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException - * @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException - */ - public function store(EggVariableFormRequest $request, Egg $egg): RedirectResponse - { - $this->creationService->handle($egg->id, $request->normalize()); - $this->alert->success(trans('admin/nests.variables.notices.variable_created'))->flash(); - - return redirect()->route('admin.nests.egg.variables', $egg->id); - } - - /** - * Handle a request to update an existing Egg variable. - * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException - */ - public function update(EggVariableFormRequest $request, Egg $egg, EggVariable $variable): RedirectResponse - { - $this->updateService->handle($variable, $request->normalize()); - $this->alert->success(trans('admin/nests.variables.notices.variable_updated', [ - 'variable' => htmlspecialchars($variable->name), - ]))->flash(); - - return redirect()->route('admin.nests.egg.variables', $egg->id); - } - - /** - * Handle a request to delete an existing Egg variable from the Panel. - */ - public function destroy(int $egg, EggVariable $variable): RedirectResponse - { - $this->variableRepository->delete($variable->id); - $this->alert->success(trans('admin/nests.variables.notices.variable_deleted', [ - 'variable' => htmlspecialchars($variable->name), - ]))->flash(); - - return redirect()->route('admin.nests.egg.variables', $egg); - } -} diff --git a/app/Http/Controllers/Admin/Nests/NestController.php b/app/Http/Controllers/Admin/Nests/NestController.php deleted file mode 100644 index 13b40900d..000000000 --- a/app/Http/Controllers/Admin/Nests/NestController.php +++ /dev/null @@ -1,102 +0,0 @@ - $this->repository->getWithCounts(), - ]); - } - - /** - * Render nest creation page. - */ - public function create(): View - { - return view('admin.nests.new'); - } - - /** - * Handle the storage of a new nest. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - public function store(StoreNestFormRequest $request): RedirectResponse - { - $nest = $this->nestCreationService->handle($request->normalize()); - $this->alert->success(trans('admin/nests.notices.created', ['name' => htmlspecialchars($nest->name)]))->flash(); - - return redirect()->route('admin.nests.view', $nest->id); - } - - /** - * Return details about a nest including all the eggs and servers per egg. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function view(int $nest): View - { - return view('admin.nests.view', [ - 'nest' => $this->repository->getWithEggServers($nest), - ]); - } - - /** - * Handle request to update a nest. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function update(StoreNestFormRequest $request, int $nest): RedirectResponse - { - $this->nestUpdateService->handle($nest, $request->normalize()); - $this->alert->success(trans('admin/nests.notices.updated'))->flash(); - - return redirect()->route('admin.nests.view', $nest); - } - - /** - * Handle request to delete a nest. - * - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException - */ - public function destroy(int $nest): RedirectResponse - { - $this->nestDeletionService->handle($nest); - $this->alert->success(trans('admin/nests.notices.deleted'))->flash(); - - return redirect()->route('admin.nests'); - } -} diff --git a/app/Http/Controllers/Admin/NodeAutoDeployController.php b/app/Http/Controllers/Admin/NodeAutoDeployController.php deleted file mode 100644 index 2be1a9111..000000000 --- a/app/Http/Controllers/Admin/NodeAutoDeployController.php +++ /dev/null @@ -1,53 +0,0 @@ -where('user_id', $request->user()->id) - ->where('key_type', ApiKey::TYPE_APPLICATION) - ->where('r_nodes', 1) - ->first(); - - // We couldn't find a key that exists for this user with only permission for - // reading nodes. Go ahead and create it now. - if (!$key) { - $key = $this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([ - 'user_id' => $request->user()->id, - 'memo' => 'Automatically generated node deployment key.', - 'allowed_ips' => [], - ], ['r_nodes' => 1]); - } - - return new JsonResponse([ - 'node' => $node->id, - 'token' => $key->identifier . $this->encrypter->decrypt($key->token), - ]); - } -} diff --git a/app/Http/Controllers/Admin/Nodes/NodeController.php b/app/Http/Controllers/Admin/Nodes/NodeController.php deleted file mode 100644 index 793677240..000000000 --- a/app/Http/Controllers/Admin/Nodes/NodeController.php +++ /dev/null @@ -1,27 +0,0 @@ -with('location')->withCount('servers') - ) - ->allowedFilters(['uuid', 'name']) - ->allowedSorts(['id']) - ->paginate(25); - - return view('admin.nodes.index', ['nodes' => $nodes]); - } -} diff --git a/app/Http/Controllers/Admin/Nodes/NodeViewController.php b/app/Http/Controllers/Admin/Nodes/NodeViewController.php deleted file mode 100644 index 843181e89..000000000 --- a/app/Http/Controllers/Admin/Nodes/NodeViewController.php +++ /dev/null @@ -1,98 +0,0 @@ -repository->loadLocationAndServerCount($node); - - return view('admin.nodes.view.index', [ - 'node' => $node, - 'stats' => $this->repository->getUsageStats($node), - 'version' => $this->versionService, - ]); - } - - /** - * Returns the settings page for a specific node. - */ - public function settings(Request $request, Node $node): View - { - return view('admin.nodes.view.settings', [ - 'node' => $node, - 'locations' => $this->locationRepository->all(), - ]); - } - - /** - * Return the node configuration page for a specific node. - */ - public function configuration(Request $request, Node $node): View - { - return view('admin.nodes.view.configuration', compact('node')); - } - - /** - * Return the node allocation management page. - */ - public function allocations(Request $request, Node $node): View - { - $node = $this->repository->loadNodeAllocations($node); - - $this->plainInject(['node' => Collection::make([$node])->only(['id'])]); - - return view('admin.nodes.view.allocation', [ - 'node' => $node, - 'allocations' => Allocation::query()->where('node_id', $node->id) - ->groupBy('ip') - ->orderByRaw('INET_ATON(ip) ASC') - ->get(['ip']), - ]); - } - - /** - * Return a listing of servers that exist for this specific node. - */ - public function servers(Request $request, Node $node): View - { - $this->plainInject([ - 'node' => Collection::make([$node->makeVisible(['daemon_token_id', 'daemon_token'])]) - ->only(['scheme', 'fqdn', 'daemonListen', 'daemon_token_id', 'daemon_token']), - ]); - - return view('admin.nodes.view.servers', [ - 'node' => $node, - 'servers' => $this->serverRepository->loadAllServersForNode($node->id, 25), - ]); - } -} diff --git a/app/Http/Controllers/Admin/Nodes/SystemInformationController.php b/app/Http/Controllers/Admin/Nodes/SystemInformationController.php deleted file mode 100644 index 875b1afbe..000000000 --- a/app/Http/Controllers/Admin/Nodes/SystemInformationController.php +++ /dev/null @@ -1,40 +0,0 @@ -repository->setNode($node)->getSystemInformation(); - - return new JsonResponse([ - 'version' => $data['version'] ?? '', - 'system' => [ - 'type' => Str::title($data['os'] ?? 'Unknown'), - 'arch' => $data['architecture'] ?? '--', - 'release' => $data['kernel_version'] ?? '--', - 'cpus' => $data['cpu_count'] ?? 0, - ], - ]); - } -} diff --git a/app/Http/Controllers/Admin/NodesController.php b/app/Http/Controllers/Admin/NodesController.php deleted file mode 100644 index 9933811d2..000000000 --- a/app/Http/Controllers/Admin/NodesController.php +++ /dev/null @@ -1,183 +0,0 @@ -locationRepository->all(); - if (count($locations) < 1) { - $this->alert->warning(trans('admin/node.notices.location_required'))->flash(); - - return redirect()->route('admin.locations'); - } - - return view('admin.nodes.new', ['locations' => $locations]); - } - - /** - * Post controller to create a new node on the system. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - public function store(NodeFormRequest $request): RedirectResponse - { - $node = $this->creationService->handle($request->normalize()); - $this->alert->info(trans('admin/node.notices.node_created'))->flash(); - - return redirect()->route('admin.nodes.view.allocation', $node->id); - } - - /** - * Updates settings for a node. - * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function updateSettings(NodeFormRequest $request, Node $node): RedirectResponse - { - $this->updateService->handle($node, $request->normalize(), $request->input('reset_secret') === 'on'); - $this->alert->success(trans('admin/node.notices.node_updated'))->flash(); - - return redirect()->route('admin.nodes.view.settings', $node->id)->withInput(); - } - - /** - * Removes a single allocation from a node. - * - * @throws \Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException - */ - public function allocationRemoveSingle(int $node, Allocation $allocation): Response - { - $this->allocationDeletionService->handle($allocation); - - return response('', 204); - } - - /** - * Removes multiple individual allocations from a node. - * - * @throws \Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException - */ - public function allocationRemoveMultiple(Request $request, int $node): Response - { - $allocations = $request->input('allocations'); - foreach ($allocations as $rawAllocation) { - $allocation = new Allocation(); - $allocation->id = $rawAllocation['id']; - $this->allocationRemoveSingle($node, $allocation); - } - - return response('', 204); - } - - /** - * Remove all allocations for a specific IP at once on a node. - */ - public function allocationRemoveBlock(Request $request, int $node): RedirectResponse - { - $this->allocationRepository->deleteWhere([ - ['node_id', '=', $node], - ['server_id', '=', null], - ['ip', '=', $request->input('ip')], - ]); - - $this->alert->success(trans('admin/node.notices.unallocated_deleted', ['ip' => htmlspecialchars($request->input('ip'))])) - ->flash(); - - return redirect()->route('admin.nodes.view.allocation', $node); - } - - /** - * Sets an alias for a specific allocation on a node. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function allocationSetAlias(AllocationAliasFormRequest $request): \Symfony\Component\HttpFoundation\Response - { - $this->allocationRepository->update($request->input('allocation_id'), [ - 'ip_alias' => (empty($request->input('alias'))) ? null : $request->input('alias'), - ]); - - return response('', 204); - } - - /** - * Creates new allocations on a node. - * - * @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException - * @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException - * @throws \Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException - * @throws \Pterodactyl\Exceptions\Service\Allocation\TooManyPortsInRangeException - */ - public function createAllocation(AllocationFormRequest $request, Node $node): RedirectResponse - { - $this->assignmentService->handle($node, $request->normalize()); - $this->alert->success(trans('admin/node.notices.allocations_added'))->flash(); - - return redirect()->route('admin.nodes.view.allocation', $node->id); - } - - /** - * Deletes a node from the system. - * - * @throws \Pterodactyl\Exceptions\DisplayException - */ - public function delete(int|Node $node): RedirectResponse - { - $this->deletionService->handle($node); - $this->alert->success(trans('admin/node.notices.node_deleted'))->flash(); - - return redirect()->route('admin.nodes'); - } -} diff --git a/app/Http/Controllers/Admin/Servers/CreateServerController.php b/app/Http/Controllers/Admin/Servers/CreateServerController.php deleted file mode 100644 index 54bf24926..000000000 --- a/app/Http/Controllers/Admin/Servers/CreateServerController.php +++ /dev/null @@ -1,84 +0,0 @@ -alert->warning(trans('admin/server.alerts.node_required'))->flash(); - - return redirect()->route('admin.nodes'); - } - - $nests = $this->nestRepository->getWithEggs(); - - \JavaScript::put([ - 'nodeData' => $this->nodeRepository->getNodesForServerCreation(), - 'nests' => $nests->map(function (Nest $item) { - return array_merge($item->toArray(), [ - 'eggs' => $item->eggs->keyBy('id')->toArray(), - ]); - })->keyBy('id'), - ]); - - return view('admin.servers.new', [ - 'locations' => Location::all(), - 'nests' => $nests, - ]); - } - - /** - * Create a new server on the remote system. - * - * @throws \Illuminate\Validation\ValidationException - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException - * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException - * @throws \Throwable - */ - public function store(ServerFormRequest $request): RedirectResponse - { - $data = $request->except(['_token']); - if (!empty($data['custom_image'])) { - $data['image'] = $data['custom_image']; - unset($data['custom_image']); - } - - $server = $this->creationService->handle($data); - - $this->alert->success(trans('admin/server.alerts.server_created'))->flash(); - - return new RedirectResponse('/admin/servers/view/' . $server->id); - } -} diff --git a/app/Http/Controllers/Admin/Servers/ServerController.php b/app/Http/Controllers/Admin/Servers/ServerController.php deleted file mode 100644 index 80de68ef9..000000000 --- a/app/Http/Controllers/Admin/Servers/ServerController.php +++ /dev/null @@ -1,30 +0,0 @@ -with('node', 'user', 'allocation')) - ->allowedFilters([ - AllowedFilter::exact('owner_id'), - AllowedFilter::custom('*', new AdminServerFilter()), - ]) - ->paginate(config()->get('pterodactyl.paginate.admin.servers')); - - return view('admin.servers.index', ['servers' => $servers]); - } -} diff --git a/app/Http/Controllers/Admin/Servers/ServerTransferController.php b/app/Http/Controllers/Admin/Servers/ServerTransferController.php deleted file mode 100644 index 8c9226a65..000000000 --- a/app/Http/Controllers/Admin/Servers/ServerTransferController.php +++ /dev/null @@ -1,119 +0,0 @@ -validate([ - 'node_id' => 'required|exists:nodes,id', - 'allocation_id' => 'required|bail|unique:servers|exists:allocations,id', - 'allocation_additional' => 'nullable', - ]); - - $node_id = $validatedData['node_id']; - $allocation_id = intval($validatedData['allocation_id']); - $additional_allocations = array_map('intval', $validatedData['allocation_additional'] ?? []); - - // Check if the node is viable for the transfer. - $node = $this->nodeRepository->getNodeWithResourceUsage($node_id); - if (!$node->isViable($server->memory, $server->disk)) { - $this->alert->danger(trans('admin/server.alerts.transfer_not_viable'))->flash(); - - return redirect()->route('admin.servers.view.manage', $server->id); - } - - $server->validateTransferState(); - - $this->connection->transaction(function () use ($server, $node_id, $allocation_id, $additional_allocations) { - // Create a new ServerTransfer entry. - $transfer = new ServerTransfer(); - - $transfer->server_id = $server->id; - $transfer->old_node = $server->node_id; - $transfer->new_node = $node_id; - $transfer->old_allocation = $server->allocation_id; - $transfer->new_allocation = $allocation_id; - $transfer->old_additional_allocations = $server->allocations->where('id', '!=', $server->allocation_id)->pluck('id')->values()->toArray(); - $transfer->new_additional_allocations = $additional_allocations; - - $transfer->save(); - - // Add the allocations to the server, so they cannot be automatically assigned while the transfer is in progress. - $this->assignAllocationsToServer($server, $node_id, $allocation_id, $additional_allocations); - - // Generate a token for the destination node that the source node can use to authenticate with. - $token = $this->nodeJWTService - ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) - ->setSubject($server->uuid) - ->setScopes(JwtScope::ServerTransfer) - ->handle($transfer->newNode, $server->uuid); - - // Notify the source node of the pending outgoing transfer. - $this->daemonTransferRepository->setServer($server)->notify($transfer->newNode, $token); - - return $transfer; - }); - - $this->alert->success(trans('admin/server.alerts.transfer_started'))->flash(); - - return redirect()->route('admin.servers.view.manage', $server->id); - } - - /** - * Assigns the specified allocations to the specified server. - */ - private function assignAllocationsToServer(Server $server, int $node_id, int $allocation_id, array $additional_allocations) - { - $allocations = $additional_allocations; - $allocations[] = $allocation_id; - - $unassigned = $this->allocationRepository->getUnassignedAllocationIds($node_id); - - $updateIds = []; - foreach ($allocations as $allocation) { - if (!in_array($allocation, $unassigned)) { - continue; - } - - $updateIds[] = $allocation; - } - - if (!empty($updateIds)) { - $this->allocationRepository->updateWhereIn('id', $updateIds, ['server_id' => $server->id]); - } - } -} diff --git a/app/Http/Controllers/Admin/Servers/ServerViewController.php b/app/Http/Controllers/Admin/Servers/ServerViewController.php deleted file mode 100644 index 0d1b7e842..000000000 --- a/app/Http/Controllers/Admin/Servers/ServerViewController.php +++ /dev/null @@ -1,150 +0,0 @@ -node->allocations->toBase(); - - return view('admin.servers.view.build', [ - 'server' => $server, - 'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'), - 'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'), - ]); - } - - /** - * Returns the server startup management page. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function startup(Request $request, Server $server): View - { - $nests = $this->nestRepository->getWithEggs(); - $variables = $this->environmentService->handle($server); - - $this->plainInject([ - 'server' => $server, - 'server_variables' => $variables, - 'nests' => $nests->map(function (Nest $item) { - return array_merge($item->toArray(), [ - 'eggs' => $item->eggs->keyBy('id')->toArray(), - ]); - })->keyBy('id'), - ]); - - return view('admin.servers.view.startup', compact('server', 'nests')); - } - - /** - * Returns all the databases that exist for the server. - */ - public function database(Request $request, Server $server): View - { - return view('admin.servers.view.database', [ - 'hosts' => $this->databaseHostRepository->all(), - 'server' => $server, - ]); - } - - /** - * Returns all the mounts that exist for the server. - */ - public function mounts(Request $request, Server $server): View - { - $server->load('mounts'); - - return view('admin.servers.view.mounts', [ - 'mounts' => $this->mountRepository->getMountListForServer($server), - 'server' => $server, - ]); - } - - /** - * Returns the base server management page, or an exception if the server - * is in a state that cannot be recovered from. - * - * @throws DisplayException - */ - public function manage(Request $request, Server $server): View - { - if ($server->status === Server::STATUS_INSTALL_FAILED) { - throw new DisplayException('This server is in a failed install state and cannot be recovered. Please delete and re-create the server.'); - } - - // Check if the panel doesn't have at least 2 nodes configured. - $nodes = $this->nodeRepository->all(); - $canTransfer = false; - if (count($nodes) >= 2) { - $canTransfer = true; - } - - \JavaScript::put([ - 'nodeData' => $this->nodeRepository->getNodesForServerCreation(), - ]); - - return view('admin.servers.view.manage', [ - 'server' => $server, - 'locations' => $this->locationRepository->all(), - 'canTransfer' => $canTransfer, - ]); - } - - /** - * Returns the server deletion page. - */ - public function delete(Request $request, Server $server): View - { - return view('admin.servers.view.delete', compact('server')); - } -} diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php deleted file mode 100644 index 1805a831a..000000000 --- a/app/Http/Controllers/Admin/ServersController.php +++ /dev/null @@ -1,273 +0,0 @@ -detailsModificationService->handle($server, $request->only([ - 'owner_id', 'external_id', 'name', 'description', - ])); - - $this->alert->success(trans('admin/server.alerts.details_updated'))->flash(); - - return redirect()->route('admin.servers.view.details', $server->id); - } - - /** - * Toggles the installation status for a server. - * - * @throws DisplayException - * @throws DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function toggleInstall(Server $server): RedirectResponse - { - if ($server->status === Server::STATUS_INSTALL_FAILED) { - throw new DisplayException(trans('admin/server.exceptions.marked_as_failed')); - } - - $this->repository->update($server->id, [ - 'status' => $server->isInstalled() ? Server::STATUS_INSTALLING : null, - ], true, true); - - $this->alert->success(trans('admin/server.alerts.install_toggled'))->flash(); - - return redirect()->route('admin.servers.view.manage', $server->id); - } - - /** - * Reinstalls the server with the currently assigned service. - * - * @throws DisplayException - * @throws DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function reinstallServer(Server $server): RedirectResponse - { - $this->reinstallService->handle($server); - $this->alert->success(trans('admin/server.alerts.server_reinstalled'))->flash(); - - return redirect()->route('admin.servers.view.manage', $server->id); - } - - /** - * Manage the suspension status for a server. - * - * @throws DisplayException - * @throws DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function manageSuspension(Request $request, Server $server): RedirectResponse - { - $this->suspensionService->toggle($server, $request->input('action')); - $this->alert->success(trans('admin/server.alerts.suspension_toggled', [ - 'status' => $request->input('action') . 'ed', - ]))->flash(); - - return redirect()->route('admin.servers.view.manage', $server->id); - } - - /** - * Update the build configuration for a server. - * - * @throws DisplayException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws ValidationException - */ - public function updateBuild(Request $request, Server $server): RedirectResponse - { - try { - $this->buildModificationService->handle($server, $request->only([ - 'allocation_id', 'add_allocations', 'remove_allocations', - 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', - 'database_limit', 'allocation_limit', 'backup_limit', 'oom_disabled', - ])); - } catch (DataValidationException $exception) { - throw new ValidationException($exception->getValidator()); - } - - $this->alert->success(trans('admin/server.alerts.build_updated'))->flash(); - - return redirect()->route('admin.servers.view.build', $server->id); - } - - /** - * Start the server deletion process. - * - * @throws DisplayException - * @throws \Throwable - */ - public function delete(Request $request, Server $server): RedirectResponse - { - $this->deletionService->withForce($request->filled('force_delete'))->handle($server); - $this->alert->success(trans('admin/server.alerts.server_deleted'))->flash(); - - return redirect()->route('admin.servers'); - } - - /** - * Update the startup command as well as variables. - * - * @throws ValidationException - */ - public function saveStartup(Request $request, Server $server): RedirectResponse - { - $data = $request->except('_token'); - if (!empty($data['custom_docker_image'])) { - $data['docker_image'] = $data['custom_docker_image']; - unset($data['custom_docker_image']); - } - - try { - $this->startupModificationService - ->setUserLevel(User::USER_LEVEL_ADMIN) - ->handle($server, $data); - } catch (DataValidationException $exception) { - throw new ValidationException($exception->getValidator()); - } - - $this->alert->success(trans('admin/server.alerts.startup_changed'))->flash(); - - return redirect()->route('admin.servers.view.startup', $server->id); - } - - /** - * Creates a new database assigned to a specific server. - * - * @throws \Throwable - */ - public function newDatabase(StoreServerDatabaseRequest $request, Server $server): RedirectResponse - { - $this->databaseManagementService->create($server, [ - 'database' => DatabaseManagementService::generateUniqueDatabaseName($request->input('database'), $server->id), - 'remote' => $request->input('remote'), - 'database_host_id' => $request->input('database_host_id'), - 'max_connections' => $request->input('max_connections'), - ]); - - return redirect()->route('admin.servers.view.database', $server->id)->withInput(); - } - - /** - * Resets the database password for a specific database on this server. - * - * @throws \Throwable - */ - public function resetDatabasePassword(Request $request, Server $server): Response - { - /** @var Database $database */ - $database = $server->databases()->findOrFail($request->input('database')); - - $this->databasePasswordService->handle($database); - - return response('', 204); - } - - /** - * Deletes a database from a server. - * - * @throws \Exception - */ - public function deleteDatabase(Server $server, Database $database): Response - { - $this->databaseManagementService->delete($database); - - return response('', 204); - } - - /** - * Add a mount to a server. - * - * @throws \Throwable - */ - public function addMount(Request $request, Server $server): RedirectResponse - { - $mountServer = (new MountServer())->forceFill([ - 'mount_id' => $request->input('mount_id'), - 'server_id' => $server->id, - ]); - - $mountServer->saveOrFail(); - - $this->alert->success('Mount was added successfully.')->flash(); - - return redirect()->route('admin.servers.view.mounts', $server->id); - } - - /** - * Remove a mount from a server. - */ - public function deleteMount(Server $server, Mount $mount): RedirectResponse - { - MountServer::where('mount_id', $mount->id)->where('server_id', $server->id)->delete(); - - $this->alert->success('Mount was removed successfully.')->flash(); - - return redirect()->route('admin.servers.view.mounts', $server->id); - } -} diff --git a/app/Http/Controllers/Admin/Settings/AdvancedController.php b/app/Http/Controllers/Admin/Settings/AdvancedController.php deleted file mode 100644 index 9c8bc03f9..000000000 --- a/app/Http/Controllers/Admin/Settings/AdvancedController.php +++ /dev/null @@ -1,60 +0,0 @@ -config->get('recaptcha._shipped_secret_key') === $this->config->get('recaptcha.secret_key') - || $this->config->get('recaptcha._shipped_website_key') === $this->config->get('recaptcha.website_key') - ) { - $showRecaptchaWarning = true; - } - - return view('admin.settings.advanced', [ - 'showRecaptchaWarning' => $showRecaptchaWarning, - ]); - } - - /** - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function update(AdvancedSettingsFormRequest $request): RedirectResponse - { - foreach ($request->normalize() as $key => $value) { - $this->settings->set('settings::' . $key, $value); - } - - $this->kernel->call('queue:restart'); - $this->alert->success('Advanced settings have been updated successfully and the queue worker was restarted to apply these changes.')->flash(); - - return redirect()->route('admin.settings.advanced'); - } -} diff --git a/app/Http/Controllers/Admin/Settings/IndexController.php b/app/Http/Controllers/Admin/Settings/IndexController.php deleted file mode 100644 index e89d120f4..000000000 --- a/app/Http/Controllers/Admin/Settings/IndexController.php +++ /dev/null @@ -1,58 +0,0 @@ - $this->versionService, - 'languages' => $this->getAvailableLanguages(true), - ]); - } - - /** - * Handle settings update. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function update(BaseSettingsFormRequest $request): RedirectResponse - { - foreach ($request->normalize() as $key => $value) { - $this->settings->set('settings::' . $key, $value); - } - - $this->kernel->call('queue:restart'); - $this->alert->success('Panel settings have been updated successfully and the queue worker was restarted to apply these changes.')->flash(); - - return redirect()->route('admin.settings'); - } -} diff --git a/app/Http/Controllers/Admin/Settings/MailController.php b/app/Http/Controllers/Admin/Settings/MailController.php deleted file mode 100644 index 0725f8d49..000000000 --- a/app/Http/Controllers/Admin/Settings/MailController.php +++ /dev/null @@ -1,88 +0,0 @@ - $this->config->get('mail.default') !== 'smtp', - ]); - } - - /** - * Handle request to update SMTP mail settings. - * - * @throws DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function update(MailSettingsFormRequest $request): Response - { - if ($this->config->get('mail.default') !== 'smtp') { - throw new DisplayException('This feature is only available if SMTP is the selected email driver for the Panel.'); - } - - $values = $request->normalize(); - if (array_get($values, 'mail:mailers:smtp:password') === '!e') { - $values['mail:mailers:smtp:password'] = ''; - } - - foreach ($values as $key => $value) { - if (in_array($key, SettingsServiceProvider::getEncryptedKeys()) && !empty($value)) { - $value = $this->encrypter->encrypt($value); - } - - $this->settings->set('settings::' . $key, $value); - } - - $this->kernel->call('queue:restart'); - - return response('', 204); - } - - /** - * Submit a request to send a test mail message. - */ - public function test(Request $request): Response - { - try { - Notification::route('mail', $request->user()->email) - ->notify(new MailTested($request->user())); - } catch (\Exception $exception) { - return response($exception->getMessage(), 500); - } - - return response('', 204); - } -} diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php deleted file mode 100644 index d44595bbe..000000000 --- a/app/Http/Controllers/Admin/UserController.php +++ /dev/null @@ -1,156 +0,0 @@ -select('users.*') - ->selectRaw('COUNT(DISTINCT(subusers.id)) as subuser_of_count') - ->selectRaw('COUNT(DISTINCT(servers.id)) as servers_count') - ->leftJoin('subusers', 'subusers.user_id', '=', 'users.id') - ->leftJoin('servers', 'servers.owner_id', '=', 'users.id') - ->groupBy('users.id') - ) - ->allowedFilters(['username', 'email', 'uuid']) - ->defaultSort('-root_admin') - ->allowedSorts(['id', 'uuid']) - ->paginate(50); - - return view('admin.users.index', ['users' => $users]); - } - - /** - * Display new user page. - */ - public function create(): View - { - return view('admin.users.new', [ - 'languages' => $this->getAvailableLanguages(true), - ]); - } - - /** - * Display user view page. - */ - public function view(User $user): View - { - return view('admin.users.view', [ - 'user' => $user, - 'languages' => $this->getAvailableLanguages(true), - ]); - } - - /** - * Delete a user from the system. - * - * @throws \Exception - * @throws DisplayException - */ - public function delete(Request $request, User $user): RedirectResponse - { - if ($request->user()->is($user)) { - throw new DisplayException(__('admin/user.exceptions.delete_self')); - } - - $this->deletionService->handle($user); - - return redirect()->route('admin.users'); - } - - /** - * Create a user. - * - * @throws \Exception - * @throws \Throwable - */ - public function store(NewUserFormRequest $request): RedirectResponse - { - $user = $this->creationService->handle($request->normalize()); - $this->alert->success($this->translator->get('admin/user.notices.account_created'))->flash(); - - return redirect()->route('admin.users.view', $user->id); - } - - /** - * Update a user on the system. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function update(UserFormRequest $request, User $user): RedirectResponse - { - $this->updateService - ->setUserLevel(User::USER_LEVEL_ADMIN) - ->handle($user, $request->normalize()); - - $this->alert->success(trans('admin/user.notices.account_updated'))->flash(); - - return redirect()->route('admin.users.view', $user->id); - } - - /** - * Get a JSON response of users on the system. - */ - public function json(Request $request): Model|Collection - { - $users = QueryBuilder::for(User::query())->allowedFilters(['email'])->paginate(25); - - // Handle single user requests. - if ($request->query('user_id')) { - $user = User::query()->findOrFail($request->input('user_id')); - // @phpstan-ignore-next-line property.notFound - $user->md5 = md5(strtolower($user->email)); - - return $user; - } - - return $users->map(function ($item) { - // @phpstan-ignore-next-line property.notFound - $item->md5 = md5(strtolower($item->email)); - - return $item; - }); - } -} diff --git a/app/Http/Controllers/Api/Admin/ActivityController.php b/app/Http/Controllers/Api/Admin/ActivityController.php new file mode 100644 index 000000000..cea7c9447 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/ActivityController.php @@ -0,0 +1,62 @@ +where('event', 'like', self::ADMIN_EVENT_PREFIX.'%')) + ->allowedFilters([AllowedFilter::partial('event'), AllowedFilter::partial('ip'), ActivityLogFilters::actor($request->string('filter.user')->toString()), ActivityLogFilters::actorId($request->integer('filter.user_id')), AllowedFilter::exact('event_name', 'event')]) + ->allowedSorts(['timestamp']) + ->defaultSort('-timestamp', '-id') + ->with('actor') + ->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS) + ->paginate($request->perPage(25)) + ->appends($request->query()); + + return Fractal::collection($activity) + ->transformWith($this->getTransformer(ActivityLogTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/ActivityFilterController.php b/app/Http/Controllers/Api/Admin/ActivityFilterController.php new file mode 100644 index 000000000..029f3d508 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/ActivityFilterController.php @@ -0,0 +1,40 @@ + [ + 'events' => ['admin:server.build', 'admin:server.suspend'], + 'users' => [ + ['id' => 1, 'username' => 'admin', 'email' => 'admin@example.com'], + ], + ], + ]; + + /** + * Return the filter options available for the administrative activity log. + */ + #[Endpoint('List activity filter options', 'Returns the distinct events and users present in the administrative activity log.')] + #[ScribeResponse(self::FACETS_EXAMPLE, description: 'Filter options returned.')] + public function __invoke(GetActivityLogsRequest $request, ActivityLogFacetService $facets): JsonResponse + { + return new JsonResponse([ + 'data' => $facets->handle(ActivityLog::query()->where('event', 'like', ActivityController::ADMIN_EVENT_PREFIX.'%')), + ]); + } +} diff --git a/app/Http/Controllers/Api/Admin/AdminApiController.php b/app/Http/Controllers/Api/Admin/AdminApiController.php new file mode 100644 index 000000000..c096a9775 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/AdminApiController.php @@ -0,0 +1,26 @@ + $abstract + * @return T + * + * @noinspection PhpDocSignatureInspection + */ + public function getTransformer(string $abstract): BaseAdminTransformer + { + return $this->makeTransformer($abstract, BaseAdminTransformer::class); + } +} diff --git a/app/Http/Controllers/Api/Admin/ApiKeys/ApiKeyController.php b/app/Http/Controllers/Api/Admin/ApiKeys/ApiKeyController.php new file mode 100644 index 000000000..f121b0720 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/ApiKeys/ApiKeyController.php @@ -0,0 +1,155 @@ +with('user')->where('key_type', ApiKey::TYPE_APPLICATION)) + ->allowedFilters(['memo', 'identifier']) + ->allowedSorts(['id', 'memo', 'created_at']) + ->paginate($request->perPage()); + + return Fractal::collection($keys) + ->transformWith($this->getTransformer(ApiKeyTransformer::class)) + ->toResponseArray(); + } + + /** + * Create API key. + */ + #[Endpoint('Create API key', 'Creates a new application API key and returns the plaintext secret token once.')] + #[ResponseFromTransformer(ApiKeyTransformer::class, ApiKey::class, status: 201, description: 'API key created.', resourceKey: 'api_key', meta: ['secret_token' => 'ptla_1234567890abcdef'])] + public function store(StoreApiKeyRequest $request, Encrypter $encrypter, CreatesApiKeys $keyCreator): JsonResponse + { + $key = $keyCreator->create(ApiKey::TYPE_APPLICATION, [ + 'memo' => $request->string('memo')->toString(), + 'user_id' => $request->user()->id, + ], $request->getKeyPermissions()); + $key->load('user'); + + Activity::event('admin:api-key.create') + ->subject($key) + ->property('identifier', $key->identifier) + ->log(); + + return Fractal::item($key) + ->transformWith($this->getTransformer(ApiKeyTransformer::class)) + ->addMeta([ + 'secret_token' => $key->identifier.JsonValueGuard::string($encrypter->decrypt($key->token)), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Show API key. + * + * @return ApiPayload + */ + #[Endpoint('Get API key', 'Returns a single application API key by identifier without exposing its token.')] + #[ResponseFromTransformer(ApiKeyTransformer::class, ApiKey::class, description: 'API key returned.', resourceKey: 'api_key')] + public function show(GetApiKeysRequest $request, string $identifier): array + { + $key = ApiKey::query() + ->with('user') + ->where('key_type', ApiKey::TYPE_APPLICATION) + ->where('identifier', $identifier) + ->firstOrFail(); + + return Fractal::item($key) + ->transformWith($this->getTransformer(ApiKeyTransformer::class)) + ->toResponseArray(); + } + + /** + * Update API key. + * + * @return ApiPayload + */ + #[Endpoint('Update API key', 'Updates an application API key memo and resource permissions without regenerating the token.')] + #[ResponseFromTransformer(ApiKeyTransformer::class, ApiKey::class, description: 'API key updated.', resourceKey: 'api_key')] + public function update(UpdateApiKeyRequest $request, string $identifier): array + { + $key = ApiKey::query() + ->where('key_type', ApiKey::TYPE_APPLICATION) + ->where('identifier', $identifier) + ->firstOrFail(); + + $key->forceFill(array_merge( + ['memo' => $request->validated('memo')], + $request->getKeyPermissions() + ))->saveOrFail(); + $key->load('user'); + + Activity::event('admin:api-key.update') + ->subject($key) + ->property('identifier', $key->identifier) + ->log(); + + return Fractal::item($key) + ->transformWith($this->getTransformer(ApiKeyTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete API key. + */ + #[Endpoint('Delete API key', 'Deletes an application API key by identifier.')] + #[ScribeResponse(status: 204, description: 'API key deleted.')] + public function destroy(DeleteApiKeyRequest $request, string $identifier): Response + { + $key = ApiKey::query() + ->where('key_type', ApiKey::TYPE_APPLICATION) + ->where('identifier', $identifier) + ->firstOrFail(); + + Activity::event('admin:api-key.delete') + ->subject($key) + ->property('identifier', $key->identifier) + ->log(); + + $key->delete(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/DatabaseHosts/DatabaseHostController.php b/app/Http/Controllers/Api/Admin/DatabaseHosts/DatabaseHostController.php new file mode 100644 index 000000000..81f27e04a --- /dev/null +++ b/app/Http/Controllers/Api/Admin/DatabaseHosts/DatabaseHostController.php @@ -0,0 +1,250 @@ + 'database', + 'attributes' => [ + 'server' => [ + 'id' => 1, + 'name' => 'Survival', + ], + 'name' => 's1_database', + 'username' => 'u1_database', + 'connections_from' => '%', + 'max_connections' => 0, + ], + ]; + + private const array DATABASE_LIST_EXAMPLE = [ + 'object' => 'list', + 'data' => [ + self::DATABASE_HOST_DATABASE_EXAMPLE, + ], + 'meta' => [ + 'pagination' => [ + 'total' => 1, + 'count' => 1, + 'per_page' => 50, + 'current_page' => 1, + 'total_pages' => 1, + 'links' => [], + ], + ], + ]; + + private const array CONNECTION_ERROR = [ + 'errors' => [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'There was an error while trying to connect to the host or while executing a query: "connection refused"', + ], + ], + ]; + + /** + * List database hosts. + * + * @return ApiPayload + */ + #[Endpoint('List database hosts', 'Returns a paginated list of database hosts.')] + #[QueryParam('page', 'integer', 'Page number to retrieve.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[QueryParam('filter[name]', 'string', 'Filter hosts by name.', required: false, example: 'Primary')] + #[QueryParam('filter[host]', 'string', 'Filter hosts by address or hostname.', required: false, example: '127.0.0.1')] + #[QueryParam('sort', 'string', 'Sort hosts by ID, name, or creation date. Prefix with a hyphen for descending order.', required: false, example: '-created_at')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports node and databases.', required: false, example: 'node')] + #[ResponseFromTransformer(DatabaseHostTransformer::class, DatabaseHost::class, description: 'Database hosts returned.', collection: true, resourceKey: 'database_host', paginate: [IlluminatePaginatorAdapter::class, 50])] + public function index(GetDatabaseHostsRequest $request): array + { + $query = QueryBuilder::for(DatabaseHost::query()) + ->allowedFilters(['name', 'host']) + ->allowedSorts(['id', 'name', 'created_at']); + + $hosts = $query->getEloquentBuilder() + ->with('node') + ->withCount('databases') + ->paginate($request->perPage()); + + return Fractal::collection($hosts) + ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->toResponseArray(); + } + + /** + * Show database host. + * + * @return ApiPayload + */ + #[Endpoint('Get database host', 'Returns a single database host by ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports node and databases.', required: false, example: 'node')] + #[ResponseFromTransformer(DatabaseHostTransformer::class, DatabaseHost::class, description: 'Database host returned.', resourceKey: 'database_host', include: ['node', 'databases'])] + public function show(GetDatabaseHostRequest $request, DatabaseHost $databaseHost): array + { + $databaseHost->loadCount('databases'); + $databaseHost->load('node'); + + return Fractal::item($databaseHost) + ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->toResponseArray(); + } + + /** + * List databases associated with a database host. + * + * @return ApiPayload + */ + #[Endpoint('List database host databases', 'Returns a paginated list of server databases assigned to a database host.')] + #[QueryParam('page', 'integer', 'Page number to retrieve.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[ScribeResponse(self::DATABASE_LIST_EXAMPLE, description: 'Databases returned.')] + #[ResponseField('attributes.max_connections', 'integer', example: 0, nullable: true)] + public function databases(GetDatabaseHostRequest $request, DatabaseHost $databaseHost): array + { + $databases = $databaseHost->databases() + ->with('server') + ->paginate($request->perPage()); + + return Fractal::collection($databases, resourceName: 'database') + ->transformWith(function (Database $database): array { + $server = $database->getRelation('server'); + throw_unless($server instanceof Server, UnexpectedValueException::class, 'A database response requires its server relation.'); + + return [ + 'server' => [ + 'id' => $server->id, + 'name' => $server->name, + ], + 'name' => $database->database, + 'username' => $database->username, + 'connections_from' => $database->remote, + 'max_connections' => $database->max_connections, + ]; + }) + ->toResponseArray(); + } + + /** + * Create database host. + */ + #[Endpoint('Create database host', 'Creates a database host after validating that the panel can connect to it.')] + #[ResponseFromTransformer(DatabaseHostTransformer::class, DatabaseHost::class, status: 201, description: 'Database host created.', resourceKey: 'database_host', meta: ['resource' => 'https://panel.example.com/api/admin/database-hosts/1'])] + #[ScribeResponse(self::CONNECTION_ERROR, status: 400, description: 'The panel could not connect to the database host.')] + public function store(StoreDatabaseHostRequest $request, CreatesDatabaseHosts $createHost): JsonResponse + { + try { + $host = $createHost->create($request->payload()); + } catch (Exception $exception) { + $this->handleConnectionException($exception); + } + + $host->load('node')->loadCount('databases'); + + Activity::event('admin:database-host.create') + ->subject($host) + ->property('name', $host->name) + ->log(); + + return Fractal::item($host) + ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.database-hosts.view', [ + 'databaseHost' => $host->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update database host. + * + * @return ApiPayload + */ + #[Endpoint('Update database host', 'Updates a database host after validating that the panel can connect to the supplied host details.')] + #[ResponseFromTransformer(DatabaseHostTransformer::class, DatabaseHost::class, description: 'Database host updated.', resourceKey: 'database_host')] + #[ScribeResponse(self::CONNECTION_ERROR, status: 400, description: 'The panel could not connect to the database host.')] + public function update(UpdateDatabaseHostRequest $request, UpdatesDatabaseHosts $updateHost, DatabaseHost $databaseHost): array + { + try { + $host = $updateHost->update($databaseHost, $request->payload()); + } catch (Exception $exception) { + $this->handleConnectionException($exception); + } + + $host->load('node')->loadCount('databases'); + + Activity::event('admin:database-host.update') + ->subject($host) + ->property('name', $host->name) + ->log(); + + return Fractal::item($host) + ->transformWith($this->getTransformer(DatabaseHostTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete database host. + */ + #[Endpoint('Delete database host', 'Deletes a database host when no server databases depend on it.')] + #[ScribeResponse(status: 204, description: 'Database host deleted.')] + public function destroy(DeleteDatabaseHostRequest $request, DeletesDatabaseHosts $deleteHost, DatabaseHost $databaseHost): Response + { + Activity::event('admin:database-host.delete') + ->subject($databaseHost) + ->property('name', $databaseHost->name) + ->log(); + + $deleteHost->delete($databaseHost); + + return $this->returnNoContent(); + } + + private function handleConnectionException(Throwable $exception): never + { + if ($exception instanceof PDOException || $exception->getPrevious() instanceof PDOException) { + throw new DisplayException(sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()), $exception); + } + + throw $exception; + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/EggCatalogController.php b/app/Http/Controllers/Api/Admin/Eggs/EggCatalogController.php new file mode 100644 index 000000000..7bbe34ae4 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/EggCatalogController.php @@ -0,0 +1,57 @@ + [[ + 'id' => 'games-minecraft-paper', + 'name' => 'Paper', + 'description' => 'High performance Minecraft server.', + 'category' => 'games', + 'source_url' => 'https://eggs.pterodactyl.io/egg/games-minecraft-paper', + ]], + ]; + + #[Endpoint('List egg catalog', 'Returns the cached Pterodactyl egg catalog for searching and filtering. The index is cached for one hour.')] + #[ScribeResponse(self::CATALOG_EXAMPLE, description: 'Catalog entries returned.')] + #[ScribeResponse(status: 502, description: 'The upstream catalog is unavailable or invalid.')] + #[ResponseField('data', 'object[]', 'The available catalog entries.', required: true)] + #[ResponseField('data.id', 'string', 'The catalog identifier used to import this egg.', required: true)] + #[ResponseField('data.name', 'string', 'The egg name.', required: true)] + #[ResponseField('data.description', 'string', 'The egg description, or an empty string.', required: true)] + #[ResponseField('data.category', 'string', 'The catalog category, or an empty string.', required: true)] + #[ResponseField('data.source_url', 'string', 'The egg page on eggs.pterodactyl.io.', required: true)] + public function index(GetEggsRequest $request, EggCatalogService $catalog): JsonResponse + { + return new JsonResponse([ + 'data' => array_map(fn (EggCatalogEntry $entry): array => $entry->toArray(), $catalog->all()), + ]); + } + + #[Endpoint('Refresh egg catalog', 'Clears the cached Pterodactyl catalog so the next listing downloads the current index.')] + #[ScribeResponse(status: 204, description: 'Catalog cache cleared.')] + public function refresh(GetEggsRequest $request, EggCatalogService $catalog): Response + { + $catalog->refresh(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/EggController.php b/app/Http/Controllers/Api/Admin/Eggs/EggController.php new file mode 100644 index 000000000..4964fd6d9 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/EggController.php @@ -0,0 +1,144 @@ + [ + [ + 'code' => 'HasActiveServersException', + 'status' => '400', + 'detail' => 'Cannot delete an egg with active servers attached to it.', + ], + ], + ]; + + /** + * List eggs. + * + * @return ApiPayload + */ + #[Endpoint('List eggs', 'Returns a paginated list of egg definitions.')] + #[QueryParam('filter[name]', 'string', 'Filter eggs by name.', required: false, example: 'Paper')] + #[QueryParam('sort', 'string', 'Sort eggs by id or name. Prefix with a hyphen for descending order.', required: false, example: 'name')] + #[QueryParam('page', 'integer', 'Page number to return.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[QueryParam('include', 'string', 'Comma-separated relationships to include: variables, tags, servers.', required: false, example: 'variables', enum: ['variables', 'tags', 'servers', 'variables,tags', 'variables,servers', 'tags,servers', 'variables,tags,servers'])] + #[ResponseFromTransformer(EggTransformer::class, Egg::class, description: 'Eggs returned.', collection: true, resourceKey: 'egg', paginate: [IlluminatePaginatorAdapter::class, 50])] + public function index(GetEggsRequest $request): array + { + $eggs = QueryBuilder::for(Egg::query()) + ->allowedFilters(['name']) + ->allowedSorts(['id', 'name']) + ->paginate($request->perPage()); + + return Fractal::collection($eggs) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } + + /** + * Show egg. + * + * @return ApiPayload + */ + #[Endpoint('Get egg', 'Returns a single egg definition by ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include: variables, tags, servers.', required: false, example: 'variables,tags', enum: ['variables', 'tags', 'servers', 'variables,tags', 'variables,servers', 'tags,servers', 'variables,tags,servers'])] + #[ResponseFromTransformer(EggTransformer::class, Egg::class, description: 'Egg returned.', resourceKey: 'egg', include: ['servers', 'variables', 'tags'])] + public function show(GetEggRequest $request, Egg $egg): array + { + return Fractal::item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } + + /** + * Create egg. + */ + #[Endpoint('Create egg', 'Creates an egg definition.')] + #[ResponseFromTransformer(EggTransformer::class, Egg::class, status: 201, description: 'Egg created.', resourceKey: 'egg', meta: ['resource' => 'https://panel.example.com/api/admin/eggs/1'])] + public function store(StoreEggRequest $request, CreatesEggs $eggs): JsonResponse + { + $egg = $eggs->create($request->payload()); + + Activity::event('admin:egg.create') + ->subject($egg) + ->property('name', $egg->name) + ->log(); + + return Fractal::item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.eggs.view', ['egg' => $egg->id]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update egg. + * + * @return ApiPayload + */ + #[Endpoint('Update egg', 'Updates an egg definition.')] + #[ResponseFromTransformer(EggTransformer::class, Egg::class, description: 'Egg updated.', resourceKey: 'egg')] + public function update(UpdateEggRequest $request, UpdatesEggs $eggs, Egg $egg): array + { + $eggs->update($egg, $request->payload()); + + Activity::event('admin:egg.update') + ->subject($egg) + ->property('name', $egg->name) + ->log(); + + return Fractal::item($egg->refresh()) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete egg. + */ + #[Endpoint('Delete egg', 'Deletes an egg definition.')] + #[ScribeResponse(status: 204, description: 'Egg deleted.')] + #[ScribeResponse(self::DELETE_CONFLICT_ERROR, status: 400, description: 'The egg has active servers or child eggs.')] + public function destroy(DeleteEggRequest $request, DeletesEggs $eggs, Egg $egg): Response + { + $eggs->delete($egg); + + Activity::event('admin:egg.delete') + ->subject($egg) + ->property('name', $egg->name) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/EggScriptController.php b/app/Http/Controllers/Api/Admin/Eggs/EggScriptController.php new file mode 100644 index 000000000..e89c7c210 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/EggScriptController.php @@ -0,0 +1,75 @@ + [ + [ + 'code' => 'InvalidCopyFromException', + 'status' => '400', + 'detail' => 'The selected egg cannot be used as an install script source.', + ], + ], + ]; + + /** + * Show egg install script. + * + * @return ApiPayload + */ + #[Endpoint('Get egg install script', 'Returns an egg with its install script block.')] + #[ResponseFromTransformer(EggTransformer::class, Egg::class, description: 'Egg install script returned.', resourceKey: 'egg')] + public function show(GetEggScriptRequest $request, Egg $egg): array + { + + return Fractal::item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } + + /** + * Update egg install script. + * + * @return ApiPayload + */ + #[Endpoint('Update egg install script', 'Updates the install script configuration for an egg.')] + #[ResponseFromTransformer(EggTransformer::class, Egg::class, description: 'Egg install script updated.', resourceKey: 'egg')] + #[ScribeResponse(self::INVALID_COPY_FROM_ERROR, status: 400, description: 'The selected copy source is invalid.')] + public function update(UpdateEggScriptRequest $request, UpdatesEggInstallScripts $scripts, Egg $egg): array + { + + $data = $request->validated(); + JsonValueGuard::assertPayload9($data); + $scripts->update($egg, $data); + + Activity::event('admin:egg.scripts') + ->subject($egg) + ->property('name', $egg->name) + ->log(); + + return Fractal::item($egg->refresh()) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/EggVariableController.php b/app/Http/Controllers/Api/Admin/Eggs/EggVariableController.php new file mode 100644 index 000000000..dd9a8c061 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/EggVariableController.php @@ -0,0 +1,121 @@ +orderedVariables($egg)) + ->transformWith($this->getTransformer(EggVariableTransformer::class)) + ->toResponseArray(); + } + + /** + * Create egg variable. + */ + #[Endpoint('Create egg variable', 'Creates a startup variable for an egg.')] + #[ResponseFromTransformer(EggVariableTransformer::class, EggVariable::class, status: 201, description: 'Egg variable created.', resourceKey: 'egg_variable')] + public function store(StoreVariableRequest $request, CreatesEggVariables $variables, Egg $egg): JsonResponse + { + + $variable = $variables->create($egg, $request->payload()); + + Activity::event('admin:egg-variable.create') + ->subject($egg, $variable) + ->property('name', $variable->name) + ->log(); + + return Fractal::item($variable) + ->transformWith($this->getTransformer(EggVariableTransformer::class)) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update egg variable. + * + * @return ApiPayload + */ + #[Endpoint('Update egg variable', 'Updates a startup variable for an egg.')] + #[ResponseFromTransformer(EggVariableTransformer::class, EggVariable::class, description: 'Egg variable updated.', resourceKey: 'egg_variable')] + public function update(UpdateVariableRequest $request, UpdatesEggVariables $variables, Egg $egg, EggVariable $variable): array + { + $variables->update($variable, $request->payload()); + + $variable = $variable->refresh(); + + Activity::event('admin:egg-variable.update') + ->subject($egg, $variable) + ->property('name', $variable->name) + ->log(); + + return Fractal::item($variable) + ->transformWith($this->getTransformer(EggVariableTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete egg variable. + */ + #[Endpoint('Delete egg variable', 'Deletes a startup variable from an egg.')] + #[ScribeResponse(status: 204, description: 'Egg variable deleted.')] + public function destroy(DeleteVariableRequest $request, Egg $egg, EggVariable $variable): Response + { + $variable->delete(); + + Activity::event('admin:egg-variable.delete') + ->subject($egg, $variable) + ->property('name', $variable->name) + ->log(); + + return $this->returnNoContent(); + } + + /** + * Return egg variables in display order. + * + * @return Collection + */ + private function orderedVariables(Egg $egg): Collection + { + return $egg->variables() + ->orderByRaw('sort_order IS NULL, sort_order ASC') + ->orderBy('id') + ->get(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/ExportEggController.php b/app/Http/Controllers/Api/Admin/Eggs/ExportEggController.php new file mode 100644 index 000000000..d77ddf83b --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/ExportEggController.php @@ -0,0 +1,53 @@ + [ + 'version' => Egg::EXPORT_VERSION, + ], + 'name' => 'Minecraft Java', + 'author' => 'support@example.com', + 'description' => 'Minecraft Java server.', + 'features' => ['eula'], + 'docker_images' => [ + 'Java 21' => 'ghcr.io/pterodactyl/yolks:java_21', + ], + 'startup' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}', + ]; + + /** + * Export egg configuration. + */ + #[Endpoint('Export egg', 'Downloads an egg share JSON file.')] + #[ScribeResponse(self::EXPORT_EXAMPLE, description: 'Egg share file returned.')] + public function __invoke(GetEggRequest $request, ExportsEggs $eggs, Egg $egg): Response + { + + $filename = mb_trim(preg_replace('/\W/', '-', Str::kebab($egg->name)), '-'); + + return new Response($eggs->export($egg), Response::HTTP_OK, [ + 'Content-Transfer-Encoding' => 'binary', + 'Content-Description' => 'File Transfer', + 'Content-Disposition' => 'attachment; filename=egg-'.$filename.'.json', + 'Content-Type' => 'application/json', + ]); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/ImportCatalogEggController.php b/app/Http/Controllers/Api/Admin/Eggs/ImportCatalogEggController.php new file mode 100644 index 000000000..381d5510f --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/ImportCatalogEggController.php @@ -0,0 +1,45 @@ + 'https://panel.example.com/api/admin/eggs/1'])] + #[ScribeResponse(status: 404, description: 'The selected catalog entry does not exist.')] + #[ScribeResponse(status: 502, description: 'The upstream catalog or egg definition could not be loaded.')] + public function __invoke(ImportCatalogEggRequest $request, ImportsCatalogEggs $catalogImporter): JsonResponse + { + $egg = $catalogImporter->import($request->catalogId()); + + Activity::event('admin:egg.import') + ->subject($egg) + ->property('name', $egg->name) + ->property('catalog_id', $request->catalogId()) + ->log(); + + return Fractal::item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->addMeta(['resource' => route('api.admin.eggs.view', ['egg' => $egg->id])]) + ->respond(Response::HTTP_CREATED); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/ImportEggController.php b/app/Http/Controllers/Api/Admin/Eggs/ImportEggController.php new file mode 100644 index 000000000..4541c98ed --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/ImportEggController.php @@ -0,0 +1,48 @@ + 'https://panel.example.com/api/admin/eggs/1'])] + public function __invoke(ImportEggRequest $request, ImportsEggs $importer): JsonResponse + { + $egg = $importer->import($request->file('import_file')); + + Activity::event('admin:egg.import') + ->subject($egg) + ->property('name', $egg->name) + ->log(); + + return Fractal::item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.eggs.view', [ + 'egg' => $egg->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/ReorderVariablesController.php b/app/Http/Controllers/Api/Admin/Eggs/ReorderVariablesController.php new file mode 100644 index 000000000..98f776fe3 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/ReorderVariablesController.php @@ -0,0 +1,48 @@ +reorder($egg, $request->order()); + + Activity::event('admin:egg-variable.reorder') + ->subject($egg) + ->log(); + + $variables = $egg->variables() + ->orderByRaw('sort_order IS NULL, sort_order ASC') + ->orderBy('id') + ->get(); + + return Fractal::collection($variables) + ->transformWith($this->getTransformer(EggVariableTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Eggs/UpdateImportEggController.php b/app/Http/Controllers/Api/Admin/Eggs/UpdateImportEggController.php new file mode 100644 index 000000000..26153b091 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Eggs/UpdateImportEggController.php @@ -0,0 +1,43 @@ +update($egg, $request->file('import_file')); + + Activity::event('admin:egg.update-import') + ->subject($egg) + ->property('name', $egg->name) + ->log(); + + return Fractal::item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Extensions/ExtensionAdminSettingsController.php b/app/Http/Controllers/Api/Admin/Extensions/ExtensionAdminSettingsController.php new file mode 100644 index 000000000..e19e506b9 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Extensions/ExtensionAdminSettingsController.php @@ -0,0 +1,42 @@ + $this->extensionSettings()->publicSettings(), + ]; + JsonValueGuard::assertPayload($payload); + + return $payload; + } + + /** @return ApiPayload */ + protected function updateExtensionSettings(Request $request): array + { + $data = $request->validate($this->extensionSettings()->validationRules()); + ExtensionSettingValueGuard::assertValues($data); + + $this->extensionSettings()->update($data); + + return $data; + } +} diff --git a/app/Http/Controllers/Api/Admin/Extensions/ExtensionController.php b/app/Http/Controllers/Api/Admin/Extensions/ExtensionController.php new file mode 100644 index 000000000..fdff53be8 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Extensions/ExtensionController.php @@ -0,0 +1,300 @@ + 'example-extension', + 'name' => 'Example Extension', + 'version' => '1.0.0', + 'description' => 'Example extension', + 'author' => 'Pterodactyl', + 'provider' => 'ExampleExtension\\Provider', + 'has_ui' => true, + 'ui_entry' => 'dist/client.js', + 'ui_mode' => 'native', + 'frontend_entry' => '/assets/extensions/example-extension/client.js?v=100', + 'installed' => true, + 'enabled' => true, + 'state' => 'enabled', + 'error' => null, + ]; + + private const array LIST_EXAMPLE = [ + 'data' => [ + self::EXTENSION_EXAMPLE, + ], + 'meta' => [ + 'enabled' => true, + 'directory' => '/var/www/pterodactyl/extensions', + ], + ]; + + private const array SETTINGS_EXAMPLE = [ + 'data' => [ + 'registered' => true, + 'schema' => [ + [ + 'input' => 'curseforge_api_key', + 'label' => 'CurseForge API Key', + 'help' => 'Leave blank to keep the stored key.', + 'field' => 'password', + 'options' => [], + 'value' => '***********9999', + 'constraints' => ['max_length' => null, 'max_items' => null, 'max_kilobytes' => null, 'accept' => []], + 'visibility' => 'admin', + ], + ], + ], + ]; + + #[Endpoint('List extensions', 'Returns discovered extensions, invalid manifests, and their install state.')] + #[ScribeResponse(self::LIST_EXAMPLE, description: 'Extensions returned.')] + public function index(GetExtensionsRequest $request, ExtensionRepository $extensions, ExtensionAssetPublisher $assets): JsonResponse + { + return new JsonResponse([ + 'data' => $this->extensionList($extensions, $assets), + 'meta' => [ + 'enabled' => (bool) config('extensions.enabled'), + 'directory' => $extensions->directory(), + ], + ]); + } + + #[Endpoint('Install extension', 'Installs an uploaded .pteroext or .zip extension package.')] + #[BodyParam('package', 'file', 'Extension archive to install.', required: true)] + #[BodyParam('enable', 'boolean', 'Enable the extension after installing it.', required: false, example: false)] + #[ScribeResponse(['data' => self::EXTENSION_EXAMPLE], status: 201, description: 'Extension installed.')] + public function store( + InstallExtensionRequest $request, + ExtensionRepository $extensions, + InstallsExtensions $installer, + ExtensionAssetPublisher $assets, + ): JsonResponse { + $payload = $request->payload(); + $uploaded = $payload['package']; + $workdir = storage_path('app'.DIRECTORY_SEPARATOR.'extensions-uploads'); + $filename = Str::random(24).'.'.($uploaded->getClientOriginalExtension() ?: 'zip'); + + File::ensureDirectoryExists($workdir); + $uploaded->move($workdir, $filename); + $path = $workdir.DIRECTORY_SEPARATOR.$filename; + + try { + $manifest = $installer->install($path, $payload['enable']); + } finally { + File::delete($path); + } + + return new JsonResponse([ + 'data' => $this->serializeManifest($manifest, $extensions->records()->get($manifest->id), $assets), + ], Response::HTTP_CREATED); + } + + #[Endpoint('Get extension settings', 'Returns the auto-render form schema (with current public values) for an extension that registered a settings definition.')] + #[ScribeResponse(self::SETTINGS_EXAMPLE, description: 'Settings schema returned.')] + public function settings(GetExtensionsRequest $request, ExtensionRepository $extensions, ExtensionSettingsRegistry $settingsRegistry, string $extension): JsonResponse + { + $definition = $settingsRegistry->get($extension); + if (! $definition instanceof ExtensionSettingsDefinition) { + abort_if($extensions->discovered()->get($extension) === null, Response::HTTP_NOT_FOUND, "Extension \"{$extension}\" is not installed."); + + return new JsonResponse(['data' => ['registered' => false, 'schema' => []]]); + } + + return new JsonResponse(['data' => ['registered' => true, 'schema' => $definition->schema()]]); + } + + #[Endpoint('Update extension settings', "Validates against the extension's declared rules and persists the submitted values. Omitted fields keep their stored values.")] + #[BodyParam('settings', 'object', 'Field values keyed by input name, as described by the settings schema.', required: true, example: ['curseforge_api_key' => 'cf-key'])] + #[ScribeResponse(self::SETTINGS_EXAMPLE, description: 'Settings updated; fresh schema returned.')] + public function updateSettings(UpdateExtensionSettingsRequest $request, UpdatesExtensionSettings $updateSettings, ExtensionSettingsRegistry $settingsRegistry, string $extension): JsonResponse + { + $definition = $settingsRegistry->get($extension); + abort_if(! $definition instanceof ExtensionSettingsDefinition, Response::HTTP_NOT_FOUND, "Extension \"{$extension}\" has not registered settings (it may be disabled)."); + + $schema = $updateSettings->update($definition, $request->settings($definition)); + + return new JsonResponse(['data' => ['registered' => true, 'schema' => $schema]]); + } + + #[Endpoint('Upload extension setting file', "Stores the uploaded file as the value of a file setting and deletes the file it replaces. The type is decided from the file's content and checked against the setting's allow-list and size limit.")] + #[BodyParam('file', 'file', 'File to store.', required: true)] + #[ScribeResponse(self::SETTINGS_EXAMPLE, description: 'File stored; fresh schema returned.')] + public function uploadSettingFile(UploadExtensionSettingFileRequest $request, ReplacesExtensionSettingFiles $files, ExtensionSettingsRegistry $settingsRegistry, string $extension, string $input): JsonResponse + { + $definition = $settingsRegistry->get($extension); + abort_if(! $definition instanceof ExtensionSettingsDefinition, Response::HTTP_NOT_FOUND, "Extension \"{$extension}\" has not registered settings (it may be disabled)."); + abort_unless($definition->fileField($input) instanceof ExtensionSettingDefinition, Response::HTTP_NOT_FOUND, "Setting \"{$input}\" is not a file setting."); + + return new JsonResponse(['data' => ['registered' => true, 'schema' => $files->replace($definition, $input, $request->upload())]]); + } + + #[Endpoint('Clear extension setting file', 'Deletes the file stored for a file setting, which returns the setting to its default.')] + #[ScribeResponse(self::SETTINGS_EXAMPLE, description: 'File removed; fresh schema returned.')] + public function clearSettingFile(UpdateExtensionRequest $request, ReplacesExtensionSettingFiles $files, ExtensionSettingsRegistry $settingsRegistry, string $extension, string $input): JsonResponse + { + $definition = $settingsRegistry->get($extension); + abort_if(! $definition instanceof ExtensionSettingsDefinition, Response::HTTP_NOT_FOUND, "Extension \"{$extension}\" has not registered settings (it may be disabled)."); + abort_unless($definition->fileField($input) instanceof ExtensionSettingDefinition, Response::HTTP_NOT_FOUND, "Setting \"{$input}\" is not a file setting."); + + return new JsonResponse(['data' => ['registered' => true, 'schema' => $files->replace($definition, $input, null)]]); + } + + #[Endpoint('Enable extension', 'Enables an installed extension, publishes assets, and runs migrations.')] + #[ScribeResponse(['data' => self::EXTENSION_EXAMPLE], description: 'Extension enabled.')] + public function enable( + UpdateExtensionRequest $request, + SetsExtensionEnabled $installer, + ExtensionRepository $extensions, + ExtensionAssetPublisher $assets, + string $extension, + ): JsonResponse { + $installer->setEnabled($extension, true); + + return new JsonResponse(['data' => $this->serializeInstalled($extension, $extensions, $assets)]); + } + + #[Endpoint('Disable extension', 'Disables an installed extension without removing files or data.')] + #[ScribeResponse(['data' => self::EXTENSION_EXAMPLE], description: 'Extension disabled.')] + public function disable( + UpdateExtensionRequest $request, + SetsExtensionEnabled $installer, + ExtensionRepository $extensions, + ExtensionAssetPublisher $assets, + string $extension, + ): JsonResponse { + $installer->setEnabled($extension, false); + + return new JsonResponse(['data' => $this->serializeInstalled($extension, $extensions, $assets)]); + } + + #[Endpoint('Remove extension', 'Deletes extension files, published assets, and the install record.')] + #[ScribeResponse(status: 204, description: 'Extension removed.')] + public function destroy(DeleteExtensionRequest $request, RemovesExtensions $installer, string $extension): Response + { + $installer->remove($extension); + + return new Response('', Response::HTTP_NO_CONTENT); + } + + /** + * @return list> + */ + private function extensionList(ExtensionRepository $extensions, ExtensionAssetPublisher $assets): array + { + $records = $extensions->records(); + $extensionsList = $extensions->discovered() + ->map(fn (ExtensionManifest $manifest): array => $this->serializeManifest($manifest, $records->get($manifest->id), $assets)) + ->values(); + + foreach ($extensions->discoveryErrors() as $directory => $error) { + $extensionsList->push([ + 'id' => $directory, + 'name' => '(invalid manifest)', + 'version' => null, + 'api' => null, + 'description' => null, + 'author' => null, + 'provider' => null, + 'has_ui' => false, + 'ui_entry' => null, + 'ui_mode' => null, + 'frontend_entry' => null, + 'installed' => false, + 'enabled' => false, + 'compatible' => false, + 'state' => 'invalid', + 'error' => $error, + ]); + } + + return array_values($extensionsList->sortBy('id')->values()->all()); + } + + /** + * @return ApiPayload + */ + private function serializeInstalled(string $identifier, ExtensionRepository $extensions, ExtensionAssetPublisher $assets): array + { + $extensions->flushDiscovery(); + + $manifest = $extensions->discovered()->get($identifier); + abort_if($manifest === null, Response::HTTP_NOT_FOUND, "Extension \"{$identifier}\" is not installed."); + + return $this->serializeManifest($manifest, $extensions->records()->get($identifier), $assets); + } + + /** + * @return ApiPayload + */ + private function serializeManifest(ExtensionManifest $manifest, ?Extension $record, ExtensionAssetPublisher $assets): array + { + return [ + 'id' => $manifest->id, + 'name' => $manifest->name, + 'version' => $manifest->version, + 'description' => $manifest->description, + 'author' => $manifest->author, + 'provider' => $manifest->provider, + 'has_ui' => $manifest->hasUi(), + 'ui_entry' => $manifest->uiEntry, + 'ui_mode' => $manifest->uiMode, + 'frontend_entry' => $manifest->hasUi() ? $assets->entryUrl($manifest) : null, + 'installed' => $record instanceof Extension, + 'enabled' => (bool) ($record->enabled ?? false), + 'state' => $this->state($record), + 'error' => $record?->error, + ]; + } + + private function state(?Extension $record): string + { + return match (true) { + ! $record instanceof Extension => 'not_registered', + $record->error !== null => 'error', + $record->enabled => 'enabled', + default => 'disabled', + }; + } +} diff --git a/app/Http/Controllers/Api/Admin/LanguagesController.php b/app/Http/Controllers/Api/Admin/LanguagesController.php new file mode 100644 index 000000000..a30cd8e6d --- /dev/null +++ b/app/Http/Controllers/Api/Admin/LanguagesController.php @@ -0,0 +1,34 @@ + 'English', + ]; + + /** + * Return languages available for Panel locale selectors. + */ + #[Endpoint('List languages', 'Returns the languages available for panel locale selectors.')] + #[ScribeResponse(self::LANGUAGES_EXAMPLE, description: 'Available languages returned.')] + public function __invoke(GetLanguagesRequest $request): JsonResponse + { + return new JsonResponse($this->getAvailableLanguages(true)); + } +} diff --git a/app/Http/Controllers/Api/Admin/Locations/EligibleNodesController.php b/app/Http/Controllers/Api/Admin/Locations/EligibleNodesController.php new file mode 100644 index 000000000..3b7d78fab --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Locations/EligibleNodesController.php @@ -0,0 +1,35 @@ +nodes) + ->transformWith($this->getTransformer(NodeTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Locations/LocationController.php b/app/Http/Controllers/Api/Admin/Locations/LocationController.php new file mode 100644 index 000000000..f5334b667 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Locations/LocationController.php @@ -0,0 +1,144 @@ +allowedFilters(['short', 'long']) + ->allowedSorts(['id', 'short', 'created_at']); + + $locations = $query->getEloquentBuilder() + ->withCount(['nodes', 'servers']) + ->paginate($request->perPage()); + + return Fractal::collection($locations) + ->transformWith($this->getTransformer(LocationTransformer::class)) + ->toResponseArray(); + } + + /** + * Show location. + * + * @return ApiPayload + */ + #[Endpoint('Get location', 'Returns a single location by ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "nodes" and "servers".', required: false, example: 'nodes', enum: ['nodes', 'servers', 'nodes,servers'])] + #[ResponseFromTransformer(LocationTransformer::class, Location::class, description: 'Location returned.', resourceKey: 'location', include: ['nodes'])] + public function show(GetLocationRequest $request, Location $location): array + { + $location->loadCount(['nodes', 'servers']); + $location->load(['nodes' => function (HasMany $query): void { + $query->withCount('servers'); + }]); + + return Fractal::item($location) + ->transformWith($this->getTransformer(LocationTransformer::class)) + ->toResponseArray(); + } + + /** + * Create location. + */ + #[Endpoint('Create location', 'Creates a location for grouping nodes and servers.')] + #[ResponseFromTransformer(LocationTransformer::class, Location::class, status: 201, description: 'Location created.', resourceKey: 'location', meta: ['resource' => 'https://panel.example.com/api/admin/locations/1'])] + public function store(StoreLocationRequest $request, CreatesLocations $locations): JsonResponse + { + $location = $locations->create($request->payload()); + + Activity::event('admin:location.create') + ->subject($location) + ->property('short', $location->short) + ->log(); + + return Fractal::item($location) + ->transformWith($this->getTransformer(LocationTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.locations.view', [ + 'location' => $location->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update location. + * + * @return ApiPayload + */ + #[Endpoint('Update location', 'Updates a location short identifier and description.')] + #[ResponseFromTransformer(LocationTransformer::class, Location::class, description: 'Location updated.', resourceKey: 'location')] + public function update(UpdateLocationRequest $request, UpdatesLocations $locations, Location $location): array + { + $location = $locations->update($location, $request->payload()); + + Activity::event('admin:location.update') + ->subject($location) + ->property('short', $location->short) + ->log(); + + return Fractal::item($location) + ->transformWith($this->getTransformer(LocationTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete location. + */ + #[Endpoint('Delete location', 'Deletes a location when no dependent resources prevent removal.')] + #[ScribeResponse(status: 204, description: 'Location deleted.')] + public function destroy(DeleteLocationRequest $request, DeletesLocations $locations, Location $location): Response + { + $locations->delete($location); + + Activity::event('admin:location.delete') + ->subject($location) + ->property('short', $location->short) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Mounts/AttachEggsController.php b/app/Http/Controllers/Api/Admin/Mounts/AttachEggsController.php new file mode 100644 index 000000000..ba416d6e6 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Mounts/AttachEggsController.php @@ -0,0 +1,46 @@ +eggs(); + + $mount->eggs()->syncWithoutDetaching($eggs); + + Activity::event('admin:mount.attach-egg') + ->subject($mount) + ->property('eggs', $eggs) + ->log(); + + return Fractal::item($mount) + ->transformWith($this->getTransformer(MountTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Mounts/AttachNodesController.php b/app/Http/Controllers/Api/Admin/Mounts/AttachNodesController.php new file mode 100644 index 000000000..53410be51 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Mounts/AttachNodesController.php @@ -0,0 +1,46 @@ +nodes(); + + $mount->nodes()->syncWithoutDetaching($nodes); + + Activity::event('admin:mount.attach-node') + ->subject($mount) + ->property('nodes', $nodes) + ->log(); + + return Fractal::item($mount) + ->transformWith($this->getTransformer(MountTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Mounts/DetachEggController.php b/app/Http/Controllers/Api/Admin/Mounts/DetachEggController.php new file mode 100644 index 000000000..a7689ee1b --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Mounts/DetachEggController.php @@ -0,0 +1,38 @@ +eggs()->detach($egg->id); + + Activity::event('admin:mount.detach-egg') + ->subject($mount) + ->property('egg', $egg->id) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Mounts/DetachNodeController.php b/app/Http/Controllers/Api/Admin/Mounts/DetachNodeController.php new file mode 100644 index 000000000..06f544d01 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Mounts/DetachNodeController.php @@ -0,0 +1,38 @@ +nodes()->detach($node->id); + + Activity::event('admin:mount.detach-node') + ->subject($mount) + ->property('node', $node->id) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Mounts/MountController.php b/app/Http/Controllers/Api/Admin/Mounts/MountController.php new file mode 100644 index 000000000..36112811f --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Mounts/MountController.php @@ -0,0 +1,156 @@ + 'mount', + 'attributes' => [ + 'id' => 1, + 'uuid' => '1b19cf3f-2f89-4f88-a81e-321e7fe326bc', + 'name' => 'Shared Mods', + 'description' => 'Shared mod files for servers.', + 'source' => '/mnt/shared-mods', + 'target' => '/home/container/mods', + 'read_only' => true, + 'user_mountable' => false, + 'eggs_count' => 1, + 'nodes_count' => 1, + 'servers_count' => 0, + ], + ]; + + /** + * List mounts. + * + * @return ApiPayload + */ + #[Endpoint('List mounts', 'Returns a paginated list of mount definitions.')] + #[QueryParam('filter[name]', 'string', 'Filter mounts by name.', required: false, example: 'Shared Mods')] + #[QueryParam('sort', 'string', 'Sort mounts by id or name. Prefix with a hyphen for descending order.', required: false, example: 'name')] + #[QueryParam('page', 'integer', 'Page number to return.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "eggs", "nodes", and "servers".', required: false, example: 'eggs,nodes', enum: ['eggs', 'nodes', 'servers', 'eggs,nodes', 'eggs,nodes,servers'])] + #[ResponseFromTransformer(MountTransformer::class, Mount::class, description: 'Mounts returned.', collection: true, resourceKey: 'mount', paginate: [IlluminatePaginatorAdapter::class, 50])] + public function index(GetMountsRequest $request): array + { + $mounts = QueryBuilder::for(Mount::query()->withCount('eggs', 'nodes', 'servers')) + ->allowedFilters(['name']) + ->allowedSorts(['id', 'name']) + ->paginate($request->perPage()); + + return Fractal::collection($mounts) + ->transformWith($this->getTransformer(MountTransformer::class)) + ->toResponseArray(); + } + + /** + * Show mount. + * + * @return ApiPayload + */ + #[Endpoint('Get mount', 'Returns a single mount definition by ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "eggs", "nodes", and "servers".', required: false, example: 'eggs,nodes', enum: ['eggs', 'nodes', 'servers', 'eggs,nodes', 'eggs,nodes,servers'])] + #[ResponseFromTransformer(MountTransformer::class, Mount::class, description: 'Mount returned.', resourceKey: 'mount', include: ['eggs', 'nodes', 'servers'])] + public function show(GetMountRequest $request, Mount $mount): array + { + $mount->loadCount('eggs', 'nodes', 'servers'); + + return Fractal::item($mount) + ->transformWith($this->getTransformer(MountTransformer::class)) + ->toResponseArray(); + } + + /** + * Create mount. + */ + #[Endpoint('Create mount', 'Creates a mount definition and generates its UUID.')] + #[ResponseFromTransformer(MountTransformer::class, Mount::class, status: 201, description: 'Mount created.', resourceKey: 'mount', meta: ['resource' => 'https://panel.example.com/api/admin/mounts/1'])] + public function store(StoreMountRequest $request): JsonResponse + { + $mount = (new Mount)->fill($request->validated()); + $mount->forceFill(['uuid' => Uuid::uuid4()->toString()]); + $mount->saveOrFail(); + + Activity::event('admin:mount.create') + ->subject($mount) + ->property('name', $mount->name) + ->log(); + + return Fractal::item($mount) + ->transformWith($this->getTransformer(MountTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.mounts.view', [ + 'mount' => $mount->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update mount. + * + * @return ApiPayload + */ + #[Endpoint('Update mount', 'Updates an existing mount definition.')] + #[ResponseFromTransformer(MountTransformer::class, Mount::class, description: 'Mount updated.', resourceKey: 'mount')] + public function update(UpdateMountRequest $request, Mount $mount): array + { + $mount->forceFill($request->validated())->save(); + + Activity::event('admin:mount.update') + ->subject($mount) + ->property('name', $mount->name) + ->log(); + + return Fractal::item($mount) + ->transformWith($this->getTransformer(MountTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete mount. + */ + #[Endpoint('Delete mount', 'Deletes a mount definition.')] + #[ScribeResponse(status: 204, description: 'Mount deleted.')] + public function destroy(DeleteMountRequest $request, Mount $mount): Response + { + $name = $mount->name; + + $mount->delete(); + + Activity::event('admin:mount.delete') + ->subject($mount) + ->property('name', $name) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/AllocationController.php b/app/Http/Controllers/Api/Admin/Nodes/AllocationController.php new file mode 100644 index 000000000..999893df6 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/AllocationController.php @@ -0,0 +1,182 @@ + [ + [ + 'code' => 'ServerUsingAllocationException', + 'status' => '400', + 'detail' => 'This allocation is currently assigned to a server.', + ], + ], + ]; + + /** + * List allocations. + * + * @return ApiPayload + */ + #[Endpoint('List node allocations', 'Returns a paginated list of allocations for a node.')] + #[QueryParam('filter[ip]', 'string', 'Filter allocations by exact IP address.', required: false, example: '192.168.1.1')] + #[QueryParam('filter[port]', 'integer', 'Filter allocations by exact port.', required: false, example: 25565)] + #[QueryParam('filter[ip_alias]', 'string', 'Filter allocations by IP alias.', required: false, example: 'game.example.com')] + #[QueryParam('filter[server_id]', 'string', 'Filter allocations by server ID, or pass an empty value to return unassigned allocations.', required: false, example: '42')] + #[QueryParam('sort', 'string', 'Sort allocations by id, ip, or port. Prefix with a hyphen for descending order.', required: false, example: 'port')] + #[QueryParam('page', 'integer', 'Page number to return.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, description: 'Allocations returned.', collection: true, resourceKey: 'allocation', paginate: [IlluminatePaginatorAdapter::class, 50])] + public function index(GetAllocationsRequest $request, Node $node): array + { + // Eager-load the owning server so the transformer avoids an N+1 on server name. + $query = $node->allocations()->with('server'); + + // An empty filter[server_id] reaches us as null because of ConvertEmptyStringsToNull, + // and Spatie skips null filters entirely, so apply the unassigned case here. + $filters = $request->input('filter'); + if (is_array($filters) && array_key_exists('server_id', $filters) && $filters['server_id'] === null) { + $query->whereNull('server_id'); + } + + $allocations = QueryBuilder::for($query) + ->allowedFilters([ + AllowedFilter::exact('ip'), + AllowedFilter::exact('port'), + 'ip_alias', + AllowedFilter::callback('server_id', function (Builder $builder, $value) { // @pest-ignore-type + if (empty($value) || is_bool($value) || ! is_string($value) && ! is_int($value)) { + return $builder->whereNull('server_id'); + } + + // SAFETY: the boundary checks above limit the filter to an integer or string before decimal validation. + if (! ctype_digit((string) $value)) { + return $builder->whereNull('server_id'); + } + + return $builder->where('server_id', $value); + }), + ]) + ->allowedSorts(['id', 'ip', 'port']) + ->paginate($request->perPage()); + + return Fractal::collection($allocations) + ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->toResponseArray(); + } + + /** + * Create allocation. + */ + #[Endpoint('Create node allocations', 'Creates one or more allocations on a node from IP addresses and ports or port ranges.')] + #[ScribeResponse(status: 204, description: 'Allocations created.')] + public function store(StoreAllocationRequest $request, CreatesAllocations $allocations, Node $node): Response + { + $ips = JsonValueGuard::stringList($request->validated('ip')); + $ports = JsonValueGuard::integerStringList($request->validated('ports')); + $alias = JsonValueGuard::nullableString($request->validated('alias')); + + // The creation action handles one (CIDR-capable) IP at a time, so fan out per IP. + foreach ($ips as $ip) { + $allocations->create($node, [ + 'allocation_ip' => $ip, + 'allocation_ports' => $ports, + 'allocation_alias' => $alias, + ]); + } + + Activity::event('admin:node-allocation.create') + ->subject($node) + ->property('address', $ips) + ->property('ports', $ports) + ->log(); + + return $this->returnNoContent(); + } + + /** + * Update allocation. + * + * @return ApiPayload + */ + #[Endpoint('Update node allocation', 'Updates the alias for a single allocation on a node.')] + #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, description: 'Allocation updated.', resourceKey: 'allocation')] + public function update(UpdateAllocationRequest $request, UpdatesAllocations $allocations, Node $node, Allocation $allocation): array + { + $this->assertAllocationBelongsToNode($node, $allocation); + + $allocation = $allocations->update($allocation, JsonValueGuard::nullableString($request->validated('alias'))); + + Activity::event('admin:node-allocation.alias') + ->subject($allocation) + ->property('alias', $allocation->ip_alias) + ->log(); + + return Fractal::item($allocation) + ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete allocation. + */ + #[Endpoint('Delete node allocation', 'Deletes a single unassigned allocation from a node.')] + #[ScribeResponse(status: 204, description: 'Allocation deleted.')] + #[ScribeResponse(self::SERVER_USING_ALLOCATION_ERROR, status: 400, description: 'The allocation is currently assigned to a server.')] + public function destroy(DeleteAllocationRequest $request, DeletesAllocations $allocations, Node $node, Allocation $allocation): Response + { + $this->assertAllocationBelongsToNode($node, $allocation); + + $allocations->delete($allocation); + + Activity::event('admin:node-allocation.delete') + ->subject($allocation) + ->property('address', $allocation->ip) + ->property('port', $allocation->port) + ->log(); + + return $this->returnNoContent(); + } + + /** + * Ensure allocation belongs to node. + */ + private function assertAllocationBelongsToNode(Node $node, Allocation $allocation): void + { + if ($allocation->node_id !== $node->id) { + throw (new ModelNotFoundException)->setModel(Allocation::class); + } + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/AvailableAllocationsController.php b/app/Http/Controllers/Api/Admin/Nodes/AvailableAllocationsController.php new file mode 100644 index 000000000..84ce59871 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/AvailableAllocationsController.php @@ -0,0 +1,53 @@ +allocations()->whereNull('server_id')) + ->allowedFilters([ + AllowedFilter::exact('ip'), + AllowedFilter::exact('port'), + 'ip_alias', + ]) + ->allowedSorts(['id', 'ip', 'port']) + ->paginate($request->perPage()); + + return Fractal::collection($allocations) + ->transformWith($this->getTransformer(AllocationTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/BulkDeleteAllocationsController.php b/app/Http/Controllers/Api/Admin/Nodes/BulkDeleteAllocationsController.php new file mode 100644 index 000000000..8f7edf14d --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/BulkDeleteAllocationsController.php @@ -0,0 +1,46 @@ +allocations() + ->whereIn('id', $request->validated('ids', [])) + ->get(); + + foreach ($allocations as $allocation) { + $deletions->delete($allocation); + + Activity::event('admin:node-allocation.delete') + ->subject($allocation) + ->property('address', $allocation->ip) + ->property('port', $allocation->port) + ->log(); + } + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/ConfigurationController.php b/app/Http/Controllers/Api/Admin/Nodes/ConfigurationController.php new file mode 100644 index 000000000..0e80c26af --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/ConfigurationController.php @@ -0,0 +1,54 @@ + false, + 'uuid' => '1b19cf3f-2f89-4f88-a81e-321e7fe326bc', + 'token_id' => 'abcd1234', + 'token' => 'secret', + 'api' => [ + 'host' => '0.0.0.0', + 'port' => 8080, + 'ssl' => [ + 'enabled' => true, + 'cert' => '/etc/letsencrypt/live/node.example.com/fullchain.pem', + 'key' => '/etc/letsencrypt/live/node.example.com/privkey.pem', + ], + 'upload_limit' => 100, + ], + 'system' => [ + 'data' => '/var/lib/pterodactyl/volumes', + 'sftp' => [ + 'bind_port' => 2022, + ], + ], + 'allowed_mounts' => ['/mnt/shared'], + 'remote' => 'https://panel.example.com', + ]; + + /** + * Return node configuration payload. + */ + #[Endpoint('Get node configuration', 'Returns the raw Wings configuration payload for a node, including daemon authentication tokens.')] + #[ScribeResponse(self::CONFIGURATION_EXAMPLE, description: 'Node configuration returned.')] + public function __invoke(GetNodeRequest $request, Node $node): JsonResponse + { + return new JsonResponse($node->getConfiguration()); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/DeleteAllocationBlockController.php b/app/Http/Controllers/Api/Admin/Nodes/DeleteAllocationBlockController.php new file mode 100644 index 000000000..8b6866de6 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/DeleteAllocationBlockController.php @@ -0,0 +1,39 @@ +validated('ip')); + $node->allocations()->unassigned()->where('ip', $ip)->delete(); + + Activity::event('admin:node-allocation.delete-block') + ->subject($node) + ->property('address', $ip) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/DeployTokenController.php b/app/Http/Controllers/Api/Admin/Nodes/DeployTokenController.php new file mode 100644 index 000000000..fcbda8a3e --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/DeployTokenController.php @@ -0,0 +1,71 @@ + 1, + 'token' => 'ptla_1234567890abcdef', + 'panel_url' => 'https://panel.example.com', + 'allow_insecure' => false, + ]; + + /** + * Create node deployment token. + */ + #[Endpoint('Create node deploy token', 'Creates or reuses an application API key that can deploy the specified node.')] + #[ScribeResponse(self::DEPLOY_TOKEN_EXAMPLE, description: 'Deploy token returned.')] + public function __invoke(DeployTokenRequest $request, CreatesApiKeys $keyCreator, Encrypter $encrypter, Node $node): JsonResponse + { + $permissions = []; + foreach (AdminAcl::getResourceList() as $resource) { + $permissions[AdminAcl::COLUMN_IDENTIFIER.$resource] = $resource === AdminAcl::RESOURCE_NODES ? AdminAcl::READ | AdminAcl::WRITE : AdminAcl::NONE; + } + + $key = ApiKey::query() + ->where('user_id', $request->user()->id) + ->where('key_type', ApiKey::TYPE_APPLICATION) + ->where($permissions) + ->first(); + + if (! $key) { + $key = $keyCreator->create(ApiKey::TYPE_APPLICATION, [ + 'user_id' => $request->user()->id, + 'memo' => 'Automatically generated node deployment key.', + 'allowed_ips' => [], + ], $permissions); + } + + Activity::event('admin:node.deploy-token') + ->subject($node) + ->property('name', $node->name) + ->log(); + + return new JsonResponse([ + 'node' => $node->id, + 'token' => $key->identifier.JsonValueGuard::string($encrypter->decrypt($key->token)), + 'panel_url' => config('app.url'), + 'allow_insecure' => config('app.debug'), + ]); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/NodeController.php b/app/Http/Controllers/Api/Admin/Nodes/NodeController.php new file mode 100644 index 000000000..5e208a939 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/NodeController.php @@ -0,0 +1,156 @@ + [ + [ + 'code' => 'HasActiveServersException', + 'status' => '400', + 'detail' => 'This node has active servers and cannot be deleted.', + ], + ], + ]; + + /** + * List nodes. + * + * @return ApiPayload + */ + #[Endpoint('List nodes', 'Returns a paginated list of Wings nodes.')] + #[QueryParam('filter[uuid]', 'string', 'Filter nodes by UUID.', required: false, example: '1b19cf3f-2f89-4f88-a81e-321e7fe326bc')] + #[QueryParam('filter[name]', 'string', 'Filter nodes by name.', required: false, example: 'node-1')] + #[QueryParam('filter[fqdn]', 'string', 'Filter nodes by FQDN.', required: false, example: 'node.example.com')] + #[QueryParam('sort', 'string', 'Sort nodes by id, uuid, name, memory, disk, or creation time. Prefix with a hyphen for descending order.', required: false, example: '-created_at')] + #[QueryParam('page', 'integer', 'Page number to return.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".', required: false, example: 'location', enum: ['allocations', 'location', 'servers', 'allocations,location', 'location,servers'])] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, description: 'Nodes returned.', collection: true, factoryStates: ['withLocation'], resourceKey: 'node', paginate: [IlluminatePaginatorAdapter::class, 50], withCount: ['servers'])] + public function index(GetNodesRequest $request): array + { + $nodes = QueryBuilder::for(Node::query()->with('location')->withCount('servers')) + ->allowedFilters(['uuid', 'name', 'fqdn']) + ->allowedSorts(['id', 'uuid', 'name', 'memory', 'disk', 'created_at']) + ->paginate($request->perPage()); + + return Fractal::collection($nodes) + ->transformWith($this->getTransformer(NodeTransformer::class)) + ->toResponseArray(); + } + + /** + * Show node. + * + * @return ApiPayload + */ + #[Endpoint('Get node', 'Returns a single Wings node by ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".', required: false, example: 'location', enum: ['allocations', 'location', 'servers', 'allocations,location', 'location,servers'])] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, description: 'Node returned.', factoryStates: ['withLocation'], resourceKey: 'node', include: ['location'], withCount: ['servers'])] + public function show(GetNodeRequest $request, Node $node): array + { + $node->loadCount('servers'); + + return Fractal::item($node) + ->transformWith($this->getTransformer(NodeTransformer::class)) + ->toResponseArray(); + } + + /** + * Create node. + */ + #[Endpoint('Create node', 'Creates a Wings node. HTTPS nodes must use a valid FQDN rather than a raw IP address.')] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, status: 201, description: 'Node created.', factoryStates: ['withLocation'], resourceKey: 'node', meta: ['resource' => 'https://panel.example.com/api/admin/nodes/1'], withCount: ['servers'])] + public function store(StoreNodeRequest $request, CreatesNodes $nodes): JsonResponse + { + $node = $nodes->create($request->payload()); + + Activity::event('admin:node.create') + ->subject($node) + ->property('name', $node->name) + ->log(); + + return Fractal::item($node) + ->transformWith($this->getTransformer(NodeTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.nodes.view', [ + 'node' => $node->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update node. + * + * @return ApiPayload + */ + #[Endpoint('Update node', 'Updates a Wings node and optionally rotates its daemon secret.')] + #[BodyParam('reset_secret', 'boolean', 'Whether to rotate the daemon secret.', required: false, example: false)] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, description: 'Node updated.', factoryStates: ['withLocation'], resourceKey: 'node', withCount: ['servers'])] + public function update(UpdateNodeRequest $request, UpdatesNodes $nodes, Node $node): array + { + $node = $nodes->update( + $node, + $request->payload(), + $request->boolean('reset_secret') + ); + + Activity::event('admin:node.update') + ->subject($node) + ->property('name', $node->name) + ->log(); + + return Fractal::item($node) + ->transformWith($this->getTransformer(NodeTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete node. + */ + #[Endpoint('Delete node', 'Deletes a node when it has no active servers.')] + #[ScribeResponse(status: 204, description: 'Node deleted.')] + #[ScribeResponse(self::HAS_SERVERS_ERROR, status: 400, description: 'The node has active servers.')] + public function destroy(DeleteNodeRequest $request, DeletesNodes $nodes, Node $node): Response + { + $nodes->delete($node); + + Activity::event('admin:node.delete') + ->subject($node) + ->property('name', $node->name) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/SystemInformationController.php b/app/Http/Controllers/Api/Admin/Nodes/SystemInformationController.php new file mode 100644 index 000000000..b3b53be02 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/SystemInformationController.php @@ -0,0 +1,48 @@ + 'amd64', + 'cpu_count' => 8, + 'kernel_version' => '6.8.0', + 'os' => 'linux', + 'version' => '1.11.0', + ]; + + private const array DAEMON_ERROR = [ + 'errors' => [ + [ + 'code' => 'DaemonConnectionException', + 'detail' => 'Could not connect to the daemon.', + ], + ], + ]; + + /** + * Return node system information. + */ + #[Endpoint('Get node system information', 'Proxies Wings system information for a node.')] + #[ScribeResponse(self::SYSTEM_INFORMATION_EXAMPLE, description: 'System information returned.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'The panel could not connect to Wings.')] + public function __invoke(GetSystemInformationRequest $request, Node $node): JsonResponse + { + return new JsonResponse(Daemon::node($node)->systemInformation()); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/UniqueIpsController.php b/app/Http/Controllers/Api/Admin/Nodes/UniqueIpsController.php new file mode 100644 index 000000000..bc7a99f2c --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/UniqueIpsController.php @@ -0,0 +1,42 @@ + [ + '10.0.0.8', + '10.0.0.9', + ], + ]; + + /** + * Return distinct allocation IPs for node. + */ + #[Endpoint('List node allocation IPs', 'Returns distinct allocation IP addresses for a node.')] + #[ScribeResponse(self::IPS_EXAMPLE, description: 'Allocation IPs returned.')] + public function __invoke(GetAllocationsRequest $request, Node $node): JsonResponse + { + $ips = $node->allocations() + ->select('ip') + ->distinct() + ->orderBy('ip') + ->pluck('ip'); + + return new JsonResponse(['data' => $ips]); + } +} diff --git a/app/Http/Controllers/Api/Admin/Nodes/UtilizationController.php b/app/Http/Controllers/Api/Admin/Nodes/UtilizationController.php new file mode 100644 index 000000000..9f8376849 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Nodes/UtilizationController.php @@ -0,0 +1,44 @@ + [ + 'value' => '1,024', + 'max' => '102,400', + 'percent' => 1.0, + 'css' => 'green', + ], + 'memory' => [ + 'value' => '512', + 'max' => '32,768', + 'percent' => 1.5625, + 'css' => 'green', + ], + ]; + + /** + * Return node resource utilization. + */ + #[Endpoint('Get node utilization', 'Returns aggregate resource utilization for a node.')] + #[ScribeResponse(self::UTILIZATION_EXAMPLE, description: 'Utilization returned.')] + public function __invoke(GetUtilizationRequest $request, Node $node): JsonResponse + { + return new JsonResponse($node->utilization()); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/BuildController.php b/app/Http/Controllers/Api/Admin/Servers/BuildController.php new file mode 100644 index 000000000..e4aa22859 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/BuildController.php @@ -0,0 +1,43 @@ +update($server, $request->payload()); + + Activity::event('admin:server.build') + ->subject($server) + ->property('name', $server->name) + ->log(); + + return Fractal::item($server) + ->transformWith($this->getTransformer(ServerTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/DatabaseController.php b/app/Http/Controllers/Api/Admin/Servers/DatabaseController.php new file mode 100644 index 000000000..d824005f5 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/DatabaseController.php @@ -0,0 +1,152 @@ + [ + [ + 'code' => 'HttpException', + 'status' => '403', + 'detail' => 'Access to this resource is not allowed due to the current installation state.', + ], + ], + ]; + + /** + * List server databases. + * + * @return ApiPayload + */ + #[Endpoint('List server databases', 'Returns all databases assigned to a server.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "password".', required: false, example: 'password', enum: ['password'])] + #[ResponseFromTransformer(ServerDatabaseTransformer::class, Database::class, description: 'Server databases returned.', collection: true, resourceKey: 'server_database')] + #[ScribeResponse(self::INSTALL_STATE_ERROR, status: 403, description: 'The server is not installed.')] + public function index(GetDatabasesRequest $request, Server $server): array + { + $this->assertServerInstalled($server); + + return Fractal::collection($server->databases) + ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) + ->toResponseArray(); + } + + /** + * Show server database. + * + * @return ApiPayload + */ + #[Endpoint('Get server database', 'Returns a single database assigned to a server.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "password".', required: false, example: 'password', enum: ['password'])] + #[ResponseFromTransformer(ServerDatabaseTransformer::class, Database::class, description: 'Server database returned.', resourceKey: 'server_database')] + #[ScribeResponse(self::INSTALL_STATE_ERROR, status: 403, description: 'The server is not installed.')] + public function show(GetDatabasesRequest $request, Server $server, Database $database): array + { + $this->assertServerInstalled($server); + $this->assertDatabaseBelongsToServer($server, $database); + + return Fractal::item($database) + ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) + ->toResponseArray(); + } + + /** + * Create server database. + */ + #[Endpoint('Create server database', 'Creates a database for a server and returns the generated password.')] + #[ResponseFromTransformer(ServerDatabaseTransformer::class, Database::class, status: 201, description: 'Server database created.', resourceKey: 'server_database', meta: ['resource' => 'https://panel.example.com/api/admin/servers/1/databases/Lk3jx4pQ'], include: ['password'])] + #[ScribeResponse(self::INSTALL_STATE_ERROR, status: 403, description: 'The server is not installed.')] + public function store(StoreDatabaseRequest $request, CreatesDatabases $createDatabase, Server $server): JsonResponse + { + $this->assertServerInstalled($server); + + $data = $request->payload(); + + $database = $createDatabase->create($server, [ + 'database_host_id' => $data['database_host_id'], + 'database' => DatabaseName::generateUnique($data['database'], $server->id), + 'remote' => $data['remote'], + 'max_connections' => $data['max_connections'] ?? null, + ]); + + Activity::event('admin:server-database.create') + ->subject($database) + ->property('name', $database->database) + ->log(); + + return Fractal::item($database) + ->parseIncludes(['password']) + ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.servers.databases.view', [ + 'server' => $server->id, + 'database' => $database->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Delete server database. + */ + #[Endpoint('Delete server database', 'Deletes a database assigned to a server.')] + #[ScribeResponse(status: 204, description: 'Server database deleted.')] + #[ScribeResponse(self::INSTALL_STATE_ERROR, status: 403, description: 'The server is not installed.')] + public function destroy(ServerDatabaseWriteRequest $request, DeletesDatabases $deleteDatabase, Server $server, Database $database): Response + { + $this->assertServerInstalled($server); + $this->assertDatabaseBelongsToServer($server, $database); + + $deleteDatabase->delete($database); + + Activity::event('admin:server-database.delete') + ->subject($database) + ->property('name', $database->database) + ->log(); + + return $this->returnNoContent(); + } + + /** + * Ensure database belongs to server. + */ + private function assertDatabaseBelongsToServer(Server $server, Database $database): void + { + if ($database->server_id !== $server->id) { + throw (new ModelNotFoundException)->setModel(Database::class); + } + } + + private function assertServerInstalled(Server $server): void + { + throw_unless($server->isInstalled(), HttpException::class, Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.'); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/DetailsController.php b/app/Http/Controllers/Api/Admin/Servers/DetailsController.php new file mode 100644 index 000000000..4e5054026 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/DetailsController.php @@ -0,0 +1,46 @@ +update( + $server, + $request->payload() + ); + + Activity::event('admin:server.details') + ->subject($updated) + ->property('name', $updated->name) + ->log(); + + return Fractal::item($updated) + ->transformWith($this->getTransformer(ServerTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/ExternalController.php b/app/Http/Controllers/Api/Admin/Servers/ExternalController.php new file mode 100644 index 000000000..171ecc23d --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/ExternalController.php @@ -0,0 +1,37 @@ +byExternalId($external_id); + + return Fractal::item($server) + ->transformWith($this->getTransformer(ServerTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/RebuildController.php b/app/Http/Controllers/Api/Admin/Servers/RebuildController.php new file mode 100644 index 000000000..ae4850198 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/RebuildController.php @@ -0,0 +1,38 @@ +rebuild($server); + + Activity::event('admin:server.rebuild') + ->subject($server) + ->property('name', $server->name) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/ReinstallController.php b/app/Http/Controllers/Api/Admin/Servers/ReinstallController.php new file mode 100644 index 000000000..c8651a089 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/ReinstallController.php @@ -0,0 +1,39 @@ +reinstall($server); + + Activity::event('admin:server.reinstall') + ->subject($server) + ->property('name', $server->name) + ->log(); + + return new JsonResponse([], Response::HTTP_ACCEPTED); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/RotateDatabasePasswordController.php b/app/Http/Controllers/Api/Admin/Servers/RotateDatabasePasswordController.php new file mode 100644 index 000000000..3a35add0a --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/RotateDatabasePasswordController.php @@ -0,0 +1,48 @@ +server_id !== $server->id) { + throw (new ModelNotFoundException)->setModel(Database::class); + } + + Activity::event('admin:server-database.rotate-password') + ->subject($database) + ->property('name', $database->database) + ->transaction(fn (): string => $passwordService->rotate($database)); + + return Fractal::item($database->refresh()) + ->parseIncludes(['password']) + ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/ServerBackupController.php b/app/Http/Controllers/Api/Admin/Servers/ServerBackupController.php new file mode 100644 index 000000000..a0a00d205 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/ServerBackupController.php @@ -0,0 +1,47 @@ +backups()) + ->allowedFilters(['uuid', 'name']) + ->allowedSorts(['id', 'bytes', 'created_at']) + ->paginate($request->perPage(25)); + + return Fractal::collection($backups) + ->transformWith($this->getTransformer(BackupTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/ServerController.php b/app/Http/Controllers/Api/Admin/Servers/ServerController.php new file mode 100644 index 000000000..e6a73e31f --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/ServerController.php @@ -0,0 +1,314 @@ + 'server', + 'attributes' => [ + 'id' => 1, + 'external_id' => 'remote-123', + 'uuid' => '1b19cf3f-2f89-4f88-a81e-321e7fe326bc', + 'identifier' => '1b19cf3f', + 'name' => 'Survival', + 'description' => 'Minecraft survival server', + 'status' => null, + 'suspended' => false, + 'limits' => [ + 'memory' => 2048, + 'swap' => 0, + 'disk' => 10240, + 'io' => 500, + 'cpu' => 100, + 'threads' => null, + 'oom_disabled' => false, + ], + 'feature_limits' => [ + 'databases' => 1, + 'allocations' => 1, + 'backups' => 1, + ], + 'user' => 1, + 'node' => 1, + 'allocation' => 1, + 'egg' => 1, + 'container' => [ + 'startup_command' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar server.jar', + 'image' => 'ghcr.io/pterodactyl/yolks:java_21', + 'skip_scripts' => false, + 'installed' => 1, + 'environment' => [ + 'SERVER_JARFILE' => 'server.jar', + ], + ], + 'updated_at' => '2026-01-01T00:00:00+00:00', + 'created_at' => '2026-01-01T00:00:00+00:00', + 'relationships' => [ + 'allocation' => [ + 'object' => 'allocation', + 'attributes' => [ + 'id' => 1, + 'ip' => '192.0.2.10', + 'alias' => null, + 'port' => 25565, + 'notes' => null, + 'assigned' => true, + ], + ], + 'allocations' => [ + 'object' => 'list', + 'data' => [ + [ + 'object' => 'allocation', + 'attributes' => [ + 'id' => 1, + 'ip' => '192.0.2.10', + 'alias' => null, + 'port' => 25565, + 'notes' => null, + 'assigned' => true, + ], + ], + ], + ], + 'user' => [ + 'object' => 'user', + 'attributes' => [ + 'id' => 1, + 'external_id' => null, + 'uuid' => '4de5a357-ed3f-4d7b-bc2c-664b74cd714d', + 'username' => 'admin', + 'email' => 'admin@example.com', + 'first_name' => 'Admin', + 'last_name' => 'User', + 'language' => 'en', + 'root_admin' => true, + '2fa' => true, + 'image' => 'https://www.gravatar.com/avatar/example', + 'servers_count' => 1, + 'subuser_of_count' => 0, + 'created_at' => '2026-01-01T00:00:00+00:00', + 'updated_at' => '2026-01-01T00:00:00+00:00', + ], + ], + 'node' => [ + 'object' => 'node', + 'attributes' => [ + 'id' => 1, + 'uuid' => '1b19cf3f-2f89-4f88-a81e-321e7fe326bc', + 'public' => true, + 'name' => 'Node 1', + 'description' => 'Primary node', + 'location_id' => 1, + 'fqdn' => 'node.example.com', + 'scheme' => 'https', + 'behind_proxy' => false, + 'maintenance_mode' => false, + 'memory' => 32768, + 'memory_overallocate' => 0, + 'disk' => 524288, + 'disk_overallocate' => 0, + 'upload_size' => 100, + 'daemon_listen' => 8080, + 'daemon_sftp' => 2022, + 'daemon_base' => '/var/lib/pterodactyl/volumes', + 'created_at' => '2026-01-01T00:00:00+00:00', + 'updated_at' => '2026-01-01T00:00:00+00:00', + ], + ], + 'egg' => [ + 'object' => 'egg', + 'attributes' => [ + 'id' => 1, + 'uuid' => '2a2dc402-ccaa-4f2d-b7bb-46b97b473c39', + 'author' => 'support@pterodactyl.io', + 'name' => 'Minecraft Java', + 'description' => 'Minecraft Java server', + 'features' => [], + 'docker_image' => 'ghcr.io/pterodactyl/yolks:java_21', + 'docker_images' => [ + 'Java 21' => 'ghcr.io/pterodactyl/yolks:java_21', + ], + 'force_outgoing_ip' => false, + 'config' => [ + 'files' => [], + 'startup' => ['done' => ['Done']], + 'stop' => 'stop', + 'logs' => ['custom' => false, 'location' => 'logs/latest.log'], + 'extends' => null, + ], + 'startup' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}', + 'script' => [ + 'privileged' => false, + 'install' => '#!/bin/ash', + 'entry' => 'ash', + 'container' => 'ghcr.io/pterodactyl/installers:alpine', + 'extends' => null, + ], + 'created_at' => '2026-01-01T00:00:00+00:00', + 'updated_at' => '2026-01-01T00:00:00+00:00', + ], + ], + 'variables' => [ + 'object' => 'list', + 'data' => [ + [ + 'object' => 'server_variable', + 'attributes' => [ + 'id' => 1, + 'egg_id' => 1, + 'name' => 'Server Jar File', + 'description' => 'The jar file to run.', + 'env_variable' => 'SERVER_JARFILE', + 'default_value' => 'server.jar', + 'server_value' => 'server.jar', + 'user_viewable' => true, + 'user_editable' => true, + 'rules' => 'required|string', + 'required' => true, + 'sort_order' => 1, + 'created_at' => '2026-01-01T00:00:00+00:00', + 'updated_at' => '2026-01-01T00:00:00+00:00', + ], + ], + ], + ], + ], + ], + ]; + + /** + * List servers. + * + * @return ApiPayload + */ + #[Endpoint('List servers', 'Returns a paginated list of servers.')] + #[QueryParam('filter[*]', 'string', 'Search servers by UUID, name, owner, node, allocation, or external identifier.', required: false, example: 'Survival')] + #[QueryParam('filter[uuid]', 'string', 'Filter servers by UUID.', required: false, example: '1b19cf3f-2f89-4f88-a81e-321e7fe326bc')] + #[QueryParam('filter[uuidShort]', 'string', 'Filter servers by short UUID identifier.', required: false, example: '1b19cf3f')] + #[QueryParam('filter[name]', 'string', 'Filter servers by name.', required: false, example: 'Survival')] + #[QueryParam('filter[external_id]', 'string', 'Filter servers by external identifier.', required: false, example: 'remote-123')] + #[QueryParam('filter[image]', 'string', 'Filter servers by Docker image.', required: false, example: 'ghcr.io/pterodactyl/yolks:java_21')] + #[QueryParam('filter[node_id]', 'integer', 'Filter servers by node ID.', required: false, example: 1)] + #[QueryParam('filter[owner_id]', 'integer', 'Filter servers by owner user ID.', required: false, example: 1)] + #[QueryParam('sort', 'string', 'Sort servers by id, uuid, name, or creation time. Prefix with a hyphen for descending order.', required: false, example: '-created_at')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports allocation, allocations, user, subusers, egg, variables, location, node, and databases.', required: false, example: 'user,node,allocation')] + #[QueryParam('page', 'integer', 'Page number to retrieve.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, description: 'Servers returned.', collection: true, factoryStates: ['withRelationships'], resourceKey: 'server', paginate: [IlluminatePaginatorAdapter::class, 50])] + public function index(GetServersRequest $request): array + { + $servers = QueryBuilder::for(Server::query()->with('allocation', 'node', 'user')) + ->allowedFilters([ + 'uuid', + 'uuidShort', + 'name', + 'external_id', + 'image', + 'node_id', + AllowedFilter::exact('owner_id'), + AllowedFilter::custom('*', new AdminServerFilter), + ]) + ->allowedSorts(['id', 'uuid', 'name', 'created_at']) + ->paginate($request->perPage()); + + return Fractal::collection($servers) + ->transformWith($this->getTransformer(ServerTransformer::class)) + ->toResponseArray(); + } + + /** + * Show server. + * + * @return ApiPayload + */ + #[Endpoint('Get server', 'Returns a single server by admin identifier.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports allocation, allocations, user, subusers, egg, variables, location, node, and databases.', required: false, example: 'allocations,user,node,egg,variables')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, description: 'Server returned.', factoryStates: ['withRelationships'], resourceKey: 'server', include: ['allocation', 'allocations', 'egg', 'node', 'user', 'variables'])] + public function show(GetServerRequest $request, Server $server): array + { + return Fractal::item($server) + ->transformWith($this->getTransformer(ServerTransformer::class)) + ->toResponseArray(); + } + + /** + * Create server. + */ + #[Endpoint('Create server', 'Creates a server using explicit allocations or automatic deployment constraints.')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, status: 201, description: 'Server created.', factoryStates: ['withRelationships'], resourceKey: 'server', meta: ['resource' => 'https://panel.example.com/api/admin/servers/1'])] + public function store(StoreServerRequest $request, CreatesServers $creation): JsonResponse + { + $server = $creation->create($request->payload(), $request->getDeploymentObject()); + + Activity::event('admin:server.create') + ->subject($server) + ->property('name', $server->name) + ->log(); + + return Fractal::item($server) + ->transformWith($this->getTransformer(ServerTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.servers.view', [ + 'server' => $server->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Delete server. + */ + #[Endpoint('Delete server', 'Deletes a server and returns an error if Wings or database host cleanup fails.')] + #[ScribeResponse(status: 204, description: 'Server deleted.')] + public function destroy(DeleteServerRequest $request, DeletesServers $deletion, Server $server, string $force = ''): Response + { + $deletion->withForce($force === 'force')->delete($server); + + Activity::event('admin:server.delete') + ->subject($server) + ->property('name', $server->name) + ->log(); + + return $this->returnNoContent(); + } + + /** + * Force delete server. + */ + #[Endpoint('Force delete server', 'Deletes a server while bypassing recoverable Wings or database host cleanup failures.')] + #[ScribeResponse(status: 204, description: 'Server force deleted.')] + public function forceDestroy(DeleteServerRequest $request, DeletesServers $deletion, Server $server): Response + { + return $this->destroy($request, $deletion, $server, 'force'); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/ServerMountController.php b/app/Http/Controllers/Api/Admin/Servers/ServerMountController.php new file mode 100644 index 000000000..3e3b7f5d6 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/ServerMountController.php @@ -0,0 +1,131 @@ + 'mount', + 'attributes' => [ + ...MountController::MOUNT_EXAMPLE['attributes'], + 'mounted' => true, + ], + ]; + + private const array SERVER_MOUNT_LIST_EXAMPLE = [ + 'object' => 'list', + 'data' => [ + self::SERVER_MOUNT_EXAMPLE, + ], + ]; + + private const array INSTALL_STATE_ERROR = [ + 'errors' => [ + [ + 'code' => 'HttpException', + 'status' => '403', + 'detail' => 'Access to this resource is not allowed due to the current installation state.', + ], + ], + ]; + + /** + * List server mounts. + * + * @return array{object: string, data: list}>} + */ + #[Endpoint('List server mounts', 'Returns mount definitions that are eligible for a server, including whether each mount is attached.')] + #[ScribeResponse(self::SERVER_MOUNT_LIST_EXAMPLE, description: 'Eligible server mounts returned.')] + #[ScribeResponse(self::INSTALL_STATE_ERROR, status: 403, description: 'The server is not installed.')] + public function index(GetServerMountsRequest $request, MountListService $listing, Server $server): array + { + $this->assertServerInstalled($server); + + $mounts = $listing->handle($server); + + $mountedIds = $server->mounts->pluck('id')->all(); + + $transformer = $this->getTransformer(MountTransformer::class); + + $data = array_values($mounts->map(fn (Mount $mount): array => array_merge($transformer->transform($mount), [ + 'mounted' => in_array($mount->id, $mountedIds, true), + ]))->all()); + + return [ + 'object' => 'list', + 'data' => array_map(fn (array $attributes): array => [ + 'object' => Mount::RESOURCE_NAME, + 'attributes' => $attributes, + ], $data), + ]; + } + + /** + * Create server mount. + */ + #[Endpoint('Attach server mount', 'Attaches an eligible mount definition to a server.')] + #[ScribeResponse(status: 204, description: 'Mount attached.')] + #[ScribeResponse(self::INSTALL_STATE_ERROR, status: 403, description: 'The server is not installed.')] + public function store(StoreServerMountRequest $request, AttachesMountsToServers $attach, Server $server): Response + { + $this->assertServerInstalled($server); + + $mount = $attach->attach($server, JsonValueGuard::integer($request->validated('mount_id'))); + + Activity::event('admin:server.mount') + ->subject($server, $mount) + ->property('name', $mount->name) + ->log(); + + return $this->returnNoContent(); + } + + /** + * Delete server mount. + */ + #[Endpoint('Detach server mount', 'Detaches a mount definition from a server.')] + #[ScribeResponse(status: 204, description: 'Mount detached.')] + #[ScribeResponse(self::INSTALL_STATE_ERROR, status: 403, description: 'The server is not installed.')] + public function destroy(DeleteServerMountRequest $request, DetachesMountsFromServers $detach, Server $server, Mount $mount): Response + { + $this->assertServerInstalled($server); + + $detach->detach($server, $mount); + + Activity::event('admin:server.unmount') + ->subject($server, $mount) + ->property('name', $mount->name) + ->log(); + + return $this->returnNoContent(); + } + + private function assertServerInstalled(Server $server): void + { + throw_unless($server->isInstalled(), HttpException::class, Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.'); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/StartupController.php b/app/Http/Controllers/Api/Admin/Servers/StartupController.php new file mode 100644 index 000000000..eeddcb564 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/StartupController.php @@ -0,0 +1,44 @@ +update($server, $request->payload(), User::USER_LEVEL_ADMIN); + + Activity::event('admin:server.startup') + ->subject($server) + ->property('name', $server->name) + ->log(); + + return Fractal::item($server) + ->transformWith($this->getTransformer(ServerTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/SuspensionController.php b/app/Http/Controllers/Api/Admin/Servers/SuspensionController.php new file mode 100644 index 000000000..0aa74f211 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/SuspensionController.php @@ -0,0 +1,43 @@ +boolean('suspended'); + + $suspension->toggle( + $server, + $suspended ? TogglesServerSuspension::ACTION_SUSPEND : TogglesServerSuspension::ACTION_UNSUSPEND + ); + + Activity::event($suspended ? 'admin:server.suspend' : 'admin:server.unsuspend') + ->subject($server) + ->property('name', $server->name) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/ToggleBackupController.php b/app/Http/Controllers/Api/Admin/Servers/ToggleBackupController.php new file mode 100644 index 000000000..0a703c425 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/ToggleBackupController.php @@ -0,0 +1,48 @@ +server_id !== $server->id) { + throw (new ModelNotFoundException)->setModel(Backup::class); + } + + $backup->update(['is_locked' => ! $backup->is_locked]); + + Activity::event('admin:server-backup.toggle-lock') + ->subject($backup) + ->property(['name' => $backup->name, 'locked' => $backup->is_locked]) + ->log(); + + return Fractal::item($backup) + ->transformWith($this->getTransformer(BackupTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/ToggleInstallController.php b/app/Http/Controllers/Api/Admin/Servers/ToggleInstallController.php new file mode 100644 index 000000000..905b3cfac --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/ToggleInstallController.php @@ -0,0 +1,56 @@ + [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'This server is marked as failed and cannot have its install state toggled.', + ], + ], + ]; + + /** + * Toggle server install state. + */ + #[Endpoint('Toggle server install state', 'Toggles a server between installed and installing states unless it is marked as failed.')] + #[ScribeResponse(status: 204, description: 'Server install state toggled.')] + #[ScribeResponse(self::INSTALL_FAILED_ERROR, status: 400, description: 'The server is marked as failed.')] + public function __invoke(ToggleInstallRequest $request, Server $server): Response + { + if ($server->status === Server::STATUS_INSTALL_FAILED) { + throw new DisplayException(trans('admin/server.exceptions.marked_as_failed')); + } + + $server->forceFill([ + 'status' => $server->isInstalled() ? Server::STATUS_INSTALLING : null, + ])->saveOrFail(); + + Activity::event('admin:server.toggle-install') + ->subject($server) + ->property('name', $server->name) + ->property('status', $server->status) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/TransferController.php b/app/Http/Controllers/Api/Admin/Servers/TransferController.php new file mode 100644 index 000000000..34980eec8 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/TransferController.php @@ -0,0 +1,58 @@ + [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'This server cannot be transferred to the selected node because the node does not have enough resources.', + ], + ], + ]; + + /** + * Start server transfer. + */ + #[Endpoint('Transfer server', 'Starts a server transfer to another node using the specified target allocations.')] + #[BodyParam('node_id', 'integer', 'The destination node ID.', required: true, example: 2)] + #[BodyParam('allocation_id', 'integer', 'The primary allocation ID on the destination node.', required: true, example: 10)] + #[BodyParam('allocation_additional', 'integer[]', 'Additional allocation IDs on the destination node.', required: false, example: [11, 12])] + #[ScribeResponse(status: 204, description: 'Server transfer started.')] + #[ScribeResponse(self::TRANSFER_NOT_VIABLE_ERROR, status: 400, description: 'The destination node cannot fit the server or the server cannot currently be transferred.')] + public function __invoke(TransferServerRequest $request, InitiatesTransfers $transfers, Server $server): Response + { + $data = $request->payload(); + $node = Node::query()->findOrFail($data['node_id']); + + $transfers->initiate($server, $node, $data['allocation_id'], $data['allocation_additional']); + + Activity::event('admin:server.transfer') + ->subject($server) + ->property('name', $server->name) + ->property('node_id', $node->id) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Servers/TransferProgressController.php b/app/Http/Controllers/Api/Admin/Servers/TransferProgressController.php new file mode 100644 index 000000000..2558bf4bf --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Servers/TransferProgressController.php @@ -0,0 +1,44 @@ +transfer; + + if (($transfer) === null) { + return $this->returnNoContent(); + } + + return Fractal::item($transfer) + ->transformWith($this->getTransformer(ServerTransferTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Settings/AdvancedController.php b/app/Http/Controllers/Api/Admin/Settings/AdvancedController.php new file mode 100644 index 000000000..5cbb899b3 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Settings/AdvancedController.php @@ -0,0 +1,37 @@ +normalize() as $key => $value) { + // SAFETY: settings are persisted in the environment store as strings; null retains its deletion semantics. + Setting::put('settings::'.$key, ($value) === null ? null : (string) $value); + } + + $kernel->call('queue:restart'); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Settings/GeneralController.php b/app/Http/Controllers/Api/Admin/Settings/GeneralController.php new file mode 100644 index 000000000..e9c4ce8fa --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Settings/GeneralController.php @@ -0,0 +1,37 @@ +normalize() as $key => $value) { + // SAFETY: settings are persisted in the environment store as strings. + Setting::put('settings::'.$key, (string) $value); + } + + $kernel->call('queue:restart'); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Settings/MailController.php b/app/Http/Controllers/Api/Admin/Settings/MailController.php new file mode 100644 index 000000000..28d92b125 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Settings/MailController.php @@ -0,0 +1,64 @@ + [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'This feature is only available if SMTP is the selected email driver for the Panel.', + ], + ], + ]; + + /** + * Update mail settings. + */ + #[Endpoint('Update mail settings', 'Updates SMTP mail settings and restarts queued workers so they reload configuration.')] + #[ScribeResponse(status: 204, description: 'Mail settings updated.')] + #[ScribeResponse(self::SMTP_DRIVER_ERROR, status: 400, description: 'The panel is not configured to use SMTP mail.')] + public function __invoke(UpdateMailSettingsRequest $request, Kernel $kernel, Encrypter $encrypter, ConfigRepository $config): Response + { + throw_if($config->get('mail.default') !== 'smtp', DisplayException::class, 'This feature is only available if SMTP is the selected email driver for the Panel.'); + + $values = $request->normalize(); + if (Arr::get($values, 'mail:mailers:smtp:password') === '!e') { + $values['mail:mailers:smtp:password'] = ''; + } + + foreach ($values as $key => $value) { + if (in_array($key, SettingsServiceProvider::getEncryptedKeys()) && ! empty($value)) { + $value = $encrypter->encrypt($value); + } + + // SAFETY: settings are persisted in the environment store as strings; null retains its deletion semantics. + Setting::put('settings::'.$key, ($value) === null ? null : (string) $value); + } + + $kernel->call('queue:restart'); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Settings/SettingsController.php b/app/Http/Controllers/Api/Admin/Settings/SettingsController.php new file mode 100644 index 000000000..5b5db4bd5 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Settings/SettingsController.php @@ -0,0 +1,94 @@ + [ + 'app:name' => 'Pterodactyl', + 'pterodactyl:auth:2fa_required' => 0, + 'app:locale' => 'en', + ], + 'mail' => [ + 'mail:default' => 'smtp', + 'mail:mailers:smtp:host' => 'mail.example.com', + 'mail:mailers:smtp:port' => 587, + 'mail:mailers:smtp:encryption' => 'tls', + 'mail:mailers:smtp:username' => 'panel@example.com', + 'mail:mailers:smtp:password' => '', + 'mail:from:address' => 'panel@example.com', + 'mail:from:name' => 'Pterodactyl', + ], + 'advanced' => [ + 'recaptcha:enabled' => false, + 'recaptcha:secret_key' => 'secret', + 'recaptcha:website_key' => 'website', + 'pterodactyl:guzzle:timeout' => 15, + 'pterodactyl:guzzle:connect_timeout' => 5, + 'pterodactyl:client_features:allocations:enabled' => false, + 'pterodactyl:client_features:allocations:range_start' => null, + 'pterodactyl:client_features:allocations:range_end' => null, + ], + 'meta' => [ + 'load_environment_only' => false, + 'show_recaptcha_warning' => false, + ], + ]; + + /** + * Return current panel settings. + */ + #[Endpoint('Get settings', 'Returns current general, mail, advanced, and metadata settings.')] + #[ScribeResponse(self::SETTINGS_EXAMPLE, description: 'Settings returned.')] + public function index(GetSettingsRequest $request, ConfigRepository $config): JsonResponse + { + return new JsonResponse([ + 'general' => [ + 'app:name' => $config->get('app.name'), + 'pterodactyl:auth:2fa_required' => JsonValueGuard::integer($config->get('pterodactyl.auth.2fa_required')), + 'app:locale' => $config->get('app.locale'), + ], + 'mail' => [ + 'mail:default' => $config->get('mail.default'), + 'mail:mailers:smtp:host' => $config->get('mail.mailers.smtp.host'), + 'mail:mailers:smtp:port' => JsonValueGuard::integer($config->get('mail.mailers.smtp.port')), + 'mail:mailers:smtp:encryption' => $config->get('mail.mailers.smtp.encryption'), + 'mail:mailers:smtp:username' => $config->get('mail.mailers.smtp.username'), + // Never return the SMTP password to the client. + 'mail:mailers:smtp:password' => '', + 'mail:from:address' => $config->get('mail.from.address'), + 'mail:from:name' => $config->get('mail.from.name'), + ], + 'advanced' => [ + 'recaptcha:enabled' => JsonValueGuard::boolean($config->get('recaptcha.enabled')), + 'recaptcha:secret_key' => $config->get('recaptcha.secret_key'), + 'recaptcha:website_key' => $config->get('recaptcha.website_key'), + 'pterodactyl:guzzle:timeout' => JsonValueGuard::integer($config->get('pterodactyl.guzzle.timeout')), + 'pterodactyl:guzzle:connect_timeout' => JsonValueGuard::integer($config->get('pterodactyl.guzzle.connect_timeout')), + 'pterodactyl:client_features:allocations:enabled' => JsonValueGuard::boolean($config->get('pterodactyl.client_features.allocations.enabled')), + 'pterodactyl:client_features:allocations:range_start' => $config->get('pterodactyl.client_features.allocations.range_start'), + 'pterodactyl:client_features:allocations:range_end' => $config->get('pterodactyl.client_features.allocations.range_end'), + ], + 'meta' => [ + 'load_environment_only' => JsonValueGuard::boolean($config->get('pterodactyl.load_environment_only', false)), + 'show_recaptcha_warning' => $config->get('recaptcha._shipped_secret_key') === $config->get('recaptcha.secret_key') + || $config->get('recaptcha._shipped_website_key') === $config->get('recaptcha.website_key'), + ], + ]); + } +} diff --git a/app/Http/Controllers/Api/Admin/Settings/TestMailController.php b/app/Http/Controllers/Api/Admin/Settings/TestMailController.php new file mode 100644 index 000000000..cd37572de --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Settings/TestMailController.php @@ -0,0 +1,50 @@ + [ + [ + 'code' => 'HttpException', + 'status' => '500', + 'detail' => 'Unable to send mail using the configured transport.', + ], + ], + ]; + + /** + * Send test mail message. + */ + #[Endpoint('Send test mail', 'Sends a test email to the authenticated administrator using the configured mail transport.')] + #[ScribeResponse(status: 204, description: 'Test mail queued.')] + #[ScribeResponse(self::MAIL_ERROR, status: 500, description: 'The configured mail transport failed to send the message.')] + public function __invoke(SendTestMailRequest $request): Response + { + try { + Notification::route('mail', $request->user()->email) + ->notify(new MailTested($request->user())); + } catch (Throwable $throwable) { + throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, $throwable->getMessage(), $throwable); + } + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Tags/TagController.php b/app/Http/Controllers/Api/Admin/Tags/TagController.php new file mode 100644 index 000000000..ead1313f2 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Tags/TagController.php @@ -0,0 +1,245 @@ + [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'Built-in game tags cannot be edited.', + ], + ], + ]; + + /** + * List tags. + * + * @return ApiPayload + */ + #[Endpoint('List tags', 'Returns a paginated list of tags.')] + #[QueryParam('filter[name]', 'string', 'Filter tags by name.', required: false, example: 'Minecraft')] + #[QueryParam('filter[slug]', 'string', 'Filter tags by slug.', required: false, example: 'minecraft')] + #[QueryParam('sort', 'string', 'Sort tags by id, name, or slug. Prefix with a hyphen for descending order.', required: false, example: 'name')] + #[QueryParam('page', 'integer', 'Page number to return.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "eggs" and "nodes".', required: false, example: 'eggs', enum: ['eggs', 'nodes', 'eggs,nodes'])] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, description: 'Tags returned.', collection: true, resourceKey: 'tag', paginate: [IlluminatePaginatorAdapter::class, 50])] + public function index(GetTagsRequest $request): array + { + $tags = QueryBuilder::for(Tag::query()->withCount('eggs', 'nodes')) + ->allowedFilters(['name', 'slug']) + ->allowedSorts(['id', 'name', 'slug']) + ->paginate($request->perPage()); + + return Fractal::collection($tags) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } + + /** + * Show tag. + * + * @return ApiPayload + */ + #[Endpoint('Get tag', 'Returns a single tag by ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "eggs" and "nodes".', required: false, example: 'eggs', enum: ['eggs', 'nodes', 'eggs,nodes'])] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, description: 'Tag returned.', resourceKey: 'tag')] + public function show(GetTagRequest $request, Tag $tag): array + { + $tag->loadCount('eggs', 'nodes'); + + return Fractal::item($tag) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } + + /** + * Create tag. + */ + #[Endpoint('Create tag', 'Creates a tag.')] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, status: 201, description: 'Tag created.', resourceKey: 'tag', meta: ['resource' => 'https://panel.example.com/api/admin/tags/1'])] + public function store(StoreTagRequest $request): JsonResponse + { + $tag = Tag::query()->create($request->validated()); + + Activity::event('admin:tag.create') + ->subject($tag) + ->property('slug', $tag->slug) + ->log(); + + return Fractal::item($tag) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.tags.view', [ + 'tag' => $tag->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update tag. + * + * + * @return ApiPayload + * + * @throws DisplayException + */ + #[Endpoint('Update tag', 'Updates an existing tag. Built-in game tags cannot be edited.')] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, description: 'Tag updated.', resourceKey: 'tag')] + #[ScribeResponse(self::BUILT_IN_ERROR, status: 400, description: 'The tag is a built-in game tag.')] + public function update(UpdateTagRequest $request, Tag $tag): array + { + $this->guardBuiltIn($tag); + + $tag->update($request->validated()); + + Activity::event('admin:tag.update') + ->subject($tag) + ->property('slug', $tag->slug) + ->log(); + + return Fractal::item($tag->refresh()) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete tag. + * + * Built-in game tags cannot be deleted because the cascading pivot cleanup would + * discard every egg and node assignment. Recreating the tag later cannot restore + * those associations. + * + * @throws DisplayException + */ + #[Endpoint('Delete tag', 'Deletes a tag and detaches it from every egg and node.')] + #[ScribeResponse(status: 204, description: 'Tag deleted.')] + #[ScribeResponse(self::BUILT_IN_ERROR, status: 400, description: 'The tag is a built-in game tag.')] + public function destroy(DeleteTagRequest $request, Tag $tag): Response + { + $this->guardBuiltIn($tag); + + $tag->delete(); + + Activity::event('admin:tag.delete') + ->subject($tag) + ->property('slug', $tag->slug) + ->log(); + + return $this->returnNoContent(); + } + + /** + * Replace the full set of tags on an egg. + * + * @return ApiPayload + */ + #[Endpoint('Sync egg tags', 'Replaces the tags applied to an egg. Values may be tag IDs or new tag names.')] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, description: 'Tags applied to the egg.', collection: true, resourceKey: 'tag')] + public function syncEgg(SyncTagsRequest $request, SyncsTags $sync, Egg $egg): array + { + $sync->syncEgg($egg, $request->tagValues()); + + Activity::event('admin:egg.tags') + ->subject($egg) + ->property('tags', JsonValueGuard::stringList($egg->tags()->pluck('slug')->all())) + ->log(); + + return Fractal::collection($egg->tags()->get()) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } + + /** + * Replace the games a node accepts (the 'egg'-kind attachments). A node's + * reservations are managed separately by syncNodeDeploymentTags(), and syncing + * one kind never disturbs the other. + * + * @return ApiPayload + */ + #[Endpoint('Sync node game tags', 'Replaces the games a node accepts. A node with no game tags accepts any egg.')] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, description: 'Games the node accepts.', collection: true, resourceKey: 'tag')] + public function syncNode(SyncTagsRequest $request, SyncsTags $sync, Node $node): array + { + $sync->syncNodeGames($node, $request->tagValues()); + + Activity::event('admin:node.tags') + ->subject($node) + ->property('tags', JsonValueGuard::stringList($node->eggTags()->pluck('slug')->all())) + ->log(); + + return Fractal::collection($node->eggTags()->get()) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } + + /** + * Replace the reservations on a node (the 'deployment'-kind attachments). A + * deploy only lands on this node when it declares exactly these tags. + * + * @return ApiPayload + */ + #[Endpoint('Sync node deployment tags', 'Replaces the reservations on a node. A deploy must declare exactly these tags to land here.')] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, description: 'Reservations on the node.', collection: true, resourceKey: 'tag')] + public function syncNodeDeploymentTags(SyncTagsRequest $request, SyncsTags $sync, Node $node): array + { + $sync->syncNodeDeployments($node, $request->tagValues()); + + Activity::event('admin:node.deployment-tags') + ->subject($node) + ->property('tags', JsonValueGuard::stringList($node->deploymentTags()->pluck('slug')->all())) + ->log(); + + return Fractal::collection($node->deploymentTags()->get()) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } + + /** + * Reject edits to a built-in game tag. Its slug is the key that feature gating + * matches on, and its presentation comes from the EggSpecificTags enum, so it + * must never be renamed or relabelled. + * + * @throws DisplayException + */ + private function guardBuiltIn(Tag $tag): void + { + throw_if(EggSpecificTags::isSpecial($tag->slug), DisplayException::class, 'Built-in game tags cannot be edited.'); + } +} diff --git a/app/Http/Controllers/Api/Admin/Users/DisableTwoFactorController.php b/app/Http/Controllers/Api/Admin/Users/DisableTwoFactorController.php new file mode 100644 index 000000000..a4cd96ab8 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Users/DisableTwoFactorController.php @@ -0,0 +1,41 @@ +forceFill([ + 'use_totp' => false, + 'totp_secret' => null, + 'totp_authenticated_at' => null, + ])->saveOrFail(); + + Activity::event('admin:user.disable-2fa') + ->subject($user) + ->property('email', $user->email) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Users/ExternalController.php b/app/Http/Controllers/Api/Admin/Users/ExternalController.php new file mode 100644 index 000000000..52d05d4d2 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Users/ExternalController.php @@ -0,0 +1,37 @@ +byExternalId($external_id); + + return Fractal::item($user) + ->transformWith($this->getTransformer(UserTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Admin/Users/UserController.php b/app/Http/Controllers/Api/Admin/Users/UserController.php new file mode 100644 index 000000000..efc8f0d51 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Users/UserController.php @@ -0,0 +1,181 @@ + [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'You cannot delete your own account.', + ], + ], + ]; + + /** + * List users. + * + * @return ApiPayload + */ + #[Endpoint('List users', 'Returns a paginated list of panel users, sorted with root administrators first by default.')] + #[QueryParam('page', 'integer', 'Page number to retrieve.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] + #[QueryParam('filter[email]', 'string', 'Filter users by email address.', required: false, example: 'admin@example.com')] + #[QueryParam('filter[uuid]', 'string', 'Filter users by UUID.', required: false, example: '1b19cf3f-2f89-4f88-a81e-321e7fe326bc')] + #[QueryParam('filter[username]', 'string', 'Filter users by username.', required: false, example: 'admin')] + #[QueryParam('filter[external_id]', 'string', 'Filter users by external identifier.', required: false, example: 'remote-123')] + #[QueryParam('filter[search]', 'string', 'Search users by username, email, or UUID.', required: false, example: 'admin')] + #[QueryParam('sort', 'string', 'Sort users by id, uuid, email, username, or creation date. Prefix with a hyphen for descending order.', required: false, example: '-created_at')] + #[ResponseFromTransformer(UserTransformer::class, User::class, description: 'Users returned.', collection: true, resourceKey: 'user', paginate: [IlluminatePaginatorAdapter::class, 50])] + public function index(GetUsersRequest $request): array + { + $users = QueryBuilder::for( + User::query() + ->select('users.*') + ->selectSub( + Subuser::query() + ->selectRaw('COUNT(*)') + ->whereColumn('subusers.user_id', 'users.id'), + 'subuser_of_count' + ) + ->withCount('servers') + ) + ->allowedFilters([ + 'email', + 'uuid', + 'username', + 'external_id', + AllowedFilter::callback('search', function (Builder $builder, string $value): void { + $builder->where(function (Builder $builder) use ($value): void { + $builder + ->where('users.username', 'LIKE', "%{$value}%") + ->orWhere('users.email', 'LIKE', "%{$value}%") + ->orWhere('users.uuid', 'LIKE', "%{$value}%"); + }); + }), + ]) + ->defaultSort('-root_admin') + ->allowedSorts(['id', 'uuid', 'email', 'username', 'created_at']) + ->paginate($request->perPage()); + + return Fractal::collection($users) + ->transformWith($this->getTransformer(UserTransformer::class)) + ->toResponseArray(); + } + + /** + * Show user. + * + * @return ApiPayload + */ + #[Endpoint('Get user', 'Returns a single panel user by internal numeric ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports servers.', required: false, example: 'servers')] + #[ResponseFromTransformer(UserTransformer::class, User::class, description: 'User returned.', resourceKey: 'user', include: ['servers'])] + public function show(GetUserRequest $request, User $user): array + { + return Fractal::item($user) + ->transformWith($this->getTransformer(UserTransformer::class)) + ->toResponseArray(); + } + + /** + * Create user. + */ + #[Endpoint('Create user', 'Creates a panel user. Optional password and language fields may be supplied explicitly.')] + #[ResponseFromTransformer(UserTransformer::class, User::class, status: 201, description: 'User created.', resourceKey: 'user', meta: ['resource' => 'https://panel.example.com/api/admin/users/1'])] + public function store(StoreUserRequest $request, CreatesUsers $users): JsonResponse + { + $user = $users->create($request->payload()); + + Activity::event('admin:user.create') + ->subject($user) + ->property('email', $user->email) + ->log(); + + return Fractal::item($user) + ->transformWith($this->getTransformer(UserTransformer::class)) + ->addMeta([ + 'resource' => route('api.admin.users.view', [ + 'user' => $user->id, + ]), + ]) + ->respond(Response::HTTP_CREATED); + } + + /** + * Update user. + * + * @return ApiPayload + */ + #[Endpoint('Update user', 'Updates an existing panel user. Supplying a password changes the user password.')] + #[ResponseFromTransformer(UserTransformer::class, User::class, description: 'User updated.', resourceKey: 'user')] + public function update(UpdateUserRequest $request, UpdatesUsers $users, User $user): array + { + $user = $users->update($user, $request->payload()); + + Activity::event('admin:user.update') + ->subject($user) + ->property('email', $user->email) + ->log(); + + return Fractal::item($user) + ->transformWith($this->getTransformer(UserTransformer::class)) + ->toResponseArray(); + } + + /** + * Delete user. + */ + #[Endpoint('Delete user', 'Deletes a panel user. The authenticated administrator cannot delete their own account.')] + #[ScribeResponse(status: 204, description: 'User deleted.')] + #[ScribeResponse(self::DELETE_SELF_ERROR, status: 400, description: 'The authenticated administrator attempted to delete their own user account.')] + public function destroy(DeleteUserRequest $request, DeletesUsers $users, User $user): Response + { + if ($request->user()->is($user)) { + throw new DisplayException(__('admin/user.exceptions.delete_self')); + } + + $users->delete($user); + + Activity::event('admin:user.delete') + ->subject($user) + ->property('email', $user->email) + ->log(); + + return $this->returnNoContent(); + } +} diff --git a/app/Http/Controllers/Api/Admin/VersionController.php b/app/Http/Controllers/Api/Admin/VersionController.php new file mode 100644 index 000000000..36174b4f3 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/VersionController.php @@ -0,0 +1,44 @@ + '1.0.0', + 'latest' => '1.0.0', + 'is_latest' => true, + 'daemon' => '1.0.0', + 'discord' => 'https://pterodactyl.io/discord', + 'donations' => 'https://github.com/sponsors/pterodactyl', + ]; + + /** + * Return panel and daemon version information. + */ + #[Endpoint('Get version information', 'Returns panel, Wings, and project version metadata.')] + #[ScribeResponse(self::VERSION_EXAMPLE, description: 'Version information returned.')] + public function __invoke(GetVersionRequest $request, SoftwareVersionService $version): JsonResponse + { + return new JsonResponse([ + 'current' => config('app.version'), + 'latest' => $version->getPanel(), + 'is_latest' => $version->isLatestPanel(), + 'daemon' => $version->getDaemon(), + 'discord' => $version->getDiscord(), + 'donations' => $version->getDonations(), + ]); + } +} diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index 4ffce692c..8aa86edb4 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -1,67 +1,50 @@ call([$this, 'loadDependencies']); - - // Parse all the includes to use on this request. - $input = $this->request->input('include', []); - $input = is_array($input) ? $input : explode(',', $input); - - $includes = (new Collection($input))->map(function ($value) { - return trim($value); - })->filter()->toArray(); - - $this->fractal->parseIncludes($includes); - $this->fractal->limitRecursion(2); - } - - /** - * Perform dependency injection of certain classes needed for core functionality - * without littering the constructors of classes that extend this abstract. - */ - public function loadDependencies(Fractal $fractal, Request $request) - { - $this->fractal = $fractal; - $this->request = $request; - } - /** * Return an instance of an application transformer. * * @template T of \Pterodactyl\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract - * + * @param class-string $abstract * @return T * * @noinspection PhpDocSignatureInspection */ - public function getTransformer(string $abstract) + public function getTransformer(string $abstract): BaseTransformer { - Assert::subclassOf($abstract, BaseTransformer::class); // @phpstan-ignore staticMethod.alreadyNarrowedType + return $this->makeTransformer($abstract, BaseTransformer::class); + } - return $abstract::fromRequest($this->request); + /** + * Resolve a transformer through the container, asserting it extends the API's base transformer. + * + * @template T of \Pterodactyl\Transformers\Api\Application\BaseTransformer + * + * @param class-string $abstract + * @param class-string $base + * @return T + */ + protected function makeTransformer(string $abstract, string $base): BaseTransformer + { + throw_unless(is_subclass_of($abstract, $base), InvalidArgumentException::class, "Transformer [$abstract] must extend ".$base.'.'); + + $transformer = App::make($abstract); + throw_unless($transformer instanceof $abstract, UnexpectedValueException::class, "The container did not resolve transformer [$abstract]."); + + return $transformer; } /** diff --git a/app/Http/Controllers/Api/Application/Eggs/EggController.php b/app/Http/Controllers/Api/Application/Eggs/EggController.php new file mode 100644 index 000000000..a224ce6a2 --- /dev/null +++ b/app/Http/Controllers/Api/Application/Eggs/EggController.php @@ -0,0 +1,67 @@ +allowedFilters([ + 'name', + AllowedFilter::exact('tag', 'tags.slug'), + ]) + ->allowedSorts(['id', 'name']) + ->paginate($request->perPage()); + + return Fractal::collection($eggs) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } + + /** + * Return a single egg. + * + * @return ApiPayload + */ + #[Endpoint('Get egg', 'Returns a single egg by internal numeric ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "servers", "config", "script", "variables", and "tags" when the key can read those resources.', required: false, example: 'variables', enum: ['servers', 'config', 'script', 'variables', 'tags'])] + #[ResponseFromTransformer(EggTransformer::class, Egg::class, resourceKey: 'egg')] + public function view(GetEggRequest $request, Egg $egg): array + { + return Fractal::item($egg) + ->transformWith($this->getTransformer(EggTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Application/Locations/LocationController.php b/app/Http/Controllers/Api/Application/Locations/LocationController.php index ae67d1390..c5d41e05b 100644 --- a/app/Http/Controllers/Api/Application/Locations/LocationController.php +++ b/app/Http/Controllers/Api/Application/Locations/LocationController.php @@ -1,71 +1,97 @@ [ + [ + 'code' => 'HasActiveNodesException', + 'status' => '400', + 'detail' => 'Cannot delete a location that has active nodes attached to it.', + ], + ], + ]; /** * Return all the locations currently registered on the Panel. + * + * @return ApiPayload */ + #[Endpoint('List locations', 'Returns a paginated list of all locations registered on the panel.')] + #[QueryParam('per_page', 'integer', 'Number of locations to return per page, up to 100.', required: false, example: 50)] + #[QueryParam('filter[short]', 'string', 'Filter locations by short identifier.', required: false, example: 'us-east')] + #[QueryParam('filter[long]', 'string', 'Filter locations by description.', required: false, example: 'US East Datacenter')] + #[QueryParam('sort', 'string', 'Sort locations by id. Prefix with "-" for descending order.', required: false, example: 'id', enum: ['id', '-id'])] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "nodes" and "servers" when the key can read those resources.', required: false, example: 'nodes,servers', enum: ['nodes', 'servers', 'nodes,servers'])] + #[ResponseFromTransformer(LocationTransformer::class, Location::class, collection: true, resourceKey: 'location', paginate: [IlluminatePaginatorAdapter::class, 50])] public function index(GetLocationsRequest $request): array { $locations = QueryBuilder::for(Location::query()) ->allowedFilters(['short', 'long']) ->allowedSorts(['id']) - ->paginate($request->query('per_page') ?? 50); + ->paginate($request->perPage()); - return $this->fractal->collection($locations) + return Fractal::collection($locations) ->transformWith($this->getTransformer(LocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Return a single location. + * + * @return ApiPayload */ + #[Endpoint('Get location', 'Returns a single location by internal numeric ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "nodes" and "servers" when the key can read those resources.', required: false, example: 'nodes,servers', enum: ['nodes', 'servers', 'nodes,servers'])] + #[ResponseFromTransformer(LocationTransformer::class, Location::class, resourceKey: 'location')] public function view(GetLocationRequest $request, Location $location): array { - return $this->fractal->item($location) + return Fractal::item($location) ->transformWith($this->getTransformer(LocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Store a new location on the Panel and return an HTTP/201 response code with the * new location attached. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function store(StoreLocationRequest $request): JsonResponse + #[Endpoint('Create location', 'Creates a new location and returns the created resource.')] + #[ResponseFromTransformer(LocationTransformer::class, Location::class, status: 201, description: 'Location created.', resourceKey: 'location', meta: ['resource' => 'https://panel.example.test/api/application/locations/1'])] + public function store(StoreLocationRequest $request, CreatesLocations $locations): JsonResponse { - $location = $this->creationService->handle($request->validated()); + $location = $locations->create($request->payload()); - return $this->fractal->item($location) + return Fractal::item($location) ->transformWith($this->getTransformer(LocationTransformer::class)) ->addMeta([ 'resource' => route('api.application.locations.view', [ @@ -78,26 +104,30 @@ class LocationController extends ApplicationApiController /** * Update a location on the Panel and return the updated record to the user. * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * @return ApiPayload */ - public function update(UpdateLocationRequest $request, Location $location): array + #[Endpoint('Update location', 'Updates an existing location by internal numeric ID.')] + #[ResponseFromTransformer(LocationTransformer::class, Location::class, resourceKey: 'location')] + public function update(UpdateLocationRequest $request, UpdatesLocations $locations, Location $location): array { - $location = $this->updateService->handle($location, $request->validated()); + $location = $locations->update($location, $request->payload()); - return $this->fractal->item($location) + return Fractal::item($location) ->transformWith($this->getTransformer(LocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Delete a location from the Panel. * - * @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException + * @throws HasActiveNodesException */ - public function delete(DeleteLocationRequest $request, Location $location): Response + #[Endpoint('Delete location', 'Deletes a location by internal numeric ID.')] + #[ScribeResponse(status: 204, description: 'Location deleted.')] + #[ScribeResponse(self::ACTIVE_NODES_ERROR, status: 400, description: 'The location has active nodes attached.')] + public function delete(DeleteLocationRequest $request, DeletesLocations $locations, Location $location): Response { - $this->deletionService->handle($location); + $locations->delete($location); return response('', 204); } diff --git a/app/Http/Controllers/Api/Application/Nests/EggController.php b/app/Http/Controllers/Api/Application/Nests/EggController.php deleted file mode 100644 index 83c3f77a0..000000000 --- a/app/Http/Controllers/Api/Application/Nests/EggController.php +++ /dev/null @@ -1,33 +0,0 @@ -fractal->collection($nest->eggs) - ->transformWith($this->getTransformer(EggTransformer::class)) - ->toArray(); - } - - /** - * Return a single egg that exists on the specified nest. - */ - public function view(GetEggRequest $request, Nest $nest, Egg $egg): array - { - return $this->fractal->item($egg) - ->transformWith($this->getTransformer(EggTransformer::class)) - ->toArray(); - } -} diff --git a/app/Http/Controllers/Api/Application/Nests/NestController.php b/app/Http/Controllers/Api/Application/Nests/NestController.php deleted file mode 100644 index f0044f53c..000000000 --- a/app/Http/Controllers/Api/Application/Nests/NestController.php +++ /dev/null @@ -1,42 +0,0 @@ -repository->paginated($request->query('per_page') ?? 50); - - return $this->fractal->collection($nests) - ->transformWith($this->getTransformer(NestTransformer::class)) - ->toArray(); - } - - /** - * Return information about a single Nest model. - */ - public function view(GetNestsRequest $request, Nest $nest): array - { - return $this->fractal->item($nest) - ->transformWith($this->getTransformer(NestTransformer::class)) - ->toArray(); - } -} diff --git a/app/Http/Controllers/Api/Application/Nodes/AllocationController.php b/app/Http/Controllers/Api/Application/Nodes/AllocationController.php index 07c201723..63d166ee5 100644 --- a/app/Http/Controllers/Api/Application/Nodes/AllocationController.php +++ b/app/Http/Controllers/Api/Application/Nodes/AllocationController.php @@ -1,70 +1,125 @@ [ + [ + 'code' => 'InvalidPortMappingException', + 'status' => '400', + 'detail' => 'The mapping provided for invalid was invalid and could not be processed.', + ], + ], + ]; + + private const array SERVER_USING_ALLOCATION_ERROR = [ + 'errors' => [ + [ + 'code' => 'ServerUsingAllocationException', + 'status' => '400', + 'detail' => 'A server is currently assigned to this allocation. An allocation can only be deleted if no server is currently assigned.', + ], + ], + ]; /** * Return all the allocations that exist for a given node. + * + * @return ApiPayload */ + #[Endpoint('List node allocations', 'Returns a paginated list of allocations belonging to a node.')] + #[QueryParam('per_page', 'integer', 'Number of allocations to return per page, up to 100.', required: false, example: 50)] + #[QueryParam('filter[ip]', 'string', 'Filter allocations by exact IP address.', required: false, example: '192.0.2.10')] + #[QueryParam('filter[port]', 'integer', 'Filter allocations by exact port.', required: false, example: 25565)] + #[QueryParam('filter[ip_alias]', 'string', 'Filter allocations by IP alias.', required: false, example: 'minecraft.example.com')] + #[QueryParam('filter[server_id]', 'string', 'Filter allocations by assigned server ID. Empty or non-numeric values return unassigned allocations.', required: false, example: '1')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "node" and "server" when the key can read those resources.', required: false, example: 'server', enum: ['node', 'server', 'node,server'])] + #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, collection: true, with: ['node.location'], resourceKey: 'allocation', paginate: [IlluminatePaginatorAdapter::class, 50])] public function index(GetAllocationsRequest $request, Node $node): array { - $allocations = QueryBuilder::for($node->allocations()) + $query = $node->allocations(); + + // An empty filter[server_id] reaches us as null because of ConvertEmptyStringsToNull, + // and Spatie skips null filters entirely, so apply the unassigned case here. + $filters = $request->input('filter'); + if (is_array($filters) && array_key_exists('server_id', $filters) && $filters['server_id'] === null) { + $query->whereNull('server_id'); + } + + $allocations = QueryBuilder::for($query) ->allowedFilters([ AllowedFilter::exact('ip'), AllowedFilter::exact('port'), 'ip_alias', - AllowedFilter::callback('server_id', function (Builder $builder, $value) { - if (empty($value) || is_bool($value) || !ctype_digit((string) $value)) { + AllowedFilter::callback('server_id', function (Builder $builder, $value) { // @pest-ignore-type + if (empty($value) || is_bool($value) || ! is_string($value) && ! is_int($value)) { + return $builder->whereNull('server_id'); + } + + // SAFETY: the boundary checks above limit the filter to an integer or string before decimal validation. + if (! ctype_digit((string) $value)) { return $builder->whereNull('server_id'); } return $builder->where('server_id', $value); }), ]) - ->paginate($request->query('per_page') ?? 50); + ->paginate($request->perPage()); - return $this->fractal->collection($allocations) + return Fractal::collection($allocations) ->transformWith($this->getTransformer(AllocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Store new allocations for a given node. * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException - * @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException - * @throws \Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException - * @throws \Pterodactyl\Exceptions\Service\Allocation\TooManyPortsInRangeException + * @throws DisplayException + * @throws CidrOutOfRangeException + * @throws InvalidPortMappingException + * @throws PortOutOfRangeException + * @throws TooManyPortsInRangeException */ - public function store(StoreAllocationRequest $request, Node $node): JsonResponse + #[Endpoint('Create node allocations', 'Assigns one or more allocation ports to a node.')] + #[ScribeResponse(status: 204, description: 'Allocations created.')] + #[ScribeResponse(self::ALLOCATION_REJECTED_ERROR, status: 400, description: 'The allocation IP, CIDR, or port mapping could not be processed.')] + public function store(StoreAllocationRequest $request, CreatesAllocations $allocations, Node $node): JsonResponse { - $this->assignmentService->handle($node, $request->validated()); + $allocations->create($node, $request->payload()); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } @@ -72,11 +127,14 @@ class AllocationController extends ApplicationApiController /** * Delete a specific allocation from the Panel. * - * @throws \Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException + * @throws ServerUsingAllocationException */ - public function delete(DeleteAllocationRequest $request, Node $node, Allocation $allocation): JsonResponse + #[Endpoint('Delete node allocation', 'Deletes an allocation from a node when no server is using it.')] + #[ScribeResponse(status: 204, description: 'Allocation deleted.')] + #[ScribeResponse(self::SERVER_USING_ALLOCATION_ERROR, status: 400, description: 'The allocation is currently assigned to a server.')] + public function delete(DeleteAllocationRequest $request, DeletesAllocations $allocations, Node $node, Allocation $allocation): JsonResponse { - $this->deletionService->handle($allocation); + $allocations->delete($allocation); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php index 2d812a89b..b0592eaed 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php @@ -1,20 +1,55 @@ false, + 'uuid' => '3d8dd7f9-07a1-4d65-8db0-8c8921f2f4f7', + 'token_id' => 'abcdefghijklmnop', + 'token' => 'example-node-token', + 'api' => [ + 'host' => '0.0.0.0', + 'port' => 8080, + 'ssl' => [ + 'enabled' => true, + 'cert' => '/etc/letsencrypt/live/node.example.com/fullchain.pem', + 'key' => '/etc/letsencrypt/live/node.example.com/privkey.pem', + ], + 'upload_limit' => 100, + ], + 'system' => [ + 'data' => '/var/lib/pterodactyl/volumes', + 'sftp' => [ + 'bind_port' => 2022, + ], + ], + 'allowed_mounts' => ['/mnt/shared'], + 'remote' => 'https://panel.example.test', + ]; + /** * Returns the configuration information for a node. This allows for automated deployments * to remote machines so long as an API key is provided to the machine to make the request * with, and the node is known. */ - public function __invoke(GetNodeRequest $request, Node $node): JsonResponse + #[Endpoint('Get node configuration', 'Returns the Wings configuration payload for a node, including node authentication tokens. Requires write access to nodes.')] + #[ScribeResponse(self::CONFIGURATION_EXAMPLE, status: 200, description: 'Node configuration.')] + public function __invoke(GetNodeConfigurationRequest $request, Node $node): JsonResponse { return new JsonResponse($node->getConfiguration()); } diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeController.php b/app/Http/Controllers/Api/Application/Nodes/NodeController.php index 5c40f77f6..6de751adf 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeController.php @@ -1,70 +1,111 @@ [ + [ + 'code' => 'HasActiveServersException', + 'status' => '400', + 'detail' => 'A node must have no servers linked to it in order to be deleted.', + ], + ], + ]; + + private const array CONFIGURATION_NOT_PERSISTED_ERROR = [ + 'errors' => [ + [ + 'code' => 'ConfigurationNotPersistedException', + 'status' => '400', + 'detail' => 'The daemon configuration has been updated, however there was an error encountered while attempting to automatically update the configuration file on the Daemon. You will need to manually update the configuration file (config.yml) for the daemon to apply these changes.', + ], + ], + ]; /** * Return all the nodes currently available on the Panel. + * + * @return ApiPayload */ + #[Endpoint('List nodes', 'Returns a paginated list of Wings nodes registered on the panel.')] + #[QueryParam('per_page', 'integer', 'Number of nodes to return per page, up to 100.', required: false, example: 50)] + #[QueryParam('filter[uuid]', 'string', 'Filter nodes by UUID.', required: false, example: '3d8dd7f9-07a1-4d65-8db0-8c8921f2f4f7')] + #[QueryParam('filter[name]', 'string', 'Filter nodes by name.', required: false, example: 'Node 1')] + #[QueryParam('filter[fqdn]', 'string', 'Filter nodes by fully qualified domain name.', required: false, example: 'node.example.com')] + #[QueryParam('filter[daemon_token_id]', 'string', 'Filter nodes by daemon token identifier.', required: false, example: 'abcdefghijklmnop')] + #[QueryParam('sort', 'string', 'Sort nodes by id, uuid, memory, or disk. Prefix with "-" for descending order.', required: false, example: '-id', enum: ['id', '-id', 'uuid', '-uuid', 'memory', '-memory', 'disk', '-disk'])] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.', required: false, example: 'location,allocations', enum: ['allocations', 'location', 'servers', 'location,allocations'])] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, collection: true, factoryStates: ['withLocation'], resourceKey: 'node', paginate: [IlluminatePaginatorAdapter::class, 50])] public function index(GetNodesRequest $request): array { - $nodes = QueryBuilder::for(Node::query()) + $nodes = QueryBuilder::for(Node::query() + ->withSum('servers as sum_memory', 'memory') + ->withSum('servers as sum_disk', 'disk')) ->allowedFilters(['uuid', 'name', 'fqdn', 'daemon_token_id']) ->allowedSorts(['id', 'uuid', 'memory', 'disk']) - ->paginate($request->query('per_page') ?? 50); + ->paginate($request->perPage()); - return $this->fractal->collection($nodes) + return Fractal::collection($nodes) ->transformWith($this->getTransformer(NodeTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Return data for a single instance of a node. + * + * @return ApiPayload */ + #[Endpoint('Get node', 'Returns a single Wings node by internal numeric ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.', required: false, example: 'location,allocations', enum: ['allocations', 'location', 'servers', 'location,allocations'])] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, factoryStates: ['withLocation'], resourceKey: 'node')] public function view(GetNodeRequest $request, Node $node): array { - return $this->fractal->item($node) + return Fractal::item($node) ->transformWith($this->getTransformer(NodeTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Create a new node on the Panel. Returns the created node and an HTTP/201 * status response on success. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function store(StoreNodeRequest $request): JsonResponse + #[Endpoint('Create node', 'Creates a new Wings node and returns the created resource.')] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, status: 201, description: 'Node created.', factoryStates: ['withLocation'], resourceKey: 'node', meta: ['resource' => 'https://panel.example.test/api/application/nodes/1'])] + public function store(StoreNodeRequest $request, CreatesNodes $nodes): JsonResponse { - $node = $this->creationService->handle($request->validated()); + $node = $nodes->create($request->payload()); - return $this->fractal->item($node) + return Fractal::item($node) ->transformWith($this->getTransformer(NodeTransformer::class)) ->addMeta([ 'resource' => route('api.application.nodes.view', [ @@ -77,30 +118,39 @@ class NodeController extends ApplicationApiController /** * Update an existing node on the Panel. * - * @throws \Throwable + * + * @return ApiPayload + * + * @throws Throwable */ - public function update(UpdateNodeRequest $request, Node $node): array + #[Endpoint('Update node', 'Updates an existing Wings node by internal numeric ID.')] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, factoryStates: ['withLocation'], resourceKey: 'node')] + #[ScribeResponse(self::CONFIGURATION_NOT_PERSISTED_ERROR, status: 400, description: 'The panel saved the node changes but could not persist the configuration to Wings.')] + public function update(UpdateNodeRequest $request, UpdatesNodes $nodes, Node $node): array { - $node = $this->updateService->handle( + $node = $nodes->update( $node, - $request->validated(), - $request->input('reset_secret') === true + $request->payload(), + $request->boolean('reset_secret') ); - return $this->fractal->item($node) + return Fractal::item($node) ->transformWith($this->getTransformer(NodeTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Deletes a given node from the Panel as long as there are no servers * currently attached to it. * - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException + * @throws HasActiveServersException */ - public function delete(DeleteNodeRequest $request, Node $node): JsonResponse + #[Endpoint('Delete node', 'Deletes a Wings node by internal numeric ID when no servers are attached.')] + #[ScribeResponse(status: 204, description: 'Node deleted.')] + #[ScribeResponse(self::ACTIVE_SERVERS_ERROR, status: 400, description: 'The node has active servers attached.')] + public function delete(DeleteNodeRequest $request, DeletesNodes $nodes, Node $node): JsonResponse { - $this->deletionService->handle($node); + $nodes->delete($node); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php index 4b49fa9c6..09dbbbd7a 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php @@ -1,39 +1,67 @@ [ + [ + 'code' => 'NoViableNodeException', + 'status' => '400', + 'detail' => 'No nodes satisfying the requirements specified for automatic deployment could be found.', + ], + ], + ]; /** * Finds any nodes that are available using the given deployment criteria. This works * similarly to the server creation process, but allows you to pass the deployment object * to this endpoint and get back a list of all Nodes satisfying the requirements. * - * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException + * + * @return ApiPayload + * + * @throws NoViableNodeException */ - public function __invoke(GetDeployableNodesRequest $request): array + #[Endpoint('List deployable nodes', 'Returns nodes that can satisfy the requested memory, disk, and optional location deployment constraints.')] + #[QueryParam('memory', 'integer', 'Memory required for the deployment, in megabytes.', required: true, example: 1024)] + #[QueryParam('disk', 'integer', 'Disk required for the deployment, in megabytes.', required: true, example: 10240)] + #[QueryParam('location_ids', 'integer[]', 'Restrict results to these location IDs.', required: false, example: [1, 2])] + #[QueryParam('page', 'integer', 'Page number to return. When omitted, all viable nodes are returned without pagination metadata.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Number of nodes to return per page when page is supplied, up to 100.', required: false, example: 50)] + #[ResponseFromTransformer(NodeTransformer::class, Node::class, description: 'Deployable nodes returned.', collection: true, factoryStates: ['withLocation'], resourceKey: 'node')] + #[ScribeResponse(self::NO_VIABLE_NODE_ERROR, status: 400, description: 'No nodes can satisfy the requested deployment constraints.')] + public function __invoke(GetDeployableNodesRequest $request, FindViableNodesService $viableNodesService): array { - $data = $request->validated(); - $nodes = $this->viableNodesService->setLocations($data['location_ids'] ?? []) - ->setMemory($data['memory']) - ->setDisk($data['disk']) - ->handle($request->query('per_page'), $request->query('page')); + $payload = $request->payload(); - return $this->fractal->collection($nodes) + $nodes = $viableNodesService + ->setLocations($payload['location_ids']) + ->setMemory($payload['memory']) + ->setDisk($payload['disk']) + ->handle($payload['per_page'], $payload['page']); + + return Fractal::collection($nodes) ->transformWith($this->getTransformer(NodeTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php index 43fc9a551..2809f66ad 100644 --- a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php @@ -1,61 +1,86 @@ [ + [ + 'code' => 'TooManyDatabasesException', + 'status' => '400', + 'detail' => 'Operation aborted: creating a new database would put this server over the defined limit.', + ], + ], + ]; /** * Return a listing of all databases currently available to a single * server. + * + * @return ApiPayload */ + #[Endpoint('List server databases', 'Returns all databases attached to a server.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "password" and "host" when the key can read database hosts.', required: false, example: 'password,host', enum: ['password', 'host', 'password,host'])] + #[ResponseFromTransformer(ServerDatabaseTransformer::class, Database::class, description: 'Server databases returned.', collection: true, factoryStates: ['withServerAndHost'], resourceKey: 'server_database')] public function index(GetServerDatabasesRequest $request, Server $server): array { - return $this->fractal->collection($server->databases) + return Fractal::collection($server->databases) ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Return a single server database. + * + * @return ApiPayload */ + #[Endpoint('Get server database', 'Returns a single database attached to a server.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "password" and "host" when the key can read database hosts.', required: false, example: 'password,host', enum: ['password', 'host', 'password,host'])] + #[ResponseFromTransformer(ServerDatabaseTransformer::class, Database::class, factoryStates: ['withServerAndHost'], resourceKey: 'server_database')] public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array { - return $this->fractal->item($database) + return Fractal::item($database) ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Reset the password for a specific server database. * - * @throws \Throwable + * @throws Throwable */ - public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): JsonResponse + #[Endpoint('Reset server database password', 'Rotates the password for a database attached to a server.')] + #[ScribeResponse(status: 204, description: 'Database password reset.')] + public function resetPassword(ServerDatabaseWriteRequest $request, RotatesDatabasePasswords $databasePasswordService, Server $server, Database $database): JsonResponse { - $this->databasePasswordService->handle($database); + $databasePasswordService->rotate($database); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } @@ -63,15 +88,18 @@ class DatabaseController extends ApplicationApiController /** * Create a new database on the Panel for a given server. * - * @throws \Throwable + * @throws Throwable */ - public function store(StoreServerDatabaseRequest $request, Server $server): JsonResponse + #[Endpoint('Create server database', 'Creates a database for a server on a configured database host.')] + #[ResponseFromTransformer(ServerDatabaseTransformer::class, Database::class, status: 201, description: 'Database created.', factoryStates: ['withServerAndHost'], resourceKey: 'server_database', meta: ['resource' => 'https://panel.example.test/api/application/servers/1/databases/1'])] + #[ScribeResponse(self::DATABASE_LIMIT_ERROR, status: 400, description: 'The server has reached its configured database limit.')] + public function store(StoreServerDatabaseRequest $request, CreatesDatabases $createDatabase, Server $server): JsonResponse { - $database = $this->databaseManagementService->create($server, array_merge($request->validated(), [ + $database = $createDatabase->create($server, array_merge($request->payload(), [ 'database' => $request->databaseName(), ])); - return $this->fractal->item($database) + return Fractal::item($database) ->transformWith($this->getTransformer(ServerDatabaseTransformer::class)) ->addMeta([ 'resource' => route('api.application.servers.databases.view', [ @@ -85,9 +113,11 @@ class DatabaseController extends ApplicationApiController /** * Handle a request to delete a specific server database from the Panel. */ - public function delete(ServerDatabaseWriteRequest $request, Server $server, Database $database): Response + #[Endpoint('Delete server database', 'Deletes a database attached to a server.')] + #[ScribeResponse(status: 204, description: 'Database deleted.')] + public function delete(ServerDatabaseWriteRequest $request, DeletesDatabases $deleteDatabase, Server $server, Database $database): Response { - $this->databaseManagementService->delete($database); + $deleteDatabase->delete($database); return response('', 204); } diff --git a/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php b/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php index 869472f72..ee327625c 100644 --- a/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php @@ -1,23 +1,37 @@ where('external_id', $external_id)->firstOrFail(); + $server = $finder->byExternalId($external_id); - return $this->fractal->item($server) + return Fractal::item($server) ->transformWith($this->getTransformer(ServerTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Application/Servers/ServerController.php b/app/Http/Controllers/Api/Application/Servers/ServerController.php index b1e80c471..4d9c91604 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerController.php @@ -1,85 +1,138 @@ [ + [ + 'code' => 'NoViableNodeException', + 'status' => '400', + 'detail' => 'No nodes satisfying the requirements specified for automatic deployment could be found.', + ], + ], + ]; /** * Return all the servers that currently exist on the Panel. + * + * @return ApiPayload */ + #[Endpoint('List servers', 'Returns a paginated list of servers visible to the application API key.')] + #[QueryParam('per_page', 'integer', 'Number of servers to return per page, up to 100.', required: false, example: 50)] + #[QueryParam('filter[uuid]', 'string', 'Filter servers by UUID.', required: false, example: '4fcb1f44-0f90-4a1a-a8bf-7cc8a14d0f26')] + #[QueryParam('filter[uuidShort]', 'string', 'Filter servers by short UUID identifier.', required: false, example: '4fcb1f44')] + #[QueryParam('filter[name]', 'string', 'Filter servers by name.', required: false, example: 'Minecraft Server')] + #[QueryParam('filter[description]', 'string', 'Filter servers by description.', required: false, example: 'Production')] + #[QueryParam('filter[image]', 'string', 'Filter servers by Docker image.', required: false, example: 'ghcr.io/pterodactyl/yolks:java_23')] + #[QueryParam('filter[external_id]', 'string', 'Filter servers by external identifier.', required: false, example: 'billing-server-42')] + #[QueryParam('search', 'string', 'Search term accepted by the list request. Must not exceed 100 characters.', required: false, example: 'minecraft')] + #[QueryParam('sort', 'string', 'Sort servers by id or uuid. Prefix with "-" for descending order.', required: false, example: '-id', enum: ['id', '-id', 'uuid', '-uuid'])] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "user", "subusers", "egg", "variables", "location", "node", "databases", and "transfer" when the key can read those resources.', required: false, example: 'user,node,allocations')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, collection: true, factoryStates: ['withRelationships'], resourceKey: 'server', paginate: [IlluminatePaginatorAdapter::class, 50])] public function index(GetServersRequest $request): array { - $servers = QueryBuilder::for(Server::query()) + $query = Server::query()->with(['egg.variables', 'serverVariables', 'location']); + $search = $request->validated('search'); + + if (is_string($search) && $search !== '') { + $query->where(function (Builder $query) use ($search): void { + $query->where('uuid', 'like', "%{$search}%") + ->orWhere('uuidShort', 'like', "%{$search}%") + ->orWhere('name', 'like', "%{$search}%") + ->orWhere('description', 'like', "%{$search}%") + ->orWhere('external_id', 'like', "%{$search}%"); + }); + } + + $servers = QueryBuilder::for($query) ->allowedFilters(['uuid', 'uuidShort', 'name', 'description', 'image', 'external_id']) ->allowedSorts(['id', 'uuid']) - ->paginate($request->query('per_page') ?? 50); + ->paginate($request->perPage()); - return $this->fractal->collection($servers) + return Fractal::collection($servers) ->transformWith($this->getTransformer(ServerTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Create a new server on the system. * - * @throws \Throwable - * @throws \Illuminate\Validation\ValidationException - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException - * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException + * @throws Throwable + * @throws ValidationException + * @throws DisplayException + * @throws NoViableAllocationException + * @throws NoViableNodeException */ - public function store(StoreServerRequest $request): JsonResponse + #[Endpoint('Create server', 'Creates a new server using either explicit allocations or automatic deployment constraints.')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, status: 201, description: 'Server created.', factoryStates: ['withRelationships'], resourceKey: 'server')] + #[ScribeResponse(self::DEPLOYMENT_ERROR, status: 400, description: 'Automatic deployment could not find a viable node or allocation.')] + public function store(StoreServerRequest $request, CreatesServers $creation): JsonResponse { - $server = $this->creationService->handle($request->validated(), $request->getDeploymentObject()); + $server = $creation->create($request->payload(), $request->getDeploymentObject()); - return $this->fractal->item($server) + return Fractal::item($server) ->transformWith($this->getTransformer(ServerTransformer::class)) ->respond(201); } /** * Show a single server transformed for the application API. + * + * @return ApiPayload */ + #[Endpoint('Get server', 'Returns a single server by internal numeric ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "user", "subusers", "egg", "variables", "location", "node", "databases", and "transfer" when the key can read those resources.', required: false, example: 'user,node,allocations')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, factoryStates: ['withRelationships'], resourceKey: 'server')] public function view(GetServerRequest $request, Server $server): array { - return $this->fractal->item($server) + return Fractal::item($server) ->transformWith($this->getTransformer(ServerTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Deletes a server. * - * @throws \Pterodactyl\Exceptions\DisplayException + * @throws DisplayException */ - public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response + #[Endpoint('Delete server', 'Deletes a server. The force route bypasses recoverable Wings or database host deletion failures.')] + #[ScribeResponse(status: 204, description: 'Server deleted.')] + public function delete(ServerWriteRequest $request, DeletesServers $deletion, Server $server, string $force = ''): Response { - $this->deletionService->withForce($force === 'force')->handle($server); + $deletion->withForce($force === 'force')->delete($server); return $this->returnNoContent(); } diff --git a/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php b/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php index 20ea05422..a208ea62d 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php @@ -1,59 +1,77 @@ [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'The requested default allocation is not currently assigned to this server.', + ], + ], + ]; /** * Update the details for a specific server. * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * + * @return ApiPayload + * + * @throws DisplayException */ - public function details(UpdateServerDetailsRequest $request, Server $server): array + #[Endpoint('Update server details', 'Updates ownership and display details for a server.')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, factoryStates: ['withRelationships'], resourceKey: 'server')] + public function details(UpdateServerDetailsRequest $request, UpdatesServerDetails $details, Server $server): array { - $updated = $this->detailsModificationService->returnUpdatedModel()->handle( + $updated = $details->update( $server, - $request->validated() + $request->payload() ); - return $this->fractal->item($updated) + return Fractal::item($updated) ->transformWith($this->getTransformer(ServerTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Update the build details for a specific server. * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * + * @return ApiPayload + * + * @throws DisplayException */ - public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array + #[Endpoint('Update server build', 'Updates resource limits, feature limits, and allocations for a server.')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, factoryStates: ['withRelationships'], resourceKey: 'server')] + #[ScribeResponse(self::ALLOCATION_ERROR, status: 400, description: 'The requested allocation change is invalid.')] + public function build(UpdateServerBuildConfigurationRequest $request, UpdatesServerBuild $build, Server $server): array { - $server = $this->buildModificationService->handle($server, $request->validated()); + $server = $build->update($server, $request->payload()); - return $this->fractal->item($server) + return Fractal::item($server) ->transformWith($this->getTransformer(ServerTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php b/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php index 51a1476fe..9a2e63479 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php @@ -1,34 +1,58 @@ [ + [ + 'code' => 'ConflictHttpException', + 'status' => '409', + 'detail' => 'Cannot toggle suspension status on a server that is currently being transferred.', + ], + ], + ]; + + private const array DAEMON_CONNECTION_ERROR = [ + 'errors' => [ + [ + 'code' => 'DaemonConnectionException', + 'status' => '504', + 'detail' => 'Could not establish a connection to the machine running this server. Please try again.', + ], + ], + ]; /** * Suspend a server on the Panel. * - * @throws \Throwable + * @throws Throwable */ - public function suspend(ServerWriteRequest $request, Server $server): Response + #[Endpoint('Suspend server', 'Marks a server as suspended and syncs the state to Wings.')] + #[ScribeResponse(status: 204, description: 'Server suspended.')] + #[ScribeResponse(self::TRANSFER_CONFLICT_ERROR, status: 409, description: 'The server is currently being transferred.')] + #[ScribeResponse(self::DAEMON_CONNECTION_ERROR, status: 504, description: 'Wings could not be reached while syncing suspension state.')] + public function suspend(ServerWriteRequest $request, TogglesServerSuspension $suspension, Server $server): Response { - $this->suspensionService->toggle($server); + $suspension->toggle($server); return $this->returnNoContent(); } @@ -36,11 +60,15 @@ class ServerManagementController extends ApplicationApiController /** * Unsuspend a server on the Panel. * - * @throws \Throwable + * @throws Throwable */ - public function unsuspend(ServerWriteRequest $request, Server $server): Response + #[Endpoint('Unsuspend server', 'Clears a server suspension and syncs the state to Wings.')] + #[ScribeResponse(status: 204, description: 'Server unsuspended.')] + #[ScribeResponse(self::TRANSFER_CONFLICT_ERROR, status: 409, description: 'The server is currently being transferred.')] + #[ScribeResponse(self::DAEMON_CONNECTION_ERROR, status: 504, description: 'Wings could not be reached while syncing suspension state.')] + public function unsuspend(ServerWriteRequest $request, TogglesServerSuspension $suspension, Server $server): Response { - $this->suspensionService->toggle($server, SuspensionService::ACTION_UNSUSPEND); + $suspension->toggle($server, TogglesServerSuspension::ACTION_UNSUSPEND); return $this->returnNoContent(); } @@ -48,13 +76,14 @@ class ServerManagementController extends ApplicationApiController /** * Mark a server as needing to be reinstalled. * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * @throws DisplayException */ - public function reinstall(ServerWriteRequest $request, Server $server): Response + #[Endpoint('Reinstall server', 'Marks a server for reinstall and asks Wings to reinstall it.')] + #[ScribeResponse(status: 204, description: 'Server marked for reinstall.')] + #[ScribeResponse(self::DAEMON_CONNECTION_ERROR, status: 504, description: 'Wings could not be reached while starting reinstall.')] + public function reinstall(ServerWriteRequest $request, ReinstallsServers $reinstall, Server $server): Response { - $this->reinstallServerService->handle($server); + $reinstall->reinstall($server); return $this->returnNoContent(); } diff --git a/app/Http/Controllers/Api/Application/Servers/StartupController.php b/app/Http/Controllers/Api/Application/Servers/StartupController.php index 6c2da078a..411eb6bce 100644 --- a/app/Http/Controllers/Api/Application/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Application/Servers/StartupController.php @@ -1,40 +1,56 @@ [ + [ + 'code' => 'DaemonConnectionException', + 'status' => '504', + 'detail' => 'Could not establish a connection to the machine running this server. Please try again.', + ], + ], + ]; /** * Update the startup and environment settings for a specific server. * - * @throws \Illuminate\Validation\ValidationException - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * + * @return ApiPayload + * + * @throws ValidationException + * @throws DaemonConnectionException */ - public function index(UpdateServerStartupRequest $request, Server $server): array + #[Endpoint('Update server startup', 'Updates startup command, image, egg, and environment variables for a server.')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, factoryStates: ['withRelationships'], resourceKey: 'server')] + #[ScribeResponse(self::DAEMON_CONNECTION_ERROR, status: 504, description: 'Wings could not be reached while syncing startup changes.')] + public function index(UpdateServerStartupRequest $request, UpdatesServerStartup $modification, Server $server): array { - $server = $this->modificationService - ->setUserLevel(User::USER_LEVEL_ADMIN) - ->handle($server, $request->validated()); + $server = $modification->update($server, $request->payload(), User::USER_LEVEL_ADMIN); - return $this->fractal->item($server) + return Fractal::item($server) ->transformWith($this->getTransformer(ServerTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Application/Tags/TagController.php b/app/Http/Controllers/Api/Application/Tags/TagController.php new file mode 100644 index 000000000..63f60c557 --- /dev/null +++ b/app/Http/Controllers/Api/Application/Tags/TagController.php @@ -0,0 +1,63 @@ +allowedFilters(['name', 'slug']) + ->allowedSorts(['id', 'name', 'slug']) + ->paginate($request->perPage()); + + return Fractal::collection($tags) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } + + /** + * Return a single tag. + * + * @return ApiPayload + */ + #[Endpoint('Get tag', 'Returns a single tag by internal numeric ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "eggs" and "nodes" when the key can read those resources.', required: false, example: 'eggs', enum: ['eggs', 'nodes', 'eggs,nodes'])] + #[ResponseFromTransformer(TagTransformer::class, Tag::class, resourceKey: 'tag')] + public function view(GetTagRequest $request, Tag $tag): array + { + return Fractal::item($tag) + ->transformWith($this->getTransformer(TagTransformer::class)) + ->toResponseArray(); + } +} diff --git a/app/Http/Controllers/Api/Application/Users/ExternalUserController.php b/app/Http/Controllers/Api/Application/Users/ExternalUserController.php index 2a8f4f07e..7871f33e8 100644 --- a/app/Http/Controllers/Api/Application/Users/ExternalUserController.php +++ b/app/Http/Controllers/Api/Application/Users/ExternalUserController.php @@ -1,23 +1,37 @@ where('external_id', $external_id)->firstOrFail(); + $user = $finder->byExternalId($external_id); - return $this->fractal->item($user) + return Fractal::item($user) ->transformWith($this->getTransformer(UserTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Application/Users/UserController.php b/app/Http/Controllers/Api/Application/Users/UserController.php index 4e251573d..065cbb396 100644 --- a/app/Http/Controllers/Api/Application/Users/UserController.php +++ b/app/Http/Controllers/Api/Application/Users/UserController.php @@ -1,95 +1,116 @@ allowedFilters(['email', 'uuid', 'username', 'external_id']) ->allowedSorts(['id', 'uuid']) - ->paginate($request->query('per_page') ?? 50); + ->paginate($request->perPage()); - return $this->fractal->collection($users) + return Fractal::collection($users) ->transformWith($this->getTransformer(UserTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Handle a request to view a single user. Includes any relations that * were defined in the request. + * + * @return ApiPayload */ + #[Endpoint('Get user', 'Returns a single panel user by internal numeric ID.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "servers" when the key can read servers.', required: false, example: 'servers', enum: ['servers'])] + #[ResponseFromTransformer(UserTransformer::class, User::class, resourceKey: 'user')] public function view(GetUsersRequest $request, User $user): array { - return $this->fractal->item($user) + return Fractal::item($user) ->transformWith($this->getTransformer(UserTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** - * Update an existing user on the system and return the response. Returns the - * updated user model response on success. Supports handling of token revocation - * errors when switching a user from an admin to a normal user. + * @return ApiPayload * - * Revocation errors are returned under the 'revocation_errors' key in the response - * meta. If there are no errors this is an empty array. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * @throws Throwable */ - public function update(UpdateUserRequest $request, User $user): array + #[Endpoint('Update user', 'Updates account details for an existing panel user.')] + #[ResponseFromTransformer(UserTransformer::class, User::class, resourceKey: 'user')] + public function update(UpdateUserRequest $request, UpdatesUsers $users, User $user): array { - $this->updateService->setUserLevel(User::USER_LEVEL_ADMIN); - $user = $this->updateService->handle($user, $request->validated()); + $user = $users->update($user, $request->payload()); - $response = $this->fractal->item($user) + $response = Fractal::item($user) ->transformWith($this->getTransformer(UserTransformer::class)); - return $response->toArray(); + return $response->toResponseArray(); } /** * Store a new user on the system. Returns the created user and an HTTP/201 * header on successful creation. * - * @throws \Exception - * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws Throwable */ - public function store(StoreUserRequest $request): JsonResponse + #[Endpoint('Create user', 'Creates a new panel user and returns the created resource.')] + #[ResponseFromTransformer(UserTransformer::class, User::class, status: 201, description: 'User created.', resourceKey: 'user', meta: ['resource' => 'https://panel.example.test/api/application/users/1'])] + public function store(StoreUserRequest $request, CreatesUsers $users): JsonResponse { - $user = $this->creationService->handle($request->validated()); + $user = $users->create($request->payload()); - return $this->fractal->item($user) + Activity::event('user:user.create') + ->subject($user) + ->property(['email' => $user->email, 'username' => $user->username, 'admin' => $user->root_admin]) + ->log(); + + return Fractal::item($user) ->transformWith($this->getTransformer(UserTransformer::class)) ->addMeta([ 'resource' => route('api.application.users.view', [ @@ -103,11 +124,13 @@ class UserController extends ApplicationApiController * Handle a request to delete a user from the Panel. Returns a HTTP/204 response * on successful deletion. * - * @throws \Pterodactyl\Exceptions\DisplayException + * @throws DisplayException */ - public function delete(DeleteUserRequest $request, User $user): JsonResponse + #[Endpoint('Delete user', 'Deletes a panel user by internal numeric ID.')] + #[ScribeResponse(status: 204, description: 'User deleted.')] + public function delete(DeleteUserRequest $request, DeletesUsers $users, User $user): JsonResponse { - $this->deletionService->handle($user); + $users->delete($user); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } diff --git a/app/Http/Controllers/Api/Client/AccountController.php b/app/Http/Controllers/Api/Client/AccountController.php index 8f733cd22..85b7db430 100644 --- a/app/Http/Controllers/Api/Client/AccountController.php +++ b/app/Http/Controllers/Api/Client/AccountController.php @@ -1,62 +1,82 @@ [ + [ + 'code' => 'InvalidPasswordProvidedException', + 'status' => '400', + 'detail' => 'The password provided was invalid for this account.', + ], + ], + ]; + + private const array THROTTLED_ERROR = [ + 'errors' => [ + [ + 'code' => 'TooManyRequestsHttpException', + 'status' => '429', + 'detail' => 'Your email address has been changed too many times today. Please try again later.', + ], + ], + ]; /** - * AccountController constructor. + * @return ApiPayload */ - public function __construct(private AuthManager $manager, private UserUpdateService $updateService) - { - parent::__construct(); - } - + #[Endpoint('Get account', 'Returns profile details for the authenticated user.')] + #[ResponseFromTransformer(AccountTransformer::class, User::class, resourceKey: 'user')] public function index(Request $request): array { - return $this->fractal->item($request->user()) + return Fractal::item($request->user()) ->transformWith($this->getTransformer(AccountTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Update the authenticated user's email address. */ - public function updateEmail(UpdateEmailRequest $request): JsonResponse + #[Endpoint('Update account email', "Updates the authenticated user's email address after verifying their current password.")] + #[BodyParam('password', 'string', 'The current account password.', required: true, example: 'current-password')] + #[ScribeResponse(status: 204, description: 'Email address updated.')] + #[ScribeResponse(self::INVALID_PASSWORD_ERROR, status: 400, description: 'The current password is invalid.')] + #[ScribeResponse(self::THROTTLED_ERROR, status: 429, description: 'The account has changed email too many times in the current throttle window.')] + public function updateEmail(UpdateEmailRequest $request, UpdatesUserEmails $emails): JsonResponse { - $user = $request->user(); - // Only allow a user to change their email three times in the span - // of 24 hours. This prevents malicious users from trying to find - // existing accounts in the system by constantly changing their email. - if (RateLimiter::tooManyAttempts($key = "user:update-email:{$user->uuid}", 3)) { - throw new TooManyRequestsHttpException(message: 'Your email address has been changed too many times today. Please try again later.'); - } + $email = JsonValueGuard::string($request->validated('email')); - $original = $user->email; - if (mb_strtolower($original) !== mb_strtolower($request->validated('email'))) { - RateLimiter::hit($key, self::EMAIL_UPDATE_THROTTLE); - - $this->updateService->handle($user, $request->validated()); + $result = $emails->update($request->user(), $email); + if ($result['changed']) { Activity::event('user:account.email-changed') - ->property(['old' => $original, 'new' => $request->validated('email')]) + ->property(['old' => $result['original'], 'new' => $result['email']]) ->log(); } @@ -67,25 +87,20 @@ class AccountController extends ClientApiController * Update the authenticated user's password. All existing sessions will be logged * out immediately. * - * @throws \Throwable + * @throws Throwable */ - public function updatePassword(UpdatePasswordRequest $request): JsonResponse + #[Endpoint('Update account password', "Updates the authenticated user's password and revokes other active sessions where supported.")] + #[BodyParam('current_password', 'string', 'The current account password.', required: true, example: 'current-password')] + #[BodyParam('password_confirmation', 'string', 'Confirmation matching the new password.', required: true, example: 'correct-horse-battery-staple')] + #[ScribeResponse(status: 204, description: 'Password updated.')] + #[ScribeResponse(self::INVALID_PASSWORD_ERROR, status: 400, description: 'The current password is invalid.')] + public function updatePassword(UpdatePasswordRequest $request, UpdatesUserPasswords $passwords): JsonResponse { - $user = Activity::event('user:account.password-changed')->transaction(function () use ($request) { - return $this->updateService->handle($request->user(), $request->validated()); - }); + $password = JsonValueGuard::string($request->validated('password')); - $guard = $this->manager->guard(); - // If you do not update the user in the session you'll end up working with a - // cached copy of the user that does not include the updated password. Do this - // to correctly store the new user details in the guard and allow the logout - // other devices functionality to work. - $guard->setUser($user); + $user = $passwords->update($request->user(), $password); - // This method doesn't exist in the stateless Sanctum world. - if (method_exists($guard, 'logoutOtherDevices')) { // @phpstan-ignore function.alreadyNarrowedType - $guard->logoutOtherDevices($request->input('password')); - } + Activity::event('user:account.password-changed')->subject($user)->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); } diff --git a/app/Http/Controllers/Api/Client/ActivityLogController.php b/app/Http/Controllers/Api/Client/ActivityLogController.php index dbbd06c06..587f0bb3e 100644 --- a/app/Http/Controllers/Api/Client/ActivityLogController.php +++ b/app/Http/Controllers/Api/Client/ActivityLogController.php @@ -1,30 +1,57 @@ user()->activity()) + $query = QueryBuilder::for($this->authenticatedUser($request)->activity()) + ->allowedFilters([AllowedFilter::partial('event'), ActivityLogFilters::actor($request->string('filter.user')->toString()), ActivityLogFilters::actorId($request->integer('filter.user_id')), AllowedFilter::exact('event_name', 'event')]) + ->allowedSorts(['timestamp']); + + $activity = $query->getEloquentBuilder() + ->select('activity_logs.*') ->with('actor') - ->allowedFilters([AllowedFilter::partial('event')]) - ->allowedSorts(['timestamp']) ->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS) - ->paginate(min($request->query('per_page', 25), 100)) + ->paginate(min($request->integer('per_page', 25), 100)) ->appends($request->query()); - return $this->fractal->collection($activity) + return Fractal::collection($activity) ->transformWith($this->getTransformer(ActivityLogTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Client/ActivityLogFilterController.php b/app/Http/Controllers/Api/Client/ActivityLogFilterController.php new file mode 100644 index 000000000..41db12364 --- /dev/null +++ b/app/Http/Controllers/Api/Client/ActivityLogFilterController.php @@ -0,0 +1,31 @@ + $facets->handle($this->authenticatedUser($request)->activity()->getQuery()), + ]); + } +} diff --git a/app/Http/Controllers/Api/Client/ApiKeyController.php b/app/Http/Controllers/Api/Client/ApiKeyController.php index f217220bb..9392c1f83 100644 --- a/app/Http/Controllers/Api/Client/ApiKeyController.php +++ b/app/Http/Controllers/Api/Client/ApiKeyController.php @@ -1,63 +1,90 @@ [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'You have reached the account limit for number of API keys.', + ], + ], + ]; + /** * Returns all the API keys that exist for the given client. + * + * @return ApiPayload */ + #[Endpoint('List account API keys', 'Returns all client API keys owned by the authenticated user.')] + #[ResponseFromTransformer(ApiKeyTransformer::class, ApiKey::class, description: 'API keys returned.', collection: true, factoryStates: ['withAllowedIps'], resourceKey: 'api_key')] public function index(ClientApiRequest $request): array { - return $this->fractal->collection($request->user()->apiKeys) + return Fractal::collection($request->user()->apiKeys) ->transformWith($this->getTransformer(ApiKeyTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Store a new API key for a user's account. * + * + * @return ApiPayload + * * @throws DisplayException */ - public function store(StoreApiKeyRequest $request): array + #[Endpoint('Create account API key', 'Creates a client API key for the authenticated user and returns the secret token once.')] + #[ResponseFromTransformer(ApiKeyTransformer::class, ApiKey::class, description: 'API key created.', factoryStates: ['withAllowedIps'], resourceKey: 'api_key', meta: ['secret_token' => 'ptlc_1234567890abcdef1234567890abcdef1234567890abcdef'])] + #[ScribeResponse(self::LIMIT_ERROR, status: 400, description: 'The account already has the maximum number of API keys.')] + public function store(StoreApiKeyRequest $request, CreatesAccountApiKeys $creation): array { - $token = DB::transaction(function () use ($request) { - if ($request->user()->apiKeys()->lockForUpdate()->count() >= 25) { - throw new DisplayException('You have reached the account limit for number of API keys.'); - } - - return $request->user()->createToken( - $request->input('description'), - $request->input('allowed_ips') - ); - }); + $token = $creation->create( + $request->user(), + JsonValueGuard::nullableString($request->validated('description')), + $request->validated('allowed_ips') === null ? null : JsonValueGuard::stringList($request->validated('allowed_ips')), + ); Activity::event('user:api-key.create') ->subject($token->accessToken) ->property('identifier', $token->accessToken->identifier) ->log(); - return $this->fractal->item($token->accessToken) + return Fractal::item($token->accessToken) ->transformWith($this->getTransformer(ApiKeyTransformer::class)) ->addMeta(['secret_token' => $token->plainTextToken]) - ->toArray(); + ->toResponseArray(); } /** * Deletes a given API key. */ + #[Endpoint('Delete account API key', 'Deletes one client API key owned by the authenticated user.')] + #[ScribeResponse(status: 204, description: 'API key deleted.')] public function delete(ClientApiRequest $request, string $identifier): JsonResponse { - /** @var ApiKey $key */ $key = $request->user()->apiKeys() ->where('key_type', ApiKey::TYPE_ACCOUNT) ->where('identifier', $identifier) diff --git a/app/Http/Controllers/Api/Client/ClientApiController.php b/app/Http/Controllers/Api/Client/ClientApiController.php index 6dcf0492c..cd0e30057 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -1,56 +1,56 @@ parseIncludes(), function ($datum) use ($transformer) { - return in_array($datum, $transformer->getAvailableIncludes()); - }); - - return array_merge($filtered, $merge); - } - - /** - * Returns the parsed includes for this request. - */ - protected function parseIncludes(): array - { - $includes = $this->request->query('include') ?? []; - - if (!is_string($includes)) { - return $includes; - } - - return array_map(function ($item) { - return trim($item); - }, explode(',', $includes)); - } + use ResolvesRequestContext; /** * Return an instance of an application transformer. * * @template T of \Pterodactyl\Transformers\Api\Client\BaseClientTransformer * - * @param class-string $abstract - * + * @param class-string $abstract * @return T * * @noinspection PhpDocSignatureInspection */ - public function getTransformer(string $abstract) + public function getTransformer(string $abstract): BaseClientTransformer { - Assert::subclassOf($abstract, BaseClientTransformer::class); // @phpstan-ignore staticMethod.alreadyNarrowedType + return $this->makeTransformer($abstract, BaseClientTransformer::class); + } - return $abstract::fromRequest($this->request); + /** + * Returns only the includes which are valid for the given transformer. + * + * @param list $merge + * @return list + */ + protected function getIncludesForTransformer(BaseClientTransformer $transformer, array $merge = []): array + { + $filtered = array_filter( + $this->parseIncludes(), + fn (string $datum): bool => in_array($datum, $transformer->getAvailableIncludes(), true), + ); + + return array_merge($filtered, $merge); + } + + /** + * Returns the parsed includes for this request. + * + * @return list + */ + protected function parseIncludes(): array + { + return Fractal::requestedIncludes(); } } diff --git a/app/Http/Controllers/Api/Client/ClientController.php b/app/Http/Controllers/Api/Client/ClientController.php index 9afb72628..cd4190d6d 100644 --- a/app/Http/Controllers/Api/Client/ClientController.php +++ b/app/Http/Controllers/Api/Client/ClientController.php @@ -1,29 +1,68 @@ 'system_permissions', + 'attributes' => [ + 'permissions' => [ + 'websocket' => [ + 'description' => 'Allows the user to connect to the server websocket, giving them access to view console output and realtime server stats.', + 'keys' => [ + 'connect' => 'Allows a user to connect to the websocket instance for a server to stream the console.', + ], + ], + 'control' => [ + 'description' => "Permissions that control a user's ability to control the power state of a server, or send commands.", + 'keys' => [ + 'console' => 'Allows a user to send commands to the server instance via the console.', + 'start' => 'Allows a user to start the server if it is stopped.', + 'stop' => 'Allows a user to stop a server if it is running.', + 'restart' => 'Allows a user to perform a server restart.', + ], + ], + ], + ], + ]; /** * Return all the servers available to the client making the API * request, including servers the user has access to as a subuser. + * + * @return ApiPayload */ + #[Endpoint('List client servers', 'Returns a paginated list of servers the authenticated user can access as an owner, subuser, or administrator.')] + #[QueryParam('page', 'integer', 'Page number to return.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Number of servers to return per page. The maximum is 100.', required: false, example: 50)] + #[QueryParam('type', 'string', 'Scope of servers to return. "owner" returns owned servers, "admin" returns admin-accessible servers excluding owned or subuser servers, and "admin-all" returns all servers for root administrators.', required: false, example: 'owner', enum: ['owner', 'admin', 'admin-all'])] + #[QueryParam('filter[uuid]', 'string', 'Filter servers by UUID.', required: false, example: '4fcb1f44-0f90-4a1a-a8bf-7cc8a14d0f26')] + #[QueryParam('filter[name]', 'string', 'Filter servers by name.', required: false, example: 'Minecraft Server')] + #[QueryParam('filter[description]', 'string', 'Filter servers by description.', required: false, example: 'Production')] + #[QueryParam('filter[external_id]', 'string', 'Filter servers by external identifier.', required: false, example: 'billing-server-42')] + #[QueryParam('filter[*]', 'string', 'Search across server name, UUID, short UUID, external identifier, or allocation address and port.', required: false, example: '192.0.2.10:25565')] + #[ResponseFromTransformer(ServerTransformer::class, Server::class, description: 'Accessible servers returned.', collection: true, factoryStates: ['withRelationships'], resourceKey: 'server', paginate: [IlluminatePaginatorAdapter::class, 50])] public function index(GetServersRequest $request): array { $user = $request->user(); @@ -37,10 +76,10 @@ class ClientController extends ClientApiController 'name', 'description', 'external_id', - AllowedFilter::custom('*', new MultiFieldServerFilter()), + AllowedFilter::custom('*', new MultiFieldServerFilter), ]); - $type = $request->input('type'); + $type = $request->validated('type'); // Either return all the servers the user has access to because they are an admin `?type=admin` or // just return all the servers the user has access to because they are the owner or a subuser of the // server. If ?type=admin-all is passed all servers on the system will be returned to the user, rather @@ -48,7 +87,7 @@ class ClientController extends ClientApiController if (in_array($type, ['admin', 'admin-all'])) { // If they aren't an admin but want all the admin servers don't fail the request, just // make it a query that will never return any results back. - if (!$user->root_admin) { + if (! $user->root_admin) { $builder->whereRaw('1 = 2'); } else { $builder = $type === 'admin-all' @@ -61,20 +100,25 @@ class ClientController extends ClientApiController $builder = $builder->whereIn('servers.id', $user->accessibleServers()->pluck('id')->all()); } - $servers = $builder->paginate(min($request->query('per_page', 50), 100))->appends($request->query()); + $servers = $builder->paginate(min($request->integer('per_page', 50), 100))->appends($request->query()); - return $this->fractal->transformWith($transformer)->collection($servers)->toArray(); + return Fractal::transformWith($transformer)->collection($servers)->toResponseArray(); } /** - * Returns all the subuser permissions available on the system. + * Returns all the subuser permissions available on the system, including those + * registered by enabled extensions. + * + * @return array{object: string, attributes: array} */ - public function permissions(): array + #[Endpoint('List server permissions', 'Returns the permission keys that can be granted to server subusers, including those registered by enabled extensions under `ext.`.')] + #[ScribeResponse(self::PERMISSIONS_EXAMPLE, description: 'System permission definitions returned.')] + public function permissions(SubuserPermissionCatalog $catalog): array { return [ 'object' => 'system_permissions', 'attributes' => [ - 'permissions' => Permission::permissions(), + 'permissions' => $catalog->groups(), ], ]; } diff --git a/app/Http/Controllers/Api/Client/ExtensionProgressController.php b/app/Http/Controllers/Api/Client/ExtensionProgressController.php new file mode 100644 index 000000000..32948211a --- /dev/null +++ b/app/Http/Controllers/Api/Client/ExtensionProgressController.php @@ -0,0 +1,50 @@ + ['id' => '11111111-1111-4111-8111-111111111111', 'extension' => 'probe', 'status' => 'running', 'percent' => 25, 'message' => 'Working', 'sequence' => 2, 'updated_at' => '2026-10-02T00:00:00+00:00']]; + + #[Endpoint('Get extension job progress', 'Returns the latest user-scoped progress snapshot, including after reconnect. Expired, disabled, and inaccessible jobs return 404.')] + #[ScribeResponse(self::EXAMPLE)] + #[ResponseField('data.status', 'string', 'Job state.', enum: ['running', 'completed', 'failed'])] + public function user(GetExtensionProgressRequest $request, ExtensionJobProgress $progress, ExtensionRepository $extensions, string $extension, string $job): JsonResponse + { + abort_unless(config('extensions.enabled') && $extensions->enabled()->has($extension), 404); + + return new JsonResponse(['data' => $progress->visible($extension, $job, $this->authenticatedUser($request))->payload()], headers: ['Cache-Control' => 'no-store']); + } + + #[Endpoint('Get server extension job progress', 'Returns the latest server-scoped snapshot to its creator or users holding the operation permission. Expired, disabled, and inaccessible jobs return 404.')] + #[ScribeResponse(self::EXAMPLE)] + #[ResponseField('data.status', 'string', 'Job state.', enum: ['running', 'completed', 'failed'])] + public function server(GetExtensionProgressRequest $request, ExtensionJobProgress $progress, ExtensionRepository $extensions, Server $server, string $extension, string $job): JsonResponse + { + abort_unless(config('extensions.enabled') && $extensions->enabled()->has($extension), 404); + + return new JsonResponse(['data' => $progress->visible($extension, $job, $this->authenticatedUser($request), $server)->payload()], headers: ['Cache-Control' => 'no-store']); + } +} diff --git a/app/Http/Controllers/Api/Client/SSHKeyController.php b/app/Http/Controllers/Api/Client/SSHKeyController.php index aa0f0c686..e377735c6 100644 --- a/app/Http/Controllers/Api/Client/SSHKeyController.php +++ b/app/Http/Controllers/Api/Client/SSHKeyController.php @@ -1,33 +1,53 @@ fractal->collection($request->user()->sshKeys) + return Fractal::collection($request->user()->sshKeys) ->transformWith($this->getTransformer(UserSSHKeyTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Stores a new SSH key for the authenticated user's account. + * + * @return ApiPayload */ + #[Endpoint('Create SSH key', 'Adds an SSH public key to the authenticated user account.')] + #[ResponseFromTransformer(UserSSHKeyTransformer::class, UserSSHKey::class, description: 'SSH key created.', resourceKey: 'ssh_key')] public function store(StoreSSHKeyRequest $request): array { $model = $request->user()->sshKeys()->create([ - 'name' => $request->input('name'), + 'name' => $request->validated('name'), 'public_key' => $request->getPublicKey(), 'fingerprint' => $request->getKeyFingerprint(), ]); @@ -37,23 +57,23 @@ class SSHKeyController extends ClientApiController ->property('fingerprint', $request->getKeyFingerprint()) ->log(); - return $this->fractal->item($model) + return Fractal::item($model) ->transformWith($this->getTransformer(UserSSHKeyTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Deletes an SSH key from the user's account. */ - public function delete(ClientApiRequest $request): JsonResponse + #[Endpoint('Delete SSH key', 'Deletes an SSH key from the authenticated user account by fingerprint. Missing keys are treated as already deleted.')] + #[ScribeResponse(status: 204, description: 'SSH key deleted or already absent.')] + public function delete(DeleteSSHKeyRequest $request): JsonResponse { - $this->validate($request, ['fingerprint' => ['required', 'string']]); - $key = $request->user()->sshKeys() - ->where('fingerprint', $request->input('fingerprint')) + ->where('fingerprint', $request->validated('fingerprint')) ->first(); - if (!is_null($key)) { + if (($key) !== null) { $key->delete(); Activity::event('user:ssh-key.delete') diff --git a/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php b/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php index f569c4122..c42a94439 100644 --- a/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php +++ b/app/Http/Controllers/Api/Client/Servers/ActivityLogController.php @@ -1,54 +1,65 @@ authorize(Permission::ACTION_ACTIVITY_READ, $server); + $this->authorize(Permissions::ActivityRead->value, $server); - $activity = QueryBuilder::for($server->activity()) - ->with('actor') + $query = QueryBuilder::for($logs->forServer($server)) ->allowedSorts(['timestamp']) - ->allowedFilters([AllowedFilter::partial('event')]) - ->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS) - ->when(config('activity.hide_admin_activity'), function (Builder $builder) use ($server) { - // We could do this with a query and a lot of joins, but that gets pretty - // painful so for now we'll execute a simpler query. - $subusers = $server->subusers()->pluck('user_id')->merge($server->owner_id); + ->allowedFilters([AllowedFilter::partial('event'), ActivityLogFilters::actor($request->string('filter.user')->toString()), ActivityLogFilters::actorId($request->integer('filter.user_id')), AllowedFilter::exact('event_name', 'event')]); - $builder->select('activity_logs.*') - ->leftJoin('users', function (JoinClause $join) { - $join->on('users.id', 'activity_logs.actor_id') - ->where('activity_logs.actor_type', (new User())->getMorphClass()); - }) - ->where(function (Builder $builder) use ($subusers) { - $builder->whereNull('users.id') - ->orWhere('users.root_admin', 0) - ->orWhereIn('users.id', $subusers); - }); - }) - ->paginate(min($request->query('per_page', 25), 100)) + $builder = $query->getEloquentBuilder() + ->select('activity_logs.*') + ->with('actor') + ->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS); + + $activity = $builder + ->paginate(min($request->integer('per_page', 25), 100)) ->appends($request->query()); - return $this->fractal->collection($activity) + return Fractal::collection($activity) ->transformWith($this->getTransformer(ActivityLogTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Client/Servers/ActivityLogFilterController.php b/app/Http/Controllers/Api/Client/Servers/ActivityLogFilterController.php new file mode 100644 index 000000000..abdc4c40e --- /dev/null +++ b/app/Http/Controllers/Api/Client/Servers/ActivityLogFilterController.php @@ -0,0 +1,35 @@ +authorize(Permissions::ActivityRead->value, $server); + + return new JsonResponse(['data' => $facets->handle($logs->forServer($server))]); + } +} diff --git a/app/Http/Controllers/Api/Client/Servers/BackupController.php b/app/Http/Controllers/Api/Client/Servers/BackupController.php index 723f3c916..6a9fb775c 100644 --- a/app/Http/Controllers/Api/Client/Servers/BackupController.php +++ b/app/Http/Controllers/Api/Client/Servers/BackupController.php @@ -1,180 +1,195 @@ 'signed_url', + 'attributes' => [ + 'url' => 'https://node.example.test/download/backup?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example.signature', + ], + ]; + + private const array BAD_REQUEST_ERROR = [ + 'errors' => [ + [ + 'code' => 'BadRequestHttpException', + 'status' => '400', + 'detail' => 'This backup cannot be restored at this time: not completed or failed.', + ], + ], + ]; /** * Returns all the backups for a given server instance in a paginated * result set. * - * @throws AuthorizationException + * + * @return ApiPayload */ - public function index(Request $request, Server $server): array + #[Endpoint('List server backups', 'Returns a paginated list of backups for the server.')] + #[QueryParam('page', 'integer', 'The page number to return.', required: false, example: 1)] + #[QueryParam('per_page', 'integer', 'Number of backups to return per page. The maximum is 50.', required: false, example: 20)] + #[ResponseFromTransformer(BackupTransformer::class, Backup::class, description: 'Server backups returned.', collection: true, resourceKey: 'backup', paginate: [IlluminatePaginatorAdapter::class, 20], meta: ['backup_count' => 1])] + public function index(ListBackupsRequest $request, BackupListService $listing, Server $server): array { - if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) { - throw new AuthorizationException(); - } + $validated = $request->payload(); - $limit = min($request->query('per_page') ?? 20, 50); + $result = $listing->handle($server, $validated['per_page']); - return $this->fractal->collection($server->backups()->paginate($limit)) + return Fractal::collection($result['backups']) ->transformWith($this->getTransformer(BackupTransformer::class)) ->addMeta([ - 'backup_count' => $this->repository->getNonFailedBackups($server)->count(), + 'backup_count' => $result['backup_count'], ]) - ->toArray(); + ->toResponseArray(); } /** * Starts the backup process for a server. * - * @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation - * @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified - * @throws \Throwable + * + * @return ApiPayload + * + * @throws InvalidTransformation + * @throws NoTransformerSpecified + * @throws Throwable */ - public function store(StoreBackupRequest $request, Server $server): array + #[Endpoint('Create server backup', 'Starts a new backup for the server.')] + #[ResponseFromTransformer(BackupTransformer::class, Backup::class, description: 'Backup started.', resourceKey: 'backup')] + public function store(StoreBackupRequest $request, InitiatesBackups $initiate, Server $server): array { - $action = $this->initiateBackupService - ->setIgnoredFiles(explode(PHP_EOL, $request->input('ignored') ?? '')); + $user = $this->authenticatedUser($request); + $validated = $request->payload(); + $action = $initiate + ->setIgnoredFiles(explode(PHP_EOL, $validated['ignored'] ?? '')); // Only set the lock status if the user even has permission to delete backups, // otherwise ignore this status. This gets a little funky since it isn't clear // how best to allow a user to create a backup that is locked without also preventing // them from just filling up a server with backups that can never be deleted? - if ($request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) { - $action->setIsLocked($request->boolean('is_locked')); + if ($user->can(Permissions::BackupDelete->value, $server)) { + $action->setIsLocked($validated['is_locked']); } - $backup = Activity::event('server:backup.start')->transaction(function ($log) use ($action, $server, $request) { - $server->backups()->lockForUpdate()->count(); + $backup = $action->initiate($server, $validated['name']); - $backup = $action->handle($server, $request->input('name')); + Activity::event('server:backup.start')->subject($backup)->property([ + 'name' => $backup->name, + 'locked' => $backup->is_locked, + ])->log(); - $log->subject($backup)->property([ - 'name' => $backup->name, - 'locked' => $request->boolean('is_locked'), - ]); - - return $backup; - }); - - return $this->fractal->item($backup) + return Fractal::item($backup) ->transformWith($this->getTransformer(BackupTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Toggles the lock status of a given backup for a server. * - * @throws \Throwable - * @throws AuthorizationException + * + * @return ApiPayload + * + * @throws Throwable */ - public function toggleLock(Request $request, Server $server, Backup $backup): array + #[Endpoint('Toggle backup lock', 'Toggles whether a backup is locked against deletion.')] + #[ResponseFromTransformer(BackupTransformer::class, Backup::class, description: 'Backup lock state toggled.', resourceKey: 'backup')] + public function toggleLock(ToggleBackupLockRequest $request, TogglesBackupLocks $toggle, Server $server, Backup $backup): array { - if (!$request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) { - throw new AuthorizationException(); - } + $backup = $toggle->toggle($backup); - $action = $backup->is_locked ? 'server:backup.unlock' : 'server:backup.lock'; - - $backup->update(['is_locked' => !$backup->is_locked]); + $action = $backup->is_locked ? 'server:backup.lock' : 'server:backup.unlock'; Activity::event($action)->subject($backup)->property('name', $backup->name)->log(); - return $this->fractal->item($backup) + return Fractal::item($backup) ->transformWith($this->getTransformer(BackupTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Returns information about a single backup. * - * @throws AuthorizationException + * + * @return ApiPayload */ - public function view(Request $request, Server $server, Backup $backup): array + #[Endpoint('Get server backup', 'Returns information about one server backup.')] + #[ResponseFromTransformer(BackupTransformer::class, Backup::class, description: 'Server backup returned.', resourceKey: 'backup')] + public function view(ViewBackupRequest $request, Server $server, Backup $backup): array { - if (!$request->user()->can(Permission::ACTION_BACKUP_READ, $server)) { - throw new AuthorizationException(); - } - - return $this->fractal->item($backup) + return Fractal::item($backup) ->transformWith($this->getTransformer(BackupTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Deletes a backup from the panel as well as the remote source where it is currently * being stored. * - * @throws \Throwable + * @throws Throwable */ - public function delete(Request $request, Server $server, Backup $backup): JsonResponse + #[Endpoint('Delete server backup', 'Deletes a backup record and its stored archive.')] + #[ScribeResponse(status: 204, description: 'Backup deleted.')] + public function delete(DeleteBackupRequest $request, DeletesBackups $delete, Server $server, Backup $backup): JsonResponse { - if (!$request->user()->can(Permission::ACTION_BACKUP_DELETE, $server)) { - throw new AuthorizationException(); - } - - $this->deleteBackupService->handle($backup); + $delete->delete($backup); Activity::event('server:backup.delete') ->subject($backup) - ->property(['name' => $backup->name, 'failed' => !$backup->is_successful]) + ->property(['name' => $backup->name, 'failed' => ! $backup->is_successful]) ->log(); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } /** - * Download the backup for a given server instance. For daemon local files, the file - * will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated - * which the user is redirected to. - * - * @throws \Throwable - * @throws AuthorizationException + * @throws Throwable */ - public function download(Request $request, Server $server, Backup $backup): JsonResponse + #[Endpoint('Get backup download URL', 'Returns a signed URL for downloading a server backup.')] + #[ScribeResponse(self::SIGNED_URL_EXAMPLE, description: 'Signed backup download URL returned.')] + #[ScribeResponse(self::BAD_REQUEST_ERROR, status: 400, description: 'The backup cannot be downloaded from its storage driver.')] + public function download(DownloadBackupRequest $request, GeneratesBackupDownloadLinks $downloadLink, Server $server, Backup $backup): JsonResponse { - if (!$request->user()->can(Permission::ACTION_BACKUP_DOWNLOAD, $server)) { - throw new AuthorizationException(); - } + $user = $this->authenticatedUser($request); - if ($backup->disk !== Backup::ADAPTER_AWS_S3 && $backup->disk !== Backup::ADAPTER_WINGS) { - throw new BadRequestHttpException('The backup requested references an unknown disk driver type and cannot be downloaded.'); - } - - $url = $this->downloadLinkService->handle($backup, $request->user()); + $url = $downloadLink->generate($backup, $user); Activity::event('server:backup.download')->subject($backup)->property('name', $backup->name)->log(); @@ -193,37 +208,23 @@ class BackupController extends ClientApiController * files that currently exist on the server will be deleted before restoring. * Otherwise, the archive will simply be unpacked over the existing files. * - * @throws \Throwable + * @throws Throwable */ - public function restore(RestoreBackupRequest $request, Server $server, Backup $backup): JsonResponse + #[Endpoint('Restore server backup', 'Restores a backup over the server files.')] + #[ScribeResponse(status: 204, description: 'Backup restore started.')] + #[ScribeResponse(self::BAD_REQUEST_ERROR, status: 400, description: 'The server or backup is not in a restorable state.')] + public function restore(RestoreBackupRequest $request, RestoresBackups $restore, Server $server, Backup $backup): JsonResponse { - // Cannot restore a backup unless a server is fully installed and not currently - // processing a different backup restoration request. - if (!is_null($server->status)) { - throw new BadRequestHttpException('This server is not currently in a state that allows for a backup to be restored.'); - } + $user = $this->authenticatedUser($request); + $validated = $request->payload(); + $truncate = $validated['truncate']; - if (!$backup->is_successful && is_null($backup->completed_at)) { - throw new BadRequestHttpException('This backup cannot be restored at this time: not completed or failed.'); - } + $restore->restore($server, $backup, $user, $truncate); - $log = Activity::event('server:backup.restore') + Activity::event('server:backup.restore') ->subject($backup) - ->property(['name' => $backup->name, 'truncate' => $request->input('truncate')]); - - $log->transaction(function () use ($backup, $server, $request) { - // If the backup is for an S3 file we need to generate a unique Download link for - // it that will allow Wings to actually access the file. - if ($backup->disk === Backup::ADAPTER_AWS_S3) { - $url = $this->downloadLinkService->handle($backup, $request->user()); - } - - // Update the status right away for the server so that we know not to allow certain - // actions against it via the Panel API. - $server->update(['status' => Server::STATUS_RESTORING_BACKUP]); - - $this->daemonRepository->setServer($server)->restore($backup, $url ?? null, $request->input('truncate')); - }); + ->property(['name' => $backup->name, 'truncate' => $truncate]) + ->log(); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } diff --git a/app/Http/Controllers/Api/Client/Servers/CommandController.php b/app/Http/Controllers/Api/Client/Servers/CommandController.php index eb6394ce5..4e0b9285b 100644 --- a/app/Http/Controllers/Api/Client/Servers/CommandController.php +++ b/app/Http/Controllers/Api/Client/Servers/CommandController.php @@ -1,49 +1,50 @@ [ + [ + 'code' => 'HttpException', + 'status' => '502', + 'detail' => 'Server must be online in order to send commands.', + ], + ], + ]; /** * Send a command to a running server. * * @throws DaemonConnectionException */ - public function index(SendCommandRequest $request, Server $server): Response + #[Endpoint('Send server command', 'Sends a console command to the running server through Wings.')] + #[ScribeResponse(status: 204, description: 'Command accepted by Wings.')] + #[ScribeResponse(self::OFFLINE_ERROR, status: 502, description: 'The server is not online or Wings rejected the command.')] + public function index(SendCommandRequest $request, SendsServerCommands $commands, Server $server): Response { - try { - $this->repository->setServer($server)->send($request->input('command')); - } catch (DaemonConnectionException $exception) { - $previous = $exception->getPrevious(); + $command = JsonValueGuard::string($request->validated('command')); + $commands->send($server, $command); - if ($previous instanceof BadResponseException) { - if ($previous->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY) { - throw new HttpException(Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception); - } - } - - throw $exception; - } - - Activity::event('server:console.command')->property('command', $request->input('command'))->log(); + Activity::event('server:console.command')->property('command', $command)->log(); return $this->returnNoContent(); } diff --git a/app/Http/Controllers/Api/Client/Servers/DatabaseController.php b/app/Http/Controllers/Api/Client/Servers/DatabaseController.php index 946861797..92a66ea68 100644 --- a/app/Http/Controllers/Api/Client/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Client/Servers/DatabaseController.php @@ -1,99 +1,121 @@ [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'Cannot create additional databases on this server: limit has been reached.', + ], + ], + ]; /** * Return all the databases that belong to the given server. + * + * @return ApiPayload */ + #[Endpoint('List server databases', 'Returns databases attached to a server visible to the authenticated user.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "password" when the user can view database passwords.', required: false, example: 'password', enum: ['password'])] + #[ResponseFromTransformer(DatabaseTransformer::class, Database::class, description: 'Server databases returned.', collection: true, resourceKey: 'server_database')] public function index(GetDatabasesRequest $request, Server $server): array { - return $this->fractal->collection($server->databases) + return Fractal::collection($server->databases) ->transformWith($this->getTransformer(DatabaseTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Create a new database for the given server and return it. * - * @throws \Throwable - * @throws \Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException - * @throws \Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException + * + * @return ApiPayload + * + * @throws Throwable + * @throws TooManyDatabasesException + * @throws DatabaseClientFeatureNotEnabledException */ - public function store(StoreDatabaseRequest $request, Server $server): array + #[Endpoint('Create server database', 'Creates a database for a server on an automatically selected database host.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "password" when the user can view database passwords.', required: false, example: 'password', enum: ['password'])] + #[ResponseFromTransformer(DatabaseTransformer::class, Database::class, description: 'Database created.', resourceKey: 'server_database', include: ['password'])] + #[ScribeResponse(self::DATABASE_LIMIT_ERROR, status: 400, description: 'The server has reached its configured database limit or client database creation is disabled.')] + public function store(StoreDatabaseRequest $request, DeploysServerDatabases $deployDatabase, Server $server): array { - $database = Activity::event('server:database.create')->transaction(function ($log) use ($request, $server) { - if ($server->databases()->lockForUpdate()->count() >= $server->database_limit) { - throw new DisplayException('Cannot create additional databases on this server: limit has been reached.'); - } + $database = $deployDatabase->deploy($server, $request->payload()); - $database = $this->deployDatabaseService->handle($server, $request->validated()); + Activity::event('server:database.create')->subject($database)->property('name', $database->database)->log(); - $log->subject($database)->property('name', $database->database); - - return $database; - }); - - return $this->fractal->item($database) + return Fractal::item($database) ->parseIncludes(['password']) ->transformWith($this->getTransformer(DatabaseTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Rotates the password for the given server model and returns a fresh instance to * the caller. * - * @throws \Throwable + * + * @return ApiPayload + * + * @throws Throwable */ - public function rotatePassword(RotatePasswordRequest $request, Server $server, Database $database): array + #[Endpoint('Rotate server database password', 'Rotates the password for a database attached to a server and returns the updated database.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "password" when the user can view database passwords.', required: false, example: 'password', enum: ['password'])] + #[ResponseFromTransformer(DatabaseTransformer::class, Database::class, description: 'Database password rotated.', resourceKey: 'server_database', include: ['password'])] + public function rotatePassword(RotatePasswordRequest $request, RotatesDatabasePasswords $passwordService, Server $server, Database $database): array { Activity::event('server:database.rotate-password') ->subject($database) ->property('name', $database->database) - ->transaction(fn () => $this->passwordService->handle($database)); + ->transaction(fn (): string => $passwordService->rotate($database)); - return $this->fractal->item($database->refresh()) + return Fractal::item($database->refresh()) ->parseIncludes(['password']) ->transformWith($this->getTransformer(DatabaseTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Removes a database from the server. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response + #[Endpoint('Delete server database', 'Deletes a database attached to a server.')] + #[ScribeResponse(status: 204, description: 'Database deleted.')] + public function delete(DeleteDatabaseRequest $request, DeletesDatabases $deleteDatabase, Server $server, Database $database): Response { - $this->managementService->delete($database); + $deleteDatabase->delete($database); Activity::event('server:database.delete') ->subject($database) diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index d5ee9e70e..9c84f23dd 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -1,70 +1,149 @@ 'file_object', + 'attributes' => [ + 'name' => 'server.properties', + 'mode' => '-rw-r--r--', + 'mode_bits' => '0644', + 'size' => 1024, + 'is_file' => true, + 'is_symlink' => false, + 'mimetype' => 'text/plain', + 'created_at' => '2026-06-29T12:00:00+00:00', + 'modified_at' => '2026-06-29T12:00:00+00:00', + ], + ]; + + private const array ARCHIVE_OBJECT_EXAMPLE = [ + 'object' => 'file_object', + 'attributes' => [ + 'name' => 'archive-2026-06-29.tar.gz', + 'mode' => '-rw-r--r--', + 'mode_bits' => '0644', + 'size' => 4096, + 'is_file' => true, + 'is_symlink' => false, + 'mimetype' => 'application/gzip', + 'created_at' => '2026-06-29T12:00:00+00:00', + 'modified_at' => '2026-06-29T12:00:00+00:00', + ], + ]; + + private const array FILE_LIST_EXAMPLE = [ + 'object' => 'list', + 'data' => [ + self::FILE_OBJECT_EXAMPLE, + ], + ]; + + private const array SIGNED_URL_EXAMPLE = [ + 'object' => 'signed_url', + 'attributes' => [ + 'url' => 'https://node.example.test/download/file?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example.signature', + ], + ]; + + private const array DAEMON_ERROR = [ + 'errors' => [ + [ + 'code' => 'DaemonConnectionException', + 'status' => '502', + 'detail' => 'There was an error while communicating with the machine running this server.', + ], + ], + ]; /** * Returns a listing of files in a given directory. * - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * + * @return ApiPayload + * + * @throws DaemonConnectionException */ - public function directory(ListFilesRequest $request, Server $server): array + #[Endpoint('List files', 'Returns files and folders in a server directory.')] + #[QueryParam('directory', 'string', 'Directory to list. Defaults to the server root.', required: false, example: '/config', nullable: true)] + #[ScribeResponse(self::FILE_LIST_EXAMPLE, description: 'Directory contents returned.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not list the directory.')] + public function directory(ListFilesRequest $request, ListsDirectories $operation, Server $server): array { - $contents = $this->fileRepository - ->setServer($server) - ->getDirectory($request->get('directory') ?? '/'); + $directory = JsonValueGuard::nullableString($request->validated('directory')) ?? '/'; + $contents = $operation->list($server, $directory); - return $this->fractal->collection($contents) + return Fractal::collection($contents) ->transformWith($this->getTransformer(FileObjectTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Return the contents of a specified file for the user. * - * @throws \Throwable + * @throws Throwable */ - public function contents(GetFileContentsRequest $request, Server $server): Response + #[Endpoint('Get file contents', 'Returns raw text contents for a server file.')] + #[QueryParam('file', 'string', 'Path to the file to read.', required: true, example: '/server.properties')] + #[ScribeResponse("motd=A Minecraft Server\nserver-port=25565", description: 'File contents returned as text/plain.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not read the file.')] + public function contents(GetFileContentsRequest $request, ReadsFileContents $operation, Server $server): Response { - $response = $this->fileRepository->setServer($server)->getContent( - $request->get('file'), - config('pterodactyl.files.max_edit_size') - ); + $file = JsonValueGuard::string($request->validated('file')); + $response = $operation->read($server, $file); - Activity::event('server:file.read')->property('file', $request->get('file'))->log(); + Activity::event('server:file.read')->property('file', $file)->log(); return new Response($response, Response::HTTP_OK, ['Content-Type' => 'text/plain']); } @@ -73,21 +152,29 @@ class FileController extends ClientApiController * Generates a one-time token with a link that the user can use to * download a given file. * - * @throws \Throwable + * + * @return array{object: string, attributes: array{url: string}} + * + * @throws Throwable */ - public function download(GetFileContentsRequest $request, Server $server): array + #[Endpoint('Get file download URL', 'Returns a short-lived signed URL for downloading a server file directly from Wings.')] + #[QueryParam('file', 'string', 'Path to the file to download.', required: true, example: '/server.properties')] + #[ScribeResponse(self::SIGNED_URL_EXAMPLE, description: 'Signed download URL returned.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not create the download URL.')] + public function download(GetFileContentsRequest $request, NodeJWTService $jwtService, Server $server): array { - $token = $this->jwtService + $file = JsonValueGuard::string($request->validated('file')); + $token = $jwtService ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setUser($request->user()) ->setClaims([ - 'file_path' => rawurldecode($request->get('file')), + 'file_path' => rawurldecode($file), 'server_uuid' => $server->uuid, ]) ->setScopes(JwtScope::FileDownload) - ->handle($server->node, $request->user()->id . $server->uuid); + ->handle($server->node, $request->user()->id.$server->uuid); - Activity::event('server:file.download')->property('file', $request->get('file'))->log(); + Activity::event('server:file.download')->property('file', $file)->log(); return [ 'object' => 'signed_url', @@ -104,13 +191,18 @@ class FileController extends ClientApiController /** * Writes the contents of the specified file to the server. * - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * @throws DaemonConnectionException */ - public function write(WriteFileContentRequest $request, Server $server): JsonResponse + #[Endpoint('Write file contents', 'Writes the raw request body to a server file. This endpoint does not expect a JSON wrapper for the file contents.')] + #[QueryParam('file', 'string', 'Path to the file to write.', required: true, example: '/server.properties')] + #[ScribeResponse(status: 204, description: 'File contents written.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not write the file.')] + public function write(WriteFileContentRequest $request, WritesFileContents $operation, Server $server): JsonResponse { - $this->fileRepository->setServer($server)->putContent($request->get('file'), $request->getContent()); + $file = JsonValueGuard::string($request->validated('file')); + $operation->write($server, $file, $request->getContent()); - Activity::event('server:file.write')->property('file', $request->get('file'))->log(); + Activity::event('server:file.write')->property('file', $file)->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); } @@ -118,17 +210,20 @@ class FileController extends ClientApiController /** * Creates a new folder on the server. * - * @throws \Throwable + * @throws Throwable */ - public function create(CreateFolderRequest $request, Server $server): JsonResponse + #[Endpoint('Create folder', 'Creates a folder in a server directory.')] + #[ScribeResponse(status: 204, description: 'Folder created.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not create the folder.')] + public function create(CreateFolderRequest $request, CreatesDirectories $operation, Server $server): JsonResponse { - $this->fileRepository - ->setServer($server) - ->createDirectory($request->input('name'), $request->input('root', '/')); + $name = JsonValueGuard::string($request->validated('name')); + $root = JsonValueGuard::string($request->validated('root', '/')); + $operation->create($server, $name, $root); Activity::event('server:file.create-directory') - ->property('name', $request->input('name')) - ->property('directory', $request->input('root')) + ->property('name', $name) + ->property('directory', $root) ->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); @@ -137,17 +232,20 @@ class FileController extends ClientApiController /** * Renames a file on the remote machine. * - * @throws \Throwable + * @throws Throwable */ - public function rename(RenameFileRequest $request, Server $server): JsonResponse + #[Endpoint('Rename files', 'Renames one or more files or folders in a server directory.')] + #[ScribeResponse(status: 204, description: 'Files renamed.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not rename the files.')] + public function rename(RenameFileRequest $request, RenamesFiles $operation, Server $server): JsonResponse { - $this->fileRepository - ->setServer($server) - ->renameFiles($request->input('root'), $request->input('files')); + $root = JsonValueGuard::nullableString($request->validated('root')); + $files = JsonValueGuard::jsonArray($request->validated('files')); + $operation->rename($server, $root, $files); Activity::event('server:file.rename') - ->property('directory', $request->input('root')) - ->property('files', $request->input('files')) + ->property('directory', $root) + ->property('files', $files) ->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); @@ -156,54 +254,67 @@ class FileController extends ClientApiController /** * Copies a file on the server. * - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * @throws DaemonConnectionException */ - public function copy(CopyFileRequest $request, Server $server): JsonResponse + #[Endpoint('Copy file', 'Creates a copy of a file on the server.')] + #[ScribeResponse(status: 204, description: 'File copied.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not copy the file.')] + public function copy(CopyFileRequest $request, CopiesFiles $operation, Server $server): JsonResponse { - $this->fileRepository - ->setServer($server) - ->copyFile($request->input('location')); + $location = JsonValueGuard::string($request->validated('location')); + $operation->copy($server, $location); - Activity::event('server:file.copy')->property('file', $request->input('location'))->log(); + Activity::event('server:file.copy')->property('file', $location)->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); } /** - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * @return ApiPayload + * + * @throws DaemonConnectionException */ - public function compress(CompressFilesRequest $request, Server $server): array + #[Endpoint('Compress files', 'Creates an archive from one or more files or folders in a server directory.')] + #[ScribeResponse(self::ARCHIVE_OBJECT_EXAMPLE, description: 'Archive created.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not create the archive.')] + public function compress(CompressFilesRequest $request, CompressesFiles $operation, Server $server): array { - $file = $this->fileRepository->setServer($server)->compressFiles( - $request->input('root'), - $request->input('files') + $root = JsonValueGuard::nullableString($request->validated('root')); + $files = JsonValueGuard::jsonArray($request->validated('files')); + $file = $operation->compress($server, + $root, + $files ); Activity::event('server:file.compress') - ->property('directory', $request->input('root')) - ->property('files', $request->input('files')) + ->property('directory', $root) + ->property('files', $files) ->log(); - return $this->fractal->item($file) + return Fractal::item($file) ->transformWith($this->getTransformer(FileObjectTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * @throws DaemonConnectionException */ - public function decompress(DecompressFilesRequest $request, Server $server): JsonResponse + #[Endpoint('Decompress file', 'Extracts an archive in a server directory.')] + #[ScribeResponse(status: 204, description: 'Archive extracted.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not extract the archive.')] + public function decompress(DecompressFilesRequest $request, DecompressesFiles $operation, Server $server): JsonResponse { - set_time_limit(300); + $root = JsonValueGuard::nullableString($request->validated('root')); + $file = JsonValueGuard::string($request->validated('file')); - $this->fileRepository->setServer($server)->decompressFile( - $request->input('root'), - $request->input('file') + $operation->decompress($server, + $root, + $file ); Activity::event('server:file.decompress') - ->property('directory', $request->input('root')) - ->property('files', $request->input('file')) + ->property('directory', $root) + ->property('files', $file) ->log(); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); @@ -212,18 +323,23 @@ class FileController extends ClientApiController /** * Deletes files or folders for the server in the given root directory. * - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * @throws DaemonConnectionException */ - public function delete(DeleteFileRequest $request, Server $server): JsonResponse + #[Endpoint('Delete files', 'Deletes one or more files or folders from a server directory.')] + #[ScribeResponse(status: 204, description: 'Files deleted.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not delete the files.')] + public function delete(DeleteFileRequest $request, DeletesFiles $operation, Server $server): JsonResponse { - $this->fileRepository->setServer($server)->deleteFiles( - $request->input('root'), - $request->input('files') + $root = JsonValueGuard::nullableString($request->validated('root')); + $files = JsonValueGuard::jsonArray($request->validated('files')); + $operation->delete($server, + $root, + $files ); Activity::event('server:file.delete') - ->property('directory', $request->input('root')) - ->property('files', $request->input('files')) + ->property('directory', $root) + ->property('files', $files) ->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); @@ -232,13 +348,18 @@ class FileController extends ClientApiController /** * Updates file permissions for file(s) in the given root directory. * - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * @throws DaemonConnectionException */ - public function chmod(ChmodFilesRequest $request, Server $server): JsonResponse + #[Endpoint('Change file permissions', 'Updates POSIX mode bits for one or more files or folders in a server directory.')] + #[ScribeResponse(status: 204, description: 'File permissions updated.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not update file permissions.')] + public function chmod(ChmodFilesRequest $request, ChangesFilePermissions $operation, Server $server): JsonResponse { - $this->fileRepository->setServer($server)->chmodFiles( - $request->input('root'), - $request->input('files') + $root = JsonValueGuard::nullableString($request->validated('root')); + $files = JsonValueGuard::jsonArray($request->validated('files')); + $operation->change($server, + $root, + $files ); return new JsonResponse([], Response::HTTP_NO_CONTENT); @@ -247,19 +368,24 @@ class FileController extends ClientApiController /** * Requests that a file be downloaded from a remote location by Wings. * - * @throws \Throwable + * @throws Throwable */ - public function pull(PullFileRequest $request, Server $server): JsonResponse + #[Endpoint('Pull remote file', 'Requests that Wings download a remote file into a server directory.')] + #[ScribeResponse(status: 204, description: 'Remote file pull queued or completed.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not pull the remote file.')] + public function pull(PullFileRequest $request, PullsFiles $operation, Server $server): JsonResponse { - $this->fileRepository->setServer($server)->pull( - $request->input('url'), - $request->input('directory'), - $request->safe(['filename', 'use_header', 'foreground']) + $url = JsonValueGuard::string($request->validated('url')); + $directory = JsonValueGuard::nullableString($request->validated('directory')); + $operation->pull($server, + $url, + $directory, + JsonValueGuard::jsonArray($request->safe()->only(['filename', 'use_header', 'foreground'])) ); Activity::event('server:file.pull') - ->property('directory', $request->input('directory')) - ->property('url', $request->input('url')) + ->property('directory', $directory) + ->property('url', $url) ->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); diff --git a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php index ed86ac7c6..3e1caf12e 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php @@ -1,36 +1,44 @@ 'signed_url', + 'attributes' => [ + 'url' => 'https://node.example.test/upload/file?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example.signature', + ], + ]; /** * Returns an url where files can be uploaded to. */ - public function __invoke(UploadFileRequest $request, Server $server): JsonResponse + #[Endpoint('Get file upload URL', 'Returns a short-lived signed URL for uploading a file directly to Wings.')] + #[ScribeResponse(self::SIGNED_URL_EXAMPLE, description: 'Signed upload URL returned.')] + public function __invoke(UploadFileRequest $request, NodeJWTService $jwtService, Server $server): JsonResponse { return new JsonResponse([ 'object' => 'signed_url', 'attributes' => [ - 'url' => $this->getUploadUrl($server, $request->user()), + 'url' => $this->getUploadUrl($server, $request->user(), $jwtService), ], ]); } @@ -38,14 +46,14 @@ class FileUploadController extends ClientApiController /** * Returns an url where files can be uploaded to. */ - protected function getUploadUrl(Server $server, User $user): string + protected function getUploadUrl(Server $server, User $user, NodeJWTService $jwtService): string { - $token = $this->jwtService + $token = $jwtService ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setUser($user) ->setClaims(['server_uuid' => $server->uuid]) ->setScopes(JwtScope::FileUpload) - ->handle($server->node, $user->id . $server->uuid); + ->handle($server->node, $user->id.$server->uuid); return sprintf( '%s/upload/file?token=%s', diff --git a/app/Http/Controllers/Api/Client/Servers/LogController.php b/app/Http/Controllers/Api/Client/Servers/LogController.php new file mode 100644 index 000000000..ff8403565 --- /dev/null +++ b/app/Http/Controllers/Api/Client/Servers/LogController.php @@ -0,0 +1,65 @@ + 'server_logs', + 'attributes' => [ + 'lines' => [ + '[12:00:00] [Server thread/INFO]: Starting minecraft server version 1.21', + '[12:00:04] [Server thread/INFO]: Done (3.512s)! For help, type "help"', + ], + ], + ]; + + private const array DAEMON_ERROR = [ + 'errors' => [ + [ + 'code' => 'DaemonConnectionException', + 'status' => '502', + 'detail' => 'There was an error while communicating with the machine running this server.', + ], + ], + ]; + + /** + * Return the most recent console output of a server, oldest line first. + * + * @return array{object: string, attributes: array{lines: list}} + * + * @throws DaemonConnectionException + */ + #[Endpoint('Get server logs', 'Returns the most recent console output lines Wings holds for the server, oldest first.')] + #[QueryParam('lines', 'integer', 'Number of lines to return. Defaults to the maximum of 100.', required: false, example: 50)] + #[ScribeResponse(self::LOGS_EXAMPLE, description: 'Console output returned.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not read the console output.')] + public function __invoke(GetServerLogsRequest $request, ReadsServerLogs $logs, Server $server): array + { + $lines = JsonValueGuard::integer($request->validated('lines') ?? ReadsServerLogs::MAX_LINES); + + return [ + 'object' => 'server_logs', + 'attributes' => [ + 'lines' => $logs->read($server, $lines), + ], + ]; + } +} diff --git a/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php b/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php index 6f66f428e..ad7e966cc 100644 --- a/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php +++ b/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php @@ -1,58 +1,82 @@ [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'Cannot assign additional allocations to this server: limit has been reached.', + ], + ], + ]; + + private const array DELETE_PRIMARY_ERROR = [ + 'errors' => [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'You cannot delete the primary allocation for this server.', + ], + ], + ]; /** * Lists all the allocations available to a server and whether * they are currently assigned as the primary for this server. + * + * @return ApiPayload */ + #[Endpoint('List server allocations', 'Returns all network allocations assigned to the server.')] + #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, description: 'Server allocations returned.', collection: true, factoryStates: ['withServer'], resourceKey: 'allocation')] public function index(GetNetworkRequest $request, Server $server): array { - return $this->fractal->collection($server->allocations) + return Fractal::collection($server->allocations) ->transformWith($this->getTransformer(AllocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** - * Set the primary allocation for a server. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * @return ApiPayload */ - public function update(UpdateAllocationRequest $request, Server $server, Allocation $allocation): array + #[Endpoint('Update allocation notes', 'Updates notes attached to a server allocation.')] + #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, description: 'Allocation notes updated.', factoryStates: ['withServer'], resourceKey: 'allocation')] + public function update(UpdateAllocationRequest $request, UpdatesAllocationNotes $notes, Server $server, Allocation $allocation): array { $original = $allocation->notes; - $allocation->forceFill(['notes' => $request->input('notes')])->save(); + $allocation = $notes->update($allocation, JsonValueGuard::nullableString($request->validated('notes'))); if ($original !== $allocation->notes) { Activity::event('server:allocation.notes') @@ -61,54 +85,49 @@ class NetworkAllocationController extends ClientApiController ->log(); } - return $this->fractal->item($allocation) + return Fractal::item($allocation) ->transformWith($this->getTransformer(AllocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Set the primary allocation for a server. * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * @return ApiPayload */ - public function setPrimary(SetPrimaryAllocationRequest $request, Server $server, Allocation $allocation): array + #[Endpoint('Set primary allocation', 'Sets the primary network allocation for the server.')] + #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, description: 'Primary allocation updated.', factoryStates: ['withServer'], resourceKey: 'allocation')] + public function setPrimary(SetPrimaryAllocationRequest $request, SetsPrimaryAllocations $allocations, Server $server, Allocation $allocation): array { - $this->serverRepository->update($server->id, ['allocation_id' => $allocation->id]); + $allocation = $allocations->setPrimary($server, $allocation); Activity::event('server:allocation.primary') ->subject($allocation) ->property('allocation', $allocation->toString()) ->log(); - return $this->fractal->item($allocation) + return Fractal::item($allocation) ->transformWith($this->getTransformer(AllocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** - * Set the notes for the allocation for a server. - *s. + * @return ApiPayload * * @throws DisplayException */ - public function store(NewAllocationRequest $request, Server $server): array + #[Endpoint('Create server allocation', 'Assigns an available allocation to the server.')] + #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, description: 'Allocation assigned.', factoryStates: ['withServer'], resourceKey: 'allocation')] + #[ScribeResponse(self::LIMIT_ERROR, status: 400, description: 'The server has reached its configured allocation limit or no allocation is available.')] + public function store(NewAllocationRequest $request, AssignsAllocations $allocations, Server $server): array { - $allocation = Activity::event('server:allocation.create')->transaction(function ($log) use ($server) { - if ($server->allocations()->lockForUpdate()->count() >= $server->allocation_limit) { - throw new DisplayException('Cannot assign additional allocations to this server: limit has been reached.'); - } + $allocation = $allocations->assign($server); - $allocation = $this->assignableAllocationService->handle($server); + Activity::event('server:allocation.create')->subject($allocation)->property('allocation', $allocation->toString())->log(); - $log->subject($allocation)->property('allocation', $allocation->toString()); - - return $allocation; - }); - - return $this->fractal->item($allocation) + return Fractal::item($allocation) ->transformWith($this->getTransformer(AllocationTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** @@ -116,22 +135,12 @@ class NetworkAllocationController extends ClientApiController * * @throws DisplayException */ - public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation): JsonResponse + #[Endpoint('Delete server allocation', 'Removes a non-primary allocation from the server and returns it to the available pool.')] + #[ScribeResponse(status: 204, description: 'Allocation removed.')] + #[ScribeResponse(self::DELETE_PRIMARY_ERROR, status: 400, description: 'The allocation cannot be removed because it is primary or the server has no allocation limit.')] + public function delete(DeleteAllocationRequest $request, UnassignsAllocations $allocations, Server $server, Allocation $allocation): JsonResponse { - // Don't allow the deletion of allocations if the server does not have an - // allocation limit set. - if (empty($server->allocation_limit)) { - throw new DisplayException('You cannot delete allocations for this server: no allocation limit is set.'); - } - - if ($allocation->id === $server->allocation_id) { - throw new DisplayException('You cannot delete the primary allocation for this server.'); - } - - Allocation::query()->where('id', $allocation->id)->update([ - 'notes' => null, - 'server_id' => null, - ]); + $allocation = $allocations->unassign($server, $allocation); Activity::event('server:allocation.delete') ->subject($allocation) diff --git a/app/Http/Controllers/Api/Client/Servers/PowerController.php b/app/Http/Controllers/Api/Client/Servers/PowerController.php index ca0575765..49f6c8b38 100644 --- a/app/Http/Controllers/Api/Client/Servers/PowerController.php +++ b/app/Http/Controllers/Api/Client/Servers/PowerController.php @@ -1,34 +1,36 @@ repository->setServer($server)->send( - $request->input('signal') - ); + $signal = JsonValueGuard::string($request->validated('signal')); + $power->send($server, $signal); - Activity::event(strtolower("server:power.{$request->input('signal')}"))->log(); + Activity::event(mb_strtolower("server:power.{$signal}"))->log(); return $this->returnNoContent(); } diff --git a/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php b/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php index dcaf48115..9ede236a3 100644 --- a/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php +++ b/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php @@ -1,41 +1,70 @@ 'stats', + 'attributes' => [ + 'current_state' => 'running', + 'is_suspended' => false, + 'resources' => [ + 'memory_bytes' => 536870912, + 'cpu_absolute' => 12.5, + 'disk_bytes' => 2147483648, + 'network_rx_bytes' => 102400, + 'network_tx_bytes' => 204800, + 'uptime' => 3600000, + ], + ], + ]; + + private const array DAEMON_ERROR = [ + 'errors' => [ + [ + 'code' => 'DaemonConnectionException', + 'status' => '502', + 'detail' => 'There was an error while communicating with the machine running this server.', + ], + ], + ]; /** * Return the current resource utilization for a server. This value is cached for up to * 20 seconds at a time to ensure that repeated requests to this endpoint do not cause * a flood of unnecessary API calls. * - * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * + * @return ApiPayload + * + * @throws DaemonConnectionException */ - public function __invoke(GetServerRequest $request, Server $server): array + #[Endpoint('Get server resources', 'Returns the latest cached resource utilization reported by Wings for the server.')] + #[ScribeResponse(self::STATS_EXAMPLE, description: 'Resource utilization returned.')] + #[ScribeResponse(self::DAEMON_ERROR, status: 502, description: 'Wings could not be reached for resource utilization.')] + #[ResponseField('attributes.current_state', 'string', example: 'running', enum: ['offline', 'stopped', 'starting', 'running', 'stopping'])] + public function __invoke(GetServerRequest $request, ReadsServerState $state, Server $server): array { - $key = "resources:$server->uuid"; - $stats = $this->cache->remember($key, Carbon::now()->addSeconds(20), function () use ($server) { - return $this->repository->setServer($server)->getDetails(); - }); - - return $this->fractal->item($stats) + return Fractal::item($state->read($server)) ->transformWith($this->getTransformer(StatsTransformer::class)) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleController.php index 832e426e2..2cf8903a3 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleController.php @@ -1,149 +1,152 @@ [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'The cron data provided does not evaluate to a valid expression.', + ], + ], + ]; /** * Returns all the schedules belonging to a given server. + * + * @return ApiPayload */ + #[Endpoint('List server schedules', 'Returns all schedules configured for the server, including their tasks.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports tasks.', required: false, example: 'tasks')] + #[ResponseFromTransformer(ScheduleTransformer::class, Schedule::class, description: 'Server schedules returned.', collection: true, resourceKey: 'server_schedule')] public function index(ViewScheduleRequest $request, Server $server): array { $schedules = $server->schedules->loadMissing('tasks'); - return $this->fractal->collection($schedules) + return Fractal::collection($schedules) ->transformWith($this->getTransformer(ScheduleTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Store a new schedule for a server. * + * + * @return ApiPayload + * * @throws DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function store(StoreScheduleRequest $request, Server $server): array + #[Endpoint('Create server schedule', 'Creates a schedule for the server.')] + #[BodyParam('month', 'string', 'The month.', required: true, example: '*')] + #[BodyParam('only_when_online', 'boolean', 'Whether the schedule should run only when the server is online.', required: false, example: true)] + #[ResponseFromTransformer(ScheduleTransformer::class, Schedule::class, description: 'Schedule created.', resourceKey: 'server_schedule')] + #[ScribeResponse(self::CRON_ERROR, status: 400, description: 'The cron expression is invalid.')] + public function store(StoreScheduleRequest $request, CreatesSchedules $schedules, Server $server): array { - /** @var Schedule $model */ - $model = $this->repository->create([ - 'server_id' => $server->id, - 'name' => $request->input('name'), - 'cron_day_of_week' => $request->input('day_of_week'), - 'cron_month' => $request->input('month'), - 'cron_day_of_month' => $request->input('day_of_month'), - 'cron_hour' => $request->input('hour'), - 'cron_minute' => $request->input('minute'), - 'is_active' => (bool) $request->input('is_active'), - 'only_when_online' => (bool) $request->input('only_when_online'), - 'next_run_at' => $this->getNextRunAt($request), - ]); + $model = $schedules->create($server, $request->payload()); Activity::event('server:schedule.create') ->subject($model) ->property('name', $model->name) ->log(); - return $this->fractal->item($model) + return Fractal::item($model) ->transformWith($this->getTransformer(ScheduleTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Returns a specific schedule for the server. + * + * @return ApiPayload */ + #[Endpoint('Get server schedule', 'Returns one schedule configured for the server, including its tasks.')] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports tasks.', required: false, example: 'tasks')] + #[ResponseFromTransformer(ScheduleTransformer::class, Schedule::class, description: 'Server schedule returned.', resourceKey: 'server_schedule')] public function view(ViewScheduleRequest $request, Server $server, Schedule $schedule): array { - if ($schedule->server_id !== $server->id) { - throw new NotFoundHttpException(); - } + throw_if($schedule->server_id !== $server->id, NotFoundHttpException::class); $schedule->loadMissing('tasks'); - return $this->fractal->item($schedule) + return Fractal::item($schedule) ->transformWith($this->getTransformer(ScheduleTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Updates a given schedule with the new data provided. * + * + * @return ApiPayload + * * @throws DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function update(UpdateScheduleRequest $request, Server $server, Schedule $schedule): array + #[Endpoint('Update server schedule', 'Updates a schedule for the server and recalculates its next run time.')] + #[BodyParam('month', 'string', 'The month.', required: true, example: '*')] + #[BodyParam('only_when_online', 'boolean', 'Whether the schedule should run only when the server is online.', required: false, example: true)] + #[ResponseFromTransformer(ScheduleTransformer::class, Schedule::class, description: 'Schedule updated.', resourceKey: 'server_schedule')] + #[ScribeResponse(self::CRON_ERROR, status: 400, description: 'The cron expression is invalid.')] + public function update(UpdateScheduleRequest $request, UpdatesSchedules $schedules, Server $server, Schedule $schedule): array { - $active = (bool) $request->input('is_active'); - - $data = [ - 'name' => $request->input('name'), - 'cron_day_of_week' => $request->input('day_of_week'), - 'cron_month' => $request->input('month'), - 'cron_day_of_month' => $request->input('day_of_month'), - 'cron_hour' => $request->input('hour'), - 'cron_minute' => $request->input('minute'), - 'is_active' => $active, - 'only_when_online' => (bool) $request->input('only_when_online'), - 'next_run_at' => $this->getNextRunAt($request), - ]; - - // Toggle the processing state of the scheduled task when it is enabled or disabled so that an - // invalid state can be reset without manual database intervention. - // - // @see https://github.com/pterodactyl/panel/issues/2425 - if ($schedule->is_active !== $active) { - $data['is_processing'] = false; - } - - $this->repository->update($schedule->id, $data); + $schedule = $schedules->update($schedule, $request->payload()); Activity::event('server:schedule.update') ->subject($schedule) - ->property(['name' => $schedule->name, 'active' => $active]) + ->property(['name' => $schedule->name, 'active' => $schedule->is_active]) ->log(); - return $this->fractal->item($schedule->refresh()) + return Fractal::item($schedule) ->transformWith($this->getTransformer(ScheduleTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Executes a given schedule immediately rather than waiting on it's normally scheduled time * to pass. This does not care about the schedule state. * - * @throws \Throwable + * @throws Throwable */ - public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse + #[Endpoint('Execute server schedule', 'Queues a schedule to run immediately regardless of its active state.')] + #[ScribeResponse(status: 202, description: 'Schedule execution queued.')] + public function execute(TriggerScheduleRequest $request, ProcessesSchedules $schedules, Server $server, Schedule $schedule): JsonResponse { - $this->service->handle($schedule, true); + $schedules->process($schedule, true); Activity::event('server:schedule.execute')->subject($schedule)->property('name', $schedule->name)->log(); @@ -153,32 +156,14 @@ class ScheduleController extends ClientApiController /** * Deletes a schedule and it's associated tasks. */ - public function delete(DeleteScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse + #[Endpoint('Delete server schedule', 'Deletes a schedule and its tasks from the server.')] + #[ScribeResponse(status: 204, description: 'Schedule deleted.')] + public function delete(DeleteScheduleRequest $request, DeletesSchedules $schedules, Server $server, Schedule $schedule): JsonResponse { - $this->repository->delete($schedule->id); + $schedules->delete($schedule); Activity::event('server:schedule.delete')->subject($schedule)->property('name', $schedule->name)->log(); return new JsonResponse([], Response::HTTP_NO_CONTENT); } - - /** - * Get the next run timestamp based on the cron data provided. - * - * @throws DisplayException - */ - protected function getNextRunAt(Request $request): Carbon - { - try { - return Utilities::getScheduleNextRunDate( - $request->input('minute'), - $request->input('hour'), - $request->input('day_of_month'), - $request->input('month'), - $request->input('day_of_week') - ); - } catch (\Exception $exception) { - throw new DisplayException('The cron data provided does not evaluate to a valid expression.'); - } - } } diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php index 1091fb2ca..9479d2b89 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php @@ -1,175 +1,118 @@ [ + [ + 'code' => 'ServiceLimitExceededException', + 'status' => '400', + 'detail' => 'Schedules may not have more than 10 tasks associated with them. Creating this task would put this schedule over the limit.', + ], + ], + ]; /** * Create a new task for a given schedule and store it in the database. * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * + * @return ApiPayload + * * @throws ServiceLimitExceededException */ - public function store(StoreTaskRequest $request, Server $server, Schedule $schedule): array + #[Endpoint('Create schedule task', 'Creates a task in a server schedule.')] + #[ResponseFromTransformer(TaskTransformer::class, Task::class, description: 'Schedule task created.', resourceKey: 'schedule_task')] + #[ScribeResponse(self::LIMIT_ERROR, status: 400, description: 'The schedule has reached its configured task limit.')] + public function store(StoreTaskRequest $request, CreatesScheduleTasks $tasks, Server $server, Schedule $schedule): array { - $limit = config('pterodactyl.client_features.schedules.per_schedule_task_limit', 10); - if ($schedule->tasks()->count() >= $limit) { - throw new ServiceLimitExceededException("Schedules may not have more than $limit tasks associated with them. Creating this task would put this schedule over the limit."); - } + $this->assertBackupTaskAllowed($request, $server); - if ($server->backup_limit === 0 && $request->action === 'backup') { - throw new HttpForbiddenException("A backup task cannot be created when the server's backup limit is set to 0."); - } - - /** @var Task|null $lastTask */ - $lastTask = $schedule->tasks()->orderByDesc('sequence_id')->first(); - - /** @var Task $task */ - $task = $this->connection->transaction(function () use ($request, $schedule, $lastTask) { - $sequenceId = ($lastTask->sequence_id ?? 0) + 1; - $requestSequenceId = $request->integer('sequence_id', $sequenceId); - - // Ensure that the sequence id is at least 1. - if ($requestSequenceId < 1) { - $requestSequenceId = 1; - } - - // If the sequence id from the request is greater than or equal to the next available - // sequence id, we don't need to do anything special. Otherwise, we need to update - // the sequence id of all tasks that are greater than or equal to the request sequence - // id to be one greater than the current value. - if ($requestSequenceId < $sequenceId) { - $schedule->tasks() - ->where('sequence_id', '>=', $requestSequenceId) - ->increment('sequence_id'); - $sequenceId = $requestSequenceId; - } - - return $this->repository->create([ - 'schedule_id' => $schedule->id, - 'sequence_id' => $sequenceId, - 'action' => $request->input('action'), - 'payload' => $request->input('payload') ?? '', - 'time_offset' => $request->input('time_offset'), - 'continue_on_failure' => $request->boolean('continue_on_failure'), - ]); - }); + $task = $tasks->create($schedule, $request->payload()); Activity::event('server:task.create') ->subject($schedule, $task) ->property(['name' => $schedule->name, 'action' => $task->action, 'payload' => $task->payload]) ->log(); - return $this->fractal->item($task) + return Fractal::item($task) ->transformWith($this->getTransformer(TaskTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Updates a given task for a server. * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * + * @return ApiPayload */ - public function update(StoreTaskRequest $request, Server $server, Schedule $schedule, Task $task): array + #[Endpoint('Update schedule task', 'Updates a task in a server schedule, including its sequence position.')] + #[ResponseFromTransformer(TaskTransformer::class, Task::class, description: 'Schedule task updated.', resourceKey: 'schedule_task')] + public function update(StoreTaskRequest $request, UpdatesScheduleTasks $tasks, Server $server, Schedule $schedule, Task $task): array { - if ($schedule->id !== $task->schedule_id || $server->id !== $schedule->server_id) { - throw new NotFoundHttpException(); - } + $this->assertBackupTaskAllowed($request, $server); - if ($server->backup_limit === 0 && $request->action === 'backup') { - throw new HttpForbiddenException("A backup task cannot be created when the server's backup limit is set to 0."); - } - - $this->connection->transaction(function () use ($request, $schedule, $task) { - $sequenceId = $request->integer('sequence_id', $task->sequence_id); - // Ensure that the sequence id is at least 1. - if ($sequenceId < 1) { - $sequenceId = 1; - } - - // Shift all other tasks in the schedule up or down to make room for the new task. - if ($sequenceId < $task->sequence_id) { - $schedule->tasks() - ->where('sequence_id', '>=', $sequenceId) - ->where('sequence_id', '<', $task->sequence_id) - ->increment('sequence_id'); - } elseif ($sequenceId > $task->sequence_id) { - $schedule->tasks() - ->where('sequence_id', '>', $task->sequence_id) - ->where('sequence_id', '<=', $sequenceId) - ->decrement('sequence_id'); - } - - $this->repository->update($task->id, [ - 'sequence_id' => $sequenceId, - 'action' => $request->input('action'), - 'payload' => $request->input('payload') ?? '', - 'time_offset' => $request->input('time_offset'), - 'continue_on_failure' => $request->boolean('continue_on_failure'), - ]); - }); + $task = $tasks->update($schedule, $task, $request->payload()); Activity::event('server:task.update') ->subject($schedule, $task) ->property(['name' => $schedule->name, 'action' => $task->action, 'payload' => $task->payload]) ->log(); - return $this->fractal->item($task->refresh()) + return Fractal::item($task) ->transformWith($this->getTransformer(TaskTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Delete a given task for a schedule. If there are subsequent tasks stored in the database * for this schedule their sequence IDs are decremented properly. - * - * @throws \Exception */ - public function delete(ClientApiRequest $request, Server $server, Schedule $schedule, Task $task): JsonResponse + #[Endpoint('Delete schedule task', 'Deletes a task from a server schedule and compacts subsequent sequence IDs.')] + #[ScribeResponse(status: 204, description: 'Schedule task deleted.')] + public function delete(DeleteTaskRequest $request, DeletesScheduleTasks $tasks, Server $server, Schedule $schedule, Task $task): JsonResponse { - if ($task->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) { - throw new NotFoundHttpException(); - } - - if (!$request->user()->can(Permission::ACTION_SCHEDULE_UPDATE, $server)) { - throw new HttpForbiddenException('You do not have permission to perform this action.'); - } - - $schedule->tasks() - ->where('sequence_id', '>', $task->sequence_id) - ->decrement('sequence_id'); - $task->delete(); + $tasks->delete($schedule, $task); Activity::event('server:task.delete')->subject($schedule, $task)->property('name', $schedule->name)->log(); return new JsonResponse(null, Response::HTTP_NO_CONTENT); } + + /** + * A backup task is refused while the server cannot hold any backups. + * + * @throws HttpForbiddenException + */ + private function assertBackupTaskAllowed(StoreTaskRequest $request, Server $server): void + { + throw_if($server->backup_limit === 0 && $request->payload()['action'] === 'backup', HttpForbiddenException::class, "A backup task cannot be created when the server's backup limit is set to 0."); + } } diff --git a/app/Http/Controllers/Api/Client/Servers/ServerController.php b/app/Http/Controllers/Api/Client/Servers/ServerController.php index 63eb9b988..c62de29cb 100644 --- a/app/Http/Controllers/Api/Client/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Client/Servers/ServerController.php @@ -1,35 +1,40 @@ true, 'user_permissions' => ['websocket.connect', 'control.console', 'control.start', 'control.stop', 'control.restart']])] + public function index(GetServerRequest $request, GetUserPermissionsService $permissionsService, Server $server): array { - return $this->fractal->item($server) + return Fractal::item($server) ->transformWith($this->getTransformer(ServerTransformer::class)) ->addMeta([ 'is_server_owner' => $request->user()->id === $server->owner_id, - 'user_permissions' => $this->permissionsService->handle($server, $request->user()), + 'user_permissions' => $permissionsService->handle($server, $request->user()), ]) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Client/Servers/SettingsController.php b/app/Http/Controllers/Api/Client/Servers/SettingsController.php index b77678889..74e5f3e79 100644 --- a/app/Http/Controllers/Api/Client/Servers/SettingsController.php +++ b/app/Http/Controllers/Api/Client/Servers/SettingsController.php @@ -1,55 +1,66 @@ [ + [ + 'code' => 'BadRequestHttpException', + 'status' => '400', + 'detail' => "This server's Docker image has been manually set by an administrator and cannot be updated.", + ], + ], + ]; /** * Renames a server. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ + #[Endpoint('Rename server', 'Updates the server name and optionally its description.')] + #[ScribeResponse(status: 204, description: 'Server renamed.')] public function rename(RenameServerRequest $request, Server $server): JsonResponse { - $name = $request->input('name'); - $description = $request->has('description') ? (string) $request->input('description') : $server->description; - $this->repository->update($server->id, [ - 'name' => $name, - 'description' => $description, + $previousName = $server->name; + $previousDescription = $server->description; + + $server->update([ + 'name' => $request->string('name')->toString(), + 'description' => $request->has('description') ? $request->description() : $server->description, ]); - if ($server->name !== $name) { + if ($server->wasChanged('name')) { Activity::event('server:settings.rename') - ->property(['old' => $server->name, 'new' => $name]) + ->property(['old' => $previousName, 'new' => $server->name]) ->log(); } - if ($server->description !== $description) { + if ($server->wasChanged('description')) { Activity::event('server:settings.description') - ->property(['old' => $server->description, 'new' => $description]) + ->property(['old' => $previousDescription, 'new' => $server->description]) ->log(); } @@ -59,11 +70,13 @@ class SettingsController extends ClientApiController /** * Reinstalls the server on the daemon. * - * @throws \Throwable + * @throws Throwable */ - public function reinstall(ReinstallServerRequest $request, Server $server): JsonResponse + #[Endpoint('Reinstall server', 'Queues a reinstall of the server on Wings.')] + #[ScribeResponse(status: 202, description: 'Server reinstall queued.')] + public function reinstall(ReinstallServerRequest $request, ReinstallsServers $reinstall, Server $server): JsonResponse { - $this->reinstallServerService->handle($server); + $reinstall->reinstall($server); Activity::event('server:reinstall')->log(); @@ -73,20 +86,24 @@ class SettingsController extends ClientApiController /** * Changes the Docker image in use by the server. * - * @throws \Throwable + * @throws Throwable */ + #[Endpoint('Set server Docker image', 'Updates the server Docker image to one of the images allowed by the server egg.')] + #[BodyParam('docker_image', 'string', 'The Docker image to use.', required: true, example: 'ghcr.io/pterodactyl/yolks:java_21')] + #[ScribeResponse(status: 204, description: 'Docker image updated.')] + #[ScribeResponse(self::BAD_REQUEST_ERROR, status: 400, description: 'The server image was manually set by an administrator and cannot be changed through this endpoint.')] public function dockerImage(SetDockerImageRequest $request, Server $server): JsonResponse { - if (!in_array($server->image, array_values($server->egg->docker_images))) { - throw new BadRequestHttpException('This server\'s Docker image has been manually set by an administrator and cannot be updated.'); - } + $egg = $server->egg ?? throw new UnexpectedValueException('The server does not have an egg relationship.'); + throw_unless(in_array($server->image, $egg->docker_images, true), BadRequestHttpException::class, "This server's Docker image has been manually set by an administrator and cannot be updated."); $original = $server->image; - $server->forceFill(['image' => $request->input('docker_image')])->saveOrFail(); + $dockerImage = JsonValueGuard::string($request->validated('docker_image')); + $server->forceFill(['image' => $dockerImage])->saveOrFail(); if ($original !== $server->image) { Activity::event('server:startup.image') - ->property(['old' => $original, 'new' => $request->input('docker_image')]) + ->property(['old' => $original, 'new' => $dockerImage]) ->log(); } diff --git a/app/Http/Controllers/Api/Client/Servers/StartupController.php b/app/Http/Controllers/Api/Client/Servers/StartupController.php index 2f8cd6c6a..bf79cf8e0 100644 --- a/app/Http/Controllers/Api/Client/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Client/Servers/StartupController.php @@ -1,99 +1,110 @@ [ + [ + 'code' => 'BadRequestHttpException', + 'status' => '400', + 'detail' => 'The environment variable you are trying to edit is read-only.', + ], + ], + ]; /** * Returns the startup information for the server including all the variables. + * + * @return ApiPayload */ - public function index(GetStartupRequest $request, Server $server): array + #[Endpoint('Get startup configuration', 'Returns the rendered startup command, available Docker images, raw startup command, and user-visible variables for the server.')] + #[ResponseFromTransformer(EggVariableTransformer::class, EggVariable::class, description: 'Startup configuration returned.', collection: true, factoryStates: ['viewable', 'editable'], resourceKey: 'egg_variable', meta: ['startup_command' => 'java -Xms128M -Xmx1024M -jar paper.jar', 'docker_images' => ['Java 23' => 'ghcr.io/pterodactyl/yolks:java_23'], 'raw_startup_command' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}'])] + public function index(GetStartupRequest $request, StartupCommandService $startupCommand, Server $server): array { - $startup = $this->startupCommandService->handle($server); + $startup = $startupCommand->handle($server); + $egg = $server->egg ?? throw new UnexpectedValueException('The server does not have an egg relationship.'); - return $this->fractal->collection( + return Fractal::collection( $server->variables()->where('user_viewable', true)->get() ) ->transformWith($this->getTransformer(EggVariableTransformer::class)) ->addMeta([ 'startup_command' => $startup, - 'docker_images' => $server->egg->docker_images, + 'docker_images' => $egg->docker_images, 'raw_startup_command' => $server->startup, ]) - ->toArray(); + ->toResponseArray(); } /** * Updates a single variable for a server. * - * @throws \Illuminate\Validation\ValidationException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * @return ApiPayload */ - public function update(UpdateStartupVariableRequest $request, Server $server): array + #[Endpoint('Update startup variable', 'Updates one editable startup variable for the server and returns the updated rendered startup command.')] + #[ResponseFromTransformer(EggVariableTransformer::class, EggVariable::class, description: 'Startup variable updated.', factoryStates: ['viewable', 'editable'], resourceKey: 'egg_variable', meta: ['startup_command' => 'java -Xms128M -Xmx1024M -jar paper.jar', 'raw_startup_command' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}'])] + #[ScribeResponse(self::BAD_REQUEST_ERROR, status: 400, description: 'The variable does not exist, is hidden, or is read-only.')] + public function update(UpdateStartupVariableRequest $request, StartupCommandService $startupCommand, Server $server): array { - $variable = $server->variables()->where('env_variable', $request->input('key'))->first(); + $variable = $request->variable(); + throw_if(! $variable instanceof EggVariable || ! $variable->user_viewable, BadRequestHttpException::class, 'The environment variable you are trying to edit does not exist.'); - if (is_null($variable) || !$variable->user_viewable) { - throw new BadRequestHttpException('The environment variable you are trying to edit does not exist.'); - } elseif (!$variable->user_editable) { - throw new BadRequestHttpException('The environment variable you are trying to edit is read-only.'); - } + throw_unless($variable->user_editable, BadRequestHttpException::class, 'The environment variable you are trying to edit is read-only.'); $original = $variable->server_value; + $value = JsonValueGuard::nullableScalarString($request->validated('value')); - // Revalidate the variable value using the egg variable specific validation rules for it. - $this->validate($request, ['value' => $variable->rules]); + $server->serverVariables()->updateOrCreate( + ['variable_id' => $variable->id], + ['variable_value' => $value ?? ''], + ); - $this->repository->updateOrCreate([ - 'server_id' => $server->id, - 'variable_id' => $variable->id, - ], [ - 'variable_value' => $request->input('value') ?? '', - ]); + $variable->refresh(); + $variable->server_value = $value; - $variable = $variable->refresh(); - $variable->server_value = $request->input('value'); + $startup = $startupCommand->handle($server); - $startup = $this->startupCommandService->handle($server); - - if ($original !== $request->input('value')) { + if ($original !== $value) { Activity::event('server:startup.edit') ->subject($variable) ->property([ 'variable' => $variable->env_variable, 'old' => $original, - 'new' => $request->input('value') ?? '', + 'new' => $value, ]) ->log(); } - return $this->fractal->item($variable) + return Fractal::item($variable) ->transformWith($this->getTransformer(EggVariableTransformer::class)) ->addMeta([ 'startup_command' => $startup, 'raw_startup_command' => $server->startup, ]) - ->toArray(); + ->toResponseArray(); } } diff --git a/app/Http/Controllers/Api/Client/Servers/SubuserController.php b/app/Http/Controllers/Api/Client/Servers/SubuserController.php index b37cc8e8d..5f0ea4621 100644 --- a/app/Http/Controllers/Api/Client/Servers/SubuserController.php +++ b/app/Http/Controllers/Api/Client/Servers/SubuserController.php @@ -1,169 +1,171 @@ [ + [ + 'code' => 'ServerSubuserExistsException', + 'status' => '400', + 'detail' => 'A user with that email address is already assigned as a subuser for this server.', + ], + ], + ]; /** * Return the users associated with this server instance. + * + * @return ApiPayload */ + #[Endpoint('List server subusers', 'Returns subusers assigned to the server.')] + #[ResponseFromTransformer(SubuserTransformer::class, Subuser::class, description: 'Server subusers returned.', collection: true, resourceKey: 'server_subuser')] public function index(GetSubuserRequest $request, Server $server): array { - return $this->fractal->collection($server->subusers) + return Fractal::collection($server->subusers) ->transformWith($this->getTransformer(SubuserTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Returns a single subuser associated with this server instance. + * + * @return ApiPayload */ + #[Endpoint('Get server subuser', 'Returns one subuser assignment for the server.')] + #[ResponseFromTransformer(SubuserTransformer::class, Subuser::class, description: 'Server subuser returned.', resourceKey: 'server_subuser')] public function view(GetSubuserRequest $request): array { $subuser = $request->attributes->get('subuser'); - return $this->fractal->item($subuser) + return Fractal::item($subuser) ->transformWith($this->getTransformer(SubuserTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Create a new subuser for the given server. * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Subuser\ServerSubuserExistsException - * @throws \Pterodactyl\Exceptions\Service\Subuser\UserIsServerOwnerException - * @throws \Throwable + * + * @return ApiPayload + * + * @throws ServerSubuserExistsException + * @throws UserIsServerOwnerException + * @throws Throwable */ - public function store(StoreSubuserRequest $request, Server $server): array + #[Endpoint('Create server subuser', 'Assigns an existing or new user as a subuser on the server.')] + #[ResponseFromTransformer(SubuserTransformer::class, Subuser::class, description: 'Server subuser created.', resourceKey: 'server_subuser')] + #[ScribeResponse(self::SUBUSER_EXISTS_ERROR, status: 400, description: 'The user is already assigned to the server or is the server owner.')] + public function store(StoreSubuserRequest $request, CreatesSubusers $subusers, Server $server): array { - $response = $this->creationService->handle( + $email = $request->string('email')->toString(); + $permissions = $request->permissions(); + $response = $subusers->create( $server, - $request->input('email'), - $this->getDefaultPermissions($request) + $email, + $permissions, ); + if ($response->user->wasRecentlyCreated) { + Activity::event('user:user.create') + ->subject($response->user) + ->property(['email' => $response->user->email, 'username' => $response->user->username, 'admin' => $response->user->root_admin]) + ->log(); + } + Activity::event('server:subuser.create') ->subject($response->user) - ->property(['email' => $request->input('email'), 'permissions' => $this->getDefaultPermissions($request)]) + ->property(['email' => $email, 'permissions' => $permissions]) ->log(); - return $this->fractal->item($response) + return Fractal::item($response) ->transformWith($this->getTransformer(SubuserTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Update a given subuser in the system for the server. * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * + * @return ApiPayload */ - public function update(UpdateSubuserRequest $request, Server $server): array + #[Endpoint('Update server subuser', 'Updates permissions for a server subuser and revokes their SFTP access tokens.')] + #[ResponseFromTransformer(SubuserTransformer::class, Subuser::class, description: 'Server subuser updated.', resourceKey: 'server_subuser')] + public function update(UpdateSubuserRequest $request, UpdatesSubusers $subusers, Server $server): array { - /** @var \Pterodactyl\Models\Subuser $subuser */ - $subuser = $request->attributes->get('subuser'); + $subuser = $request->subuser(); + $permissions = $request->permissions(); - $permissions = $this->getDefaultPermissions($request); $current = $subuser->permissions; - - sort($permissions); + $requested = $permissions; sort($current); + sort($requested); - $log = Activity::event('server:subuser.update') - ->subject($subuser->user) - ->property([ - 'email' => $subuser->user->email, - 'old' => $current, - 'new' => $permissions, - 'revoked' => true, - ]); + // Only touch the database and Wings when the permissions actually change. + if ($requested !== $current) { + $subuser = $subusers->update($server, $subuser, $permissions); - // Only update the database and hit up the Wings instance to invalidate JTI's if the permissions - // have actually changed for the user. - if ($permissions !== $current) { - $log->transaction(function () use ($request, $subuser, $server) { - $this->repository->update($subuser->id, [ - 'permissions' => $this->getDefaultPermissions($request), - ]); - - RevokeSftpAccessJob::dispatch($subuser->user->uuid, $server); - }); + Activity::event('server:subuser.update') + ->subject($subuser->user) + ->property([ + 'email' => $subuser->user->email, + 'old' => $current, + 'new' => $requested, + 'revoked' => true, + ]) + ->log(); } - $log->reset(); - - return $this->fractal->item($subuser->refresh()) + return Fractal::item($subuser) ->transformWith($this->getTransformer(SubuserTransformer::class)) - ->toArray(); + ->toResponseArray(); } /** * Removes a subusers from a server's assignment. */ - public function delete(DeleteSubuserRequest $request, Server $server): JsonResponse + #[Endpoint('Delete server subuser', 'Removes a subuser assignment from the server and revokes SFTP access tokens.')] + #[ScribeResponse(status: 204, description: 'Server subuser removed.')] + public function delete(DeleteSubuserRequest $request, DeletesSubusers $subusers, Server $server): JsonResponse { - /** @var \Pterodactyl\Models\Subuser $subuser */ - $subuser = $request->attributes->get('subuser'); + $subuser = $request->subuser(); - $log = Activity::event('server:subuser.delete') + $subusers->delete($server, $subuser); + + Activity::event('server:subuser.delete') ->subject($subuser->user) ->property('email', $subuser->user->email) - ->property('revoked', true); - - $log->transaction(function () use ($server, $subuser) { - $subuser->delete(); - - RevokeSftpAccessJob::dispatch($subuser->user->uuid, $server); - }); + ->property('revoked', true) + ->log(); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } - - /** - * Returns the default permissions for subusers and parses out any permissions - * that were passed that do not also exist in the internally tracked list of - * permissions. - */ - protected function getDefaultPermissions(Request $request): array - { - $allowed = Permission::permissions() - ->map(function ($value, $prefix) { - return array_map(function ($value) use ($prefix) { - return "$prefix.$value"; - }, array_keys($value['keys'])); - }) - ->flatten() - ->all(); - - $cleaned = array_intersect($request->input('permissions') ?? [], $allowed); - - return array_unique(array_merge($cleaned, [Permission::ACTION_WEBSOCKET_CONNECT])); - } } diff --git a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php index a949bd0a7..f9e6bf000 100644 --- a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php +++ b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php @@ -1,29 +1,34 @@ [ + 'token' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example.signature', + 'socket' => 'wss://node.example.test/api/servers/4fcb1f44-0f90-4a1a-a8bf-7cc8a14d0f26/ws', + ], + ]; /** * Generates a one-time token that is sent along in every websocket call to the Daemon. @@ -31,21 +36,19 @@ class WebsocketController extends ClientApiController * allows us to continually renew this token and avoid users maintaining sessions wrongly, * as well as ensure that user's only perform actions they're allowed to. */ - public function __invoke(ClientApiRequest $request, Server $server): JsonResponse + #[Endpoint('Get websocket credentials', 'Returns a short-lived Wings websocket token and socket URL for the server.')] + #[ScribeResponse(self::WEBSOCKET_EXAMPLE, description: 'Websocket credentials returned.')] + public function __invoke(ClientApiRequest $request, GetUserPermissionsService $permissionsService, NodeJWTService $jwtService, Server $server): JsonResponse { $user = $request->user(); - if ($user->cannot(Permission::ACTION_WEBSOCKET_CONNECT, $server)) { - throw new HttpForbiddenException('You do not have permission to connect to this server\'s websocket.'); - } + throw_if($user->cannot(Permissions::WebsocketConnect->value, $server), HttpForbiddenException::class, "You do not have permission to connect to this server's websocket."); - $permissions = $this->permissionsService->handle($server, $user); + $permissions = $permissionsService->handle($server, $user); $node = $server->node; - if (!is_null($server->transfer)) { + if (($server->transfer) !== null) { // Check if the user has permissions to receive transfer logs. - if (!in_array('admin.websocket.transfer', $permissions)) { - throw new HttpForbiddenException('You do not have permission to view server transfer logs.'); - } + throw_unless(in_array('admin.websocket.transfer', $permissions), HttpForbiddenException::class, 'You do not have permission to view server transfer logs.'); // Redirect the websocket request to the new node if the server has been archived. if ($server->transfer->archived) { @@ -53,7 +56,7 @@ class WebsocketController extends ClientApiController } } - $token = $this->jwtService + $token = $jwtService ->setExpiresAt(CarbonImmutable::now()->addMinutes(10)) ->setUser($request->user()) ->setClaims([ @@ -61,14 +64,14 @@ class WebsocketController extends ClientApiController 'permissions' => $permissions, ]) ->setScopes(JwtScope::Websocket) - ->handle($node, $user->id . $server->uuid); + ->handle($node, $user->id.$server->uuid); $socket = str_replace(['https://', 'http://'], ['wss://', 'ws://'], $node->getConnectionAddress()); return new JsonResponse([ 'data' => [ 'token' => $token->toString(), - 'socket' => $socket . sprintf('/api/servers/%s/ws', $server->uuid), + 'socket' => $socket.sprintf('/api/servers/%s/ws', $server->uuid), ], ]); } diff --git a/app/Http/Controllers/Api/Client/TwoFactorController.php b/app/Http/Controllers/Api/Client/TwoFactorController.php index edc13d26f..9bd8ae33c 100644 --- a/app/Http/Controllers/Api/Client/TwoFactorController.php +++ b/app/Http/Controllers/Api/Client/TwoFactorController.php @@ -1,68 +1,107 @@ [ + 'image_url_data' => 'otpauth://totp/Pterodactyl:user@example.com?secret=EXAMPLESECRET&issuer=Pterodactyl', + 'secret' => 'EXAMPLESECRET', + ], + ]; + + private const array RECOVERY_TOKENS_EXAMPLE = [ + 'object' => 'recovery_tokens', + 'attributes' => [ + 'tokens' => [ + 'r1a2b3c4d5', + 'r6e7f8g9h0', + ], + ], + ]; + + private const array BAD_REQUEST_ERROR = [ + 'errors' => [ + [ + 'code' => 'InvalidPasswordProvidedException', + 'status' => '400', + 'detail' => 'The password provided was invalid for this account.', + ], + ], + ]; + + private const array ALREADY_ENABLED_ERROR = [ + 'errors' => [ + [ + 'code' => 'BadRequestHttpException', + 'status' => '400', + 'detail' => 'Two-factor authentication is already enabled on this account.', + ], + ], + ]; /** * Returns two-factor token credentials that allow a user to configure * it on their account. If two-factor is already enabled this endpoint * will return a 400 error. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function index(Request $request): JsonResponse + #[Endpoint('Get two-factor setup', 'Creates or returns the current two-factor setup payload for the authenticated user.')] + #[ScribeResponse(self::TWO_FACTOR_SETUP_EXAMPLE, description: 'Two-factor setup data returned.')] + #[ScribeResponse(self::ALREADY_ENABLED_ERROR, status: 400, description: 'Two-factor authentication is already enabled.')] + public function index(Request $request, SetsUpTwoFactor $twoFactor): JsonResponse { - if ($request->user()->use_totp) { - throw new BadRequestHttpException('Two-factor authentication is already enabled on this account.'); - } + $user = $this->authenticatedUser($request); + throw_if($user->use_totp, BadRequestHttpException::class, 'Two-factor authentication is already enabled on this account.'); return new JsonResponse([ - 'data' => $this->setupService->handle($request->user()), + 'data' => $twoFactor->setup($user), ]); } /** * Updates a user's account to have two-factor enabled. * - * @throws \Throwable - * @throws \Illuminate\Validation\ValidationException + * @throws Throwable */ - public function store(Request $request): JsonResponse + #[Endpoint('Enable two-factor authentication', 'Enables two-factor authentication for the authenticated user and returns one-time recovery tokens.')] + #[BodyParam('code', 'string', 'The six-digit TOTP code generated by the authenticator app.', required: true, example: '123456')] + #[BodyParam('password', 'string', 'The current account password.', required: true, example: 'current-password')] + #[ScribeResponse(self::RECOVERY_TOKENS_EXAMPLE, description: 'Two-factor authentication enabled. Store these recovery tokens now; they are not shown again.')] + #[ScribeResponse(self::BAD_REQUEST_ERROR, status: 400, description: 'The password or TOTP code is invalid.')] + public function store(EnableTwoFactorRequest $request, TogglesTwoFactor $twoFactor): JsonResponse { - $validator = $this->validation->make($request->all(), [ - 'code' => ['required', 'string', 'size:6'], - 'password' => ['required', 'string'], - ]); + $user = $this->authenticatedUser($request); + $password = JsonValueGuard::string($request->validated('password')); + throw_unless(Hash::check($password, $user->password), InvalidPasswordProvidedException::class, trans('validation.internal.invalid_password')); - $data = $validator->validate(); - if (!password_verify($data['password'], $request->user()->password)) { - throw new BadRequestHttpException('The password provided was not valid.'); - } + $code = JsonValueGuard::string($request->validated('code')); - $tokens = $this->toggleTwoFactorService->handle($request->user(), $data['code'], true); + $tokens = $twoFactor->toggle($user, $code, true); Activity::event('user:two-factor.create')->log(); @@ -78,21 +117,19 @@ class TwoFactorController extends ClientApiController * Disables two-factor authentication on an account if the password provided * is valid. * - * @throws \Throwable + * @throws Throwable */ - public function delete(Request $request): JsonResponse + #[Endpoint('Disable two-factor authentication', 'Disables two-factor authentication for the authenticated user after verifying their password.')] + #[BodyParam('password', 'string', 'The current account password.', required: true, example: 'current-password')] + #[ScribeResponse(status: 204, description: 'Two-factor authentication disabled.')] + #[ScribeResponse(self::BAD_REQUEST_ERROR, status: 400, description: 'The password is invalid.')] + public function delete(DisableTwoFactorRequest $request, DisablesTwoFactor $twoFactor): JsonResponse { - if (!password_verify($request->input('password') ?? '', $request->user()->password)) { - throw new BadRequestHttpException('The password provided was not valid.'); - } + $user = $this->authenticatedUser($request); + $password = JsonValueGuard::string($request->validated('password')); + throw_unless(Hash::check($password, $user->password), InvalidPasswordProvidedException::class, trans('validation.internal.invalid_password')); - /** @var \Pterodactyl\Models\User $user */ - $user = $request->user(); - - $user->update([ - 'totp_authenticated_at' => Carbon::now(), - 'use_totp' => false, - ]); + $twoFactor->disable($user); Activity::event('user:two-factor.delete')->log(); diff --git a/app/Http/Controllers/Api/Remote/ActivityProcessingController.php b/app/Http/Controllers/Api/Remote/ActivityProcessingController.php index b88d7ae7a..33cee93ca 100644 --- a/app/Http/Controllers/Api/Remote/ActivityProcessingController.php +++ b/app/Http/Controllers/Api/Remote/ActivityProcessingController.php @@ -1,90 +1,17 @@ getTimezone(); - - /** @var \Pterodactyl\Models\Node $node */ - $node = $request->attributes->get('node'); - - $servers = $node->servers()->whereIn('uuid', $request->servers())->get()->keyBy('uuid'); - $users = User::query()->whereIn('uuid', $request->users())->get()->keyBy('uuid'); - - $logs = []; - foreach ($request->input('data') as $datum) { - /** @var Server|null $server */ - $server = $servers->get($datum['server']); - if (is_null($server) || !Str::startsWith($datum['event'], 'server:')) { - continue; - } - - try { - $when = Carbon::createFromFormat( - \DateTimeInterface::RFC3339, - preg_replace('/(\.\d+)Z$/', 'Z', $datum['timestamp']), - 'UTC' - ); - } catch (\Exception $exception) { - Log::warning($exception, ['timestamp' => $datum['timestamp']]); - - // If we cannot parse the value for some reason don't blow up this request, just go ahead - // and log the event with the current time, and set the metadata value to have the original - // timestamp that was provided. - $when = Carbon::now(); - $datum['metadata'] = array_merge($datum['metadata'] ?? [], ['original_timestamp' => $datum['timestamp']]); - } - - $log = [ - 'ip' => empty($datum['ip']) ? '127.0.0.1' : $datum['ip'], - 'event' => $datum['event'], - 'properties' => json_encode($datum['metadata'] ?? []), - // We have to change the time to the current timezone due to the way Laravel is handling - // the date casting internally. If we just leave it in UTC it ends up getting double-cast - // and the time is way off. - 'timestamp' => $when->setTimezone($tz), - ]; - - if ($user = $users->get($datum['user'])) { - $log['actor_id'] = $user->id; - $log['actor_type'] = $user->getMorphClass(); - } - - if (!isset($logs[$datum['server']])) { - $logs[$datum['server']] = []; - } - - $logs[$datum['server']][] = $log; - } - - foreach ($logs as $key => $data) { - Assert::isInstanceOf($server = $servers->get($key), Server::class); - - $batch = []; - foreach ($data as $datum) { - $id = ActivityLog::insertGetId($datum); - $batch[] = [ - 'activity_log_id' => $id, - 'subject_id' => $server->id, - 'subject_type' => $server->getMorphClass(), - ]; - } - - ActivityLogSubject::insert($batch); - } + $ingestion->ingest($request->node(), $request->events()); } } diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php b/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php index 6d8865fd2..e119a0bb8 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php @@ -1,134 +1,50 @@ attributes->get('node'); + $node = RemoteRequestNode::get($request); // Get the size query parameter. - $size = (int) $request->query('size'); - if (empty($size)) { - throw new BadRequestHttpException('A non-empty "size" query parameter must be provided.'); - } + $size = $request->integer('size'); + throw_if(empty($size), BadRequestHttpException::class, 'A non-empty "size" query parameter must be provided.'); $model = Backup::query()->where('uuid', $backup)->firstOrFail(); // Check that the backup is "owned" by the node making the request. This avoids other nodes // from messing with backups that they don't own. $server = $model->server; - if ($server->node_id !== $node->id) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } + throw_if($server->node_id !== $node->id, HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); // Prevent backups that have already been completed from trying to // be uploaded again. - if (!is_null($model->completed_at)) { - throw new ConflictHttpException('This backup is already in a completed state.'); - } + throw_if(($model->completed_at) !== null, ConflictHttpException::class, 'This backup is already in a completed state.'); - // Ensure we are using the S3 adapter. - $adapter = $this->backupManager->adapter(); - if (!$adapter instanceof S3Filesystem) { - throw new BadRequestHttpException('The configured backup adapter is not an S3 compatible adapter.'); - } - - // The path where backup will be uploaded to - $path = sprintf('%s/%s.tar.gz', $model->server->uuid, $model->uuid); - - // Get the S3 client - $client = $adapter->getClient(); - $expires = CarbonImmutable::now()->addMinutes(config('backups.presigned_url_lifespan', 60)); - - // Params for generating the presigned urls - $params = [ - 'Bucket' => $adapter->getBucket(), - 'Key' => $path, - 'ContentType' => 'application/x-gzip', - ]; - - $storageClass = config('backups.disks.s3.storage_class'); - if (!is_null($storageClass)) { - $params['StorageClass'] = $storageClass; - } - - // Execute the CreateMultipartUpload request - $result = $client->execute($client->getCommand('CreateMultipartUpload', $params)); - - // Get the UploadId from the CreateMultipartUpload request, this is needed to create - // the other presigned urls. - $params['UploadId'] = $result->get('UploadId'); - - // Retrieve configured part size - $maxPartSize = $this->getConfiguredMaxPartSize(); - - // Create as many UploadPart presigned urls as needed - $parts = []; - for ($i = 0; $i < ($size / $maxPartSize); ++$i) { - $parts[] = $client->createPresignedRequest( - $client->getCommand('UploadPart', array_merge($params, ['PartNumber' => $i + 1])), - $expires - )->getUri()->__toString(); - } - - // Set the upload_id on the backup in the database. - $model->update(['upload_id' => $params['UploadId']]); - - return new JsonResponse([ - 'parts' => $parts, - 'part_size' => $maxPartSize, - ]); - } - - /** - * Get the configured maximum size of a single part in the multipart upload. - * - * The function tries to retrieve a configured value from the configuration. - * If no value is specified, a fallback value will be used. - * - * Note if the received config cannot be converted to int (0), is zero or is negative, - * the fallback value will be used too. - * - * The fallback value is {@see BackupRemoteUploadController::DEFAULT_MAX_PART_SIZE}. - */ - private function getConfiguredMaxPartSize(): int - { - $maxPartSize = (int) config('backups.max_part_size', self::DEFAULT_MAX_PART_SIZE); - if ($maxPartSize <= 0) { - $maxPartSize = self::DEFAULT_MAX_PART_SIZE; - } - - return $maxPartSize; + return new JsonResponse($presignBackupUpload->presign($model, $size)); } } diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php index aede7fae1..7504111a5 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php @@ -1,108 +1,49 @@ attributes->get('node'); + $node = RemoteRequestNode::get($request); - /** @var Backup $model */ $model = Backup::query() ->where('uuid', $backup) ->firstOrFail(); // Check that the backup is "owned" by the node making the request. This avoids other nodes // from messing with backups that they don't own. - /** @var \Pterodactyl\Models\Server $server */ $server = $model->server; - if ($server->node_id !== $node->id) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } + throw_if($server->node_id !== $node->id, HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); - if ($model->is_successful) { - throw new BadRequestHttpException('Cannot update the status of a backup that is already marked as completed.'); - } + throw_if($model->is_successful, BadRequestHttpException::class, 'Cannot update the status of a backup that is already marked as completed.'); - $action = $request->boolean('successful') ? 'server:backup.complete' : 'server:backup.fail'; - $log = Activity::event($action)->subject($model, $model->server)->property('name', $model->name); + $data = $request->payload(); - $log->transaction(function () use ($model, $request) { - $successful = $request->boolean('successful'); + $completeBackup->complete($model, $data); - $model->fill([ - 'is_successful' => $successful, - // Change the lock state to unlocked if this was a failed backup so that it can be - // deleted easily. Also does not make sense to have a locked backup on the system - // that is failed. - 'is_locked' => $successful ? $model->is_locked : false, - 'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null, - 'bytes' => $successful ? $request->input('size') : 0, - 'completed_at' => CarbonImmutable::now(), - ])->save(); - - // Check if we are using the s3 backup adapter. If so, make sure we mark the backup as - // being completed in S3 correctly. - $adapter = $this->backupManager->adapter(); - if ($adapter instanceof S3Filesystem) { - $this->completeMultipartUpload($model, $adapter, $successful, $request->input('parts')); - } - }); - - return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); - } - - /** - * Handles toggling the restoration status of a server. The server status field should be - * set back to null, even if the restoration failed. This is not an unsolvable state for - * the server, and the user can keep trying to restore, or just use the reinstall button. - * - * The only thing the successful field does is update the entry value for the audit logs - * table tracking for this restoration. - * - * @throws \Throwable - */ - public function restore(Request $request, string $backup): JsonResponse - { - /** @var Backup $model */ - $model = Backup::query()->where('uuid', $backup)->firstOrFail(); - - $node = $request->attributes->get('node'); - if (! $model->server->node->is($node)) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } - - $model->server->update(['status' => null]); - - Activity::event($request->boolean('successful') ? 'server:backup.restore-complete' : 'server.backup.restore-failed') + Activity::event($data['successful'] ? 'server:backup.complete' : 'server:backup.fail') ->subject($model, $model->server) ->property('name', $model->name) ->log(); @@ -111,56 +52,23 @@ class BackupStatusController extends Controller } /** - * Marks a multipart upload in a given S3-compatible instance as failed or successful for - * the given backup. + * Resets the server status to null after a restore attempt - even a failed restore is + * recoverable by retrying or reinstalling, and the successful flag only selects which + * activity log event is recorded. * - * @throws \Exception - * @throws DisplayException + * @throws Throwable */ - protected function completeMultipartUpload(Backup $backup, S3Filesystem $adapter, bool $successful, ?array $parts): void + public function restore(ReportBackupRestoreRequest $request, RestoresBackupStatuses $restoreStatus, string $backup): JsonResponse { - // This should never really happen, but if it does don't let us fall victim to Amazon's - // wildly fun error messaging. Just stop the process right here. - if (empty($backup->upload_id)) { - // A failed backup doesn't need to error here, this can happen if the backup encounters - // an error before we even start the upload. AWS gives you tooling to clear these failed - // multipart uploads as needed too. - if (!$successful) { - return; - } + $model = $restoreStatus->restoreStatus($backup, RemoteRequestNode::get($request)); - throw new DisplayException('Cannot complete backup request: no upload_id present on model.'); - } + $successful = $request->payload()['successful']; - $params = [ - 'Bucket' => $adapter->getBucket(), - 'Key' => sprintf('%s/%s.tar.gz', $backup->server->uuid, $backup->uuid), - 'UploadId' => $backup->upload_id, - ]; + Activity::event($successful ? 'server:backup.restore-complete' : 'server:backup.restore-failed') + ->subject($model, $model->server) + ->property('name', $model->name) + ->log(); - $client = $adapter->getClient(); - if (!$successful) { - $client->execute($client->getCommand('AbortMultipartUpload', $params)); - - return; - } - - // Otherwise send a CompleteMultipartUpload request. - $params['MultipartUpload'] = [ - 'Parts' => [], - ]; - - if (is_null($parts)) { - $params['MultipartUpload']['Parts'] = $client->execute($client->getCommand('ListParts', $params))['Parts']; - } else { - foreach ($parts as $part) { - $params['MultipartUpload']['Parts'][] = [ - 'ETag' => $part['etag'], - 'PartNumber' => $part['part_number'], - ]; - } - } - - $client->execute($client->getCommand('CompleteMultipartUpload', $params)); + return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } } diff --git a/app/Http/Controllers/Api/Remote/EggInstallController.php b/app/Http/Controllers/Api/Remote/EggInstallController.php deleted file mode 100644 index 31df7a96c..000000000 --- a/app/Http/Controllers/Api/Remote/EggInstallController.php +++ /dev/null @@ -1,51 +0,0 @@ -attributes->get('node'); - - /** @var \Pterodactyl\Models\Server $server */ - $server = $this->repository->findFirstWhere([ - ['uuid', '=', $uuid], - ['node_id', '=', $node->id], - ]); - - $this->repository->loadEggRelations($server); - $egg = $server->getRelation('egg'); - - return response()->json([ - 'scripts' => [ - 'install' => !$egg->copy_script_install ? null : str_replace(["\r\n", "\n", "\r"], "\n", $egg->copy_script_install), - 'privileged' => $egg->script_is_privileged, - ], - 'config' => [ - 'container' => $egg->copy_script_container, - 'entry' => $egg->copy_script_entry, - ], - 'env' => $this->environment->handle($server), - ]); - } -} diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php index 26e28ae37..4bd263577 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php @@ -1,45 +1,32 @@ attributes->get('node'), Node::class); + $node = RemoteRequestNode::get($request); - $server = $this->repository->getByUuid($uuid); + $server = Server::query()->with('node')->whereUuidOrShort($uuid)->firstOrFail(); $transfer = $server->transfer; // If the server is being transferred allow either node to request information about @@ -49,33 +36,30 @@ class ServerDetailsController extends Controller ? $node->id === $transfer->old_node || $node->id === $transfer->new_node : $node->id === $server->node_id; - if (! $valid) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } + throw_unless($valid, HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); return new JsonResponse([ - 'settings' => $this->configurationStructureService->handle($server), - 'process_configuration' => $this->eggConfigurationService->handle($server), + 'settings' => $configuration->handle($server), + 'process_configuration' => $eggConfiguration->handle($server), ]); } /** * Lists all servers with their configurations that are assigned to the requesting node. */ - public function list(Request $request): ServerConfigurationCollection + public function list(Request $request, ServerConfigurationStructureService $configuration, EggConfigurationService $eggConfiguration): JsonResponse { - /** @var Node $node */ - $node = $request->attributes->get('node'); + $node = RemoteRequestNode::get($request); // Avoid run-away N+1 SQL queries by preloading the relationships that are used // within each of the services called below. - $servers = Server::query()->with('allocations', 'egg', 'mounts', 'variables', 'location') + $servers = Server::query()->with('allocations', 'egg.variables', 'egg.configFrom', 'serverVariables', 'mounts', 'location') ->where('node_id', $node->id) // If you don't cast this to a string you'll end up with a stringified per_page returned in // the metadata, and then Wings will panic crash as a result. - ->paginate((int) $request->input('per_page', 50)); + ->paginate($request->integer('per_page', 50)); - return new ServerConfigurationCollection($servers); + return (new ServerConfigurationCollection($servers, $eggConfiguration, $configuration))->response(); } /** @@ -84,51 +68,11 @@ class ServerDetailsController extends Controller * do not get incorrectly stuck in installing/restoring from backup states since * a Wings reboot would completely stop those processes. * - * @throws \Throwable + * @throws Throwable */ - public function resetState(Request $request): JsonResponse + public function resetState(Request $request, ResetsServerStates $states): JsonResponse { - $node = $request->attributes->get('node'); - - // Get all the servers that are currently marked as restoring from a backup - // on this node that do not have a failed backup tracked in the audit logs table - // as well. - // - // For each of those servers we'll track a new audit log entry to mark them as - // failed and then update them all to be in a valid state. - $servers = Server::query() - ->with([ - 'activity' => fn ($builder) => $builder - ->where('activity_logs.event', 'server:backup.restore-started') - ->latest('timestamp'), - ]) - ->where('node_id', $node->id) - ->where('status', Server::STATUS_RESTORING_BACKUP) - ->get(); - - $this->connection->transaction(function () use ($node, $servers) { - /** @var Server $server */ - foreach ($servers as $server) { - /** @var \Pterodactyl\Models\ActivityLog|null $activity */ - $activity = $server->activity->first(); - if (!is_null($activity)) { - if ($subject = $activity->subjects->where('subject_type', 'backup')->first()) { - // Just create a new audit entry for this event and update the server state - // so that power actions, file management, and backups can resume as normal. - Activity::event('server:backup.restore-failed') - ->subject($server, $subject->subject) - ->property('name', $subject->subject->name) // @phpstan-ignore property.notFound - ->log(); - } - } - } - - // Update any server marked as installing or restoring as being in a normal state - // at this point in the process. - Server::query()->where('node_id', $node->id) - ->whereIn('status', [Server::STATUS_INSTALLING, Server::STATUS_RESTORING_BACKUP]) - ->update(['status' => null]); - }); + $states->reset(RemoteRequestNode::get($request)); return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); } diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php index e97fdb871..c821e07d3 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php @@ -1,88 +1,41 @@ repository->getByUuid($uuid); - $egg = $server->egg; - - if (! $server->node->is($request->attributes->get('node'))) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } - - return new JsonResponse([ - 'container_image' => $egg->copy_script_container, - 'entrypoint' => $egg->copy_script_entry, - 'script' => $egg->copy_script_install, - ]); + return new JsonResponse($install->info($request, $uuid)); } /** * Updates the installation state of a server. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function store(InstallationDataRequest $request, string $uuid): JsonResponse + public function store(InstallationDataRequest $request, RecordsServerInstallResults $installResult, string $uuid): JsonResponse { - $server = $this->repository->getByUuid($uuid); - $status = null; + $validated = $request->validated(); - if (! $server->node->is($request->attributes->get('node'))) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } - - // Make sure the type of failure is accurate - if (!$request->boolean('successful')) { - $status = Server::STATUS_INSTALL_FAILED; - - if ($request->boolean('reinstall')) { - $status = Server::STATUS_REINSTALL_FAILED; - } - } - - // Keep the server suspended if it's already suspended - if ($server->status === Server::STATUS_SUSPENDED) { - $status = Server::STATUS_SUSPENDED; - } - - $this->repository->update($server->id, ['status' => $status, 'installed_at' => CarbonImmutable::now()], true, true); - - // If the server successfully installed, fire installed event. - // This logic allows individually disabling install and reinstall notifications separately. - $isInitialInstall = is_null($server->installed_at); - if ($isInitialInstall && config()->get('pterodactyl.email.send_install_notification', true)) { - $this->eventDispatcher->dispatch(new ServerInstalled($server)); - } elseif (!$isInitialInstall && config()->get('pterodactyl.email.send_reinstall_notification', true)) { - $this->eventDispatcher->dispatch(new ServerInstalled($server)); - } + $installResult->record( + $request, + $uuid, + JsonValueGuard::boolean($validated['successful'] ?? false), + JsonValueGuard::boolean($validated['reinstall'] ?? false), + ); return new JsonResponse([], Response::HTTP_NO_CONTENT); } diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php index 02311bead..3e34a8cc1 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php @@ -1,129 +1,62 @@ repository->getByUuid($uuid); - $transfer = $server->transfer; - if (is_null($transfer)) { - throw new ConflictHttpException('Server is not being transferred.'); - } + $transfer = $this->activeTransfer($uuid); - /* @var Node $node */ - Assert::isInstanceOf($node = $request->attributes->get('node'), Node::class); + $node = RemoteRequestNode::get($request); + throw_if(! $node->is($transfer->newNode) && ! $node->is($transfer->oldNode), HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); - // Either node can tell the panel that the transfer has failed. Only the new node - // can tell the panel that it was successful. - if (! $node->is($transfer->newNode) && ! $node->is($transfer->oldNode)) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } - - return $this->processFailedTransfer($transfer); - } - - /** - * The daemon notifies us about a transfer success. - * - * @throws \Throwable - */ - public function success(Request $request, string $uuid): JsonResponse - { - $server = $this->repository->getByUuid($uuid); - $transfer = $server->transfer; - if (is_null($transfer)) { - throw new ConflictHttpException('Server is not being transferred.'); - } - - /* @var Node $node */ - Assert::isInstanceOf($node = $request->attributes->get('node'), Node::class); - - // Only the new node communicates a successful state to the panel, so we should - // not allow the old node to hit this endpoint. - if (! $node->is($transfer->newNode)) { - throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); - } - - /** @var \Pterodactyl\Models\Server $server */ - $server = $this->connection->transaction(function () use ($server, $transfer) { - $allocations = array_merge([$transfer->old_allocation], $transfer->old_additional_allocations); - - // Remove the old allocations for the server and re-assign the server to the new - // primary allocation and node. - Allocation::query()->whereIn('id', $allocations)->update(['server_id' => null]); - $server->update([ - 'allocation_id' => $transfer->new_allocation, - 'node_id' => $transfer->new_node, - ]); - - $server = $server->fresh(); - $server->transfer->update(['successful' => true]); - - return $server; - }); - - // Delete the server from the old node making sure to point it to the old node so - // that we do not delete it from the new node the server was transferred to. - try { - $this->daemonServerRepository - ->setServer($server) - ->setNode($transfer->oldNode) - ->delete(); - } catch (DaemonConnectionException $exception) { - Log::warning($exception, ['transfer_id' => $server->transfer->id]); - } + $transfers->fail($transfer); return new JsonResponse([], Response::HTTP_NO_CONTENT); } /** - * Release all the reserved allocations for this transfer and mark it as failed in - * the database. + * The daemon notifies us about a transfer success. Only the new node may report it. * - * @throws \Throwable + * @throws Throwable */ - protected function processFailedTransfer(ServerTransfer $transfer): JsonResponse + public function success(Request $request, CompletesTransfers $transfers, string $uuid): JsonResponse { - $this->connection->transaction(function () use (&$transfer) { - $transfer->forceFill(['successful' => false])->saveOrFail(); + $transfer = $this->activeTransfer($uuid); - $allocations = array_merge([$transfer->new_allocation], $transfer->new_additional_allocations); - Allocation::query()->whereIn('id', $allocations)->update(['server_id' => null]); - }); + $node = RemoteRequestNode::get($request); + throw_unless($node->is($transfer->newNode), HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); + + $transfers->complete($transfer); return new JsonResponse([], Response::HTTP_NO_CONTENT); } + + private function activeTransfer(string $uuid): ServerTransfer + { + $server = Server::query()->with('node')->whereUuidOrShort($uuid)->firstOrFail(); + + return $server->transfer ?? throw new ConflictHttpException('Server is not being transferred.'); + } } diff --git a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php index 6db0d45df..89293d16e 100644 --- a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php +++ b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php @@ -1,45 +1,47 @@ parseUsername($request->input('username')); - if (empty($connection['server'])) { - throw new BadRequestHttpException('No valid server identifier was included in the request.'); - } + $connection = $this->parseUsername(JsonValueGuard::string($request->validated('username'))); + throw_if(empty($connection['server']), BadRequestHttpException::class, 'No valid server identifier was included in the request.'); if ($this->hasTooManyLoginAttempts($request)) { - $seconds = $this->limiter()->availableIn($this->throttleKey($request)); + $seconds = RateLimiter::availableIn($this->throttleKey($request)); throw new TooManyRequestsHttpException($seconds, "Too many login attempts for this account, please try again in $seconds seconds."); } @@ -47,38 +49,36 @@ class SftpAuthenticationController extends Controller $user = $this->getUser($request, $connection['username']); $server = $this->getServer($request, $connection['server']); - if ($request->input('type') !== 'public_key') { - if (!password_verify($request->input('password'), $user->password)) { + if ($request->validated('type') !== 'public_key') { + if (! Hash::check(JsonValueGuard::string($request->validated('password')), $user->password)) { Activity::event('auth:sftp.fail')->property('method', 'password')->subject($user)->log(); $this->reject($request); } } else { $key = null; - try { - $key = PublicKeyLoader::loadPublicKey(trim($request->input('password'))); - } catch (NoKeyLoadedException) { - // do nothing + $publicKey = mb_trim(JsonValueGuard::string($request->validated('password'))); + if (UserSSHKeyRules::isSupportedPublicKey($publicKey)) { + try { + $key = PublicKeyLoader::loadPublicKey($publicKey); + } catch (NoKeyLoadedException) { + // do nothing + } } - if (!$key || !$user->sshKeys()->where('fingerprint', $key->getFingerprint('sha256'))->exists()) { - // We don't log here because of the way the SFTP system works. This endpoint - // will get hit for every key the user provides, which could be 4 or 5. That is - // a lot of unnecessary log noise. - // - // For now, we'll only log failures due to a bad password as those are not likely - // to occur more than once in a session for the user, and are more likely to be of - // value to the end user. - $this->reject($request, is_null($key)); + if (! $key || ! $user->sshKeys()->where('fingerprint', $key->getFingerprint('sha256'))->exists()) { + // Don't log public key failures - this endpoint is hit once for every key the + // user offers, so only the (rarer, more meaningful) bad-password failures are logged. + $this->reject($request, ($key) === null); } } - $this->validateSftpAccess($user, $server); + $this->validateSftpAccess($user, $server, $permissions); return new JsonResponse([ 'user' => $user->uuid, 'server' => $server->uuid, - 'permissions' => $this->permissions->handle($server, $user), + 'permissions' => $permissions->handle($server, $user), ]); } @@ -88,12 +88,12 @@ class SftpAuthenticationController extends Controller */ protected function getServer(Request $request, string $uuid): Server { - return Server::query() - ->where(fn ($builder) => $builder->where('uuid', $uuid)->orWhere('uuidShort', $uuid)) - ->where('node_id', $request->attributes->get('node')->id) - ->firstOr(function () use ($request) { - $this->reject($request); - }); + $server = Server::query() + ->where(fn (Builder $builder) => $builder->where('uuid', $uuid)->orWhere('uuidShort', $uuid)) + ->where('node_id', RemoteRequestNode::get($request)->id) + ->first(); + + return $server ?? $this->reject($request); } /** @@ -101,9 +101,9 @@ class SftpAuthenticationController extends Controller */ protected function getUser(Request $request, string $username): User { - return User::query()->where('username', $username)->firstOr(function () use ($request) { - $this->reject($request); - }); + $user = User::query()->where('username', $username)->first(); + + return $user ?? $this->reject($request); } /** @@ -118,15 +118,15 @@ class SftpAuthenticationController extends Controller // Unreverse the strings after parsing them apart. return [ - 'username' => strrev(array_get($parts, 1)), - 'server' => strrev(array_get($parts, 0)), + 'username' => strrev($parts[1] ?? ''), + 'server' => strrev($parts[0]), ]; } /** * Rejects the request and increments the login attempts. */ - protected function reject(Request $request, bool $increment = true): void + protected function reject(Request $request, bool $increment = true): never { if ($increment) { $this->incrementLoginAttempts($request); @@ -138,12 +138,12 @@ class SftpAuthenticationController extends Controller /** * Validates that a user should have permission to use SFTP for the given server. */ - protected function validateSftpAccess(User $user, Server $server): void + protected function validateSftpAccess(User $user, Server $server, GetUserPermissionsService $permissions): void { - if (!$user->root_admin && $server->owner_id !== $user->id) { - $permissions = $this->permissions->handle($server, $user); + if (! $user->root_admin && $server->owner_id !== $user->id) { + $resolved = $permissions->handle($server, $user); - if (!in_array(Permission::ACTION_FILE_SFTP, $permissions)) { + if (! in_array(Permissions::FileSftp->value, $resolved)) { Activity::event('server:sftp.denied')->actor($user)->subject($server)->log(); throw new HttpForbiddenException('You do not have permission to access SFTP for this server.'); @@ -158,8 +158,9 @@ class SftpAuthenticationController extends Controller */ protected function throttleKey(Request $request): string { - $username = explode('.', strrev($request->input('username', ''))); + $raw = JsonValueGuard::nullableString($request->input('username', '')) ?? ''; + $username = explode('.', strrev($raw)); - return strtolower(strrev($username[0] ?? '') . '|' . $request->ip()); // @phpstan-ignore nullCoalesce.offset + return mb_strtolower(strrev($username[0] ?? '').'|'.$request->ip()); // @phpstan-ignore nullCoalesce.offset } } diff --git a/app/Http/Controllers/Auth/AbstractLoginController.php b/app/Http/Controllers/Auth/AbstractLoginController.php index 11d3744c0..50c526407 100644 --- a/app/Http/Controllers/Auth/AbstractLoginController.php +++ b/app/Http/Controllers/Auth/AbstractLoginController.php @@ -1,66 +1,37 @@ lockoutTime = config('auth.lockout.time'); - $this->maxLoginAttempts = config('auth.lockout.attempts'); - $this->auth = Container::getInstance()->make(AuthManager::class); - } + use ThrottlesLogins; /** * Get the failed login response instance. * - * @return never-return - * * @throws DisplayException */ - protected function sendFailedLoginResponse(Request $request, ?Authenticatable $user = null, ?string $message = null) + protected function sendFailedLoginResponse(Request $request, ?Authenticatable $user = null, ?string $message = null): never { $this->incrementLoginAttempts($request); + $login = $request->string('user')->toString(); $this->fireFailedLoginEvent($user, [ - $this->getField($request->input('user')) => $request->input('user'), + $this->getField($login) => $login, ]); - if ($request->route()->named('auth.login-checkpoint')) { + if ($request->route()?->named('auth.login-checkpoint')) { throw new DisplayException($message ?? trans('auth.two_factor.checkpoint_failed')); } @@ -68,26 +39,17 @@ abstract class AbstractLoginController extends Controller } /** - * Send the response after the user was authenticated. + * Send the response for a completed login step. The throttle is only + * reset once a session exists, so a pending two-factor checkpoint keeps + * counting failed attempts. */ - protected function sendLoginResponse(User $user, Request $request): JsonResponse + protected function sendLoginResponse(LoginResult $result, Request $request): JsonResponse { - $request->session()->remove('auth_confirmation_token'); - $request->session()->regenerate(); + if ($result->complete) { + $this->clearLoginAttempts($request); + } - $this->clearLoginAttempts($request); - - $this->auth->guard()->login($user, true); - - Event::dispatch(new DirectLogin($user, true)); - - return new JsonResponse([ - 'data' => [ - 'complete' => true, - 'intended' => $this->redirectPath(), - 'user' => $user->toVueObject(), - ], - ]); + return new JsonResponse(['data' => $result->toResponseData()]); } /** @@ -100,8 +62,10 @@ abstract class AbstractLoginController extends Controller /** * Fire a failed login event. + * + * @param array $credentials */ - protected function fireFailedLoginEvent(?Authenticatable $user = null, array $credentials = []) + protected function fireFailedLoginEvent(?Authenticatable $user = null, array $credentials = []): void { Event::dispatch(new Failed('auth', $user, $credentials)); } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index d67b0de51..16405a1d8 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -1,27 +1,65 @@ 'We have emailed your password reset link.', + ]; + + private const array CAPTCHA_FAILED_ERROR = [ + 'errors' => [ + [ + 'code' => 'HttpException', + 'status' => '400', + 'detail' => 'Failed to validate reCAPTCHA data.', + ], + ], + ]; + + #[Unauthenticated] + #[Endpoint('Request password reset email', 'Sends a password reset email when the account exists. The response is intentionally the same when no matching account is found.')] + #[BodyParam('email', 'string', 'The account email address.', required: true, example: 'admin@example.com')] + #[BodyParam('g-recaptcha-response', 'string', 'The reCAPTCHA token when reCAPTCHA is enabled.', required: false, example: '03AFcWeA...', nullable: true)] + #[ScribeResponse(self::RESET_LINK_SENT_EXAMPLE, description: 'Password reset email accepted.')] + #[ScribeResponse(self::CAPTCHA_FAILED_ERROR, status: 400, description: 'The reCAPTCHA token is invalid or missing.')] + public function sendResetLinkEmail(Request $request): JsonResponse + { + $request->validate(['email' => ['required', 'email']]); + + $response = Password::broker()->sendResetLink($request->only('email')); + + return $response === Password::RESET_LINK_SENT + ? $this->sendResetLinkResponse($request, $response) + : $this->sendResetLinkFailedResponse($request, $response); + } /** * Get the response for a failed password reset link. + * + * @param string $response */ - protected function sendResetLinkFailedResponse(Request $request, $response): JsonResponse + protected function sendResetLinkFailedResponse(Request $request, $response): JsonResponse // @pest-ignore-type { // As noted in #358 we will return success even if it failed // to avoid pointing out that an account does or does not // exist on the system. - event(new FailedPasswordReset($request->ip(), $request->input('email'))); + event(new FailedPasswordReset($request->ip() ?? 'unknown', $request->string('email')->toString())); return $this->sendResetLinkResponse($request, Password::RESET_LINK_SENT); } @@ -29,9 +67,9 @@ class ForgotPasswordController extends Controller /** * Get the response for a successful password reset link. * - * @param string $response + * @param string $response */ - protected function sendResetLinkResponse(Request $request, $response): JsonResponse + protected function sendResetLinkResponse(Request $request, $response): JsonResponse // @pest-ignore-type { return response()->json([ 'status' => trans($response), diff --git a/app/Http/Controllers/Auth/LoginCheckpointController.php b/app/Http/Controllers/Auth/LoginCheckpointController.php index ed212e455..9e5a0d28e 100644 --- a/app/Http/Controllers/Auth/LoginCheckpointController.php +++ b/app/Http/Controllers/Auth/LoginCheckpointController.php @@ -1,109 +1,154 @@ [ + 'complete' => true, + 'intended' => '/', + 'user' => [ + 'uuid' => '9a8b7c6d-5e4f-4321-9876-123456789abc', + 'username' => 'admin', + 'email' => 'admin@example.com', + 'name_first' => 'Admin', + 'name_last' => 'User', + 'language' => 'en', + 'root_admin' => true, + 'use_totp' => true, + 'created_at' => '2026-06-29T12:00:00+00:00', + 'updated_at' => '2026-06-29T12:00:00+00:00', + 'identifier' => 'usr_1a2b3c4d', + ], + ], + ]; + + private const array CHECKPOINT_FAILED_ERROR = [ + 'errors' => [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'The authentication token provided has expired, please refresh the page and try again.', + ], + ], + ]; /** * Handle a login where the user is required to provide a TOTP authentication * token. Once a user has reached this stage it is assumed that they have already * provided a valid username and password. * - * @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException - * @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException - * @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException - * @throws \Exception - * @throws \Illuminate\Validation\ValidationException + * @throws IncompatibleWithGoogleAuthenticatorException + * @throws InvalidCharactersException + * @throws SecretKeyTooShortException + * @throws Exception + * @throws ValidationException */ - public function __invoke(LoginCheckpointRequest $request): JsonResponse + #[Unauthenticated] + #[Endpoint('Complete login checkpoint', 'Completes a two-factor login checkpoint using either a TOTP code or a recovery token.')] + #[BodyParam('confirmation_token', 'string', 'The confirmation token returned by the login endpoint.', required: true, example: 'b6e22f85d63c4d9db9739f9ab0a27a48f51f7ad38ef8c12fd157c4c6f4b2e51d')] + #[BodyParam('authentication_code', 'string', 'The six-digit TOTP code. Required when recovery_token is not provided.', required: false, example: '123456', nullable: true)] + #[BodyParam('recovery_token', 'string', 'A recovery token. Required when authentication_code is not provided.', required: false, example: 'r1a2b3c4d5', nullable: true)] + #[ScribeResponse(self::LOGIN_COMPLETE_EXAMPLE, description: 'Login completed and a browser session was created.')] + #[ScribeResponse(self::CHECKPOINT_FAILED_ERROR, status: 400, description: 'The checkpoint token, TOTP code, or recovery token is invalid.')] + public function __invoke(LoginCheckpointRequest $request, CompletesLogins $logins, Google2FA $google2FA, Encrypter $encrypter): JsonResponse { if ($this->hasTooManyLoginAttempts($request)) { $this->sendLockoutResponse($request); } - $details = $request->session()->get('auth_confirmation_token'); - if (!$this->hasValidSessionData($details)) { + $checkpoint = $logins->pendingCheckpoint(); + if (! $checkpoint instanceof LoginCheckpoint) { $this->sendFailedLoginResponse($request, null, self::TOKEN_EXPIRED_MESSAGE); } - if (!hash_equals($request->input('confirmation_token') ?? '', $details['token_value'])) { + if (! $checkpoint->matches(JsonValueGuard::nullableString($request->validated('confirmation_token')) ?? '')) { $this->sendFailedLoginResponse($request); } try { - $user = User::query()->findOrFail($details['user_id']); + $user = User::query()->findOrFail($checkpoint->userId); } catch (ModelNotFoundException) { $this->sendFailedLoginResponse($request, null, self::TOKEN_EXPIRED_MESSAGE); } // Recovery tokens go through a slightly different pathway for usage. - if (!is_null($recoveryToken = $request->input('recovery_token'))) { - if ($this->isValidRecoveryToken($user, $recoveryToken)) { + if (($recoveryToken = $request->validated('recovery_token')) !== null) { + if ($this->isValidRecoveryToken($user, JsonValueGuard::string($recoveryToken))) { Event::dispatch(new ProvidedAuthenticationToken($user, true)); - return $this->sendLoginResponse($user, $request); + return $this->sendLoginResponse($logins->establish($user), $request); } } else { - $decrypted = $this->encrypter->decrypt($user->totp_secret); + $totpSecret = $user->totp_secret; + if ($totpSecret === null) { + $this->sendFailedLoginResponse($request, $user, self::TOKEN_EXPIRED_MESSAGE); + } + + $decrypted = JsonValueGuard::string($encrypter->decrypt($totpSecret)); + // SAFETY: TOTP counters are discrete intervals, so flooring and converting the quotient to an integer is required. $oldTimestamp = $user->totp_authenticated_at - ? (int) floor($user->totp_authenticated_at->unix() / $this->google2FA->getKeyRegeneration()) + ? (int) floor($user->totp_authenticated_at->unix() / $google2FA->getKeyRegeneration()) : null; - $verified = $this->google2FA->verifyKeyNewer( + $verified = $google2FA->verifyKeyNewer( $decrypted, - $request->input('authentication_code') ?? '', + JsonValueGuard::nullableString($request->validated('authentication_code')) ?? '', $oldTimestamp, - config('pterodactyl.auth.2fa.window') ?? 1, + JsonValueGuard::integer(config('pterodactyl.auth.2fa.window', 1)) ); if ($verified !== false) { - $user->update(['totp_authenticated_at' => Carbon::now()]); + $user->update(['totp_authenticated_at' => now()]); Event::dispatch(new ProvidedAuthenticationToken($user)); - return $this->sendLoginResponse($user, $request); + return $this->sendLoginResponse($logins->establish($user), $request); } } - $this->sendFailedLoginResponse($request, $user, !empty($recoveryToken) ? 'The recovery token provided is not valid.' : null); + $this->sendFailedLoginResponse($request, $user, ! empty($recoveryToken) ? 'The recovery token provided is not valid.' : null); } /** * Determines if a given recovery token is valid for the user account. If we find a matching token * it will be deleted from the database. * - * @throws \Exception + * @throws Exception */ protected function isValidRecoveryToken(User $user, string $value): bool { foreach ($user->recoveryTokens as $token) { - if (password_verify($value, $token->token)) { + if (Hash::check($value, $token->token)) { $token->delete(); return true; @@ -112,32 +157,4 @@ class LoginCheckpointController extends AbstractLoginController return false; } - - /** - * Determines if the data provided from the session is valid or not. This - * will return false if the data is invalid, or if more time has passed than - * was configured when the session was written. - */ - protected function hasValidSessionData(?array $data): bool - { - $validator = $this->validation->make($data ?? [], [ - 'user_id' => 'required|integer|min:1', - 'token_value' => 'required|string', - 'expires_at' => 'required', - ]); - - if ($validator->fails()) { - return false; - } - - if (!$data['expires_at'] instanceof CarbonInterface) { - return false; - } - - if ($data['expires_at']->isBefore(CarbonImmutable::now())) { - return false; - } - - return true; - } } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 1ca321c1e..0a85f94ee 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -1,18 +1,76 @@ [ + 'complete' => true, + 'intended' => '/', + 'user' => [ + 'uuid' => '9a8b7c6d-5e4f-4321-9876-123456789abc', + 'username' => 'admin', + 'email' => 'admin@example.com', + 'name_first' => 'Admin', + 'name_last' => 'User', + 'language' => 'en', + 'root_admin' => true, + 'use_totp' => false, + 'created_at' => '2026-06-29T12:00:00+00:00', + 'updated_at' => '2026-06-29T12:00:00+00:00', + 'identifier' => 'usr_1a2b3c4d', + ], + ], + ]; + + private const array LOGIN_CHECKPOINT_EXAMPLE = [ + 'data' => [ + 'complete' => false, + 'confirmation_token' => 'b6e22f85d63c4d9db9739f9ab0a27a48f51f7ad38ef8c12fd157c4c6f4b2e51d', + ], + ]; + + private const array LOGIN_FAILED_ERROR = [ + 'errors' => [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'These credentials do not match our records.', + ], + ], + ]; + + private const array CAPTCHA_FAILED_ERROR = [ + 'errors' => [ + [ + 'code' => 'HttpException', + 'status' => '400', + 'detail' => 'Failed to validate reCAPTCHA data.', + ], + ], + ]; + /** * Handle all incoming requests for the authentication routes and render the * base authentication view component. React will take over at this point and @@ -23,25 +81,46 @@ class LoginController extends AbstractLoginController return view('templates/auth.core'); } + #[Endpoint('Logout', 'Destroys the current browser session and regenerates the CSRF token.')] + #[ScribeResponse(status: 204, description: 'The browser session was destroyed.')] + public function logout(Request $request): JsonResponse|RedirectResponse + { + Auth::guard()->logout(); + + $request->session()->invalidate(); + $request->session()->regenerateToken(); + + return $request->wantsJson() + ? new JsonResponse([], JsonResponse::HTTP_NO_CONTENT) + : new RedirectResponse('/'); + } + /** * Handle a login request to the application. * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Illuminate\Validation\ValidationException + * @throws DisplayException + * @throws ValidationException */ - public function login(Request $request): JsonResponse + #[Unauthenticated] + #[Endpoint('Login', 'Authenticates a browser session. Returns a complete login payload, or a two-factor checkpoint token when the account requires a second factor.')] + #[BodyParam('user', 'string', 'The account username or email address.', required: true, example: 'admin')] + #[BodyParam('password', 'string', 'The account password.', required: true, example: 'correct-horse-battery-staple')] + #[BodyParam('g-recaptcha-response', 'string', 'The reCAPTCHA token when reCAPTCHA is enabled.', required: false, example: '03AFcWeA...', nullable: true)] + #[ScribeResponse(self::LOGIN_COMPLETE_EXAMPLE, description: 'Login completed and a browser session was created.')] + #[ScribeResponse(self::LOGIN_CHECKPOINT_EXAMPLE, description: 'Two-factor checkpoint is required before login can complete.')] + #[ScribeResponse(self::LOGIN_FAILED_ERROR, status: 400, description: 'The credentials are invalid.')] + #[ScribeResponse(self::CAPTCHA_FAILED_ERROR, status: 400, description: 'The reCAPTCHA token is invalid or missing.')] + public function login(Request $request, CompletesLogins $logins): JsonResponse { if ($this->hasTooManyLoginAttempts($request)) { $this->fireLockoutEvent($request); $this->sendLockoutResponse($request); } - try { - $username = $request->input('user'); + $username = JsonValueGuard::nullableString($request->input('user')); - /** @var User $user */ - $user = User::query()->where($this->getField($username), $username)->firstOrFail(); - } catch (ModelNotFoundException) { + $user = User::query()->where($this->getField($username), $username)->first(); + if (($user) === null) { $this->sendFailedLoginResponse($request); } @@ -49,27 +128,10 @@ class LoginController extends AbstractLoginController // continue. Previously this was handled in the 2FA checkpoint, however that has // a flaw in which you can discover if an account exists simply by seeing if you // can proceed to the next step in the login process. - if (!password_verify($request->input('password'), $user->password)) { + if (! Hash::check(JsonValueGuard::string($request->input('password')), $user->password)) { $this->sendFailedLoginResponse($request, $user); } - if (!$user->use_totp) { - return $this->sendLoginResponse($user, $request); - } - - Activity::event('auth:checkpoint')->withRequestMetadata()->subject($user)->log(); - - $request->session()->put('auth_confirmation_token', [ - 'user_id' => $user->id, - 'token_value' => $token = Str::random(64), - 'expires_at' => CarbonImmutable::now()->addMinutes(5), - ]); - - return new JsonResponse([ - 'data' => [ - 'complete' => false, - 'confirmation_token' => $token, - ], - ]); + return $this->sendLoginResponse($logins->complete($user), $request); } } diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 343f33bca..e85676892 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -1,23 +1,45 @@ true, + 'redirect_to' => '/', + 'send_to_login' => false, + ]; + + private const array RESET_FAILED_ERROR = [ + 'errors' => [ + [ + 'code' => 'DisplayException', + 'status' => '400', + 'detail' => 'This password reset token is invalid.', + ], + ], + ]; /** * The URL to redirect users to after password reset. @@ -26,41 +48,36 @@ class ResetPasswordController extends Controller protected bool $hasTwoFactor = false; - /** - * ResetPasswordController constructor. - */ - public function __construct( - private Dispatcher $dispatcher, - private Hasher $hasher, - private UserRepositoryInterface $userRepository, - ) { - } - /** * Reset the given user's password. * * @throws DisplayException */ + #[Unauthenticated] + #[Endpoint('Reset password', 'Resets an account password using a password reset token. The response tells the frontend whether the user must return to the login form.')] + #[BodyParam('email', 'string', 'The account email address.', required: true, example: 'admin@example.com')] + #[BodyParam('token', 'string', 'The password reset token.', required: true, example: 'b6e22f85d63c4d9db9739f9ab0a27a48f51f7ad38ef8c12fd157c4c6f4b2e51d')] + #[BodyParam('password', 'string', 'The new account password. Must be at least eight characters.', required: true, example: 'correct-horse-battery-staple')] + #[BodyParam('password_confirmation', 'string', 'Confirmation matching the new account password.', required: true, example: 'correct-horse-battery-staple')] + #[ScribeResponse(self::RESET_COMPLETE_EXAMPLE, description: 'Password reset completed.')] + #[ScribeResponse(self::RESET_FAILED_ERROR, status: 400, description: 'The reset token is invalid or expired.')] public function __invoke(ResetPasswordRequest $request): JsonResponse { // Here we will attempt to reset the user's password. If it is successful we // will update the password on an actual user model and persist it to the // database. Otherwise, we will parse the error and return the response. - $response = $this->broker()->reset( - $this->credentials($request), - function ($user, $password) { + $response = Password::broker()->reset( + $request->only('email', 'password', 'password_confirmation', 'token'), + function (User $user, string $password): void { $this->resetPassword($user, $password); } ); - // If the password was successfully reset, we will redirect the user back to - // the application's home authenticated view. If there is an error we can - // redirect them back to where they came from with their error message. if ($response === Password::PASSWORD_RESET) { return $this->sendResetResponse(); } - throw new DisplayException(trans($response)); + throw new DisplayException(trans(JsonValueGuard::nullableString($response))); } /** @@ -68,26 +85,23 @@ class ResetPasswordController extends Controller * account do not automatically log them in. In those cases, send the user back to the login * form with a note telling them their password was changed and to log back in. * - * @param \Illuminate\Contracts\Auth\CanResetPassword&\Pterodactyl\Models\User $user - * @param string $password - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + * @param CanResetPassword&User $user + * @param string $password */ - protected function resetPassword($user, $password) + protected function resetPassword($user, $password): void // @pest-ignore-type { - $user = $this->userRepository->update($user->id, [ - 'password' => $this->hasher->make($password), + $user->forceFill([ + 'password' => $password, $user->getRememberTokenName() => Str::random(60), - ]); + ])->save(); - $this->dispatcher->dispatch(new PasswordReset($user)); - PasswordChanged::dispatch($user); + event(new PasswordReset($user)); + event(new PasswordChanged($user)); // If the user is not using 2FA log them in, otherwise skip this step and force a // fresh login where they'll be prompted to enter a token. - if (!$user->use_totp) { - $this->guard()->login($user); + if (! $user->use_totp) { + Auth::guard()->login($user); } $this->hasTwoFactor = $user->use_totp; diff --git a/app/Http/Controllers/Base/ExtensionFileController.php b/app/Http/Controllers/Base/ExtensionFileController.php new file mode 100644 index 000000000..eabf5fa0b --- /dev/null +++ b/app/Http/Controllers/Base/ExtensionFileController.php @@ -0,0 +1,34 @@ +read($extension, $file); + abort_if($stored === null, Response::HTTP_NOT_FOUND); + + return new Response($stored['contents'], Response::HTTP_OK, [ + 'Content-Type' => $stored['mime'], + 'Content-Disposition' => 'inline; filename="'.$file.'"', + 'Cache-Control' => 'public, max-age=31536000, immutable', + 'X-Content-Type-Options' => 'nosniff', + // The type is fixed by the stored name and never sniffed; this keeps an + // SVG opened directly from running script or loading anything. + 'Content-Security-Policy' => "default-src 'none'; style-src 'unsafe-inline'; sandbox", + ]); + } +} diff --git a/app/Http/Controllers/Base/IndexController.php b/app/Http/Controllers/Base/IndexController.php index 37d33ab95..5833d9934 100644 --- a/app/Http/Controllers/Base/IndexController.php +++ b/app/Http/Controllers/Base/IndexController.php @@ -1,23 +1,14 @@ input('locale'); - $namespace = $request->input('namespace'); - $response[$locale][$namespace] = $this->i18n($this->loader->load($locale, $namespace)); + $locale = JsonValueGuard::string($request->validated('locale')); + $namespace = JsonValueGuard::string($request->validated('namespace')); + $segments = explode('::', $namespace, 2); + $translations = count($segments) === 2 + ? $this->loader->load($locale, $segments[1], $segments[0]) + : $this->loader->load($locale, $namespace); + JsonValueGuard::assertValue($translations); + $response[$locale][$namespace] = $this->i18n($translations); return new JsonResponse($response, 200, [ // Cache this in the browser for an hour, and allow the browser to use a stale // cache for up to a day after it was created while it fetches an updated set // of translation keys. 'Cache-Control' => 'public, max-age=3600, stale-while-revalidate=86400', - 'ETag' => md5(json_encode($response, JSON_THROW_ON_ERROR)), + 'ETag' => hash('sha256', json_encode($response, JSON_THROW_ON_ERROR)), ]); } @@ -39,6 +48,9 @@ class LocaleController extends Controller * Convert standard Laravel translation keys that look like ":foo" * into key structures that are supported by the front-end i18n * library, like "{{foo}}". + * + * @param array $data + * @return array */ protected function i18n(array $data): array { @@ -46,15 +58,9 @@ class LocaleController extends Controller if (is_array($value)) { $data[$key] = $this->i18n($value); } else { - // Find a Laravel style translation replacement in the string and replace it with - // one that the front-end is able to use. This won't always be present, especially - // for complex strings or things where we'd never have a backend component anyways. - // - // For example: - // "Hello :name, the :notifications.0.title notification needs :count actions :foo.0.bar." - // - // Becomes: - // "Hello {{name}}, the {{notifications.0.title}} notification needs {{count}} actions {{foo.0.bar}}." + throw_unless(is_string($value), UnexpectedValueException::class, 'Translation leaves must be strings.'); + // Rewrite any Laravel-style ":name" placeholders into the "{{name}}" form the + // front-end i18n library understands. $data[$key] = preg_replace('/:([\w.-]+\w)([^\w:]?|$)/m', '{{$1}}$2', $value); } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index ee7af2f7a..efe0e8386 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,11 +1,13 @@ [ - EncryptCookies::class, - AddQueuedCookiesToResponse::class, - StartSession::class, - ShareErrorsFromSession::class, - VerifyCsrfToken::class, - SubstituteBindings::class, - LanguageMiddleware::class, - ], - 'api' => [ - EnsureStatefulRequests::class, - 'auth:sanctum', - IsValidJson::class, - TrackAPIKey::class, - RequireTwoFactorAuthentication::class, - AuthenticateIPAccess::class, - ], - 'application-api' => [ - SubstituteBindings::class, - AuthenticateApplicationUser::class, - ], - 'client-api' => [ - SubstituteClientBindings::class, - RequireClientApiKey::class, - ], - 'daemon' => [ - SubstituteBindings::class, - DaemonAuthenticate::class, - ], - ]; - - /** - * The application's route middleware. - */ - protected $middlewareAliases = [ - 'auth' => Authenticate::class, - 'auth.basic' => AuthenticateWithBasicAuth::class, - 'auth.session' => AuthenticateSession::class, - 'guest' => RedirectIfAuthenticated::class, - 'csrf' => VerifyCsrfToken::class, - 'throttle' => ThrottleRequests::class, - 'can' => Authorize::class, - 'bindings' => SubstituteBindings::class, - 'recaptcha' => VerifyReCaptcha::class, - 'node.maintenance' => MaintenanceMiddleware::class, - ]; -} diff --git a/app/Http/Middleware/Activity/AccountSubject.php b/app/Http/Middleware/Activity/AccountSubject.php index fba1ea087..d7883e0c1 100644 --- a/app/Http/Middleware/Activity/AccountSubject.php +++ b/app/Http/Middleware/Activity/AccountSubject.php @@ -1,20 +1,31 @@ user()); - LogTarget::setSubject($request->user()); + $user = $this->authenticatedUser($request); + LogTarget::setActor($user); + LogTarget::setSubject($user); return $next($request); } diff --git a/app/Http/Middleware/Activity/ServerSubject.php b/app/Http/Middleware/Activity/ServerSubject.php index c4dd160c8..d4ca376c5 100644 --- a/app/Http/Middleware/Activity/ServerSubject.php +++ b/app/Http/Middleware/Activity/ServerSubject.php @@ -1,13 +1,20 @@ route()->parameter('server'); + $server = $this->resolvedRoute($request)->parameter('server'); if ($server instanceof Server) { - LogTarget::setActor($request->user()); + LogTarget::setActor($this->authenticatedUser($request)); LogTarget::setSubject($server); } diff --git a/app/Http/Middleware/Activity/TrackAPIKey.php b/app/Http/Middleware/Activity/TrackAPIKey.php index 5f45d0cbc..ff3b2c285 100644 --- a/app/Http/Middleware/Activity/TrackAPIKey.php +++ b/app/Http/Middleware/Activity/TrackAPIKey.php @@ -1,10 +1,14 @@ user()) { $token = $request->user()->currentAccessToken(); - LogTarget::setApiKeyId($token instanceof ApiKey ? $token->id : null); // @phpstan-ignore instanceof.alwaysTrue + $id = $token instanceof ApiKey ? $token->id : null; + + LogTarget::setApiKeyId($id !== null && $id > 0 ? $id : null); } return $next($request); diff --git a/app/Http/Middleware/Admin/Servers/ServerInstalled.php b/app/Http/Middleware/Admin/Servers/ServerInstalled.php deleted file mode 100644 index d3fa75951..000000000 --- a/app/Http/Middleware/Admin/Servers/ServerInstalled.php +++ /dev/null @@ -1,31 +0,0 @@ -route()->parameter('server'); - - if (!$server instanceof Server) { - throw new NotFoundHttpException('No server resource was located in the request parameters.'); - } - - if (!$server->isInstalled()) { - throw new HttpException(Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.'); - } - - return $next($request); - } -} diff --git a/app/Http/Middleware/AdminAuthenticate.php b/app/Http/Middleware/AdminAuthenticate.php deleted file mode 100644 index 2e61f6429..000000000 --- a/app/Http/Middleware/AdminAuthenticate.php +++ /dev/null @@ -1,23 +0,0 @@ -user() || !$request->user()->root_admin) { - throw new AccessDeniedHttpException(); - } - - return $next($request); - } -} diff --git a/app/Http/Middleware/Api/Admin/AuthenticateAdmin.php b/app/Http/Middleware/Api/Admin/AuthenticateAdmin.php new file mode 100644 index 000000000..a865dc1a1 --- /dev/null +++ b/app/Http/Middleware/Api/Admin/AuthenticateAdmin.php @@ -0,0 +1,38 @@ +user(); + throw_if(! $user || ! $user->root_admin, AccessDeniedHttpException::class, 'This action is unauthorized.'); + + $token = $user->currentAccessToken(); + if ($token instanceof HasAbilities && ! $token instanceof TransientToken) { + throw_if($token->key_type === ApiKey::TYPE_APPLICATION, AccessDeniedHttpException::class, 'You are attempting to use an application API key on an endpoint that does not accept them.'); + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php b/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php index e6f83b433..3bc306309 100644 --- a/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php +++ b/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php @@ -1,8 +1,12 @@ user(); - if (!$user || !$user->root_admin) { - throw new AccessDeniedHttpException('This account does not have permission to access the API.'); - } + throw_if(! $user || ! $user->root_admin, AccessDeniedHttpException::class, 'This account does not have permission to access the API.'); return $next($request); } diff --git a/app/Http/Middleware/Api/AuthenticateIPAccess.php b/app/Http/Middleware/Api/AuthenticateIPAccess.php index e2332de3a..bed6d92b5 100644 --- a/app/Http/Middleware/Api/AuthenticateIPAccess.php +++ b/app/Http/Middleware/Api/AuthenticateIPAccess.php @@ -1,36 +1,53 @@ user()->currentAccessToken(); + $user = $this->authenticatedUser($request); + // SAFETY: Sanctum may supply a TransientToken for stateful requests; authenticated API requests use the configured ApiKey model. + /** @var TransientToken|ApiKey|null $token */ + $token = $user->currentAccessToken(); // If this is a stateful request just push the request through to the next // middleware in the stack, there is nothing we need to explicitly check. If // this is a valid API Key, but there is no allowed IP restriction, also pass // the request through. - if ($token instanceof TransientToken || empty($token->allowed_ips)) { + if ($token === null || $token instanceof TransientToken || empty($token->allowed_ips)) { return $next($request); } - $find = new IP($request->ip()); + $requestIp = $request->ip(); + throw_if($requestIp === null, AccessDeniedHttpException::class, 'The request did not contain a valid IP address.'); + + $find = new IP($requestIp); foreach ($token->allowed_ips as $ip) { if (Range::parse($ip)->contains($find)) { return $next($request); @@ -38,11 +55,11 @@ class AuthenticateIPAccess } Activity::event('auth:ip-blocked') - ->actor($request->user()) - ->subject($request->user(), $token) + ->actor($user) + ->subject($user, $token) ->property('identifier', $token->identifier) ->log(); - throw new AccessDeniedHttpException('This IP address (' . $request->ip() . ') does not have permission to access the API using these credentials.'); + throw new AccessDeniedHttpException('This IP address ('.$request->ip().') does not have permission to access the API using these credentials.'); } } diff --git a/app/Http/Middleware/Api/Client/RequireClientApiKey.php b/app/Http/Middleware/Api/Client/RequireClientApiKey.php index 6c815fc35..438d2fa62 100644 --- a/app/Http/Middleware/Api/Client/RequireClientApiKey.php +++ b/app/Http/Middleware/Api/Client/RequireClientApiKey.php @@ -1,25 +1,39 @@ user()->currentAccessToken(); - - if ($token instanceof ApiKey && $token->key_type === ApiKey::TYPE_APPLICATION) { // @phpstan-ignore instanceof.alwaysTrue - throw new AccessDeniedHttpException('You are attempting to use an application API key on an endpoint that requires a client API key.'); + $token = $this->authenticatedUser($request)->currentAccessToken(); + if (! $token instanceof HasAbilities || $token instanceof TransientToken) { + return $next($request); } + throw_if($token->key_type === ApiKey::TYPE_APPLICATION, AccessDeniedHttpException::class, 'You are attempting to use an application API key on an endpoint that requires a client API key.'); + return $next($request); } } diff --git a/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php b/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php index f60b696c1..382912826 100644 --- a/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php +++ b/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php @@ -1,63 +1,64 @@ */ protected array $except = [ 'api:client:server.ws', ]; - /** - * AuthenticateServerAccess constructor. - */ - public function __construct() - { - } - /** * Authenticate that this server exists and is not suspended or marked as installing. */ - public function handle(Request $request, \Closure $next): mixed + /** + * @param Closure(Request):Response $next + * @return Response + */ + public function handle(Request $request, Closure $next): mixed { - /** @var \Pterodactyl\Models\User $user */ - $user = $request->user(); - $server = $request->route()->parameter('server'); + $user = $this->authenticatedUser($request); + $server = $this->resolvedRoute($request)->parameter('server'); - if (!$server instanceof Server) { + if (! $server instanceof Server) { throw new NotFoundHttpException(trans('exceptions.api.resource_not_found')); } // At the very least, ensure that the user trying to make this request is the // server owner, a subuser, or a root admin. We'll leave it up to the controllers // to authenticate more detailed permissions if needed. - if ($user->id !== $server->owner_id && !$user->root_admin) { + if ($user->id !== $server->owner_id && ! $user->root_admin) { // Check for subuser status. - if (!$server->subusers->contains('user_id', $user->id)) { + if ($server->subusers->doesntContain('user_id', $user->id)) { throw new NotFoundHttpException(trans('exceptions.api.resource_not_found')); } } try { $server->validateCurrentState(); - } catch (ServerStateConflictException $exception) { + } catch (ServerStateConflictException $serverStateConflictException) { // Still allow users to get information about their server if it is installing or // being transferred. - if (!$request->routeIs('api:client:server.view')) { - if (($server->isSuspended() || $server->node->isUnderMaintenance()) && !$request->routeIs('api:client:server.resources')) { - throw $exception; - } - if (!$user->root_admin || !$request->routeIs($this->except)) { - throw $exception; - } + if (! $request->routeIs('api:client:server.view')) { + throw_if(($server->isSuspended() || $server->node->isUnderMaintenance()) && ! $request->routeIs('api:client:server.resources'), $serverStateConflictException); + throw_if(! $user->root_admin || ! $request->routeIs($this->except), $serverStateConflictException); } } diff --git a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php index 43a48a408..707a1bfb2 100644 --- a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php +++ b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php @@ -1,21 +1,29 @@ route()->parameters(); - if (! isset($params['server']) || !$params['server'] instanceof Server) { - throw new \InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.'); - } + $route = $this->resolvedRoute($request); + $params = $route->parameters(); + throw_if(! isset($params['server']) || ! $params['server'] instanceof Server, InvalidArgumentException::class, 'This middleware cannot be used in a context that is missing a server in the parameters.'); - /** @var Server $server */ - $server = $request->route()->parameter('server'); + $server = $params['server']; $exception = new NotFoundHttpException('The requested resource was not found for this server.'); foreach ($params as $key => $model) { // Specifically skip the server, we're just trying to see if all of the // other resources are assigned to this server. Also skip anything that // is not currently a Model instance since those will just end up being // a 404 down the road. - if ($key === 'server' || !$model instanceof Model) { + if ($key === 'server' || ! $model instanceof Model) { continue; } - switch (get_class($model)) { + switch ($model::class) { // All of these models use "server_id" as the field key for the server // they are assigned to, so the logic is identical for them all. case Allocation::class: @@ -51,17 +61,15 @@ class ResourceBelongsToServer case Database::class: case Schedule::class: case Subuser::class: - if ($model->server_id !== $server->id) { - throw $exception; - } + throw_if($model->server_id !== $server->id, $exception); + break; // Regular users are a special case here as we need to make sure they're // currently assigned as a subuser on the server. case User::class: $subuser = $server->subusers()->where('user_id', $model->id)->first(); - if (is_null($subuser)) { - throw $exception; - } + throw_if(($subuser) === null, $exception); + // This is a special case to avoid an additional query being triggered // in the underlying logic. $request->attributes->set('subuser', $subuser); @@ -69,15 +77,14 @@ class ResourceBelongsToServer // Tasks are special since they're (currently) the only item in the API // that requires something in addition to the server in order to be accessed. case Task::class: - $schedule = $request->route()->parameter('schedule'); - if (!$schedule instanceof Schedule || $model->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) { - throw $exception; - } + $schedule = $route->parameter('schedule'); + throw_if(! $schedule instanceof Schedule || $model->schedule_id !== $schedule->id || $schedule->server_id !== $server->id, $exception); + break; default: // Don't return a 404 here since we want to make sure no one relies // on this middleware in a context in which it will not work. Fail safe. - throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model)); + throw new InvalidArgumentException('There is no handler configured for a resource of this type: '.$model::class); } } diff --git a/app/Http/Middleware/Api/Client/SubstituteClientBindings.php b/app/Http/Middleware/Api/Client/SubstituteClientBindings.php index 3ae2dd87e..c217d5127 100644 --- a/app/Http/Middleware/Api/Client/SubstituteClientBindings.php +++ b/app/Http/Middleware/Api/Client/SubstituteClientBindings.php @@ -1,32 +1,46 @@ router->bind('server', function ($value) { - return Server::query() - ->when( - str_starts_with($value, 'serv_'), - fn ($builder) => $builder->whereIdentifier($value), - fn ($builder) => $builder->where(strlen($value) === 8 ? 'uuidShort' : 'uuid', $value) - ) - ->firstOrFail(); - }); + $this->router->bind('server', fn (string $value) => Server::query() + ->when( + str_starts_with($value, 'serv_'), + fn (Builder $builder) => $builder->whereIdentifier($value), + fn (Builder $builder) => $builder->where(mb_strlen($value) === 8 ? 'uuidShort' : 'uuid', $value) + ) + ->firstOrFail()); - $this->router->bind('user', function ($value, $route) { - /** @var \Pterodactyl\Models\Subuser $match */ - $match = $route->parameter('server') + $this->router->bind('user', function (string $value, Route $route) { + $server = $route->parameter('server'); + throw_unless($server instanceof Server, ModelNotFoundException::class); + + $match = $server ->subusers() ->whereRelation('user', 'uuid', '=', $value) ->firstOrFail(); @@ -34,6 +48,9 @@ class SubstituteClientBindings extends SubstituteBindings return $match->user; }); - return parent::handle($request, $next); + $response = parent::handle($request, $next); + throw_unless($response instanceof Response, UnexpectedValueException::class, 'Route binding middleware must return an HTTP response.'); + + return $response; } } diff --git a/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php b/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php index d782ed8cf..afb775350 100644 --- a/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php +++ b/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php @@ -1,19 +1,27 @@ */ protected array $except = [ 'daemon.configuration', @@ -22,44 +30,40 @@ class DaemonAuthenticate /** * DaemonAuthenticate constructor. */ - public function __construct(private Encrypter $encrypter, private NodeRepository $repository) - { - } + public function __construct(private readonly Encrypter $encrypter) {} /** * Check if a request from the daemon can be properly attributed back to a single node instance. * * @throws HttpException */ - public function handle(Request $request, \Closure $next): mixed + /** + * @param Closure(Request):Response $next + * @return Response + */ + public function handle(Request $request, Closure $next): mixed { - if (in_array($request->route()->getName(), $this->except)) { + if (in_array($this->resolvedRoute($request)->getName(), $this->except, true)) { return $next($request); } - if (is_null($bearer = $request->bearerToken())) { - throw new HttpException(401, 'Access to this endpoint must include an Authorization header.', null, ['WWW-Authenticate' => 'Bearer']); - } + throw_if(($bearer = $request->bearerToken()) === null, HttpException::class, 401, 'Access to this endpoint must include an Authorization header.', null, ['WWW-Authenticate' => 'Bearer']); $parts = explode('.', $bearer); // Ensure that all of the correct parts are provided in the header. - if (count($parts) !== 2 || empty($parts[0]) || empty($parts[1])) { - throw new BadRequestHttpException('The Authorization header provided was not in a valid format.'); - } + throw_if(count($parts) !== 2 || empty($parts[0]) || empty($parts[1]), BadRequestHttpException::class, 'The Authorization header provided was not in a valid format.'); - try { - /** @var \Pterodactyl\Models\Node $node */ - $node = $this->repository->findFirstWhere([ - 'daemon_token_id' => $parts[0], - ]); + // Unknown token ids and wrong tokens fail identically. + $node = Node::query()->where('daemon_token_id', $parts[0])->first(); + if ($node !== null) { + $token = $this->encrypter->decrypt($node->daemon_token); + throw_unless(is_string($token), AccessDeniedHttpException::class, 'The authentication token provided is not valid.'); - if (hash_equals((string) $this->encrypter->decrypt($node->daemon_token), $parts[1])) { + if (hash_equals($token, $parts[1])) { $request->attributes->set('node', $node); return $next($request); } - } catch (RecordNotFoundException $exception) { - // Do nothing, we don't want to expose a node not existing at all. } throw new AccessDeniedHttpException('You are not authorized to access this resource.'); diff --git a/app/Http/Middleware/Api/IsValidJson.php b/app/Http/Middleware/Api/IsValidJson.php index 95101a1b2..285405c89 100644 --- a/app/Http/Middleware/Api/IsValidJson.php +++ b/app/Http/Middleware/Api/IsValidJson.php @@ -1,8 +1,13 @@ isJson() && !empty($request->getContent())) { + if ($request->isJson() && ! empty($request->getContent())) { try { json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $exception) { - throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage()); + } catch (JsonException $exception) { + throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: '.$exception->getMessage(), $exception); } } diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php deleted file mode 100644 index 1ac425a33..000000000 --- a/app/Http/Middleware/EncryptCookies.php +++ /dev/null @@ -1,13 +0,0 @@ -extensions->enabled()->has($identifier), Response::HTTP_NOT_FOUND); + + return $next($request); + } +} diff --git a/app/Http/Middleware/EnsureStatefulRequests.php b/app/Http/Middleware/EnsureStatefulRequests.php index db6e19ae9..c001ae8d5 100644 --- a/app/Http/Middleware/EnsureStatefulRequests.php +++ b/app/Http/Middleware/EnsureStatefulRequests.php @@ -1,26 +1,25 @@ hasCookie(config('session.cookie')); + return $request->hasCookie(JsonValueGuard::string(config('session.cookie'))); } } diff --git a/app/Http/Middleware/LanguageMiddleware.php b/app/Http/Middleware/LanguageMiddleware.php index e98ad2863..f9cca2f70 100644 --- a/app/Http/Middleware/LanguageMiddleware.php +++ b/app/Http/Middleware/LanguageMiddleware.php @@ -1,25 +1,34 @@ app->setLocale($request->user()->language ?? config('app.locale', 'en')); + $user = $request->user(); + $this->app->setLocale($user instanceof User ? $user->language : JsonValueGuard::string(config('app.locale', 'en'))); return $next($request); } diff --git a/app/Http/Middleware/MaintenanceMiddleware.php b/app/Http/Middleware/MaintenanceMiddleware.php index 61247b4e0..4f7e3958b 100644 --- a/app/Http/Middleware/MaintenanceMiddleware.php +++ b/app/Http/Middleware/MaintenanceMiddleware.php @@ -1,27 +1,38 @@ attributes->get('server'); + throw_unless($server instanceof Server, InvalidArgumentException::class, 'The maintenance middleware requires a server request attribute.'); + $node = $server->getRelation('node'); + throw_unless($node instanceof Node, InvalidArgumentException::class, 'The maintenance middleware requires the server node relation.'); if ($node->maintenance_mode) { return $this->response->view('errors.maintenance'); diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 2889506c9..9fbcc4ff7 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -1,26 +1,32 @@ authManager->guard($guard)->check()) { - return redirect()->route('index'); + return to_route('index'); } return $next($request); diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index d609bfa60..12afab9c4 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -1,17 +1,26 @@ user(); - $uri = rtrim($request->getRequestUri(), '/') . '/'; - $current = $request->route()->getName(); + $uri = mb_rtrim($request->getRequestUri(), '/').'/'; + $current = $this->resolvedRoute($request)->getName() ?? ''; - if (!$user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { + if (! $user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { return $next($request); } - $level = (int) config('pterodactyl.auth.2fa_required'); + $configuredLevel = filter_var(config('pterodactyl.auth.2fa_required'), FILTER_VALIDATE_INT); + $level = $configuredLevel === false ? self::LEVEL_NONE : $configuredLevel; // If this setting is not configured, or the user is already using 2FA then we can just // send them right through, nothing else needs to be checked. // // If the level is set as admin and the user is not an admin, pass them through as well. if ($level === self::LEVEL_NONE || $user->use_totp) { return $next($request); - } elseif ($level === self::LEVEL_ADMIN && !$user->root_admin) { + } + + if ($level === self::LEVEL_ADMIN && ! $user->root_admin) { return $next($request); } // For API calls return an exception which gets rendered nicely in the API response. - if ($request->isJson() || Str::startsWith($uri, '/api/')) { - throw new TwoFactorAuthRequiredException(); - } + throw_if($request->isJson() || Str::startsWith($uri, '/api/'), TwoFactorAuthRequiredException::class); $this->alert->danger(trans('auth.2fa_must_be_enabled'))->flash(); diff --git a/app/Http/Middleware/SetSecurityHeaders.php b/app/Http/Middleware/SetSecurityHeaders.php index a1d2518d7..b07b357e9 100644 --- a/app/Http/Middleware/SetSecurityHeaders.php +++ b/app/Http/Middleware/SetSecurityHeaders.php @@ -1,8 +1,12 @@ */ private static array $headers = [ 'X-Frame-Options' => 'DENY', @@ -26,13 +32,17 @@ class SetSecurityHeaders * If a header has already been set in another location within the code it will be * skipped over here. * - * @param (\Closure(mixed): \Illuminate\Http\Response) $next + * @param (Closure(mixed): Response) $next */ - public function handle(Request $request, \Closure $next): mixed + /** + * @param Closure(Request):Response $next + * @return Response + */ + public function handle(Request $request, Closure $next): mixed { $response = $next($request); - foreach (static::$headers as $key => $value) { + foreach (self::$headers as $key => $value) { if (! $response->headers->has($key)) { $response->headers->set($key, $value); } diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php deleted file mode 100644 index af5382e8c..000000000 --- a/app/Http/Middleware/TrimStrings.php +++ /dev/null @@ -1,16 +0,0 @@ -config->get('recaptcha.enabled')) { + if (! $this->config->get('recaptcha.enabled')) { return $next($request); } if ($request->filled('g-recaptcha-response')) { - $client = new Client(); - $res = $client->post($this->config->get('recaptcha.domain'), [ + $client = new Client(['timeout' => 5, 'connect_timeout' => 2]); + $res = $client->post(JsonValueGuard::string($this->config->get('recaptcha.domain')), [ 'form_params' => [ 'secret' => $this->config->get('recaptcha.secret_key'), 'response' => $request->input('g-recaptcha-response'), @@ -38,9 +45,9 @@ class VerifyReCaptcha ]); if ($res->getStatusCode() === 200) { - $result = json_decode($res->getBody()); + $result = $this->decodeResponse($res->getBody()->__toString()); - if ($result->success && (!$this->config->get('recaptcha.verify_domain') || $this->isResponseVerified($result, $request))) { + if ($result['success'] && (! $this->config->get('recaptcha.verify_domain') || $this->isResponseVerified($result, $request))) { return $next($request); } } @@ -48,8 +55,8 @@ class VerifyReCaptcha $this->dispatcher->dispatch( new FailedCaptcha( - $request->ip(), - !empty($result) ? ($result->hostname ?? null) : null + $request->ip() ?? 'unknown', + $result['hostname'] ?? 'unknown' ) ); @@ -59,14 +66,36 @@ class VerifyReCaptcha /** * Determine if the response from the recaptcha servers was valid. */ - private function isResponseVerified(\stdClass $result, Request $request): bool + /** + * @param array{success: bool, hostname: string|null} $result + */ + private function isResponseVerified(array $result, Request $request): bool { - if (!$this->config->get('recaptcha.verify_domain')) { + if (! $this->config->get('recaptcha.verify_domain')) { return false; } $url = parse_url($request->url()); - return $result->hostname === array_get($url, 'host'); + return $url !== false && $result['hostname'] === Arr::get($url, 'host'); + } + + /** + * @return array{success: bool, hostname: string|null} + */ + private function decodeResponse(string $response): array + { + $decoded = json_decode($response, true); + if (! is_array($decoded)) { + return ['success' => false, 'hostname' => null]; + } + + $success = $decoded['success'] ?? false; + $hostname = $decoded['hostname'] ?? null; + + return [ + 'success' => is_bool($success) && $success, + 'hostname' => is_string($hostname) ? $hostname : null, + ]; } } diff --git a/app/Http/Requests/Admin/AdminFormRequest.php b/app/Http/Requests/Admin/AdminFormRequest.php deleted file mode 100644 index 59ba0db64..000000000 --- a/app/Http/Requests/Admin/AdminFormRequest.php +++ /dev/null @@ -1,35 +0,0 @@ -user())) { - return false; - } - - return (bool) $this->user()->root_admin; - } - - /** - * Return only the fields that we are interested in from the request. - * This will include empty fields as a null value. - */ - public function normalize(?array $only = null): array - { - return $this->only($only ?? array_keys($this->rules())); - } -} diff --git a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php deleted file mode 100644 index f451239e6..000000000 --- a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php +++ /dev/null @@ -1,37 +0,0 @@ -mapWithKeys(function ($resource) use ($modelRules) { - return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]]; - })->merge(['memo' => $modelRules['memo']])->toArray(); - } - - public function attributes(): array - { - return [ - 'memo' => 'Description', - ]; - } - - public function getKeyPermissions(): array - { - return collect($this->validated())->filter(function ($value, $key) { - return substr($key, 0, strlen(AdminAcl::COLUMN_IDENTIFIER)) === AdminAcl::COLUMN_IDENTIFIER; - })->toArray(); - } -} diff --git a/app/Http/Requests/Admin/BaseFormRequest.php b/app/Http/Requests/Admin/BaseFormRequest.php deleted file mode 100644 index cd2c78e4d..000000000 --- a/app/Http/Requests/Admin/BaseFormRequest.php +++ /dev/null @@ -1,13 +0,0 @@ - 'required|between:1,256', - ]; - } -} diff --git a/app/Http/Requests/Admin/DatabaseHostFormRequest.php b/app/Http/Requests/Admin/DatabaseHostFormRequest.php deleted file mode 100644 index 2e581478e..000000000 --- a/app/Http/Requests/Admin/DatabaseHostFormRequest.php +++ /dev/null @@ -1,30 +0,0 @@ -method() !== 'POST') { - return DatabaseHost::getRulesForUpdate($this->route()->parameter('host')); - } - - return DatabaseHost::getRules(); - } - - /** - * Modify submitted data before it is passed off to the validator. - */ - protected function getValidatorInstance(): Validator - { - if (!$this->filled('node_id')) { - $this->merge(['node_id' => null]); - } - - return parent::getValidatorInstance(); - } -} diff --git a/app/Http/Requests/Admin/Egg/EggFormRequest.php b/app/Http/Requests/Admin/Egg/EggFormRequest.php deleted file mode 100644 index 561ffb797..000000000 --- a/app/Http/Requests/Admin/Egg/EggFormRequest.php +++ /dev/null @@ -1,49 +0,0 @@ - 'required|string|max:191', - 'description' => 'nullable|string', - 'docker_images' => ['required', 'string', 'regex:/^[\w#\.\/\- ]*\|?~?[\w\.\/\-:@ ]*$/im'], - 'force_outgoing_ip' => 'sometimes|boolean', - 'file_denylist' => 'array', - 'features' => 'sometimes|array', - 'startup' => 'required|string', - 'config_from' => 'sometimes|bail|nullable|numeric', - 'config_stop' => 'required_without:config_from|nullable|string|max:191', - 'config_startup' => 'required_without:config_from|nullable|json', - 'config_logs' => 'required_without:config_from|nullable|json', - 'config_files' => 'required_without:config_from|nullable|json', - ]; - - if ($this->method() === 'POST') { - $rules['nest_id'] = 'required|numeric|exists:nests,id'; - } - - return $rules; - } - - public function withValidator($validator) - { - $validator->sometimes('config_from', 'exists:eggs,id', function () { - return (int) $this->input('config_from') !== 0; - }); - } - - public function validated($key = null, $default = null): array - { - $data = parent::validated(); - - return array_merge($data, [ - 'force_outgoing_ip' => array_get($data, 'force_outgoing_ip', false), - 'features' => array_get($data, 'features', []), - ]); - } -} diff --git a/app/Http/Requests/Admin/Egg/EggImportFormRequest.php b/app/Http/Requests/Admin/Egg/EggImportFormRequest.php deleted file mode 100644 index 7718480e9..000000000 --- a/app/Http/Requests/Admin/Egg/EggImportFormRequest.php +++ /dev/null @@ -1,21 +0,0 @@ - 'bail|required|file|max:1000|mimetypes:application/json,text/plain', - ]; - - if ($this->method() !== 'PUT') { - $rules['import_to_nest'] = 'bail|required|integer|exists:nests,id'; - } - - return $rules; - } -} diff --git a/app/Http/Requests/Admin/Egg/EggScriptFormRequest.php b/app/Http/Requests/Admin/Egg/EggScriptFormRequest.php deleted file mode 100644 index b93a63c63..000000000 --- a/app/Http/Requests/Admin/Egg/EggScriptFormRequest.php +++ /dev/null @@ -1,22 +0,0 @@ - 'sometimes|nullable|string', - 'script_is_privileged' => 'sometimes|required|boolean', - 'script_entry' => 'sometimes|required|string', - 'script_container' => 'sometimes|required|string', - 'copy_script_from' => 'sometimes|nullable|numeric', - ]; - } -} diff --git a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php deleted file mode 100644 index d232254ea..000000000 --- a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php +++ /dev/null @@ -1,24 +0,0 @@ - 'required|string|min:1|max:191', - 'description' => 'sometimes|nullable|string', - 'env_variable' => 'required|regex:/^[\w]{1,191}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES, - 'options' => 'sometimes|required|array', - 'rules' => 'bail|required|string', - 'default_value' => 'present', - ]; - } -} diff --git a/app/Http/Requests/Admin/LocationFormRequest.php b/app/Http/Requests/Admin/LocationFormRequest.php deleted file mode 100644 index 9625f083a..000000000 --- a/app/Http/Requests/Admin/LocationFormRequest.php +++ /dev/null @@ -1,20 +0,0 @@ -method() === 'PATCH') { - return Location::getRulesForUpdate($this->route()->parameter('location')->id); // @phpstan-ignore property.nonObject - } - - return Location::getRules(); - } -} diff --git a/app/Http/Requests/Admin/MountFormRequest.php b/app/Http/Requests/Admin/MountFormRequest.php deleted file mode 100644 index 995c9479c..000000000 --- a/app/Http/Requests/Admin/MountFormRequest.php +++ /dev/null @@ -1,20 +0,0 @@ -method() === 'PATCH') { - return Mount::getRulesForUpdate($this->route()->parameter('mount')->id); // @phpstan-ignore property.nonObject - } - - return Mount::getRules(); - } -} diff --git a/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php b/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php deleted file mode 100644 index 81505de15..000000000 --- a/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php +++ /dev/null @@ -1,16 +0,0 @@ - 'required|string|min:1|max:191|regex:/^[\w\- ]+$/', - 'description' => 'string|nullable', - ]; - } -} diff --git a/app/Http/Requests/Admin/NewUserFormRequest.php b/app/Http/Requests/Admin/NewUserFormRequest.php deleted file mode 100644 index d8c199380..000000000 --- a/app/Http/Requests/Admin/NewUserFormRequest.php +++ /dev/null @@ -1,28 +0,0 @@ -only([ - 'email', - 'username', - 'name_first', - 'name_last', - 'password', - 'language', - 'root_admin', - ])->toArray(); - } -} diff --git a/app/Http/Requests/Admin/Node/AllocationAliasFormRequest.php b/app/Http/Requests/Admin/Node/AllocationAliasFormRequest.php deleted file mode 100644 index f388203a0..000000000 --- a/app/Http/Requests/Admin/Node/AllocationAliasFormRequest.php +++ /dev/null @@ -1,16 +0,0 @@ - 'present|nullable|string', - 'allocation_id' => 'required|numeric|exists:allocations,id', - ]; - } -} diff --git a/app/Http/Requests/Admin/Node/AllocationFormRequest.php b/app/Http/Requests/Admin/Node/AllocationFormRequest.php deleted file mode 100644 index 641b8d08a..000000000 --- a/app/Http/Requests/Admin/Node/AllocationFormRequest.php +++ /dev/null @@ -1,17 +0,0 @@ - 'required|string', - 'allocation_alias' => 'sometimes|nullable|string|max:191', - 'allocation_ports' => 'required|array', - ]; - } -} diff --git a/app/Http/Requests/Admin/Node/NodeFormRequest.php b/app/Http/Requests/Admin/Node/NodeFormRequest.php deleted file mode 100644 index f95189f29..000000000 --- a/app/Http/Requests/Admin/Node/NodeFormRequest.php +++ /dev/null @@ -1,25 +0,0 @@ -method() === 'PATCH') { - return Node::getRulesForUpdate($this->route()->parameter('node')); - } - - $data = Node::getRules(); - $data['fqdn'][] = Fqdn::make('scheme'); - - return $data; - } -} diff --git a/app/Http/Requests/Admin/ServerFormRequest.php b/app/Http/Requests/Admin/ServerFormRequest.php deleted file mode 100644 index bf461dc95..000000000 --- a/app/Http/Requests/Admin/ServerFormRequest.php +++ /dev/null @@ -1,58 +0,0 @@ -after(function ($validator) { - $validator->sometimes('node_id', 'required|numeric|bail|exists:nodes,id', function ($input) { - return !$input->auto_deploy; - }); - - $validator->sometimes('allocation_id', [ - 'required', - 'numeric', - 'bail', - Rule::exists('allocations', 'id')->where(function ($query) { - $query->where('node_id', $this->input('node_id')); - $query->whereNull('server_id'); - }), - ], function ($input) { - return !$input->auto_deploy; - }); - - $validator->sometimes('allocation_additional.*', [ - 'sometimes', - 'required', - 'numeric', - Rule::exists('allocations', 'id')->where(function ($query) { - $query->where('node_id', $this->input('node_id')); - $query->whereNull('server_id'); - }), - ], function ($input) { - return !$input->auto_deploy; - }); - }); - } -} diff --git a/app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php b/app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php deleted file mode 100644 index 144755d2b..000000000 --- a/app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php +++ /dev/null @@ -1,31 +0,0 @@ - [ - 'required', - 'string', - 'min:1', - 'max:24', - Rule::unique('databases')->where(function (Builder $query) { - $query->where('database_host_id', $this->input('database_host_id') ?? 0); - }), - ], - 'max_connections' => 'nullable', - 'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/', - 'database_host_id' => 'required|integer|exists:database_hosts,id', - ]; - } -} diff --git a/app/Http/Requests/Admin/Settings/AdvancedSettingsFormRequest.php b/app/Http/Requests/Admin/Settings/AdvancedSettingsFormRequest.php deleted file mode 100644 index 17608d9f2..000000000 --- a/app/Http/Requests/Admin/Settings/AdvancedSettingsFormRequest.php +++ /dev/null @@ -1,50 +0,0 @@ - 'required|in:true,false', - 'recaptcha:secret_key' => 'required|string|max:191', - 'recaptcha:website_key' => 'required|string|max:191', - 'pterodactyl:guzzle:timeout' => 'required|integer|between:1,60', - 'pterodactyl:guzzle:connect_timeout' => 'required|integer|between:1,60', - 'pterodactyl:client_features:allocations:enabled' => 'required|in:true,false', - 'pterodactyl:client_features:allocations:range_start' => [ - 'nullable', - 'required_if:pterodactyl:client_features:allocations:enabled,true', - 'integer', - 'between:1024,65535', - ], - 'pterodactyl:client_features:allocations:range_end' => [ - 'nullable', - 'required_if:pterodactyl:client_features:allocations:enabled,true', - 'integer', - 'between:1024,65535', - 'gt:pterodactyl:client_features:allocations:range_start', - ], - ]; - } - - public function attributes(): array - { - return [ - 'recaptcha:enabled' => 'reCAPTCHA Enabled', - 'recaptcha:secret_key' => 'reCAPTCHA Secret Key', - 'recaptcha:website_key' => 'reCAPTCHA Website Key', - 'pterodactyl:guzzle:timeout' => 'HTTP Request Timeout', - 'pterodactyl:guzzle:connect_timeout' => 'HTTP Connection Timeout', - 'pterodactyl:client_features:allocations:enabled' => 'Auto Create Allocations Enabled', - 'pterodactyl:client_features:allocations:range_start' => 'Starting Port', - 'pterodactyl:client_features:allocations:range_end' => 'Ending Port', - ]; - } -} diff --git a/app/Http/Requests/Admin/Settings/BaseSettingsFormRequest.php b/app/Http/Requests/Admin/Settings/BaseSettingsFormRequest.php deleted file mode 100644 index 8a24dd0ac..000000000 --- a/app/Http/Requests/Admin/Settings/BaseSettingsFormRequest.php +++ /dev/null @@ -1,30 +0,0 @@ - 'required|string|max:191', - 'pterodactyl:auth:2fa_required' => 'required|integer|in:0,1,2', - 'app:locale' => ['required', 'string', Rule::in(array_keys($this->getAvailableLanguages()))], - ]; - } - - public function attributes(): array - { - return [ - 'app:name' => 'Company Name', - 'pterodactyl:auth:2fa_required' => 'Require 2-Factor Authentication', - 'app:locale' => 'Default Language', - ]; - } -} diff --git a/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php b/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php deleted file mode 100644 index 983698070..000000000 --- a/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php +++ /dev/null @@ -1,40 +0,0 @@ - 'required|string', - 'mail:mailers:smtp:port' => 'required|integer|between:1,65535', - 'mail:mailers:smtp:encryption' => ['present', Rule::in([null, 'tls', 'ssl'])], - 'mail:mailers:smtp:username' => 'nullable|string|max:191', - 'mail:mailers:smtp:password' => 'nullable|string|max:191', - 'mail:from:address' => 'required|string|email', - 'mail:from:name' => 'nullable|string|max:191', - ]; - } - - /** - * Override the default normalization function for this type of request - * as we need to accept empty values on the keys. - */ - public function normalize(?array $only = null): array - { - $keys = array_flip(array_keys($this->rules())); - - if (empty($this->input('mail:mailers:smtp:password'))) { - unset($keys['mail:mailers:smtp:password']); - } - - return $this->only(array_flip($keys)); - } -} diff --git a/app/Http/Requests/Admin/UserFormRequest.php b/app/Http/Requests/Admin/UserFormRequest.php deleted file mode 100644 index ae5b5f346..000000000 --- a/app/Http/Requests/Admin/UserFormRequest.php +++ /dev/null @@ -1,28 +0,0 @@ -route()->parameter('user')) - )->only([ - 'email', - 'username', - 'name_first', - 'name_last', - 'password', - 'language', - 'root_admin', - ])->toArray(); - } -} diff --git a/app/Http/Requests/Api/Admin/Activity/GetActivityLogsRequest.php b/app/Http/Requests/Api/Admin/Activity/GetActivityLogsRequest.php new file mode 100644 index 000000000..4ddafae47 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Activity/GetActivityLogsRequest.php @@ -0,0 +1,22 @@ +permissions(); + + // A request that declares no specific permissions still requires root administrator access. + if ($permissions === []) { + return (bool) $this->user()->root_admin; + } + + $abilities = array_map(fn (Permissions $permission) => $permission->value, $permissions); + + return $this->user()->can($abilities); + } +} diff --git a/app/Http/Requests/Api/Admin/ApiKeys/DeleteApiKeyRequest.php b/app/Http/Requests/Api/Admin/ApiKeys/DeleteApiKeyRequest.php new file mode 100644 index 000000000..20583b6fa --- /dev/null +++ b/app/Http/Requests/Api/Admin/ApiKeys/DeleteApiKeyRequest.php @@ -0,0 +1,16 @@ + $modelRules['memo']]; + foreach (AdminAcl::getResourceList() as $resource) { + $column = AdminAcl::COLUMN_IDENTIFIER.$resource; + $rules[$column] = $modelRules[$column]; + } + + return $rules; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'memo' => 'Description', + ]; + } + + /** + * The per-resource permission values from the validated payload. + * + * @return array + */ + public function getKeyPermissions(): array + { + $permissions = []; + foreach ($this->validated() as $key => $value) { + if (! str_starts_with($key, AdminAcl::COLUMN_IDENTIFIER)) { + continue; + } + + throw_unless(is_int($value), UnexpectedValueException::class, 'Validated API key permissions must be integers.'); + + $permissions[$key] = $value; + } + + return $permissions; + } +} diff --git a/app/Http/Requests/Api/Admin/ApiKeys/UpdateApiKeyRequest.php b/app/Http/Requests/Api/Admin/ApiKeys/UpdateApiKeyRequest.php new file mode 100644 index 000000000..41d7bbd3e --- /dev/null +++ b/app/Http/Requests/Api/Admin/ApiKeys/UpdateApiKeyRequest.php @@ -0,0 +1,17 @@ + $this->string('name')->toString(), + 'host' => $this->string('host')->toString(), + 'port' => $this->integer('port'), + 'username' => $this->string('username')->toString(), + 'password' => $this->filled('password') ? $this->string('password')->toString() : null, + 'node_id' => $this->filled('node_id') ? $this->integer('node_id') : null, + ]; + } + + /** Default an unsupplied node_id to null so the host is treated as global. */ + protected function prepareForValidation(): void + { + if (! $this->filled('node_id')) { + $this->merge(['node_id' => null]); + } + } +} diff --git a/app/Http/Requests/Api/Admin/DatabaseHosts/UpdateDatabaseHostRequest.php b/app/Http/Requests/Api/Admin/DatabaseHosts/UpdateDatabaseHostRequest.php new file mode 100644 index 000000000..8cc9c3dbd --- /dev/null +++ b/app/Http/Requests/Api/Admin/DatabaseHosts/UpdateDatabaseHostRequest.php @@ -0,0 +1,15 @@ + ['required', 'string', 'max:255'], + ]; + } + + public function catalogId(): string + { + return $this->string('catalog_id')->toString(); + } +} diff --git a/app/Http/Requests/Api/Admin/Eggs/ImportEggRequest.php b/app/Http/Requests/Api/Admin/Eggs/ImportEggRequest.php new file mode 100644 index 000000000..a21acf192 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Eggs/ImportEggRequest.php @@ -0,0 +1,28 @@ + ['bail', 'required', 'file', 'max:1000', 'mimetypes:application/json,text/plain'], + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Eggs/StoreEggRequest.php b/app/Http/Requests/Api/Admin/Eggs/StoreEggRequest.php new file mode 100644 index 000000000..2698540ad --- /dev/null +++ b/app/Http/Requests/Api/Admin/Eggs/StoreEggRequest.php @@ -0,0 +1,118 @@ + ['required', 'string', 'max:191'], + 'description' => ['nullable', 'string'], + 'docker_images' => ['required', 'string', 'regex:/^[\w#\.\/\- ]*\|?~?[\w\.\/\-:@ ]*$/im'], + 'force_outgoing_ip' => ['sometimes', 'boolean'], + 'file_denylist' => ['array'], + 'features' => ['sometimes', 'array'], + 'startup' => ['required', 'string'], + 'config_from' => ['sometimes', 'bail', 'nullable', 'integer', Rule::exists(Egg::class, 'id')], + 'config_stop' => ['required_without:config_from', 'nullable', 'string', 'max:191'], + 'config_startup' => ['required_without:config_from', 'nullable', 'json'], + 'config_logs' => ['required_without:config_from', 'nullable', 'json'], + 'config_files' => ['required_without:config_from', 'nullable', 'json'], + ]; + } + + /** + * Normalize docker_images and apply defaults before handing data to the service. + * + * @return EggCreationData + */ + public function payload(): array + { + $data = [ + 'name' => $this->string('name')->toString(), + 'description' => $this->filled('description') ? $this->string('description')->toString() : null, + 'docker_images' => $this->normalizeDockerImages($this->string('docker_images')->toString()), + 'force_outgoing_ip' => $this->boolean('force_outgoing_ip'), + 'features' => $this->stringList('features'), + 'startup' => $this->string('startup')->toString(), + ]; + + if ($this->has('file_denylist')) { + $data['file_denylist'] = $this->stringList('file_denylist'); + } + + if ($this->has('config_from')) { + $data['config_from'] = $this->filled('config_from') ? $this->integer('config_from') : null; + } + + foreach (['config_stop', 'config_startup', 'config_logs', 'config_files'] as $field) { + if ($this->has($field)) { + $data[$field] = $this->filled($field) ? $this->string($field)->toString() : null; + } + } + + return $data; + } + + /** A zero config_from is the legacy "no parent egg" sentinel; treat it as null. */ + protected function prepareForValidation(): void + { + if ($this->has('config_from') && filter_var($this->input('config_from'), FILTER_VALIDATE_INT) === 0) { + $this->merge(['config_from' => null]); + } + } + + /** + * Normalize a newline-delimited docker image string into a name => image array. + * + * @return array + */ + protected function normalizeDockerImages(?string $input = null): array + { + $data = array_map(trim(...), explode("\n", $input ?? '')); + + $images = []; + foreach ($data as $value) { + $parts = explode('|', $value, 2); + $images[$parts[0]] = empty($parts[1]) ? $parts[0] : $parts[1]; + } + + return $images; + } + + /** @return list */ + private function stringList(string $field): array + { + $values = $this->input($field, []); + if (! is_array($values) || ! array_is_list($values)) { + return []; + } + + $strings = []; + foreach ($values as $value) { + if (is_string($value)) { + $strings[] = $value; + } + } + + return $strings; + } +} diff --git a/app/Http/Requests/Api/Admin/Eggs/UpdateEggRequest.php b/app/Http/Requests/Api/Admin/Eggs/UpdateEggRequest.php new file mode 100644 index 000000000..848f0fd7d --- /dev/null +++ b/app/Http/Requests/Api/Admin/Eggs/UpdateEggRequest.php @@ -0,0 +1,17 @@ + ['sometimes', 'nullable', 'string'], + 'script_is_privileged' => ['sometimes', 'required', 'boolean'], + 'script_entry' => ['sometimes', 'required', 'string'], + 'script_container' => ['sometimes', 'required', 'string'], + 'copy_script_from' => ['sometimes', 'nullable', 'numeric'], + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Eggs/UpdateImportEggRequest.php b/app/Http/Requests/Api/Admin/Eggs/UpdateImportEggRequest.php new file mode 100644 index 000000000..e701e41f2 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Eggs/UpdateImportEggRequest.php @@ -0,0 +1,28 @@ + ['bail', 'required', 'file', 'max:1000', 'mimetypes:application/json,text/plain'], + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Eggs/Variables/DeleteVariableRequest.php b/app/Http/Requests/Api/Admin/Eggs/Variables/DeleteVariableRequest.php new file mode 100644 index 000000000..cd6b09245 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Eggs/Variables/DeleteVariableRequest.php @@ -0,0 +1,16 @@ + ['required', 'array', 'list'], + 'order.*' => ['required', Rule::anyOf([['integer:strict'], ['string']]), 'integer', 'distinct'], + ]; + } + + /** @return list */ + public function order(): array + { + return JsonValueGuard::normalizedIntegerList(JsonValueGuard::integerStringList($this->validated('order'))); + } +} diff --git a/app/Http/Requests/Api/Admin/Eggs/Variables/StoreVariableRequest.php b/app/Http/Requests/Api/Admin/Eggs/Variables/StoreVariableRequest.php new file mode 100644 index 000000000..5ccb52eaa --- /dev/null +++ b/app/Http/Requests/Api/Admin/Eggs/Variables/StoreVariableRequest.php @@ -0,0 +1,100 @@ + ['required', 'string', 'min:1', 'max:191'], + 'description' => ['sometimes', 'nullable', 'string'], + 'env_variable' => [ + 'required', + 'regex:/^[\w]{1,191}$/', + Rule::notIn($this->reservedEnvironmentVariables()), + $this->uniqueEnvironmentVariable(), + ], + 'options' => ['sometimes', 'required', 'array', 'list'], + 'options.*' => ['string'], + 'rules' => ['bail', 'required', 'string', new ValidRuleSet], + 'default_value' => ['present', 'string'], + ]; + } + + /** + * Reserved names are rejected in any letter case. + * + * @return list + */ + public function after(): array + { + return [ + function (Validator $validator): void { + $name = $this->string('env_variable')->toString(); + if ($validator->errors()->has('env_variable') || ! in_array(mb_strtoupper($name), $this->reservedEnvironmentVariables(), true)) { + return; + } + + $validator->errors()->add('env_variable', trans('exceptions.service.variables.reserved_name', ['name' => $name])); + }, + ]; + } + + /** + * Model attributes for the variable; the options list becomes the two flags. + * + * @return EggVariableData + */ + public function payload(): array + { + $options = JsonValueGuard::stringList($this->input('options', [])); + + return [ + 'name' => $this->string('name')->toString(), + 'description' => JsonValueGuard::nullableString($this->input('description')) ?? '', + 'env_variable' => $this->string('env_variable')->toString(), + 'default_value' => JsonValueGuard::string($this->input('default_value')), + 'user_viewable' => in_array('user_viewable', $options, true), + 'user_editable' => in_array('user_editable', $options, true), + 'rules' => $this->string('rules')->toString(), + ]; + } + + /** + * The environment variable name must be unique among the egg's variables. + */ + protected function uniqueEnvironmentVariable(): Unique + { + return Rule::unique(EggVariable::class, 'env_variable')->where('egg_id', $this->parameter('egg', Egg::class)->id); + } + + /** @return list */ + private function reservedEnvironmentVariables(): array + { + return explode(',', EggVariable::RESERVED_ENV_NAMES); + } +} diff --git a/app/Http/Requests/Api/Admin/Eggs/Variables/UpdateVariableRequest.php b/app/Http/Requests/Api/Admin/Eggs/Variables/UpdateVariableRequest.php new file mode 100644 index 000000000..fbbe9dca0 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Eggs/Variables/UpdateVariableRequest.php @@ -0,0 +1,22 @@ +ignore($this->parameter('variable', EggVariable::class)); + } +} diff --git a/app/Http/Requests/Api/Admin/Extensions/DeleteExtensionRequest.php b/app/Http/Requests/Api/Admin/Extensions/DeleteExtensionRequest.php new file mode 100644 index 000000000..584028f49 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Extensions/DeleteExtensionRequest.php @@ -0,0 +1,16 @@ + ['required', 'file', 'max:51200'], + 'enable' => ['sometimes', 'boolean'], + ]; + } + + public function attributes(): array + { + return [ + 'package' => 'extension package', + ]; + } + + /** + * @return array{package: UploadedFile, enable: bool} + */ + public function payload(): array + { + $package = $this->file('package'); + throw_unless($package instanceof UploadedFile, UnexpectedValueException::class, 'Expected an uploaded extension package.'); + + return [ + 'package' => $package, + 'enable' => $this->boolean('enable', false), + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Extensions/UpdateExtensionRequest.php b/app/Http/Requests/Api/Admin/Extensions/UpdateExtensionRequest.php new file mode 100644 index 000000000..9e7998366 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Extensions/UpdateExtensionRequest.php @@ -0,0 +1,16 @@ + ['bail', 'present', 'array', new ValidExtensionSettings]]; + } + + /** @return ExtensionSettingValues */ + public function settings(ExtensionSettingsDefinition $definition): array + { + $input = $this->validated('settings'); + ExtensionSettingValueGuard::assertValues($input); + + $settings = Validator::make( + $definition->withoutBlankSecrets($input), + $definition->validationRules(), + )->validate(); + ExtensionSettingValueGuard::assertValues($settings); + + return $settings; + } +} diff --git a/app/Http/Requests/Api/Admin/Extensions/UploadExtensionSettingFileRequest.php b/app/Http/Requests/Api/Admin/Extensions/UploadExtensionSettingFileRequest.php new file mode 100644 index 000000000..76f025ac9 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Extensions/UploadExtensionSettingFileRequest.php @@ -0,0 +1,31 @@ + ['required', 'file', 'max:'.ExtensionSettingFiles::MAX_KILOBYTES]]; + } + + public function upload(): UploadedFile + { + $file = $this->file('file'); + throw_unless($file instanceof UploadedFile, UnexpectedValueException::class, 'Expected an uploaded settings file.'); + + return $file; + } +} diff --git a/app/Http/Requests/Api/Admin/GetLanguagesRequest.php b/app/Http/Requests/Api/Admin/GetLanguagesRequest.php new file mode 100644 index 000000000..9267f7e62 --- /dev/null +++ b/app/Http/Requests/Api/Admin/GetLanguagesRequest.php @@ -0,0 +1,13 @@ + 'Location Identifier', + 'long' => 'Location Description', + ]; + } + + /** @return LocationCreationData */ + public function payload(): array + { + return [ + 'short' => $this->string('short')->toString(), + 'long' => $this->filled('long') ? $this->string('long')->toString() : null, + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Locations/UpdateLocationRequest.php b/app/Http/Requests/Api/Admin/Locations/UpdateLocationRequest.php new file mode 100644 index 000000000..2b51c8dc7 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Locations/UpdateLocationRequest.php @@ -0,0 +1,27 @@ +parameter('location', Location::class)); + } +} diff --git a/app/Http/Requests/Api/Admin/Mounts/AttachEggsRequest.php b/app/Http/Requests/Api/Admin/Mounts/AttachEggsRequest.php new file mode 100644 index 000000000..dd888b48e --- /dev/null +++ b/app/Http/Requests/Api/Admin/Mounts/AttachEggsRequest.php @@ -0,0 +1,51 @@ + + */ + public function after(): array + { + return [fn (Validator $validator) => $this->validateArrayExistence($validator, 'eggs', Egg::query())]; + } + + public function permissions(): array + { + return [Permissions::AdminMountsUpdate]; + } + + /** + * Validation rules for attaching eggs to a mount. + * + * @return ValidationRules + */ + public function rules(): array + { + return [ + 'eggs' => ['required', 'array', 'list', 'min:1'], + 'eggs.*' => [Rule::anyOf([['integer:strict'], ['string']]), 'required', 'integer'], + ]; + } + + /** @return list */ + public function eggs(): array + { + return JsonValueGuard::normalizedIntegerList(JsonValueGuard::integerStringList($this->validated('eggs'))); + } +} diff --git a/app/Http/Requests/Api/Admin/Mounts/AttachNodesRequest.php b/app/Http/Requests/Api/Admin/Mounts/AttachNodesRequest.php new file mode 100644 index 000000000..fb7bce246 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Mounts/AttachNodesRequest.php @@ -0,0 +1,51 @@ + + */ + public function after(): array + { + return [fn (Validator $validator) => $this->validateArrayExistence($validator, 'nodes', Node::query())]; + } + + public function permissions(): array + { + return [Permissions::AdminMountsUpdate]; + } + + /** + * Validation rules for attaching nodes to a mount. + * + * @return ValidationRules + */ + public function rules(): array + { + return [ + 'nodes' => ['required', 'array', 'list', 'min:1'], + 'nodes.*' => [Rule::anyOf([['integer:strict'], ['string']]), 'required', 'integer'], + ]; + } + + /** @return list */ + public function nodes(): array + { + return JsonValueGuard::normalizedIntegerList(JsonValueGuard::integerStringList($this->validated('nodes'))); + } +} diff --git a/app/Http/Requests/Api/Admin/Mounts/DeleteMountRequest.php b/app/Http/Requests/Api/Admin/Mounts/DeleteMountRequest.php new file mode 100644 index 000000000..41a1df40a --- /dev/null +++ b/app/Http/Requests/Api/Admin/Mounts/DeleteMountRequest.php @@ -0,0 +1,16 @@ +parameter('mount', Mount::class)); + } +} diff --git a/app/Http/Requests/Api/Admin/Nodes/Allocations/BlockDeleteAllocationRequest.php b/app/Http/Requests/Api/Admin/Nodes/Allocations/BlockDeleteAllocationRequest.php new file mode 100644 index 000000000..12d0e898c --- /dev/null +++ b/app/Http/Requests/Api/Admin/Nodes/Allocations/BlockDeleteAllocationRequest.php @@ -0,0 +1,28 @@ + ['required', 'string'], + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Nodes/Allocations/BulkDeleteAllocationRequest.php b/app/Http/Requests/Api/Admin/Nodes/Allocations/BulkDeleteAllocationRequest.php new file mode 100644 index 000000000..0cade8f14 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Nodes/Allocations/BulkDeleteAllocationRequest.php @@ -0,0 +1,29 @@ + ['required', 'array'], + 'ids.*' => ['integer'], + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Nodes/Allocations/DeleteAllocationRequest.php b/app/Http/Requests/Api/Admin/Nodes/Allocations/DeleteAllocationRequest.php new file mode 100644 index 000000000..f1c971cf7 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Nodes/Allocations/DeleteAllocationRequest.php @@ -0,0 +1,26 @@ + ['required', 'array', 'list'], + 'ip.*' => ['string'], + 'alias' => ['sometimes', 'nullable', 'string', 'max:255'], + 'ports' => ['required', 'array', 'list'], + 'ports.*' => ['string'], + ]; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'ip' => 'IP Address', + 'alias' => 'IP Alias', + 'ports' => 'Ports', + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Nodes/Allocations/UpdateAllocationRequest.php b/app/Http/Requests/Api/Admin/Nodes/Allocations/UpdateAllocationRequest.php new file mode 100644 index 000000000..64a0aea7a --- /dev/null +++ b/app/Http/Requests/Api/Admin/Nodes/Allocations/UpdateAllocationRequest.php @@ -0,0 +1,36 @@ + ['present', 'nullable', 'string'], + ]; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'alias' => 'IP Alias', + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Nodes/DeleteNodeRequest.php b/app/Http/Requests/Api/Admin/Nodes/DeleteNodeRequest.php new file mode 100644 index 000000000..a5cda329b --- /dev/null +++ b/app/Http/Requests/Api/Admin/Nodes/DeleteNodeRequest.php @@ -0,0 +1,16 @@ + $value) { + $key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key; + $normalized[Str::snake($key)] = $value; + } + + return $normalized; + } + + /** + * @return list + */ + public function after(): array + { + return [function (Validator $validator): void { + if ($this->isSecure() && $this->input('scheme') === 'http') { + $validator->errors()->add( + 'scheme', + 'HTTP node connections cannot be used when the Panel is loaded over HTTPS.' + ); + } + }]; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'daemon_base' => 'Daemon Base Path', + 'upload_size' => 'File Upload Size Limit', + 'location_id' => 'Location', + 'public' => 'Node Visibility', + ]; + } + + /** + * Remap snake_case keys back to the daemon* keys the services expect. + * + * @return NodeCreationData + */ + public function payload(): array + { + $data = parent::validated(); + + $daemonBase = Arr::get($data, 'daemon_base'); + + $response = [ + 'name' => JsonValueGuard::string(Arr::get($data, 'name')), + 'location_id' => JsonValueGuard::integer(Arr::get($data, 'location_id')), + 'fqdn' => JsonValueGuard::string(Arr::get($data, 'fqdn')), + 'scheme' => JsonValueGuard::string(Arr::get($data, 'scheme')), + 'memory' => JsonValueGuard::integer(Arr::get($data, 'memory')), + 'memory_overallocate' => JsonValueGuard::integer(Arr::get($data, 'memory_overallocate')), + 'disk' => JsonValueGuard::integer(Arr::get($data, 'disk')), + 'disk_overallocate' => JsonValueGuard::integer(Arr::get($data, 'disk_overallocate')), + 'daemonListen' => JsonValueGuard::integer(Arr::get($data, 'daemon_listen')), + 'daemonSFTP' => JsonValueGuard::integer(Arr::get($data, 'daemon_sftp')), + 'daemonBase' => $daemonBase !== null && $daemonBase !== '' ? JsonValueGuard::string($daemonBase) : '/var/lib/pterodactyl/volumes', + ]; + + if (array_key_exists('description', $data)) { + $description = Arr::get($data, 'description'); + $response['description'] = $description !== null && $description !== '' ? JsonValueGuard::string($description) : null; + } + + foreach (['public', 'behind_proxy', 'maintenance_mode'] as $boolean) { + if (array_key_exists($boolean, $data)) { + $response[$boolean] = JsonValueGuard::boolean(Arr::get($data, $boolean)); + } + } + + $uploadSize = Arr::get($data, 'upload_size'); + if ($uploadSize !== null && $uploadSize !== '') { + $response['upload_size'] = JsonValueGuard::integer($uploadSize); + } + + return $response; + } +} diff --git a/app/Http/Requests/Api/Admin/Nodes/UpdateNodeRequest.php b/app/Http/Requests/Api/Admin/Nodes/UpdateNodeRequest.php new file mode 100644 index 000000000..2543ace42 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Nodes/UpdateNodeRequest.php @@ -0,0 +1,42 @@ + ['sometimes', 'boolean'], + ]; + } + + /** + * Existing HTTP nodes can still be updated when the Panel is served over HTTPS. + * + * @return list + */ + public function after(): array + { + return []; + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/Backups/ListBackupsRequest.php b/app/Http/Requests/Api/Admin/Servers/Backups/ListBackupsRequest.php new file mode 100644 index 000000000..1cf8d6d6b --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/Backups/ListBackupsRequest.php @@ -0,0 +1,18 @@ +parameter('server', Server::class); + + return [ + 'database' => [ + 'required', + 'alpha_dash', + 'min:1', + 'max:48', + Rule::unique('databases')->where(function (Builder $query) use ($server): void { + $query->where('server_id', $server->id)->where('database', $this->databaseName()); + }), + ], + 'remote' => ['required', 'string', 'regex:/^[0-9%.]{1,15}$/'], + 'database_host_id' => ['required', 'integer', 'exists:database_hosts,id'], + 'max_connections' => ['nullable', 'integer', 'min:0'], + ]; + } + + /** + * Format the validated data for the service to consume. + * + * @return DatabaseCreationData + */ + public function payload(): array + { + return [ + 'database' => $this->string('database')->toString(), + 'remote' => $this->string('remote')->toString(), + 'database_host_id' => $this->integer('database_host_id'), + 'max_connections' => $this->filled('max_connections') ? $this->integer('max_connections') : null, + ]; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'database_host_id' => 'Database Host Server ID', + 'remote' => 'Remote Connection String', + 'database' => 'Database Name', + 'max_connections' => 'Max Connections', + ]; + } + + /** The unique, prefixed database name used by the uniqueness rule and the service. */ + public function databaseName(): string + { + $server = $this->parameter('server', Server::class); + + return DatabaseName::generateUnique(JsonValueGuard::string($this->input('database')), $server->id); + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/DeleteServerMountRequest.php b/app/Http/Requests/Api/Admin/Servers/DeleteServerMountRequest.php new file mode 100644 index 000000000..0cbf7ff3e --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/DeleteServerMountRequest.php @@ -0,0 +1,15 @@ + ['required', 'integer', 'exists:mounts,id'], + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/StoreServerRequest.php b/app/Http/Requests/Api/Admin/Servers/StoreServerRequest.php new file mode 100644 index 000000000..dc4723807 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/StoreServerRequest.php @@ -0,0 +1,142 @@ + $rules['external_id'], + 'name' => $rules['name'], + 'description' => array_merge(['nullable'], $rules['description']), + 'owner_id' => $rules['owner_id'], + 'egg_id' => $rules['egg_id'], + 'docker_image' => $rules['image'], + 'startup' => $rules['startup'], + 'environment' => ['present', 'array'], + 'skip_scripts' => ['sometimes', 'boolean'], + 'oom_disabled' => ['sometimes', 'boolean'], + + 'memory' => $rules['memory'], + 'swap' => $rules['swap'], + 'disk' => $rules['disk'], + 'io' => $rules['io'], + 'threads' => $rules['threads'], + 'cpu' => $rules['cpu'], + + 'database_limit' => $rules['database_limit'], + 'allocation_limit' => $rules['allocation_limit'], + 'backup_limit' => $rules['backup_limit'], + + // Allocations are chosen by hand unless a deployment object picks them. + 'primary_allocation_id' => ['exclude_with:deploy', 'required', 'integer', 'bail', AllocationRules::unassigned()], + 'secondary_allocations_ids.*' => ['exclude_with:deploy', 'integer', AllocationRules::unassigned()], + + 'deploy' => ['sometimes', 'required', 'array'], + 'deploy.locations' => ['present_with:deploy', 'array', 'list'], + 'deploy.locations.*' => ['required', Rule::anyOf([['integer:strict'], ['string']]), 'integer', 'min:1'], + 'deploy.dedicated_ip' => ['required_with:deploy', 'boolean'], + 'deploy.port_range' => ['present_with:deploy', 'array', 'list'], + 'deploy.port_range.*' => ['string'], + // Deploy tags (D): the reservations this deployment opts into. Each may + // be given as a tag id or a slug; existence is checked in after() + // so the message can name the offending value. + 'deploy.tags' => ['array'], + 'deploy.tags.*' => ['string'], + + 'start_on_completion' => ['sometimes', 'boolean'], + ]; + } + + /** + * Normalize the validated data for the server creation service. + * + * @return ServerCreationAttributes + */ + public function payload(): array + { + $data = parent::validated(); + + $payload = [ + 'external_id' => Arr::get($data, 'external_id'), + 'name' => Arr::get($data, 'name'), + 'description' => Arr::get($data, 'description'), + 'owner_id' => Arr::get($data, 'owner_id'), + 'egg_id' => Arr::get($data, 'egg_id'), + 'image' => Arr::get($data, 'docker_image'), + 'startup' => Arr::get($data, 'startup'), + 'environment' => Arr::get($data, 'environment'), + 'memory' => Arr::get($data, 'memory'), + 'swap' => Arr::get($data, 'swap'), + 'disk' => Arr::get($data, 'disk'), + 'io' => Arr::get($data, 'io'), + 'cpu' => Arr::get($data, 'cpu'), + 'threads' => Arr::get($data, 'threads'), + 'skip_scripts' => Arr::get($data, 'skip_scripts', false), + 'allocation_id' => Arr::get($data, 'primary_allocation_id'), + 'allocation_additional' => Arr::get($data, 'secondary_allocations_ids'), + 'start_on_completion' => Arr::get($data, 'start_on_completion', false), + 'database_limit' => Arr::get($data, 'database_limit'), + 'allocation_limit' => Arr::get($data, 'allocation_limit'), + 'backup_limit' => Arr::get($data, 'backup_limit'), + 'oom_disabled' => Arr::get($data, 'oom_disabled'), + ]; + JsonValueGuard::assertPayload9($payload); + + return ServerCreationData::parse($payload); + } + + /** + * @return list + */ + public function after(): array + { + return [$this->validateDeployTagsExist(...)]; + } + + /** Build a deployment object from the deploy payload, or null when absent. */ + public function getDeploymentObject(): ?DeploymentObject + { + if (($this->input('deploy')) === null) { + return null; + } + + $object = new DeploymentObject; + $object->setDedicated($this->boolean('deploy.dedicated_ip')); + $object->setLocations(JsonValueGuard::normalizedIntegerList(JsonValueGuard::integerStringList($this->input('deploy.locations', [])))); + $object->setPorts(JsonValueGuard::stringList($this->input('deploy.port_range', []))); + $object->setTags($this->resolveDeployTagSlugs()); + + return $object; + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/ToggleInstallRequest.php b/app/Http/Requests/Api/Admin/Servers/ToggleInstallRequest.php new file mode 100644 index 000000000..227162b7b --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/ToggleInstallRequest.php @@ -0,0 +1,15 @@ +parameter('server', Server::class); + + return [ + 'node_id' => [ + 'required', + 'integer', + 'exists:nodes,id', + Rule::notIn([$server->node_id]), + ], + 'allocation_id' => ['required', 'bail', 'unique:servers', 'exists:allocations,id'], + 'allocation_additional' => ['nullable', 'array', 'list'], + 'allocation_additional.*' => ['required', Rule::anyOf([['integer:strict'], ['string']]), 'integer'], + ]; + } + + /** + * Chosen allocations must belong to the target node and be unassigned. + * + * @return list + */ + public function after(): array + { + return [function (Validator $validator): void { + $this->validateArrayExistence($validator, 'allocation_additional', Allocation::query()); + + // Skip cross-field checks if the basic rules already failed. + if ($validator->errors()->isNotEmpty()) { + return; + } + + $nodeId = $this->integer('node_id'); + $ids = array_unique([$this->integer('allocation_id'), ...$this->additionalAllocations()]); + $count = Allocation::query() + ->whereIn('id', $ids) + ->where('node_id', $nodeId) + ->whereNull('server_id') + ->count(); + + if ($count !== count($ids)) { + $validator->errors()->add('allocation_id', 'The selected allocation must be an unassigned allocation on the target node.'); + } + }]; + } + + /** + * Normalize the validated transfer payload for the controller. + * + * @return ServerTransferData + */ + public function payload(): array + { + return [ + 'node_id' => $this->integer('node_id'), + 'allocation_id' => $this->integer('allocation_id'), + 'allocation_additional' => $this->additionalAllocations(), + ]; + } + + /** @return list */ + private function additionalAllocations(): array + { + return JsonValueGuard::normalizedIntegerList(JsonValueGuard::integerStringList($this->input('allocation_additional') ?? [])); + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/UpdateServerBuildConfigurationRequest.php b/app/Http/Requests/Api/Admin/Servers/UpdateServerBuildConfigurationRequest.php new file mode 100644 index 000000000..52339d671 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/UpdateServerBuildConfigurationRequest.php @@ -0,0 +1,141 @@ +parameter('server', Server::class)); + + return [ + 'allocation_id' => $rules['allocation_id'], + 'oom_disabled' => $rules['oom_disabled'], + + 'memory' => $this->requiredToOptional('memory', $rules['memory']), + 'swap' => $this->requiredToOptional('swap', $rules['swap']), + 'io' => $this->requiredToOptional('io', $rules['io']), + 'cpu' => $this->requiredToOptional('cpu', $rules['cpu']), + 'threads' => $this->requiredToOptional('threads', $rules['threads']), + 'disk' => $this->requiredToOptional('disk', $rules['disk']), + + 'add_allocation_ids' => ['bail', 'array'], + 'add_allocation_ids.*' => ['integer'], + 'remove_allocation_ids' => ['bail', 'array'], + 'remove_allocation_ids.*' => ['integer'], + + 'database_limit' => $rules['database_limit'], + 'allocation_limit' => $rules['allocation_limit'], + 'backup_limit' => $rules['backup_limit'], + ]; + } + + /** + * Rename the allocation id fields into the add/remove keys the service expects. + * + * @return ServerBuildModificationData + */ + public function payload(): array + { + $data = []; + + if ($this->has('oom_disabled')) { + $data['oom_disabled'] = $this->boolean('oom_disabled'); + } + + foreach (['memory', 'swap', 'io', 'cpu', 'disk', 'allocation_id'] as $field) { + if ($this->filled($field)) { + $data[$field] = $this->integer($field); + } + } + + if ($this->has('threads')) { + $data['threads'] = $this->filled('threads') ? $this->string('threads')->toString() : null; + } + + foreach (['database_limit', 'allocation_limit', 'backup_limit'] as $field) { + if ($this->has($field)) { + $data[$field] = $this->filled($field) ? $this->integer($field) : null; + } + } + + if ($this->has('add_allocation_ids')) { + $data['add_allocations'] = $this->integerList('add_allocation_ids'); + } + + if ($this->has('remove_allocation_ids')) { + $data['remove_allocations'] = $this->integerList('remove_allocation_ids'); + } + + return $data; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'add_allocation_ids' => 'allocations to add', + 'remove_allocation_ids' => 'allocations to remove', + 'add_allocation_ids.*' => 'allocation to add', + 'remove_allocation_ids.*' => 'allocation to remove', + 'database_limit' => 'Database Limit', + 'allocation_limit' => 'Allocation Limit', + 'backup_limit' => 'Backup Limit', + ]; + } + + /** + * Relax a `required` limit rule into required_with/without:limits for backwards compat. @see https://github.com/pterodactyl/panel/issues/1500 + * + * @param ValidationRuleSet $rules + * @return ValidationRuleSet + */ + protected function requiredToOptional(string $field, array $rules, bool $limits = false): array + { + if (! in_array('required', $rules, true)) { + return $rules; + } + + $optional = [$limits ? 'required_with:limits' : 'required_without:limits']; + foreach ($rules as $rule) { + if ($rule !== 'required') { + $optional[] = $rule; + } + } + + return $optional; + } + + /** @return list */ + private function integerList(string $field): array + { + $values = $this->input($field, []); + throw_if(! is_array($values) || ! array_is_list($values), UnexpectedValueException::class, "The validated [{$field}] field must be a list."); + + $integers = []; + foreach ($values as $value) { + throw_unless(is_int($value), UnexpectedValueException::class, "The validated [{$field}] field must contain integers."); + + $integers[] = $value; + } + + return $integers; + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/UpdateServerDetailsRequest.php b/app/Http/Requests/Api/Admin/Servers/UpdateServerDetailsRequest.php new file mode 100644 index 000000000..b12a5eb5a --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/UpdateServerDetailsRequest.php @@ -0,0 +1,58 @@ +parameter('server', Server::class)); + + return [ + 'external_id' => $rules['external_id'], + 'name' => $rules['name'], + 'owner_id' => $rules['owner_id'], + 'description' => array_merge(['nullable'], $rules['description']), + ]; + } + + /** + * Normalize the validated data for the service. + * + * @return ServerDetailsModificationData + */ + public function payload(): array + { + return [ + 'external_id' => $this->filled('external_id') ? $this->string('external_id')->toString() : null, + 'name' => $this->string('name')->toString(), + 'owner_id' => $this->integer('owner_id'), + 'description' => $this->filled('description') ? $this->string('description')->toString() : null, + ]; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'owner_id' => 'User ID', + 'name' => 'Server Name', + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/UpdateServerStartupRequest.php b/app/Http/Requests/Api/Admin/Servers/UpdateServerStartupRequest.php new file mode 100644 index 000000000..bb77d83fa --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/UpdateServerStartupRequest.php @@ -0,0 +1,48 @@ +parameter('server', Server::class)); + + return [ + 'startup' => $data['startup'], + 'environment' => ['present', 'array'], + 'egg_id' => $data['egg_id'], + 'docker_image' => $data['image'], + 'skip_scripts' => ['present', 'boolean'], + ]; + } + + /** + * Normalize the validated data for the service. + * + * @return ServerStartupModificationData + */ + public function payload(): array + { + return $this->serverStartupData('egg_id', 'docker_image'); + } +} diff --git a/app/Http/Requests/Api/Admin/Servers/UpdateServerSuspensionRequest.php b/app/Http/Requests/Api/Admin/Servers/UpdateServerSuspensionRequest.php new file mode 100644 index 000000000..294bff87d --- /dev/null +++ b/app/Http/Requests/Api/Admin/Servers/UpdateServerSuspensionRequest.php @@ -0,0 +1,27 @@ + ['nullable', 'boolean'], + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Settings/GetSettingsRequest.php b/app/Http/Requests/Api/Admin/Settings/GetSettingsRequest.php new file mode 100644 index 000000000..9b3122334 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Settings/GetSettingsRequest.php @@ -0,0 +1,16 @@ + ['required', 'in:true,false'], + 'recaptcha:secret_key' => ['required', 'string', 'max:191'], + 'recaptcha:website_key' => ['required', 'string', 'max:191'], + 'pterodactyl:guzzle:timeout' => ['required', 'integer', 'between:1,60'], + 'pterodactyl:guzzle:connect_timeout' => ['required', 'integer', 'between:1,60'], + 'pterodactyl:client_features:allocations:enabled' => ['required', 'in:true,false'], + 'pterodactyl:client_features:allocations:range_start' => [ + 'nullable', + 'required_if:pterodactyl:client_features:allocations:enabled,true', + 'integer', + 'between:1024,65535', + ], + 'pterodactyl:client_features:allocations:range_end' => [ + 'nullable', + 'required_if:pterodactyl:client_features:allocations:enabled,true', + 'integer', + 'between:1024,65535', + 'gt:pterodactyl:client_features:allocations:range_start', + ], + ]; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'recaptcha:enabled' => 'reCAPTCHA Enabled', + 'recaptcha:secret_key' => 'reCAPTCHA Secret Key', + 'recaptcha:website_key' => 'reCAPTCHA Website Key', + 'pterodactyl:guzzle:timeout' => 'HTTP Request Timeout', + 'pterodactyl:guzzle:connect_timeout' => 'HTTP Connection Timeout', + 'pterodactyl:client_features:allocations:enabled' => 'Auto Create Allocations Enabled', + 'pterodactyl:client_features:allocations:range_start' => 'Starting Port', + 'pterodactyl:client_features:allocations:range_end' => 'Ending Port', + ]; + } + + /** + * Pull the settings keys for persistence, including empty fields as null. + * + * @param list|null $only + * @return AdvancedSettingsData + */ + public function normalize(?array $only = null): array + { + return [ + 'recaptcha:enabled' => $this->string('recaptcha:enabled')->toString(), + 'recaptcha:secret_key' => $this->string('recaptcha:secret_key')->toString(), + 'recaptcha:website_key' => $this->string('recaptcha:website_key')->toString(), + 'pterodactyl:guzzle:timeout' => $this->integer('pterodactyl:guzzle:timeout'), + 'pterodactyl:guzzle:connect_timeout' => $this->integer('pterodactyl:guzzle:connect_timeout'), + 'pterodactyl:client_features:allocations:enabled' => $this->string('pterodactyl:client_features:allocations:enabled')->toString(), + 'pterodactyl:client_features:allocations:range_start' => $this->input('pterodactyl:client_features:allocations:range_start') === null + ? null + : $this->integer('pterodactyl:client_features:allocations:range_start'), + 'pterodactyl:client_features:allocations:range_end' => $this->input('pterodactyl:client_features:allocations:range_end') === null + ? null + : $this->integer('pterodactyl:client_features:allocations:range_end'), + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Settings/UpdateGeneralSettingsRequest.php b/app/Http/Requests/Api/Admin/Settings/UpdateGeneralSettingsRequest.php new file mode 100644 index 000000000..aedd0d36f --- /dev/null +++ b/app/Http/Requests/Api/Admin/Settings/UpdateGeneralSettingsRequest.php @@ -0,0 +1,59 @@ + ['required', 'string', 'max:191'], + 'misc.required_2fa' => ['required', 'integer', 'in:0,1,2'], + 'default_locale' => ['required', 'string', Rule::in(array_keys($this->getAvailableLanguages()))], + ]; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'branding.name' => 'Company Name', + 'misc.required_2fa' => 'Require 2-Factor Authentication', + 'default_locale' => 'Default Language', + ]; + } + + /** + * Map input keys onto the colon-namespaced settings storage keys. + * + * @param list|null $only + * @return GeneralSettingsData + */ + public function normalize(?array $only = null): array + { + return [ + 'app:name' => $this->string('branding.name')->toString(), + 'pterodactyl:auth:2fa_required' => $this->integer('misc.required_2fa'), + 'app:locale' => $this->string('default_locale')->toString(), + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Settings/UpdateMailSettingsRequest.php b/app/Http/Requests/Api/Admin/Settings/UpdateMailSettingsRequest.php new file mode 100644 index 000000000..2703b80e3 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Settings/UpdateMailSettingsRequest.php @@ -0,0 +1,59 @@ + ['required', 'string'], + 'smtp.port' => ['required', 'integer', 'between:1,65535'], + 'smtp.encryption' => ['present', Rule::in([null, 'tls', 'ssl'])], + 'smtp.username' => ['nullable', 'string', 'max:191'], + 'smtp.password' => ['nullable', 'string', 'max:191'], + 'smtp.from_address' => ['required', 'string', 'email'], + 'smtp.from_name' => ['nullable', 'string', 'max:191'], + ]; + } + + /** + * Map smtp.* input onto settings storage keys; password is only included when present so it is never blanked out. + * + * @param list|null $only + * @return MailSettingsData + */ + public function normalize(?array $only = null): array + { + $values = [ + 'mail:mailers:smtp:host' => $this->string('smtp.host')->toString(), + 'mail:mailers:smtp:port' => $this->integer('smtp.port'), + 'mail:mailers:smtp:encryption' => $this->filled('smtp.encryption') ? $this->string('smtp.encryption')->toString() : null, + 'mail:mailers:smtp:username' => $this->filled('smtp.username') ? $this->string('smtp.username')->toString() : null, + 'mail:from:address' => $this->string('smtp.from_address')->toString(), + 'mail:from:name' => $this->filled('smtp.from_name') ? $this->string('smtp.from_name')->toString() : null, + ]; + + if (! empty($this->input('smtp.password'))) { + $values['mail:mailers:smtp:password'] = $this->string('smtp.password')->toString(); + } + + return $values; + } +} diff --git a/app/Http/Requests/Api/Admin/Tags/DeleteTagRequest.php b/app/Http/Requests/Api/Admin/Tags/DeleteTagRequest.php new file mode 100644 index 000000000..fa5d3dab0 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Tags/DeleteTagRequest.php @@ -0,0 +1,16 @@ +withSlugRule(TagRules::rules()); + } + + /** + * Narrow the model rules to the writable fields and forbid numeric slugs, so a + * leftover legacy nest id can be told apart from a real tag and a slug can never + * shadow a tag id (see TagSlug). + * + * @param NormalizedValidationRules $rules + * @return NormalizedValidationRules + */ + protected function withSlugRule(array $rules): array + { + $rules = ValidationRuleSubset::select($rules, ['name', 'slug', 'color']); + $rules['slug'] = array_merge($rules['slug'], [new TagSlug]); + + return $rules; + } +} diff --git a/app/Http/Requests/Api/Admin/Tags/SyncTagsRequest.php b/app/Http/Requests/Api/Admin/Tags/SyncTagsRequest.php new file mode 100644 index 000000000..c17adb9e3 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Tags/SyncTagsRequest.php @@ -0,0 +1,63 @@ + ['present', 'array'], + // A numeric value is read as an existing tag id rather than a new name. + // \Pterodactyl\Rules\TagSlug is what keeps those two spaces from + // overlapping, so no rule is needed here beyond the length bound. + 'tags.*' => ['string', 'max:191'], + ]; + } + + /** + * The submitted values, normalised to strings for the resolver. + * + * @return list + */ + public function tagValues(): array + { + $values = $this->input('tags', []); + if (! is_array($values)) { + return []; + } + + $tags = []; + foreach ($values as $tag) { + if (is_string($tag)) { + $tags[] = $tag; + } elseif (is_int($tag)) { + // SAFETY: integer tag IDs have an exact decimal string representation. + $tags[] = (string) $tag; + } + } + + return $tags; + } +} diff --git a/app/Http/Requests/Api/Admin/Tags/UpdateTagRequest.php b/app/Http/Requests/Api/Admin/Tags/UpdateTagRequest.php new file mode 100644 index 000000000..7635af3ea --- /dev/null +++ b/app/Http/Requests/Api/Admin/Tags/UpdateTagRequest.php @@ -0,0 +1,25 @@ +withSlugRule(TagRules::rules($this->parameter('tag', Tag::class))); + } +} diff --git a/app/Http/Requests/Api/Admin/Users/DeleteUserRequest.php b/app/Http/Requests/Api/Admin/Users/DeleteUserRequest.php new file mode 100644 index 000000000..5a33b915b --- /dev/null +++ b/app/Http/Requests/Api/Admin/Users/DeleteUserRequest.php @@ -0,0 +1,16 @@ + JsonValueGuard::string(Arr::get($validated, 'email')), + 'username' => JsonValueGuard::string(Arr::get($validated, 'username')), + 'name_first' => JsonValueGuard::string(Arr::get($validated, 'name_first')), + 'name_last' => JsonValueGuard::string(Arr::get($validated, 'name_last')), + ]; + + foreach (['external_id', 'password'] as $nullable) { + if (array_key_exists($nullable, $validated)) { + $value = Arr::get($validated, $nullable); + $data[$nullable] = $value !== null && $value !== '' ? JsonValueGuard::string($value) : null; + } + } + + if (array_key_exists('root_admin', $validated)) { + $data['root_admin'] = JsonValueGuard::boolean(Arr::get($validated, 'root_admin')); + } + + $language = Arr::get($validated, 'preferences.language'); + if ($language !== null && $language !== '') { + $data['language'] = JsonValueGuard::string($language); + } + + return $data; + } + + /** Rename fields to be more clear in error messages. */ + public function attributes(): array + { + return [ + 'external_id' => 'Third Party Identifier', + 'name_first' => 'First Name', + 'name_last' => 'Last Name', + 'root_admin' => 'Root Administrator Status', + ]; + } +} diff --git a/app/Http/Requests/Api/Admin/Users/UpdateUserRequest.php b/app/Http/Requests/Api/Admin/Users/UpdateUserRequest.php new file mode 100644 index 000000000..94ae943d2 --- /dev/null +++ b/app/Http/Requests/Api/Admin/Users/UpdateUserRequest.php @@ -0,0 +1,28 @@ +parameter('user', User::class))); + } +} diff --git a/app/Http/Requests/Api/ApiRequest.php b/app/Http/Requests/Api/ApiRequest.php new file mode 100644 index 000000000..db251780e --- /dev/null +++ b/app/Http/Requests/Api/ApiRequest.php @@ -0,0 +1,72 @@ +validated('per_page') ?? $default, FILTER_VALIDATE_INT); + throw_if($perPage === false, InvalidArgumentException::class, 'The validated per-page value must be an integer.'); + + return $perPage; + } + + /** + * Returns the named route parameter and asserts that it is a real model that + * exists in the database. + * + * @template T of \Illuminate\Database\Eloquent\Model + * + * @param class-string $expect + * @return T + * + * @noinspection PhpDocSignatureInspection + */ + public function parameter(string $key, string $expect): Model + { + $route = $this->route(); + throw_if($route === null, InvalidArgumentException::class, 'Cannot resolve a route parameter without an active route.'); + + $value = $route->parameter($key); + + throw_unless($value instanceof $expect, InvalidArgumentException::class, "Route parameter [$key] is not a valid model."); + + throw_unless($value->exists, InvalidArgumentException::class, "Route parameter [$key] does not exist."); + + return $value; + } + + /** @return ValidationRules */ + protected function validationRules(): array + { + if (! $this->isMethod('GET')) { + return $this->rules(); + } + + return array_merge($this->rules(), [ + 'page' => ['sometimes', 'integer', 'min:1'], + 'per_page' => ['sometimes', 'integer', 'min:1', 'max:'.self::MAX_PER_PAGE], + ]); + } +} diff --git a/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php b/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php index 6529a9a5a..c2f0784ea 100644 --- a/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php +++ b/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php @@ -1,9 +1,11 @@ 'required|string', - 'alias' => 'sometimes|nullable|string|max:191', - 'ports' => 'required|array', - 'ports.*' => 'string', + 'ip' => ['required', 'string'], + 'alias' => ['sometimes', 'nullable', 'string', 'max:191'], + 'ports' => ['required', 'array'], + 'ports.*' => ['string'], ]; } - public function validated($key = null, $default = null): array + /** + * @return AllocationAssignmentData + */ + public function payload(): array { $data = parent::validated(); + $ip = $data['ip'] ?? null; + $ports = $data['ports'] ?? null; + $alias = $data['alias'] ?? null; + + throw_if(! is_string($ip) || ! is_array($ports) || ! array_is_list($ports), UnexpectedValueException::class, 'Validated allocation data has an invalid structure.'); + + $normalizedPorts = []; + foreach ($ports as $port) { + throw_unless(is_string($port), UnexpectedValueException::class, 'Validated allocation ports must be strings.'); + + $normalizedPorts[] = $port; + } + + throw_if($alias !== null && ! is_string($alias), UnexpectedValueException::class, 'Validated allocation aliases must be strings or null.'); return [ - 'allocation_ip' => $data['ip'], - 'allocation_ports' => $data['ports'], - 'allocation_alias' => $data['alias'] ?? null, + 'allocation_ip' => $ip, + 'allocation_ports' => $normalizedPorts, + 'allocation_alias' => $alias, ]; } } diff --git a/app/Http/Requests/Api/Application/ApplicationApiRequest.php b/app/Http/Requests/Api/Application/ApplicationApiRequest.php index bddbfba0f..4e9eb4f1b 100644 --- a/app/Http/Requests/Api/Application/ApplicationApiRequest.php +++ b/app/Http/Requests/Api/Application/ApplicationApiRequest.php @@ -1,23 +1,22 @@ resource)) { - throw new PterodactylException('An ACL resource must be defined on API requests.'); - } + throw_if(($this->resource) === null, PterodactylException::class, 'An ACL resource must be defined on API requests.'); - $token = $this->user()->currentAccessToken(); - if ($token instanceof TransientToken) { // @phpstan-ignore instanceof.alwaysFalse + $user = $this->user(); + throw_if($user === null, PterodactylException::class, 'Application API requests require an authenticated user.'); + + $token = $user->currentAccessToken(); + if ($token === null || $token instanceof TransientToken) { return true; } @@ -48,46 +48,4 @@ abstract class ApplicationApiRequest extends FormRequest return AdminAcl::check($token, $this->resource, $this->permission); } - - /** - * Default set of rules to apply to API requests. - */ - public function rules(): array - { - return []; - } - - /** - * Helper method allowing a developer to easily hook into this logic without having - * to remember what the method name is called or where to use it. By default this is - * a no-op. - */ - public function withValidator(Validator $validator): void - { - // do nothing - } - - /** - * Returns the named route parameter and asserts that it is a real model that - * exists in the database. - * - * @template T of \Illuminate\Database\Eloquent\Model - * - * @param class-string $expect - * - * @return T - * - * @noinspection PhpDocSignatureInspection - */ - public function parameter(string $key, string $expect) - { - $value = $this->route()->parameter($key); - - Assert::isInstanceOf($value, $expect); - Assert::isInstanceOf($value, Model::class); // @phpstan-ignore staticMethod.alreadyNarrowedType - Assert::true($value->exists); - - /* @var T $value */ - return $value; - } } diff --git a/app/Http/Requests/Api/Application/Nests/Eggs/GetEggRequest.php b/app/Http/Requests/Api/Application/Eggs/GetEggRequest.php similarity index 77% rename from app/Http/Requests/Api/Application/Nests/Eggs/GetEggRequest.php rename to app/Http/Requests/Api/Application/Eggs/GetEggRequest.php index 7c6eb5412..f4964ac2a 100644 --- a/app/Http/Requests/Api/Application/Nests/Eggs/GetEggRequest.php +++ b/app/Http/Requests/Api/Application/Eggs/GetEggRequest.php @@ -1,9 +1,11 @@ only([ - 'long', - 'short', - ])->toArray(); + return LocationRules::rules(); } /** @@ -33,4 +34,13 @@ class StoreLocationRequest extends ApplicationApiRequest 'short' => 'Location Identifier', ]; } + + /** @return LocationCreationData */ + public function payload(): array + { + return [ + 'short' => $this->string('short')->toString(), + 'long' => $this->filled('long') ? $this->string('long')->toString() : null, + ]; + } } diff --git a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php b/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php index afda4a15b..8a3963614 100644 --- a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php +++ b/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php @@ -1,21 +1,21 @@ route()->parameter('location')->id; // @phpstan-ignore property.nonObject - - return collect(Location::getRulesForUpdate($locationId))->only([ - 'short', - 'long', - ])->toArray(); + return LocationRules::rules($this->parameter('location', Location::class)); } } diff --git a/app/Http/Requests/Api/Application/Nests/GetNestsRequest.php b/app/Http/Requests/Api/Application/Nests/GetNestsRequest.php deleted file mode 100644 index b4a990f9f..000000000 --- a/app/Http/Requests/Api/Application/Nests/GetNestsRequest.php +++ /dev/null @@ -1,13 +0,0 @@ - 'integer', - 'memory' => 'required|integer|min:0', - 'disk' => 'required|integer|min:0', - 'location_ids' => 'array', - 'location_ids.*' => 'integer', + 'page' => ['sometimes', 'integer', 'min:1'], + 'per_page' => ['sometimes', 'integer', 'min:1', 'max:100'], + 'memory' => ['required', 'integer', 'min:0'], + 'disk' => ['required', 'integer', 'min:0'], + 'location_ids' => ['sometimes', 'array'], + 'location_ids.*' => ['integer'], + ]; + } + + /** + * @return array{memory: int, disk: int, location_ids: list, per_page: int|null, page: int|null} + */ + public function payload(): array + { + $validated = parent::validated(); + + $rawLocationIds = Arr::get($validated, 'location_ids', []); + throw_unless(is_array($rawLocationIds), UnexpectedValueException::class, 'The validated [location_ids] field must be an array.'); + + $locationIds = []; + foreach ($rawLocationIds as $rawLocationId) { + $locationIds[] = JsonValueGuard::integer($rawLocationId); + } + + return [ + 'memory' => JsonValueGuard::integer($validated['memory']), + 'disk' => JsonValueGuard::integer($validated['disk']), + 'location_ids' => $locationIds, + 'per_page' => isset($validated['per_page']) ? JsonValueGuard::integer($validated['per_page']) : null, + 'page' => isset($validated['page']) ? JsonValueGuard::integer($validated['page']) : null, ]; } } diff --git a/app/Http/Requests/Api/Application/Nodes/GetNodeConfigurationRequest.php b/app/Http/Requests/Api/Application/Nodes/GetNodeConfigurationRequest.php new file mode 100644 index 000000000..cba8e6c55 --- /dev/null +++ b/app/Http/Requests/Api/Application/Nodes/GetNodeConfigurationRequest.php @@ -0,0 +1,15 @@ +only([ + $selected = ValidationRuleSubset::select($rules ?? NodeRules::rules(), [ 'public', 'name', 'description', @@ -34,11 +43,15 @@ class StoreNodeRequest extends ApplicationApiRequest 'daemonListen', 'daemonSFTP', 'daemonBase', - ])->mapWithKeys(function ($value, $key) { - $key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key; + ]); - return [snake_case($key) => $value]; - })->toArray(); + $normalized = []; + foreach ($selected as $key => $value) { + $key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key; + $normalized[Str::snake($key)] = $value; + } + + return $normalized; } /** @@ -57,15 +70,44 @@ class StoreNodeRequest extends ApplicationApiRequest /** * Change the formatting of some data keys in the validated response data * to match what the application expects in the services. + * + * @return NodeCreationData */ - public function validated($key = null, $default = null): array + public function payload(): array { - $response = parent::validated(); - $response['daemonListen'] = $response['daemon_listen']; - $response['daemonSFTP'] = $response['daemon_sftp']; - $response['daemonBase'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemonBase'); + $data = parent::validated(); - unset($response['daemon_base'], $response['daemon_listen'], $response['daemon_sftp']); + $daemonBase = Arr::get($data, 'daemon_base'); + + $response = [ + 'name' => JsonValueGuard::string(Arr::get($data, 'name')), + 'location_id' => JsonValueGuard::integer(Arr::get($data, 'location_id')), + 'fqdn' => JsonValueGuard::string(Arr::get($data, 'fqdn')), + 'scheme' => JsonValueGuard::string(Arr::get($data, 'scheme')), + 'memory' => JsonValueGuard::integer(Arr::get($data, 'memory')), + 'memory_overallocate' => JsonValueGuard::integer(Arr::get($data, 'memory_overallocate')), + 'disk' => JsonValueGuard::integer(Arr::get($data, 'disk')), + 'disk_overallocate' => JsonValueGuard::integer(Arr::get($data, 'disk_overallocate')), + 'daemonListen' => JsonValueGuard::integer(Arr::get($data, 'daemon_listen')), + 'daemonSFTP' => JsonValueGuard::integer(Arr::get($data, 'daemon_sftp')), + 'daemonBase' => $daemonBase !== null && $daemonBase !== '' ? JsonValueGuard::string($daemonBase) : '/var/lib/pterodactyl/volumes', + ]; + + if (array_key_exists('description', $data)) { + $description = Arr::get($data, 'description'); + $response['description'] = $description !== null && $description !== '' ? JsonValueGuard::string($description) : null; + } + + foreach (['public', 'behind_proxy', 'maintenance_mode'] as $boolean) { + if (array_key_exists($boolean, $data)) { + $response[$boolean] = JsonValueGuard::boolean(Arr::get($data, $boolean)); + } + } + + $uploadSize = Arr::get($data, 'upload_size'); + if ($uploadSize !== null && $uploadSize !== '') { + $response['upload_size'] = JsonValueGuard::integer($uploadSize); + } return $response; } diff --git a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php index a968232fe..b414f26d6 100644 --- a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php @@ -1,19 +1,25 @@ parameter('node', Node::class); - - return parent::rules(Node::getRulesForUpdate($node)); + return [ + ...parent::rules(NodeRules::rules()), + 'reset_secret' => ['sometimes', 'boolean'], + ]; } } diff --git a/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php b/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php index 01df4af32..c7f01393e 100644 --- a/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php +++ b/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php @@ -1,9 +1,11 @@ where(function (Builder $query) use ($server) { + Rule::unique('databases')->where(function (Builder $query) use ($server): void { $query->where('server_id', $server->id)->where('database', $this->databaseName()); }), ], - 'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/', - 'host' => 'required|integer|exists:database_hosts,id', + 'remote' => ['required', 'string', 'regex:/^[0-9%.]{1,15}$/'], + 'host' => ['required', 'integer', 'exists:database_hosts,id'], ]; } /** * Return data formatted in the correct format for the service to consume. + * + * @return DatabaseCreationData */ - public function validated($key = null, $default = null): array + public function payload(): array { return [ - 'database' => $this->input('database'), - 'remote' => $this->input('remote'), - 'database_host_id' => $this->input('host'), + 'database' => $this->string('database')->toString(), + 'remote' => $this->string('remote')->toString(), + 'database_host_id' => $this->integer('host'), ]; } @@ -67,10 +73,8 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest */ public function databaseName(): string { - $server = $this->route()->parameter('server'); + $server = $this->parameter('server', Server::class); - Assert::isInstanceOf($server, Server::class); - - return DatabaseManagementService::generateUniqueDatabaseName($this->input('database'), $server->id); + return DatabaseName::generateUnique(JsonValueGuard::string($this->input('database')), $server->id); } } diff --git a/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php b/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php index 50c9dabf8..6bb894a26 100644 --- a/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php +++ b/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php @@ -1,9 +1,11 @@ 'string|max:100', + 'search' => ['string', 'max:100'], ]; } } diff --git a/app/Http/Requests/Api/Application/Servers/ServerWriteRequest.php b/app/Http/Requests/Api/Application/Servers/ServerWriteRequest.php index df2d76cd3..679d00354 100644 --- a/app/Http/Requests/Api/Application/Servers/ServerWriteRequest.php +++ b/app/Http/Requests/Api/Application/Servers/ServerWriteRequest.php @@ -1,9 +1,11 @@ $rules['external_id'], @@ -30,12 +42,12 @@ class StoreServerRequest extends ApplicationApiRequest 'egg' => $rules['egg_id'], 'docker_image' => $rules['image'], 'startup' => $rules['startup'], - 'environment' => 'present|array', - 'skip_scripts' => 'sometimes|boolean', - 'oom_disabled' => 'sometimes|boolean', + 'environment' => ['present', 'array'], + 'skip_scripts' => ['sometimes', 'boolean'], + 'oom_disabled' => ['sometimes', 'boolean'], // Resource limitations - 'limits' => 'required|array', + 'limits' => ['required', 'array'], 'limits.memory' => $rules['memory'], 'limits.swap' => $rules['swap'], 'limits.disk' => $rules['disk'], @@ -44,92 +56,76 @@ class StoreServerRequest extends ApplicationApiRequest 'limits.cpu' => $rules['cpu'], // Application Resource Limits - 'feature_limits' => 'required|array', + 'feature_limits' => ['required', 'array'], 'feature_limits.databases' => $rules['database_limit'], 'feature_limits.allocations' => $rules['allocation_limit'], 'feature_limits.backups' => $rules['backup_limit'], - // Placeholders for rules added in withValidator() function. - 'allocation.default' => '', - 'allocation.additional.*' => '', + // Allocations are chosen by hand unless a deployment object picks them. + 'allocation.default' => ['exclude_with:deploy', 'required', 'integer', 'bail', AllocationRules::unassigned()], + 'allocation.additional.*' => ['exclude_with:deploy', 'integer', AllocationRules::unassigned()], // Automatic deployment rules - 'deploy' => 'sometimes|required|array', - 'deploy.locations' => 'array', - 'deploy.locations.*' => 'integer|min:1', - 'deploy.dedicated_ip' => 'required_with:deploy,boolean', - 'deploy.port_range' => 'array', - 'deploy.port_range.*' => 'string', + 'deploy' => ['sometimes', 'required', 'array'], + 'deploy.locations' => ['present_with:deploy', 'array', 'list'], + 'deploy.locations.*' => ['required', Rule::anyOf([['integer:strict'], ['string']]), 'integer', 'min:1'], + 'deploy.dedicated_ip' => ['required_with:deploy', 'boolean'], + 'deploy.port_range' => ['present_with:deploy', 'array', 'list'], + 'deploy.port_range.*' => ['string'], + // Deploy tags (D): the reservations this deployment opts into. Each may + // be given as a tag id or a slug; existence is checked in after() + // so the message can name the offending value. + 'deploy.tags' => ['array'], + 'deploy.tags.*' => [$this->validateDeployTagReference(...)], - 'start_on_completion' => 'sometimes|boolean', + 'start_on_completion' => ['sometimes', 'boolean'], ]; } /** * Normalize the data into a format that can be consumed by the service. + * + * @return ServerCreationAttributes */ - public function validated($key = null, $default = null): array + public function payload(): array { $data = parent::validated(); - return [ - 'external_id' => array_get($data, 'external_id'), - 'name' => array_get($data, 'name'), - 'description' => array_get($data, 'description'), - 'owner_id' => array_get($data, 'user'), - 'egg_id' => array_get($data, 'egg'), - 'image' => array_get($data, 'docker_image'), - 'startup' => array_get($data, 'startup'), - 'environment' => array_get($data, 'environment'), - 'memory' => array_get($data, 'limits.memory'), - 'swap' => array_get($data, 'limits.swap'), - 'disk' => array_get($data, 'limits.disk'), - 'io' => array_get($data, 'limits.io'), - 'cpu' => array_get($data, 'limits.cpu'), - 'threads' => array_get($data, 'limits.threads'), - 'skip_scripts' => array_get($data, 'skip_scripts', false), - 'allocation_id' => array_get($data, 'allocation.default'), - 'allocation_additional' => array_get($data, 'allocation.additional'), - 'start_on_completion' => array_get($data, 'start_on_completion', false), - 'database_limit' => array_get($data, 'feature_limits.databases'), - 'allocation_limit' => array_get($data, 'feature_limits.allocations'), - 'backup_limit' => array_get($data, 'feature_limits.backups'), - 'oom_disabled' => array_get($data, 'oom_disabled'), + $payload = [ + 'external_id' => Arr::get($data, 'external_id'), + 'name' => Arr::get($data, 'name'), + 'description' => Arr::get($data, 'description'), + 'owner_id' => Arr::get($data, 'user'), + 'egg_id' => Arr::get($data, 'egg'), + 'image' => Arr::get($data, 'docker_image'), + 'startup' => Arr::get($data, 'startup'), + 'environment' => Arr::get($data, 'environment'), + 'memory' => Arr::get($data, 'limits.memory'), + 'swap' => Arr::get($data, 'limits.swap'), + 'disk' => Arr::get($data, 'limits.disk'), + 'io' => Arr::get($data, 'limits.io'), + 'cpu' => Arr::get($data, 'limits.cpu'), + 'threads' => Arr::get($data, 'limits.threads'), + 'skip_scripts' => Arr::get($data, 'skip_scripts', false), + 'allocation_id' => Arr::get($data, 'allocation.default'), + 'allocation_additional' => Arr::get($data, 'allocation.additional'), + 'start_on_completion' => Arr::get($data, 'start_on_completion', false), + 'database_limit' => Arr::get($data, 'feature_limits.databases'), + 'allocation_limit' => Arr::get($data, 'feature_limits.allocations'), + 'backup_limit' => Arr::get($data, 'feature_limits.backups'), + 'oom_disabled' => Arr::get($data, 'oom_disabled'), ]; + JsonValueGuard::assertPayload9($payload); + + return ServerCreationData::parse($payload); } - /* - * Run validation after the rules above have been applied. - * - * @param \Illuminate\Validation\Validator $validator + /** + * @return list */ - public function withValidator(Validator $validator): void + public function after(): array { - $validator->sometimes('allocation.default', [ - 'required', 'integer', 'bail', - Rule::exists('allocations', 'id')->where(function ($query) { - $query->whereNull('server_id'); - }), - ], function ($input) { - return !$input->deploy; - }); - - $validator->sometimes('allocation.additional.*', [ - 'integer', - Rule::exists('allocations', 'id')->where(function ($query) { - $query->whereNull('server_id'); - }), - ], function ($input) { - return !$input->deploy; - }); - - $validator->sometimes('deploy.locations', 'present', function ($input) { - return $input->deploy; - }); - - $validator->sometimes('deploy.port_range', 'present', function ($input) { - return $input->deploy; - }); + return [$this->validateDeployTagsExist(...)]; } /** @@ -137,15 +133,24 @@ class StoreServerRequest extends ApplicationApiRequest */ public function getDeploymentObject(): ?DeploymentObject { - if (is_null($this->input('deploy'))) { + if (($this->input('deploy')) === null) { return null; } - $object = new DeploymentObject(); - $object->setDedicated($this->input('deploy.dedicated_ip', false)); - $object->setLocations($this->input('deploy.locations', [])); - $object->setPorts($this->input('deploy.port_range', [])); + $object = new DeploymentObject; + $object->setDedicated($this->boolean('deploy.dedicated_ip')); + $object->setLocations(JsonValueGuard::normalizedIntegerList(JsonValueGuard::integerStringList($this->input('deploy.locations', [])))); + $object->setPorts(JsonValueGuard::stringList($this->input('deploy.port_range', []))); + $object->setTags($this->resolveDeployTagSlugs()); return $object; } + + /** @phpstan-assert int|string $value */ + private function validateDeployTagReference(string $attribute, mixed $value, Closure $fail): void + { + if (! is_int($value) && ! is_string($value)) { + $fail("The {$attribute} field must be a tag ID or slug."); + } + } } diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php index f1c977f11..43dcd036d 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php @@ -1,24 +1,29 @@ parameter('server', Server::class)); + $rules = ServerRules::rules($this->parameter('server', Server::class)); return [ 'allocation' => $rules['allocation_id'], 'oom_disabled' => $rules['oom_disabled'], - 'limits' => 'sometimes|array', + 'limits' => ['sometimes', 'array'], 'limits.memory' => $this->requiredToOptional('memory', $rules['memory'], true), 'limits.swap' => $this->requiredToOptional('swap', $rules['swap'], true), 'limits.io' => $this->requiredToOptional('io', $rules['io'], true), @@ -37,12 +42,12 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest 'threads' => $this->requiredToOptional('threads', $rules['threads']), 'disk' => $this->requiredToOptional('disk', $rules['disk']), - 'add_allocations' => 'bail|array', - 'add_allocations.*' => 'integer', - 'remove_allocations' => 'bail|array', - 'remove_allocations.*' => 'integer', + 'add_allocations' => ['bail', 'array'], + 'add_allocations.*' => ['integer'], + 'remove_allocations' => ['bail', 'array'], + 'remove_allocations.*' => ['integer'], - 'feature_limits' => 'required|array', + 'feature_limits' => ['required', 'array'], 'feature_limits.databases' => $rules['database_limit'], 'feature_limits.allocations' => $rules['allocation_limit'], 'feature_limits.backups' => $rules['backup_limit'], @@ -51,24 +56,42 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest /** * Convert the allocation field into the expected format for the service handler. + * + * @return ServerBuildModificationData */ - public function validated($key = null, $default = null): array + public function payload(): array { - $data = parent::validated(); + $data = [ + 'database_limit' => $this->filled('feature_limits.databases') ? $this->integer('feature_limits.databases') : null, + 'allocation_limit' => $this->filled('feature_limits.allocations') ? $this->integer('feature_limits.allocations') : null, + 'backup_limit' => $this->filled('feature_limits.backups') ? $this->integer('feature_limits.backups') : null, + ]; - $data['allocation_id'] = $data['allocation']; - $data['database_limit'] = $data['feature_limits']['databases'] ?? null; - $data['allocation_limit'] = $data['feature_limits']['allocations'] ?? null; - $data['backup_limit'] = $data['feature_limits']['backups'] ?? null; - unset($data['allocation'], $data['feature_limits']); + if ($this->filled('allocation')) { + $data['allocation_id'] = $this->integer('allocation'); + } - // Adjust the limits field to match what is expected by the model. - if (!empty($data['limits'])) { - foreach ($data['limits'] as $key => $value) { - $data[$key] = $value; + if ($this->has('oom_disabled')) { + $data['oom_disabled'] = $this->boolean('oom_disabled'); + } + + foreach (['memory', 'swap', 'io', 'cpu', 'disk'] as $field) { + if ($this->filled("limits.{$field}")) { + $data[$field] = $this->integer("limits.{$field}"); + } elseif ($this->filled($field)) { + $data[$field] = $this->integer($field); } + } - unset($data['limits']); + if ($this->has('limits.threads') || $this->has('threads')) { + $field = $this->has('limits.threads') ? 'limits.threads' : 'threads'; + $data['threads'] = $this->filled($field) ? $this->string($field)->toString() : null; + } + + foreach (['add_allocations', 'remove_allocations'] as $field) { + if ($this->has($field)) { + $data[$field] = $this->integerList($field); + } } return $data; @@ -96,18 +119,39 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest * call. * * @see https://github.com/pterodactyl/panel/issues/1500 + * + * @param ValidationRuleSet $rules + * @return ValidationRuleSet */ protected function requiredToOptional(string $field, array $rules, bool $limits = false): array { - if (!in_array('required', $rules)) { + if (! in_array('required', $rules, true)) { return $rules; } - return (new Collection($rules)) - ->filter(function ($value) { - return $value !== 'required'; - }) - ->prepend($limits ? 'required_with:limits' : 'required_without:limits') - ->toArray(); + $optional = [$limits ? 'required_with:limits' : 'required_without:limits']; + foreach ($rules as $rule) { + if ($rule !== 'required') { + $optional[] = $rule; + } + } + + return $optional; + } + + /** @return list */ + private function integerList(string $field): array + { + $values = $this->input($field, []); + throw_if(! is_array($values) || ! array_is_list($values), UnexpectedValueException::class, "The validated [{$field}] field must be a list."); + + $integers = []; + foreach ($values as $value) { + throw_unless(is_int($value), UnexpectedValueException::class, "The validated [{$field}] field must contain integers."); + + $integers[] = $value; + } + + return $integers; } } diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php index aecc1cf02..dcd7bf37f 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php @@ -1,17 +1,22 @@ parameter('server', Server::class)); + $rules = ServerRules::rules($this->parameter('server', Server::class)); return [ 'external_id' => $rules['external_id'], @@ -24,14 +29,16 @@ class UpdateServerDetailsRequest extends ServerWriteRequest /** * Convert the posted data into the correct format that is expected * by the application. + * + * @return ServerDetailsModificationData */ - public function validated($key = null, $default = null): array + public function payload(): array { return [ - 'external_id' => $this->input('external_id'), - 'name' => $this->input('name'), - 'owner_id' => $this->input('user'), - 'description' => $this->input('description'), + 'external_id' => $this->filled('external_id') ? $this->string('external_id')->toString() : null, + 'name' => $this->string('name')->toString(), + 'owner_id' => $this->integer('user'), + 'description' => $this->filled('description') ? $this->string('description')->toString() : null, ]; } diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php index 985b10a6f..4dacb3065 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php @@ -1,43 +1,48 @@ parameter('server', Server::class)); + $data = ServerRules::rules($this->parameter('server', Server::class)); return [ 'startup' => $data['startup'], - 'environment' => 'present|array', + 'environment' => ['present', 'array'], 'egg' => $data['egg_id'], 'image' => $data['image'], - 'skip_scripts' => 'present|boolean', + 'skip_scripts' => ['present', 'boolean'], ]; } /** * Return the validated data in a format that is expected by the service. + * + * @return ServerStartupModificationData */ - public function validated($key = null, $default = null): array + public function payload(): array { - $data = parent::validated(); - - return collect($data)->only(['startup', 'environment', 'skip_scripts'])->merge([ - 'egg_id' => array_get($data, 'egg'), - 'docker_image' => array_get($data, 'image'), - ])->toArray(); + return $this->serverStartupData('egg', 'image'); } } diff --git a/app/Http/Requests/Api/Application/Tags/GetTagRequest.php b/app/Http/Requests/Api/Application/Tags/GetTagRequest.php new file mode 100644 index 000000000..325a5b57b --- /dev/null +++ b/app/Http/Requests/Api/Application/Tags/GetTagRequest.php @@ -0,0 +1,15 @@ +only([ + $response = ValidationRuleSubset::select($rules, [ 'external_id', 'email', 'username', 'password', 'language', 'root_admin', - ])->toArray(); + ]); $response['first_name'] = $rules['name_first']; $response['last_name'] = $rules['name_last']; @@ -34,14 +42,35 @@ class StoreUserRequest extends ApplicationApiRequest return $response; } - public function validated($key = null, $default = null): array + /** + * @return UserCreationData + */ + public function payload(): array { - $data = parent::validated(); + $validated = parent::validated(); - $data['name_first'] = $data['first_name']; - $data['name_last'] = $data['last_name']; + $data = [ + 'email' => JsonValueGuard::string(Arr::get($validated, 'email')), + 'username' => JsonValueGuard::string(Arr::get($validated, 'username')), + 'name_first' => JsonValueGuard::string(Arr::get($validated, 'first_name')), + 'name_last' => JsonValueGuard::string(Arr::get($validated, 'last_name')), + ]; - unset($data['first_name'], $data['last_name']); + foreach (['external_id', 'password'] as $nullable) { + if (array_key_exists($nullable, $validated)) { + $value = Arr::get($validated, $nullable); + $data[$nullable] = $value !== null && $value !== '' ? JsonValueGuard::string($value) : null; + } + } + + if (array_key_exists('root_admin', $validated)) { + $data['root_admin'] = JsonValueGuard::boolean(Arr::get($validated, 'root_admin')); + } + + $language = Arr::get($validated, 'language'); + if ($language !== null && $language !== '') { + $data['language'] = JsonValueGuard::string($language); + } return $data; } diff --git a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php index b31a3c52c..46e373025 100644 --- a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php @@ -1,18 +1,22 @@ parameter('user', User::class)->id; - - return parent::rules(User::getRulesForUpdate($userId)); + return parent::rules(UserRules::rules($this->parameter('user', User::class))); } } diff --git a/app/Http/Requests/Api/Client/Account/DeleteSSHKeyRequest.php b/app/Http/Requests/Api/Client/Account/DeleteSSHKeyRequest.php new file mode 100644 index 000000000..aa07892db --- /dev/null +++ b/app/Http/Requests/Api/Client/Account/DeleteSSHKeyRequest.php @@ -0,0 +1,20 @@ + ['required', 'string'], + ]; + } +} diff --git a/app/Http/Requests/Api/Client/Account/DisableTwoFactorRequest.php b/app/Http/Requests/Api/Client/Account/DisableTwoFactorRequest.php new file mode 100644 index 000000000..5c71ebccc --- /dev/null +++ b/app/Http/Requests/Api/Client/Account/DisableTwoFactorRequest.php @@ -0,0 +1,20 @@ + ['required', 'string'], + ]; + } +} diff --git a/app/Http/Requests/Api/Client/Account/EnableTwoFactorRequest.php b/app/Http/Requests/Api/Client/Account/EnableTwoFactorRequest.php new file mode 100644 index 000000000..cc65b63d2 --- /dev/null +++ b/app/Http/Requests/Api/Client/Account/EnableTwoFactorRequest.php @@ -0,0 +1,21 @@ + ['required', 'string', 'size:6'], + 'password' => ['required', 'string'], + ]; + } +} diff --git a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php index efa1cc3cd..5edf907e4 100644 --- a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php @@ -1,47 +1,61 @@ $rules['memo'], - 'allowed_ips' => [...$rules['allowed_ips'], 'max:50'], - 'allowed_ips.*' => 'string', + 'allowed_ips' => [...$rules['allowed_ips'], 'list', 'max:50'], + 'allowed_ips.*' => ['string'], ]; } /** * Check that each of the values entered is actually valid. */ - public function withValidator(Validator $validator): void + /** + * @return list + */ + public function after(): array { - $validator->after(function (Validator $validator) { - if (!is_array($ips = $this->input('allowed_ips'))) { + return [function (Validator $validator): void { + if (! is_array($ips = $this->input('allowed_ips'))) { return; } foreach ($ips as $index => $ip) { $valid = false; + if (! is_string($ip)) { + $validator->errors()->add("allowed_ips.{$index}", 'The IP address or CIDR range must be a string.'); + + continue; + } + try { $valid = Range::parse($ip)->valid(); - } catch (\Exception $exception) { - if ($exception->getMessage() !== 'Invalid IP address format') { - throw $exception; - } + } catch (Exception $exception) { + throw_if($exception->getMessage() !== 'Invalid IP address format', $exception); } finally { - $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"' . $ip . '" is not a valid IP address or CIDR range.'); + $validator->errors()->addIf(! $valid, "allowed_ips.{$index}", '"'.$ip.'" is not a valid IP address or CIDR range.'); } } - }); + }]; } } diff --git a/app/Http/Requests/Api/Client/Account/StoreSSHKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreSSHKeyRequest.php index 3c8cf89ed..cbc3aa102 100644 --- a/app/Http/Requests/Api/Client/Account/StoreSSHKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreSSHKeyRequest.php @@ -1,28 +1,35 @@ UserSSHKey::getRulesForField('name'), - 'public_key' => UserSSHKey::getRulesForField('public_key'), + 'name' => UserSSHKeyRules::rules()['name'], + 'public_key' => UserSSHKeyRules::rules()['public_key'], ]; } @@ -30,30 +37,44 @@ class StoreSSHKeyRequest extends ClientApiRequest * Check to see if this SSH key has already been added to the user's account * and if so return an error. */ - public function withValidator(Validator $validator): void + /** + * @return list + */ + public function after(): array { - $validator->after(function () { + return [function (Validator $validator): void { + if ($validator->errors()->has('public_key')) { + return; + } + + $publicKey = mb_trim(JsonValueGuard::string($this->input('public_key'))); + if (! UserSSHKeyRules::isSupportedPublicKey($publicKey)) { + $validator->errors()->add('public_key', 'The public key provided is not valid.'); + + return; + } + try { - $this->key = PublicKeyLoader::loadPublicKey($this->input('public_key')); - } catch (NoKeyLoadedException $exception) { - $this->validator->errors()->add('public_key', 'The public key provided is not valid.'); + $this->key = PublicKeyLoader::loadPublicKey($publicKey); + } catch (NoKeyLoadedException) { + $validator->errors()->add('public_key', 'The public key provided is not valid.'); return; } if ($this->key instanceof DSA) { - $this->validator->errors()->add('public_key', 'DSA keys are not supported.'); + $validator->errors()->add('public_key', 'DSA keys are not supported.'); } if ($this->key instanceof RSA && $this->key->getLength() < 2048) { - $this->validator->errors()->add('public_key', 'RSA keys must be at least 2048 bytes in length.'); + $validator->errors()->add('public_key', 'RSA keys must be at least 2048 bytes in length.'); } $fingerprint = $this->key->getFingerprint('sha256'); if ($this->user()->sshKeys()->where('fingerprint', $fingerprint)->exists()) { - $this->validator->errors()->add('public_key', 'The public key provided already exists on your account.'); + $validator->errors()->add('public_key', 'The public key provided already exists on your account.'); } - }); + }]; } /** @@ -61,7 +82,10 @@ class StoreSSHKeyRequest extends ClientApiRequest */ public function getPublicKey(): string { - return $this->key->toString('PKCS8'); + $publicKey = $this->loadedKey()->toString('PKCS8'); + throw_unless(is_string($publicKey), UnexpectedValueException::class, 'The loaded public key could not be serialized.'); + + return $publicKey; } /** @@ -69,10 +93,14 @@ class StoreSSHKeyRequest extends ClientApiRequest */ public function getKeyFingerprint(): string { - if (!$this->key) { - throw new \Exception('The public key was not properly loaded for this request.'); - } + $fingerprint = $this->loadedKey()->getFingerprint('sha256'); + throw_unless(is_string($fingerprint), UnexpectedValueException::class, 'The loaded public key did not produce a SHA256 fingerprint.'); - return $this->key->getFingerprint('sha256'); + return $fingerprint; + } + + private function loadedKey(): PublicKey + { + return $this->key ?? throw new UnexpectedValueException('The public key was not properly loaded for this request.'); } } diff --git a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php index abafc2dc6..dca2377ca 100644 --- a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php +++ b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php @@ -1,38 +1,30 @@ make(Hasher::class); - - // Verify password matches when changing password or email. - if (!$hasher->check($this->input('password'), $this->user()->password)) { - throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password')); - } - - return true; - } - public function rules(): array { - $rules = User::getRulesForUpdate($this->user()); + return [ + 'email' => UserRules::rules($this->user())['email'], + 'password' => ['required', 'string'], + ]; + } - return ['email' => $rules['email']]; + protected function passedValidation(): void + { + throw_unless(Hash::check(JsonValueGuard::string($this->validated('password')), $this->user()->password), InvalidPasswordProvidedException::class, trans('validation.internal.invalid_password')); } } diff --git a/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php b/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php index 8f003d028..9b0970fc1 100644 --- a/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php +++ b/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php @@ -1,37 +1,30 @@ make(Hasher::class); - - // Verify password matches when changing password or email. - if (!$hasher->check($this->input('current_password'), $this->user()->password)) { - throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password')); - } - - return true; - } - public function rules(): array { return [ - 'password' => ['required', 'string', 'confirmed', 'min:8'], + 'current_password' => ['required', 'string'], + 'password' => ['required', 'confirmed', ...UserRules::PASSWORD], ]; } + + protected function passedValidation(): void + { + throw_unless(Hash::check(JsonValueGuard::string($this->validated('current_password')), $this->user()->password), InvalidPasswordProvidedException::class, trans('validation.internal.invalid_password')); + } } diff --git a/app/Http/Requests/Api/Client/ClientApiRequest.php b/app/Http/Requests/Api/Client/ClientApiRequest.php index 5ae1680a4..6272cd3d9 100644 --- a/app/Http/Requests/Api/Client/ClientApiRequest.php +++ b/app/Http/Requests/Api/Client/ClientApiRequest.php @@ -1,13 +1,16 @@ route()->parameter('server'); + if ($this instanceof ClientPermissionsRequest) { + $server = $this->parameter('server', Server::class); - if ($server instanceof Server) { - return $this->user()->can($this->permission(), $server); - } - - // If there is no server available on the reqest, trigger a failure since - // we expect there to be one at this point. - return false; + return $this->user()->can($this->permission(), $server); } return true; diff --git a/app/Http/Requests/Api/Client/GetActivityLogsRequest.php b/app/Http/Requests/Api/Client/GetActivityLogsRequest.php new file mode 100644 index 000000000..d709cfc33 --- /dev/null +++ b/app/Http/Requests/Api/Client/GetActivityLogsRequest.php @@ -0,0 +1,15 @@ + ['sometimes', 'nullable', 'string', Rule::in(['owner', 'admin', 'admin-all'])], + ]; + } } diff --git a/app/Http/Requests/Api/Client/Servers/Backups/DeleteBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/DeleteBackupRequest.php new file mode 100644 index 000000000..ae49d6f02 --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/Backups/DeleteBackupRequest.php @@ -0,0 +1,15 @@ +value; + } +} diff --git a/app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php new file mode 100644 index 000000000..8f3cf079e --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php @@ -0,0 +1,15 @@ +value; + } +} diff --git a/app/Http/Requests/Api/Client/Servers/Backups/ListBackupsRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/ListBackupsRequest.php new file mode 100644 index 000000000..132d5b4e0 --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/Backups/ListBackupsRequest.php @@ -0,0 +1,43 @@ +value; + } + + /** + * @return ValidationRules + */ + public function rules(): array + { + return [ + 'per_page' => ['sometimes', 'integer', 'min:1', 'max:50'], + ]; + } + + /** + * @return array{per_page: int} + */ + public function payload(): array + { + $data = parent::validated(); + + $perPage = Arr::get($data, 'per_page', 20); + + return [ + 'per_page' => min(JsonValueGuard::integer($perPage), 50), + ]; + } +} diff --git a/app/Http/Requests/Api/Client/Servers/Backups/RestoreBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/RestoreBackupRequest.php index d2d427f99..51105e3a9 100644 --- a/app/Http/Requests/Api/Client/Servers/Backups/RestoreBackupRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Backups/RestoreBackupRequest.php @@ -1,19 +1,39 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { - return ['truncate' => 'required|boolean']; + return ['truncate' => ['required', 'boolean']]; + } + + /** + * @return array{truncate: bool} + */ + public function payload(): array + { + $data = parent::validated(); + + return [ + 'truncate' => JsonValueGuard::boolean(Arr::get($data, 'truncate')), + ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php index 2871c039c..a9a012a17 100644 --- a/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php @@ -1,23 +1,45 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'name' => 'nullable|string|max:191', - 'is_locked' => 'nullable|boolean', - 'ignored' => 'nullable|string', + 'name' => ['nullable', 'string', 'max:191'], + 'is_locked' => ['nullable', 'boolean'], + 'ignored' => ['nullable', 'string'], + ]; + } + + /** + * @return array{name: string|null, is_locked: bool, ignored: string|null} + */ + public function payload(): array + { + $data = parent::validated(); + + return [ + 'name' => JsonValueGuard::nullableString(Arr::get($data, 'name')), + 'is_locked' => JsonValueGuard::boolean(Arr::get($data, 'is_locked', false)), + 'ignored' => JsonValueGuard::nullableString(Arr::get($data, 'ignored')), ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Backups/ToggleBackupLockRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/ToggleBackupLockRequest.php new file mode 100644 index 000000000..59b772f6e --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/Backups/ToggleBackupLockRequest.php @@ -0,0 +1,15 @@ +value; + } +} diff --git a/app/Http/Requests/Api/Client/Servers/Backups/ViewBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/ViewBackupRequest.php new file mode 100644 index 000000000..a241343c0 --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/Backups/ViewBackupRequest.php @@ -0,0 +1,39 @@ +parameter('server', Server::class); + $route = $this->route(); + throw_if($route === null, UnexpectedValueException::class, 'The backup request does not have an active route.'); + + $backup = $route->parameter('backup'); + if ($backup instanceof Backup) { + throw_if($backup->server_id !== $server->id, NotFoundHttpException::class, 'The requested resource does not exist on the system.'); + } + + return true; + } + + public function permission(): string + { + return Permissions::BackupRead->value; + } +} diff --git a/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php index eb2cbc57e..ec915039f 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php @@ -1,15 +1,17 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php index 80eabf945..c3061ae72 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php @@ -1,15 +1,17 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php index b2a9163ad..4e99be595 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php @@ -1,17 +1,20 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php index be4f4a719..c50f29e81 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php @@ -1,29 +1,32 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { - $server = $this->route()->parameter('server'); - - Assert::isInstanceOf($server, Server::class); + $server = $this->parameter('server', Server::class); return [ 'database' => [ @@ -31,15 +34,13 @@ class StoreDatabaseRequest extends ClientApiRequest implements ClientPermissions 'alpha_dash', 'min:3', 'max:48', - // Yes, I am aware that you could have the same database name across two unique hosts. However, - // I don't really care about that for this validation. We just want to make sure it is unique to - // the server itself. No need for complexity. - Rule::unique('databases')->where(function (Builder $query) use ($server) { + // The name only needs to be unique to this server, not across database hosts. + Rule::unique('databases')->where(function (Builder $query) use ($server): void { $query->where('server_id', $server->id) - ->where('database', DatabaseManagementService::generateUniqueDatabaseName($this->input('database'), $server->id)); + ->where('database', DatabaseName::generateUnique(JsonValueGuard::string($this->input('database')), $server->id)); }), ], - 'remote' => Database::getRulesForField('remote'), + 'remote' => DatabaseRules::rules()['remote'], ]; } @@ -49,4 +50,13 @@ class StoreDatabaseRequest extends ClientApiRequest implements ClientPermissions 'database.unique' => 'The database name you have selected is already in use by this server.', ]; } + + /** @return DatabaseDeploymentData */ + public function payload(): array + { + return [ + 'database' => $this->string('database')->toString(), + 'remote' => $this->string('remote')->toString(), + ]; + } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php index bf94cb6ba..9de333095 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php @@ -1,25 +1,30 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'root' => 'required|nullable|string', - 'files' => 'required|array', - 'files.*.file' => 'required|string', - 'files.*.mode' => 'required|numeric', + 'root' => ['required', 'nullable', 'string'], + 'files' => ['required', 'array'], + 'files.*.file' => ['required', 'string'], + 'files.*.mode' => ['required', 'numeric'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php index 3d6e96aac..ff778972a 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php @@ -1,26 +1,32 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'root' => 'sometimes|nullable|string', - 'files' => 'required|array', - 'files.*' => 'string', + 'root' => ['sometimes', 'nullable', 'string'], + 'files' => ['required', 'array'], + 'files.*' => ['string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php index 686c23a23..e6f21901f 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php @@ -1,22 +1,27 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'location' => 'required|string', + 'location' => ['required', 'string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php b/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php index e4655575d..54ec89162 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php @@ -1,25 +1,31 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'root' => 'sometimes|nullable|string', - 'name' => 'required|string', + 'root' => ['sometimes', 'nullable', 'string'], + 'name' => ['required', 'string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php index 6e24682e4..e97a960de 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php @@ -1,11 +1,14 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'root' => 'sometimes|nullable|string', - 'file' => 'required|string', + 'root' => ['sometimes', 'nullable', 'string'], + 'file' => ['required', 'string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php index 10db32811..007cd83e1 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php @@ -1,24 +1,29 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'root' => 'required|nullable|string', - 'files' => 'required|array', - 'files.*' => 'string', + 'root' => ['required', 'nullable', 'string'], + 'files' => ['required', 'array'], + 'files.*' => ['string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php deleted file mode 100644 index c588c9b23..000000000 --- a/app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php +++ /dev/null @@ -1,18 +0,0 @@ -user()->can('file.read', $this->parameter('server', Server::class)); - } -} diff --git a/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php b/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php index ea6ed7b69..dc98068d5 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php @@ -1,9 +1,11 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'file' => 'required|string', + 'file' => ['required', 'string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php index 25443148f..818053501 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php @@ -1,11 +1,14 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'directory' => 'sometimes|nullable|string', + 'directory' => ['sometimes', 'nullable', 'string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php index 5f7648247..d129a0184 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php @@ -1,26 +1,31 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'url' => 'required|string|url', - 'directory' => 'nullable|string', - 'filename' => 'nullable|string', - 'use_header' => 'boolean', - 'foreground' => 'boolean', + 'url' => ['required', 'string', 'url'], + 'directory' => ['nullable', 'string'], + 'filename' => ['nullable', 'string'], + 'use_header' => ['boolean'], + 'foreground' => ['boolean'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php index 61c4a0c5f..54747f256 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php @@ -1,9 +1,11 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'root' => 'required|nullable|string', - 'files' => 'required|array', - 'files.*' => 'array', - 'files.*.to' => 'required|string', - 'files.*.from' => 'required|string', + 'root' => ['required', 'nullable', 'string'], + 'files' => ['required', 'array'], + 'files.*' => ['array'], + 'files.*.to' => ['required', 'string'], + 'files.*.from' => ['required', 'string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/UploadFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/UploadFileRequest.php index a591fdf68..1e965ead8 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/UploadFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/UploadFileRequest.php @@ -1,14 +1,17 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php b/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php index 82a994c36..8ebc88345 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php @@ -1,9 +1,11 @@ value; } /** * There is no rule here for the file contents since we just use the body content * on the request to set the file contents. If nothing is passed that is fine since * it just means we want to set the file to be empty. + * + * @return ValidationRules */ public function rules(): array { return [ - 'file' => 'required|string', + 'file' => ['required', 'string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/GetServerLogsRequest.php b/app/Http/Requests/Api/Client/Servers/GetServerLogsRequest.php new file mode 100644 index 000000000..c6be1eeae --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/GetServerLogsRequest.php @@ -0,0 +1,32 @@ +value; + } + + /** + * @return ValidationRules + */ + public function rules(): array + { + return [ + 'lines' => ['sometimes', 'integer', 'min:1', 'max:'.ReadsServerLogs::MAX_LINES], + ]; + } +} diff --git a/app/Http/Requests/Api/Client/Servers/GetServerRequest.php b/app/Http/Requests/Api/Client/Servers/GetServerRequest.php index 3798d77ab..716ebd53c 100644 --- a/app/Http/Requests/Api/Client/Servers/GetServerRequest.php +++ b/app/Http/Requests/Api/Client/Servers/GetServerRequest.php @@ -1,16 +1,13 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php b/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php index 7304bbd97..f6791ddf0 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php @@ -1,11 +1,14 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php b/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php index e6fc19b3f..45836098b 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php @@ -1,14 +1,17 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php b/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php index 30186d731..5a98fe412 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php @@ -1,9 +1,14 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { - $rules = Allocation::getRules(); - return [ - 'notes' => array_merge($rules['notes'], ['present']), + 'notes' => [...AllocationRules::rules()['notes'], 'present'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php index 19d972265..4cdeec6d7 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php @@ -1,13 +1,15 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/DeleteTaskRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/DeleteTaskRequest.php new file mode 100644 index 000000000..aaab48042 --- /dev/null +++ b/app/Http/Requests/Api/Client/Servers/Schedules/DeleteTaskRequest.php @@ -0,0 +1,15 @@ +value; + } +} diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php index 771407f10..c3f460732 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php @@ -1,20 +1,27 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { - $rules = Schedule::getRules(); + $rules = ScheduleRules::rules(); return [ 'name' => $rules['name'], @@ -22,7 +29,28 @@ class StoreScheduleRequest extends ViewScheduleRequest 'minute' => $rules['cron_minute'], 'hour' => $rules['cron_hour'], 'day_of_month' => $rules['cron_day_of_month'], + 'month' => $rules['cron_month'], 'day_of_week' => $rules['cron_day_of_week'], + 'only_when_online' => $rules['only_when_online'], + ]; + } + + /** + * @return ScheduleCreationData + */ + public function payload(): array + { + $data = parent::validated(); + + return [ + 'name' => JsonValueGuard::string(Arr::get($data, 'name')), + 'is_active' => array_key_exists('is_active', $data) && JsonValueGuard::boolean(Arr::get($data, 'is_active')), + 'minute' => JsonValueGuard::string(Arr::get($data, 'minute')), + 'hour' => JsonValueGuard::string(Arr::get($data, 'hour')), + 'day_of_month' => JsonValueGuard::string(Arr::get($data, 'day_of_month')), + 'month' => JsonValueGuard::string(Arr::get($data, 'month')), + 'day_of_week' => JsonValueGuard::string(Arr::get($data, 'day_of_week')), + 'only_when_online' => JsonValueGuard::boolean(Arr::get($data, 'only_when_online', false)), ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php index 5ceb7c8e0..fe1695fa7 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php @@ -1,29 +1,75 @@ value; } + /** + * The user also needs the permission for the task's action, such as console access for + * a command task. An unknown action or power signal is left to validation to reject. + */ + public function authorize(): bool + { + if (! parent::authorize()) { + return false; + } + + $permission = Task::permissionForAction($this->string('action')->toString(), $this->string('payload')->toString()); + + return ! $permission instanceof Permissions || $this->user()->can($permission->value, $this->parameter('server', Server::class)); + } + + /** + * @return ValidationRules + */ public function rules(): array { + $payload = ['required_unless:action,backup', 'string', 'nullable']; + if ($this->input('action') === Task::ACTION_POWER) { + $payload[] = Rule::in(Task::POWER_ACTIONS); + } + return [ - 'action' => 'required|in:command,power,backup', - 'payload' => 'required_unless:action,backup|string|nullable', - 'time_offset' => 'required|numeric|min:0|max:900', - 'sequence_id' => 'sometimes|required|numeric|min:1', - 'continue_on_failure' => 'sometimes|required|boolean', + 'action' => ['required', 'in:command,power,backup'], + 'payload' => $payload, + 'time_offset' => ['required', 'numeric', 'min:0', 'max:900'], + 'sequence_id' => ['sometimes', 'required', 'numeric', 'min:1'], + 'continue_on_failure' => ['sometimes', 'required', 'boolean'], + ]; + } + + /** + * @return TaskData + */ + public function payload(): array + { + $data = parent::validated(); + + $sequenceId = Arr::get($data, 'sequence_id'); + + return [ + 'action' => JsonValueGuard::string(Arr::get($data, 'action')), + 'payload' => JsonValueGuard::nullableScalarString(Arr::get($data, 'payload')) ?? '', + 'time_offset' => JsonValueGuard::integer(Arr::get($data, 'time_offset')), + 'sequence_id' => $sequenceId === null || $sequenceId === '' ? null : JsonValueGuard::integer($sequenceId), + 'continue_on_failure' => JsonValueGuard::boolean(Arr::get($data, 'continue_on_failure', false)), ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php index 216274acf..81ed819f5 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php @@ -1,17 +1,23 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return []; diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php index 4b9fe431b..1ea97a629 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php @@ -1,13 +1,15 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php index 72674a354..1f9a76be5 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php @@ -1,36 +1,40 @@ route()->parameter('server'); - $schedule = $this->route()->parameter('schedule'); + $server = $this->parameter('server', Server::class); + $route = $this->route(); + throw_if($route === null, UnexpectedValueException::class, 'The schedule request does not have an active route.'); + + $schedule = $route->parameter('schedule'); // If the schedule does not belong to this server throw a 404 error. Also throw an // error if the task being requested does not belong to the associated schedule. - if ($server instanceof Server && $schedule instanceof Schedule) { - $task = $this->route()->parameter('task'); - - if ($schedule->server_id !== $server->id || ($task instanceof Task && $task->schedule_id !== $schedule->id)) { - throw new NotFoundHttpException('The requested resource does not exist on the system.'); - } + if ($schedule instanceof Schedule) { + $task = $route->parameter('task'); + throw_if($schedule->server_id !== $server->id || ($task instanceof Task && $task->schedule_id !== $schedule->id), NotFoundHttpException::class, 'The requested resource does not exist on the system.'); } return true; @@ -38,6 +42,6 @@ class ViewScheduleRequest extends ClientApiRequest public function permission(): string { - return Permission::ACTION_SCHEDULE_READ; + return Permissions::ScheduleRead->value; } } diff --git a/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php b/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php index 171cd19d9..299526343 100644 --- a/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php +++ b/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php @@ -1,27 +1,32 @@ value; } /** * Rules to validate this request against. + * + * @return ValidationRules */ public function rules(): array { return [ - 'command' => 'required|string|min:1', + 'command' => ['required', 'string', 'min:1'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php b/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php index e071388cf..8eee72d59 100644 --- a/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php +++ b/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php @@ -1,37 +1,33 @@ input('signal')) { - case 'start': - return Permission::ACTION_CONTROL_START; - case 'stop': - case 'kill': - return Permission::ACTION_CONTROL_STOP; - case 'restart': - return Permission::ACTION_CONTROL_RESTART; - } - - return '__invalid'; + return Task::permissionForAction(Task::ACTION_POWER, $this->string('signal')->toString())->value ?? '__invalid'; } /** * Rules to validate this request against. + * + * @return ValidationRules */ public function rules(): array { return [ - 'signal' => 'required|string|in:start,stop,restart,kill', + 'signal' => ['required', 'string', Rule::in(Task::POWER_ACTIONS)], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Settings/ReinstallServerRequest.php b/app/Http/Requests/Api/Client/Servers/Settings/ReinstallServerRequest.php index 63f01dbae..7951470db 100644 --- a/app/Http/Requests/Api/Client/Servers/Settings/ReinstallServerRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Settings/ReinstallServerRequest.php @@ -1,14 +1,17 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php b/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php index 4a74f0a0e..9385bf96f 100644 --- a/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php @@ -1,11 +1,14 @@ value; } /** * The rules to apply when validating this request. + * + * @return ValidationRules */ public function rules(): array { return [ - 'name' => Server::getRules()['name'], - 'description' => 'string|nullable', + 'name' => ServerRules::rules()['name'], + 'description' => ['string', 'nullable'], ]; } + + public function description(): ?string + { + $description = $this->input('description'); + throw_if($description !== null && ! is_string($description), UnexpectedValueException::class, 'The validated server description must be a string or null.'); + + return $description; + } } diff --git a/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php b/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php index 2d4e182e0..57205a0aa 100644 --- a/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php @@ -1,29 +1,39 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { - $server = $this->route()->parameter('server'); + if (! $this->filled('docker_image')) { + return [ + 'docker_image' => ['required', 'string', 'max:191'], + ]; + } - Assert::isInstanceOf($server, Server::class); + $server = $this->parameter('server', Server::class); + $egg = $server->egg ?? throw new UnexpectedValueException('The server does not have an egg relationship.'); return [ - 'docker_image' => ['required', 'string', 'max:191', 'regex:/^[\w#\.\/\- ]*\|?~?[\w\.\/\-:@ ]*$/', Rule::in(array_values($server->egg->docker_images))], + 'docker_image' => ['required', 'string', 'max:191', 'regex:/^[\w#\.\/\- ]*\|?~?[\w\.\/\-:@ ]*$/', Rule::in(array_values($egg->docker_images))], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Startup/GetStartupRequest.php b/app/Http/Requests/Api/Client/Servers/Startup/GetStartupRequest.php index fee92bcbc..4a2e71e45 100644 --- a/app/Http/Requests/Api/Client/Servers/Startup/GetStartupRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Startup/GetStartupRequest.php @@ -1,14 +1,17 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Startup/UpdateStartupVariableRequest.php b/app/Http/Requests/Api/Client/Servers/Startup/UpdateStartupVariableRequest.php index 2c32f4df6..084ca4950 100644 --- a/app/Http/Requests/Api/Client/Servers/Startup/UpdateStartupVariableRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Startup/UpdateStartupVariableRequest.php @@ -1,25 +1,68 @@ value; } /** - * The actual validation of the variable's value will happen inside the controller. + * The value is validated with the egg variable's own rules when the variable can be edited. + * + * @return ValidationRules */ public function rules(): array { + $variable = $this->filled('key') ? $this->variable() : null; + return [ - 'key' => 'required|string', - 'value' => 'present', + 'key' => ['required', 'string'], + 'value' => $variable instanceof EggVariable && $variable->user_viewable && $variable->user_editable + ? ['present', ...$this->variableRules($variable)] + : 'present', ]; } + + /** + * The server's egg variable named by the request, with its server value loaded. + */ + public function variable(): ?EggVariable + { + if (! $this->resolvedVariable) { + $this->variable = $this->parameter('server', Server::class) + ->variables() + ->where('env_variable', $this->string('key')->toString()) + ->first(); + $this->resolvedVariable = true; + } + + return $this->variable; + } + + /** + * Split the variable's pipe-delimited rule string the way the validator would, keeping + * a regex rule intact. + * + * @return list + */ + private function variableRules(EggVariable $variable): array + { + return Str::startsWith($variable->rules, 'regex:') ? [$variable->rules] : explode('|', $variable->rules); + } } diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/DeleteSubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/DeleteSubuserRequest.php index eabd84e61..ef980157d 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/DeleteSubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/DeleteSubuserRequest.php @@ -1,13 +1,15 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php index ee43e0d62..88385e0ec 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php @@ -1,8 +1,10 @@ value; } } diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php index 6e8722516..96da97c44 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php @@ -1,22 +1,28 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'email' => 'required|email|between:1,191', - 'permissions' => 'required|array', - 'permissions.*' => 'string', + 'email' => ['required', 'email:strict', 'between:1,191', new UserEmail], + 'permissions' => ['required', 'array'], + 'permissions.*' => ['string'], ]; } } diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php index 3e60ac52c..d0eb20ccd 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php @@ -1,30 +1,41 @@ route()->parameter('user'); + $route = $this->route(); + throw_if($route === null, UnexpectedValueException::class, 'The subuser request does not have an active route.'); + + $user = $route->parameter('user'); // Don't allow a user to edit themselves on the server. if ($user instanceof User) { if ($user->uuid === $this->user()->uuid) { @@ -35,25 +46,47 @@ abstract class SubuserRequest extends ClientApiRequest // If this is a POST request, validate that the user can even assign the permissions they // have selected to assign. if ($this->method() === Request::METHOD_POST && $this->has('permissions')) { - $this->validatePermissionsCanBeAssigned( - $this->input('permissions') ?? [] - ); + $this->validatePermissionsCanBeAssigned($this->permissionInput()); } return true; } + public function subuser(): Subuser + { + $subuser = $this->attributes->get('subuser'); + throw_unless($subuser instanceof Subuser, UnexpectedValueException::class, 'The subuser request is missing its subuser attribute.'); + + return $subuser; + } + + /** + * The permissions to store for the subuser: the submitted keys the panel or an enabled + * extension knows about, always including websocket access. + * + * @return list + */ + public function permissions(): array + { + $allowed = $this->container->make(SubuserPermissionCatalog::class)->keys(); + + $cleaned = array_intersect($this->permissionInput(), $allowed); + + return array_values(array_unique(array_merge($cleaned, [Permissions::WebsocketConnect->value]))); + } + /** * Validates that the permissions we are trying to assign can actually be assigned * by the user making the request. * - * @throws \Illuminate\Contracts\Container\BindingResolutionException + * @param list $permissions unvalidated input, this runs before validation + * + * @throws BindingResolutionException */ - protected function validatePermissionsCanBeAssigned(array $permissions) + protected function validatePermissionsCanBeAssigned(array $permissions): void { $user = $this->user(); - /** @var \Pterodactyl\Models\Server $server */ - $server = $this->route()->parameter('server'); + $server = $this->parameter('server', Server::class); // If we are a root admin or the server owner, no need to perform these checks. if ($user->root_admin || $user->id === $server->owner_id) { @@ -65,8 +98,24 @@ abstract class SubuserRequest extends ClientApiRequest // already have. $service = $this->container->make(GetUserPermissionsService::class); - if (count(array_diff($permissions, $service->handle($server, $user))) > 0) { - throw new HttpForbiddenException('Cannot assign permissions to a subuser that your account does not actively possess.'); + throw_if(count(array_diff($permissions, $service->handle($server, $user))) > 0, HttpForbiddenException::class, 'Cannot assign permissions to a subuser that your account does not actively possess.'); + } + + /** @return list */ + private function permissionInput(): array + { + $value = $this->input('permissions', []); + if (! is_array($value) || ! array_is_list($value)) { + return []; } + + $permissions = []; + foreach ($value as $permission) { + if (is_string($permission)) { + $permissions[] = $permission; + } + } + + return $permissions; } } diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php index bd8929a98..99f5516a1 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php @@ -1,21 +1,26 @@ value; } + /** + * @return ValidationRules + */ public function rules(): array { return [ - 'permissions' => 'required|array', - 'permissions.*' => 'string', + 'permissions' => ['required', 'array'], + 'permissions.*' => ['string'], ]; } } diff --git a/app/Http/Requests/Api/Remote/ActivityEventRequest.php b/app/Http/Requests/Api/Remote/ActivityEventRequest.php index 43f527dfa..c01b9a991 100644 --- a/app/Http/Requests/Api/Remote/ActivityEventRequest.php +++ b/app/Http/Requests/Api/Remote/ActivityEventRequest.php @@ -1,9 +1,13 @@ input('data'))->pluck('server')->unique()->toArray(); + $data = $this->input('data'); + JsonValueGuard::assertValue($data); + throw_unless(is_array($data), UnexpectedValueException::class, 'Activity event data must be a list.'); + + $events = []; + foreach ($data as $value) { + throw_unless(is_array($value), UnexpectedValueException::class, 'Each activity event must be an object.'); + + $metadata = $value['metadata'] ?? []; + throw_unless(is_array($metadata), UnexpectedValueException::class, 'Activity event metadata must be an object.'); + + $normalizedMetadata = []; + foreach ($metadata as $key => $item) { + throw_unless(is_string($key), UnexpectedValueException::class, 'Activity event metadata keys must be strings.'); + + $normalizedMetadata[$key] = $item; + } + + $events[] = [ + 'user' => $this->nullableString($value['user'] ?? null, 'user'), + 'server' => $this->requiredString($value['server'] ?? null, 'server'), + 'event' => $this->requiredString($value['event'] ?? null, 'event'), + 'metadata' => $normalizedMetadata, + 'ip' => $this->nullableString($value['ip'] ?? null, 'ip'), + 'timestamp' => $this->requiredString($value['timestamp'] ?? null, 'timestamp'), + ]; + } + + return $events; } - /** - * Returns all the unique user UUIDs that were submitted in this request. - */ - public function users(): array + public function node(): Node { - return Collection::make($this->input('data')) - ->filter(function ($value) { - return !empty($value['user']); - }) - ->pluck('user') - ->unique() - ->toArray(); + return RemoteRequestNode::get($this); + } + + /** @param JsonInputValue $value */ + private function requiredString(mixed $value, string $key): string + { + if (! is_string($value)) { + throw new UnexpectedValueException(sprintf('Activity event field "%s" must be a string.', $key)); + } + + return $value; + } + + /** @param JsonInputValue $value */ + private function nullableString(mixed $value, string $key): ?string + { + return $value === null ? null : $this->requiredString($value, $key); } } diff --git a/app/Http/Requests/Api/Remote/AuthenticateWebsocketDetailsRequest.php b/app/Http/Requests/Api/Remote/AuthenticateWebsocketDetailsRequest.php deleted file mode 100644 index 1bae01dd7..000000000 --- a/app/Http/Requests/Api/Remote/AuthenticateWebsocketDetailsRequest.php +++ /dev/null @@ -1,20 +0,0 @@ - 'required|string', - ]; - } -} diff --git a/app/Http/Requests/Api/Remote/InstallationDataRequest.php b/app/Http/Requests/Api/Remote/InstallationDataRequest.php index 13b3e77d7..22b88fd91 100644 --- a/app/Http/Requests/Api/Remote/InstallationDataRequest.php +++ b/app/Http/Requests/Api/Remote/InstallationDataRequest.php @@ -1,5 +1,7 @@ 'present|boolean', - 'reinstall' => 'sometimes|boolean', + 'successful' => ['present', 'boolean'], + 'reinstall' => ['sometimes', 'boolean'], ]; } } diff --git a/app/Http/Requests/Api/Remote/RemoteRequestNode.php b/app/Http/Requests/Api/Remote/RemoteRequestNode.php new file mode 100644 index 000000000..022f5a810 --- /dev/null +++ b/app/Http/Requests/Api/Remote/RemoteRequestNode.php @@ -0,0 +1,20 @@ +attributes->get('node'); + throw_unless($node instanceof Node, UnexpectedValueException::class, 'The authenticated node is missing from the remote request.'); + + return $node; + } +} diff --git a/app/Http/Requests/Api/Remote/ReportBackupCompleteRequest.php b/app/Http/Requests/Api/Remote/ReportBackupCompleteRequest.php index d0dd3090b..1152929e8 100644 --- a/app/Http/Requests/Api/Remote/ReportBackupCompleteRequest.php +++ b/app/Http/Requests/Api/Remote/ReportBackupCompleteRequest.php @@ -1,21 +1,67 @@ 'required|boolean', - 'checksum' => 'nullable|string|required_if:successful,true', - 'checksum_type' => 'nullable|string|required_if:successful,true', - 'size' => 'nullable|numeric|required_if:successful,true', - 'parts' => 'nullable|array', - 'parts.*.etag' => 'required|string', - 'parts.*.part_number' => 'required|numeric', + 'successful' => ['required', 'boolean'], + 'checksum' => ['nullable', 'string', 'required_if:successful,true'], + 'checksum_type' => ['nullable', 'string', 'required_if:successful,true'], + 'size' => ['nullable', 'numeric', 'required_if:successful,true'], + 'parts' => ['nullable', 'array', 'list'], + 'parts.*.etag' => ['required', 'string'], + 'parts.*.part_number' => ['required', 'integer'], ]; } + + /** + * @return BackupCompletionData + */ + public function payload(): array + { + return [ + 'successful' => $this->boolean('successful'), + 'checksum' => JsonValueGuard::nullableString($this->input('checksum')), + 'checksum_type' => JsonValueGuard::nullableString($this->input('checksum_type')), + 'size' => $this->integer('size'), + 'parts' => $this->parts(), + ]; + } + + /** + * @return list|null + */ + private function parts(): ?array + { + $parts = $this->input('parts'); + if ($parts === null) { + return null; + } + + throw_if(! is_array($parts) || ! array_is_list($parts), UnexpectedValueException::class, 'Multipart upload parts must be a list.'); + + $normalized = []; + foreach ($parts as $part) { + throw_unless(is_array($part), UnexpectedValueException::class, 'Each multipart upload part must be a string-keyed array.'); + + $normalized[] = [ + 'etag' => JsonValueGuard::string($part['etag'] ?? null), + 'part_number' => JsonValueGuard::integer($part['part_number'] ?? null), + ]; + } + + return $normalized; + } } diff --git a/app/Http/Requests/Api/Remote/ReportBackupRestoreRequest.php b/app/Http/Requests/Api/Remote/ReportBackupRestoreRequest.php new file mode 100644 index 000000000..fb3087bbe --- /dev/null +++ b/app/Http/Requests/Api/Remote/ReportBackupRestoreRequest.php @@ -0,0 +1,39 @@ + ['required', 'boolean'], + ]; + } + + /** + * @return array{successful: bool} + */ + public function payload(): array + { + $data = parent::validated(); + + return [ + 'successful' => JsonValueGuard::boolean(Arr::get($data, 'successful')), + ]; + } +} diff --git a/app/Http/Requests/Api/Remote/SftpAuthenticationFormRequest.php b/app/Http/Requests/Api/Remote/SftpAuthenticationFormRequest.php index 964c27974..bcf918dc8 100644 --- a/app/Http/Requests/Api/Remote/SftpAuthenticationFormRequest.php +++ b/app/Http/Requests/Api/Remote/SftpAuthenticationFormRequest.php @@ -1,5 +1,7 @@ only( - array_keys($this->rules()) - ); + return [ + 'type' => $this->filled('type') ? $this->string('type')->toString() : null, + 'username' => $this->string('username')->toString(), + 'password' => $this->string('password')->toString(), + ]; } } diff --git a/app/Http/Requests/Auth/LoginCheckpointRequest.php b/app/Http/Requests/Auth/LoginCheckpointRequest.php index 3c9392a63..27d29a206 100644 --- a/app/Http/Requests/Auth/LoginCheckpointRequest.php +++ b/app/Http/Requests/Auth/LoginCheckpointRequest.php @@ -1,9 +1,11 @@ 'required|string', + 'confirmation_token' => ['required', 'string'], 'authentication_code' => [ 'nullable', 'numeric', - Rule::requiredIf(function () { - return empty($this->input('recovery_token')); - }), + Rule::requiredIf(fn (): bool => empty($this->input('recovery_token'))), ], 'recovery_token' => [ 'nullable', 'string', - Rule::requiredIf(function () { - return empty($this->input('authentication_code')); - }), + Rule::requiredIf(fn (): bool => empty($this->input('authentication_code'))), ], ]; } diff --git a/app/Http/Requests/Auth/LoginRequest.php b/app/Http/Requests/Auth/LoginRequest.php deleted file mode 100644 index d08846929..000000000 --- a/app/Http/Requests/Auth/LoginRequest.php +++ /dev/null @@ -1,21 +0,0 @@ - 'required|string|min:1', - 'password' => 'required|string', - ]; - } -} diff --git a/app/Http/Requests/Auth/ResetPasswordRequest.php b/app/Http/Requests/Auth/ResetPasswordRequest.php index e5bb3299c..ed09d669e 100644 --- a/app/Http/Requests/Auth/ResetPasswordRequest.php +++ b/app/Http/Requests/Auth/ResetPasswordRequest.php @@ -1,8 +1,11 @@ 'required|string', - 'email' => 'required|email', - 'password' => 'required|string|confirmed|min:8', + 'token' => ['required', 'string'], + 'email' => ['required', 'email'], + 'password' => ['required', 'confirmed', ...UserRules::PASSWORD], ]; } } diff --git a/app/Http/Requests/Base/LocaleRequest.php b/app/Http/Requests/Base/LocaleRequest.php index 0a2cc03d7..c0284c7b2 100644 --- a/app/Http/Requests/Base/LocaleRequest.php +++ b/app/Http/Requests/Base/LocaleRequest.php @@ -1,16 +1,21 @@ ['required', 'string', 'regex:/^[a-z][a-z]$/'], - 'namespace' => ['required', 'string', 'regex:/^[a-z]{1,191}$/'], + 'namespace' => ['required', 'string', 'regex:/^(?:[a-z]{1,191}|ext-[a-z][a-z0-9-]{0,47}::[a-z][a-z0-9_-]{0,63})$/'], ]; } } diff --git a/app/Http/Requests/Concerns/FiltersDeployTags.php b/app/Http/Requests/Concerns/FiltersDeployTags.php new file mode 100644 index 000000000..b0f720c0f --- /dev/null +++ b/app/Http/Requests/Concerns/FiltersDeployTags.php @@ -0,0 +1,108 @@ +|null + */ + private $resolvedDeployTags; + + /** + * Fail validation when a deploy tag names neither an existing tag id nor an + * existing slug, unless it is a legacy nest id left over in the caller's + * configuration. + */ + protected function validateDeployTagsExist(Validator $validator): void + { + $submitted = $this->deployTagInput(); + + if ($submitted === []) { + return; + } + + $known = $this->matchedDeployTags() + ->flatMap(fn (Tag $tag): array => [(string) $tag->id, $tag->slug]) + ->all(); + + foreach (array_diff($submitted, $known) as $value) { + if (TagSlug::isReserved($value)) { + continue; + } + + $validator->errors()->add('deploy.tags', "The node tag '{$value}' does not exist."); + } + } + + /** + * Resolve the deploy tags, given as ids and/or slugs, to the slugs the + * deployment gate matches on. Anything that matched no tag is already either a + * dropped nest id or a validation error, so it simply does not appear here. + * + * @return string[] + */ + protected function resolveDeployTagSlugs(): array + { + return JsonValueGuard::stringList($this->matchedDeployTags()->pluck('slug')->all()); + } + + /** + * The tags named by deploy.tags, by id or slug, in one query. + * + * @return Collection + */ + private function matchedDeployTags() + { + if (($this->resolvedDeployTags) !== null) { + return $this->resolvedDeployTags; + } + + $submitted = $this->deployTagInput(); + + return $this->resolvedDeployTags = Tag::matchingKeysOrSlugs($submitted); + } + + /** + * The deploy tags as submitted, normalised to a list of strings. + * + * @return list + */ + private function deployTagInput(): array + { + $input = $this->input('deploy.tags', []); + if (! is_array($input)) { + return []; + } + + $tags = []; + foreach ($input as $tag) { + if (is_string($tag) && mb_trim($tag) !== '') { + $tags[] = mb_trim($tag); + } elseif (is_int($tag)) { + // SAFETY: integer tag IDs have an exact decimal string representation. + $tags[] = (string) $tag; + } + } + + return array_values(array_unique($tags)); + } +} diff --git a/app/Http/Requests/Concerns/ParsesServerStartupData.php b/app/Http/Requests/Concerns/ParsesServerStartupData.php new file mode 100644 index 000000000..a70999922 --- /dev/null +++ b/app/Http/Requests/Concerns/ParsesServerStartupData.php @@ -0,0 +1,32 @@ +input('environment', []); + throw_unless(is_array($environment), UnexpectedValueException::class, 'The validated server environment must be an array.'); + + $variables = []; + foreach ($environment as $key => $value) { + throw_if(! is_string($key) || (! is_bool($value) && ! is_float($value) && ! is_int($value) && ! is_string($value) && $value !== null), UnexpectedValueException::class, 'Server environment variables must have string keys and scalar values.'); + + $variables[$key] = $value; + } + + return [ + 'startup' => $this->string('startup')->toString(), + 'environment' => $variables, + 'skip_scripts' => $this->boolean('skip_scripts'), + 'egg_id' => $this->integer($eggField), + 'docker_image' => $this->string($imageField)->toString(), + ]; + } +} diff --git a/app/Http/Requests/Concerns/ValidatesArrayExistence.php b/app/Http/Requests/Concerns/ValidatesArrayExistence.php new file mode 100644 index 000000000..7441ac5ca --- /dev/null +++ b/app/Http/Requests/Concerns/ValidatesArrayExistence.php @@ -0,0 +1,45 @@ + $query + */ + protected function validateArrayExistence(Validator $validator, string $attribute, Builder $query): void + { + $values = $validator->getData()[$attribute] ?? []; + if (! is_array($values) || $validator->errors()->has($attribute)) { + return; + } + + $ids = []; + foreach ($values as $index => $value) { + if (! $validator->errors()->has($attribute.'.'.$index) && (is_int($value) || is_string($value))) { + $ids[$index] = $value; + } + } + + if ($ids === []) { + return; + } + + $existing = $query->whereKey(array_values($ids))->pluck($query->getModel()->getKeyName())->all(); + foreach ($ids as $index => $id) { + if (! in_array($id, $existing)) { + $validator->addFailure($attribute.'.'.$index, 'Exists', [$query->getModel()->getTable(), $query->getModel()->getKeyName()]); + } + } + } +} diff --git a/app/Http/Requests/FrontendUserFormRequest.php b/app/Http/Requests/FrontendUserFormRequest.php deleted file mode 100644 index 66d13d8c5..000000000 --- a/app/Http/Requests/FrontendUserFormRequest.php +++ /dev/null @@ -1,29 +0,0 @@ -user()); - } - - /** - * Return only the fields that we are interested in from the request. - * This will include empty fields as a null value. - */ - public function normalize(): array - { - return $this->only( - array_keys($this->rules()) - ); - } -} diff --git a/app/Http/Resources/Wings/ServerConfigurationCollection.php b/app/Http/Resources/Wings/ServerConfigurationCollection.php index 84fc2f811..1d4343048 100644 --- a/app/Http/Resources/Wings/ServerConfigurationCollection.php +++ b/app/Http/Resources/Wings/ServerConfigurationCollection.php @@ -1,32 +1,50 @@ , process_configuration: array}> */ public function toArray($request): array { - $egg = Container::getInstance()->make(EggConfigurationService::class); - $configuration = Container::getInstance()->make(ServerConfigurationStructureService::class); + $result = []; + foreach ($this->collection ?? [] as $server) { + throw_unless($server instanceof Server, UnexpectedValueException::class, 'Server configuration resources require Server models.'); - return $this->collection->map(function (Server $server) use ($configuration, $egg) { - return [ + $processConfiguration = $this->egg->handle($server); + JsonValueGuard::assertPayload9($processConfiguration); + + $result[] = [ 'uuid' => $server->uuid, - 'settings' => $configuration->handle($server), - 'process_configuration' => $egg->handle($server), + 'settings' => $this->configuration->handle($server), + 'process_configuration' => $processConfiguration, ]; - })->toArray(); + } + + return $result; } } diff --git a/app/Http/ViewComposers/AssetComposer.php b/app/Http/ViewComposers/AssetComposer.php index d42f8a80a..9b42fc025 100644 --- a/app/Http/ViewComposers/AssetComposer.php +++ b/app/Http/ViewComposers/AssetComposer.php @@ -1,18 +1,26 @@ with('asset', $this->assetHashService); + // Rendered lazily by the layout; resolving the tags never throws. + $view->with('extensionHead', $this->extensionHeadTags); $view->with('siteConfiguration', [ - 'name' => config('app.name') ?? 'Pterodactyl', - 'locale' => config('app.locale') ?? 'en', + 'name' => config('app.name', 'Pterodactyl'), + 'locale' => config('app.locale', 'en'), 'recaptcha' => [ 'enabled' => config('recaptcha.enabled', false), - 'siteKey' => config('recaptcha.website_key') ?? '', + 'siteKey' => config('recaptcha.website_key', ''), ], + 'extensions' => $this->extensionPayload(), ]); } + + /** + * The enabled frontend extensions the SPA boot loader should import, with their + * frontend settings for signed-in users and only the public ones for guests. + * Never allowed to break page rendering - worst case the SPA sees no extensions. + * + * @return array + */ + private function extensionPayload(): array + { + if (! config('extensions.enabled')) { + return []; + } + + try { + return $this->extensionManager->frontendPayload(authenticated: Auth::check()); + } catch (Throwable) { + return []; + } + } } diff --git a/app/Jobs/RevokeSftpAccessJob.php b/app/Jobs/RevokeSftpAccessJob.php index faaba4096..1ee3f0156 100644 --- a/app/Jobs/RevokeSftpAccessJob.php +++ b/app/Jobs/RevokeSftpAccessJob.php @@ -1,22 +1,24 @@ */ + public array $backoff = [10, 30, 60]; + public function __construct( public readonly string $user, #[WithoutRelations] public readonly Server|Node $target, - ) { - } + ) {} public function uniqueId(): string { @@ -38,12 +44,12 @@ class RevokeSftpAccessJob implements ShouldQueue, ShouldBeUnique return "revoke-sftp:{$this->user}:{$target}"; } - public function handle(DaemonRevocationRepository $repository): void + public function handle(): void { $node = $this->target instanceof Node ? $this->target : $this->target->node; try { - $repository->setNode($node)->deauthorize( + Daemon::node($node)->deauthorize( $this->user, $this->target instanceof Server ? [$this->target->uuid] : [] ); diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index 527b0303a..1775cc0f3 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -1,24 +1,37 @@ */ + public array $backoff = [10, 30, 60]; + + public int $tries = 3; + /** * RunTaskJob constructor. */ @@ -30,15 +43,13 @@ class RunTaskJob implements ShouldQueue /** * Run the job and send actions to the daemon running the server. * - * @throws \Throwable + * @throws Throwable */ public function handle( - DaemonCommandRepository $commandRepository, - InitiateBackupService $backupService, - DaemonPowerRepository $powerRepository, - ) { + InitiatesBackups $backupService, + ): void { // Do not process a task that is not set to active, unless it's been manually triggered. - if (!$this->task->schedule->is_active && !$this->manualRun) { + if (! $this->task->schedule->is_active && ! $this->manualRun) { $this->markTaskNotQueued(); $this->markScheduleComplete(); @@ -48,9 +59,9 @@ class RunTaskJob implements ShouldQueue $server = $this->task->server; // If we made it to this point and the server status is not null it means the // server was likely suspended or marked as reinstalling after the schedule - // was queued up. Just end the task right now — this should be a very rare + // was queued up. Just end the task right now - this should be a very rare // condition. - if (!is_null($server->status)) { + if (($server->status) !== null) { $this->failed(); return; @@ -58,25 +69,16 @@ class RunTaskJob implements ShouldQueue // Perform the provided task against the daemon. try { - switch ($this->task->action) { - case Task::ACTION_POWER: - $powerRepository->setServer($server)->send($this->task->payload); - break; - case Task::ACTION_COMMAND: - $commandRepository->setServer($server)->send($this->task->payload); - break; - case Task::ACTION_BACKUP: - $backupService->setIgnoredFiles(explode(PHP_EOL, $this->task->payload))->handle($server, null, true); - break; - default: - throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action); - } - } catch (\Exception $exception) { + match ($this->task->action) { + Task::ACTION_POWER => Daemon::server($server)->power($this->task->payload), + Task::ACTION_COMMAND => Daemon::server($server)->commands($this->task->payload), + Task::ACTION_BACKUP => $backupService->setIgnoredFiles(explode(PHP_EOL, $this->task->payload))->initiate($server, null, true), + default => throw new InvalidArgumentException('Invalid task action provided: '.$this->task->action), + }; + } catch (Throwable $throwable) { // If this isn't a DaemonConnectionException on a task that allows for failures // throw the exception back up the chain so that the task is stopped. - if (!($this->task->continue_on_failure && $exception instanceof DaemonConnectionException)) { - throw $exception; - } + throw_if(! $this->task->continue_on_failure || ! $throwable instanceof DaemonConnectionException, $throwable); } $this->markTaskNotQueued(); @@ -86,24 +88,28 @@ class RunTaskJob implements ShouldQueue /** * Handle a failure while sending the action to the daemon or otherwise processing the job. */ - public function failed(?\Exception $exception = null) + public function failed(?Throwable $exception = null): void { - $this->markTaskNotQueued(); - $this->markScheduleComplete(); + $this->task->getConnection()->transaction(function (): void { + $schedule = Schedule::query()->without('tasks')->lockForUpdate()->findOrFail($this->task->schedule_id); + $schedule->tasks()->where('is_queued', true)->update(['is_queued' => false]); + $schedule->forceFill(['is_processing' => false, 'last_run_at' => CarbonImmutable::now()])->saveOrFail(); + }); } /** * Get the next task in the schedule and queue it for running after the defined period of wait time. */ - private function queueNextTask() + private function queueNextTask(): void { + // SAFETY: this query is rooted in the Task model and first() therefore returns Task|null. /** @var Task|null $nextTask */ $nextTask = Task::query()->where('schedule_id', $this->task->schedule_id) ->orderBy('sequence_id', 'asc') ->where('sequence_id', '>', $this->task->sequence_id) ->first(); - if (is_null($nextTask)) { + if (($nextTask) === null) { $this->markScheduleComplete(); return; @@ -111,13 +117,25 @@ class RunTaskJob implements ShouldQueue $nextTask->update(['is_queued' => true]); - $this->dispatch((new self($nextTask, $this->manualRun))->delay($nextTask->time_offset)); + try { + $this->dispatch((new self($nextTask, $this->manualRun))->delay($nextTask->time_offset)); + } catch (Throwable $throwable) { + rescue(fn () => $this->failed($throwable)); + + if ($this->job !== null) { + $this->fail($throwable); + + return; + } + + throw $throwable; + } } /** * Marks the parent schedule as being complete. */ - private function markScheduleComplete() + private function markScheduleComplete(): void { $this->task->schedule()->update([ 'is_processing' => false, @@ -128,7 +146,7 @@ class RunTaskJob implements ShouldQueue /** * Mark a specific task as no longer being queued. */ - private function markTaskNotQueued() + private function markTaskNotQueued(): void { $this->task->update(['is_queued' => false]); } diff --git a/app/Listeners/AuthenticationListener.php b/app/Listeners/AuthenticationListener.php index e9234262e..86f5b4a18 100644 --- a/app/Listeners/AuthenticationListener.php +++ b/app/Listeners/AuthenticationListener.php @@ -1,13 +1,16 @@ credentials as $key => $value) { + JsonValueGuard::assertValue($value); $activity = $activity->property($key, $value); } } @@ -33,13 +37,13 @@ class AuthenticationListener implements SubscribesToEvents public function reset(PasswordReset $event): void { - Activity::event('event:password-reset')->withRequestMetadata()->subject($event->user)->log(); + Activity::event('auth:password-reset')->withRequestMetadata()->subject($event->user)->log(); } public function subscribe(Dispatcher $events): void { - $events->listen(Failed::class, [self::class, 'login']); - $events->listen(DirectLogin::class, [self::class, 'login']); - $events->listen(PasswordReset::class, [self::class, 'reset']); + $events->listen(Failed::class, self::login(...)); + $events->listen(DirectLogin::class, self::login(...)); + $events->listen(PasswordReset::class, self::reset(...)); } } diff --git a/app/Listeners/RevocationListener.php b/app/Listeners/RevocationListener.php index 0d60d2ed3..7d305a8d7 100644 --- a/app/Listeners/RevocationListener.php +++ b/app/Listeners/RevocationListener.php @@ -1,14 +1,17 @@ whereIn('nodes.id', $user->accessibleServers()->select('servers.node_id')->distinct()) - ->chunk(50, function (Collection $nodes) use ($user) { - $nodes->each(fn (Node $node) => RevokeSftpAccessJob::dispatch($user->uuid, $node)); + ->chunk(50, function (Collection $nodes) use ($user): void { + $nodes->each(fn (Node $node): PendingDispatch => dispatch(new RevokeSftpAccessJob($user->uuid, $node))); }); } public function subscribe(Dispatcher $events): void { - $events->listen(Deleting::class, [self::class, 'revoke']); - $events->listen(PasswordChanged::class, [self::class, 'revoke']); + $events->listen(Deleting::class, self::revoke(...)); + $events->listen(PasswordChanged::class, self::revoke(...)); } } diff --git a/app/Listeners/TwoFactorListener.php b/app/Listeners/TwoFactorListener.php index b1b765783..6707a2b8b 100644 --- a/app/Listeners/TwoFactorListener.php +++ b/app/Listeners/TwoFactorListener.php @@ -1,11 +1,13 @@ 'boolean', - ]; -} diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index 9ccefe528..01c72db38 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -1,18 +1,28 @@ $properties * @property Carbon $timestamp - * @property IlluminateModel|\Eloquent $actor - * @property \Illuminate\Database\Eloquent\Collection $subjects + * @property IlluminateModel|null $actor + * @property \Illuminate\Database\Eloquent\Collection $subjects * @property int|null $subjects_count * @property ApiKey|null $apiKey * @@ -48,46 +58,45 @@ use Illuminate\Database\Eloquent\Model as IlluminateModel; * @method static Builder|ActivityLog whereProperties($value) * @method static Builder|ActivityLog whereTimestamp($value) * - * @mixin \Eloquent + * @mixin \Illuminate\Database\Eloquent\Model */ #[Attributes\Identifiable('actl')] +#[Guarded([ + 'id', + 'timestamp', +])] +#[WithoutTimestamps] class ActivityLog extends Model implements Identifiable { - use MassPrunable; - use HasRealtimeIdentifier; + /** @use HasFactory */ + use HasFactory; - public const RESOURCE_NAME = 'activity_log'; + use HasRealtimeIdentifier; + use MassPrunable; + + public const string RESOURCE_NAME = 'activity_log'; /** * Tracks all the events we no longer wish to display to users. These are either legacy * events or just events where we never ended up using the associated data. */ - public const DISABLED_EVENTS = ['server:file.upload']; - - public $timestamps = false; - - protected $guarded = [ - 'id', - 'timestamp', - ]; - - protected $casts = [ - 'properties' => 'collection', - 'timestamp' => 'datetime', - ]; + public const array DISABLED_EVENTS = ['server:file.upload']; protected $with = ['subjects']; - public static array $validationRules = [ - 'event' => ['required', 'string'], - 'batch' => ['nullable', 'uuid'], - 'ip' => ['required', 'string'], - 'description' => ['nullable', 'string'], - 'properties' => ['array'], - ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'properties' => 'collection', + 'timestamp' => 'datetime', + ]; + } /** - * @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Illuminate\Database\Eloquent\Model, $this> + * @return MorphTo */ public function actor(): MorphTo { @@ -100,7 +109,7 @@ class ActivityLog extends Model implements Identifiable } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\ActivityLogSubject, $this> + * @return HasMany */ public function subjects(): HasMany { @@ -108,50 +117,66 @@ class ActivityLog extends Model implements Identifiable } /** - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\ApiKey, $this> + * @return HasOne */ public function apiKey(): HasOne { return $this->hasOne(ApiKey::class, 'id', 'api_key_id'); } - public function scopeForEvent(Builder $builder, string $action): Builder + /** @return array */ + public function propertyValues(): array { - return $builder->where('event', $action); - } + $values = $this->properties->all(); + JsonValueGuard::assertValue($values); - /** - * Scopes a query to only return results where the actor is a given model. - */ - public function scopeForActor(Builder $builder, IlluminateModel $actor): Builder - { - return $builder->whereMorphedTo('actor', $actor); + return $values; } /** * Returns models to be pruned. * * @see https://laravel.com/docs/9.x/eloquent#pruning-models + * + * @return Builder */ - public function prunable() + public function prunable(): Builder { - if (is_null(config('activity.prune_days'))) { - throw new \LogicException('Cannot prune activity logs: no "prune_days" configuration value is set.'); - } + throw_if((config('activity.prune_days')) === null, LogicException::class, 'Cannot prune activity logs: no "prune_days" configuration value is set.'); - return static::where('timestamp', '<=', Carbon::now()->subDays(config('activity.prune_days'))); + return static::query()->where('timestamp', '<=', now()->subDays(JsonValueGuard::integer(config('activity.prune_days')))); } /** * Boots the model event listeners. This will trigger an activity log event every * time a new model is inserted which can then be captured and worked with as needed. */ - protected static function boot() + protected static function boot(): void { parent::boot(); - static::created(function (self $model) { + static::created(function (self $model): void { Event::dispatch(new ActivityLogged($model)); }); } + + /** + * @param Builder $builder + */ + #[Scope] + protected function forEvent(Builder $builder, string $action): void + { + $builder->where('event', $action); + } + + /** + * Scopes a query to only return results where the actor is a given model. + * + * @param Builder $builder + */ + #[Scope] + protected function forActor(Builder $builder, IlluminateModel $actor): void + { + $builder->whereMorphedTo('actor', $actor); + } } diff --git a/app/Models/ActivityLogSubject.php b/app/Models/ActivityLogSubject.php index 9da2e4b39..51e6c8908 100644 --- a/app/Models/ActivityLogSubject.php +++ b/app/Models/ActivityLogSubject.php @@ -1,10 +1,17 @@ + * @return BelongsTo */ public function activityLog(): BelongsTo { @@ -40,7 +45,7 @@ class ActivityLogSubject extends Pivot } /** - * @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Illuminate\Database\Eloquent\Model, $this> + * @return MorphTo */ public function subject(): MorphTo { diff --git a/app/Models/Allocation.php b/app/Models/Allocation.php index 0f9bcae1f..bba474d91 100644 --- a/app/Models/Allocation.php +++ b/app/Models/Allocation.php @@ -1,9 +1,18 @@ */ + /** @use HasFactory */ use HasFactory; + use HasHashid; + /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'allocation'; + public const string RESOURCE_NAME = 'allocation'; /** - * The table associated with the model. + * @return array */ - protected $table = 'allocations'; - - /** - * Fields that are not mass assignable. - */ - protected $guarded = ['id', 'created_at', 'updated_at']; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'node_id' => 'integer', - 'port' => 'integer', - 'server_id' => 'integer', - ]; - - public static array $validationRules = [ - 'node_id' => 'required|exists:nodes,id', - 'ip' => 'required|ip', - 'port' => 'required|numeric|between:1024,65535', - 'ip_alias' => 'nullable|string', - 'server_id' => 'nullable|exists:servers,id', - 'notes' => 'nullable|string|max:256', - ]; + protected function casts(): array + { + return [ + 'node_id' => 'integer', + 'port' => 'integer', + 'server_id' => 'integer', + ]; + } public function getRouteKeyName(): string { return $this->getKeyName(); } - /** - * Return a hashid encoded string to represent the ID of the allocation. - */ - public function getHashidAttribute(): string - { - return app()->make('hashids')->encode($this->id); - } - - /** - * Accessor to automatically provide the IP alias if defined. - */ - public function getAliasAttribute(?string $value): string - { - return (is_null($this->ip_alias)) ? $this->ip : $this->ip_alias; - } - - /** - * Accessor to quickly determine if this allocation has an alias. - */ - public function getHasAliasAttribute(?string $value): bool - { - return !is_null($this->ip_alias); - } - public function toString(): string { return sprintf('%s:%s', $this->ip, $this->port); @@ -115,7 +86,7 @@ class Allocation extends Model /** * Gets information for the server associated with this allocation. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { @@ -125,10 +96,96 @@ class Allocation extends Model /** * Return the Node model associated with this allocation. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Node, $this> + * @return BelongsTo */ public function node(): BelongsTo { return $this->belongsTo(Node::class); } + + /** + * Accessor to automatically provide the IP alias if defined. + * + * @return Attribute + */ + protected function alias(): Attribute + { + return Attribute::make(get: fn (): string => $this->ip_alias ?? $this->ip); + } + + /** + * Accessor to quickly determine if this allocation has an alias. + * + * @return Attribute + */ + protected function hasAlias(): Attribute + { + return Attribute::make(get: fn (): bool => $this->ip_alias !== null); + } + + /** + * Allocations not yet assigned to a server. + * + * @param Builder $query + */ + #[Scope] + protected function unassigned(Builder $query): void + { + $query->whereNull('server_id'); + } + + /** + * Allocations on any of the given nodes; an empty list leaves the query unrestricted. + * + * @param Builder $query + * @param list $nodes + */ + #[Scope] + protected function onNodes(Builder $query, array $nodes): void + { + $query->when($nodes !== [], fn (Builder $q) => $q->whereIn('node_id', $nodes)); + } + + /** + * Allocations whose port is one of the given ports or falls inside one of the + * given [start, end] ranges; with neither given the query is unrestricted. + * + * @param Builder $query + * @param list $ports + * @param list $ranges + */ + #[Scope] + protected function onPorts(Builder $query, array $ports, array $ranges = []): void + { + if ($ports === [] && $ranges === []) { + return; + } + + $query->where(function (Builder $inner) use ($ports, $ranges): void { + if ($ports !== []) { + $inner->orWhereIn('port', $ports); + } + + foreach ($ranges as $range) { + $inner->orWhereBetween('port', $range); + } + }); + } + + /** + * Allocations on node/IP pairs that no server uses yet. + * + * @param Builder $query + * @param list $nodes restrict the occupied-IP lookup to these nodes + */ + #[Scope] + protected function onDedicatedIp(Builder $query, array $nodes = []): void + { + $occupied = self::query() + ->selectRaw('CONCAT_WS("-", node_id, ip)') + ->whereNotNull('server_id') + ->onNodes($nodes); + + $query->whereNotIn($query->raw('CONCAT_WS("-", node_id, ip)'), $occupied); + } } diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 45ea6a1be..ad4f93640 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -1,13 +1,21 @@ |null $allowed_ips * @property string|null $memo - * @property \Illuminate\Support\Carbon|null $last_used_at - * @property \Illuminate\Support\Carbon|null $expires_at - * @property \Illuminate\Support\Carbon|null $created_at - * @property \Illuminate\Support\Carbon|null $updated_at + * @property Carbon|null $last_used_at + * @property Carbon|null $expires_at + * @property Carbon|null $created_at + * @property Carbon|null $updated_at * @property int $r_servers * @property int $r_nodes * @property int $r_allocations * @property int $r_users * @property int $r_locations - * @property int $r_nests * @property int $r_eggs * @property int $r_database_hosts * @property int $r_server_databases * @property User $tokenable * @property User $user * - * @method static \Database\Factories\ApiKeyFactory factory(...$parameters) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey newModelQuery() - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey newQuery() - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey query() - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereAllowedIps($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereCreatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereId($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereIdentifier($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereKeyType($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereLastUsedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereMemo($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRAllocations($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRDatabaseHosts($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereREggs($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRLocations($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRNests($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRNodes($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRServerDatabases($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRServers($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRUsers($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereToken($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereUpdatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereUserId($value) + * @method static ApiKeyFactory factory(...$parameters) + * @method static Builder|ApiKey newModelQuery() + * @method static Builder|ApiKey newQuery() + * @method static Builder|ApiKey query() + * @method static Builder|ApiKey whereAllowedIps($value) + * @method static Builder|ApiKey whereCreatedAt($value) + * @method static Builder|ApiKey whereId($value) + * @method static Builder|ApiKey whereIdentifier($value) + * @method static Builder|ApiKey whereKeyType($value) + * @method static Builder|ApiKey whereLastUsedAt($value) + * @method static Builder|ApiKey whereMemo($value) + * @method static Builder|ApiKey whereRAllocations($value) + * @method static Builder|ApiKey whereRDatabaseHosts($value) + * @method static Builder|ApiKey whereREggs($value) + * @method static Builder|ApiKey whereRLocations($value) + * @method static Builder|ApiKey whereRNodes($value) + * @method static Builder|ApiKey whereRServerDatabases($value) + * @method static Builder|ApiKey whereRServers($value) + * @method static Builder|ApiKey whereRUsers($value) + * @method static Builder|ApiKey whereToken($value) + * @method static Builder|ApiKey whereUpdatedAt($value) + * @method static Builder|ApiKey whereUserId($value) * - * @mixin \Eloquent + * @mixin \Illuminate\Database\Eloquent\Model */ +#[Fillable([ + 'identifier', + 'token', + 'allowed_ips', + 'memo', + 'last_used_at', + 'expires_at', +])] +#[Hidden(['token'])] class ApiKey extends Model implements HasAbilities { - /** @use HasFactory<\Database\Factories\ApiKeyFactory> */ + /** @use HasFactory */ use HasFactory; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'api_key'; + public const string RESOURCE_NAME = 'api_key'; + /** * Different API keys that can exist on the system. */ - public const TYPE_NONE = 0; - public const TYPE_ACCOUNT = 1; + public const int TYPE_NONE = 0; + + public const int TYPE_ACCOUNT = 1; + /* @deprecated */ - public const TYPE_APPLICATION = 2; + public const int TYPE_APPLICATION = 2; + /* @deprecated */ - public const TYPE_DAEMON_USER = 3; + public const int TYPE_DAEMON_USER = 3; + /* @deprecated */ - public const TYPE_DAEMON_APPLICATION = 4; + public const int TYPE_DAEMON_APPLICATION = 4; + /** * The length of API key identifiers. */ - public const IDENTIFIER_LENGTH = 16; + public const int IDENTIFIER_LENGTH = 16; + /** * The length of the actual API key that is encrypted and stored * in the database. */ - public const KEY_LENGTH = 32; + public const int KEY_LENGTH = 32; /** - * The table associated with the model. + * @return array */ - protected $table = 'api_keys'; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'allowed_ips' => 'array', - 'user_id' => 'int', - 'last_used_at' => 'datetime', - 'expires_at' => 'datetime', - self::CREATED_AT => 'datetime', - self::UPDATED_AT => 'datetime', - 'r_' . AdminAcl::RESOURCE_USERS => 'int', - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int', - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int', - 'r_' . AdminAcl::RESOURCE_EGGS => 'int', - 'r_' . AdminAcl::RESOURCE_LOCATIONS => 'int', - 'r_' . AdminAcl::RESOURCE_NESTS => 'int', - 'r_' . AdminAcl::RESOURCE_NODES => 'int', - 'r_' . AdminAcl::RESOURCE_SERVERS => 'int', - ]; - - /** - * Fields that are mass assignable. - */ - protected $fillable = [ - 'identifier', - 'token', - 'allowed_ips', - 'memo', - 'last_used_at', - 'expires_at', - ]; - - /** - * Fields that should not be included when calling toArray() or toJson() - * on this model. - */ - protected $hidden = ['token']; - - /** - * Rules to protect against invalid data entry to DB. - */ - public static array $validationRules = [ - 'user_id' => 'required|exists:users,id', - 'key_type' => 'present|integer|min:0|max:4', - 'identifier' => 'required|string|size:16|unique:api_keys,identifier', - 'token' => 'required|string', - 'memo' => 'required|nullable|string|max:500', - 'allowed_ips' => 'nullable|array', - 'allowed_ips.*' => 'string', - 'last_used_at' => 'nullable|date', - 'expires_at' => 'nullable|date', - 'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_LOCATIONS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_NESTS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', - ]; - - public function can($ability) + protected function casts(): array { - // todo: this was never initially implemented and only became obvious once - // internal tooling was updated and started catching this mistake. - return false; - } - - public function cant($ability) - { - return ! $this->can($ability); - } - - /** - * Returns the user this token is assigned to. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this> - */ - public function user(): BelongsTo - { - return $this->belongsTo(User::class); - } - - /** - * Required for support with Laravel Sanctum. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this> - * - * @see \Laravel\Sanctum\Guard::supportsTokens() - */ - public function tokenable(): BelongsTo - { - return $this->user(); + return [ + 'allowed_ips' => 'array', + 'user_id' => 'int', + 'last_used_at' => 'datetime', + 'expires_at' => 'datetime', + self::CREATED_AT => 'datetime', + self::UPDATED_AT => 'datetime', + 'r_'.AdminAcl::RESOURCE_USERS => 'int', + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'int', + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'int', + 'r_'.AdminAcl::RESOURCE_EGGS => 'int', + 'r_'.AdminAcl::RESOURCE_LOCATIONS => 'int', + 'r_'.AdminAcl::RESOURCE_NODES => 'int', + 'r_'.AdminAcl::RESOURCE_SERVERS => 'int', + ]; } /** @@ -199,10 +142,10 @@ class ApiKey extends Model implements HasAbilities */ public static function findToken(string $token): ?self { - $identifier = substr($token, 0, self::IDENTIFIER_LENGTH); + $identifier = mb_substr($token, 0, self::IDENTIFIER_LENGTH); - $model = static::where('identifier', $identifier)->first(); - if (!is_null($model) && decrypt($model->token) === substr($token, strlen($identifier))) { + $model = static::query()->where('identifier', $identifier)->first(); + if (($model) !== null && decrypt($model->token) === mb_substr($token, mb_strlen($identifier))) { return $model; } @@ -214,7 +157,7 @@ class ApiKey extends Model implements HasAbilities */ public static function getPrefixForType(int $type): string { - Assert::oneOf($type, [self::TYPE_ACCOUNT, self::TYPE_APPLICATION]); + throw_unless(in_array($type, [self::TYPE_ACCOUNT, self::TYPE_APPLICATION], true), InvalidArgumentException::class, "Unsupported API key type [$type]."); return $type === self::TYPE_ACCOUNT ? 'ptlc_' : 'ptla_'; } @@ -226,6 +169,40 @@ class ApiKey extends Model implements HasAbilities { $prefix = self::getPrefixForType($type); - return $prefix . Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); + return $prefix.Str::random(self::IDENTIFIER_LENGTH - mb_strlen($prefix)); + } + + public function can($ability): bool + { + // todo: this was never initially implemented and only became obvious once + // internal tooling was updated and started catching this mistake. + return false; + } + + public function cant($ability): bool + { + return ! $this->can($ability); + } + + /** + * Returns the user this token is assigned to. + * + * @return BelongsTo + */ + public function user(): BelongsTo + { + return $this->belongsTo(User::class); + } + + /** + * Required for support with Laravel Sanctum. + * + * @return BelongsTo + * + * @see Guard::supportsTokens() + */ + public function tokenable(): BelongsTo + { + return $this->user(); } } diff --git a/app/Models/Attributes/Identifiable.php b/app/Models/Attributes/Identifiable.php index 9c73695c3..26d1b6624 100644 --- a/app/Models/Attributes/Identifiable.php +++ b/app/Models/Attributes/Identifiable.php @@ -1,11 +1,13 @@ 'required|uuid', - 'action' => 'required|string|max:191', - 'subaction' => 'nullable|string|max:191', - 'device' => 'array', - 'device.ip_address' => 'ip', - 'device.user_agent' => 'string', - 'metadata' => 'array', - ]; - - protected $table = 'audit_logs'; - - protected bool $immutableDates = true; - - protected $casts = [ - 'is_system' => 'bool', - 'device' => 'array', - 'metadata' => 'array', - ]; - - protected $guarded = [ - 'id', - 'created_at', - ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'is_system' => 'bool', + 'device' => 'array', + 'metadata' => 'array', + ]; + } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this> + * @return BelongsTo */ public function user(): BelongsTo { @@ -48,38 +39,10 @@ class AuditLog extends Model } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { return $this->belongsTo(Server::class); } - - /** - * Creates a new AuditLog model and returns it, attaching device information and the - * currently authenticated user if available. This model is not saved at this point, so - * you can always make modifications to it as needed before saving. - * - * @deprecated - */ - public static function instance(string $action, array $metadata, bool $isSystem = false): self - { - $request = Container::getInstance()->make('request'); - if ($isSystem || !$request instanceof Request) { // @phpstan-ignore instanceof.alwaysTrue - $request = null; - } - - return (new self())->fill([ - 'uuid' => Uuid::uuid4()->toString(), - 'is_system' => $isSystem, - 'user_id' => ($request && $request->user()) ? $request->user()->id : null, - 'server_id' => null, - 'action' => $action, - 'device' => $request ? [ - 'ip_address' => $request->getClientIp() ?? '127.0.0.1', - 'user_agent' => $request->userAgent() ?? '', - ] : [], - 'metadata' => $metadata, - ]); - } } diff --git a/app/Models/Backup.php b/app/Models/Backup.php index dd9cacf85..9155d284f 100644 --- a/app/Models/Backup.php +++ b/app/Models/Backup.php @@ -1,12 +1,19 @@ */ + /** @use HasFactory */ use HasFactory; - use SoftDeletes; + use HasRealtimeIdentifier; + use SoftDeletes; - public const RESOURCE_NAME = 'backup'; + public const string RESOURCE_NAME = 'backup'; - public const ADAPTER_WINGS = 'wings'; - public const ADAPTER_AWS_S3 = 's3'; + public const string ADAPTER_WINGS = 'wings'; - protected $table = 'backups'; - - protected bool $immutableDates = true; - - protected $casts = [ - 'id' => 'int', - 'is_successful' => 'bool', - 'is_locked' => 'bool', - 'ignored_files' => 'array', - 'bytes' => 'int', - 'completed_at' => 'datetime', - ]; + public const string ADAPTER_AWS_S3 = 's3'; protected $attributes = [ 'is_successful' => false, @@ -61,26 +58,37 @@ class Backup extends Model implements Identifiable 'upload_id' => null, ]; - protected $guarded = ['id', 'created_at', 'updated_at', 'deleted_at']; - - public static array $validationRules = [ - 'server_id' => 'bail|required|numeric|exists:servers,id', - 'uuid' => 'required|uuid', - 'is_successful' => 'boolean', - 'is_locked' => 'boolean', - 'name' => 'required|string', - 'ignored_files' => 'array', - 'disk' => 'required|string', - 'checksum' => 'nullable|string', - 'bytes' => 'numeric', - 'upload_id' => 'nullable|string', - ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'id' => 'integer', + 'is_successful' => 'boolean', + 'is_locked' => 'boolean', + 'ignored_files' => 'array', + 'bytes' => 'integer', + 'completed_at' => 'datetime', + ]; + } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { return $this->belongsTo(Server::class); } + + /** + * Backups still running or completed successfully. + * + * @param Builder $query + */ + #[Scope] + protected function nonFailed(Builder $query): void + { + $query->where(fn (Builder $inner) => $inner->whereNull('completed_at')->orWhere('is_successful', true)); + } } diff --git a/app/Models/Database.php b/app/Models/Database.php index fa6d91112..632a6a1e4 100644 --- a/app/Models/Database.php +++ b/app/Models/Database.php @@ -1,11 +1,16 @@ */ + /** @use HasFactory */ use HasFactory; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'server_database'; + public const string RESOURCE_NAME = 'server_database'; /** - * The table associated with the model. + * @return array */ - protected $table = 'databases'; - - /** - * The attributes excluded from the model's JSON form. - */ - protected $hidden = ['password']; - - /** - * Fields that are mass assignable. - */ - protected $fillable = [ - 'server_id', 'database_host_id', 'database', 'username', 'password', 'remote', 'max_connections', - ]; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'server_id' => 'integer', - 'database_host_id' => 'integer', - 'max_connections' => 'integer', - ]; - - public static array $validationRules = [ - 'server_id' => 'required|numeric|exists:servers,id', - 'database_host_id' => 'required|exists:database_hosts,id', - 'database' => 'required|string|alpha_dash|between:3,48', - 'username' => 'string|alpha_dash|between:3,100', - 'max_connections' => 'nullable|integer', - 'remote' => 'required|string|regex:/^[\w\-\/.%:]+$/', - 'password' => 'string', - ]; + protected function casts(): array + { + return [ + 'server_id' => 'integer', + 'database_host_id' => 'integer', + 'max_connections' => 'integer', + ]; + } public function getRouteKeyName(): string { @@ -77,16 +62,14 @@ class Database extends Model * Resolves the database using the ID by checking if the value provided is a HashID * string value, or just the ID to the database itself. * - * @param string|null $field - * - * @throws \Illuminate\Contracts\Container\BindingResolutionException + * @param string|null $field */ public function resolveRouteBinding($value, $field = null): ?\Illuminate\Database\Eloquent\Model { - if (is_scalar($value) && ($field ?? $this->getRouteKeyName()) === 'id') { - $value = ctype_digit((string) $value) + if (($field ?? $this->getRouteKeyName()) === 'id' && (is_string($value) || is_int($value))) { + $value = is_int($value) || ctype_digit($value) ? $value - : Container::getInstance()->make(HashidsInterface::class)->decodeFirst($value); + : Hashids::decodeFirst($value); } return $this->where($field ?? $this->getRouteKeyName(), $value)->firstOrFail(); @@ -95,7 +78,7 @@ class Database extends Model /** * Gets the host database server associated with a database. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\DatabaseHost, $this> + * @return BelongsTo */ public function host(): BelongsTo { @@ -105,7 +88,7 @@ class Database extends Model /** * Gets the server associated with a database. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { diff --git a/app/Models/DatabaseHost.php b/app/Models/DatabaseHost.php index ad90f1103..92a3a04ae 100644 --- a/app/Models/DatabaseHost.php +++ b/app/Models/DatabaseHost.php @@ -1,10 +1,16 @@ */ + /** @use HasFactory */ use HasFactory; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'database_host'; - - protected bool $immutableDates = true; + public const string RESOURCE_NAME = 'database_host'; /** - * The table associated with the model. + * @return array */ - protected $table = 'database_hosts'; - - /** - * The attributes excluded from the model's JSON form. - */ - protected $hidden = ['password']; - - /** - * Fields that are mass assignable. - */ - protected $fillable = [ - 'name', 'host', 'port', 'username', 'password', 'max_databases', 'node_id', - ]; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'id' => 'integer', - 'max_databases' => 'integer', - 'node_id' => 'integer', - ]; - - /** - * Validation rules to assign to this model. - */ - public static array $validationRules = [ - 'name' => 'required|string|max:191', - 'host' => 'required|string|regex:/^[\w\-\.]+$/', - 'port' => 'required|numeric|between:1,65535', - 'username' => 'required|string|max:32', - 'password' => 'nullable|string', - 'node_id' => 'sometimes|nullable|integer|exists:nodes,id', - ]; + protected function casts(): array + { + return [ + 'id' => 'integer', + 'max_databases' => 'integer', + 'node_id' => 'integer', + ]; + } /** * Gets the node associated with a database host. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Node, $this> + * @return BelongsTo */ public function node(): BelongsTo { @@ -82,7 +64,7 @@ class DatabaseHost extends Model /** * Gets the databases associated with this host. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Database, $this> + * @return HasMany */ public function databases(): HasMany { diff --git a/app/Models/Egg.php b/app/Models/Egg.php index 7b5f6ac8c..7829e3d74 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -1,26 +1,38 @@ |null $features * @property string $docker_image -- deprecated, use $docker_images * @property array $docker_images * @property string $update_url * @property bool $force_outgoing_ip - * @property array|null $file_denylist + * @property list|null $file_denylist * @property string|null $config_files * @property string|null $config_startup * @property string|null $config_logs @@ -32,8 +44,8 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; * @property string $script_entry * @property string $script_container * @property int|null $copy_script_from - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at + * @property Carbon $created_at + * @property Carbon $updated_at * @property string|null $copy_script_install * @property string $copy_script_entry * @property string $copy_script_container @@ -41,106 +53,60 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; * @property string|null $inherit_config_startup * @property string|null $inherit_config_logs * @property string|null $inherit_config_stop - * @property string $inherit_file_denylist - * @property array|null $inherit_features - * @property Nest $nest - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Server[] $servers - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\EggVariable[] $variables + * @property list|null $inherit_file_denylist + * @property list|null $inherit_features + * @property Collection|Server[] $servers + * @property Collection|EggVariable[] $variables + * @property Collection|Egg[] $configuredChildren * @property Egg|null $scriptFrom * @property Egg|null $configFrom */ #[Attributes\Identifiable('eegg')] +#[Fillable([ + 'name', + 'description', + 'features', + 'docker_images', + 'force_outgoing_ip', + 'file_denylist', + 'config_files', + 'config_startup', + 'config_logs', + 'config_stop', + 'config_from', + 'startup', + 'script_is_privileged', + 'script_install', + 'script_entry', + 'script_container', + 'copy_script_from', +])] class Egg extends Model implements Identifiable { - /** @use HasFactory<\Database\Factories\EggFactory> */ + /** @use HasFactory */ use HasFactory; + use HasRealtimeIdentifier; + use HasVersion4Uuids; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'egg'; + public const string RESOURCE_NAME = 'egg'; /** * Defines the current egg export version. */ - public const EXPORT_VERSION = 'PTDL_v2'; + public const string EXPORT_VERSION = 'PTDL_v2'; /** - * Different features that can be enabled on any given egg. These are used internally - * to determine which types of frontend functionality should be shown to the user. Eggs - * will automatically inherit features from a parent egg if they are already configured - * to copy configuration values from said egg. - * - * To skip copying the features, an empty array value should be passed in ("[]") rather - * than leaving it null. + * Features that toggle frontend functionality for an egg, inherited from the parent + * egg it copies configuration from unless explicitly set to an empty array ("[]"). */ - public const FEATURE_EULA_POPUP = 'eula'; - public const FEATURE_FASTDL = 'fastdl'; + public const string FEATURE_EULA_POPUP = 'eula'; - /** - * The table associated with the model. - */ - protected $table = 'eggs'; - - /** - * Fields that are not mass assignable. - */ - protected $fillable = [ - 'name', - 'description', - 'features', - 'docker_images', - 'force_outgoing_ip', - 'file_denylist', - 'config_files', - 'config_startup', - 'config_logs', - 'config_stop', - 'config_from', - 'startup', - 'script_is_privileged', - 'script_install', - 'script_entry', - 'script_container', - 'copy_script_from', - ]; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'nest_id' => 'integer', - 'config_from' => 'integer', - 'script_is_privileged' => 'boolean', - 'force_outgoing_ip' => 'boolean', - 'copy_script_from' => 'integer', - 'features' => 'array', - 'docker_images' => 'array', - 'file_denylist' => 'array', - ]; - - public static array $validationRules = [ - 'nest_id' => 'required|bail|numeric|exists:nests,id', - 'uuid' => 'required|string|size:36', - 'name' => 'required|string|max:191', - 'description' => 'string|nullable', - 'features' => 'array|nullable', - 'author' => 'required|string|email', - 'file_denylist' => 'array|nullable', - 'file_denylist.*' => 'string', - 'docker_images' => 'required|array|min:1', - 'docker_images.*' => ['required', 'string', 'max:191', 'regex:/^[\w#\.\/\- ]*\|?~?[\w\.\/\-:@ ]*$/'], - 'startup' => 'required|nullable|string', - 'config_from' => 'sometimes|bail|nullable|numeric|exists:eggs,id', - 'config_stop' => 'required_without:config_from|nullable|string|max:191', - 'config_startup' => 'required_without:config_from|nullable|json', - 'config_logs' => 'required_without:config_from|nullable|json', - 'config_files' => 'required_without:config_from|nullable|json', - 'update_url' => 'sometimes|nullable|string', - 'force_outgoing_ip' => 'sometimes|boolean', - ]; + public const string FEATURE_FASTDL = 'fastdl'; protected $attributes = [ 'features' => null, @@ -153,132 +119,55 @@ class Egg extends Model implements Identifiable ]; /** - * Returns the install script for the egg; if egg is copying from another - * it will return the copied script. + * @return array */ - public function getCopyScriptInstallAttribute(): ?string + protected function casts(): array { - if (!is_null($this->script_install) || is_null($this->copy_script_from)) { - return $this->script_install; - } - - return $this->scriptFrom->script_install; + return [ + 'config_from' => 'integer', + 'script_is_privileged' => 'boolean', + 'force_outgoing_ip' => 'boolean', + 'copy_script_from' => 'integer', + 'features' => 'array', + 'docker_images' => 'array', + 'file_denylist' => 'array', + ]; } /** - * Returns the entry command for the egg; if egg is copying from another - * it will return the copied entry command. + * @return list */ - public function getCopyScriptEntryAttribute(): string + public function uniqueIds(): array { - if (is_null($this->copy_script_from)) { - return $this->script_entry; - } - - return $this->scriptFrom->script_entry; + return ['uuid']; } /** - * Returns the install container for the egg; if egg is copying from another - * it will return the copied install container. - */ - public function getCopyScriptContainerAttribute(): string - { - if (is_null($this->copy_script_from)) { - return $this->script_container; - } - - return $this->scriptFrom->script_container; - } - - /** - * Return the file configuration for an egg. - */ - public function getInheritConfigFilesAttribute(): ?string - { - if (!is_null($this->config_files) || is_null($this->config_from)) { - return $this->config_files; - } - - return $this->configFrom->config_files; - } - - /** - * Return the startup configuration for an egg. - */ - public function getInheritConfigStartupAttribute(): ?string - { - if (!is_null($this->config_startup) || is_null($this->config_from)) { - return $this->config_startup; - } - - return $this->configFrom->config_startup; - } - - /** - * Return the log reading configuration for an egg. - */ - public function getInheritConfigLogsAttribute(): ?string - { - if (!is_null($this->config_logs) || is_null($this->config_from)) { - return $this->config_logs; - } - - return $this->configFrom->config_logs; - } - - /** - * Return the stop command configuration for an egg. - */ - public function getInheritConfigStopAttribute(): ?string - { - if (!is_null($this->config_stop) || is_null($this->config_from)) { - return $this->config_stop; - } - - return $this->configFrom->config_stop; - } - - /** - * Returns the features available to this egg from the parent configuration if there are - * no features defined for this egg specifically and there is a parent egg configured. - */ - public function getInheritFeaturesAttribute(): ?array - { - if (!is_null($this->features) || is_null($this->config_from)) { - return $this->features; - } - - return $this->configFrom->features; - } - - /** - * Returns the features available to this egg from the parent configuration if there are - * no features defined for this egg specifically and there is a parent egg configured. - */ - public function getInheritFileDenylistAttribute(): ?array - { - if (is_null($this->config_from)) { - return $this->file_denylist; - } - - return $this->configFrom->file_denylist; - } - - /** - * Gets nest associated with an egg. + * The tags applied to this egg. These replace the grouping the egg's nest used + * to provide, and are what the deployment gate matches a node's accepted games + * against. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Nest, $this> + * @return MorphToMany */ - public function nest(): BelongsTo + public function tags(): MorphToMany { - return $this->belongsTo(Nest::class); + return $this->morphToMany(Tag::class, 'taggable', 'taggables', 'taggable_id', 'tag_id'); + } + + /** + * The slugs of this egg's tags, used to gate node selection. + * + * @return string[] + */ + public function tagSlugs(): array + { + return JsonValueGuard::stringList($this->tags->pluck('slug')->all()); } /** * Gets all servers associated with this egg. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this> + * @return HasMany */ public function servers(): HasMany { @@ -288,17 +177,27 @@ class Egg extends Model implements Identifiable /** * Gets all variables associated with this egg. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\EggVariable, $this> + * @return HasMany */ public function variables(): HasMany { return $this->hasMany(EggVariable::class, 'egg_id'); } + /** + * Eggs that inherit their configuration from this egg. + * + * @return HasMany + */ + public function configuredChildren(): HasMany + { + return $this->hasMany(self::class, 'config_from'); + } + /** * Get the parent egg from which to copy scripts. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return BelongsTo */ public function scriptFrom(): BelongsTo { @@ -308,10 +207,180 @@ class Egg extends Model implements Identifiable /** * Get the parent egg from which to copy configuration settings. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return BelongsTo */ public function configFrom(): BelongsTo { return $this->belongsTo(self::class, 'config_from'); } + + /** + * Returns the install script for the egg; if egg is copying from another + * it will return the copied script. + * + * @return Attribute + */ + protected function copyScriptInstall(): Attribute + { + return Attribute::make(get: function (): ?string { + if (($this->script_install) !== null || ($this->copy_script_from) === null) { + return $this->script_install; + } + + return $this->copiedScriptEgg()->script_install; + }); + } + + /** + * Returns the entry command for the egg; if egg is copying from another + * it will return the copied entry command. + * + * @return Attribute + */ + protected function copyScriptEntry(): Attribute + { + return Attribute::make(get: function (): string { + if (($this->copy_script_from) === null) { + return $this->script_entry; + } + + return $this->copiedScriptEgg()->script_entry; + }); + } + + /** + * Returns the install container for the egg; if egg is copying from another + * it will return the copied install container. + * + * @return Attribute + */ + protected function copyScriptContainer(): Attribute + { + return Attribute::make(get: function (): string { + if (($this->copy_script_from) === null) { + return $this->script_container; + } + + return $this->copiedScriptEgg()->script_container; + }); + } + + /** + * Return the file configuration for an egg. + * + * @return Attribute + */ + protected function inheritConfigFiles(): Attribute + { + return Attribute::make(get: function (): ?string { + if (($this->config_files) !== null || ($this->config_from) === null) { + return $this->config_files; + } + + return $this->inheritedConfigurationEgg()->config_files; + }); + } + + /** + * Return the startup configuration for an egg. + * + * @return Attribute + */ + protected function inheritConfigStartup(): Attribute + { + return Attribute::make(get: function (): ?string { + if (($this->config_startup) !== null || ($this->config_from) === null) { + return $this->config_startup; + } + + return $this->inheritedConfigurationEgg()->config_startup; + }); + } + + /** + * Return the log reading configuration for an egg. + * + * @return Attribute + */ + protected function inheritConfigLogs(): Attribute + { + return Attribute::make(get: function (): ?string { + if (($this->config_logs) !== null || ($this->config_from) === null) { + return $this->config_logs; + } + + return $this->inheritedConfigurationEgg()->config_logs; + }); + } + + /** + * Return the stop command configuration for an egg. + * + * @return Attribute + */ + protected function inheritConfigStop(): Attribute + { + return Attribute::make(get: function (): ?string { + if (($this->config_stop) !== null || ($this->config_from) === null) { + return $this->config_stop; + } + + return $this->inheritedConfigurationEgg()->config_stop; + }); + } + + /** + * Returns the features available to this egg from the parent configuration if there are + * no features defined for this egg specifically and there is a parent egg configured. + * + * @return Attribute|null, never> + */ + protected function inheritFeatures(): Attribute + { + return Attribute::make(get: function (): ?array { + if (($this->features) !== null || ($this->config_from) === null) { + return $this->features; + } + + return $this->inheritedConfigurationEgg()->features; + }); + } + + /** + * Returns the features available to this egg from the parent configuration if there are + * no features defined for this egg specifically and there is a parent egg configured. + * + * @return Attribute|null, never> + */ + protected function inheritFileDenylist(): Attribute + { + return Attribute::make(get: function (): ?array { + if (($this->config_from) === null) { + return $this->file_denylist; + } + + return $this->inheritedConfigurationEgg()->file_denylist; + }); + } + + /** + * Eggs whose install script is their own. + * + * @param Builder $query + */ + #[Scope] + protected function scriptSources(Builder $query): void + { + $query->whereNull('copy_script_from'); + } + + private function copiedScriptEgg(): self + { + return $this->scriptFrom ?? throw new RuntimeException('The configured script source egg does not exist.'); + } + + private function inheritedConfigurationEgg(): self + { + return $this->configFrom ?? throw new RuntimeException('The configured parent egg does not exist.'); + } } diff --git a/app/Models/EggMount.php b/app/Models/EggMount.php deleted file mode 100644 index 2016f5423..000000000 --- a/app/Models/EggMount.php +++ /dev/null @@ -1,12 +0,0 @@ - */ + /** @use HasFactory */ use HasFactory; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'egg_variable'; + public const string RESOURCE_NAME = 'egg_variable'; /** * Reserved environment variable names. */ - public const RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID'; - - protected bool $immutableDates = true; - - /** - * The table associated with the model. - */ - protected $table = 'egg_variables'; - - /** - * Fields that are not mass assignable. - */ - protected $guarded = ['id', 'created_at', 'updated_at']; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'egg_id' => 'integer', - 'user_viewable' => 'bool', - 'user_editable' => 'bool', - ]; - - public static array $validationRules = [ - 'egg_id' => 'exists:eggs,id', - 'name' => 'required|string|between:1,191', - 'description' => 'string', - 'env_variable' => 'required|regex:/^[\w]{1,191}$/|notIn:' . self::RESERVED_ENV_NAMES, - 'default_value' => 'string', - 'user_viewable' => 'boolean', - 'user_editable' => 'boolean', - 'rules' => 'required|string', - ]; + public const string RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID'; protected $attributes = [ 'user_editable' => 0, 'user_viewable' => 0, ]; - public function getRequiredAttribute(): bool + /** + * @return array + */ + protected function casts(): array { - return in_array('required', explode('|', $this->rules)); + return [ + 'egg_id' => 'integer', + 'user_viewable' => 'bool', + 'user_editable' => 'bool', + 'sort_order' => 'integer', + ]; } /** - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Egg, $this> + * The egg this variable is defined on. + * + * @return BelongsTo */ - public function egg(): HasOne + public function egg(): BelongsTo { - return $this->hasOne(Egg::class); + return $this->belongsTo(Egg::class); } /** * Return server variables associated with this variable. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\ServerVariable, $this> + * @return HasMany */ public function serverVariable(): HasMany { return $this->hasMany(ServerVariable::class, 'variable_id'); } + + /** + * @return Attribute + */ + protected function required(): Attribute + { + return Attribute::make(get: fn (): bool => in_array('required', explode('|', $this->rules))); + } } diff --git a/app/Models/Extension.php b/app/Models/Extension.php new file mode 100644 index 000000000..6d1c877c8 --- /dev/null +++ b/app/Models/Extension.php @@ -0,0 +1,35 @@ + + */ + protected function casts(): array + { + return [ + 'enabled' => 'bool', + ]; + } +} diff --git a/app/Models/ExtensionSetting.php b/app/Models/ExtensionSetting.php new file mode 100644 index 000000000..bf968c9c9 --- /dev/null +++ b/app/Models/ExtensionSetting.php @@ -0,0 +1,37 @@ + */ + protected $attributes = ['scope' => 'global', 'is_secret' => false]; + + /** @return array */ + protected function casts(): array + { + return ['is_secret' => 'boolean']; + } +} diff --git a/app/Models/Filters/AdminServerFilter.php b/app/Models/Filters/AdminServerFilter.php index 638946734..7a95147ce 100644 --- a/app/Models/Filters/AdminServerFilter.php +++ b/app/Models/Filters/AdminServerFilter.php @@ -1,27 +1,34 @@ + */ class AdminServerFilter implements Filter { /** * A multi-column filter for the servers table that allows an administrative user to search * across UUID, name, owner username, and owner email. * - * @param string $value + * @param Builder $query + * @param string $value */ - public function __invoke(Builder $query, $value, string $property) + public function __invoke(Builder $query, $value, string $property): void { - if ($query->getQuery()->from !== 'servers') { - throw new \BadMethodCallException('Cannot use the AdminServerFilter against a non-server model.'); - } + throw_if($query->getQuery()->from !== 'servers', BadMethodCallException::class, 'Cannot use the AdminServerFilter against a non-server model.'); + $query ->select('servers.*') ->leftJoin('users', 'users.id', '=', 'servers.owner_id') - ->where(function (Builder $builder) use ($value) { + ->where(function (Builder $builder) use ($value): void { $builder->where('servers.uuid', $value) ->orWhere('servers.uuid', 'LIKE', "$value%") ->orWhere('servers.uuidShort', $value) diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index fe0a7ebd5..ce45f322a 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -1,31 +1,37 @@ + */ class MultiFieldServerFilter implements Filter { /** * If we detect that the value matches an IPv4 address we will use a different type of filtering * to look at the allocations. */ - private const IPV4_REGEX = '/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}(\:\d{1,5})?$/'; + private const string IPV4_REGEX = '/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}(\:\d{1,5})?$/'; /** * A multi-column filter for the servers table that allows you to pass in a single value and * search across multiple columns. This allows us to provide a very generic search ability for * the frontend. * - * @param string $value + * @param Builder $query + * @param string $value */ - public function __invoke(Builder $query, $value, string $property) + public function __invoke(Builder $query, $value, string $property): void { - if ($query->getQuery()->from !== 'servers') { - throw new \BadMethodCallException('Cannot use the MultiFieldServerFilter against a non-server model.'); - } + throw_if($query->getQuery()->from !== 'servers', BadMethodCallException::class, 'Cannot use the MultiFieldServerFilter against a non-server model.'); if (preg_match(self::IPV4_REGEX, $value) || preg_match('/^:\d{1,5}$/', $value)) { $query @@ -33,22 +39,22 @@ class MultiFieldServerFilter implements Filter // server objects together, resulting in incorrect behavior and returned values. ->select('servers.*') ->join('allocations', 'allocations.server_id', '=', 'servers.id') - ->where(function (Builder $builder) use ($value) { + ->where(function (Builder $builder) use ($value): void { $parts = explode(':', $value); - $builder->when( - !Str::startsWith($value, ':'), + $builder->unless( + Str::startsWith($value, ':'), // When the string does not start with a ":" it means we're looking for an IP or IP:Port // combo, so use a query to handle that. - function (Builder $builder) use ($parts) { + function (Builder $builder) use ($parts): void { $builder->orWhere('allocations.ip', $parts[0]); - if (!is_null($parts[1] ?? null)) { + if (($parts[1] ?? null) !== null) { $builder->where('allocations.port', 'LIKE', "{$parts[1]}%"); } }, // Otherwise, just try to search for that specific port in the allocations. - function (Builder $builder) use ($value) { - $builder->orWhere('allocations.port', 'LIKE', substr($value, 1) . '%'); + function (Builder $builder) use ($value): void { + $builder->orWhere('allocations.port', 'LIKE', mb_substr($value, 1).'%'); } ); }) @@ -58,7 +64,7 @@ class MultiFieldServerFilter implements Filter } $query - ->where(function (Builder $builder) use ($value) { + ->where(function (Builder $builder) use ($value): void { $builder->where('servers.uuid', $value) ->orWhere('servers.uuid', 'LIKE', "$value%") ->orWhere('servers.uuidShort', $value) diff --git a/app/Models/Location.php b/app/Models/Location.php index b083d7b2b..5fdf4ab91 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -1,48 +1,36 @@ */ + /** @use HasFactory */ use HasFactory; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'location'; - - /** - * The table associated with the model. - */ - protected $table = 'locations'; - - /** - * Fields that are not mass assignable. - */ - protected $guarded = ['id', 'created_at', 'updated_at']; - - /** - * Rules ensuring that the raw data stored in the database meets expectations. - */ - public static array $validationRules = [ - 'short' => 'required|string|between:1,60|unique:locations,short', - 'long' => 'string|nullable|between:1,191', - ]; + public const string RESOURCE_NAME = 'location'; public function getRouteKeyName(): string { @@ -52,7 +40,7 @@ class Location extends Model /** * Gets the nodes in a specified location. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Node, $this> + * @return HasMany */ public function nodes(): HasMany { @@ -62,7 +50,7 @@ class Location extends Model /** * Gets the servers within a given location. * - * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Pterodactyl\Models\Server, \Pterodactyl\Models\Node, $this> + * @return HasManyThrough */ public function servers(): HasManyThrough { diff --git a/app/Models/Model.php b/app/Models/Model.php index 01958c0bc..df442b5a5 100644 --- a/app/Models/Model.php +++ b/app/Models/Model.php @@ -1,183 +1,11 @@ make(ValidationFactory::class); - - static::saving(function (Model $model) { - try { - $model->validate(); - } catch (ValidationException $exception) { - throw new DataValidationException($exception->validator, $model); - } - - return true; - }); - } - - /** - * Returns the model key to use for route model binding. By default, we'll - * assume every model uses a UUID field for this. If the model does not have - * a UUID and is using a different key it should be specified on the model - * itself. - * - * You may also optionally override this on a per-route basis by declaring - * the key name in the URL definition, like "{user:id}". - */ - public function getRouteKeyName(): string - { - return 'uuid'; - } - - /** - * Set the model to skip validation when saving. - */ - public function skipValidation(): self - { - $this->skipValidation = true; - - return $this; - } - - /** - * Returns the validator instance used by this model. - */ - public function getValidator(): \Illuminate\Validation\Validator - { - $rules = $this->exists ? static::getRulesForUpdate($this) : static::getRules(); - - // @phpstan-ignore-next-line return.type - return static::$validatorFactory->make([], $rules); - } - - /** - * Returns the rules associated with this model. - */ - public static function getRules(): array - { - $rules = static::$validationRules; - foreach ($rules as $key => &$rule) { - $rule = is_array($rule) ? $rule : explode('|', $rule); - } - - return $rules; - } - - /** - * Returns the rules for a specific field. If the field is not found an empty - * array is returned. - */ - public static function getRulesForField(string $field): array - { - return Arr::get(static::getRules(), $field) ?? []; - } - - /** - * Returns the rules associated with the model, specifically for updating the given model - * rather than just creating it. - */ - public static function getRulesForUpdate($model, string $column = 'id'): array - { - if ($model instanceof Model) { - [$id, $column] = [$model->getKey(), $model->getKeyName()]; - } - - $rules = static::getRules(); - foreach ($rules as $key => &$data) { - // For each rule in a given field, iterate over it and confirm if the rule - // is one for a unique field. If that is the case, append the ID of the current - // working model, so we don't run into errors due to the way that field validation - // works. - foreach ($data as &$datum) { - if (!is_string($datum) || !Str::startsWith($datum, 'unique')) { - continue; - } - - [, $args] = explode(':', $datum); - $args = explode(',', $args); - - $datum = Rule::unique($args[0], $args[1] ?? $key)->ignore($id ?? $model, $column); - } - } - - return $rules; - } - - /** - * Determines if the model is in a valid state or not. - * - * @throws ValidationException - */ - public function validate(): void - { - if ($this->skipValidation) { - return; - } - - $validator = $this->getValidator(); - $validator->setData( - // Trying to do self::toArray() here will leave out keys based on the whitelist/blacklist - // for that model. Doing this will return all the attributes in a format that can - // properly be validated. - $this->addCastAttributesToArray( - $this->getAttributes(), - $this->getMutatedAttributes() - ) - ); - - if (!$validator->passes()) { - throw new ValidationException($validator); - } - } - - /** - * Return a timestamp as DateTime object. - */ - protected function asDateTime($value): Carbon|CarbonImmutable - { - if (!$this->immutableDates) { - return parent::asDateTime($value); - } - - return parent::asDateTime($value)->toImmutable(); - } -} +#[RouteKey('uuid')] +abstract class Model extends IlluminateModel {} diff --git a/app/Models/Mount.php b/app/Models/Mount.php index 7d036a4aa..658212025 100644 --- a/app/Models/Mount.php +++ b/app/Models/Mount.php @@ -1,11 +1,19 @@ */ + use HasFactory; + use HasRealtimeIdentifier; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'mount'; - - /** - * The table associated with the model. - */ - protected $table = 'mounts'; - - /** - * Fields that are not mass assignable. - */ - protected $guarded = ['id', 'uuid']; - - /** - * Default values for specific fields in the database. - */ - protected $casts = [ - 'id' => 'int', - 'read_only' => 'bool', - 'user_mountable' => 'bool', - ]; - - /** - * Rules verifying that the data being stored matches the expectations of the database. - */ - public static array $validationRules = [ - 'name' => 'required|string|min:2|max:64|unique:mounts,name', - 'description' => 'nullable|string|max:191', - 'source' => 'required|string', - 'target' => 'required|string', - 'read_only' => 'sometimes|boolean', - 'user_mountable' => 'sometimes|boolean', - ]; - - /** - * Implement language verification by overriding Eloquence's gather - * rules function. - */ - public static function getRules(): array - { - $rules = parent::getRules(); - - $rules['source'][] = new NotIn(Mount::$invalidSourcePaths); - $rules['target'][] = new NotIn(Mount::$invalidTargetPaths); - - return $rules; - } - - /** - * Disable timestamps on this model. - */ - public $timestamps = false; + public const string RESOURCE_NAME = 'mount'; /** * Blacklisted source paths. + * + * @var list */ - public static $invalidSourcePaths = [ + public static array $invalidSourcePaths = [ '/etc/pterodactyl', '/var/lib/pterodactyl/volumes', '/srv/daemon-data', @@ -92,15 +57,29 @@ class Mount extends Model implements Identifiable /** * Blacklisted target paths. + * + * @var list */ - public static $invalidTargetPaths = [ + public static array $invalidTargetPaths = [ '/home/container', ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'id' => 'int', + 'read_only' => 'bool', + 'user_mountable' => 'bool', + ]; + } + /** * Returns all eggs that have this mount assigned. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Egg, $this> + * @return BelongsToMany */ public function eggs(): BelongsToMany { @@ -110,7 +89,7 @@ class Mount extends Model implements Identifiable /** * Returns all nodes that have this mount assigned. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Node, $this> + * @return BelongsToMany */ public function nodes(): BelongsToMany { @@ -120,10 +99,24 @@ class Mount extends Model implements Identifiable /** * Returns all servers that have this mount assigned. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Pterodactyl\Models\Server, $this> + * @return BelongsToMany */ public function servers(): BelongsToMany { return $this->belongsToMany(Server::class); } + + /** + * Mounts attached to both the server's egg and its node, whether or not the + * server currently has them mounted. + * + * @param Builder $query + */ + #[Scope] + protected function availableToServer(Builder $query, Server $server): void + { + $query + ->whereHas('eggs', fn (Builder $eggs) => $eggs->whereKey($server->egg_id)) + ->whereHas('nodes', fn (Builder $nodes) => $nodes->whereKey($server->node_id)); + } } diff --git a/app/Models/MountNode.php b/app/Models/MountNode.php index dae6b3179..1dc49f502 100644 --- a/app/Models/MountNode.php +++ b/app/Models/MountNode.php @@ -1,14 +1,16 @@ */ - use HasFactory; - - /** - * The resource name for this model when it is transformed into an - * API representation using fractal. - */ - public const RESOURCE_NAME = 'nest'; - - /** - * The table associated with the model. - */ - protected $table = 'nests'; - - /** - * Fields that are mass assignable. - */ - protected $fillable = [ - 'name', - 'description', - ]; - - public static array $validationRules = [ - 'author' => 'required|string|email', - 'name' => 'required|string|max:191', - 'description' => 'nullable|string', - ]; - - /** - * Gets all eggs associated with this service. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Egg, $this> - */ - public function eggs(): HasMany - { - return $this->hasMany(Egg::class); - } - - /** - * Gets all servers associated with this nest. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this> - */ - public function servers(): HasMany - { - return $this->hasMany(Server::class); - } -} diff --git a/app/Models/Node.php b/app/Models/Node.php index 22c962aa9..60fd65d97 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -1,18 +1,28 @@ $mounts + * @property Server[]|Collection $servers + * @property Allocation[]|Collection $allocations */ #[Attributes\Identifiable('node')] +#[Fillable([ + 'public', 'name', 'location_id', + 'description', 'fqdn', 'scheme', 'behind_proxy', + 'memory', 'memory_overallocate', 'disk', + 'disk_overallocate', 'upload_size', 'daemonBase', + 'daemonSFTP', 'daemonListen', + 'maintenance_mode', +])] +#[Hidden(['daemon_token_id', 'daemon_token'])] class Node extends Model implements Identifiable { - /** @use HasFactory<\Database\Factories\NodeFactory> */ + /** @use HasFactory */ use HasFactory; - use Notifiable; + use HasRealtimeIdentifier; + use HasVersion4Uuids; + use Notifiable; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'node'; + public const string RESOURCE_NAME = 'node'; - public const DAEMON_TOKEN_ID_LENGTH = 16; - public const DAEMON_TOKEN_LENGTH = 64; + public const int DAEMON_TOKEN_ID_LENGTH = 16; - /** - * The table associated with the model. - */ - protected $table = 'nodes'; + public const int DAEMON_TOKEN_LENGTH = 64; - /** - * The attributes excluded from the model's JSON form. - */ - protected $hidden = ['daemon_token_id', 'daemon_token']; + /** Utilization at or below this percentage renders green. */ + public const int THRESHOLD_PERCENTAGE_LOW = 75; - /** - * Cast values to correct type. - */ - protected $casts = [ - 'location_id' => 'integer', - 'memory' => 'integer', - 'disk' => 'integer', - 'daemonListen' => 'integer', - 'daemonSFTP' => 'integer', - 'behind_proxy' => 'boolean', - 'public' => 'boolean', - 'maintenance_mode' => 'boolean', - ]; - - /** - * Fields that are mass assignable. - */ - protected $fillable = [ - 'public', 'name', 'location_id', - 'description', 'fqdn', 'scheme', 'behind_proxy', - 'memory', 'memory_overallocate', 'disk', - 'disk_overallocate', 'upload_size', 'daemonBase', - 'daemonSFTP', 'daemonListen', - 'description', 'maintenance_mode', - ]; - - public static array $validationRules = [ - 'name' => 'required|regex:/^([\w .-]{1,100})$/', - 'description' => 'string|nullable', - 'location_id' => 'required|exists:locations,id', - 'public' => 'boolean', - 'fqdn' => 'required|string', - 'scheme' => 'required', - 'behind_proxy' => 'boolean', - 'memory' => 'required|numeric|min:1', - 'memory_overallocate' => 'required|numeric|min:-1', - 'disk' => 'required|numeric|min:1', - 'disk_overallocate' => 'required|numeric|min:-1', - 'daemonBase' => 'sometimes|required|regex:/^([\/][\d\w.\-\/]+)$/', - 'daemonSFTP' => 'required|numeric|between:1,65535', - 'daemonListen' => 'required|numeric|between:1,65535', - 'maintenance_mode' => 'boolean', - 'upload_size' => 'int|min:1', - ]; + /** Utilization above this percentage renders red; between the two, yellow. */ + public const int THRESHOLD_PERCENTAGE_MEDIUM = 90; /** * Default values for specific columns that are generally not changed on base installs. @@ -128,6 +101,34 @@ class Node extends Model implements Identifiable 'maintenance_mode' => false, ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'location_id' => 'integer', + 'memory' => 'integer', + 'memory_overallocate' => 'integer', + 'disk' => 'integer', + 'disk_overallocate' => 'integer', + 'upload_size' => 'integer', + 'daemonListen' => 'integer', + 'daemonSFTP' => 'integer', + 'behind_proxy' => 'boolean', + 'public' => 'boolean', + 'maintenance_mode' => 'boolean', + ]; + } + + /** + * @return list + */ + public function uniqueIds(): array + { + return ['uuid']; + } + /** * Get the connection address to use when making calls to this node. */ @@ -138,21 +139,28 @@ class Node extends Model implements Identifiable /** * Returns the configuration as an array. + * + * @return NodeConfiguration the wings configuration blob for this node */ public function getConfiguration(): array { + $allowedMounts = []; + foreach ($this->mounts as $mount) { + $allowedMounts[] = $mount->source; + } + return [ 'debug' => false, 'uuid' => $this->uuid, 'token_id' => $this->daemon_token_id, - 'token' => Container::getInstance()->make(Encrypter::class)->decrypt($this->daemon_token), + 'token' => $this->getDecryptedKey(), 'api' => [ 'host' => '0.0.0.0', 'port' => $this->daemonListen, 'ssl' => [ - 'enabled' => (!$this->behind_proxy && $this->scheme === 'https'), - 'cert' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/fullchain.pem', - 'key' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/privkey.pem', + 'enabled' => (! $this->behind_proxy && $this->scheme === 'https'), + 'cert' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/fullchain.pem', + 'key' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/privkey.pem', ], 'upload_limit' => $this->upload_size, ], @@ -162,8 +170,8 @@ class Node extends Model implements Identifiable 'bind_port' => $this->daemonSFTP, ], ], - 'allowed_mounts' => $this->mounts->pluck('source')->toArray(), - 'remote' => route('index'), + 'allowed_mounts' => $allowedMounts, + 'remote' => mb_rtrim(JsonValueGuard::nonEmptyString(config('app.url')), '/'), ]; } @@ -180,7 +188,10 @@ class Node extends Model implements Identifiable */ public function getJsonConfiguration(bool $pretty = false): string { - return json_encode($this->getConfiguration(), $pretty ? JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT : JSON_UNESCAPED_SLASHES); + return json_encode( + $this->getConfiguration(), + ($pretty ? JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT : JSON_UNESCAPED_SLASHES) | JSON_THROW_ON_ERROR + ); } /** @@ -188,9 +199,10 @@ class Node extends Model implements Identifiable */ public function getDecryptedKey(): string { - return (string) Container::getInstance()->make(Encrypter::class)->decrypt( - $this->daemon_token - ); + $key = Crypt::decrypt($this->daemon_token); + throw_unless(is_string($key), UnexpectedValueException::class, 'The decrypted node key must be a string.'); + + return $key; } public function isUnderMaintenance(): bool @@ -199,7 +211,7 @@ class Node extends Model implements Identifiable } /** - * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Pterodactyl\Models\Mount, \Pterodactyl\Models\MountNode, $this> + * @return HasManyThrough */ public function mounts(): HasManyThrough { @@ -209,7 +221,7 @@ class Node extends Model implements Identifiable /** * Gets the location associated with a node. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Location, $this> + * @return BelongsTo */ public function location(): BelongsTo { @@ -219,7 +231,7 @@ class Node extends Model implements Identifiable /** * Gets the servers associated with a node. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this> + * @return HasMany */ public function servers(): HasMany { @@ -229,7 +241,7 @@ class Node extends Model implements Identifiable /** * Gets the allocations associated with a node. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Allocation, $this> + * @return HasMany */ public function allocations(): HasMany { @@ -237,14 +249,129 @@ class Node extends Model implements Identifiable } /** - * Returns a boolean if the node is viable for an additional server to be placed on it. + * The tags on this node, under either pivot kind. Present for administrative + * listings; the deploy gate reads the kind-scoped eggTags()/deploymentTags() + * instead. + * + * @return MorphToMany + */ + public function tags(): MorphToMany + { + return $this->morphToMany(Tag::class, 'taggable', 'taggables', 'taggable_id', 'tag_id'); + } + + /** + * The games this node accepts, OR-matched against a deploying egg's tags. + * + * withPivotValue both scopes reads and stamps the kind on attach/sync, so + * syncing one kind never disturbs the other's rows. + * + * @return MorphToMany + */ + public function eggTags(): MorphToMany + { + return $this->morphToMany(Tag::class, 'taggable', 'taggables', 'taggable_id', 'tag_id') + ->withPivotValue('kind', 'egg'); + } + + /** + * The reservations on this node: a deploy lands here only when its own deploy + * tags match these exactly (see NodeTagGate). + * + * @return MorphToMany + */ + public function deploymentTags(): MorphToMany + { + return $this->morphToMany(Tag::class, 'taggable', 'taggables', 'taggable_id', 'tag_id') + ->withPivotValue('kind', 'deployment'); + } + + /** + * @return string[] + */ + public function eggTagSlugs(): array + { + return JsonValueGuard::stringList($this->eggTags->pluck('slug')->all()); + } + + /** + * @return string[] + */ + public function deploymentTagSlugs(): array + { + return JsonValueGuard::stringList($this->deploymentTags->pluck('slug')->all()); + } + + /** + * Whether an additional server of the given size fits within this node's + * (over)allocatable memory and disk. */ public function isViable(int $memory, int $disk): bool { + $used = $this->allocatedResources(); $memoryLimit = $this->memory * (1 + ($this->memory_overallocate / 100)); $diskLimit = $this->disk * (1 + ($this->disk_overallocate / 100)); - // @phpstan-ignore-next-line property.notFound, property.notFound - return ($this->sum_memory + $memory) <= $memoryLimit && ($this->sum_disk + $disk) <= $diskLimit; + return ($used['memory'] + $memory) <= $memoryLimit && ($used['disk'] + $disk) <= $diskLimit; + } + + /** + * Memory and disk consumed by this node's servers against its (over)allocatable + * capacity, in the shape the admin utilization endpoint returns. + * + * @return array + */ + public function utilization(): array + { + $used = $this->allocatedResources(); + + return [ + 'disk' => $this->utilizationOf($used['disk'], $this->disk, $this->disk_overallocate), + 'memory' => $this->utilizationOf($used['memory'], $this->memory, $this->memory_overallocate), + ]; + } + + /** @return array{memory: int, disk: int} */ + public function allocatedResources(): array + { + if (array_key_exists('sum_memory', $this->getAttributes()) && array_key_exists('sum_disk', $this->getAttributes())) { + // SAFETY: these aliases are database SUM projections and therefore integer-like. + $sumMemory = $this->getAttribute('sum_memory'); + $memory = $sumMemory === null ? 0 : JsonValueGuard::integer($sumMemory); + // SAFETY: these aliases are database SUM projections and therefore integer-like. + $sumDisk = $this->getAttribute('sum_disk'); + $disk = $sumDisk === null ? 0 : JsonValueGuard::integer($sumDisk); + } else { + $resources = $this->servers()->toBase() + ->selectRaw('COALESCE(SUM(memory), 0) AS memory, COALESCE(SUM(disk), 0) AS disk') + ->first(); + + throw_if($resources === null || ! is_numeric($resources->memory) || ! is_numeric($resources->disk), UnexpectedValueException::class, 'The node resource aggregate query returned malformed values.'); + + // SAFETY: the aggregate values were validated as numeric immediately above. + $memory = (int) $resources->memory; + // SAFETY: the aggregate values were validated as numeric immediately above. + $disk = (int) $resources->disk; + } + + return ['memory' => $memory, 'disk' => $disk]; + } + + /** @return array{value: string, max: string, percent: float|int, css: string} */ + private function utilizationOf(int $used, int $capacity, int $overallocate): array + { + $max = $overallocate > 0 ? $capacity * (1 + ($overallocate / 100)) : $capacity; + $percent = $max > 0 ? ($used / $max) * 100 : 0; + + return [ + 'value' => number_format($used), + 'max' => number_format($max), + 'percent' => $percent, + 'css' => match (true) { + $percent <= self::THRESHOLD_PERCENTAGE_LOW => 'green', + $percent > self::THRESHOLD_PERCENTAGE_MEDIUM => 'red', + default => 'yellow', + }, + ]; } } diff --git a/app/Models/Objects/DeploymentObject.php b/app/Models/Objects/DeploymentObject.php index 0c44be08e..3ff9d095a 100644 --- a/app/Models/Objects/DeploymentObject.php +++ b/app/Models/Objects/DeploymentObject.php @@ -1,15 +1,37 @@ + */ private array $locations = []; + /** + * Individual ports and port ranges exactly as they arrived from the request; + * AllocationSelectionService discards the entries it cannot use. + * + * @var list + */ private array $ports = []; + /** + * The deploy tags (D) this deployment declares. A node's reservations are + * matched against these exactly - see NodeTagGate. + * + * @var array + */ + private array $tags = []; + public function isDedicated(): bool { return $this->dedicated; @@ -22,11 +44,17 @@ class DeploymentObject return $this; } + /** + * @return list + */ public function getLocations(): array { return $this->locations; } + /** + * @param list $locations + */ public function setLocations(array $locations): self { $this->locations = $locations; @@ -34,15 +62,39 @@ class DeploymentObject return $this; } + /** + * @return list + */ public function getPorts(): array { return $this->ports; } + /** + * @param list $ports + */ public function setPorts(array $ports): self { $this->ports = $ports; return $this; } + + /** + * @return array + */ + public function getTags(): array + { + return $this->tags; + } + + /** + * @param array $tags + */ + public function setTags(array $tags): self + { + $this->tags = $tags; + + return $this; + } } diff --git a/app/Models/Permission.php b/app/Models/Permission.php index b2e00070e..669841766 100644 --- a/app/Models/Permission.php +++ b/app/Models/Permission.php @@ -1,102 +1,30 @@ 'integer', - ]; - - public static array $validationRules = [ - 'subuser_id' => 'required|numeric|min:1', - 'permission' => 'required|string', - ]; + public const string RESOURCE_NAME = 'subuser_permission'; /** * All the permissions available on the system. You should use self::permissions() * to retrieve them, and not directly access this array as it is subject to change. * - * @see \Pterodactyl\Models\Permission::permissions() + * @see Permission::permissions() + * + * @var array}> */ protected static array $permissions = [ 'websocket' => [ @@ -107,7 +35,7 @@ class Permission extends Model ], 'control' => [ - 'description' => 'Permissions that control a user\'s ability to control the power state of a server, or send commands.', + 'description' => "Permissions that control a user's ability to control the power state of a server, or send commands.", 'keys' => [ 'console' => 'Allows a user to send commands to the server instance via the console.', 'start' => 'Allows a user to start the server if it is stopped.', @@ -127,7 +55,7 @@ class Permission extends Model ], 'file' => [ - 'description' => 'Permissions that control a user\'s ability to modify the filesystem for this server.', + 'description' => "Permissions that control a user's ability to modify the filesystem for this server.", 'keys' => [ 'create' => 'Allows a user to create additional files and folders via the Panel or direct upload.', 'read' => 'Allows a user to view the contents of a directory, but not view the contents of or download files.', @@ -140,7 +68,7 @@ class Permission extends Model ], 'backup' => [ - 'description' => 'Permissions that control a user\'s ability to generate and manage server backups.', + 'description' => "Permissions that control a user's ability to generate and manage server backups.", 'keys' => [ 'create' => 'Allows a user to create new backups for this server.', 'read' => 'Allows a user to view all backups that exist for this server.', @@ -152,7 +80,7 @@ class Permission extends Model // Controls permissions for editing or viewing a server's allocations. 'allocation' => [ - 'description' => 'Permissions that control a user\'s ability to modify the port allocations for this server.', + 'description' => "Permissions that control a user's ability to modify the port allocations for this server.", 'keys' => [ 'read' => 'Allows a user to view all allocations currently assigned to this server. Users with any level of access to this server can always view the primary allocation.', 'create' => 'Allows a user to assign additional allocations to the server.', @@ -163,7 +91,7 @@ class Permission extends Model // Controls permissions for editing or viewing a server's startup parameters. 'startup' => [ - 'description' => 'Permissions that control a user\'s ability to view this server\'s startup parameters.', + 'description' => "Permissions that control a user's ability to view this server's startup parameters.", 'keys' => [ 'read' => 'Allows a user to view the startup variables for a server.', 'update' => 'Allows a user to modify the startup variables for the server.', @@ -172,7 +100,7 @@ class Permission extends Model ], 'database' => [ - 'description' => 'Permissions that control a user\'s access to the database management for this server.', + 'description' => "Permissions that control a user's access to the database management for this server.", 'keys' => [ 'create' => 'Allows a user to create a new database for this server.', 'read' => 'Allows a user to view the database associated with this server.', @@ -183,7 +111,7 @@ class Permission extends Model ], 'schedule' => [ - 'description' => 'Permissions that control a user\'s access to the schedule management for this server.', + 'description' => "Permissions that control a user's access to the schedule management for this server.", 'keys' => [ 'create' => 'Allows a user to create new schedules for this server.', // task.create-schedule 'read' => 'Allows a user to view schedules and the tasks associated with them for this server.', // task.view-schedule, task.list-schedules @@ -193,7 +121,7 @@ class Permission extends Model ], 'settings' => [ - 'description' => 'Permissions that control a user\'s access to the settings for this server.', + 'description' => "Permissions that control a user's access to the settings for this server.", 'keys' => [ 'rename' => 'Allows a user to rename this server and change the description of it.', 'reinstall' => 'Allows a user to trigger a reinstall of this server.', @@ -201,16 +129,28 @@ class Permission extends Model ], 'activity' => [ - 'description' => 'Permissions that control a user\'s access to the server activity logs.', + 'description' => "Permissions that control a user's access to the server activity logs.", 'keys' => [ 'read' => 'Allows a user to view the activity logs for the server.', ], ], ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'subuser_id' => 'integer', + ]; + } + /** * Returns all the permissions available on the system for a user to * have when controlling a server. + * + * @return Collection}> */ public static function permissions(): Collection { diff --git a/app/Models/RecoveryToken.php b/app/Models/RecoveryToken.php index 64b3b9fad..9a7312c88 100644 --- a/app/Models/RecoveryToken.php +++ b/app/Models/RecoveryToken.php @@ -1,14 +1,17 @@ 'required|string', - ]; - /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this> + * @return BelongsTo */ public function user(): BelongsTo { diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index 4d988d000..dfae8a1d2 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -1,14 +1,20 @@ $tasks + * @property Collection $tasks */ +#[Fillable([ + 'server_id', + 'name', + 'cron_day_of_week', + 'cron_month', + 'cron_day_of_month', + 'cron_hour', + 'cron_minute', + 'is_active', + 'is_processing', + 'only_when_online', + 'last_run_at', + 'next_run_at', +])] class Schedule extends Model { - /** @use HasFactory<\Database\Factories\ScheduleFactory> */ + /** @use HasFactory */ use HasFactory; + use HasHashid; + /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'server_schedule'; - - /** - * The table associated with the model. - */ - protected $table = 'schedules'; + public const string RESOURCE_NAME = 'server_schedule'; /** * Always return the tasks associated with this schedule. */ protected $with = ['tasks']; - /** - * Mass assignable attributes on this model. - */ - protected $fillable = [ - 'server_id', - 'name', - 'cron_day_of_week', - 'cron_month', - 'cron_day_of_month', - 'cron_hour', - 'cron_minute', - 'is_active', - 'is_processing', - 'only_when_online', - 'last_run_at', - 'next_run_at', - ]; - - protected $casts = [ - 'id' => 'integer', - 'server_id' => 'integer', - 'is_active' => 'boolean', - 'is_processing' => 'boolean', - 'only_when_online' => 'boolean', - 'last_run_at' => 'datetime', - 'next_run_at' => 'datetime', - ]; - protected $attributes = [ 'name' => null, 'cron_day_of_week' => '*', @@ -91,20 +79,21 @@ class Schedule extends Model 'only_when_online' => false, ]; - public static array $validationRules = [ - 'server_id' => 'required|exists:servers,id', - 'name' => 'required|string|max:191', - 'cron_day_of_week' => 'required|string', - 'cron_month' => 'required|string', - 'cron_day_of_month' => 'required|string', - 'cron_hour' => 'required|string', - 'cron_minute' => 'required|string', - 'is_active' => 'boolean', - 'is_processing' => 'boolean', - 'only_when_online' => 'boolean', - 'last_run_at' => 'nullable|date', - 'next_run_at' => 'nullable|date', - ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'id' => 'integer', + 'server_id' => 'integer', + 'is_active' => 'boolean', + 'is_processing' => 'boolean', + 'only_when_online' => 'boolean', + 'last_run_at' => 'datetime', + 'next_run_at' => 'datetime', + ]; + } public function getRouteKeyName(): string { @@ -114,7 +103,7 @@ class Schedule extends Model /** * Returns the schedule's execution crontab entry as a string. * - * @throws \Exception + * @throws Exception */ public function getNextRunDate(): CarbonImmutable { @@ -123,28 +112,20 @@ class Schedule extends Model return CarbonImmutable::instance((new CronExpression($formatted))->getNextRunDate()); } - /** - * Return a hashid encoded string to represent the ID of the schedule. - */ - public function getHashidAttribute(): string - { - return Container::getInstance()->make(HashidsInterface::class)->encode($this->id); - } - /** * Return tasks belonging to a schedule. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Task, $this> + * @return HasMany */ public function tasks(): HasMany { - return $this->hasMany(Task::class); + return $this->hasMany(Task::class)->chaperone('schedule'); } /** * Return the server model that a schedule belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { diff --git a/app/Models/Server.php b/app/Models/Server.php index 7411a2a9c..f84893942 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -1,19 +1,31 @@ |DatabaseNotification[] $notifications * @property int|null $notifications_count - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Schedule[] $schedules + * @property Collection|Schedule[] $schedules * @property int|null $schedules_count - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Subuser[] $subusers + * @property Collection|Subuser[] $subusers * @property int|null $subusers_count * @property ServerTransfer|null $transfer * @property User $user - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\EggVariable[] $variables + * @property Collection|EggVariable[] $variables * @property int|null $variables_count + * @property Collection|ServerVariable[] $serverVariables * - * @method static \Database\Factories\ServerFactory factory(...$parameters) - * @method static \Illuminate\Database\Eloquent\Builder|Server newModelQuery() - * @method static \Illuminate\Database\Eloquent\Builder|Server newQuery() - * @method static \Illuminate\Database\Eloquent\Builder|Server query() - * @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationLimit($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereBackupLimit($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereCpu($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereCreatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereDatabaseLimit($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereDescription($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereDisk($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereEggId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereExternalId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereImage($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereIo($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereMemory($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereName($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereNestId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereNodeId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereOomDisabled($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereOwnerId($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereSkipScripts($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereStartup($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereStatus($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereSwap($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereThreads($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereUpdatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereUuid($value) - * @method static \Illuminate\Database\Eloquent\Builder|Server whereUuidShort($value) + * @method static ServerFactory factory(...$parameters) + * @method static Builder|Server newModelQuery() + * @method static Builder|Server newQuery() + * @method static Builder|Server query() + * @method static Builder|Server whereAllocationId($value) + * @method static Builder|Server whereAllocationLimit($value) + * @method static Builder|Server whereBackupLimit($value) + * @method static Builder|Server whereCpu($value) + * @method static Builder|Server whereCreatedAt($value) + * @method static Builder|Server whereDatabaseLimit($value) + * @method static Builder|Server whereDescription($value) + * @method static Builder|Server whereDisk($value) + * @method static Builder|Server whereEggId($value) + * @method static Builder|Server whereExternalId($value) + * @method static Builder|Server whereId($value) + * @method static Builder|Server whereImage($value) + * @method static Builder|Server whereIo($value) + * @method static Builder|Server whereMemory($value) + * @method static Builder|Server whereName($value) + * @method static Builder|Server whereNodeId($value) + * @method static Builder|Server whereOomDisabled($value) + * @method static Builder|Server whereOwnerId($value) + * @method static Builder|Server whereSkipScripts($value) + * @method static Builder|Server whereStartup($value) + * @method static Builder|Server whereStatus($value) + * @method static Builder|Server whereSwap($value) + * @method static Builder|Server whereThreads($value) + * @method static Builder|Server whereUpdatedAt($value) + * @method static Builder|Server whereUuid($value) + * @method static Builder|Server whereUuidShort($value) * - * @mixin \Eloquent + * @mixin \Illuminate\Database\Eloquent\Model */ #[Attributes\Identifiable('serv')] +#[Guarded(['id', self::CREATED_AT, self::UPDATED_AT, 'deleted_at', 'installed_at'])] class Server extends Model implements Identifiable { - /** @use HasFactory<\Database\Factories\ServerFactory> */ + /** @use HasFactory */ use HasFactory; - use BelongsToThrough; - use Notifiable; + use HasRealtimeIdentifier; + use Notifiable; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'server'; - public const STATUS_INSTALLING = 'installing'; - public const STATUS_INSTALL_FAILED = 'install_failed'; - public const STATUS_REINSTALL_FAILED = 'reinstall_failed'; - public const STATUS_SUSPENDED = 'suspended'; - public const STATUS_RESTORING_BACKUP = 'restoring_backup'; + public const string RESOURCE_NAME = 'server'; - /** - * The table associated with the model. - */ - protected $table = 'servers'; + public const string STATUS_INSTALLING = 'installing'; + + public const string STATUS_INSTALL_FAILED = 'install_failed'; + + public const string STATUS_REINSTALL_FAILED = 'reinstall_failed'; + + public const string STATUS_SUSPENDED = 'suspended'; + + public const string STATUS_RESTORING_BACKUP = 'restoring_backup'; + + private const string ADMIN_ROUTE_BINDING_FIELD = 'admin_identifier'; /** * Default values when creating the model. We want to switch to disabling OOM killer @@ -146,68 +159,48 @@ class Server extends Model implements Identifiable protected $with = ['allocation']; /** - * Fields that are not mass assignable. + * @return array */ - protected $guarded = ['id', self::CREATED_AT, self::UPDATED_AT, 'deleted_at', 'installed_at']; - - public static array $validationRules = [ - 'external_id' => 'sometimes|nullable|string|between:1,191|unique:servers', - 'owner_id' => 'required|integer|exists:users,id', - 'name' => 'required|string|min:1|max:191', - 'node_id' => 'required|exists:nodes,id', - 'description' => 'string', - 'status' => 'nullable|string', - 'memory' => 'required|numeric|min:0', - 'swap' => 'required|numeric|min:-1', - 'io' => 'required|numeric|between:10,1000', - 'cpu' => 'required|numeric|min:0', - 'threads' => 'nullable|regex:/^[0-9-,]+$/', - 'oom_disabled' => 'sometimes|boolean', - 'disk' => 'required|numeric|min:0', - 'allocation_id' => 'required|bail|unique:servers|exists:allocations,id', - 'nest_id' => 'required|exists:nests,id', - 'egg_id' => 'required|exists:eggs,id', - 'startup' => 'required|string', - 'skip_scripts' => 'sometimes|boolean', - 'image' => ['required', 'string', 'max:191', 'regex:/^~?[\w\.\/\-:@ ]*$/'], - 'database_limit' => 'present|nullable|integer|min:0', - 'allocation_limit' => 'sometimes|nullable|integer|min:0', - 'backup_limit' => 'present|nullable|integer|min:0', - ]; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'node_id' => 'integer', - 'skip_scripts' => 'boolean', - 'owner_id' => 'integer', - 'memory' => 'integer', - 'swap' => 'integer', - 'disk' => 'integer', - 'io' => 'integer', - 'cpu' => 'integer', - 'oom_disabled' => 'boolean', - 'allocation_id' => 'integer', - 'nest_id' => 'integer', - 'egg_id' => 'integer', - 'database_limit' => 'integer', - 'allocation_limit' => 'integer', - 'backup_limit' => 'integer', - self::CREATED_AT => 'datetime', - self::UPDATED_AT => 'datetime', - 'deleted_at' => 'datetime', - 'installed_at' => 'datetime', - ]; + protected function casts(): array + { + return [ + 'node_id' => 'integer', + 'skip_scripts' => 'boolean', + 'owner_id' => 'integer', + 'memory' => 'integer', + 'swap' => 'integer', + 'disk' => 'integer', + 'io' => 'integer', + 'cpu' => 'integer', + 'oom_disabled' => 'boolean', + 'allocation_id' => 'integer', + 'egg_id' => 'integer', + 'database_limit' => 'integer', + 'allocation_limit' => 'integer', + 'backup_limit' => 'integer', + self::CREATED_AT => 'datetime', + self::UPDATED_AT => 'datetime', + 'deleted_at' => 'datetime', + 'installed_at' => 'datetime', + ]; + } /** * Returns the format for server allocations when communicating with the Daemon. + * + * @return array> ports keyed by the allocation IP */ public function getAllocationMappings(): array { - return $this->allocations->where('node_id', $this->node_id)->groupBy('ip')->map(function ($item) { - return $item->pluck('port'); - })->toArray(); + $mappings = []; + foreach ($this->allocations as $allocation) { + if ($allocation->node_id === $this->node_id) { + $mappings[$allocation->ip] ??= []; + $mappings[$allocation->ip][] = $allocation->port; + } + } + + return $mappings; } public function isInstalled(): bool @@ -220,10 +213,45 @@ class Server extends Model implements Identifiable return $this->status === self::STATUS_SUSPENDED; } + /** + * Whether a reinstall would run the egg's install script. A server that skips its install + * script can still be reinstalled while its install is unfinished or has failed. + */ + public function canBeReinstalled(): bool + { + return ! $this->skip_scripts || in_array($this->status, [ + self::STATUS_INSTALLING, + self::STATUS_INSTALL_FAILED, + self::STATUS_REINSTALL_FAILED, + ], true); + } + + public function resolveRouteBinding($value, $field = null): ?\Illuminate\Database\Eloquent\Model + { + if ($field !== self::ADMIN_ROUTE_BINDING_FIELD) { + return parent::resolveRouteBinding($value, $field); + } + + if (! is_int($value) && ! is_string($value)) { + return null; + } + + // SAFETY: the type check above limits route binding values to integers and strings. + $routeValue = (string) $value; + if (ctype_digit($routeValue)) { + $server = self::query()->whereKey($routeValue)->first(); + if (($server) !== null) { + return $server; + } + } + + return self::query()->whereUuidOrShort($routeValue)->first(); + } + /** * Gets the user who owns the server. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this> + * @return BelongsTo */ public function user(): BelongsTo { @@ -233,7 +261,7 @@ class Server extends Model implements Identifiable /** * Gets the subusers associated with a server. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Subuser, $this> + * @return HasMany */ public function subusers(): HasMany { @@ -243,53 +271,67 @@ class Server extends Model implements Identifiable /** * Gets the default allocation for a server. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Allocation, $this> + * @return HasOne */ public function allocation(): HasOne { - return $this->hasOne(Allocation::class, 'id', 'allocation_id'); + return $this->hasOne(Allocation::class, 'id', 'allocation_id')->chaperone('server'); } /** * Gets all allocations associated with this server. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Allocation, $this> + * @return HasMany */ public function allocations(): HasMany { - return $this->hasMany(Allocation::class, 'server_id'); - } - - /** - * Gets information for the nest associated with this server. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Nest, $this> - */ - public function nest(): BelongsTo - { - return $this->belongsTo(Nest::class); + return $this->hasMany(Allocation::class, 'server_id')->chaperone('server'); } /** * Gets information for the egg associated with this server. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Egg, $this> + * @return HasOne */ public function egg(): HasOne { return $this->hasOne(Egg::class, 'id', 'egg_id'); } + /** + * The tag slugs that describe this server's game, taken from its egg. These are + * what feature gating matches on, replacing the nest a server used to carry. + * + * @return string[] + */ + public function tagSlugs(): array + { + $this->loadMissing('egg.tags'); + + return $this->egg === null ? [] : JsonValueGuard::stringList($this->egg->tags->pluck('slug')->all()); + } + + /** + * Whether this server's egg carries the given tag slug. + */ + public function hasTag(string $slug): bool + { + return in_array($slug, $this->tagSlugs(), true); + } + /** * Gets information for the service variables associated with this server. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\EggVariable, $this> + * @return HasMany */ public function variables(): HasMany { + // WARNING: lazy/instance use only. The join below captures $this->id, and an + // eager load (with()/load()/loadMissing()) rebuilds the relation on a blank + // model, degrading the join to "server_id is null" and nulling server_value. return $this->hasMany(EggVariable::class, 'egg_id', 'egg_id') ->select(['egg_variables.*', 'server_variables.variable_value as server_value']) - ->leftJoin('server_variables', function (JoinClause $join) { + ->leftJoin('server_variables', function (JoinClause $join): void { // Don't forget to join against the server ID as well since the way we're using this relationship // would actually return all the variables and their values for _all_ servers using that egg, // rather than only the server for this model. @@ -300,10 +342,20 @@ class Server extends Model implements Identifiable }); } + /** + * Gets the environment variable overrides stored specifically for this server. + * + * @return HasMany + */ + public function serverVariables(): HasMany + { + return $this->hasMany(ServerVariable::class); + } + /** * Gets information for the node associated with this server. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Node, $this> + * @return BelongsTo */ public function node(): BelongsTo { @@ -313,7 +365,7 @@ class Server extends Model implements Identifiable /** * Gets information for the tasks associated with this server. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Schedule, $this> + * @return HasMany */ public function schedules(): HasMany { @@ -323,29 +375,31 @@ class Server extends Model implements Identifiable /** * Gets all databases associated with a server. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Database, $this> + * @return HasMany */ public function databases(): HasMany { - return $this->hasMany(Database::class); + return $this->hasMany(Database::class)->chaperone('server'); } /** * Returns the location that a server belongs to. * - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Pterodactyl\Models\Location, \Pterodactyl\Models\Node> + * The server's location is whatever its node belongs to, so this resolves + * through the node with local keys - the same native emulation of an inverse + * through-relation used elsewhere in this codebase. * - * @throws \Exception + * @return HasOneThrough */ - public function location(): \Znck\Eloquent\Relations\BelongsToThrough + public function location(): HasOneThrough { - return $this->belongsToThrough(Location::class, Node::class); // @phpstan-ignore return.type + return $this->hasOneThrough(Location::class, Node::class, 'id', 'id', 'node_id', 'location_id'); } /** * Returns the associated server transfer. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\ServerTransfer, $this> + * @return HasOne */ public function transfer(): HasOne { @@ -353,7 +407,7 @@ class Server extends Model implements Identifiable } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Backup, $this> + * @return HasMany */ public function backups(): HasMany { @@ -363,7 +417,7 @@ class Server extends Model implements Identifiable /** * Returns all mounts that have this server has mounted. * - * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Pterodactyl\Models\Mount, \Pterodactyl\Models\MountServer, $this> + * @return HasManyThrough */ public function mounts(): HasManyThrough { @@ -373,7 +427,7 @@ class Server extends Model implements Identifiable /** * Returns all of the activity log entries where the server is the subject. * - * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\Pterodactyl\Models\ActivityLog, $this> + * @return MorphToMany */ public function activity(): MorphToMany { @@ -387,17 +441,13 @@ class Server extends Model implements Identifiable * * @throws ServerStateConflictException */ - public function validateCurrentState() + public function validateCurrentState(): void { - if ( - $this->isSuspended() - || $this->node->isUnderMaintenance() - || !$this->isInstalled() - || $this->status === self::STATUS_RESTORING_BACKUP - || !is_null($this->transfer) - ) { - throw new ServerStateConflictException($this); - } + throw_if($this->isSuspended() + || $this->node->isUnderMaintenance() + || ! $this->isInstalled() + || $this->status === self::STATUS_RESTORING_BACKUP + || ($this->transfer) !== null, ServerStateConflictException::class, $this); } /** @@ -406,14 +456,29 @@ class Server extends Model implements Identifiable * sure the server is able to be transferred and is not currently being transferred * or installed. */ - public function validateTransferState() + public function validateTransferState(): void { - if ( - !$this->isInstalled() - || $this->status === self::STATUS_RESTORING_BACKUP - || !is_null($this->transfer) - ) { - throw new ServerStateConflictException($this); - } + throw_if(! $this->isInstalled() + || $this->status === self::STATUS_RESTORING_BACKUP + || ($this->transfer) !== null, ServerStateConflictException::class, $this); + } + + /** + * @return Attribute + */ + protected function adminIdentifier(): Attribute + { + return Attribute::make(get: fn (): int => $this->id); + } + + /** + * Match a server by its full uuid or its eight-character short uuid. + * + * @param Builder $query + */ + #[Scope] + protected function whereUuidOrShort(Builder $query, string $uuid): void + { + $query->where(fn (Builder $inner) => $inner->where('uuidShort', $uuid)->orWhere('uuid', $uuid)); } } diff --git a/app/Models/ServerTransfer.php b/app/Models/ServerTransfer.php index f432d2e5e..4e07b8080 100644 --- a/app/Models/ServerTransfer.php +++ b/app/Models/ServerTransfer.php @@ -1,10 +1,15 @@ |null $old_additional_allocations + * @property list|null $new_additional_allocations * @property bool|null $successful * @property bool $archived - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at + * @property Carbon $created_at + * @property Carbon $updated_at * @property Server $server * @property Node $oldNode * @property Node $newNode */ +#[Guarded(['id', 'created_at', 'updated_at'])] class ServerTransfer extends Model { - /** @use HasFactory<\Database\Factories\ServerTransferFactory> */ + /** @use HasFactory */ use HasFactory; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'server_transfer'; + public const string RESOURCE_NAME = 'server_transfer'; /** - * The table associated with the model. + * @return array */ - protected $table = 'server_transfers'; - - /** - * Fields that are not mass assignable. - */ - protected $guarded = ['id', 'created_at', 'updated_at']; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'server_id' => 'int', - 'old_node' => 'int', - 'new_node' => 'int', - 'old_allocation' => 'int', - 'new_allocation' => 'int', - 'old_additional_allocations' => 'array', - 'new_additional_allocations' => 'array', - 'successful' => 'bool', - 'archived' => 'bool', - ]; - - public static array $validationRules = [ - 'server_id' => 'required|numeric|exists:servers,id', - 'old_node' => 'required|numeric', - 'new_node' => 'required|numeric', - 'old_allocation' => 'required|numeric', - 'new_allocation' => 'required|numeric', - 'old_additional_allocations' => 'nullable|array', - 'old_additional_allocations.*' => 'numeric', - 'new_additional_allocations' => 'nullable|array', - 'new_additional_allocations.*' => 'numeric', - 'successful' => 'sometimes|nullable|boolean', - ]; + protected function casts(): array + { + return [ + 'server_id' => 'int', + 'old_node' => 'int', + 'new_node' => 'int', + 'old_allocation' => 'int', + 'new_allocation' => 'int', + 'old_additional_allocations' => 'array', + 'new_additional_allocations' => 'array', + 'successful' => 'bool', + 'archived' => 'bool', + ]; + } /** * Gets the server associated with a server transfer. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { @@ -85,7 +71,7 @@ class ServerTransfer extends Model /** * Gets the source node associated with a server transfer. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this> + * @return HasOne */ public function oldNode(): HasOne { @@ -95,7 +81,7 @@ class ServerTransfer extends Model /** * Gets the target node associated with a server transfer. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Node, $this> + * @return HasOne */ public function newNode(): HasOne { diff --git a/app/Models/ServerVariable.php b/app/Models/ServerVariable.php index eecdd4552..2c7e45107 100644 --- a/app/Models/ServerVariable.php +++ b/app/Models/ServerVariable.php @@ -1,7 +1,11 @@ 'integer', - 'variable_id' => 'integer', - ]; - - public static array $validationRules = [ - 'server_id' => 'required|int', - 'variable_id' => 'required|int', - 'variable_value' => 'string', - ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'server_id' => 'integer', + 'variable_id' => 'integer', + ]; + } /** * Returns the server this variable is associated with. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { @@ -52,7 +51,7 @@ class ServerVariable extends Model /** * Returns information about a given variables parent. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\EggVariable, $this> + * @return BelongsTo */ public function variable(): BelongsTo { diff --git a/app/Models/Session.php b/app/Models/Session.php deleted file mode 100644 index baacdb875..000000000 --- a/app/Models/Session.php +++ /dev/null @@ -1,21 +0,0 @@ - 'string', - 'user_id' => 'integer', - ]; -} diff --git a/app/Models/Setting.php b/app/Models/Setting.php index b8812bc66..d4a385c02 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -1,7 +1,12 @@ updateOrCreate(['key' => $key], ['value' => $value ?? '']); + } - public $timestamps = false; - - protected $fillable = ['key', 'value']; - - public static array $validationRules = [ - 'key' => 'required|string|between:1,191', - 'value' => 'string', - ]; + /** + * Retrieve a persistent setting, or null when nothing is stored for the key. + */ + public static function fetch(string $key): ?string + { + return static::query()->where('key', $key)->first()?->value; + } } diff --git a/app/Models/Subuser.php b/app/Models/Subuser.php index 1d263b0dc..7e98537eb 100644 --- a/app/Models/Subuser.php +++ b/app/Models/Subuser.php @@ -1,72 +1,59 @@ $permissions + * @property Carbon $created_at + * @property Carbon $updated_at * @property User $user * @property Server $server */ +#[Guarded(['id', 'created_at', 'updated_at'])] class Subuser extends Model { - /** @use HasFactory<\Database\Factories\SubuserFactory> */ + /** @use HasFactory */ use HasFactory; + + use HasHashid; use Notifiable; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'server_subuser'; + public const string RESOURCE_NAME = 'server_subuser'; /** - * The table associated with the model. + * @return array */ - protected $table = 'subusers'; - - /** - * Fields that are not mass assignable. - */ - protected $guarded = ['id', 'created_at', 'updated_at']; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'user_id' => 'int', - 'server_id' => 'int', - 'permissions' => 'array', - ]; - - public static array $validationRules = [ - 'user_id' => 'required|numeric|exists:users,id', - 'server_id' => 'required|numeric|exists:servers,id', - 'permissions' => 'nullable|array', - 'permissions.*' => 'string', - ]; - - /** - * Return a hashid encoded string to represent the ID of the subuser. - */ - public function getHashidAttribute(): string + protected function casts(): array { - return app()->make('hashids')->encode($this->id); + return [ + 'user_id' => 'int', + 'server_id' => 'int', + 'permissions' => 'array', + ]; } /** * Gets the server associated with a subuser. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Server, $this> + * @return BelongsTo */ public function server(): BelongsTo { @@ -76,7 +63,7 @@ class Subuser extends Model /** * Gets the user associated with a subuser. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this> + * @return BelongsTo */ public function user(): BelongsTo { @@ -86,7 +73,7 @@ class Subuser extends Model /** * Gets the permissions associated with a subuser. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Permission, $this> + * @return HasMany */ public function permissions(): HasMany { diff --git a/app/Models/Tag.php b/app/Models/Tag.php new file mode 100644 index 000000000..9592af6b9 --- /dev/null +++ b/app/Models/Tag.php @@ -0,0 +1,165 @@ + */ + use HasFactory; + + /** + * The resource name for this model when it is transformed into an + * API representation using fractal. + */ + public const string RESOURCE_NAME = 'tag'; + + /** + * Fields that are searchable. + * + * @var list + */ + public static array $searchableColumns = [ + 'name', + 'slug', + ]; + + /** + * @return array + */ + protected function casts(): array + { + return [ + 'legacy_nest_id' => 'integer', + ]; + } + + /** + * @param list $identifiers + * @return Collection + */ + public static function matchingKeysOrSlugs(array $identifiers): Collection + { + $query = self::query(); + self::filterKeysOrSlugs($query, $identifiers); + + return $query->get(['id', 'slug']); + } + + /** + * The nodes carrying this tag, under either pivot kind. The deploy gate reads + * the kind-scoped Node::eggTags()/deploymentTags() instead. + * + * @return MorphToMany + */ + public function nodes(): MorphToMany + { + return $this->morphedByMany(Node::class, 'taggable', 'taggables', 'tag_id', 'taggable_id'); + } + + /** + * The eggs carrying this tag. + * + * @return MorphToMany + */ + public function eggs(): MorphToMany + { + return $this->morphedByMany(Egg::class, 'taggable', 'taggables', 'tag_id', 'taggable_id'); + } + + /** + * Whether this is a built-in "special" game tag whose presentation is owned by + * the EggSpecificTags enum, and which therefore cannot be edited. + */ + public function isPredefined(): bool + { + return EggSpecificTags::isSpecial($this->slug); + } + + /** + * The chip colour to render: the enum's brand colour for built-in tags, + * otherwise the operator-chosen colour. + */ + public function effectiveColor(): ?string + { + return $this->isPredefined() ? EggSpecificTags::from($this->slug)->color() : $this->color; + } + + /** + * The display name to render: the enum's friendly name for built-in tags, + * otherwise the operator-chosen name. + */ + public function effectiveName(): string + { + return $this->isPredefined() ? EggSpecificTags::from($this->slug)->friendlyName() : $this->name; + } + + /** + * Match a tag by either its primary key or its slug - pass a single identifier + * or a list of them. Callers can therefore mix ids and slugs freely: a slug can + * never be purely numeric ({@see TagSlug} forbids it), so the + * two identifier spaces are disjoint and the match is unambiguous. + * + * @param Builder $query + * @param string|array $identifier + */ + #[Scope] + protected function whereKeyOrSlug(Builder $query, string|array $identifier): void + { + // SAFETY: the declared union is either one string or a list of strings; array casting only wraps the scalar case. + $identifiers = array_values((array) $identifier); + + self::filterKeysOrSlugs($query, $identifiers); + } + + /** + * @param Builder $query + * @param list $identifiers + */ + private static function filterKeysOrSlugs(Builder $query, array $identifiers): void + { + $keys = array_values(array_filter($identifiers, fn (string $value): bool => preg_match('/^\d+$/', $value) === 1)); + $slugColumn = $query->getModel()->qualifyColumn('slug'); + + $query->where(function (Builder $inner) use ($identifiers, $keys, $slugColumn): void { + if ($keys !== []) { + $inner->whereKey($keys); + } + + $inner->orWhereIn($slugColumn, $identifiers); + }); + } +} diff --git a/app/Models/Task.php b/app/Models/Task.php index 50dab16eb..2a7a11f1f 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -1,12 +1,18 @@ */ + /** @use HasFactory */ use HasFactory; - use BelongsToThrough; + + use HasHashid; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'schedule_task'; + public const string RESOURCE_NAME = 'schedule_task'; /** * The default actions that can exist for a task in Pterodactyl. */ - public const ACTION_POWER = 'power'; - public const ACTION_COMMAND = 'command'; - public const ACTION_BACKUP = 'backup'; + public const string ACTION_POWER = 'power'; + + public const string ACTION_COMMAND = 'command'; + + public const string ACTION_BACKUP = 'backup'; /** - * The table associated with the model. + * The signals a power task may send. + * + * @var list */ - protected $table = 'tasks'; - - /** - * Relationships to be updated when this model is updated. - */ - protected $touches = ['schedule']; - - /** - * Fields that are mass assignable. - */ - protected $fillable = [ - 'schedule_id', - 'sequence_id', - 'action', - 'payload', - 'time_offset', - 'is_queued', - 'continue_on_failure', - ]; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'id' => 'integer', - 'schedule_id' => 'integer', - 'sequence_id' => 'integer', - 'time_offset' => 'integer', - 'is_queued' => 'boolean', - 'continue_on_failure' => 'boolean', - ]; + public const array POWER_ACTIONS = ['start', 'stop', 'restart', 'kill']; /** * Default attributes when creating a new model. @@ -86,33 +76,49 @@ class Task extends Model 'continue_on_failure' => false, ]; - public static array $validationRules = [ - 'schedule_id' => 'required|numeric|exists:schedules,id', - 'sequence_id' => 'required|numeric|min:1', - 'action' => 'required|string', - 'payload' => 'required_unless:action,backup|string', - 'time_offset' => 'required|numeric|between:0,900', - 'is_queued' => 'boolean', - 'continue_on_failure' => 'boolean', - ]; + /** + * @return array + */ + protected function casts(): array + { + return [ + 'id' => 'integer', + 'schedule_id' => 'integer', + 'sequence_id' => 'integer', + 'time_offset' => 'integer', + 'is_queued' => 'boolean', + 'continue_on_failure' => 'boolean', + ]; + } + + /** + * The permission a user needs to run a task with the given action and payload, or + * null when the action or power signal is not one a task can perform. + */ + public static function permissionForAction(string $action, ?string $payload = null): ?Permissions + { + return match ($action) { + self::ACTION_COMMAND => Permissions::ControlConsole, + self::ACTION_BACKUP => Permissions::BackupCreate, + self::ACTION_POWER => match (mb_trim((string) $payload)) { + 'start' => Permissions::ControlStart, + 'stop', 'kill' => Permissions::ControlStop, + 'restart' => Permissions::ControlRestart, + default => null, + }, + default => null, + }; + } public function getRouteKeyName(): string { return $this->getKeyName(); } - /** - * Return a hashid encoded string to represent the ID of the task. - */ - public function getHashidAttribute(): string - { - return Container::getInstance()->make(HashidsInterface::class)->encode($this->id); - } - /** * Return the schedule that a task belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\Schedule, $this> + * @return BelongsTo */ public function schedule(): BelongsTo { @@ -120,12 +126,13 @@ class Task extends Model } /** - * Return the server a task is assigned to, acts as a belongsToThrough. + * The server a task runs against is whatever its schedule belongs to, so this + * resolves through the schedule with local keys. * - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Pterodactyl\Models\Server, \Pterodactyl\Models\Schedule> + * @return HasOneThrough */ - public function server(): \Znck\Eloquent\Relations\BelongsToThrough + public function server(): HasOneThrough { - return $this->belongsToThrough(Server::class, Schedule::class); // @phpstan-ignore return.type + return $this->hasOneThrough(Server::class, Schedule::class, 'id', 'id', 'schedule_id', 'server_id'); } } diff --git a/app/Models/TaskLog.php b/app/Models/TaskLog.php deleted file mode 100644 index 81b7fdb78..000000000 --- a/app/Models/TaskLog.php +++ /dev/null @@ -1,30 +0,0 @@ - 'integer', - 'task_id' => 'integer', - 'run_status' => 'integer', - 'run_time' => 'datetime', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - ]; -} diff --git a/app/Models/Traits/HasAccessTokens.php b/app/Models/Traits/HasAccessTokens.php index 224ba942a..9ab3b5aec 100644 --- a/app/Models/Traits/HasAccessTokens.php +++ b/app/Models/Traits/HasAccessTokens.php @@ -1,34 +1,52 @@ */ + /** @use HasApiTokens */ use HasApiTokens { tokens as private _tokens; createToken as private _createToken; + currentAccessToken as private _currentAccessToken; } + /** + * The tokens issued to this model. + * + * The concrete class is whatever is registered with + * {@see Sanctum::usePersonalAccessTokenModel()} - {@see ApiKey} in this application. + * + * @return HasMany + */ public function tokens(): HasMany { return $this->hasMany(Sanctum::$personalAccessTokenModel); } + /** + * @param list|null $ips IP addresses the token may be used from + */ public function createToken(?string $memo, ?array $ips): NewAccessToken { + // SAFETY: Sanctum is configured globally to persist personal access tokens with the ApiKey model. /** @var ApiKey $token */ $token = $this->tokens()->forceCreate([ 'user_id' => $this->id, @@ -41,4 +59,10 @@ trait HasAccessTokens return new NewAccessToken($token, $plain); } + + /** @return TToken|null */ + public function currentAccessToken(): ?HasAbilities + { + return $this->_currentAccessToken(); + } } diff --git a/app/Models/Traits/HasHashid.php b/app/Models/Traits/HasHashid.php new file mode 100644 index 000000000..b3a8df8aa --- /dev/null +++ b/app/Models/Traits/HasHashid.php @@ -0,0 +1,27 @@ + + */ + protected function hashid(): Attribute + { + return Attribute::get(fn (): string => Hashids::encode($this->getKey())); + } +} diff --git a/app/Models/Traits/HasRealtimeIdentifier.php b/app/Models/Traits/HasRealtimeIdentifier.php index ea1ea3181..d99cb5647 100644 --- a/app/Models/Traits/HasRealtimeIdentifier.php +++ b/app/Models/Traits/HasRealtimeIdentifier.php @@ -1,14 +1,20 @@ whereIdentifier(string $identifier) * - * @mixin \Illuminate\Database\Eloquent\Model + * @mixin Model */ trait HasRealtimeIdentifier { @@ -28,24 +34,21 @@ trait HasRealtimeIdentifier private static string $identifierDataColumn; - protected function identifier(): Attribute + /** + * @param Builder $builder matches the Pterodactyl\Contracts\Models\Identifiable + * contract; Eloquent always hands the scope a builder for + * the model the trait is used on + */ + #[Scope] + public function whereIdentifier(Builder $builder, string $identifier): void { - return Attribute::get(function () { - $bytes = Uuid::fromString($this->getRawOriginal(static::$identifierDataColumn))->getBytes(); - - return sprintf('%s_%s', static::$identifierPrefix, Base32::encodeUnpadded($bytes)); - }); - } - - public function scopeWhereIdentifier(Builder $builder, string $identifier): void - { - if (!str_starts_with($identifier, $prefix = self::$identifierPrefix . '_')) { + if (! str_starts_with($identifier, $prefix = self::$identifierPrefix.'_')) { $builder->whereRaw('0 = 1'); return; } - $bytes = rescue(fn () => Base32::decode(Str::replaceFirst($prefix, '', $identifier)), report: false); + $bytes = rescue(fn (): string => Base32::decode(Str::replaceFirst($prefix, '', $identifier)), report: false); if (empty($bytes)) { $builder->whereRaw('0 = 1'); @@ -57,17 +60,25 @@ trait HasRealtimeIdentifier protected static function bootHasRealtimeIdentifier(): void { - $attrs = (new \ReflectionClass(static::class))->getAttributes(Identifiable::class); + $attrs = (new ReflectionClass(static::class))->getAttributes(Identifiable::class); - Assert::count( - $attrs, - 1, - 'The #[' . Identifiable::class . '] attribute must be set on ' . static::class . ' to use realtime identifiers.' - ); + throw_if(count($attrs) !== 1, InvalidArgumentException::class, 'The #['.Identifiable::class.'] attribute must be set on '.static::class.' to use realtime identifiers.'); $instance = $attrs[0]->newInstance(); self::$identifierPrefix = $instance->prefix; self::$identifierDataColumn = $instance->column; } + + /** + * @return Attribute + */ + protected function identifier(): Attribute + { + return Attribute::get(function (): string { + $bytes = Uuid::fromString(JsonValueGuard::string($this->getRawOriginal(self::$identifierDataColumn)))->getBytes(); + + return sprintf('%s_%s', self::$identifierPrefix, Base32::encodeUnpadded($bytes)); + }); + } } diff --git a/app/Models/User.php b/app/Models/User.php index 02df0ca09..4786bceed 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -1,27 +1,34 @@ |DatabaseNotification[] $notifications * @property int|null $notifications_count - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\RecoveryToken[] $recoveryTokens + * @property \Illuminate\Database\Eloquent\Collection|RecoveryToken[] $recoveryTokens * @property int|null $recovery_tokens_count - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Server[] $servers + * @property \Illuminate\Database\Eloquent\Collection|Server[] $servers * @property int|null $servers_count - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\UserSSHKey[] $sshKeys + * @property int|null $subuser_of_count + * @property \Illuminate\Database\Eloquent\Collection|UserSSHKey[] $sshKeys * @property int|null $ssh_keys_count - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\ApiKey[] $tokens + * @property \Illuminate\Database\Eloquent\Collection|ApiKey[] $tokens * @property int|null $tokens_count * - * @method static \Database\Factories\UserFactory factory(...$parameters) + * @method static UserFactory factory(...$parameters) * @method static Builder|User newModelQuery() * @method static Builder|User newQuery() * @method static Builder|User query() @@ -79,77 +87,48 @@ use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification; * @method static Builder|User whereUsername($value) * @method static Builder|User whereUuid($value) * - * @mixin \Eloquent + * @mixin Model */ #[Attributes\Identifiable('user')] -class User extends Model implements - AuthenticatableContract, - AuthorizableContract, - CanResetPasswordContract, - Identifiable +#[Fillable([ + 'external_id', + 'username', + 'email', + 'name_first', + 'name_last', + 'password', + 'language', + 'use_totp', + 'totp_secret', + 'totp_authenticated_at', + 'gravatar', + 'root_admin', +])] +#[Hidden(['password', 'remember_token', 'totp_secret', 'totp_authenticated_at'])] +#[RouteKey('uuid')] +class User extends Authenticatable implements Identifiable { - use Authenticatable; - use Authorizable; use AvailableLanguages; - use CanResetPassword; - /** @use \Pterodactyl\Models\Traits\HasAccessTokens<\Pterodactyl\Models\ApiKey> */ - use HasAccessTokens; - use Notifiable; - /** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\UserFactory> */ - use HasFactory; - use HasRealtimeIdentifier; - public const USER_LEVEL_USER = 0; - public const USER_LEVEL_ADMIN = 1; + /** @use HasAccessTokens */ + use HasAccessTokens; + + /** @use HasFactory */ + use HasFactory; + + use HasRealtimeIdentifier; + use HasVersion4Uuids; + use Notifiable; + + public const int USER_LEVEL_USER = 0; + + public const int USER_LEVEL_ADMIN = 1; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - public const RESOURCE_NAME = 'user'; - - /** - * Level of servers to display when using access() on a user. - */ - protected string $accessLevel = 'all'; - - /** - * The table associated with the model. - */ - protected $table = 'users'; - - /** - * A list of mass-assignable variables. - */ - protected $fillable = [ - 'external_id', - 'username', - 'email', - 'name_first', - 'name_last', - 'password', - 'language', - 'use_totp', - 'totp_secret', - 'totp_authenticated_at', - 'gravatar', - 'root_admin', - ]; - - /** - * Cast values to correct type. - */ - protected $casts = [ - 'root_admin' => 'boolean', - 'use_totp' => 'boolean', - 'gravatar' => 'boolean', - 'totp_authenticated_at' => 'datetime', - ]; - - /** - * The attributes excluded from the model's JSON form. - */ - protected $hidden = ['password', 'remember_token', 'totp_secret', 'totp_authenticated_at']; + public const string RESOURCE_NAME = 'user'; /** * Default values for specific fields in the database. @@ -163,52 +142,48 @@ class User extends Model implements ]; /** - * Rules verifying that the data being stored matches the expectations of the database. + * @return array */ - public static array $validationRules = [ - 'uuid' => 'required|string|size:36|unique:users,uuid', - 'email' => 'required|email|between:1,191|unique:users,email', - 'external_id' => 'sometimes|nullable|string|max:191|unique:users,external_id', - 'username' => 'required|between:1,191|unique:users,username', - 'name_first' => 'required|string|between:1,191', - 'name_last' => 'required|string|between:1,191', - 'password' => 'sometimes|nullable|string', - 'root_admin' => 'boolean', - 'language' => 'string', - 'use_totp' => 'boolean', - 'totp_secret' => 'nullable|string', - ]; - - /** - * Implement language verification by overriding Eloquence's gather - * rules function. - */ - public static function getRules(): array + protected function casts(): array { - $rules = parent::getRules(); - - $rules['language'][] = new In(array_keys((new self())->getAvailableLanguages())); - $rules['username'][] = new Username(); - - return $rules; + return [ + 'root_admin' => 'boolean', + 'use_totp' => 'boolean', + 'gravatar' => 'boolean', + 'password' => 'hashed', + 'totp_authenticated_at' => 'datetime', + ]; } /** - * Return the user model in a format that can be passed over to Vue templates. + * The column holding the automatically generated v4 UUID for the user. + * + * @return list + */ + public function uniqueIds(): array + { + return ['uuid']; + } + + /** + * @return ApiPayload */ public function toVueObject(): array { - return Collection::make($this->toArray())->except(['id', 'external_id']) + $payload = Collection::make($this->toArray())->except(['id', 'external_id']) ->merge(['identifier' => $this->identifier]) ->toArray(); + JsonValueGuard::assertPayload($payload); + + return $payload; } /** * Send the password reset notification. * - * @param string $token + * @param string $token */ - public function sendPasswordResetNotification($token) + public function sendPasswordResetNotification($token): void { Activity::event('auth:reset-password') ->withRequestMetadata() @@ -218,26 +193,10 @@ class User extends Model implements $this->notify(new ResetPasswordNotification($token)); } - /** - * Store the username as a lowercase string. - */ - public function setUsernameAttribute(string $value) - { - $this->attributes['username'] = mb_strtolower($value); - } - - /** - * Return a concatenated result for the accounts full name. - */ - public function getNameAttribute(): string - { - return trim($this->name_first . ' ' . $this->name_last); - } - /** * Returns all servers that a user owns. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Server, $this> + * @return HasMany */ public function servers(): HasMany { @@ -245,7 +204,7 @@ class User extends Model implements } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\ApiKey, $this> + * @return HasMany */ public function apiKeys(): HasMany { @@ -254,7 +213,7 @@ class User extends Model implements } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\RecoveryToken, $this> + * @return HasMany */ public function recoveryTokens(): HasMany { @@ -262,7 +221,7 @@ class User extends Model implements } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\UserSSHKey, $this> + * @return HasMany */ public function sshKeys(): HasMany { @@ -270,10 +229,10 @@ class User extends Model implements } /** - * Returns all the activity logs where this user is the subject — not to + * Returns all the activity logs where this user is the subject - not to * be confused by activity logs where this user is the _actor_. * - * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\Pterodactyl\Models\ActivityLog, $this> + * @return MorphToMany */ public function activity(): MorphToMany { @@ -284,16 +243,41 @@ class User extends Model implements * Returns all the servers that a user can access by way of being the owner of the * server, or because they are assigned as a subuser for that server. * - * @return \Illuminate\Database\Eloquent\Builder<\Pterodactyl\Models\Server> + * @return Builder */ public function accessibleServers(): Builder { return Server::query() ->select('servers.*') ->leftJoin('subusers', 'subusers.server_id', '=', 'servers.id') - ->where(function (Builder $builder) { + ->where(function (Builder $builder): void { $builder->where('servers.owner_id', $this->id)->orWhere('subusers.user_id', $this->id); }) ->groupBy('servers.id'); } + + /** + * Store the username as a lowercase string. Reads fall through to the stored + * column, so the get side is the string it was written as. + * + * @return Attribute + */ + protected function username(): Attribute + { + return Attribute::make( + set: fn (string $value): string => mb_strtolower($value), + ); + } + + /** + * Return a concatenated result for the accounts full name. + * + * @return Attribute + */ + protected function name(): Attribute + { + return Attribute::make( + get: fn (): string => mb_trim($this->name_first.' '.$this->name_last), + ); + } } diff --git a/app/Models/UserSSHKey.php b/app/Models/UserSSHKey.php index d219f0407..be21aab54 100644 --- a/app/Models/UserSSHKey.php +++ b/app/Models/UserSSHKey.php @@ -1,10 +1,17 @@ */ + /** @use HasFactory */ use HasFactory; + use SoftDeletes; - public const RESOURCE_NAME = 'ssh_key'; - - protected $table = 'user_ssh_keys'; - - protected $fillable = [ - 'name', - 'public_key', - 'fingerprint', - ]; - - public static array $validationRules = [ - 'name' => ['required', 'string'], - 'fingerprint' => ['required', 'string'], - 'public_key' => ['required', 'string'], - ]; + public const string RESOURCE_NAME = 'ssh_key'; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Pterodactyl\Models\User, $this> + * @return BelongsTo */ public function user(): BelongsTo { diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index fb1338012..2badabdd1 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -1,12 +1,15 @@ afterCommit(); } /** * Get the notification's delivery channels. + * + * @return list */ public function via(): array { @@ -32,14 +38,14 @@ class AccountCreated extends Notification implements ShouldQueue */ public function toMail(): MailMessage { - $message = (new MailMessage()) - ->greeting('Hello ' . $this->user->name . '!') - ->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.') - ->line('Username: ' . $this->user->username) - ->line('Email: ' . $this->user->email); + $message = (new MailMessage) + ->greeting('Hello '.$this->user->name.'!') + ->line('You are receiving this email because an account has been created for you on '.JsonValueGuard::string(config('app.name')).'.') + ->line('Username: '.$this->user->username) + ->line('Email: '.$this->user->email); - if (!is_null($this->token)) { - return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email))); + if (($this->token) !== null) { + return $message->action('Setup Your Account', url('/auth/password/reset/'.$this->token.'?email='.urlencode($this->user->email))); } return $message; diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index c78c7db8b..82ec447f9 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -1,28 +1,33 @@ server = (object) $server; + public function __construct( + public readonly array $server, + ) { + $this->afterCommit(); } /** * Get the notification's delivery channels. + * + * @return list */ public function via(): array { @@ -34,10 +39,10 @@ class AddedToServer extends Notification implements ShouldQueue */ public function toMail(): MailMessage { - return (new MailMessage()) - ->greeting('Hello ' . $this->server->user . '!') + return (new MailMessage) + ->greeting('Hello '.$this->server['user'].'!') ->line('You have been added as a subuser for the following server, allowing you certain control over the server.') - ->line('Server Name: ' . $this->server->name) - ->action('Visit Server', url('/server/' . $this->server->uuidShort)); + ->line('Server Name: '.$this->server['name']) + ->action('Visit Server', url('/server/'.$this->server['uuidShort'])); } } diff --git a/app/Notifications/MailTested.php b/app/Notifications/MailTested.php index 892ff7b0a..04698c734 100644 --- a/app/Notifications/MailTested.php +++ b/app/Notifications/MailTested.php @@ -1,17 +1,20 @@ + */ public function via(): array { return ['mail']; @@ -19,9 +22,9 @@ class MailTested extends Notification public function toMail(): MailMessage { - return (new MailMessage()) + return (new MailMessage) ->subject('Pterodactyl Test Message') - ->greeting('Hello ' . $this->user->name . '!') - ->line('This is a test of the Pterodactyl mail system. You\'re good to go!'); + ->greeting('Hello '.$this->user->name.'!') + ->line("This is a test of the Pterodactyl mail system. You're good to go!"); } } diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index 492dc60e6..5ca9da58b 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -1,28 +1,33 @@ server = (object) $server; + public function __construct( + public readonly array $server, + ) { + $this->afterCommit(); } /** * Get the notification's delivery channels. + * + * @return list */ public function via(): array { @@ -34,11 +39,11 @@ class RemovedFromServer extends Notification implements ShouldQueue */ public function toMail(): MailMessage { - return (new MailMessage()) + return (new MailMessage) ->error() - ->greeting('Hello ' . $this->server->user . '.') + ->greeting('Hello '.$this->server['user'].'.') ->line('You have been removed as a subuser for the following server.') - ->line('Server Name: ' . $this->server->name) + ->line('Server Name: '.$this->server['name']) ->action('Visit Panel', route('index')); } } diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index b424c8293..0ad12e17e 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -1,11 +1,14 @@ */ public function via(): array { @@ -29,12 +32,13 @@ class SendPasswordReset extends Notification implements ShouldQueue /** * Get the mail representation of the notification. */ + /** @param User $notifiable */ public function toMail(mixed $notifiable): MailMessage { - return (new MailMessage()) + return (new MailMessage) ->subject('Reset Password') ->line('You are receiving this email because we received a password reset request for your account.') - ->action('Reset Password', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email))) + ->action('Reset Password', url('/auth/password/reset/'.$this->token.'?email='.urlencode($notifiable->email))) ->line('If you did not request a password reset, no further action is required.'); } } diff --git a/app/Notifications/ServerInstalled.php b/app/Notifications/ServerInstalled.php index 037633786..c88fc5271 100644 --- a/app/Notifications/ServerInstalled.php +++ b/app/Notifications/ServerInstalled.php @@ -1,20 +1,20 @@ server = $event->server; $this->user = $event->server->user; - // Since we are calling this notification directly from an event listener we need to fire off the dispatcher - // to send the email now. Don't use send() or you'll end up firing off two different events. - Container::getInstance()->make(Dispatcher::class)->sendNow($this->user, $this); + $this->user->notifyNow($this); } /** * Get the notification's delivery channels. + * + * @return list */ public function via(): array { @@ -53,10 +53,10 @@ class ServerInstalled extends Notification implements ShouldQueue, ReceivesEvent */ public function toMail(): MailMessage { - return (new MailMessage()) - ->greeting('Hello ' . $this->user->username . '.') + return (new MailMessage) + ->greeting('Hello '.$this->user->username.'.') ->line('Your server has finished installing and is now ready for you to use.') - ->line('Server Name: ' . $this->server->name) + ->line('Server Name: '.$this->server->name) ->action('Login and Begin Using', route('index')); } } diff --git a/app/Observers/EggVariableObserver.php b/app/Observers/EggVariableObserver.php deleted file mode 100644 index 3ae3a8917..000000000 --- a/app/Observers/EggVariableObserver.php +++ /dev/null @@ -1,24 +0,0 @@ -field_type) { - unset($variable->field_type); - } - } - - public function updating(EggVariable $variable): void - { - // @phpstan-ignore-next-line property.notFound - if ($variable->field_type) { - unset($variable->field_type); - } - } -} diff --git a/app/Observers/ServerObserver.php b/app/Observers/ServerObserver.php index 51276523e..877f1c006 100644 --- a/app/Observers/ServerObserver.php +++ b/app/Observers/ServerObserver.php @@ -1,10 +1,19 @@ user->notify(new AddedToServer([ - 'user' => $subuser->user->name_first, + 'user' => $subuser->user->name_first ?? $subuser->user->username, 'name' => $subuser->server->name, 'uuidShort' => $subuser->server->uuidShort, ])); @@ -36,7 +41,7 @@ class SubuserObserver */ public function deleting(Subuser $subuser): void { - event(new Events\Subuser\Deleting($subuser)); + event(new Deleting($subuser)); } /** @@ -44,10 +49,10 @@ class SubuserObserver */ public function deleted(Subuser $subuser): void { - event(new Events\Subuser\Deleted($subuser)); + event(new Deleted($subuser)); $subuser->user->notify(new RemovedFromServer([ - 'user' => $subuser->user->name_first, + 'user' => $subuser->user->name_first ?? $subuser->user->username, 'name' => $subuser->server->name, ])); } diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index dd017a22d..ae545acc9 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -1,8 +1,13 @@ $arguments */ + public function __call(string $name, array $arguments): void { - $subuser = $server->subusers->where('user_id', $user->id)->first(); - if (!$subuser || empty($permission)) { - return false; - } - - return in_array($permission, $subuser->permissions); + // do nothing } /** @@ -33,12 +33,15 @@ class ServerPolicy } /** - * This is a horrendous hack to avoid Laravel's "smart" behavior that does - * not call the before() function if there isn't a function matching the - * policy permission. + * Checks if the user has the given permission on/for the server. */ - public function __call(string $name, mixed $arguments) + protected function checkPermission(User $user, Server $server, string $permission): bool { - // do nothing + $subuser = $server->loadMissing('subusers')->subusers->where('user_id', $user->id)->first(); + if (! $subuser || empty($permission)) { + return false; + } + + return in_array($permission, $subuser->permissions); } } diff --git a/app/Providers/ActionServiceProvider.php b/app/Providers/ActionServiceProvider.php new file mode 100644 index 000000000..8e7a5be7b --- /dev/null +++ b/app/Providers/ActionServiceProvider.php @@ -0,0 +1,325 @@ +app->bind(CreatesAccountApiKeys::class, CreateAccountApiKey::class); + $this->app->bind(ReordersEggVariables::class, ReorderEggVariables::class); + $this->app->bind(SyncsTags::class, SyncTags::class); + $this->app->bind(RebuildsServers::class, RebuildServer::class); + $this->app->bind(SendsServerCommands::class, SendServerCommand::class); + $this->app->bind(SendsServerPower::class, SendServerPower::class); + $this->app->bind(WritesFileContents::class, WriteFileContents::class); + $this->app->bind(CreatesDirectories::class, CreateDirectory::class); + $this->app->bind(RenamesFiles::class, RenameFiles::class); + $this->app->bind(CopiesFiles::class, CopyFile::class); + $this->app->bind(CompressesFiles::class, CompressFiles::class); + $this->app->bind(DecompressesFiles::class, DecompressFile::class); + $this->app->bind(DeletesFiles::class, DeleteFiles::class); + $this->app->bind(ChangesFilePermissions::class, ChangeFilePermissions::class); + $this->app->bind(PullsFiles::class, PullFile::class); + $this->app->bind(ReadsFileContents::class, ReadFileContents::class); + $this->app->bind(ListsDirectories::class, ListDirectory::class); + + $this->app->bind(UpdatesExtensionSettings::class, UpdateExtensionSettings::class); + $this->app->bind(ReplacesExtensionSettingFiles::class, ReplaceExtensionSettingFile::class); + $this->app->bind(InstallsExtensions::class, InstallExtension::class); + $this->app->bind(RemovesExtensions::class, RemoveExtension::class); + $this->app->bind(SetsExtensionEnabled::class, SetExtensionEnabled::class); + $this->app->bind(AppliesThemes::class, ApplyTheme::class); + $this->app->bind(ResetsThemes::class, ResetTheme::class); + $this->app->bind(ImportsCatalogEggs::class, ImportCatalogEgg::class); + $this->app->bind(UpdatesEggsFromImports::class, UpdateEggFromImport::class); + $this->app->bind(CreatesServers::class, CreateServer::class); + $this->app->bind(DeletesServers::class, DeleteServer::class); + $this->app->bind(CreatesAllocations::class, CreateAllocations::class); + $this->app->bind(ReinstallsServers::class, ReinstallServer::class); + $this->app->bind(ImportsEggs::class, ImportEgg::class); + $this->app->bind(InitiatesBackups::class, InitiateBackup::class); + $this->app->bind(UpdatesServerBuild::class, UpdateServerBuild::class); + $this->app->bind(UpdatesServerDetails::class, UpdateServerDetails::class); + $this->app->bind(UpdatesServerStartup::class, UpdateServerStartup::class); + $this->app->bind(CompletesBackups::class, CompleteBackup::class); + $this->app->bind(DeletesBackups::class, DeleteBackup::class); + $this->app->bind(IngestsActivityLogs::class, IngestActivityLogs::class); + $this->app->bind(AttachesMountsToServers::class, AttachMountToServer::class); + $this->app->bind(DetachesMountsFromServers::class, DetachMountFromServer::class); + $this->app->bind(RecordsServerInstallResults::class, RecordServerInstallResult::class); + $this->app->bind(RestoresBackups::class, RestoreBackup::class); + $this->app->bind(AssignsAvailableAllocations::class, AssignAvailableAllocation::class); + $this->app->bind(RestoresBackupStatuses::class, RestoreBackupStatus::class); + $this->app->bind(TogglesBackupLocks::class, ToggleBackupLock::class); + $this->app->bind(PresignsBackupUploads::class, PresignBackupUpload::class); + $this->app->bind(GeneratesBackupDownloadLinks::class, GenerateBackupDownloadLink::class); + $this->app->bind(TogglesServerSuspension::class, ToggleServerSuspension::class); + $this->app->bind(DeploysServerDatabases::class, DeployServerDatabase::class); + $this->app->bind(RotatesDatabasePasswords::class, RotateDatabasePassword::class); + $this->app->bind(DeletesDatabases::class, DeleteDatabase::class); + $this->app->bind(CreatesDatabases::class, CreateDatabase::class); + $this->app->bind(CreatesDatabaseHosts::class, CreateDatabaseHost::class); + $this->app->bind(UpdatesDatabaseHosts::class, UpdateDatabaseHost::class); + $this->app->bind(DeletesDatabaseHosts::class, DeleteDatabaseHost::class); + $this->app->bind(CreatesApiKeys::class, CreateApiKey::class); + $this->app->bind(SendsTelemetry::class, SendTelemetry::class); + $this->app->bind(AssignsAllocations::class, AssignAllocation::class); + $this->app->bind(CompletesTransfers::class, CompleteTransfer::class); + $this->app->bind(CreatesEggVariables::class, CreateEggVariable::class); + $this->app->bind(CreatesEggs::class, CreateEgg::class); + $this->app->bind(CreatesLocations::class, CreateLocation::class); + $this->app->bind(CreatesNodes::class, CreateNode::class); + $this->app->bind(CreatesScheduleTasks::class, CreateScheduleTask::class); + $this->app->bind(CreatesSchedules::class, CreateSchedule::class); + $this->app->bind(CreatesSubusers::class, CreateSubuser::class); + $this->app->bind(CreatesUsers::class, CreateUser::class); + $this->app->bind(DeletesAllocations::class, DeleteAllocation::class); + $this->app->bind(DeletesEggs::class, DeleteEgg::class); + $this->app->bind(DeletesLocations::class, DeleteLocation::class); + $this->app->bind(DeletesNodes::class, DeleteNode::class); + $this->app->bind(DeletesScheduleTasks::class, DeleteScheduleTask::class); + $this->app->bind(DeletesSchedules::class, DeleteSchedule::class); + $this->app->bind(DeletesSubusers::class, DeleteSubuser::class); + $this->app->bind(DeletesUsers::class, DeleteUser::class); + $this->app->bind(DisablesTwoFactor::class, DisableTwoFactor::class); + $this->app->bind(ExportsEggs::class, ExportEgg::class); + $this->app->bind(FailsTransfers::class, FailTransfer::class); + $this->app->bind(InitiatesTransfers::class, InitiateTransfer::class); + $this->app->bind(SetsPrimaryAllocations::class, SetPrimaryAllocation::class); + $this->app->bind(UnassignsAllocations::class, UnassignAllocation::class); + $this->app->bind(UpdatesAllocationNotes::class, UpdateAllocationNotes::class); + $this->app->bind(UpdatesAllocations::class, UpdateAllocation::class); + $this->app->bind(UpdatesEggInstallScripts::class, UpdateInstallScript::class); + $this->app->bind(UpdatesEggVariables::class, UpdateEggVariable::class); + $this->app->bind(UpdatesEggs::class, UpdateEgg::class); + $this->app->bind(UpdatesLocations::class, UpdateLocation::class); + $this->app->bind(UpdatesNodes::class, UpdateNode::class); + $this->app->bind(ResetsServerStates::class, ResetServerStates::class); + $this->app->bind(UpdatesScheduleTasks::class, UpdateScheduleTask::class); + $this->app->bind(UpdatesSchedules::class, UpdateSchedule::class); + $this->app->bind(UpdatesSubusers::class, UpdateSubuser::class); + $this->app->bind(UpdatesUserEmails::class, UpdateUserEmail::class); + $this->app->bind(UpdatesUserPasswords::class, UpdateUserPassword::class); + $this->app->bind(UpdatesUsers::class, UpdateUser::class); + $this->app->bind(ProcessesSchedules::class, ProcessSchedule::class); + $this->app->bind(SetsUpTwoFactor::class, SetupTwoFactor::class); + $this->app->bind(TogglesTwoFactor::class, ToggleTwoFactor::class); + $this->app->bind(ReadsServerLogs::class, ReadServerLogs::class); + $this->app->bind(ReadsServerState::class, ReadServerState::class); + $this->app->bind(ChangesServerEgg::class, ChangeServerEgg::class); + $this->app->bind(CompletesLogins::class, CompleteLogin::class); + } +} diff --git a/app/Providers/ActivityLogServiceProvider.php b/app/Providers/ActivityLogServiceProvider.php index 7a3de759c..ea0c657b3 100644 --- a/app/Providers/ActivityLogServiceProvider.php +++ b/app/Providers/ActivityLogServiceProvider.php @@ -1,5 +1,7 @@ app->scoped(ActivityLogBatchService::class); $this->app->scoped(ActivityLogTargetableService::class); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 63c12014b..1bea01be6 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -1,17 +1,46 @@ versionData()['version'] ?? 'undefined'); - View::share('appIsGit', $this->versionData()['is_git'] ?? false); + Route::model('database', Database::class); + + $this->configureRateLimiting(); + + // Surface lazy loads, discarded fills, and missing-attribute reads as + // exceptions everywhere except production, where a missed spot should log a + // query rather than take the panel down. + Model::shouldBeStrict(! $this->app->isProduction()); + + // Refuse migrate:fresh and friends against the production database. + DB::prohibitDestructiveCommands($this->app->isProduction()); + + // All framework-created dates (model casts included) are immutable; in-place + // mutation of a shared timestamp is never something we want. + Date::use(CarbonImmutable::class); + + View::share('appVersion', $this->versionData()['version']); + View::share('appIsGit', $this->versionData()['is_git']); Paginator::useBootstrap(); @@ -32,22 +77,28 @@ class AppServiceProvider extends ServiceProvider // doesn't, and it triggers a lot of support requests, so lets just head it off here. // // @see https://github.com/pterodactyl/panel/issues/3623 - if (Str::startsWith(config('app.url') ?? '', 'https://')) { + if (Str::startsWith(JsonValueGuard::nullableString(config('app.url')) ?? '', 'https://')) { URL::forceScheme('https'); } Relation::enforceMorphMap([ - 'allocation' => Models\Allocation::class, - 'api_key' => Models\ApiKey::class, - 'backup' => Models\Backup::class, - 'database' => Models\Database::class, - 'egg' => Models\Egg::class, - 'egg_variable' => Models\EggVariable::class, - 'schedule' => Models\Schedule::class, - 'server' => Models\Server::class, - 'ssh_key' => Models\UserSSHKey::class, - 'task' => Models\Task::class, - 'user' => Models\User::class, + 'allocation' => Allocation::class, + 'api_key' => ApiKey::class, + 'backup' => Backup::class, + 'database' => Database::class, + 'database_host' => DatabaseHost::class, + 'egg' => Egg::class, + 'egg_variable' => EggVariable::class, + 'location' => Location::class, + 'mount' => Mount::class, + 'node' => Node::class, + 'schedule' => Schedule::class, + 'server' => Server::class, + 'server_database' => Database::class, + 'ssh_key' => UserSSHKey::class, + 'tag' => Tag::class, + 'task' => Task::class, + 'user' => User::class, ]); } @@ -56,42 +107,94 @@ class AppServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->singleton(DaemonManager::class); + + $this->app->bind(function (): Fractal { + $requested = JsonValueGuard::stringList(array_values($this->app->make(Request::class)->collect('include')->all())); + + $includes = collect($requested) + ->flatMap(fn (string $value): array => explode(',', $value)) + ->map(fn (string $value): string => mb_trim($value)) + ->filter() + ->values() + ->all(); + + return (new Fractal(new Manager))->parseIncludes($includes)->limitRecursion(2); + }); + // Only load the settings service provider if the environment // is configured to allow it. - if (!config('pterodactyl.load_environment_only', false) && $this->app->environment() !== 'testing') { + if (! config('pterodactyl.load_environment_only', false) && ! $this->app->environment('testing')) { $this->app->register(SettingsServiceProvider::class); } - - $this->app->singleton('extensions.themes', function () { - return new Theme(); - }); } /** * Return version information for the footer. + * + * @return array{version: string, is_git: bool} */ protected function versionData(): array { - return Cache::remember('git-version', 5, function () { + return Cache::remember('git-version', 5, function (): array { if (file_exists(base_path('.git/HEAD'))) { - $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); + $headContents = file_get_contents(base_path('.git/HEAD')); - if (array_key_exists(1, $head)) { - $path = base_path('.git/' . trim($head[1])); + if ($headContents !== false) { + $head = explode(' ', $headContents); + + if (array_key_exists(1, $head)) { + $path = base_path('.git/'.mb_trim($head[1])); + } } } if (isset($path) && file_exists($path)) { - return [ - 'version' => substr(file_get_contents($path), 0, 8), - 'is_git' => true, - ]; + $refContents = file_get_contents($path); + + if ($refContents !== false) { + return [ + 'version' => mb_substr($refContents, 0, 8), + 'is_git' => true, + ]; + } } return [ - 'version' => config('app.version'), + 'version' => config()->string('app.version'), 'is_git' => false, ]; }); } + + /** + * Rate limiters for authentication and the three APIs. + */ + private function configureRateLimiting(): void + { + RateLimiter::for('authentication', function (Request $request): Limit { + if ($request->route()?->named('auth.post.forgot-password')) { + return Limit::perMinute(2)->by($request->ip()); + } + + return Limit::perMinute(10)->by($request->ip()); + }); + + RateLimiter::for('api.client', fn (Request $request): Limit => $this->apiLimit($request, 'client')); + RateLimiter::for('api.application', fn (Request $request): Limit => $this->apiLimit($request, 'application')); + RateLimiter::for('api.admin', fn (Request $request): Limit => $this->apiLimit($request, 'admin')); + + ResourceLimit::boot(); + } + + private function apiLimit(Request $request, string $name): Limit + { + $user = $request->user(); + $key = $user instanceof User ? $user->uuid : $request->ip(); + + return Limit::perMinutes( + JsonValueGuard::integer(config("http.rate_limit.{$name}_period")), + JsonValueGuard::integer(config("http.rate_limit.{$name}")), + )->by($key); + } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 28222f006..f5625bbf7 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -1,12 +1,16 @@ $user->root_admin ? true : null); } } diff --git a/app/Providers/BackupsServiceProvider.php b/app/Providers/BackupsServiceProvider.php index 25ce9bd7a..9dd9753dd 100644 --- a/app/Providers/BackupsServiceProvider.php +++ b/app/Providers/BackupsServiceProvider.php @@ -1,10 +1,13 @@ app->singleton(BackupManager::class, function ($app) { - return new BackupManager($app); - }); + $this->app->singleton(BackupManager::class, fn (Application $app): BackupManager => new BackupManager($app)); } + /** + * @return list + */ public function provides(): array { return [BackupManager::class]; diff --git a/app/Providers/BladeServiceProvider.php b/app/Providers/BladeServiceProvider.php index 3512acfd9..10de3c38f 100644 --- a/app/Providers/BladeServiceProvider.php +++ b/app/Providers/BladeServiceProvider.php @@ -1,8 +1,11 @@ app->make('blade.compiler') - ->directive('datetimeHuman', function ($expression) { - return "setTimezone(config('app.timezone'))->toDateTimeString(); ?>"; - }); + $this->app->make(BladeCompiler::class) + ->directive('datetimeHuman', fn (string $expression): string => "setTimezone(config('app.timezone'))->toDateTimeString(); ?>"); } } diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 0630a6377..d1d3b10a7 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -1,9 +1,12 @@ id === (int) $userId; + Broadcast::channel('App.User.*', function (User $user, string $userId): bool { + $id = filter_var($userId, FILTER_VALIDATE_INT); + + return $id !== false && $user->id === $id; }); } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index e5d7be3b3..13a377fc7 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -1,21 +1,21 @@ [ServerInstalledNotification::class], ]; + /** + * The event subscribers to register. + * + * @var list + */ protected $subscribe = [ AuthenticationListener::class, RevocationListener::class, @@ -44,6 +49,5 @@ class EventServiceProvider extends ServiceProvider User::observe(UserObserver::class); Server::observe(ServerObserver::class); Subuser::observe(SubuserObserver::class); - EggVariable::observe(EggVariableObserver::class); } } diff --git a/app/Providers/ExtensionServiceProvider.php b/app/Providers/ExtensionServiceProvider.php new file mode 100644 index 000000000..92de2ed18 --- /dev/null +++ b/app/Providers/ExtensionServiceProvider.php @@ -0,0 +1,89 @@ +app->singleton(ExtensionManifestValidator::class); + $this->app->singleton(ExtensionAssetPublisher::class); + $this->app->singleton(ExtensionSettingsRegistry::class); + $this->app->singleton(ExtensionPermissionRegistry::class); + $this->app->singleton(ExtensionRepository::class); + $this->app->singleton(ExtensionLock::class); + $this->app->singleton(ExtensionProviderLoader::class); + $this->app->singleton(ExtensionManager::class); + $this->app->singleton(ExtensionActionDecorators::class); + $this->app->singleton(ExtensionConsoleRegistry::class); + $this->app->singleton(ExtensionHeadTags::class); + $this->app->singleton(ExtensionFailureAttributor::class); + + if (! config('extensions.enabled')) { + return; + } + + // Registered during the provider registration phase, then executed after + // the core app has booted. Application::register() immediately runs + // Laravel's normal provider boot path inside the loader's failure boundary. + $this->app->booted(fn () => $this->app->make(ExtensionManager::class)->registerProviders()); + } + + public function boot(): void + { + // Root path routes of extensions are public, so they are throttled per client. + RateLimiter::for('extensions.root', function (Request $request): Limit { + $user = $request->user(); + + return Limit::perMinute(JsonValueGuard::integer(config('extensions.root_routes_per_minute'))) + ->by($user instanceof User ? $user->uuid : $request->ip()); + }); + + if (! config('extensions.enabled')) { + return; + } + + // The console application starts after every extension provider has been + // committed, so the registry only ever hands over what booted successfully. The + // scheduler is wired the way core's own schedule is (bootstrap/app.php). + Artisan::starting(static function (Artisan $artisan): void { + $app = $artisan->getLaravel(); + $registry = $app->make(ExtensionConsoleRegistry::class); + $registry->resolveCommands($artisan); + + $app->afterResolving(Schedule::class, static fn (Schedule $schedule) => $registry->schedule($schedule)); + if ($app->resolved(Schedule::class)) { + $registry->schedule($app->make(Schedule::class)); + } + }); + + Exceptions::reportable(function (Throwable $throwable): void { + $this->app->make(ExtensionFailureAttributor::class)->attribute($throwable); + }); + } +} diff --git a/app/Providers/HashidsServiceProvider.php b/app/Providers/HashidsServiceProvider.php index e2493e8e4..3fc903354 100644 --- a/app/Providers/HashidsServiceProvider.php +++ b/app/Providers/HashidsServiceProvider.php @@ -1,10 +1,14 @@ app->singleton(HashidsInterface::class, function () { - /** @var \Illuminate\Contracts\Config\Repository $config */ - $config = $this->app['config']; + $this->app->singleton(function (): HashidsInterface { + $config = $this->app->make(Repository::class); + $length = filter_var($config->get('hashids.length', 0), FILTER_VALIDATE_INT); return new Hashids( - $config->get('hashids.salt', ''), - $config->get('hashids.length', 0), - $config->get('hashids.alphabet', 'abcdefghijkmlnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890') + JsonValueGuard::string($config->get('hashids.salt', '')), + $length === false ? 0 : $length, + JsonValueGuard::string($config->get('hashids.alphabet', 'abcdefghijkmlnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')) ); }); diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php deleted file mode 100644 index b06ca7a13..000000000 --- a/app/Providers/RepositoryServiceProvider.php +++ /dev/null @@ -1,67 +0,0 @@ -app->bind(AllocationRepositoryInterface::class, AllocationRepository::class); - $this->app->bind(ApiKeyRepositoryInterface::class, ApiKeyRepository::class); - $this->app->bind(DatabaseRepositoryInterface::class, DatabaseRepository::class); - $this->app->bind(DatabaseHostRepositoryInterface::class, DatabaseHostRepository::class); - $this->app->bind(EggRepositoryInterface::class, EggRepository::class); - $this->app->bind(EggVariableRepositoryInterface::class, EggVariableRepository::class); - $this->app->bind(LocationRepositoryInterface::class, LocationRepository::class); - $this->app->bind(NestRepositoryInterface::class, NestRepository::class); - $this->app->bind(NodeRepositoryInterface::class, NodeRepository::class); - $this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class); - $this->app->bind(ServerRepositoryInterface::class, ServerRepository::class); - $this->app->bind(ServerVariableRepositoryInterface::class, ServerVariableRepository::class); - $this->app->bind(SessionRepositoryInterface::class, SessionRepository::class); - $this->app->bind(SettingsRepositoryInterface::class, SettingsRepository::class); - $this->app->bind(SubuserRepositoryInterface::class, SubuserRepository::class); - $this->app->bind(TaskRepositoryInterface::class, TaskRepository::class); - $this->app->bind(UserRepositoryInterface::class, UserRepository::class); - } -} diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php deleted file mode 100644 index 9bf79fabe..000000000 --- a/app/Providers/RouteServiceProvider.php +++ /dev/null @@ -1,113 +0,0 @@ -configureRateLimiting(); - - // Disable trimming string values when requesting file information — it isn't helpful - // and messes up the ability to actually open a directory that ends with a space. - TrimStrings::skipWhen(function (Request $request) { - return preg_match(self::FILE_PATH_REGEX, $request->getPathInfo()) === 1; - }); - - // This is needed to make use of the "resolveRouteBinding" functionality in the - // model. Without it you'll never trigger that logic flow thus resulting in a 404 - // error because we request databases with a HashID, and not with a normal ID. - Route::model('database', Database::class); - - $this->routes(function () { - Route::middleware('web')->group(function () { - Route::middleware(['auth.session', RequireTwoFactorAuthentication::class]) - ->group(base_path('routes/base.php')); - - Route::middleware(['auth.session', RequireTwoFactorAuthentication::class, AdminAuthenticate::class]) - ->prefix('/admin') - ->group(base_path('routes/admin.php')); - - Route::middleware('guest')->prefix('/auth')->group(base_path('routes/auth.php')); - }); - - Route::middleware(['api', RequireTwoFactorAuthentication::class])->group(function () { - Route::middleware(['application-api', 'throttle:api.application']) - ->prefix('/api/application') - ->scopeBindings() - ->group(base_path('routes/api-application.php')); - - Route::middleware(['client-api', 'throttle:api.client']) - ->prefix('/api/client') - ->scopeBindings() - ->group(base_path('routes/api-client.php')); - }); - - Route::middleware('daemon') - ->prefix('/api/remote') - ->scopeBindings() - ->group(base_path('routes/api-remote.php')); - }); - } - - /** - * Configure the rate limiters for the application. - */ - protected function configureRateLimiting(): void - { - // Authentication rate limiting. For login and checkpoint endpoints we'll apply - // a limit of 10 requests per minute, for the forgot password endpoint apply a - // limit of two per minute for the requester so that there is less ability to - // trigger email spam. - RateLimiter::for('authentication', function (Request $request) { - if ($request->route()->named('auth.post.forgot-password')) { - return Limit::perMinute(2)->by($request->ip()); - } - - return Limit::perMinute(10)->by($request->ip()); - }); - - // Configure the throttles for both the application and client APIs below. - // This is configurable per-instance in "config/http.php". By default this - // limiter will be tied to the specific request user, and falls back to the - // request IP if there is no request user present for the key. - // - // This means that an authenticated API user cannot use IP switching to get - // around the limits. - RateLimiter::for('api.client', function (Request $request) { - $key = optional($request->user())->uuid ?: $request->ip(); - - return Limit::perMinutes( - config('http.rate_limit.client_period'), - config('http.rate_limit.client') - )->by($key); - }); - - RateLimiter::for('api.application', function (Request $request) { - $key = optional($request->user())->uuid ?: $request->ip(); - - return Limit::perMinutes( - config('http.rate_limit.application_period'), - config('http.rate_limit.application') - )->by($key); - }); - - ResourceLimit::boot(); - } -} diff --git a/app/Providers/SettingsServiceProvider.php b/app/Providers/SettingsServiceProvider.php index dbcca85ea..5e66291d7 100644 --- a/app/Providers/SettingsServiceProvider.php +++ b/app/Providers/SettingsServiceProvider.php @@ -1,20 +1,25 @@ */ protected array $keys = [ 'app:name', @@ -35,6 +40,8 @@ class SettingsServiceProvider extends ServiceProvider /** * Keys specific to the mail driver that are only grabbed from the database * when using the SMTP driver. + * + * @var list */ protected array $emailKeys = [ 'mail:mailers:smtp:host', @@ -49,15 +56,25 @@ class SettingsServiceProvider extends ServiceProvider /** * Keys that are encrypted and should be decrypted when set in the * configuration array. + * + * @var list */ protected static array $encrypted = [ 'mail:mailers:smtp:password', ]; + /** + * @return list + */ + public static function getEncryptedKeys(): array + { + return self::$encrypted; + } + /** * Boot the service provider. */ - public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings): void + public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log): void { // Only set the email driver settings from the database if we // are configured using SMTP as the driver. @@ -66,25 +83,23 @@ class SettingsServiceProvider extends ServiceProvider } try { - $values = $settings->all()->mapWithKeys(function ($setting) { - return [$setting->key => $setting->value]; - })->toArray(); - } catch (QueryException $exception) { - $log->notice('A query exception was encountered while trying to load settings from the database: ' . $exception->getMessage()); + $values = Setting::query()->pluck('value', 'key')->all(); + } catch (QueryException $queryException) { + $log->notice('A query exception was encountered while trying to load settings from the database: '.$queryException->getMessage()); return; } foreach ($this->keys as $key) { - $value = array_get($values, 'settings::' . $key, $config->get(str_replace(':', '.', $key))); - if (in_array($key, self::$encrypted)) { + $value = Arr::get($values, 'settings::'.$key, $config->get(str_replace(':', '.', $key))); + if (in_array($key, self::$encrypted, true) && is_string($value)) { try { $value = $encrypter->decrypt($value); - } catch (DecryptException $exception) { + } catch (DecryptException) { } } - switch (strtolower($value)) { + switch (is_string($value) ? mb_strtolower($value) : $value) { case 'true': case '(true)': $value = true; @@ -105,9 +120,4 @@ class SettingsServiceProvider extends ServiceProvider $config->set(str_replace(':', '.', $key), $value); } } - - public static function getEncryptedKeys(): array - { - return self::$encrypted; - } } diff --git a/app/Providers/ViewComposerServiceProvider.php b/app/Providers/ViewComposerServiceProvider.php index 8ab7208c7..3bc18aa0b 100644 --- a/app/Providers/ViewComposerServiceProvider.php +++ b/app/Providers/ViewComposerServiceProvider.php @@ -1,7 +1,10 @@ app->make('view')->composer('*', AssetComposer::class); + $this->app->make(Factory::class)->composer('*', AssetComposer::class); } } diff --git a/app/Repositories/Eloquent/AllocationRepository.php b/app/Repositories/Eloquent/AllocationRepository.php deleted file mode 100644 index 6eb8b6d1e..000000000 --- a/app/Repositories/Eloquent/AllocationRepository.php +++ /dev/null @@ -1,100 +0,0 @@ -select('id') - ->whereNull('server_id') - ->where('node_id', $node) - ->get() - ->pluck('id') - ->toArray(); - } - - /** - * Return a concatenated result set of node ips that already have at least one - * server assigned to that IP. This allows for filtering out sets for - * dedicated allocation IPs. - * - * If an array of nodes is passed the results will be limited to allocations - * in those nodes. - */ - protected function getDiscardableDedicatedAllocations(array $nodes = []): array - { - $query = Allocation::query()->selectRaw('CONCAT_WS("-", node_id, ip) as result'); - - if (!empty($nodes)) { - $query->whereIn('node_id', $nodes); - } - - return $query->whereNotNull('server_id') - ->groupByRaw('CONCAT(node_id, ip)') - ->get() - ->pluck('result') - ->toArray(); - } - - /** - * Return a single allocation from those meeting the requirements. - */ - public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false): ?Allocation - { - $query = Allocation::query()->whereNull('server_id'); - - if (!empty($nodes)) { - $query->whereIn('node_id', $nodes); - } - - if (!empty($ports)) { - $query->where(function (Builder $inner) use ($ports) { - $whereIn = []; - foreach ($ports as $port) { - if (is_array($port)) { - $inner->orWhereBetween('port', $port); - continue; - } - - $whereIn[] = $port; - } - - if (!empty($whereIn)) { - $inner->orWhereIn('port', $whereIn); - } - }); - } - - // If this allocation should not be shared with any other servers get - // the data and modify the query as necessary, - if ($dedicated) { - $discard = $this->getDiscardableDedicatedAllocations($nodes); - - if (!empty($discard)) { - $query->whereNotIn( - $this->getBuilder()->raw('CONCAT_WS("-", node_id, ip)'), - $discard - ); - } - } - - return $query->inRandomOrder()->first(); - } -} diff --git a/app/Repositories/Eloquent/ApiKeyRepository.php b/app/Repositories/Eloquent/ApiKeyRepository.php deleted file mode 100644 index 5a63514fe..000000000 --- a/app/Repositories/Eloquent/ApiKeyRepository.php +++ /dev/null @@ -1,40 +0,0 @@ -getBuilder()->where('user_id', $user->id) - ->where('key_type', ApiKey::TYPE_ACCOUNT) - ->get($this->getColumns()); - } - - /** - * Delete an account API key from the panel for a specific user. - */ - public function deleteAccountKey(User $user, string $identifier): int - { - return $this->getBuilder()->where('user_id', $user->id) - ->where('key_type', ApiKey::TYPE_ACCOUNT) - ->where('identifier', $identifier) - ->delete(); - } -} diff --git a/app/Repositories/Eloquent/BackupRepository.php b/app/Repositories/Eloquent/BackupRepository.php deleted file mode 100644 index fa79f7098..000000000 --- a/app/Repositories/Eloquent/BackupRepository.php +++ /dev/null @@ -1,47 +0,0 @@ -getBuilder() - ->withTrashed() - ->where('server_id', $server) - ->where(function ($query) { - $query->whereNull('completed_at') - ->orWhere('is_successful', '=', true); - }) - ->where('created_at', '>=', Carbon::now()->subSeconds($seconds)->toDateTimeString()) - ->get() - ->toBase(); - } - - /** - * Returns a query filtering only non-failed backups for a specific server. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\Backup, \Pterodactyl\Models\Server> - */ - public function getNonFailedBackups(Server $server): HasMany - { - return $server->backups()->where(function ($query) { - $query->whereNull('completed_at') - ->orWhere('is_successful', true); - }); - } -} diff --git a/app/Repositories/Eloquent/DatabaseHostRepository.php b/app/Repositories/Eloquent/DatabaseHostRepository.php deleted file mode 100644 index 2c2b9dcde..000000000 --- a/app/Repositories/Eloquent/DatabaseHostRepository.php +++ /dev/null @@ -1,27 +0,0 @@ -getBuilder()->withCount('databases')->with('node')->get(); - } -} diff --git a/app/Repositories/Eloquent/DatabaseRepository.php b/app/Repositories/Eloquent/DatabaseRepository.php deleted file mode 100644 index 9bc33d035..000000000 --- a/app/Repositories/Eloquent/DatabaseRepository.php +++ /dev/null @@ -1,136 +0,0 @@ -connection; - } - - /** - * Set the connection name to execute statements against. - */ - public function setConnection(string $connection): self - { - $this->connection = $connection; - - return $this; - } - - /** - * Return all the databases belonging to a server. - */ - public function getDatabasesForServer(int $server): Collection - { - return $this->getBuilder()->with('host')->where('server_id', $server)->get($this->getColumns()); - } - - /** - * Return all the databases for a given host with the server relationship loaded. - */ - public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator - { - return $this->getBuilder()->with('server') - ->where('database_host_id', $host) - ->paginate($count, $this->getColumns()); - } - - /** - * Create a new database on a given connection. - */ - public function createDatabase(string $database): bool - { - return $this->run(sprintf('CREATE DATABASE IF NOT EXISTS `%s`', $database)); - } - - /** - * Create a new database user on a given connection. - */ - public function createUser(string $username, string $remote, string $password, ?int $max_connections): bool - { - $args = [$username, $remote, $password]; - $command = 'CREATE USER `%s`@`%s` IDENTIFIED BY \'%s\''; - - if (!empty($max_connections)) { - $args[] = $max_connections; - $command .= ' WITH MAX_USER_CONNECTIONS %s'; - } - - return $this->run(sprintf($command, ...$args)); - } - - /** - * Give a specific user access to a given database. - */ - public function assignUserToDatabase(string $database, string $username, string $remote): bool - { - return $this->run(sprintf( - 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, REFERENCES, INDEX, LOCK TABLES, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, CREATE TEMPORARY TABLES, CREATE VIEW, SHOW VIEW, EVENT, TRIGGER ON `%s`.* TO `%s`@`%s`', - $database, - $username, - $remote - )); - } - - /** - * Flush the privileges for a given connection. - */ - public function flush(): bool - { - return $this->run('FLUSH PRIVILEGES'); - } - - /** - * Drop a given database on a specific connection. - */ - public function dropDatabase(string $database): bool - { - return $this->run(sprintf('DROP DATABASE IF EXISTS `%s`', $database)); - } - - /** - * Drop a given user on a specific connection. - */ - public function dropUser(string $username, string $remote): bool - { - return $this->run(sprintf('DROP USER IF EXISTS `%s`@`%s`', $username, $remote)); - } - - /** - * Run the provided statement against the database on a given connection. - */ - private function run(string $statement): bool - { - return $this->database->connection($this->getConnection())->statement($statement); - } -} diff --git a/app/Repositories/Eloquent/EggRepository.php b/app/Repositories/Eloquent/EggRepository.php deleted file mode 100644 index 0e09ab20f..000000000 --- a/app/Repositories/Eloquent/EggRepository.php +++ /dev/null @@ -1,86 +0,0 @@ -getBuilder()->with('variables')->findOrFail($id, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Return all eggs and their relations to be used in the daemon API. - */ - public function getAllWithCopyAttributes(): Collection - { - return $this->getBuilder()->with('scriptFrom', 'configFrom')->get($this->getColumns()); - } - - /** - * Return an egg with the scriptFrom and configFrom relations loaded onto the model. - * - * @param int|string $value - * - * @throws RecordNotFoundException - */ - public function getWithCopyAttributes($value, string $column = 'id'): Egg - { - Assert::true(is_digit($value) || is_string($value), 'First argument passed to getWithCopyAttributes must be an integer or string, received %s.'); - - try { - return $this->getBuilder()->with('scriptFrom', 'configFrom')->where($column, '=', $value)->firstOrFail($this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Return all the data needed to export a service. - * - * @throws RecordNotFoundException - */ - public function getWithExportAttributes(int $id): Egg - { - try { - return $this->getBuilder()->with('scriptFrom', 'configFrom', 'variables')->findOrFail($id, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Confirm a copy script belongs to the same nest as the item trying to use it. - */ - public function isCopyableScript(int $copyFromId, int $service): bool - { - return $this->getBuilder()->whereNull('copy_script_from') - ->where('id', '=', $copyFromId) - ->where('nest_id', '=', $service) - ->exists(); - } -} diff --git a/app/Repositories/Eloquent/EggVariableRepository.php b/app/Repositories/Eloquent/EggVariableRepository.php deleted file mode 100644 index 8ca35debb..000000000 --- a/app/Repositories/Eloquent/EggVariableRepository.php +++ /dev/null @@ -1,31 +0,0 @@ -getBuilder()->where([ - ['egg_id', '=', $egg], - ['user_viewable', '=', 1], - ['user_editable', '=', 1], - ])->get($this->getColumns()); - } -} diff --git a/app/Repositories/Eloquent/EloquentRepository.php b/app/Repositories/Eloquent/EloquentRepository.php deleted file mode 100644 index 443accfd3..000000000 --- a/app/Repositories/Eloquent/EloquentRepository.php +++ /dev/null @@ -1,288 +0,0 @@ -useRequestFilters = $usingFilters; - - return $this; - } - - /** - * Returns the request instance. - */ - protected function request(): Request - { - return $this->app->make(Request::class); - } - - /** - * Paginate the response data based on the page para. - */ - protected function paginate(Builder $instance, int $default = 50): LengthAwarePaginator - { - if (!$this->useRequestFilters) { - return $instance->paginate($default); - } - - return $instance->paginate($this->request()->query('per_page', $default)); - } - - /** - * Return an instance of the eloquent model bound to this - * repository instance. - */ - public function getModel(): Model - { - return $this->model; - } - - /** - * Return an instance of the builder to use for this repository. - */ - public function getBuilder(): Builder - { - return $this->getModel()->newQuery(); - } - - /** - * Create a new record in the database and return the associated model. - * - * @throws DataValidationException - */ - public function create(array $fields, bool $validate = true, bool $force = false): Model|bool - { - $instance = $this->getBuilder()->newModelInstance(); - ($force) ? $instance->forceFill($fields) : $instance->fill($fields); - - if (!$validate) { - $saved = $instance->skipValidation()->save(); - } else { - if (!$saved = $instance->save()) { - throw new DataValidationException($instance->getValidator(), $instance); - } - } - - return ($this->withFresh) ? $instance->fresh() : $saved; - } - - /** - * Find a model that has the specific ID passed. - * - * @throws RecordNotFoundException - */ - public function find(int $id): Model - { - try { - return $this->getBuilder()->findOrFail($id, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Find a model matching an array of where clauses. - */ - public function findWhere(array $fields): Collection - { - return $this->getBuilder()->where($fields)->get($this->getColumns()); - } - - /** - * Find and return the first matching instance for the given fields. - * - * @throws RecordNotFoundException - */ - public function findFirstWhere(array $fields): Model - { - try { - return $this->getBuilder()->where($fields)->firstOrFail($this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Return a count of records matching the passed arguments. - */ - public function findCountWhere(array $fields): int - { - return $this->getBuilder()->where($fields)->count($this->getColumns()); - } - - /** - * Delete a given record from the database. - */ - public function delete(int $id, bool $destroy = false): int - { - return $this->deleteWhere(['id' => $id], $destroy); - } - - /** - * Delete records matching the given attributes. - */ - public function deleteWhere(array $attributes, bool $force = false): int - { - $instance = $this->getBuilder()->where($attributes); - - return ($force) ? $instance->forceDelete() : $instance->delete(); - } - - /** - * Update a given ID with the passed array of fields. - * - * @throws DataValidationException - * @throws RecordNotFoundException - */ - public function update(int $id, array $fields, bool $validate = true, bool $force = false): Model|bool - { - try { - $instance = $this->getBuilder()->where('id', $id)->firstOrFail(); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - - ($force) ? $instance->forceFill($fields) : $instance->fill($fields); - - if (!$validate) { - $saved = $instance->skipValidation()->save(); - } else { - if (!$saved = $instance->save()) { - throw new DataValidationException($instance->getValidator(), $instance); - } - } - - return ($this->withFresh) ? $instance->fresh() : $saved; - } - - /** - * Update a model using the attributes passed. - */ - public function updateWhere(array $attributes, array $values): int - { - return $this->getBuilder()->where($attributes)->update($values); - } - - /** - * Perform a mass update where matching records are updated using whereIn. - * This does not perform any model data validation. - */ - public function updateWhereIn(string $column, array $values, array $fields): int - { - Assert::notEmpty($column, 'First argument passed to updateWhereIn must be a non-empty string.'); - - return $this->getBuilder()->whereIn($column, $values)->update($fields); - } - - /** - * Update a record if it exists in the database, otherwise create it. - * - * @throws DataValidationException - * @throws RecordNotFoundException - */ - public function updateOrCreate(array $where, array $fields, bool $validate = true, bool $force = false): Model|bool - { - foreach ($where as $item) { - Assert::true(is_scalar($item) || is_null($item), 'First argument passed to updateOrCreate should be an array of scalar or null values, received an array value of %s.'); - } - - try { - $instance = $this->setColumns('id')->findFirstWhere($where); - } catch (RecordNotFoundException) { - return $this->create(array_merge($where, $fields), $validate, $force); - } - - return $this->update($instance->id, $fields, $validate, $force); - } - - /** - * Return all records associated with the given model. - * - * @deprecated Just use the model - */ - public function all(): Collection - { - return $this->getBuilder()->get($this->getColumns()); - } - - /** - * Return a paginated result set using a search term if set on the repository. - */ - public function paginated(int $perPage): LengthAwarePaginator - { - return $this->getBuilder()->paginate($perPage, $this->getColumns()); - } - - /** - * Insert a single or multiple records into the database at once skipping - * validation and mass assignment checking. - */ - public function insert(array $data): bool - { - return $this->getBuilder()->insert($data); - } - - /** - * Insert multiple records into the database and ignore duplicates. - */ - public function insertIgnore(array $values): bool - { - if (empty($values)) { - return true; - } - - foreach ($values as $key => $value) { - ksort($value); - $values[$key] = $value; - } - - $bindings = array_values(array_filter(array_flatten($values, 1), function ($binding) { - return !$binding instanceof Expression; - })); - - $grammar = $this->getBuilder()->toBase()->getGrammar(); - $table = $grammar->wrapTable($this->getModel()->getTable()); - $columns = $grammar->columnize(array_keys(reset($values))); - - $parameters = collect($values)->map(function ($record) use ($grammar) { - return sprintf('(%s)', $grammar->parameterize($record)); - })->implode(', '); - - $statement = "insert ignore into $table ($columns) values $parameters"; - - return $this->getBuilder()->getConnection()->statement($statement, $bindings); - } - - /** - * Get the amount of entries in the database. - * - * @deprecated just use the count method off a model - */ - public function count(): int - { - return $this->getBuilder()->count(); - } -} diff --git a/app/Repositories/Eloquent/LocationRepository.php b/app/Repositories/Eloquent/LocationRepository.php deleted file mode 100644 index 066f6d2fa..000000000 --- a/app/Repositories/Eloquent/LocationRepository.php +++ /dev/null @@ -1,64 +0,0 @@ -getBuilder()->withCount('nodes', 'servers')->get($this->getColumns()); - } - - /** - * Return all the available locations with the nodes as a relationship. - */ - public function getAllWithNodes(): Collection - { - return $this->getBuilder()->with('nodes')->get($this->getColumns()); - } - - /** - * Return all the nodes and their respective count of servers for a location. - * - * @throws RecordNotFoundException - */ - public function getWithNodes(int $id): Location - { - try { - return $this->getBuilder()->with('nodes.servers')->findOrFail($id, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Return a location and the count of nodes in that location. - * - * @throws RecordNotFoundException - */ - public function getWithNodeCount(int $id): Location - { - try { - return $this->getBuilder()->withCount('nodes')->findOrFail($id, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } -} diff --git a/app/Repositories/Eloquent/MountRepository.php b/app/Repositories/Eloquent/MountRepository.php deleted file mode 100644 index f0983aa0b..000000000 --- a/app/Repositories/Eloquent/MountRepository.php +++ /dev/null @@ -1,57 +0,0 @@ -getBuilder()->withCount('eggs', 'nodes')->get($this->getColumns()); - } - - /** - * Return all the mounts and their respective relations. - * - * @throws RecordNotFoundException - */ - public function getWithRelations(string $id): Mount - { - try { - return $this->getBuilder()->with('eggs', 'nodes')->findOrFail($id, $this->getColumns()); - } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException(); - } - } - - /** - * Return mounts available to a server (ignoring if they are or are not mounted). - */ - public function getMountListForServer(Server $server): Collection - { - return $this->getBuilder() - ->whereHas('eggs', function ($q) use ($server) { - $q->where('id', '=', $server->egg_id); - }) - ->whereHas('nodes', function ($q) use ($server) { - $q->where('id', '=', $server->node_id); - }) - ->get($this->getColumns()); - } -} diff --git a/app/Repositories/Eloquent/NestRepository.php b/app/Repositories/Eloquent/NestRepository.php deleted file mode 100644 index 6b8d75987..000000000 --- a/app/Repositories/Eloquent/NestRepository.php +++ /dev/null @@ -1,80 +0,0 @@ -|\Pterodactyl\Models\Nest - * - * @throws RecordNotFoundException - */ - public function getWithEggs(?int $id = null): Collection|Nest - { - $instance = $this->getBuilder()->with('eggs', 'eggs.variables'); - - if (!is_null($id)) { - $instance = $instance->find($id, $this->getColumns()); - if (!$instance) { - throw new RecordNotFoundException(); - } - - return $instance; - } - - return $instance->get($this->getColumns()); - } - - /** - * Return a nest or all nests and the count of eggs and servers for that nest. - * - * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest - * - * @throws RecordNotFoundException - */ - public function getWithCounts(?int $id = null): Collection|Nest - { - $instance = $this->getBuilder()->withCount(['eggs', 'servers']); - - if (!is_null($id)) { - $instance = $instance->find($id, $this->getColumns()); - if (!$instance) { - throw new RecordNotFoundException(); - } - - return $instance; - } - - return $instance->get($this->getColumns()); - } - - /** - * Return a nest along with its associated eggs and the servers relation on those eggs. - * - * @throws RecordNotFoundException - */ - public function getWithEggServers(int $id): Nest - { - $instance = $this->getBuilder()->with('eggs.servers')->find($id, $this->getColumns()); - if (!$instance) { - throw new RecordNotFoundException(); - } - - return $instance; // @phpstan-ignore return.type - } -} diff --git a/app/Repositories/Eloquent/NodeRepository.php b/app/Repositories/Eloquent/NodeRepository.php deleted file mode 100644 index fe019e50a..000000000 --- a/app/Repositories/Eloquent/NodeRepository.php +++ /dev/null @@ -1,152 +0,0 @@ -getBuilder() - ->selectRaw('IFNULL(SUM(servers.memory), 0) as sum_memory, IFNULL(SUM(servers.disk), 0) as sum_disk') - ->join('servers', 'servers.node_id', '=', 'nodes.id') - ->where('node_id', '=', $node->id) - ->first(); - - return Collection::make(['disk' => $stats->sum_disk, 'memory' => $stats->sum_memory]) - ->mapWithKeys(function ($value, $key) use ($node) { - $maxUsage = $node->{$key}; - if ($node->{$key . '_overallocate'} > 0) { - $maxUsage = $node->{$key} * (1 + ($node->{$key . '_overallocate'} / 100)); - } - - $percent = ($value / $maxUsage) * 100; - - return [ - $key => [ - 'value' => number_format($value), - 'max' => number_format($maxUsage), - 'percent' => $percent, - 'css' => ($percent <= self::THRESHOLD_PERCENTAGE_LOW) ? 'green' : (($percent > self::THRESHOLD_PERCENTAGE_MEDIUM) ? 'red' : 'yellow'), - ], - ]; - }) - ->toArray(); - } - - /** - * Return the usage stats for a single node. - */ - public function getUsageStatsRaw(Node $node): array - { - $stats = $this->getBuilder()->select( - $this->getBuilder()->raw('IFNULL(SUM(servers.memory), 0) as sum_memory, IFNULL(SUM(servers.disk), 0) as sum_disk') - )->join('servers', 'servers.node_id', '=', 'nodes.id')->where('node_id', $node->id)->first(); - - return collect(['disk' => $stats->sum_disk, 'memory' => $stats->sum_memory])->mapWithKeys(function ($value, $key) use ($node) { - $maxUsage = $node->{$key}; - if ($node->{$key . '_overallocate'} > 0) { - $maxUsage = $node->{$key} * (1 + ($node->{$key . '_overallocate'} / 100)); - } - - return [ - $key => [ - 'value' => $value, - 'max' => $maxUsage, - ], - ]; - })->toArray(); - } - - /** - * Return a single node with location and server information. - */ - public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node - { - if (!$node->relationLoaded('location') || $refresh) { - $node->load('location'); - } - - // This is quite ugly and can probably be improved down the road. - // And by probably, I mean it should. - if (is_null($node->servers_count) || $refresh) { - $node->load('servers'); - $node->setRelation('servers_count', count($node->getRelation('servers'))); - unset($node->servers); - } - - return $node; - } - - /** - * Attach a paginated set of allocations to a node mode including - * any servers that are also attached to those allocations. - */ - public function loadNodeAllocations(Node $node, bool $refresh = false): Node - { - $node->setRelation( - 'allocations', - $node->allocations() - ->orderByRaw('server_id IS NOT NULL DESC, server_id IS NULL') - ->orderByRaw('INET_ATON(ip) ASC') - ->orderBy('port') - ->with('server:id,name') - ->paginate(50) - ); - - return $node; - } - - /** - * Return a collection of nodes for all locations to use in server creation UI. - */ - public function getNodesForServerCreation(): Collection - { - return $this->getBuilder()->with('allocations')->get()->map(function (Node $item) { - $filtered = $item->getRelation('allocations')->where('server_id', null)->map(function ($map) { - return collect($map)->only(['id', 'ip', 'port']); - }); - - $item->ports = $filtered->map(function ($map) { - return [ - 'id' => $map['id'], - 'text' => sprintf('%s:%s', $map['ip'], $map['port']), - ]; - })->values(); - - return [ - 'id' => $item->id, - 'text' => $item->name, - 'allocations' => $item->ports, - ]; - })->values(); - } - - /** - * Returns a node with the given id with the Node's resource usage. - */ - public function getNodeWithResourceUsage(int $node_id): Node - { - $instance = $this->getBuilder() - ->select(['nodes.id', 'nodes.fqdn', 'nodes.scheme', 'nodes.daemon_token', 'nodes.daemonListen', 'nodes.memory', 'nodes.disk', 'nodes.memory_overallocate', 'nodes.disk_overallocate']) - ->selectRaw('IFNULL(SUM(servers.memory), 0) as sum_memory, IFNULL(SUM(servers.disk), 0) as sum_disk') - ->leftJoin('servers', 'servers.node_id', '=', 'nodes.id') - ->where('nodes.id', $node_id); - - return $instance->first(); - } -} diff --git a/app/Repositories/Eloquent/PermissionRepository.php b/app/Repositories/Eloquent/PermissionRepository.php deleted file mode 100644 index 603829bc1..000000000 --- a/app/Repositories/Eloquent/PermissionRepository.php +++ /dev/null @@ -1,18 +0,0 @@ -getBuilder()->withCount('tasks')->where('server_id', '=', $server)->get($this->getColumns()); - } - - /** - * Return a schedule model with all the associated tasks as a relationship. - * - * @throws RecordNotFoundException - */ - public function getScheduleWithTasks(int $schedule): Schedule - { - try { - return $this->getBuilder()->with('tasks')->findOrFail($schedule, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } -} diff --git a/app/Repositories/Eloquent/ServerRepository.php b/app/Repositories/Eloquent/ServerRepository.php deleted file mode 100644 index 56097f976..000000000 --- a/app/Repositories/Eloquent/ServerRepository.php +++ /dev/null @@ -1,179 +0,0 @@ -relationLoaded('egg') || $refresh) { - $server->load('egg.scriptFrom'); - } - - return $server; - } - - /** - * Return a collection of servers with their associated data for rebuild operations. - */ - public function getDataForRebuild(?int $server = null, ?int $node = null): Collection - { - $instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']); - - if (!is_null($server) && is_null($node)) { - $instance = $instance->where('id', '=', $server); - } elseif (is_null($server) && !is_null($node)) { - $instance = $instance->where('node_id', '=', $node); - } - - return $instance->get($this->getColumns()); - } - - /** - * Return a collection of servers with their associated data for reinstall operations. - */ - public function getDataForReinstall(?int $server = null, ?int $node = null): Collection - { - $instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']); - - if (!is_null($server) && is_null($node)) { - $instance = $instance->where('id', '=', $server); - } elseif (is_null($server) && !is_null($node)) { - $instance = $instance->where('node_id', '=', $node); - } - - return $instance->get($this->getColumns()); - } - - /** - * Return a server model and all variables associated with the server. - * - * @throws RecordNotFoundException - */ - public function findWithVariables(int $id): Server - { - try { - return $this->getBuilder()->with('egg.variables', 'variables') - ->where($this->getModel()->getKeyName(), '=', $id) - ->firstOrFail($this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Get the primary allocation for a given server. If a model is passed into - * the function, load the allocation relationship onto it. Otherwise, find and - * return the server from the database. - */ - public function getPrimaryAllocation(Server $server, bool $refresh = false): Server - { - if (!$server->relationLoaded('allocation') || $refresh) { - $server->load('allocation'); - } - - return $server; - } - - /** - * Return enough data to be used for the creation of a server via the daemon. - */ - public function getDataForCreation(Server $server, bool $refresh = false): Server - { - foreach (['allocation', 'allocations', 'egg'] as $relation) { - if (!$server->relationLoaded($relation) || $refresh) { - $server->load($relation); - } - } - - return $server; - } - - /** - * Load associated databases onto the server model. - */ - public function loadDatabaseRelations(Server $server, bool $refresh = false): Server - { - if (!$server->relationLoaded('databases') || $refresh) { - $server->load('databases.host'); - } - - return $server; - } - - /** - * Get data for use when updating a server on the Daemon. Returns an array of - * the egg which is used for build and rebuild. Only loads relations - * if they are missing, or refresh is set to true. - */ - public function getDaemonServiceData(Server $server, bool $refresh = false): array - { - if (!$server->relationLoaded('egg') || $refresh) { - $server->load('egg'); - } - - return [ - 'egg' => $server->getRelation('egg')->uuid, - ]; - } - - /** - * Return a server by UUID. - * - * @throws RecordNotFoundException - */ - public function getByUuid(string $uuid): Server - { - try { - /** @var Server $model */ - $model = $this->getBuilder() - ->with('nest', 'node') - ->where(function (Builder $query) use ($uuid) { - $query->where('uuidShort', $uuid)->orWhere('uuid', $uuid); - }) - ->firstOrFail($this->getColumns()); - - return $model; - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Check if a given UUID and UUID-Short string are unique to a server. - */ - public function isUniqueUuidCombo(string $uuid, string $short): bool - { - return !$this->getBuilder()->where('uuid', '=', $uuid)->orWhere('uuidShort', '=', $short)->exists(); - } - - /** - * Returns all the servers that exist for a given node in a paginated response. - */ - public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator - { - return $this->getBuilder() - ->with(['user', 'nest', 'egg']) - ->where('node_id', '=', $node) - ->paginate($limit); - } -} diff --git a/app/Repositories/Eloquent/ServerVariableRepository.php b/app/Repositories/Eloquent/ServerVariableRepository.php deleted file mode 100644 index 26ded2cf6..000000000 --- a/app/Repositories/Eloquent/ServerVariableRepository.php +++ /dev/null @@ -1,17 +0,0 @@ -getBuilder()->where('user_id', $user)->get($this->getColumns()); - } - - /** - * Delete a session for a given user. - */ - public function deleteUserSession(int $user, string $session): ?int - { - return $this->getBuilder()->where('user_id', $user)->where('id', $session)->delete(); - } -} diff --git a/app/Repositories/Eloquent/SettingsRepository.php b/app/Repositories/Eloquent/SettingsRepository.php deleted file mode 100644 index 4deea80a7..000000000 --- a/app/Repositories/Eloquent/SettingsRepository.php +++ /dev/null @@ -1,75 +0,0 @@ -clearCache($key); - $this->withoutFreshModel()->updateOrCreate(['key' => $key], ['value' => $value ?? '']); - - self::$cache[$key] = $value; - } - - /** - * Retrieve a persistent setting from the database. - */ - public function get(string $key, mixed $default = null): mixed - { - // If item has already been requested return it from the cache. If - // we already know it is missing, immediately return the default value. - if (array_key_exists($key, self::$cache)) { - return self::$cache[$key]; - } elseif (array_key_exists($key, self::$databaseMiss)) { - return value($default); - } - - $instance = $this->getBuilder()->where('key', $key)->first(); - if (is_null($instance)) { - self::$databaseMiss[$key] = true; - - return value($default); - } - - return self::$cache[$key] = $instance->value; - } - - /** - * Remove a key from the database cache. - */ - public function forget(string $key) - { - $this->clearCache($key); - $this->deleteWhere(['key' => $key]); - } - - /** - * Remove a key from the cache. - */ - private function clearCache(string $key) - { - unset(self::$cache[$key], self::$databaseMiss[$key]); - } -} diff --git a/app/Repositories/Eloquent/SubuserRepository.php b/app/Repositories/Eloquent/SubuserRepository.php deleted file mode 100644 index 01bc0c0cb..000000000 --- a/app/Repositories/Eloquent/SubuserRepository.php +++ /dev/null @@ -1,69 +0,0 @@ -relationLoaded('server') || $refresh) { - $subuser->load('server'); - } - - if (!$subuser->relationLoaded('user') || $refresh) { - $subuser->load('user'); - } - - return $subuser; - } - - /** - * Return a subuser with the associated permissions relationship. - */ - public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser - { - if (!$subuser->relationLoaded('permissions') || $refresh) { - $subuser->load('permissions'); - } - - if (!$subuser->relationLoaded('user') || $refresh) { - $subuser->load('user'); - } - - return $subuser; - } - - /** - * Return a subuser and associated permissions given a user_id and server_id. - * - * @throws RecordNotFoundException - */ - public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser - { - $instance = $this->getBuilder()->with('permissions')->where([ - ['user_id', '=', $user], - ['server_id', '=', $server], - ])->first(); - - if (is_null($instance)) { - throw new RecordNotFoundException(); - } - - return $instance; - } -} diff --git a/app/Repositories/Eloquent/TaskRepository.php b/app/Repositories/Eloquent/TaskRepository.php deleted file mode 100644 index 4a68167cf..000000000 --- a/app/Repositories/Eloquent/TaskRepository.php +++ /dev/null @@ -1,44 +0,0 @@ -getBuilder()->with('server.user', 'schedule')->findOrFail($id, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } - - /** - * Returns the next task in a schedule. - */ - public function getNextTask(int $schedule, int $index): ?Task - { - return $this->getBuilder()->where('schedule_id', '=', $schedule) - ->orderBy('sequence_id') - ->where('sequence_id', '>', $index) - ->first($this->getColumns()); - } -} diff --git a/app/Repositories/Eloquent/UserRepository.php b/app/Repositories/Eloquent/UserRepository.php deleted file mode 100644 index 444534625..000000000 --- a/app/Repositories/Eloquent/UserRepository.php +++ /dev/null @@ -1,17 +0,0 @@ -initializeModel($this->model()); - } - - /** - * Return the model backing this repository. - */ - abstract public function model(): string; - - /** - * Return the model being used for this repository. - */ - public function getModel(): Model - { - return $this->model; - } - - /** - * Setup column selection functionality. - * - * @param array|string $columns - */ - public function setColumns($columns = ['*']): self - { - $clone = clone $this; - $clone->columns = is_array($columns) ? $columns : func_get_args(); - - return $clone; - } - - /** - * Return the columns to be selected in the repository call. - */ - public function getColumns(): array - { - return $this->columns; - } - - /** - * Stop repository update functions from returning a fresh - * model when changes are committed. - */ - public function withoutFreshModel(): self - { - return $this->setFreshModel(false); - } - - /** - * Return a fresh model with a repository updates a model. - */ - public function withFreshModel(): self - { - return $this->setFreshModel(); - } - - /** - * Set whether the repository should return a fresh model - * when changes are committed. - */ - public function setFreshModel(bool $fresh = true): self - { - $clone = clone $this; - $clone->withFresh = $fresh; - - return $clone; - } - - /** - * Take the provided model and make it accessible to the rest of the repository. - */ - protected function initializeModel(string ...$model): mixed - { - switch (count($model)) { - case 1: - return $this->model = $this->app->make($model[0]); - case 2: - return $this->model = call_user_func([$this->app->make($model[0]), $model[1]]); - default: - throw new \InvalidArgumentException('Model must be a FQDN or an array with a count of two.'); - } - } -} diff --git a/app/Repositories/Wings/DaemonBackupRepository.php b/app/Repositories/Wings/DaemonBackupRepository.php deleted file mode 100644 index 228784089..000000000 --- a/app/Repositories/Wings/DaemonBackupRepository.php +++ /dev/null @@ -1,97 +0,0 @@ -adapter = $adapter; - - return $this; - } - - /** - * Tells the remote Daemon to begin generating a backup for the server. - * - * @throws DaemonConnectionException - */ - public function backup(Backup $backup): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/backup', $this->server->uuid), - [ - 'json' => [ - 'adapter' => $this->adapter ?? config('backups.default'), - 'uuid' => $backup->uuid, - 'ignore' => implode("\n", $backup->ignored_files), - ], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Sends a request to Wings to begin restoring a backup for a server. - * - * @throws DaemonConnectionException - */ - public function restore(Backup $backup, ?string $url = null, bool $truncate = false): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/backup/%s/restore', $this->server->uuid, $backup->uuid), - [ - 'json' => [ - 'adapter' => $backup->disk, - 'truncate_directory' => $truncate, - 'download_url' => $url ?? '', - ], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Deletes a backup from the daemon. - * - * @throws DaemonConnectionException - */ - public function delete(Backup $backup): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->delete( - sprintf('/api/servers/%s/backup/%s', $this->server->uuid, $backup->uuid) - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Repositories/Wings/DaemonCommandRepository.php b/app/Repositories/Wings/DaemonCommandRepository.php deleted file mode 100644 index 858d41a77..000000000 --- a/app/Repositories/Wings/DaemonCommandRepository.php +++ /dev/null @@ -1,37 +0,0 @@ -server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/commands', $this->server->uuid), - [ - 'json' => ['commands' => is_array($command) ? $command : [$command]], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Repositories/Wings/DaemonConfigurationRepository.php b/app/Repositories/Wings/DaemonConfigurationRepository.php deleted file mode 100644 index 90a7ef21c..000000000 --- a/app/Repositories/Wings/DaemonConfigurationRepository.php +++ /dev/null @@ -1,50 +0,0 @@ -getHttpClient()->get('/api/system' . (!is_null($version) ? '?v=' . $version : '')); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - - return json_decode($response->getBody()->__toString(), true); - } - - /** - * Updates the configuration information for a daemon. Updates the information for - * this instance using a passed-in model. This allows us to change plenty of information - * in the model, and still use the old, pre-update model to actually make the HTTP request. - * - * @throws DaemonConnectionException - */ - public function update(Node $node): ResponseInterface - { - try { - return $this->getHttpClient()->post( - '/api/update', - ['json' => $node->getConfiguration()] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Repositories/Wings/DaemonFileRepository.php b/app/Repositories/Wings/DaemonFileRepository.php deleted file mode 100644 index af8db9be6..000000000 --- a/app/Repositories/Wings/DaemonFileRepository.php +++ /dev/null @@ -1,301 +0,0 @@ -server, Server::class); - - try { - $response = $this->getHttpClient()->get( - sprintf('/api/servers/%s/files/contents', $this->server->uuid), - [ - 'query' => ['file' => $path], - ] - ); - } catch (ClientException|TransferException $exception) { - throw new DaemonConnectionException($exception); - } - - $length = (int) Arr::get($response->getHeader('Content-Length'), 0, 0); - if ($notLargerThan && $length > $notLargerThan) { - throw new FileSizeTooLargeException(); - } - - return $response->getBody()->__toString(); - } - - /** - * Save new contents to a given file. This works for both creating and updating - * a file. - * - * @throws DaemonConnectionException - */ - public function putContent(string $path, string $content): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/write', $this->server->uuid), - [ - 'query' => ['file' => $path], - 'body' => $content, - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Return a directory listing for a given path. - * - * @throws DaemonConnectionException - */ - public function getDirectory(string $path): array - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $response = $this->getHttpClient()->get( - sprintf('/api/servers/%s/files/list-directory', $this->server->uuid), - [ - 'query' => ['directory' => $path], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - - return json_decode($response->getBody(), true); - } - - /** - * Creates a new directory for the server in the given $path. - * - * @throws DaemonConnectionException - */ - public function createDirectory(string $name, string $path): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/create-directory', $this->server->uuid), - [ - 'json' => [ - 'name' => $name, - 'path' => $path, - ], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Renames or moves a file on the remote machine. - * - * @throws DaemonConnectionException - */ - public function renameFiles(?string $root, array $files): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->put( - sprintf('/api/servers/%s/files/rename', $this->server->uuid), - [ - 'json' => [ - 'root' => $root ?? '/', - 'files' => $files, - ], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Copy a given file and give it a unique name. - * - * @throws DaemonConnectionException - */ - public function copyFile(string $location): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/copy', $this->server->uuid), - [ - 'json' => [ - 'location' => $location, - ], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Delete a file or folder for the server. - * - * @throws DaemonConnectionException - */ - public function deleteFiles(?string $root, array $files): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/delete', $this->server->uuid), - [ - 'json' => [ - 'root' => $root ?? '/', - 'files' => $files, - ], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Compress the given files or folders in the given root. - * - * @throws DaemonConnectionException - */ - public function compressFiles(?string $root, array $files): array - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $response = $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/compress', $this->server->uuid), - [ - 'json' => [ - 'root' => $root ?? '/', - 'files' => $files, - ], - // Wait for up to 15 minutes for the archive to be completed when calling this endpoint - // since it will likely take quite awhile for large directories. - 'timeout' => 60 * 15, - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - - return json_decode($response->getBody(), true); - } - - /** - * Decompresses a given archive file. - * - * @throws DaemonConnectionException - */ - public function decompressFile(?string $root, string $file): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/decompress', $this->server->uuid), - [ - 'json' => [ - 'root' => $root ?? '/', - 'file' => $file, - ], - // Wait for up to 15 minutes for the decompress to be completed when calling this endpoint - // since it will likely take quite awhile for large directories. - 'timeout' => 60 * 15, - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Chmods the given files. - * - * @throws DaemonConnectionException - */ - public function chmodFiles(?string $root, array $files): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/chmod', $this->server->uuid), - [ - 'json' => [ - 'root' => $root ?? '/', - 'files' => $files, - ], - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Pulls a file from the given URL and saves it to the disk. - * - * @throws DaemonConnectionException - */ - public function pull(string $url, ?string $directory, array $params = []): ResponseInterface - { - Assert::isInstanceOf($this->server, Server::class); - - $attributes = [ - 'url' => $url, - 'root' => $directory ?? '/', - 'file_name' => $params['filename'] ?? null, - 'use_header' => $params['use_header'] ?? null, - 'foreground' => $params['foreground'] ?? null, - ]; - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/files/pull', $this->server->uuid), - [ - 'json' => array_filter($attributes, fn ($value) => !is_null($value)), - ] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Repositories/Wings/DaemonPowerRepository.php b/app/Repositories/Wings/DaemonPowerRepository.php deleted file mode 100644 index 2b6f339a6..000000000 --- a/app/Repositories/Wings/DaemonPowerRepository.php +++ /dev/null @@ -1,35 +0,0 @@ -server, Server::class); - - try { - return $this->getHttpClient()->post( - sprintf('/api/servers/%s/power', $this->server->uuid), - ['json' => ['action' => $action]] - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Repositories/Wings/DaemonRepository.php b/app/Repositories/Wings/DaemonRepository.php deleted file mode 100644 index 512626d73..000000000 --- a/app/Repositories/Wings/DaemonRepository.php +++ /dev/null @@ -1,65 +0,0 @@ -server = $server; - - $this->setNode($this->server->node); - - return $this; - } - - /** - * Set the node model this request is stemming from. - */ - public function setNode(Node $node): self - { - $this->node = $node; - - return $this; - } - - /** - * Return an instance of the Guzzle HTTP Client to be used for requests. - */ - public function getHttpClient(array $headers = []): Client - { - Assert::isInstanceOf($this->node, Node::class); - - return new Client([ - 'verify' => $this->app->environment('production'), - 'base_uri' => $this->node->getConnectionAddress(), - 'timeout' => config('pterodactyl.guzzle.timeout'), - 'connect_timeout' => config('pterodactyl.guzzle.connect_timeout'), - 'headers' => array_merge($headers, [ - 'Authorization' => 'Bearer ' . $this->node->getDecryptedKey(), - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - ]), - ]); - } -} diff --git a/app/Repositories/Wings/DaemonRevocationRepository.php b/app/Repositories/Wings/DaemonRevocationRepository.php deleted file mode 100644 index f8a839985..000000000 --- a/app/Repositories/Wings/DaemonRevocationRepository.php +++ /dev/null @@ -1,27 +0,0 @@ -getHttpClient()->post('/api/deauthorize-user', [ - 'json' => ['user' => $user, 'servers' => $servers], - ]); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Repositories/Wings/DaemonServerRepository.php b/app/Repositories/Wings/DaemonServerRepository.php deleted file mode 100644 index 07d40cceb..000000000 --- a/app/Repositories/Wings/DaemonServerRepository.php +++ /dev/null @@ -1,165 +0,0 @@ -server, Server::class); - - try { - $response = $this->getHttpClient()->get( - sprintf('/api/servers/%s', $this->server->uuid) - ); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception, false); - } - - return json_decode($response->getBody()->__toString(), true); - } - - /** - * Creates a new server on the Wings daemon. - * - * @throws DaemonConnectionException - */ - public function create(bool $startOnCompletion = true): void - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $this->getHttpClient()->post('/api/servers', [ - 'json' => [ - 'uuid' => $this->server->uuid, - 'start_on_completion' => $startOnCompletion, - ], - ]); - } catch (GuzzleException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Triggers a server sync on Wings. - * - * @throws DaemonConnectionException - */ - public function sync(): void - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $this->getHttpClient()->post("/api/servers/{$this->server->uuid}/sync"); - } catch (GuzzleException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Delete a server from the daemon, forcibly if passed. - * - * @throws DaemonConnectionException - */ - public function delete(): void - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $this->getHttpClient()->delete('/api/servers/' . $this->server->uuid); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Reinstall a server on the daemon. - * - * @throws DaemonConnectionException - */ - public function reinstall(): void - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $this->getHttpClient()->post(sprintf( - '/api/servers/%s/reinstall', - $this->server->uuid - )); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Requests the daemon to create a full archive of the server. Once the daemon is finished - * they will send a POST request to "/api/remote/servers/{uuid}/archive" with a boolean. - * - * @throws DaemonConnectionException - */ - public function requestArchive(): void - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $this->getHttpClient()->post(sprintf( - '/api/servers/%s/archive', - $this->server->uuid - )); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } - - /** - * Revokes a single user's JTI by using their ID. This is simply a helper function to - * make it easier to revoke tokens on the fly. This ensures that the JTI key is formatted - * correctly and avoids any costly mistakes in the codebase. - * - * @deprecated - * @see \Pterodactyl\Repositories\Wings\DaemonRevocationRepository::deauthorize() - * - * @throws DaemonConnectionException - */ - public function revokeUserJTI(int $id): void - { - Assert::isInstanceOf($this->server, Server::class); - - $this->revokeJTIs([md5($id . $this->server->uuid)]); - } - - /** - * Revokes an array of JWT JTI's by marking any token generated before the current time on - * the Wings instance as being invalid. - * - * @throws DaemonConnectionException - */ - protected function revokeJTIs(array $jtis): void - { - Assert::isInstanceOf($this->server, Server::class); - - try { - $this->getHttpClient() - ->post(sprintf('/api/servers/%s/ws/deny', $this->server->uuid), [ - 'json' => ['jtis' => $jtis], - ]); - } catch (TransferException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Repositories/Wings/DaemonTransferRepository.php b/app/Repositories/Wings/DaemonTransferRepository.php deleted file mode 100644 index 9a2cd2160..000000000 --- a/app/Repositories/Wings/DaemonTransferRepository.php +++ /dev/null @@ -1,37 +0,0 @@ -getHttpClient()->post(sprintf('/api/servers/%s/transfer', $this->server->uuid), [ - 'json' => [ - 'server_id' => $this->server->uuid, - 'url' => $targetNode->getConnectionAddress() . '/api/transfers', - 'token' => 'Bearer ' . $token->toString(), - 'server' => [ - 'uuid' => $this->server->uuid, - 'start_on_completion' => false, - ], - ], - ]); - } catch (GuzzleException $exception) { - throw new DaemonConnectionException($exception); - } - } -} diff --git a/app/Rules/Fqdn.php b/app/Rules/Fqdn.php index 19a500963..f0fa85a72 100644 --- a/app/Rules/Fqdn.php +++ b/app/Rules/Fqdn.php @@ -1,19 +1,35 @@ schemeField = $schemeField; + }); + } + + /** + * @param ValidationData $data */ public function setData($data): self { @@ -25,55 +41,32 @@ class Fqdn implements Rule, DataAwareRule /** * Validates that the value provided resolves to an IP address. If a scheme is * specified when this rule is created additional checks will be applied. - * - * @param string $attribute */ - public function passes($attribute, $value): bool + public function validate(string $attribute, mixed $value, Closure $fail): void { - if (filter_var($value, FILTER_VALIDATE_IP)) { - // Check if the scheme is set to HTTPS. - // - // Unless someone owns their IP blocks and decides to pay who knows how much for a - // custom SSL cert, IPs will not be able to use HTTPS. This should prevent most - // home users from making this mistake and wondering why their node is not working. - if ($this->schemeField && Arr::get($this->data, $this->schemeField) === 'https') { - $this->message = 'The :attribute must not be an IP address when HTTPS is enabled.'; + if (! is_string($value)) { + $fail('The :attribute could not be resolved to a valid IP address.'); - return false; + return; + } + + if (filter_var($value, FILTER_VALIDATE_IP)) { + // Unless someone owns their IP blocks and pays for a custom certificate, an IP + // cannot serve HTTPS, so refuse the combination before the node fails to connect. + if ($this->schemeField && Arr::get($this->data, $this->schemeField) === 'https') { + $fail('The :attribute must not be an IP address when HTTPS is enabled.'); } - return true; + return; } - // Lookup A and AAAA DNS records for the FQDN. Note, this function will also resolve CNAMEs - // for us automatically, there is no need to manually resolve them here. - // - // The error suppression is intentional, see https://bugs.php.net/bug.php?id=73149 + // dns_get_record resolves CNAMEs for us; the suppression is intentional, + // see https://bugs.php.net/bug.php?id=73149. gethostbyname is the IPv4-only fallback. $records = @dns_get_record($value, DNS_A + DNS_AAAA); - // If no records were returned fall back to trying to resolve the value using the hosts DNS - // resolution. This will not work for IPv6 which is why we prefer to use `dns_get_record` - // first. - if (!empty($records) || filter_var(gethostbyname($value), FILTER_VALIDATE_IP)) { - return true; + if (! empty($records) || filter_var(gethostbyname($value), FILTER_VALIDATE_IP)) { + return; } - $this->message = 'The :attribute could not be resolved to a valid IP address.'; - - return false; - } - - public function message(): string - { - return $this->message; - } - - /** - * Returns a new instance of the rule with a defined scheme set. - */ - public static function make(?string $schemeField = null): self - { - return tap(new self(), function ($fqdn) use ($schemeField) { - $fqdn->schemeField = $schemeField; - }); + $fail('The :attribute could not be resolved to a valid IP address.'); } } diff --git a/app/Rules/TagSlug.php b/app/Rules/TagSlug.php new file mode 100644 index 000000000..9715cc80b --- /dev/null +++ b/app/Rules/TagSlug.php @@ -0,0 +1,41 @@ +getMessage()); + } + } +} diff --git a/app/Rules/ValidRuleSet.php b/app/Rules/ValidRuleSet.php new file mode 100644 index 000000000..7873a335a --- /dev/null +++ b/app/Rules/ValidRuleSet.php @@ -0,0 +1,35 @@ + 'test'], ['__TEST' => $value])->fails(); + } catch (BadMethodCallException $badMethodCallException) { + $matches = []; + $rule = preg_match('/Method (.+) does not exist\./', $badMethodCallException->getMessage(), $matches) === 1 + ? Str::snake(Str::after(Str::afterLast($matches[1], '::'), 'validate')) + : $value; + + $fail('exceptions.egg.variables.bad_validation_rule')->translate(['rule' => $rule]); + } + } +} diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index cee076e17..a1892bbb2 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -1,8 +1,13 @@ + * + * @throws ReflectionException */ public static function getResourceList(): array { - $reflect = new \ReflectionClass(__CLASS__); + $reflect = new ReflectionClass(self::class); - return collect($reflect->getConstants())->filter(function ($value, $key) { - return substr($key, 0, 9) === 'RESOURCE_'; - })->values()->toArray(); + $resources = []; + foreach ($reflect->getConstants() as $key => $value) { + if (str_starts_with($key, 'RESOURCE_') && is_string($value)) { + $resources[] = $value; + } + } + + return $resources; } } diff --git a/app/Services/Activity/ActivityLogBatchService.php b/app/Services/Activity/ActivityLogBatchService.php index f4206ea56..53ea74e2d 100644 --- a/app/Services/Activity/ActivityLogBatchService.php +++ b/app/Services/Activity/ActivityLogBatchService.php @@ -1,12 +1,16 @@ uuid = Uuid::uuid4()->toString(); } - ++$this->transaction; + $this->transaction++; } /** @@ -47,8 +51,13 @@ class ActivityLogBatchService /** * Executes the logic provided within the callback in the scope of an activity * log batch transaction. + * + * @template TReturn of object|ApiValue10 + * + * @param Closure(?string): TReturn $callback + * @return TReturn */ - public function transaction(\Closure $callback): mixed + public function transaction(Closure $callback): mixed { $this->start(); $result = $callback($this->uuid()); diff --git a/app/Services/Activity/ActivityLogFacetService.php b/app/Services/Activity/ActivityLogFacetService.php new file mode 100644 index 000000000..266e7adbe --- /dev/null +++ b/app/Services/Activity/ActivityLogFacetService.php @@ -0,0 +1,48 @@ + $query + * @return array{events: list, users: list} + */ + public function handle(Builder $query): array + { + $query = (clone $query)->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS); + $events = JsonValueGuard::stringList((clone $query)->select('activity_logs.event') + ->distinct()->orderBy('activity_logs.event')->pluck('event')->all()); + + $actorIds = (clone $query) + ->where('activity_logs.actor_type', (new User)->getMorphClass()) + ->whereNotNull('activity_logs.actor_id') + ->select('activity_logs.actor_id') + ->distinct() + ->pluck('actor_id') + ->all(); + + $users = User::query() + ->whereIn('id', $actorIds) + ->orderBy('username') + ->get(['id', 'username', 'email']) + ->map(fn (User $user): array => [ + 'id' => $user->id, + 'username' => $user->username, + 'email' => $user->email, + ]) + ->all(); + + return ['events' => $events, 'users' => array_values($users)]; + } +} diff --git a/app/Services/Activity/ActivityLogQueryService.php b/app/Services/Activity/ActivityLogQueryService.php new file mode 100644 index 000000000..8295c846c --- /dev/null +++ b/app/Services/Activity/ActivityLogQueryService.php @@ -0,0 +1,36 @@ + */ + public function forServer(Server $server): Builder + { + $query = $server->activity()->getQuery()->select('activity_logs.*') + ->whereNotIn('activity_logs.event', ActivityLog::DISABLED_EVENTS); + + if (config('activity.hide_admin_activity')) { + $subusers = $server->subusers()->pluck('user_id')->merge([$server->owner_id]); + + $query->leftJoin('users', function (JoinClause $join): void { + $join->on('users.id', 'activity_logs.actor_id') + ->where('activity_logs.actor_type', (new User)->getMorphClass()); + })->where(function (Builder $builder) use ($subusers): void { + $builder->whereNull('users.id') + ->orWhere('users.root_admin', 0) + ->orWhereIn('users.id', $subusers); + }); + } + + return $query; + } +} diff --git a/app/Services/Activity/ActivityLogService.php b/app/Services/Activity/ActivityLogService.php index 4fb687905..4faa5bc28 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -1,22 +1,29 @@ */ protected array $subjects = []; public function __construct( @@ -24,8 +31,8 @@ class ActivityLogService protected ActivityLogBatchService $batch, protected ActivityLogTargetableService $targetable, protected ConnectionInterface $connection, - ) { - } + protected Request $request, + ) {} /** * Sets the activity logger as having been caused by an anonymous @@ -61,16 +68,18 @@ class ActivityLogService } /** - * Sets the subject model instance. + * Sets the subject model instance(s) for this activity log entry. Null entries + * are ignored, which lets callers pass an optional subject conditionally. A + * non-Model Authenticatable (accepted here because auth events type their + * user as the interface) is also skipped -- every Authenticatable this app + * actually issues is a Model too, but this only ever tracks morphable models. * - * @template T extends \Illuminate\Database\Eloquent\Model|\Illuminate\Contracts\Auth\Authenticatable - * - * @param T|T[]|null $subjects + * @param Model|Authenticatable|null ...$subjects */ public function subject(...$subjects): self { - foreach (Arr::wrap($subjects) as $subject) { - if (is_null($subject)) { + foreach ($subjects as $subject) { + if (! $subject instanceof Model) { continue; } @@ -101,14 +110,23 @@ class ActivityLogService /** * Sets a custom property on the activity log instance. * - * @param string|array $key + * @param string|array $key + * @param JsonInputValue $value Ignored when an array of properties is provided. */ - public function property($key, $value = null): self + public function property(array|string $key, array|bool|float|int|string|JsonEmptyObject|null $value = null): self { - $properties = $this->getActivity()->properties; - $this->activity->properties = is_array($key) - ? $properties->merge($key) - : $properties->put($key, $value); + $activity = $this->getActivity(); + $properties = $activity->properties; + if (is_array($key)) { + foreach ($key as $name => $property) { + $properties->put($name, $property); + } + } else { + JsonValueGuard::assertValue($value); + $properties->put($key, $value); + } + + $activity->properties = $properties; return $this; } @@ -119,8 +137,8 @@ class ActivityLogService public function withRequestMetadata(): self { return $this->property([ - 'ip' => Request::getClientIp(), - 'useragent' => Request::userAgent(), + 'ip' => $this->request->ip(), + 'useragent' => $this->request->userAgent(), ]); } @@ -134,19 +152,17 @@ class ActivityLogService { $activity = $this->getActivity(); - if (!is_null($description)) { + if (($description) !== null) { $activity->description = $description; } try { return $this->save(); - } catch (\Throwable $exception) { - if (config('app.env') !== 'production') { - /* @noinspection PhpUnhandledExceptionInspection */ - throw $exception; - } + } catch (Throwable $throwable) { + /* @noinspection PhpUnhandledExceptionInspection */ + throw_if(config('app.env') !== 'production', $throwable); - Log::error($exception); + Log::error($throwable->getMessage(), ['exception' => $throwable]); } return $activity; @@ -166,11 +182,14 @@ class ActivityLogService * and will only save the activity log entry if everything else successfully * settles. * - * @param \Closure($this): mixed $callback + * @template TReturn of object|ApiValue10 * - * @throws \Throwable + * @param Closure($this): TReturn $callback + * @return TReturn + * + * @throws Throwable */ - public function transaction(\Closure $callback) + public function transaction(Closure $callback): array|bool|float|int|object|string|null { return $this->connection->transaction(function () use ($callback) { $response = $callback($this); @@ -195,24 +214,24 @@ class ActivityLogService */ protected function getActivity(): ActivityLog { - if ($this->activity) { + if ($this->activity instanceof ActivityLog) { return $this->activity; } $this->activity = new ActivityLog([ - 'ip' => Request::ip(), + 'ip' => $this->request->ip(), 'batch' => $this->batch->uuid(), 'properties' => Collection::make([]), 'api_key_id' => $this->targetable->apiKeyId(), ]); - if ($subject = $this->targetable->subject()) { + if (($subject = $this->targetable->subject()) instanceof Model) { $this->subject($subject); } - if ($actor = $this->targetable->actor()) { + if (($actor = $this->targetable->actor()) instanceof Model) { $this->actor($actor); - } elseif (! is_null($user = $this->manager->guard()->user())) { + } elseif (($user = $this->manager->guard()->user()) !== null) { $this->actor($user); } @@ -222,27 +241,28 @@ class ActivityLogService /** * Saves the activity log instance and attaches all of the subject models. * - * @throws \Throwable + * @throws Throwable */ protected function save(): ActivityLog { - Assert::notNull($this->activity); + throw_unless($this->activity instanceof ActivityLog, InvalidArgumentException::class, 'Cannot save an activity log before one has been initialized.'); - $response = $this->connection->transaction(function () { - $this->activity->save(); + $activity = $this->activity; + $response = $this->connection->transaction(function () use ($activity): ActivityLog { + $activity->save(); $subjects = Collection::make($this->subjects) - ->map(fn (Model $subject) => [ - 'activity_log_id' => $this->activity->id, + ->map(fn (Model $subject): array => [ + 'activity_log_id' => $activity->id, 'subject_id' => $subject->getKey(), 'subject_type' => $subject->getMorphClass(), ]) ->values() - ->toArray(); + ->all(); - ActivityLogSubject::insert($subjects); + ActivityLogSubject::query()->insert($subjects); - return $this->activity; + return $activity; }); $this->activity = null; diff --git a/app/Services/Activity/ActivityLogTargetableService.php b/app/Services/Activity/ActivityLogTargetableService.php index 4d37e9828..1a5e5f80b 100644 --- a/app/Services/Activity/ActivityLogTargetableService.php +++ b/app/Services/Activity/ActivityLogTargetableService.php @@ -1,5 +1,7 @@ server_id)) { - throw new ServerUsingAllocationException(trans('exceptions.allocations.server_using')); - } - - return $this->repository->delete($allocation->id); - } -} diff --git a/app/Services/Allocations/AssignmentService.php b/app/Services/Allocations/AssignmentService.php deleted file mode 100644 index 94f347c6c..000000000 --- a/app/Services/Allocations/AssignmentService.php +++ /dev/null @@ -1,109 +0,0 @@ - self::CIDR_MIN_BITS || $explode[1] < self::CIDR_MAX_BITS)) { - throw new CidrOutOfRangeException(); - } - } - - try { - // TODO: how should we approach supporting IPv6 with this? - // gethostbyname only supports IPv4, but the alternative (dns_get_record) returns - // an array of records, which is not ideal for this use case, we need a SINGLE - // IP to use, not multiple. - $underlying = gethostbyname($data['allocation_ip']); - $parsed = Network::parse($underlying); - } catch (\Exception $exception) { - // @phpstan-ignore-next-line variable.undefined - throw new DisplayException("Could not parse provided allocation IP address ({$underlying}): {$exception->getMessage()}", $exception); - } - - $this->connection->beginTransaction(); - foreach ($parsed as $ip) { - foreach ($data['allocation_ports'] as $port) { - if (!is_digit($port) && !preg_match(self::PORT_RANGE_REGEX, $port)) { - throw new InvalidPortMappingException($port); - } - - $insertData = []; - if (preg_match(self::PORT_RANGE_REGEX, $port, $matches)) { - $block = range($matches[1], $matches[2]); - - if (count($block) > self::PORT_RANGE_LIMIT) { - throw new TooManyPortsInRangeException(); - } - - if ((int) $matches[1] <= self::PORT_FLOOR || (int) $matches[2] > self::PORT_CEIL) { - throw new PortOutOfRangeException(); - } - - foreach ($block as $unit) { - $insertData[] = [ - 'node_id' => $node->id, - 'ip' => $ip->__toString(), - 'port' => (int) $unit, - 'ip_alias' => array_get($data, 'allocation_alias'), - 'server_id' => null, - ]; - } - } else { - if ((int) $port <= self::PORT_FLOOR || (int) $port > self::PORT_CEIL) { - throw new PortOutOfRangeException(); - } - - $insertData[] = [ - 'node_id' => $node->id, - 'ip' => $ip->__toString(), - 'port' => (int) $port, - 'ip_alias' => array_get($data, 'allocation_alias'), - 'server_id' => null, - ]; - } - - $this->repository->insertIgnore($insertData); - } - } - - $this->connection->commit(); - } -} diff --git a/app/Services/Allocations/FindAssignableAllocationService.php b/app/Services/Allocations/FindAssignableAllocationService.php deleted file mode 100644 index 76b27ac6b..000000000 --- a/app/Services/Allocations/FindAssignableAllocationService.php +++ /dev/null @@ -1,113 +0,0 @@ -node->allocations() - ->lockForUpdate() - ->where('ip', $server->allocation->ip) - ->whereNull('server_id') - ->inRandomOrder() - ->first(); - - $allocation = $allocation ?? $this->createNewAllocation($server); - - $allocation->update(['server_id' => $server->id]); - - return $allocation->refresh(); - } - - /** - * Create a new allocation on the server's node with a random port from the defined range - * in the settings. If there are no matches in that range, or something is wrong with the - * range information provided an exception will be raised. - * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException - * @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException - * @throws \Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException - * @throws \Pterodactyl\Exceptions\Service\Allocation\TooManyPortsInRangeException - */ - protected function createNewAllocation(Server $server): Allocation - { - $start = config('pterodactyl.client_features.allocations.range_start', null); - $end = config('pterodactyl.client_features.allocations.range_end', null); - - if (!$start || !$end) { - throw new NoAutoAllocationSpaceAvailableException(); - } - - Assert::integerish($start); - Assert::integerish($end); - - // Get all of the currently allocated ports for the node so that we can figure out - // which port might be available. - $ports = $server->node->allocations() - ->where('ip', $server->allocation->ip) - ->whereBetween('port', [$start, $end]) - ->pluck('port'); - - // Compute the difference of the range and the currently created ports, finding - // any port that does not already exist in the database. We will then use this - // array of ports to create a new allocation to assign to the server. - $available = array_diff(range($start, $end), $ports->toArray()); - - // If we've already allocated all of the ports, just abort. - if (empty($available)) { - throw new NoAutoAllocationSpaceAvailableException(); - } - - // Pick a random port out of the remaining available ports. - /** @var int $port */ - $port = $available[array_rand($available)]; - - $this->service->handle($server->node, [ - 'allocation_ip' => $server->allocation->ip, - 'allocation_ports' => [$port], - ]); - - /** @var Allocation $allocation */ - $allocation = $server->node->allocations() - ->lockForUpdate() - ->where('ip', $server->allocation->ip) - ->where('port', $port) - ->firstOrFail(); - - return $allocation; - } -} diff --git a/app/Services/Api/KeyCreationService.php b/app/Services/Api/KeyCreationService.php deleted file mode 100644 index f026b9f22..000000000 --- a/app/Services/Api/KeyCreationService.php +++ /dev/null @@ -1,52 +0,0 @@ -keyType = $type; - - return $this; - } - - /** - * Create a new API key for the Panel using the permissions passed in the data request. - * This will automatically generate an identifier and an encrypted token that are - * stored in the database. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - public function handle(array $data, array $permissions = []): ApiKey - { - $data = array_merge($data, [ - 'key_type' => $this->keyType, - 'identifier' => ApiKey::generateTokenIdentifier($this->keyType), - 'token' => $this->encrypter->encrypt(str_random(ApiKey::KEY_LENGTH)), - ]); - - if ($this->keyType === ApiKey::TYPE_APPLICATION) { - $data = array_merge($data, $permissions); - } - - return $this->repository->create($data, true, true); - } -} diff --git a/app/Services/Backups/BackupListService.php b/app/Services/Backups/BackupListService.php new file mode 100644 index 000000000..90740a8fb --- /dev/null +++ b/app/Services/Backups/BackupListService.php @@ -0,0 +1,23 @@ +, backup_count: int} + */ + public function handle(Server $server, int $perPage): array + { + return [ + 'backups' => $server->backups()->paginate($perPage), + 'backup_count' => $server->backups()->nonFailed()->count(), + ]; + } +} diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php deleted file mode 100644 index a1ecd3888..000000000 --- a/app/Services/Backups/InitiateBackupService.php +++ /dev/null @@ -1,127 +0,0 @@ -isLocked = $isLocked; - - return $this; - } - - /** - * Sets the files to be ignored by this backup. - * - * @param string[]|null $ignored - */ - public function setIgnoredFiles(?array $ignored): self - { - if (is_array($ignored)) { - foreach ($ignored as $value) { - Assert::string($value); // @phpstan-ignore staticMethod.alreadyNarrowedType - } - } - - // Set the ignored files to be any values that are not empty in the array. Don't use - // the PHP empty function here incase anything that is "empty" by default (0, false, etc.) - // were passed as a file or folder name. - $this->ignoredFiles = is_null($ignored) ? [] : array_filter($ignored, function ($value) { - return strlen($value) > 0; - }); - - return $this; - } - - /** - * Initiates the backup process for a server on Wings. - * - * @throws \Throwable - * @throws TooManyBackupsException - * @throws TooManyRequestsHttpException - */ - public function handle(Server $server, ?string $name = null, bool $override = false): Backup - { - $limit = config('backups.throttles.limit'); - $period = config('backups.throttles.period'); - if ($period > 0) { - $previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, $period); - if ($previous->count() >= $limit) { - $message = sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period); - - throw new TooManyRequestsHttpException((int) CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addSeconds($period)), $message); - } - } - - // Check if the server has reached or exceeded its backup limit. - // completed_at == null will cover any ongoing backups, while is_successful == true will cover any completed backups. - $successful = $this->repository->getNonFailedBackups($server); - if (!$server->backup_limit || $successful->count() >= $server->backup_limit) { - // Do not allow the user to continue if this server is already at its limit and can't override. - if (!$override || $server->backup_limit <= 0) { - throw new TooManyBackupsException($server->backup_limit); - } - - // Get the oldest backup the server has that is not "locked" (indicating a backup that should - // never be automatically purged). If we find a backup we will delete it and then continue with - // this process. If no backup is found that can be used an exception is thrown. - $oldest = $successful->where('is_locked', false)->orderBy('created_at')->first(); - if (!$oldest) { - throw new TooManyBackupsException($server->backup_limit); - } - - $this->deleteBackupService->handle($oldest); - } - - return $this->connection->transaction(function () use ($server, $name) { - /** @var Backup $backup */ - $backup = $this->repository->create([ - 'server_id' => $server->id, - 'uuid' => Uuid::uuid4()->toString(), - 'name' => trim($name) ?: sprintf('Backup at %s', CarbonImmutable::now()->toDateTimeString()), - 'ignored_files' => array_values($this->ignoredFiles), - 'disk' => $this->backupManager->getDefaultAdapter(), - 'is_locked' => $this->isLocked, - ], true, true); - - $this->daemonBackupRepository->setServer($server) - ->setBackupAdapter($this->backupManager->getDefaultAdapter()) - ->backup($backup); - - return $backup; - }); - } -} diff --git a/app/Services/Daemon/BackupsClient.php b/app/Services/Daemon/BackupsClient.php new file mode 100644 index 000000000..dc3445e0f --- /dev/null +++ b/app/Services/Daemon/BackupsClient.php @@ -0,0 +1,41 @@ +connection->request('POST', "/api/servers/{$this->uuid}/backup", ['json' => [ + 'adapter' => $adapter ?? $backup->disk, + 'uuid' => $backup->uuid, + 'ignore' => implode("\n", $backup->ignored_files), + ]]); + } + + public function restore(Backup $backup, ?string $url = null, bool $truncate = false): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/backup/{$backup->uuid}/restore", ['json' => [ + 'adapter' => $backup->disk, + 'truncate_directory' => $truncate, + 'download_url' => $url ?? '', + ]]); + } + + public function delete(Backup $backup): Response + { + return $this->connection->request('DELETE', "/api/servers/{$this->uuid}/backup/{$backup->uuid}"); + } +} diff --git a/app/Services/Daemon/DaemonConnection.php b/app/Services/Daemon/DaemonConnection.php new file mode 100644 index 000000000..2096eded3 --- /dev/null +++ b/app/Services/Daemon/DaemonConnection.php @@ -0,0 +1,73 @@ +, body?: string, timeout?: int} */ +final readonly class DaemonConnection +{ + private function __construct(private string $url, private string $token) {} + + public static function forNode(Node $node): self + { + return new self($node->getConnectionAddress(), $node->getDecryptedKey()); + } + + /** @param RequestOptions $options */ + public function request(string $method, string $path, array $options = [], bool $useStatusCode = true): Response + { + $request = Http::baseUrl($this->url) + ->withToken($this->token) + ->acceptJson() + ->asJson() + ->timeout(JsonValueGuard::integer(config('pterodactyl.guzzle.timeout'))) + ->connectTimeout(JsonValueGuard::integer(config('pterodactyl.guzzle.connect_timeout'))) + ->withOptions(['verify' => App::isProduction()]); + + if (isset($options['body'])) { + $request->withBody($options['body'], 'application/json'); + unset($options['body']); + } + + try { + return $request->send($method, $path, $options)->throw(); + } catch (ConnectionException|RequestException $exception) { + throw new DaemonConnectionException($exception, $useStatusCode); + } + } + + /** + * @param NormalizedValidationRules $rules + * @return array + */ + public function decode(Response $response, array $rules = [], bool $expectsList = false): array + { + try { + $data = JsonValueGuard::jsonArray(json_decode($response->body(), true, 512, JSON_THROW_ON_ERROR)); + + if (! $expectsList) { + JsonValueGuard::assertPayload($data); + } + + Validator::make(['data' => $data], $rules)->validate(); + + return $data; + } catch (JsonException|UnexpectedValueException|ValidationException $exception) { + throw new DaemonConnectionException($exception, response: $response); + } + } +} diff --git a/app/Services/Daemon/DaemonManager.php b/app/Services/Daemon/DaemonManager.php new file mode 100644 index 000000000..6f97c2e2e --- /dev/null +++ b/app/Services/Daemon/DaemonManager.php @@ -0,0 +1,21 @@ +connection->request('GET', "/api/servers/{$this->uuid}/files/contents", [ + 'query' => ['file' => $path], + ]); + $length = JsonValueGuard::integer($response->header('Content-Length') ?: 0); + throw_if($notLargerThan && $length > $notLargerThan, FileSizeTooLargeException::class); + + return $response->body(); + } + + public function putContent(string $path, string $content): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/files/write", [ + 'query' => ['file' => $path], + 'body' => $content, + ]); + } + + /** @return list */ + public function getDirectory(string $path): array + { + $response = $this->connection->request('GET', "/api/servers/{$this->uuid}/files/list-directory", [ + 'query' => ['directory' => $path], + ]); + $data = $this->connection->decode($response, [ + 'data' => ['array', 'list'], + 'data.*' => ['array'], + ...$this->fileRules('data.*'), + ], expectsList: true); + + // SAFETY: list and file entries are validated by the transport above. + /** @var list $data */ + return $data; + } + + public function createDirectory(string $name, string $path): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/files/create-directory", [ + 'json' => ['name' => $name, 'path' => $path], + ]); + } + + /** @param array $files */ + public function renameFiles(?string $root, array $files): Response + { + return $this->connection->request('PUT', "/api/servers/{$this->uuid}/files/rename", [ + 'json' => ['root' => $root ?? '/', 'files' => $files], + ]); + } + + public function copyFile(string $location): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/files/copy", [ + 'json' => ['location' => $location], + ]); + } + + /** @param array $files */ + public function deleteFiles(?string $root, array $files): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/files/delete", [ + 'json' => ['root' => $root ?? '/', 'files' => $files], + ]); + } + + /** + * @param array $files + * @return DaemonFileObject + */ + public function compressFiles(?string $root, array $files): array + { + $response = $this->connection->request('POST', "/api/servers/{$this->uuid}/files/compress", [ + 'json' => ['root' => $root ?? '/', 'files' => $files], + 'timeout' => self::ARCHIVE_TIMEOUT, + ]); + $data = $this->connection->decode($response, $this->fileRules('data')); + + // SAFETY: the transport validates the bounded JSON and file shape above. + /** @var DaemonFileObject $data */ + return $data; + } + + public function decompressFile(?string $root, string $file): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/files/decompress", [ + 'json' => ['root' => $root ?? '/', 'file' => $file], + 'timeout' => self::ARCHIVE_TIMEOUT, + ]); + } + + /** @param array $files */ + public function chmodFiles(?string $root, array $files): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/files/chmod", [ + 'json' => ['root' => $root ?? '/', 'files' => $files], + ]); + } + + /** @param array $params */ + public function pull(string $url, ?string $directory, array $params = []): Response + { + $attributes = [ + 'url' => $url, + 'root' => $directory ?? '/', + 'file_name' => JsonValueGuard::nullableString($params['filename'] ?? null), + 'use_header' => isset($params['use_header']) ? JsonValueGuard::boolean($params['use_header']) : null, + 'foreground' => isset($params['foreground']) ? JsonValueGuard::boolean($params['foreground']) : null, + ]; + $options = ['json' => array_filter($attributes, fn (bool|string|null $value): bool => $value !== null)]; + + if (isset($params['timeout'])) { + $options['timeout'] = JsonValueGuard::integer($params['timeout']); + } + + return $this->connection->request('POST', "/api/servers/{$this->uuid}/files/pull", $options); + } + + /** @return NormalizedValidationRules */ + private function fileRules(string $prefix): array + { + return [ + $prefix.'.name' => ['sometimes', 'string'], + $prefix.'.mode' => ['sometimes', 'string'], + $prefix.'.mode_bits' => ['sometimes', 'string'], + $prefix.'.size' => ['sometimes', 'integer:strict'], + $prefix.'.file' => ['sometimes', 'boolean:strict'], + $prefix.'.symlink' => ['sometimes', 'boolean:strict'], + $prefix.'.mime' => ['sometimes', 'string'], + $prefix.'.created' => ['sometimes', 'string', 'date'], + $prefix.'.modified' => ['sometimes', 'string', 'date'], + ]; + } +} diff --git a/app/Services/Daemon/NodeClient.php b/app/Services/Daemon/NodeClient.php new file mode 100644 index 000000000..209135978 --- /dev/null +++ b/app/Services/Daemon/NodeClient.php @@ -0,0 +1,42 @@ +connection->request('GET', '/api/system', [ + 'query' => $version === null ? [] : ['v' => $version], + ]); + $data = $this->connection->decode($response); + JsonValueGuard::assertPayload($data); + + return $data; + } + + public function update(Node $node): Response + { + return $this->connection->request('POST', '/api/update', ['json' => $node->getConfiguration()]); + } + + /** @param list $servers */ + public function deauthorize(string $user, array $servers = []): void + { + $this->connection->request('POST', '/api/deauthorize-user', ['json' => ['user' => $user, 'servers' => $servers]]); + } +} diff --git a/app/Services/Daemon/ServerClient.php b/app/Services/Daemon/ServerClient.php new file mode 100644 index 000000000..cd39a70db --- /dev/null +++ b/app/Services/Daemon/ServerClient.php @@ -0,0 +1,125 @@ +uuid, DaemonConnection::forNode($node ?? $server->node)); + } + + public function files(): FilesClient + { + return FilesClient::forServer($this->uuid, $this->connection); + } + + public function backups(): BackupsClient + { + return BackupsClient::forServer($this->uuid, $this->connection); + } + + /** @return DaemonStats */ + public function details(): array + { + $response = $this->connection->request('GET', "/api/servers/{$this->uuid}", useStatusCode: false); + $data = $this->connection->decode($response, [ + 'data.state' => ['sometimes', 'string'], + 'data.is_suspended' => ['sometimes', 'boolean:strict'], + 'data.utilization' => ['sometimes', 'array'], + 'data.utilization.memory_bytes' => ['sometimes', 'integer:strict'], + 'data.utilization.cpu_absolute' => ['sometimes', 'numeric:strict'], + 'data.utilization.disk_bytes' => ['sometimes', 'integer:strict'], + 'data.utilization.uptime' => ['sometimes', 'integer:strict'], + 'data.utilization.network' => ['sometimes', 'array'], + 'data.utilization.network.rx_bytes' => ['sometimes', 'integer:strict'], + 'data.utilization.network.tx_bytes' => ['sometimes', 'integer:strict'], + ]); + + // SAFETY: the transport validates the bounded JSON and the stats shape above. + /** @var DaemonStats $data */ + return $data; + } + + public function create(bool $startOnCompletion = true): void + { + $this->connection->request('POST', '/api/servers', ['json' => [ + 'uuid' => $this->uuid, + 'start_on_completion' => $startOnCompletion, + ]]); + } + + public function sync(): void + { + $this->connection->request('POST', "/api/servers/{$this->uuid}/sync"); + } + + public function delete(): void + { + $this->connection->request('DELETE', "/api/servers/{$this->uuid}"); + } + + public function reinstall(): void + { + $this->connection->request('POST', "/api/servers/{$this->uuid}/reinstall"); + } + + public function requestArchive(): void + { + $this->connection->request('POST', "/api/servers/{$this->uuid}/archive"); + } + + public function power(string $action): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/power", ['json' => ['action' => $action]]); + } + + /** @param list|string $commands */ + public function commands(array|string $commands): Response + { + return $this->connection->request('POST', "/api/servers/{$this->uuid}/commands", [ + 'json' => ['commands' => Arr::wrap($commands)], + ]); + } + + /** + * Read the most recent console output lines. Wings never returns more + * than its own ceiling of 100 lines, whatever size is requested. + * + * @return list + */ + public function logs(int $lines = 100): array + { + $response = $this->connection->request('GET', "/api/servers/{$this->uuid}/logs", [ + 'query' => ['size' => $lines], + ]); + $data = $this->connection->decode($response, [ + 'data.data' => ['present', 'nullable', 'array', 'list'], + 'data.data.*' => ['string'], + ]); + + // SAFETY: the transport validates the bounded JSON and the list of lines above. + /** @var array{data: list|null} $data */ + return $data['data'] ?? []; + } + + public function transfer(Node $target, UnencryptedToken $token): void + { + $this->connection->request('POST', "/api/servers/{$this->uuid}/transfer", ['json' => [ + 'server_id' => $this->uuid, + 'url' => $target->getConnectionAddress().'/api/transfers', + 'token' => 'Bearer '.$token->toString(), + 'server' => ['uuid' => $this->uuid, 'start_on_completion' => false], + ]]); + } +} diff --git a/app/Services/Databases/DatabaseHostGateway.php b/app/Services/Databases/DatabaseHostGateway.php new file mode 100644 index 000000000..3827fcbed --- /dev/null +++ b/app/Services/Databases/DatabaseHostGateway.php @@ -0,0 +1,104 @@ +connection = $connection; + + return $this; + } + + /** + * Return the connection to execute statements against. + */ + public function getConnection(): string + { + return $this->connection; + } + + /** + * Create a new database on the host. + */ + public function createDatabase(string $database): bool + { + return $this->run(sprintf('CREATE DATABASE IF NOT EXISTS `%s`', $database)); + } + + /** + * Create a new database user on the host. + */ + public function createUser(string $username, string $remote, string $password, ?int $maxConnections): bool + { + $args = [$username, $remote, $password]; + $command = "CREATE USER `%s`@`%s` IDENTIFIED BY '%s'"; + + if (! empty($maxConnections)) { + $args[] = $maxConnections; + $command .= ' WITH MAX_USER_CONNECTIONS %s'; + } + + return $this->run(sprintf($command, ...$args)); + } + + /** + * Give a user access to a database. + */ + public function assignUserToDatabase(string $database, string $username, string $remote): bool + { + return $this->run(sprintf( + 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, REFERENCES, INDEX, LOCK TABLES, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, CREATE TEMPORARY TABLES, CREATE VIEW, SHOW VIEW, EVENT, TRIGGER ON `%s`.* TO `%s`@`%s`', + $database, + $username, + $remote + )); + } + + /** + * Flush the host's privilege tables. + */ + public function flush(): bool + { + return $this->run('FLUSH PRIVILEGES'); + } + + /** + * Drop a database on the host. + */ + public function dropDatabase(string $database): bool + { + return $this->run(sprintf('DROP DATABASE IF EXISTS `%s`', $database)); + } + + /** + * Drop a user on the host. + */ + public function dropUser(string $username, string $remote): bool + { + return $this->run(sprintf('DROP USER IF EXISTS `%s`@`%s`', $username, $remote)); + } + + private function run(string $statement): bool + { + return $this->database->connection($this->getConnection())->statement($statement); + } +} diff --git a/app/Services/Databases/DatabaseManagementService.php b/app/Services/Databases/DatabaseManagementService.php deleted file mode 100644 index 1cabddbdb..000000000 --- a/app/Services/Databases/DatabaseManagementService.php +++ /dev/null @@ -1,177 +0,0 @@ -validateDatabaseLimit = $validate; - - return $this; - } - - /** - * Create a new database that is linked to a specific host. - * - * @throws \Throwable - * @throws TooManyDatabasesException - * @throws DatabaseClientFeatureNotEnabledException - */ - public function create(Server $server, array $data): Database - { - if (!config('pterodactyl.client_features.databases.enabled')) { - throw new DatabaseClientFeatureNotEnabledException(); - } - - if ($this->validateDatabaseLimit) { - // If the server has a limit assigned and we've already reached that limit, throw back - // an exception and kill the process. - if (!is_null($server->database_limit) && $server->databases()->count() >= $server->database_limit) { - throw new TooManyDatabasesException(); - } - } - - // Protect against developer mistakes... - if (empty($data['database']) || !preg_match(self::MATCH_NAME_REGEX, $data['database'])) { - throw new \InvalidArgumentException('The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".'); - } - - $data = array_merge($data, [ - 'server_id' => $server->id, - 'username' => sprintf('u%d_%s', $server->id, str_random(10)), - 'password' => $this->encrypter->encrypt( - Utilities::randomStringWithSpecialCharacters(24) - ), - ]); - - $database = null; - - try { - return $this->connection->transaction(function () use ($data, &$database) { - $database = $this->createModel($data); - - $this->dynamic->set('dynamic', $data['database_host_id']); - - $this->repository->createDatabase($database->database); - $this->repository->createUser( - $database->username, - $database->remote, - $this->encrypter->decrypt($database->password), - $database->max_connections - ); - $this->repository->assignUserToDatabase($database->database, $database->username, $database->remote); - $this->repository->flush(); - - return $database; - }); - } catch (\Exception $exception) { - try { - // This is actually incorrect, it can be null in the case that the $database model - // itself isn't able to be created in Pterodactyl's database. - // - // @phpstan-ignore-next-line instanceof.alwaysFalse - if ($database instanceof Database) { - $this->repository->dropDatabase($database->database); - $this->repository->dropUser($database->username, $database->remote); - $this->repository->flush(); - } - } catch (\Throwable $deletionException) { // @phpstan-ignore catch.neverThrown - // Do nothing here. We've already encountered an issue before this point so no - // reason to prioritize this error over the initial one. - } - - throw $exception; - } - } - - /** - * Delete a database from the given host server. - * - * @throws \Exception - */ - public function delete(Database $database): ?bool - { - $this->dynamic->set('dynamic', $database->database_host_id); - - $this->repository->dropDatabase($database->database); - $this->repository->dropUser($database->username, $database->remote); - $this->repository->flush(); - - return $database->delete(); - } - - /** - * Create the database if there is not an identical match in the DB. While you can technically - * have the same name across multiple hosts, for the sake of keeping this logic easy to understand - * and avoiding user confusion we will ignore the specific host and just look across all hosts. - * - * @throws DuplicateDatabaseNameException - * @throws \Throwable - */ - protected function createModel(array $data): Database - { - $exists = Database::query()->where('server_id', $data['server_id']) - ->where('database', $data['database']) - ->exists(); - - if ($exists) { - throw new DuplicateDatabaseNameException('A database with that name already exists for this server.'); - } - - $database = (new Database())->forceFill($data); - $database->saveOrFail(); - - return $database; - } -} diff --git a/app/Services/Databases/DatabasePasswordService.php b/app/Services/Databases/DatabasePasswordService.php deleted file mode 100644 index 69510ed6a..000000000 --- a/app/Services/Databases/DatabasePasswordService.php +++ /dev/null @@ -1,51 +0,0 @@ -connection->transaction(function () use ($database, $password) { - // Lock the row to serialize concurrent rotations of the same database. - $database->newQuery()->whereKey($database->getKey())->lockForUpdate()->firstOrFail(); - - $database->update([ - 'password' => $this->encrypter->encrypt($password), - ]); - - $this->dynamic->set('dynamic', $database->database_host_id); - $this->repository->dropUser($database->username, $database->remote); - $this->repository->createUser($database->username, $database->remote, $password, $database->max_connections); - $this->repository->assignUserToDatabase($database->database, $database->username, $database->remote); - $this->repository->flush(); - }); - - return $password; - } -} diff --git a/app/Services/Databases/DeployServerDatabaseService.php b/app/Services/Databases/DeployServerDatabaseService.php deleted file mode 100644 index e22eba51d..000000000 --- a/app/Services/Databases/DeployServerDatabaseService.php +++ /dev/null @@ -1,49 +0,0 @@ -get()->toBase(); - if ($hosts->isEmpty()) { - throw new NoSuitableDatabaseHostException(); - } else { - $nodeHosts = $hosts->where('node_id', $server->node_id)->toBase(); - - if ($nodeHosts->isEmpty() && !config('pterodactyl.client_features.databases.allow_random')) { - throw new NoSuitableDatabaseHostException(); - } - } - - return $this->managementService->create($server, [ - 'database_host_id' => $nodeHosts->isEmpty() - ? $hosts->random()->id - : $nodeHosts->random()->id, - 'database' => DatabaseManagementService::generateUniqueDatabaseName($data['database'], $server->id), - 'remote' => $data['remote'], - ]); - } -} diff --git a/app/Services/Databases/Hosts/HostCreationService.php b/app/Services/Databases/Hosts/HostCreationService.php deleted file mode 100644 index 0eecd7971..000000000 --- a/app/Services/Databases/Hosts/HostCreationService.php +++ /dev/null @@ -1,51 +0,0 @@ -connection->transaction(function () use ($data) { - $host = $this->repository->create([ - 'password' => $this->encrypter->encrypt(array_get($data, 'password')), - 'name' => array_get($data, 'name'), - 'host' => array_get($data, 'host'), - 'port' => array_get($data, 'port'), - 'username' => array_get($data, 'username'), - 'max_databases' => null, - 'node_id' => array_get($data, 'node_id'), - ]); - - // Confirm access using the provided credentials before saving data. - $this->dynamic->set('dynamic', $host); - $this->databaseManager->connection('dynamic')->select('SELECT 1 FROM dual'); - - return $host; - }); - } -} diff --git a/app/Services/Databases/Hosts/HostDeletionService.php b/app/Services/Databases/Hosts/HostDeletionService.php deleted file mode 100644 index 890412108..000000000 --- a/app/Services/Databases/Hosts/HostDeletionService.php +++ /dev/null @@ -1,35 +0,0 @@ -databaseRepository->findCountWhere([['database_host_id', '=', $host]]); - if ($count > 0) { - throw new HasActiveServersException(trans('exceptions.databases.delete_has_databases')); - } - - return $this->repository->delete($host); - } -} diff --git a/app/Services/Databases/Hosts/HostUpdateService.php b/app/Services/Databases/Hosts/HostUpdateService.php deleted file mode 100644 index e2efd46fc..000000000 --- a/app/Services/Databases/Hosts/HostUpdateService.php +++ /dev/null @@ -1,47 +0,0 @@ -encrypter->encrypt($data['password']); - } else { - unset($data['password']); - } - - return $this->connection->transaction(function () use ($data, $hostId) { - $host = $this->repository->update($hostId, $data); - $this->dynamic->set('dynamic', $host); - $this->databaseManager->connection('dynamic')->select('SELECT 1 FROM dual'); - - return $host; - }); - } -} diff --git a/app/Services/Deployment/AllocationSelectionService.php b/app/Services/Deployment/AllocationSelectionService.php index 7915fc5fe..f4600b4e4 100644 --- a/app/Services/Deployment/AllocationSelectionService.php +++ b/app/Services/Deployment/AllocationSelectionService.php @@ -1,27 +1,35 @@ */ protected array $nodes = []; + /** + * Single ports as they were provided. + * + * @var list + */ protected array $ports = []; /** - * AllocationSelectionService constructor. + * Port ranges reduced to [start, end] pairs for the Allocation::onPorts() scope. + * + * @var list */ - public function __construct(private AllocationRepositoryInterface $repository) - { - } + protected array $portRanges = []; /** * Toggle if the selected allocation should be the only allocation belonging @@ -38,6 +46,8 @@ class AllocationSelectionService /** * A list of node IDs that should be used when selecting an allocation. If empty, all * nodes will be used to filter with. + * + * @param list $nodes */ public function setNodes(array $nodes): self { @@ -51,28 +61,36 @@ class AllocationSelectionService * empty, all ports will be considered when finding an allocation. If set, only ports appearing * in the array or range will be used. * + * @param list $ports Entries that are neither a port nor a port range + * are discarded rather than rejected. + * * @throws DisplayException */ public function setPorts(array $ports): self { $stored = []; + $ranges = []; foreach ($ports as $port) { - if (is_digit($port)) { - $stored[] = $port; + // SAFETY: deployment ports are JSON scalars; string conversion is used only to test decimal port syntax. + if (! is_bool($port) && ctype_digit((string) $port)) { + // SAFETY: ctype_digit() above proves the scalar is a decimal integer before normalization. + $stored[] = (int) $port; } - // Ranges are stored in the ports array as an array which can be - // better processed in the repository. - if (preg_match(AssignmentService::PORT_RANGE_REGEX, $port, $matches)) { - if (abs($matches[2] - $matches[1]) > AssignmentService::PORT_RANGE_LIMIT) { + // Ranges are stored as a [start, end] pair for the onPorts() scope. + // SAFETY: deployment ports are JSON scalars; string conversion is used only to match the anchored range grammar. + if (preg_match(CreateAllocations::PORT_RANGE_REGEX, (string) $port, $matches)) { + if (abs($matches[2] - $matches[1]) > CreateAllocations::PORT_RANGE_LIMIT) { throw new DisplayException(trans('exceptions.allocations.too_many_ports')); } - $stored[] = [$matches[1], $matches[2]]; + // SAFETY: PORT_RANGE_REGEX captures two decimal integer strings. + $ranges[] = [(int) $matches[1], (int) $matches[2]]; } } $this->ports = $stored; + $this->portRanges = $ranges; return $this; } @@ -84,9 +102,15 @@ class AllocationSelectionService */ public function handle(): Allocation { - $allocation = $this->repository->getRandomAllocation($this->nodes, $this->ports, $this->dedicated); + $allocation = Allocation::query() + ->unassigned() + ->onNodes($this->nodes) + ->onPorts($this->ports, $this->portRanges) + ->when($this->dedicated, fn (Builder $query) => $query->onDedicatedIp($this->nodes)) + ->inRandomOrder() + ->first(); - if (is_null($allocation)) { + if ($allocation === null) { throw new NoViableAllocationException(trans('exceptions.deployment.no_viable_allocations')); } diff --git a/app/Services/Deployment/FindViableNodesService.php b/app/Services/Deployment/FindViableNodesService.php index cc76ad718..a6e0a5d36 100644 --- a/app/Services/Deployment/FindViableNodesService.php +++ b/app/Services/Deployment/FindViableNodesService.php @@ -1,27 +1,60 @@ + */ protected array $locations = []; + protected ?int $disk = null; + protected ?int $memory = null; + /** + * Null means "no egg is known yet", so the game half of the tag gate is skipped + * entirely. An empty array is a real constraint: an egg carrying no tags can + * only land on a node that accepts any game. + * + * @var string[]|null + */ + protected ?array $eggTags = null; + + /** @var string[] */ + protected array $deployTags = []; + + public function __construct(private readonly NodeTagGate $tagGate) {} + /** * Set the locations that should be searched through to locate available nodes. + * + * @param list $locations Rejected element by element unless every entry + * is an integer or an integer-like string. */ public function setLocations(array $locations): self { - Assert::allIntegerish($locations, 'An array of location IDs should be provided when calling setLocations.'); + $parsed = []; + foreach ($locations as $location) { + throw_if(is_string($location) && preg_match('/^-?\d+$/', $location) !== 1, InvalidArgumentException::class, 'An array of location IDs should be provided when calling setLocations.'); - $this->locations = $locations; + // SAFETY: integers pass directly and strings are accepted only after the anchored integer check above. + $parsed[] = (int) $location; + } + + $this->locations = $parsed; return $this; } @@ -49,6 +82,33 @@ class FindViableNodesService return $this; } + /** + * Set the tags of the egg being deployed. A node that declares which games it + * accepts is filtered out unless it shares at least one of these. + * + * @param array $eggTags + */ + public function setEggTags(array $eggTags): self + { + $this->eggTags = $eggTags; + + return $this; + } + + /** + * Set the deploy tags this deployment declares. Nodes reserved for tags the + * deployment did not declare are filtered out, and once a tag is declared only + * nodes carrying it remain. + * + * @param array $deployTags + */ + public function setDeployTags(array $deployTags): self + { + $this->deployTags = $deployTags; + + return $this; + } + /** * Returns an array of nodes that meet the provided requirements and can then * be passed to the AllocationSelectionService to return a single allocation. @@ -59,17 +119,23 @@ class FindViableNodesService * are tossed out, as are any nodes marked as non-public, meaning automatic * deployments should not be done against them. * - * @param int|null $page If provided the results will be paginated by returning - * up to 50 nodes at a time starting at the provided page. - * If "null" is provided as the value no pagination will - * be used. + * @param int|null $page If provided the results will be paginated by returning + * up to 50 nodes at a time starting at the provided page. + * If "null" is provided as the value no pagination will + * be used. + * @return ($page is null ? Collection : LengthAwarePaginator) * * @throws NoViableNodeException */ public function handle(?int $perPage = null, ?int $page = null): LengthAwarePaginator|Collection { - Assert::integer($this->disk, 'Disk space must be an int, got %s'); - Assert::integer($this->memory, 'Memory usage must be an int, got %s'); + if (! is_int($this->disk)) { + throw new InvalidArgumentException(sprintf('Disk space must be an int, got %s', get_debug_type($this->disk))); + } + + if (! is_int($this->memory)) { + throw new InvalidArgumentException(sprintf('Memory usage must be an int, got %s', get_debug_type($this->memory))); + } $query = Node::query()->select('nodes.*') ->selectRaw('IFNULL(SUM(servers.memory), 0) as sum_memory') @@ -77,15 +143,23 @@ class FindViableNodesService ->leftJoin('servers', 'servers.node_id', '=', 'nodes.id') ->where('nodes.public', 1); - if (!empty($this->locations)) { + if ($this->locations !== []) { $query = $query->whereIn('nodes.location_id', $this->locations); } + // A preview that has no egg yet can still reproduce the reservation match + // exactly, so it applies that half on its own rather than nothing at all. + if (($this->eggTags) === null) { + $this->tagGate->applyDeploymentTags($query, $this->deployTags); + } else { + $this->tagGate->apply($query, $this->eggTags, $this->deployTags); + } + $results = $query->groupBy('nodes.id') ->havingRaw('(IFNULL(SUM(servers.memory), 0) + ?) <= (nodes.memory * (1 + (nodes.memory_overallocate / 100)))', [$this->memory]) ->havingRaw('(IFNULL(SUM(servers.disk), 0) + ?) <= (nodes.disk * (1 + (nodes.disk_overallocate / 100)))', [$this->disk]); - if (!is_null($page)) { + if (($page) !== null) { $results = $results->paginate($perPage ?? 50, ['*'], 'page', $page); } else { $results = $results->get()->toBase(); diff --git a/app/Services/Deployment/NodeTagGate.php b/app/Services/Deployment/NodeTagGate.php new file mode 100644 index 000000000..96f7b151a --- /dev/null +++ b/app/Services/Deployment/NodeTagGate.php @@ -0,0 +1,84 @@ + $query + * @param string[] $eggTags E + * @param string[] $deployTags D + */ + public function apply(Builder $query, array $eggTags, array $deployTags): void + { + // Game (OR): no egg tags at all, or at least one shared with the egg. + $query->where(function (Builder $outer) use ($eggTags): void { + $outer->whereDoesntHave('eggTags'); + + if ($eggTags !== []) { + $outer->orWhereHas('eggTags', fn (Builder $relation) => $relation->whereIn('tags.slug', $eggTags)); + } + }); + + $this->applyDeploymentTags($query, $deployTags); + } + + /** + * Constrain a Node query to the deployment-tag (reservation) half of the gate, + * leaving the egg/game half out. This is what an eligible-nodes preview uses: it + * can reproduce the reservation match exactly, but not the egg match, because + * the egg is not chosen until creation. + * + * @param Builder $query + * @param string[] $deployTags D + */ + public function applyDeploymentTags(Builder $query, array $deployTags): void + { + // Reservation: no deployment tag the deploy didn't declare. + $query->whereDoesntHave('deploymentTags', fn (Builder $relation) => $relation->whereNotIn('tags.slug', $deployTags)); + + // Targeting: every declared deploy tag is on the node. + foreach ($deployTags as $slug) { + $query->whereHas('deploymentTags', fn (Builder $relation) => $relation->where('tags.slug', $slug)); + } + } + + /** + * Whether a single node, given its kind-split tag slugs, is eligible for the + * given egg/deploy tags. + * + * @param string[] $nodeEggTags + * @param string[] $nodeDeploymentTags + * @param string[] $eggTags E + * @param string[] $deployTags D + */ + public function allows(array $nodeEggTags, array $nodeDeploymentTags, array $eggTags, array $deployTags = []): bool + { + // Game (OR): egg tags only constrain when the node declares some. + if ($nodeEggTags !== [] && array_intersect($nodeEggTags, $eggTags) === []) { + return false; + } + + // Reservation: every node deployment tag must be declared by the deploy. + if (array_diff($nodeDeploymentTags, $deployTags) !== []) { + return false; + } + + // Targeting: every declared deploy tag must be on the node. + return array_diff($deployTags, $nodeDeploymentTags) === []; + } +} diff --git a/app/Services/Eggs/EggCatalogService.php b/app/Services/Eggs/EggCatalogService.php new file mode 100644 index 000000000..42a44b20b --- /dev/null +++ b/app/Services/Eggs/EggCatalogService.php @@ -0,0 +1,54 @@ + */ + public function all(): array + { + $contents = Cache::remember(self::CACHE_KEY, 3600, function (): string { + $contents = $this->downloadUrl(self::INDEX_URL); + EggCatalogEntry::listFromJson($contents); + + return $contents; + }); + + return EggCatalogEntry::listFromJson($contents); + } + + public function refresh(): void + { + Cache::forget(self::CACHE_KEY); + } + + public function download(EggCatalogEntry $entry): string + { + return $this->downloadUrl($entry->downloadUrl()); + } + + private function downloadUrl(string $url): string + { + try { + $response = Http::acceptJson()->connectTimeout(3)->timeout(10)->withoutRedirecting()->get($url); + } catch (ConnectionException $connectionException) { + throw new HttpException(502, 'Could not reach the Pterodactyl egg catalog. Please try again.', $connectionException); + } + + throw_unless($response->successful(), HttpException::class, 502, 'Could not download from the Pterodactyl egg catalog. Please try again.'); + + return $response->body(); + } +} diff --git a/app/Services/Eggs/EggConfigurationService.php b/app/Services/Eggs/EggConfigurationService.php index 7eb10ed18..5eaadd3a2 100644 --- a/app/Services/Eggs/EggConfigurationService.php +++ b/app/Services/Eggs/EggConfigurationService.php @@ -1,49 +1,60 @@ replacePlaceholders( - $server, - json_decode($server->egg->inherit_config_files) - ); + $egg = $server->egg ?? throw new UnexpectedValueException('The server does not have an egg assigned.'); + $configs = $this->replacePlaceholders($server, $this->configurationFiles($egg->inherit_config_files)); return [ - 'startup' => $this->convertStartupToNewFormat(json_decode($server->egg->inherit_config_startup, true)), - 'stop' => $this->convertStopToNewFormat($server->egg->inherit_config_stop), + 'startup' => $this->convertStartupToNewFormat($this->jsonObject($egg->inherit_config_startup)), + 'stop' => $this->convertStopToNewFormat($egg->inherit_config_stop ?? ''), 'configs' => $configs, ]; } /** * Convert the "done" variable into an array if it is not currently one. + * + * @param array $startup + * @return array{done: ApiValue9, user_interaction: array{}, strip_ansi: ApiValue9} */ protected function convertStartupToNewFormat(array $startup): array { - $done = Arr::get($startup, 'done'); + $done = $startup['done'] ?? null; return [ 'done' => is_string($done) ? [$done] : $done, 'user_interaction' => [], - 'strip_ansi' => Arr::get($startup, 'strip_ansi') ?? false, + 'strip_ansi' => $startup['strip_ansi'] ?? false, ]; } @@ -53,25 +64,31 @@ class EggConfigurationService * For most eggs, this ends up just being a command sent to the server console, but * if the stop command is something starting with a caret (^), it will be converted * into the associated kill signal for the instance. + * + * @return array{type: string, value: string} */ protected function convertStopToNewFormat(string $stop): array { - if (!Str::startsWith($stop, '^')) { + if (! Str::startsWith($stop, '^')) { return [ 'type' => 'command', 'value' => $stop, ]; } - $signal = substr($stop, 1); + $signal = mb_substr($stop, 1); return [ 'type' => 'signal', - 'value' => strtoupper($signal), + 'value' => mb_strtoupper($signal), ]; } - protected function replacePlaceholders(Server $server, object $configs): array + /** + * @param EggConfigurationFiles $configs the decoded "config.files" JSON structure for the egg + * @return EggConfigurationOutputs + */ + protected function replacePlaceholders(Server $server, array $configs): array { // Get the legacy configuration structure for the server so that we // can property map the egg placeholders to values. @@ -81,22 +98,12 @@ class EggConfigurationService // Normalize the output of the configuration for the new Wings Daemon to more // easily ingest, as well as make things more flexible down the road. foreach ($configs as $file => $data) { - // Try to head off any errors relating to parsing a set of configuration files - // or other JSON data for the egg. This should probably be blocked at the time - // of egg creation/update, but it isn't so this check will at least prevent a - // 500 error which would crash the entire Wings boot process. - // - // @see https://github.com/pterodactyl/panel/issues/3055 - if (!is_object($data) || !isset($data->find)) { - continue; - } + $replaceValues = []; - $append = array_merge((array) $data, ['file' => $file, 'replace' => []]); - - foreach ($this->iterate($data->find, $structure) as $find => $replace) { - if (is_object($replace)) { + foreach ($this->iterate($data['find'], $structure) as $find => $replace) { + if (is_array($replace)) { foreach ($replace as $match => $replaceWith) { - $append['replace'][] = [ + $replaceValues[] = [ 'match' => $find, 'if_value' => $match, 'replace_with' => $replaceWith, @@ -106,15 +113,18 @@ class EggConfigurationService continue; } - $append['replace'][] = [ + $replaceValues[] = [ 'match' => $find, 'replace_with' => $replace, ]; } - unset($append['find']); + unset($data['find']); - $response[] = $append; + $response[] = array_merge($data, [ + 'file' => $file, + 'replace' => $replaceValues, + ]); } return $response; @@ -128,31 +138,22 @@ class EggConfigurationService */ protected function replaceLegacyModifiers(string $key, string $value): string { - switch ($key) { - case 'config.docker.interface': - $replace = 'config.docker.network.interface'; - break; - case 'server.build.env.SERVER_MEMORY': - case 'env.SERVER_MEMORY': - $replace = 'server.build.memory'; - break; - case 'server.build.env.SERVER_IP': - case 'env.SERVER_IP': - $replace = 'server.build.default.ip'; - break; - case 'server.build.env.SERVER_PORT': - case 'env.SERVER_PORT': - $replace = 'server.build.default.port'; - break; - default: - // By default, we don't need to change anything, only if we ended up matching a specific legacy item. - $replace = $key; - } + $replace = match ($key) { + 'config.docker.interface' => 'config.docker.network.interface', + 'server.build.env.SERVER_MEMORY', 'env.SERVER_MEMORY' => 'server.build.memory', + 'server.build.env.SERVER_IP', 'env.SERVER_IP' => 'server.build.default.ip', + 'server.build.env.SERVER_PORT', 'env.SERVER_PORT' => 'server.build.default.port', + // By default, we don't need to change anything, only if we ended up matching a specific legacy item. + default => $key, + }; return str_replace("{{{$key}}}", "{{{$replace}}}", $value); } - protected function matchAndReplaceKeys(mixed $value, array $structure): mixed + /** + * @param array $structure the legacy server configuration structure + */ + protected function matchAndReplaceKeys(string $value, array $structure): string { preg_match_all('/{{(?[\w.-]*)}}/', $value, $matches); @@ -161,13 +162,7 @@ class EggConfigurationService // value from the server properties. // // The Daemon supports server.X, env.X, and config.X placeholders. - if (!Str::startsWith($key, ['server.', 'env.', 'config.'])) { - continue; - } - - // Don't do a replacement on anything that is not a string, we don't want to unintentionally - // modify the resulting output. - if (!is_string($value)) { + if (! Str::startsWith($key, ['server.', 'env.', 'config.'])) { continue; } @@ -183,9 +178,10 @@ class EggConfigurationService // Replace anything starting with "server." with the value out of the server configuration // array that used to be created for the old daemon. if (Str::startsWith($key, 'server.')) { - $plucked = Arr::get($structure, preg_replace('/^server\./', '', $key), ''); + $plucked = Arr::get($structure, Str::after($key, 'server.'), ''); + JsonValueGuard::assertValue($plucked); + $value = str_replace("{{{$key}}}", $this->placeholderValue($plucked), $value); - $value = str_replace("{{{$key}}}", $plucked, $value); continue; } @@ -193,11 +189,12 @@ class EggConfigurationService // variable from the server configuration. $plucked = Arr::get( $structure, - preg_replace('/^env\./', 'build.env.', $key), + 'build.env.'.Str::after($key, 'env.'), '' ); - $value = str_replace("{{{$key}}}", $plucked, $value); + JsonValueGuard::assertValue($plucked); + $value = str_replace("{{{$key}}}", $this->placeholderValue($plucked), $value); } return $value; @@ -207,33 +204,86 @@ class EggConfigurationService * Iterates over a set of "find" values for a given file in the parser configuration. If * the value of the line match is something iterable, continue iterating, otherwise perform * a match & replace. + * + * The egg config is decoded associatively (see handle()), so nested "find" values are + * always arrays rather than objects -- PHP arrays are copy-on-write, so mutating $data + * below only affects this function's local copy, never the caller's. + * + * @param array $data + * @param array $structure the legacy server configuration structure + * @return array */ private function iterate(mixed $data, array $structure): mixed { - if (!is_iterable($data) && !is_object($data)) { - return $data; - } - - // Remember, in PHP objects are always passed by reference, so if we do not clone this object - // instance we'll end up making modifications to the object outside the scope of this function - // which leads to some fun behavior in the parser. - if (is_array($data)) { - // Copy the array. - // NOTE: if the array contains any objects, they will be passed by reference. - $clone = $data; - } else { - $clone = clone $data; - } - foreach ($clone as $key => &$value) { - if (is_iterable($value) || is_object($value)) { - $value = $this->iterate($value, $structure); + return JsonValueTree::from($data) + ->mapStrings(fn (string $value): string => $this->matchAndReplaceKeys($value, $structure)) + ->toArray8(); + } + /** @return EggConfigurationFiles */ + private function configurationFiles(?string $encoded): array + { + $files = []; + foreach ($this->jsonObject($encoded) as $file => $value) { + if (! is_array($value)) { continue; } - $value = $this->matchAndReplaceKeys($value, $structure); + $configuration = []; + foreach ($value as $key => $entry) { + if (is_string($key)) { + $configuration[$key] = $entry; + } + } + + if (! isset($configuration['find']) || ! is_array($configuration['find'])) { + continue; + } + + $files[$file] = $configuration; } - return $clone; + return $files; + } + + /** @return array */ + private function jsonObject(?string $encoded): array + { + $value = JsonValueGuard::decode($encoded ?? '{}'); + if (! is_array($value)) { + return []; + } + + $object = []; + foreach ($value as $key => $entry) { + if (is_string($key)) { + $object[$key] = $entry; + } + } + + return $object; + } + + /** @param JsonInputValue $value */ + private function placeholderValue(mixed $value): string + { + if ($value === null) { + return ''; + } + + if (is_bool($value)) { + return $value ? '1' : ''; + } + + if (is_array($value)) { + return 'Array'; + } + + if ($value instanceof JsonEmptyObject) { + return 'Array'; + } + + // SAFETY: this preserves PHP's legacy scalar-to-string placeholder conversion after arrays, booleans, and null are handled explicitly. + return (string) $value; } } diff --git a/app/Services/Eggs/EggCreationService.php b/app/Services/Eggs/EggCreationService.php deleted file mode 100644 index 7379eae7c..000000000 --- a/app/Services/Eggs/EggCreationService.php +++ /dev/null @@ -1,46 +0,0 @@ -repository->findCountWhere([ - ['nest_id', '=', array_get($data, 'nest_id')], - ['id', '=', array_get($data, 'config_from')], - ]); - - if ($results !== 1) { - throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child')); - } - } - - return $this->repository->create(array_merge($data, [ - 'uuid' => Uuid::uuid4()->toString(), - 'author' => $this->config->get('pterodactyl.service.author'), - ]), true, true); - } -} diff --git a/app/Services/Eggs/EggDeletionService.php b/app/Services/Eggs/EggDeletionService.php deleted file mode 100644 index 50b4e1c6d..000000000 --- a/app/Services/Eggs/EggDeletionService.php +++ /dev/null @@ -1,41 +0,0 @@ -serverRepository->findCountWhere([['egg_id', '=', $egg]]); - if ($servers > 0) { - throw new HasActiveServersException(trans('exceptions.nest.egg.delete_has_servers')); - } - - $children = $this->repository->findCountWhere([['config_from', '=', $egg]]); - if ($children > 0) { - throw new HasChildrenException(trans('exceptions.nest.egg.has_children')); - } - - return $this->repository->delete($egg); - } -} diff --git a/app/Services/Eggs/EggImportData.php b/app/Services/Eggs/EggImportData.php new file mode 100644 index 000000000..769a9be3c --- /dev/null +++ b/app/Services/Eggs/EggImportData.php @@ -0,0 +1,225 @@ +|null $features + * @param array $dockerImages + * @param list $fileDenylist + * @param list $variables + */ + public function __construct( + public string $name, + public string $author, + public ?string $description, + public ?array $features, + public array $dockerImages, + public array $fileDenylist, + public ?string $updateUrl, + public ?string $configFiles, + public ?string $configStartup, + public ?string $configLogs, + public ?string $configStop, + public ?string $startup, + public ?string $scriptInstall, + public string $scriptEntry, + public string $scriptContainer, + public array $variables, + ) {} + + public static function fromJson(string $contents): self + { + return self::fromValue(JsonValueGuard::decodeArray8($contents)); + } + + /** @param JsonInputValue $value */ + private static function fromValue(mixed $value): self + { + $root = self::object($value, 'egg'); + $meta = self::object($root['meta'] ?? null, 'meta'); + $version = self::string($meta['version'] ?? null, 'meta.version'); + + if (! in_array($version, ['PTDL_v1', Egg::EXPORT_VERSION], true)) { + throw self::invalid('meta.version'); + } + + $config = self::object($root['config'] ?? null, 'config'); + $scripts = self::object($root['scripts'] ?? null, 'scripts'); + $installation = self::object($scripts['installation'] ?? null, 'scripts.installation'); + + return new self( + name: self::string($root['name'] ?? null, 'name'), + author: self::string($root['author'] ?? null, 'author'), + description: self::nullableString($root['description'] ?? null, 'description'), + features: self::nullableStringList($root['features'] ?? null, 'features'), + dockerImages: self::dockerImages($root, $version), + fileDenylist: self::fileDenylist($root['file_denylist'] ?? null), + updateUrl: self::nullableString($meta['update_url'] ?? null, 'meta.update_url'), + configFiles: self::nullableString($config['files'] ?? null, 'config.files'), + configStartup: self::nullableString($config['startup'] ?? null, 'config.startup'), + configLogs: self::nullableString($config['logs'] ?? null, 'config.logs'), + configStop: self::nullableString($config['stop'] ?? null, 'config.stop'), + startup: self::nullableString($root['startup'] ?? null, 'startup'), + scriptInstall: self::nullableString($installation['script'] ?? null, 'scripts.installation.script'), + scriptEntry: self::string($installation['entrypoint'] ?? null, 'scripts.installation.entrypoint'), + scriptContainer: self::string($installation['container'] ?? null, 'scripts.installation.container'), + variables: self::variables($root['variables'] ?? []), + ); + } + + /** + * @param array $root + * @return array + */ + private static function dockerImages(array $root, string $version): array + { + if ($version === Egg::EXPORT_VERSION) { + $images = self::object($root['docker_images'] ?? null, 'docker_images'); + $normalized = []; + foreach ($images as $label => $image) { + $normalized[$label] = self::string($image, 'docker_images.'.$label); + } + + return $normalized; + } + + $legacy = $root['images'] ?? $root['image'] ?? null; + $images = is_string($legacy) ? [$legacy] : self::stringList($legacy, 'images'); + $normalized = []; + foreach ($images as $image) { + $normalized[$image] = $image; + } + + return $normalized; + } + + /** + * @param JsonInputValue $value + * @return list + */ + private static function variables(mixed $value): array + { + if (! is_array($value) || ! array_is_list($value)) { + throw self::invalid('variables'); + } + + $variables = []; + foreach ($value as $index => $item) { + $variable = self::object($item, 'variables.'.$index); + $variables[] = new EggImportVariable( + name: self::string($variable['name'] ?? null, "variables.$index.name"), + description: self::string($variable['description'] ?? null, "variables.$index.description"), + environmentVariable: self::string($variable['env_variable'] ?? null, "variables.$index.env_variable"), + defaultValue: self::string($variable['default_value'] ?? null, "variables.$index.default_value"), + userViewable: self::boolean($variable['user_viewable'] ?? null, "variables.$index.user_viewable"), + userEditable: self::boolean($variable['user_editable'] ?? null, "variables.$index.user_editable"), + rules: self::string($variable['rules'] ?? null, "variables.$index.rules"), + ); + } + + return $variables; + } + + /** + * @param JsonInputValue $value + * @return list + */ + private static function fileDenylist(mixed $value): array + { + if ($value === null) { + return []; + } + + $values = is_string($value) ? [$value] : self::stringList($value, 'file_denylist'); + + return array_values(array_filter($values, fn (string $item): bool => ! empty($item))); + } + + /** + * @param JsonInputValue $value + * @return array + */ + private static function object(mixed $value, string $field): array + { + if (! is_array($value)) { + throw self::invalid($field); + } + + $object = []; + foreach ($value as $key => $item) { + if (! is_string($key)) { + throw self::invalid($field); + } + + $object[$key] = $item; + } + + return $object; + } + + /** @param JsonInputValue $value */ + private static function string(mixed $value, string $field): string + { + if (! is_string($value)) { + throw self::invalid($field); + } + + return $value; + } + + /** @param JsonInputValue $value */ + private static function nullableString(mixed $value, string $field): ?string + { + return $value === null ? null : self::string($value, $field); + } + + /** @param JsonInputValue $value */ + private static function boolean(mixed $value, string $field): bool + { + if (! is_bool($value)) { + throw self::invalid($field); + } + + return $value; + } + + /** + * @param JsonInputValue $value + * @return list|null + */ + private static function nullableStringList(mixed $value, string $field): ?array + { + return $value === null ? null : self::stringList($value, $field); + } + + /** + * @param JsonInputValue $value + * @return list + */ + private static function stringList(mixed $value, string $field): array + { + if (! is_array($value) || ! array_is_list($value)) { + throw self::invalid($field); + } + + $strings = []; + foreach ($value as $item) { + $strings[] = self::string($item, $field); + } + + return $strings; + } + + private static function invalid(string $field): InvalidFileUploadException + { + return new InvalidFileUploadException(sprintf('The egg field "%s" is missing or invalid.', $field)); + } +} diff --git a/app/Services/Eggs/EggImportVariable.php b/app/Services/Eggs/EggImportVariable.php new file mode 100644 index 000000000..2733f8e21 --- /dev/null +++ b/app/Services/Eggs/EggImportVariable.php @@ -0,0 +1,42 @@ + $this->name, + 'description' => $this->description, + 'env_variable' => $this->environmentVariable, + 'default_value' => $this->defaultValue, + 'user_viewable' => $this->userViewable, + 'user_editable' => $this->userEditable, + 'rules' => $this->rules, + ]; + } + + /** + * @return array{name: string, description: string, env_variable: string, default_value: string, user_viewable: bool, user_editable: bool, rules: string, egg_id: int} + */ + public function attributesForEgg(int $eggId): array + { + return array_merge($this->attributes(), ['egg_id' => $eggId]); + } +} diff --git a/app/Services/Eggs/EggParserService.php b/app/Services/Eggs/EggParserService.php index 75add2352..98b09b5dc 100644 --- a/app/Services/Eggs/EggParserService.php +++ b/app/Services/Eggs/EggParserService.php @@ -1,90 +1,52 @@ getError() !== UPLOAD_ERR_OK || !$file->isFile()) { - throw new InvalidFileUploadException('The selected file is not valid and cannot be imported.'); - } + throw_if($file->getError() !== UPLOAD_ERR_OK || ! $file->isFile(), InvalidFileUploadException::class, 'The selected file is not valid and cannot be imported.'); - /** @var array $parsed */ - $parsed = json_decode($file->openFile()->fread($file->getSize()), true, 512, JSON_THROW_ON_ERROR); - if (!in_array(Arr::get($parsed, 'meta.version') ?? '', ['PTDL_v1', 'PTDL_v2'])) { - throw new InvalidFileUploadException('The JSON file provided is not in a format that can be recognized.'); - } + $contents = $file->openFile()->fread($file->getSize()); + throw_if($contents === false, InvalidFileUploadException::class, 'The selected file could not be read.'); - return $this->convertToV2($parsed); + return EggImportData::fromJson($contents); } /** * Fills the provided model with the parsed JSON data. */ - public function fillFromParsed(Egg $model, array $parsed): Egg + public function fillFromParsed(Egg $model, EggImportData $parsed): Egg { return $model->forceFill([ - 'name' => Arr::get($parsed, 'name'), - 'description' => Arr::get($parsed, 'description'), - 'features' => Arr::get($parsed, 'features'), - 'docker_images' => Arr::get($parsed, 'docker_images'), - 'file_denylist' => Collection::make(Arr::get($parsed, 'file_denylist')) - ->filter(fn ($value) => !empty($value)), - 'update_url' => Arr::get($parsed, 'meta.update_url'), - 'config_files' => Arr::get($parsed, 'config.files'), - 'config_startup' => Arr::get($parsed, 'config.startup'), - 'config_logs' => Arr::get($parsed, 'config.logs'), - 'config_stop' => Arr::get($parsed, 'config.stop'), - 'startup' => Arr::get($parsed, 'startup'), - 'script_install' => Arr::get($parsed, 'scripts.installation.script'), - 'script_entry' => Arr::get($parsed, 'scripts.installation.entrypoint'), - 'script_container' => Arr::get($parsed, 'scripts.installation.container'), + 'name' => $parsed->name, + 'description' => $parsed->description, + 'features' => $parsed->features, + 'docker_images' => $parsed->dockerImages, + 'file_denylist' => $parsed->fileDenylist, + 'update_url' => $parsed->updateUrl, + 'config_files' => $parsed->configFiles, + 'config_startup' => $parsed->configStartup, + 'config_logs' => $parsed->configLogs, + 'config_stop' => $parsed->configStop, + 'startup' => $parsed->startup, + 'script_install' => $parsed->scriptInstall, + 'script_entry' => $parsed->scriptEntry, + 'script_container' => $parsed->scriptContainer, ]); } - - /** - * Converts a PTDL_V1 egg into the expected PTDL_V2 egg format. This just handles - * the "docker_images" field potentially not being present, and not being in the - * expected "key => value" format. - */ - protected function convertToV2(array $parsed): array - { - if (Arr::get($parsed, 'meta.version') === Egg::EXPORT_VERSION) { - return $parsed; - } - - // Maintain backwards compatability for eggs that are still using the old single image - // string format. New eggs can provide an array of Docker images that can be used. - if (!isset($parsed['images'])) { - $images = [Arr::get($parsed, 'image') ?? 'nil']; - } else { - $images = $parsed['images']; - } - - unset($parsed['images'], $parsed['image']); - - $parsed['docker_images'] = []; - foreach ($images as $image) { - $parsed['docker_images'][$image] = $image; - } - - $parsed['variables'] = array_map(function ($value) { - return array_merge($value, ['field_type' => 'text']); - }, $parsed['variables']); - - return $parsed; - } } diff --git a/app/Services/Eggs/EggUpdateService.php b/app/Services/Eggs/EggUpdateService.php deleted file mode 100644 index 64c2755be..000000000 --- a/app/Services/Eggs/EggUpdateService.php +++ /dev/null @@ -1,44 +0,0 @@ -repository->findCountWhere([ - ['nest_id', '=', $egg->nest_id], - ['id', '=', array_get($data, 'config_from')], - ]); - - if ($results !== 1) { - throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child')); - } - } - - // TODO(dane): Once the admin UI is done being reworked and this is exposed - // in said UI, remove this so that you can actually update the denylist. - unset($data['file_denylist']); - - $this->repository->withoutFreshModel()->update($egg->id, $data); - } -} diff --git a/app/Services/Eggs/Scripts/InstallScriptService.php b/app/Services/Eggs/Scripts/InstallScriptService.php deleted file mode 100644 index a6f24f0b1..000000000 --- a/app/Services/Eggs/Scripts/InstallScriptService.php +++ /dev/null @@ -1,41 +0,0 @@ -repository->isCopyableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) { - throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id')); - } - } - - $this->repository->withoutFreshModel()->update($egg->id, [ - 'script_install' => array_get($data, 'script_install'), - 'script_is_privileged' => array_get($data, 'script_is_privileged', 1), - 'script_entry' => array_get($data, 'script_entry'), - 'script_container' => array_get($data, 'script_container'), - 'copy_script_from' => array_get($data, 'copy_script_from'), - ]); - } -} diff --git a/app/Services/Eggs/Sharing/EggImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php deleted file mode 100644 index 997dc9236..000000000 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ /dev/null @@ -1,50 +0,0 @@ -parser->handle($file); - - /** @var Nest $nest */ - $nest = Nest::query()->with('eggs', 'eggs.variables')->findOrFail($nest); - - return $this->connection->transaction(function () use ($nest, $parsed) { - $egg = (new Egg())->forceFill([ - 'uuid' => Uuid::uuid4()->toString(), - 'nest_id' => $nest->id, - 'author' => Arr::get($parsed, 'author'), - 'copy_script_from' => null, - ]); - - $egg = $this->parser->fillFromParsed($egg, $parsed); - $egg->save(); - - foreach ($parsed['variables'] ?? [] as $variable) { - EggVariable::query()->forceCreate(array_merge($variable, ['egg_id' => $egg->id])); - } - - return $egg; - }); - } -} diff --git a/app/Services/Eggs/Sharing/EggUpdateImporterService.php b/app/Services/Eggs/Sharing/EggUpdateImporterService.php deleted file mode 100644 index 89a1f9287..000000000 --- a/app/Services/Eggs/Sharing/EggUpdateImporterService.php +++ /dev/null @@ -1,50 +0,0 @@ -parser->handle($file); - - return $this->connection->transaction(function () use ($egg, $parsed) { - $egg = $this->parser->fillFromParsed($egg, $parsed); - $egg->save(); - - // Update existing variables or create new ones. - foreach ($parsed['variables'] ?? [] as $variable) { - EggVariable::unguarded(function () use ($egg, $variable) { - $egg->variables()->updateOrCreate([ - 'env_variable' => $variable['env_variable'], - ], Collection::make($variable)->except('egg_id', 'env_variable')->toArray()); - }); - } - - $imported = array_map(fn ($value) => $value['env_variable'], $parsed['variables'] ?? []); - - $egg->variables()->whereNotIn('env_variable', $imported)->delete(); - - return $egg->refresh(); - }); - } -} diff --git a/app/Services/Eggs/Variables/VariableCreationService.php b/app/Services/Eggs/Variables/VariableCreationService.php deleted file mode 100644 index 601a3513a..000000000 --- a/app/Services/Eggs/Variables/VariableCreationService.php +++ /dev/null @@ -1,61 +0,0 @@ -validator; - } - - /** - * Create a new variable for a given Egg. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException - * @throws ReservedVariableNameException - */ - public function handle(int $egg, array $data): EggVariable - { - if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) { - throw new ReservedVariableNameException(sprintf('Cannot use the protected name %s for this environment variable.', array_get($data, 'env_variable'))); - } - - if (!empty($data['rules'] ?? '')) { - $this->validateRules($data['rules']); - } - - $options = array_get($data, 'options') ?? []; - - return $this->repository->create([ - 'egg_id' => $egg, - 'name' => $data['name'] ?? '', - 'description' => $data['description'] ?? '', - 'env_variable' => $data['env_variable'] ?? '', - 'default_value' => $data['default_value'] ?? '', - 'user_viewable' => in_array('user_viewable', $options), - 'user_editable' => in_array('user_editable', $options), - 'rules' => $data['rules'] ?? '', - ]); - } -} diff --git a/app/Services/Eggs/Variables/VariableUpdateService.php b/app/Services/Eggs/Variables/VariableUpdateService.php deleted file mode 100644 index c3ca303bd..000000000 --- a/app/Services/Eggs/Variables/VariableUpdateService.php +++ /dev/null @@ -1,79 +0,0 @@ -validator; - } - - /** - * Update a specific egg variable. - * - * @throws DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws ReservedVariableNameException - */ - public function handle(EggVariable $variable, array $data): mixed - { - if (!is_null(array_get($data, 'env_variable'))) { - if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) { - throw new ReservedVariableNameException(trans('exceptions.service.variables.reserved_name', ['name' => array_get($data, 'env_variable')])); - } - - $search = $this->repository->setColumns('id')->findCountWhere([ - ['env_variable', '=', $data['env_variable']], - ['egg_id', '=', $variable->egg_id], - ['id', '!=', $variable->id], - ]); - - if ($search > 0) { - throw new DisplayException(trans('exceptions.service.variables.env_not_unique', ['name' => array_get($data, 'env_variable')])); - } - } - - if (!empty($data['rules'] ?? '')) { - $this->validateRules( - (is_string($data['rules']) && Str::contains($data['rules'], ';;')) - ? explode(';;', $data['rules']) - : $data['rules'] - ); - } - - $options = array_get($data, 'options') ?? []; - - return $this->repository->withoutFreshModel()->update($variable->id, [ - 'name' => $data['name'] ?? '', - 'description' => $data['description'] ?? '', - 'env_variable' => $data['env_variable'] ?? '', - 'default_value' => $data['default_value'] ?? '', - 'user_viewable' => in_array('user_viewable', $options), - 'user_editable' => in_array('user_editable', $options), - 'rules' => $data['rules'] ?? '', - ]); - } -} diff --git a/app/Services/Extensions/Contracts/ManagesExtensionSettings.php b/app/Services/Extensions/Contracts/ManagesExtensionSettings.php new file mode 100644 index 000000000..2dbf4ae48 --- /dev/null +++ b/app/Services/Extensions/Contracts/ManagesExtensionSettings.php @@ -0,0 +1,17 @@ +> */ + private array $decorators = []; + + /** @var array */ + private array $extended = []; + + public function __construct( + private readonly Application $app, + private readonly ExtensionRepository $extensions, + ) {} + + /** + * @template TContract of object + * + * @param class-string $contract + * @param Closure(TContract): TContract $decorator + */ + public function register(string $identifier, string $contract, Closure $decorator, ExtensionRegistration $registration): void + { + throw_unless( + str_starts_with($contract, self::CONTRACT_NAMESPACE) && interface_exists($contract) && $this->app->bound($contract) && ! $this->app->isShared($contract), + InvalidArgumentException::class, + sprintf('Extension "%s" can only wrap action contracts under %s that the panel binds per caller; "%s" is not one.', $identifier, self::CONTRACT_NAMESPACE, $contract), + ); + + $this->decorators[$contract][] = ['identifier' => $identifier, 'decorator' => $decorator, 'registration' => $registration]; + if (isset($this->extended[$contract])) { + return; + } + + // Container extenders cannot be removed, so exactly one is installed per contract + // and it consults this registry: rolling a registration back only edits the list. + $this->extended[$contract] = true; + $this->app->extend($contract, (new ExtensionActionExtender($this, $contract))(...)); + } + + /** @return array> */ + public function snapshot(): array + { + return $this->decorators; + } + + /** @param array> $decorators */ + public function restore(array $decorators): void + { + $this->decorators = $decorators; + } + + /** + * Apply every decorator that is currently active to a freshly resolved action. + * + * @template TContract of object + * + * @param class-string $contract + * @param TContract $action + * @return TContract + */ + public function decorate(string $contract, object $action): object + { + foreach ($this->decorators[$contract] ?? [] as $entry) { + if (! $entry['registration']->isActive() || ! $this->extensions->isAvailable($entry['identifier'])) { + continue; + } + + try { + $decorated = $entry['decorator']($action); + throw_unless($decorated instanceof $contract, UnexpectedValueException::class, sprintf('The decorator for %s must return an implementation of that contract.', $contract)); + $action = $decorated; + } catch (Throwable $throwable) { + $this->extensions->recordFailure($entry['identifier'], $throwable->getMessage(), $throwable, 'action'); + } + } + + return $action; + } +} diff --git a/app/Services/Extensions/ExtensionActionExtender.php b/app/Services/Extensions/ExtensionActionExtender.php new file mode 100644 index 000000000..0a97a36c3 --- /dev/null +++ b/app/Services/Extensions/ExtensionActionExtender.php @@ -0,0 +1,29 @@ + $contract */ + public function __construct( + private ExtensionActionDecorators $decorators, + private string $contract, + ) {} + + /** + * @param TContract $action + * @return TContract + */ + public function __invoke(object $action): object + { + return $this->decorators->decorate($this->contract, $action); + } +} diff --git a/app/Services/Extensions/ExtensionAssetPublisher.php b/app/Services/Extensions/ExtensionAssetPublisher.php new file mode 100644 index 000000000..53c784e07 --- /dev/null +++ b/app/Services/Extensions/ExtensionAssetPublisher.php @@ -0,0 +1,166 @@ +currentVersion($manifest->id); + if ($version !== null) { + return sprintf('/assets/extensions/%s/%s/client.js', $manifest->id, $version); + } + + return sprintf('/assets/extensions/%s/client.js?v=%s', $manifest->id, Str::slug($manifest->version)); + } + + public function publish(ExtensionManifest $manifest): void + { + $version = $this->stage($manifest); + if ($version !== null) { + $this->activate($manifest->id, $version); + } + } + + /** @param Closure(): void $callback */ + public function publishWith(ExtensionManifest $manifest, Closure $callback): void + { + $previous = $this->currentVersion($manifest->id); + + try { + $this->publish($manifest); + $callback(); + } catch (Throwable $throwable) { + rescue(fn () => $this->activate($manifest->id, $previous)); + + throw $throwable; + } + } + + public function stage(ExtensionManifest $manifest): ?string + { + if (! $manifest->hasUi()) { + return null; + } + + throw_if($reason = $this->unusableBuildReason($manifest), InvalidExtensionException::class, $reason); + $dist = $manifest->path('dist'); + $files = File::allFiles($dist); + usort($files, fn (SplFileInfo $left, SplFileInfo $right): int => strcmp($left->getRelativePathname(), $right->getRelativePathname())); + $hash = hash_init('sha256'); + foreach ($files as $file) { + hash_update($hash, $file->getRelativePathname()."\0"); + hash_update_file($hash, $file->getPathname()); + } + + $version = hash_final($hash); + $root = $this->publishedPath($manifest->id); + $target = $root.DIRECTORY_SEPARATOR.$version; + if (! is_dir($target)) { + $staged = $root.DIRECTORY_SEPARATOR.'.staging-'.Str::random(12); + File::ensureDirectoryExists($root); + try { + throw_unless(File::copyDirectory($dist, $staged), InvalidExtensionException::class, 'Unable to stage extension assets.'); + throw_unless(File::moveDirectory($staged, $target), InvalidExtensionException::class, 'Unable to publish extension assets.'); + } finally { + File::deleteDirectory($staged); + } + } + + return $version; + } + + public function currentVersion(string $identifier): ?string + { + $path = $this->publishedPath($identifier).DIRECTORY_SEPARATOR.'_current'; + if (! is_file($path)) { + return null; + } + + $version = mb_trim(File::get($path)); + + return preg_match('/^[a-f0-9]{64}$/', $version) ? $version : null; + } + + public function activate(string $identifier, ?string $version): void + { + $path = $this->publishedPath($identifier).DIRECTORY_SEPARATOR.'_current'; + if ($version === null) { + File::delete($path); + $this->stopDevelopment($identifier); + } else { + File::replace($path, $version); + if (is_file($this->developmentPath($identifier))) { + File::replace($this->developmentPath($identifier), $version); + } + } + } + + public function missingBuildReason(ExtensionManifest $manifest): ?string + { + if (! $manifest->hasUi()) { + return null; + } + + if (! is_file($manifest->path($manifest->uiEntry ?? ExtensionManifest::UI_ENTRY))) { + return "Extension \"{$manifest->id}\" declares ui.entry \"{$manifest->uiEntry}\" but the built file is missing - build the extension before installing."; + } + + return null; + } + + /** Why the built frontend cannot be published: it is missing, or its styles would override the panel's or another extension's. */ + public function unusableBuildReason(ExtensionManifest $manifest): ?string + { + if (! $manifest->hasUi()) { + return null; + } + + return $this->missingBuildReason($manifest) ?? $this->stylesheets->conflictReason($manifest); + } + + public function publishedPath(string $identifier): string + { + return mb_rtrim(JsonValueGuard::string(config('extensions.assets_directory')), '/\\').DIRECTORY_SEPARATOR.$identifier; + } + + public function watchDevelopment(string $identifier): void + { + $version = $this->currentVersion($identifier); + throw_if($version === null, InvalidExtensionException::class, 'Publish a frontend build before watching it.'); + File::replace($this->developmentPath($identifier), $version); + } + + public function stopDevelopment(string $identifier): void + { + File::delete($this->developmentPath($identifier)); + } + + /** @return array{url: string, version: string}|null */ + public function developmentPayload(string $identifier): ?array + { + $version = $this->currentVersion($identifier); + if (! config('app.debug') || $version === null || ! is_file($this->developmentPath($identifier))) { + return null; + } + + return ['url' => '/assets/extensions/'.$identifier.'/_development', 'version' => $version]; + } + + private function developmentPath(string $identifier): string + { + return $this->publishedPath($identifier).DIRECTORY_SEPARATOR.'_development'; + } +} diff --git a/app/Services/Extensions/ExtensionCompatibility.php b/app/Services/Extensions/ExtensionCompatibility.php new file mode 100644 index 000000000..f12bbac4b --- /dev/null +++ b/app/Services/Extensions/ExtensionCompatibility.php @@ -0,0 +1,136 @@ + $enabled + * @return array{manifests: Collection, errors: array} + */ + public function resolve(Collection $enabled): array + { + $remaining = $enabled->all(); + $accepted = []; + $errors = []; + foreach ($remaining as $id => $manifest) { + $reason = $this->failureReason($manifest, $enabled); + if ($reason !== null) { + $errors[$id] = $reason; + unset($remaining[$id]); + } + } + + while ($remaining !== []) { + $progress = false; + foreach ($remaining as $id => $manifest) { + $dependencies = array_keys($manifest->requiredExtensions); + $failed = array_intersect($dependencies, array_keys($errors)); + if ($failed !== []) { + $errors[$id] = sprintf('Extension "%s" requires unavailable extension "%s".', $id, reset($failed)); + } elseif (array_diff($dependencies, array_keys($accepted)) === []) { + $accepted[$id] = $manifest; + } else { + continue; + } + + unset($remaining[$id]); + $progress = true; + } + + if (! $progress) { + foreach (array_keys($remaining) as $id) { + $errors[$id] = sprintf('Extension "%s" has a circular extension dependency.', $id); + } + + break; + } + } + + return ['manifests' => collect($accepted), 'errors' => $errors]; + } + + /** @param Collection $enabled */ + public function assertCompatible(ExtensionManifest $manifest, Collection $enabled): void + { + $errors = $this->resolve((clone $enabled)->put($manifest->id, $manifest))['errors']; + // A claim both sides make is reported from the side of the extension being checked. + $reason = $errors[$manifest->id] ?? reset($errors); + throw_if($reason !== false, InvalidExtensionException::class, $reason); + } + + /** @param Collection $enabled */ + public function assertCanDisable(string $identifier, Collection $enabled): void + { + foreach ($enabled as $manifest) { + throw_if(isset($manifest->requiredExtensions[$identifier]), InvalidExtensionException::class, "Disable dependent extension \"{$manifest->id}\" before \"{$identifier}\"."); + } + } + + public function assertRuntimeCompatible(ExtensionManifest $manifest): void + { + $reason = $this->runtimeFailureReason($manifest); + throw_if($reason !== null, InvalidExtensionException::class, $reason); + } + + /** @param Collection $enabled */ + private function failureReason(ExtensionManifest $manifest, Collection $enabled): ?string + { + $reason = $this->runtimeFailureReason($manifest); + if ($reason !== null) { + return $reason; + } + + foreach ($enabled as $other) { + if ($other->id === $manifest->id) { + continue; + } + + $conflicts = array_intersect($manifest->components, $other->components); + if ($conflicts !== []) { + return sprintf('Extension "%s" cannot replace "%s": enabled extension "%s" also declares it.', $manifest->id, reset($conflicts), $other->id); + } + + $prefixes = array_intersect($manifest->rootPrefixes, $other->rootPrefixes); + if ($prefixes !== []) { + return sprintf('Extension "%s" cannot claim root path "/%s": enabled extension "%s" also declares it.', $manifest->id, reset($prefixes), $other->id); + } + + if ($manifest->uiPrefix !== null && $manifest->uiPrefix === $other->uiPrefix) { + return sprintf('Extension "%s" cannot use Tailwind prefix "%s": enabled extension "%s" also declares it.', $manifest->id, $manifest->uiPrefix, $other->id); + } + } + + foreach ($manifest->requiredExtensions as $id => $constraint) { + $dependency = $enabled->get($id); + if ($dependency === null || ! Semver::satisfies($dependency->version, $constraint)) { + return sprintf('Extension "%s" requires enabled extension "%s" %s.', $manifest->id, $id, $constraint); + } + } + + return null; + } + + private function runtimeFailureReason(ExtensionManifest $manifest): ?string + { + $versions = [ + 'panel' => JsonValueGuard::string(config('extensions.panel_version')), + 'sdk' => JsonValueGuard::string(config('extensions.sdk_version')), + 'php' => PHP_VERSION, + ]; + foreach ($manifest->requirements as $runtime => $constraint) { + if (! Semver::satisfies($versions[$runtime], $constraint)) { + return sprintf('Extension "%s" requires %s %s; installed version is %s.', $manifest->id, $runtime, $constraint, $versions[$runtime]); + } + } + + return null; + } +} diff --git a/app/Services/Extensions/ExtensionConsoleRegistry.php b/app/Services/Extensions/ExtensionConsoleRegistry.php new file mode 100644 index 000000000..c79e12a98 --- /dev/null +++ b/app/Services/Extensions/ExtensionConsoleRegistry.php @@ -0,0 +1,112 @@ +>> */ + private array $commands = []; + + /** @var array> */ + private array $schedules = []; + + public function __construct(private readonly ExtensionRepository $extensions) {} + + /** @param list $classes */ + public function registerCommands(string $identifier, array $classes): void + { + $commands = []; + foreach ($classes as $class) { + throw_unless(is_subclass_of($class, Command::class), InvalidArgumentException::class, sprintf('Extension "%s" registered "%s", which is not a console command.', $identifier, $class)); + $commands[] = $class; + } + + $this->commands[$identifier] = array_values(array_unique([...$this->commands[$identifier] ?? [], ...$commands])); + } + + /** @param Closure(Schedule): void $callback */ + public function registerSchedule(string $identifier, Closure $callback): void + { + $this->schedules[$identifier][] = $callback; + } + + /** Hand the commands of every available extension to the starting console application. */ + public function resolveCommands(Artisan $artisan): void + { + foreach ($this->commands as $identifier => $commands) { + if (! $this->extensions->isAvailable($identifier)) { + continue; + } + + try { + $artisan->resolveCommands($commands); + } catch (Throwable $throwable) { + $this->extensions->recordFailure($identifier, $throwable->getMessage(), $throwable, 'command'); + } + } + } + + /** + * Let every available extension define its scheduled tasks. Each task an extension + * defines only runs while that extension is still enabled, and a failed run is + * recorded against the extension. An extension whose callback throws schedules nothing. + */ + public function schedule(Schedule $schedule): void + { + foreach ($this->schedules as $identifier => $callbacks) { + if (! $this->extensions->isAvailable($identifier)) { + continue; + } + + foreach ($callbacks as $callback) { + $defined = count($schedule->events()); + $failure = null; + try { + $callback($schedule); + } catch (Throwable $throwable) { + $failure = $throwable; + $this->extensions->recordFailure($identifier, $throwable->getMessage(), $throwable, 'schedule'); + } + + foreach (array_slice($schedule->events(), $defined) as $event) { + // Events cannot be removed from the schedule again, so a half-defined + // set is kept from ever running instead. + $event->skip($failure instanceof Throwable) + ->when(fn (): bool => $this->extensions->isAvailable($identifier)) + ->onFailure(function () use ($identifier, $event): void { + $this->extensions->recordFailure($identifier, sprintf('Scheduled task "%s" failed.', $event->getSummaryForDisplay()), phase: 'schedule'); + }); + } + } + } + } + + /** @return array{commands: array>>, schedules: array>} */ + public function snapshot(): array + { + return ['commands' => $this->commands, 'schedules' => $this->schedules]; + } + + /** @param array{commands: array>>, schedules: array>} $snapshot */ + public function restore(array $snapshot): void + { + $this->commands = $snapshot['commands']; + $this->schedules = $snapshot['schedules']; + } +} diff --git a/app/Services/Extensions/ExtensionFailureAttributor.php b/app/Services/Extensions/ExtensionFailureAttributor.php new file mode 100644 index 000000000..d2e8d0595 --- /dev/null +++ b/app/Services/Extensions/ExtensionFailureAttributor.php @@ -0,0 +1,73 @@ +attributing || ! config('extensions.enabled')) { + return; + } + + $this->attributing = true; + try { + $identifier = $this->owner($throwable); + if ($identifier !== null) { + $this->extensions->recordFailure($identifier, $throwable->getMessage(), $throwable); + } + } catch (Throwable) { + // Attribution is best effort and must never mask the exception being reported. + } finally { + $this->attributing = false; + } + } + + private function normalize(string $path): string + { + return mb_rtrim(str_replace('\\', '/', $path), '/'); + } + + private function owner(Throwable $throwable): ?string + { + $vendor = $this->normalize(base_path('vendor')).'/'; + foreach ([$throwable->getFile(), ...array_column($throwable->getTrace(), 'file')] as $file) { + $file = $this->normalize($file); + if (str_starts_with($file, $vendor)) { + continue; + } + + foreach ($this->extensions->enabled() as $manifest) { + foreach (array_unique([$manifest->directory, realpath($manifest->directory) ?: $manifest->directory]) as $directory) { + if (str_starts_with($file, $this->normalize($directory).'/')) { + return $manifest->id; + } + } + } + + return null; + } + + return null; + } +} diff --git a/app/Services/Extensions/ExtensionHeadTag.php b/app/Services/Extensions/ExtensionHeadTag.php new file mode 100644 index 000000000..37aa5dae1 --- /dev/null +++ b/app/Services/Extensions/ExtensionHeadTag.php @@ -0,0 +1,149 @@ +` or `` element an extension adds to the panel's document + * head. Only these two void elements exist here: there is no way to express a script, a + * stylesheet, inline style or an event handler, and every attribute comes from a fixed + * allow-list and is escaped when rendered. + */ +final readonly class ExtensionHeadTag +{ + /** The most tags a single extension may register. */ + public const int LIMIT = 32; + + /** @var array<'meta'|'link', list> */ + public const array ATTRIBUTES = [ + 'meta' => ['name', 'property', 'content', 'media'], + 'link' => ['rel', 'href', 'sizes', 'type', 'media', 'color', 'crossorigin', 'hreflang', 'title'], + ]; + + /** Link relations that cannot load or execute anything in the page. */ + public const array LINK_RELATIONS = [ + 'manifest', + 'icon', + 'shortcut icon', + 'apple-touch-icon', + 'apple-touch-icon-precomposed', + 'apple-touch-startup-image', + 'mask-icon', + 'alternate', + 'canonical', + 'search', + 'preconnect', + 'dns-prefetch', + ]; + + /** Meta names the panel owns; `http-equiv` and `charset` are not expressible at all. */ + public const array RESERVED_META_NAMES = ['csrf-token', 'viewport', 'robots', 'referrer']; + + /** Elements of which a document should only carry one: an extension's replaces the panel's. */ + private const array SINGLETON_LINK_RELATIONS = ['manifest', 'canonical', 'mask-icon', 'apple-touch-icon', 'shortcut icon']; + + private const string TOKEN_REGEX = '/^[A-Za-z0-9][A-Za-z0-9:._-]{0,63}$/'; + + /** Printable text only: no control characters, so a value can never break out of its line. */ + private const string TEXT_REGEX = '/^[^\x00-\x1F\x7F]*$/u'; + + /** An absolute http(s) URL or a path on this panel (never protocol-relative). */ + private const string URL_REGEX = '~^(?:https?://[^\s/?#\\\\]+(?:[/?#][^\s\\\\]*)?|/(?![/\\\\])[^\s\\\\]*)$~i'; + + /** + * @param 'meta'|'link' $tag + * @param array $attributes + */ + private function __construct( + public string $tag, + public array $attributes, + ) {} + + /** + * @param array $entry `['tag' => 'meta'|'link', => , ...]` + * + * @throws InvalidArgumentException + */ + public static function fromArray(array $entry): self + { + $tag = $entry['tag'] ?? null; + throw_unless($tag === 'meta' || $tag === 'link', InvalidArgumentException::class, 'Head tags must set "tag" to "meta" or "link".'); + + $text = ['string', 'max:2048', 'regex:'.self::TEXT_REGEX]; + $validator = Validator::make($entry, $tag === 'meta' ? [ + 'tag' => ['required'], + 'name' => ['required_without:property', 'prohibits:property', 'string', 'regex:'.self::TOKEN_REGEX], + 'property' => ['required_without:name', 'string', 'regex:'.self::TOKEN_REGEX], + 'content' => ['present', ...$text], + 'media' => ['sometimes', 'required', ...$text], + ] : [ + 'tag' => ['required'], + 'rel' => ['required', 'string', Rule::in(self::LINK_RELATIONS)], + 'href' => ['required', ...$text, 'regex:'.self::URL_REGEX], + 'sizes' => ['sometimes', 'required', 'string', 'regex:/^(?:any|[1-9][0-9]{0,4}x[1-9][0-9]{0,4})(?: [1-9][0-9]{0,4}x[1-9][0-9]{0,4})*$/i'], + 'type' => ['sometimes', 'required', 'string', 'regex:~^[a-z0-9][a-z0-9.+-]{0,63}/[a-z0-9][a-z0-9.+-]{0,63}$~i'], + 'media' => ['sometimes', 'required', ...$text], + 'color' => ['sometimes', 'required', 'string', 'max:64', 'regex:/^[#A-Za-z0-9(),.% -]+$/'], + 'crossorigin' => ['sometimes', 'required', 'string', 'in:anonymous,use-credentials'], + 'hreflang' => ['sometimes', 'required', 'string', 'regex:/^[A-Za-z0-9-]{1,35}$/'], + 'title' => ['sometimes', 'required', ...$text], + ]); + + $unknown = array_diff(array_keys($entry), ['tag', ...self::ATTRIBUTES[$tag]]); + throw_if($unknown !== [], InvalidArgumentException::class, sprintf('Head tag <%s> does not support the "%s" attribute.', $tag, reset($unknown))); + throw_if($validator->fails(), InvalidArgumentException::class, sprintf('Invalid <%s> head tag: %s', $tag, $validator->errors()->first())); + + $attributes = []; + foreach (self::ATTRIBUTES[$tag] as $attribute) { + $value = $validator->validated()[$attribute] ?? null; + if ($value !== null) { + $attributes[$attribute] = JsonValueGuard::string($value); + } + } + + throw_if(in_array(mb_strtolower($attributes['name'] ?? ''), self::RESERVED_META_NAMES, true), InvalidArgumentException::class, sprintf('The "%s" meta tag is managed by the panel.', $attributes['name'] ?? '')); + + return new self($tag, $attributes); + } + + /** + * What this element is, for de-duplication: a meta name/property, a link relation that + * a document should carry once, or otherwise the exact element. + */ + public function identity(): string + { + if ($this->tag === 'meta') { + return 'meta:'.mb_strtolower($this->attributes['name'] ?? $this->attributes['property'] ?? ''); + } + + $relation = mb_strtolower($this->attributes['rel'] ?? ''); + + return in_array($relation, self::SINGLETON_LINK_RELATIONS, true) + ? 'link:'.$relation + : 'link:'.$relation.':'.implode('|', $this->attributes); + } + + /** The key core's own head elements are looked up by, e.g. `meta:theme-color` or `link:icon`. */ + public function replaces(): string + { + return $this->tag === 'meta' + ? $this->identity() + : 'link:'.mb_strtolower($this->attributes['rel'] ?? ''); + } + + public function toHtml(): string + { + $html = '<'.$this->tag; + foreach ($this->attributes as $name => $value) { + $html .= ' '.$name.'="'.e($value).'"'; + } + + return $html.'>'; + } +} diff --git a/app/Services/Extensions/ExtensionHeadTags.php b/app/Services/Extensions/ExtensionHeadTags.php new file mode 100644 index 000000000..4589a959e --- /dev/null +++ b/app/Services/Extensions/ExtensionHeadTags.php @@ -0,0 +1,176 @@ +|Closure}> */ + private array $sources = []; + + /** @var list|null */ + private ?array $resolved = null; + + public function __construct(private readonly ExtensionRepository $extensions) {} + + /** + * @param array|Closure $tags + * + * @throws InvalidArgumentException|UnexpectedValueException + */ + public function register(string $identifier, string $version, array|Closure $tags): void + { + $this->sources[$identifier] = ['version' => $version, 'tags' => $tags instanceof Closure ? $tags : $this->parse($tags)]; + $this->resolved = null; + } + + /** Drop the cached result of an extension's closure so the next render resolves it again. */ + public function forget(string $identifier): void + { + $source = $this->sources[$identifier] ?? null; + if ($source !== null) { + Cache::forget($this->cacheKey($identifier, $source['version'])); + } + + $this->resolved = null; + } + + /** + * Whether an extension supplies its own version of one of the panel's default head + * elements, e.g. `replaces('meta', 'theme-color')` or `replaces('link', 'manifest')`. + */ + public function replaces(string $tag, string $key): bool + { + $needle = $tag.':'.$key; + foreach ($this->tags() as $candidate) { + if ($candidate->replaces() === $needle) { + return true; + } + } + + return false; + } + + public function toHtml(): string + { + return implode("\n", array_map(fn (ExtensionHeadTag $tag): string => $tag->toHtml(), $this->tags())); + } + + /** @return array|Closure}> */ + public function snapshot(): array + { + return $this->sources; + } + + /** @param array|Closure}> $sources */ + public function restore(array $sources): void + { + $this->sources = $sources; + $this->resolved = null; + } + + /** + * @param array $tags + * @return list + * + * @throws InvalidArgumentException|UnexpectedValueException + */ + private function parse(array $tags): array + { + throw_if(count($tags) > ExtensionHeadTag::LIMIT, InvalidArgumentException::class, sprintf('An extension may register at most %d head tags.', ExtensionHeadTag::LIMIT)); + + $parsed = []; + foreach ($tags as $tag) { + $parsed[] = ExtensionHeadTag::fromArray(JsonValueGuard::jsonArray($tag)); + } + + return $parsed; + } + + private function cacheKey(string $identifier, string $version): string + { + return 'extensions:head:'.$identifier.':'.$version; + } + + /** + * Every available extension's elements, the first registration of an element winning. + * + * @return list + */ + private function tags(): array + { + if ($this->resolved !== null) { + return $this->resolved; + } + + $tags = []; + foreach ($this->sources as $identifier => $source) { + try { + if (! $this->extensions->isAvailable($identifier)) { + continue; + } + + foreach ($source['tags'] instanceof Closure ? $this->resolve($identifier, $source['version'], $source['tags']) : $source['tags'] as $tag) { + $tags[$tag->identity()] ??= $tag; + } + } catch (Throwable $throwable) { + rescue(fn () => $this->extensions->recordFailure($identifier, $throwable->getMessage(), $throwable, 'head'), report: false); + } + } + + return $this->resolved = array_values($tags); + } + + /** + * @return list + */ + private function resolve(string $identifier, string $version, Closure $tags): array + { + $key = $this->cacheKey($identifier, $version); + $seconds = JsonValueGuard::integer(config('extensions.head_tags_cache_seconds')); + $cached = $seconds > 0 ? Cache::get($key) : null; + if ($cached !== null) { + return $this->parse(JsonValueGuard::jsonArray($cached)); + } + + try { + $parsed = $this->parse(JsonValueGuard::jsonArray($tags())); + } catch (Throwable $throwable) { + // Remember the failure too, or a broken callback would run on every page load. + $this->remember($key, $seconds, []); + + throw $throwable; + } + + $this->remember($key, $seconds, array_map(fn (ExtensionHeadTag $tag): array => ['tag' => $tag->tag, ...$tag->attributes], $parsed)); + + return $parsed; + } + + /** @param list> $tags */ + private function remember(string $key, int $seconds, array $tags): void + { + if ($seconds > 0) { + Cache::put($key, $tags, $seconds); + } + } +} diff --git a/app/Services/Extensions/ExtensionIconCatalog.php b/app/Services/Extensions/ExtensionIconCatalog.php new file mode 100644 index 000000000..a57e62351 --- /dev/null +++ b/app/Services/Extensions/ExtensionIconCatalog.php @@ -0,0 +1,41 @@ + + */ + public function unknownIcons(ExtensionManifest $manifest): array + { + $declared = []; + foreach ($manifest->screens as $screen) { + if (isset($screen['nav']['icon'])) { + $declared[] = $screen['nav']['icon']; + } + } + + return array_values(array_unique(array_diff($declared, $this->names()))); + } + + /** @return list */ + public function names(): array + { + return JsonValueGuard::stringList(File::json(base_path(self::PATH))); + } +} diff --git a/app/Services/Extensions/ExtensionJobProgress.php b/app/Services/Extensions/ExtensionJobProgress.php new file mode 100644 index 000000000..2f4fa4bef --- /dev/null +++ b/app/Services/Extensions/ExtensionJobProgress.php @@ -0,0 +1,80 @@ +toString(), $extension, $user->uuid, $server?->uuid, $permission, 'running', 0, '', 1, now()->toIso8601String()); + $this->store($snapshot); + + return $snapshot; + } + + /** @param 'running'|'completed'|'failed' $status */ + public function update(string $extension, string $id, int $percent, string $message = '', string $status = 'running'): ExtensionJobSnapshot + { + throw_if($percent < 0 || $percent > 100 || mb_strlen($message) > 1000, InvalidArgumentException::class, 'Invalid progress update.'); + + $lock = Cache::lock($this->key($extension, $id).':lock', 10); + $lock->block(5); + try { + $previous = $this->find($extension, $id); + throw_if(! $previous instanceof ExtensionJobSnapshot, InvalidArgumentException::class, 'Progress has expired or does not exist.'); + throw_if($previous->status !== 'running', InvalidArgumentException::class, 'Completed progress cannot be updated.'); + throw_if($percent < $previous->percent, InvalidArgumentException::class, 'Progress cannot move backwards.'); + $snapshot = new ExtensionJobSnapshot($id, $extension, $previous->userUuid, $previous->serverUuid, $previous->permission, $status, $status === 'completed' ? 100 : $percent, $message, $previous->sequence + 1, now()->toIso8601String()); + $this->store($snapshot); + + return $snapshot; + } finally { + $lock->release(); + } + } + + public function find(string $extension, string $id): ?ExtensionJobSnapshot + { + $snapshot = Cache::get($this->key($extension, $id)); + + ExtensionJobSnapshot::assertCacheValue($snapshot); + + return $snapshot; + } + + public function visible(string $extension, string $id, User $user, ?Server $server = null): ExtensionJobSnapshot + { + $snapshot = $this->find($extension, $id); + abort_if(! $snapshot instanceof ExtensionJobSnapshot || $snapshot->serverUuid !== $server?->uuid, 404); + if (! $server instanceof Server || $snapshot->permission === null) { + abort_unless($snapshot->userUuid === $user->uuid || $user->root_admin, 404); + } else { + abort_unless($user->can($snapshot->permission, $server), 404); + } + + return $snapshot; + } + + private function store(ExtensionJobSnapshot $snapshot): void + { + Cache::put($this->key($snapshot->extension, $snapshot->id), $snapshot, max(60, JsonValueGuard::integer(config('extensions.progress_retention_seconds')))); + } + + private function key(string $extension, string $id): string + { + return 'extensions:progress:'.hash('sha256', $extension.'\0'.$id); + } +} diff --git a/app/Services/Extensions/ExtensionLock.php b/app/Services/Extensions/ExtensionLock.php new file mode 100644 index 000000000..4cff8325e --- /dev/null +++ b/app/Services/Extensions/ExtensionLock.php @@ -0,0 +1,68 @@ + */ + private array $locks = []; + + private int $depth = 0; + + /** + * @template T of object|ApiValue10|void + * + * @param Closure(): T $callback + * @return T + */ + public function run(string $identifier, Closure $callback): mixed + { + $this->acquire($identifier); + + try { + return $callback(); + } finally { + $this->release(); + } + } + + public function acquire(string $identifier): void + { + if (isset($this->locks['packages'])) { + $this->depth++; + + return; + } + + $directory = mb_rtrim(JsonValueGuard::string(config('extensions.directory')), '/\\').DIRECTORY_SEPARATOR.'.locks'; + File::ensureDirectoryExists($directory); + $lock = fopen($directory.DIRECTORY_SEPARATOR.'packages', 'c'); + throw_if($lock === false, InvalidExtensionException::class, 'Unable to lock extension package.'); + if (! flock($lock, LOCK_EX | LOCK_NB)) { + fclose($lock); + throw new InvalidExtensionException("Another operation is updating extensions; cannot update \"{$identifier}\" yet."); + } + + $this->locks['packages'] = $lock; + $this->depth = 1; + } + + public function release(): void + { + if (--$this->depth > 0) { + return; + } + + $lock = $this->locks['packages']; + unset($this->locks['packages']); + flock($lock, LOCK_UN); + fclose($lock); + } +} diff --git a/app/Services/Extensions/ExtensionManager.php b/app/Services/Extensions/ExtensionManager.php new file mode 100644 index 000000000..0b25ad9ca --- /dev/null +++ b/app/Services/Extensions/ExtensionManager.php @@ -0,0 +1,88 @@ +extensions->directory(); + } + + /** + * @return Collection + */ + public function discovered(): Collection + { + return $this->extensions->discovered(); + } + + /** + * @return array + */ + public function discoveryErrors(): array + { + return $this->extensions->discoveryErrors(); + } + + public function flushDiscovery(): void + { + $this->extensions->flushDiscovery(); + } + + /** + * @return Collection + */ + public function records(): Collection + { + return $this->extensions->records(); + } + + /** + * @return Collection + */ + public function enabled(): Collection + { + return $this->extensions->enabled(); + } + + /** + * @return array + */ + public function frontendPayload(bool $authenticated): array + { + return $this->extensions->frontendPayload($authenticated); + } + + public function registerProviders(): void + { + $this->providers->registerProviders($this->enabled()); + } + + public function bootProviders(): void + { + $this->providers->bootProviders(); + } + + public function settings(string $identifier): ExtensionSettings + { + return $this->extensions->settings($identifier); + } +} diff --git a/app/Services/Extensions/ExtensionManifest.php b/app/Services/Extensions/ExtensionManifest.php new file mode 100644 index 000000000..450db1b2c --- /dev/null +++ b/app/Services/Extensions/ExtensionManifest.php @@ -0,0 +1,164 @@ + PSR-4 prefix => relative source directory */ + public readonly array $autoload, + public readonly ?string $uiEntry, + public readonly string $uiMode, + /** @var list */ + public readonly array $screens, + /** @var list */ + public readonly array $components, + /** @var array<'panel'|'sdk'|'php', string> */ + public readonly array $requirements, + /** @var array */ + public readonly array $requiredExtensions, + /** @var list top-level URL prefixes claimed under `routes.root` */ + public readonly array $rootPrefixes = [], + /** The Tailwind prefix this extension builds its utilities and theme variables with. */ + public readonly ?string $uiPrefix = null, + ) {} + + /** + * @param ExtensionManifestInput $data + * @param array $autoload + */ + public static function fromValidatedData( + string $directory, + array $data, + array $autoload, + ?string $uiEntry, + string $uiMode, + ?string $provider, + ): self { + return new self( + directory: mb_rtrim($directory, '/\\'), + id: $data['id'], + name: $data['name'], + version: $data['version'], + description: is_string($data['description'] ?? null) ? $data['description'] : null, + author: is_string($data['author'] ?? null) ? $data['author'] : null, + provider: $provider, + autoload: $autoload, + uiEntry: $uiEntry, + uiMode: $uiMode, + screens: $data['ui']['screens'] ?? [], + components: $data['ui']['components'] ?? [], + requirements: array_intersect_key($data['requires'] ?? [], ['panel' => true, 'sdk' => true, 'php' => true]), + requiredExtensions: $data['requires']['extensions'] ?? [], + rootPrefixes: $data['routes']['root'] ?? [], + uiPrefix: $data['ui']['prefix'] ?? null, + ); + } + + /** Whether a Tailwind prefix is well formed and not reserved; uniqueness is compared when an extension is enabled. */ + public static function isUsableUiPrefix(string $prefix): bool + { + return preg_match(self::UI_PREFIX_REGEX, $prefix) === 1 && ! in_array($prefix, self::RESERVED_UI_PREFIXES, true); + } + + /** + * The prefix suggested for an extension id: the initials of its words (`hello-world` + * gives `hw`), else its letters, else its letters followed by `ui` when both are + * too short or reserved. + */ + public static function defaultUiPrefix(string $id): string + { + $words = []; + foreach (explode('-', $id) as $word) { + $word = implode('', array_filter(mb_str_split($word), ctype_lower(...))); + if ($word !== '') { + $words[] = $word; + } + } + + $letters = implode('', $words); + $fallback = mb_substr($letters, 0, 10).'ui'; + $initials = implode('', array_map(fn (string $word): string => mb_substr($word, 0, 1), $words)); + + return array_find([mb_substr($initials, 0, 12), mb_substr($letters, 0, 12)], self::isUsableUiPrefix(...)) ?? $fallback; + } + + public function hasUi(): bool + { + return $this->uiEntry !== null; + } + + public function path(string ...$parts): string + { + return $this->directory.($parts === [] ? '' : DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts)); + } +} diff --git a/app/Services/Extensions/ExtensionManifestValidator.php b/app/Services/Extensions/ExtensionManifestValidator.php new file mode 100644 index 000000000..e5817bb47 --- /dev/null +++ b/app/Services/Extensions/ExtensionManifestValidator.php @@ -0,0 +1,257 @@ +validateManifestStructure($data); + + $parser = new VersionParser; + try { + $parser->normalize($data['version']); + foreach ([$data['requires']['panel'] ?? null, $data['requires']['sdk'] ?? null, $data['requires']['php'] ?? null, ...array_values($data['requires']['extensions'] ?? [])] as $constraint) { + if ($constraint !== null) { + $parser->parseConstraints($constraint); + } + } + } catch (UnexpectedValueException $unexpectedValueException) { + throw new InvalidExtensionException('Invalid extension version or requirement: '.$unexpectedValueException->getMessage(), $unexpectedValueException->getCode(), $unexpectedValueException); + } + + foreach (array_keys($data['requires']['extensions'] ?? []) as $dependency) { + throw_unless(preg_match(ExtensionManifest::ID_REGEX, $dependency) && $dependency !== $data['id'], InvalidExtensionException::class, 'Extension dependencies must be valid identifiers other than the extension itself.'); + } + + foreach ($data['ui']['screens'] ?? [] as $screen) { + $parameters = array_values(array_filter(explode('/', $screen['path']), fn (string $segment): bool => str_starts_with($segment, '$'))); + throw_if(in_array('$id', $parameters, true), InvalidExtensionException::class, 'The id path parameter is reserved for the panel.'); + throw_if(count(array_unique($parameters)) !== count($parameters), InvalidExtensionException::class, 'Screen path parameters must be unique.'); + if (isset($screen['nav'])) { + $names = array_map(fn (string $parameter): string => mb_substr($parameter, 1), $parameters); + $defaults = array_keys($screen['nav']['params'] ?? []); + throw_if(array_diff($names, $defaults) !== [] || array_diff($defaults, $names) !== [], InvalidExtensionException::class, 'Navigation params must supply exactly the screen path parameters.'); + } + + if (isset($screen['when'])) { + $this->validateScreenCondition($screen['when']); + } + } + + $this->assertRootPrefixesAreFree($data['routes']['root'] ?? []); + + $id = $data['id']; + throw_unless(preg_match(ExtensionManifest::ID_REGEX, $id), InvalidExtensionException::class, "Extension id \"{$id}\" must match ".ExtensionManifest::ID_REGEX.'.'); + + throw_if(in_array($id, ExtensionManifest::RESERVED_IDS, true), InvalidExtensionException::class, "Extension id \"{$id}\" is reserved."); + + $autoload = $this->normalizeAutoload($data['autoload'] ?? []); + [$uiEntry, $uiMode] = $this->normalizeUi($data['ui'] ?? null); + + $provider = $data['provider'] ?? null; + throw_if($provider !== null && $provider === '', InvalidExtensionException::class, 'Manifest "provider" must be a class name string.'); + + return ExtensionManifest::fromValidatedData( + directory: $directory, + data: $data, + autoload: $autoload, + uiEntry: $uiEntry, + uiMode: $uiMode, + provider: $provider, + ); + } + + /** + * @phpstan-assert ExtensionManifestInput $data + */ + private function validateManifestStructure(mixed $data): void + { + throw_unless(is_array($data), InvalidExtensionException::class, 'The extension manifest must be a JSON object.'); + + $validator = Validator::make($data, [ + 'id' => ['required', 'string'], + 'name' => ['required', 'string'], + 'version' => ['required', 'string', 'max:64'], + 'description' => ['nullable', 'string'], + 'author' => ['nullable', 'string'], + 'provider' => ['nullable', 'string'], + 'autoload' => ['sometimes', 'array'], + 'requires' => ['sometimes', 'array:panel,sdk,php,extensions'], + 'requires.panel' => ['sometimes', 'string', 'max:255'], + 'requires.sdk' => ['required_with:ui.components', 'string', 'max:255'], + 'requires.php' => ['sometimes', 'string', 'max:255'], + 'requires.extensions' => ['sometimes', 'array', 'max:64'], + 'requires.extensions.*' => ['required', 'string', 'max:255'], + 'ui' => ['sometimes', 'array'], + 'ui.entry' => ['required_with:ui', 'string'], + 'ui.mode' => ['sometimes', 'string'], + 'ui.prefix' => ['sometimes', 'filled', 'string', 'regex:'.ExtensionManifest::UI_PREFIX_REGEX, Rule::notIn(ExtensionManifest::RESERVED_UI_PREFIXES)], + 'ui.components' => ['sometimes', 'array', 'list', 'max:64'], + 'ui.components.*' => ['required', 'string', 'distinct:strict', Rule::in(ExtensionManifest::COMPONENT_NAMES)], + 'ui.screens' => ['sometimes', 'array', 'list', 'max:64'], + 'ui.screens.*' => ['required', 'array:id,area,path,nav,permission,parent,when'], + 'ui.screens.*.id' => ['required', 'string', 'max:48', 'regex:/^[a-z][a-z0-9-]*$/', 'distinct:strict'], + 'ui.screens.*.area' => ['required', 'string', 'in:account,server,admin'], + 'ui.screens.*.path' => ['required', 'string', 'max:255', 'regex:~^[a-z][a-z0-9-]*(?:/(?:[a-z][a-z0-9-]*|\\$[a-zA-Z][a-zA-Z0-9_]*))*/?$~'], + 'ui.screens.*.parent' => ['sometimes', 'string', 'prohibited_unless:ui.screens.*.area,admin', 'in:admin.node,admin.server,admin.egg,admin.user'], + 'ui.screens.*.nav' => ['sometimes', 'array:label,exact,params,order,group,badge,icon', 'required_array_keys:label'], + 'ui.screens.*.nav.label' => ['required_with:ui.screens.*.nav', 'string', 'max:100'], + 'ui.screens.*.nav.exact' => ['sometimes', 'boolean:strict'], + 'ui.screens.*.nav.params' => ['sometimes', 'array'], + 'ui.screens.*.nav.params.*' => ['required', 'string', 'max:255'], + 'ui.screens.*.nav.order' => ['sometimes', 'integer', 'between:-10000,10000'], + 'ui.screens.*.nav.group' => ['sometimes', 'string', 'max:100'], + 'ui.screens.*.nav.badge' => ['sometimes', 'string', 'max:32'], + 'ui.screens.*.nav.icon' => ['sometimes', 'string', 'max:64', 'regex:'.ExtensionManifest::ICON_REGEX], + 'ui.screens.*.when' => ['sometimes', 'array:eggFeatures,eggTags,match,runtime'], + 'ui.screens.*.when.eggFeatures' => ['sometimes', 'prohibited_unless:ui.screens.*.area,server', 'array:any,all'], + 'ui.screens.*.when.eggFeatures.*' => ['required', 'array', 'list', 'min:1', 'max:32'], + 'ui.screens.*.when.eggFeatures.*.*' => ['required', 'string', 'max:100'], + 'ui.screens.*.when.eggTags' => ['sometimes', 'prohibited_unless:ui.screens.*.area,server', 'array:any,all'], + 'ui.screens.*.when.eggTags.*' => ['required', 'array', 'list', 'min:1', 'max:32'], + 'ui.screens.*.when.eggTags.*.*' => ['required', 'string', 'max:100'], + 'ui.screens.*.when.match' => ['sometimes', 'string', 'in:all,any'], + 'ui.screens.*.when.runtime' => ['sometimes', 'boolean:strict'], + 'ui.screens.*.permission' => ['sometimes', 'prohibited_unless:ui.screens.*.area,server', 'array', 'list'], + 'ui.screens.*.permission.*' => ['required', 'string', 'max:100'], + 'routes' => ['sometimes', 'array:root'], + 'routes.root' => ['sometimes', 'array', 'list', 'max:8'], + 'routes.root.*' => ['required', 'string', 'distinct:strict', 'regex:'.ExtensionManifest::ROOT_PREFIX_REGEX], + ], [ + 'id.required' => 'Manifest field "id" is required and must be a string.', + 'id.string' => 'Manifest field "id" is required and must be a string.', + 'name.required' => 'Manifest field "name" is required and must be a string.', + 'name.string' => 'Manifest field "name" is required and must be a string.', + 'version.required' => 'Manifest field "version" is required and must be a string.', + 'version.string' => 'Manifest field "version" is required and must be a string.', + 'version.max' => 'Manifest field "version" must not be longer than 64 characters.', + 'provider.string' => 'Manifest "provider" must be a class name string.', + 'autoload.array' => 'Manifest "autoload" must map "Vendor\\\\Prefix\\\\" to a source directory.', + 'ui.array' => 'Manifest "ui" must be an object with an "entry" path.', + 'ui.entry.required_with' => 'Manifest "ui" must be an object with an "entry" path.', + 'ui.entry.string' => 'Manifest "ui" must be an object with an "entry" path.', + 'ui.mode.string' => 'Manifest "ui.mode" must be a string.', + 'ui.prefix.filled' => 'Manifest "ui.prefix" must match '.ExtensionManifest::UI_PREFIX_REGEX.'.', + 'ui.prefix.string' => 'Manifest "ui.prefix" must match '.ExtensionManifest::UI_PREFIX_REGEX.'.', + 'ui.prefix.regex' => 'Manifest "ui.prefix" must match '.ExtensionManifest::UI_PREFIX_REGEX.'.', + 'ui.prefix.not_in' => 'Manifest "ui.prefix" is a Tailwind variant, theme namespace or panel name and cannot be used as a prefix.', + 'requires.sdk.required_with' => 'Component replacements must declare a "requires.sdk" version constraint.', + 'ui.components.*.in' => 'Manifest "ui.components" must contain supported component names.', + 'ui.screens.*.permission.prohibited_unless' => 'Screen "permission" is only supported on server screens.', + 'ui.screens.*.nav.icon.regex' => 'Navigation "icon" must be a lucide icon name such as "life-buoy".', + 'ui.screens.*.when.eggFeatures.prohibited_unless' => 'Screen "when" egg rules are only supported on server screens.', + 'ui.screens.*.when.eggTags.prohibited_unless' => 'Screen "when" egg rules are only supported on server screens.', + 'routes.array' => 'Manifest "routes" must be an object with a "root" list.', + 'routes.root.*.regex' => 'Manifest "routes.root" prefixes must match '.ExtensionManifest::ROOT_PREFIX_REGEX.'.', + 'routes.root.*.distinct' => 'Manifest "routes.root" prefixes must be unique.', + ]); + + if ($validator->fails()) { + throw new InvalidExtensionException($validator->errors()->first()); + } + } + + /** + * A condition has to restrict something: an empty rule, an empty matcher, or a + * combinator with nothing to combine is a manifest mistake rather than "always". + * + * @param ExtensionScreenCondition $when + */ + private function validateScreenCondition(array $when): void + { + $rules = array_intersect_key($when, ['eggFeatures' => true, 'eggTags' => true]); + throw_if($rules === [] && ($when['runtime'] ?? false) !== true, InvalidExtensionException::class, 'Screen "when" must declare an egg rule or "runtime": true.'); + throw_if(isset($when['match']) && count($rules) < 2, InvalidExtensionException::class, 'Screen "when.match" combines "eggFeatures" with "eggTags" and requires both.'); + foreach ($rules as $name => $matcher) { + throw_if($matcher === [], InvalidExtensionException::class, "Screen \"when.{$name}\" must list \"any\" or \"all\" values."); + } + } + + /** + * A claimed top-level prefix must not shadow anything the panel already serves: the + * SPA's client-side routes, the first segment of any registered core route, or a + * file or directory in the public web root. Routes of extensions are named + * `extensions.*` and are skipped - claims between extensions are compared when one + * is enabled, not here. + * + * @param list $prefixes + */ + private function assertRootPrefixesAreFree(array $prefixes): void + { + if ($prefixes === []) { + return; + } + + $reserved = array_fill_keys(ExtensionManifest::RESERVED_ROOT_PREFIXES, true); + foreach (Route::getRoutes()->getRoutes() as $route) { + $segment = explode('/', mb_ltrim($route->uri(), '/'))[0]; + if ($segment !== '' && ! str_contains($segment, '{') && ! str_starts_with($route->getName() ?? '', 'extensions.')) { + $reserved[mb_strtolower($segment)] = true; + } + } + + foreach ($prefixes as $prefix) { + throw_if(isset($reserved[$prefix]) || File::exists(public_path($prefix)), InvalidExtensionException::class, "Root path prefix \"/{$prefix}\" is reserved by the panel."); + } + } + + /** + * @param array $autoload + * @return array + */ + private function normalizeAutoload(mixed $autoload): array + { + $normalized = []; + foreach ($autoload as $prefix => $src) { + throw_if(! is_string($prefix) || ! is_string($src) || ! str_ends_with($prefix, '\\'), InvalidExtensionException::class, 'Manifest "autoload" must map "Vendor\\\\Prefix\\\\" to a source directory.'); + + throw_if(str_starts_with($src, '/') || str_contains($src, '..'), InvalidExtensionException::class, 'Manifest "autoload" directories must be relative paths inside the package.'); + + $normalized[$prefix] = mb_trim(str_replace('\\', '/', $src), '/'); + } + + return $normalized; + } + + /** + * @param array{entry: string, mode?: string, prefix?: string, screens?: list, components?: list}|null $ui + * @return array{0: string|null, 1: string} + */ + private function normalizeUi(mixed $ui): array + { + if ($ui === null) { + return [null, 'native']; + } + + $uiEntry = str_replace('\\', '/', $ui['entry']); + throw_if(str_starts_with($uiEntry, '/') || str_contains($uiEntry, '..'), InvalidExtensionException::class, 'Manifest "ui.entry" must be a relative path inside the package.'); + + throw_if($uiEntry !== ExtensionManifest::UI_ENTRY, InvalidExtensionException::class, 'Manifest "ui.entry" must be "'.ExtensionManifest::UI_ENTRY.'".'); + + $uiMode = $ui['mode'] ?? 'native'; + throw_if($uiMode !== 'native', InvalidExtensionException::class, "Unsupported ui.mode \"{$uiMode}\" - this panel supports: native."); + + return [$uiEntry, $uiMode]; + } +} diff --git a/app/Services/Extensions/ExtensionPackageFiles.php b/app/Services/Extensions/ExtensionPackageFiles.php new file mode 100644 index 000000000..ed083b1b7 --- /dev/null +++ b/app/Services/Extensions/ExtensionPackageFiles.php @@ -0,0 +1,35 @@ +directory === $target || realpath($manifest->directory) === realpath($target)) { + return $callback($target); + } + + File::ensureDirectoryExists(dirname($target)); + $staged = dirname($target).DIRECTORY_SEPARATOR.'.staging-'.Str::random(12); + try { + throw_unless(File::copyDirectory($manifest->directory, $staged), InvalidExtensionException::class, 'Unable to stage extension package.'); + $this->validator->fromDirectory($staged); + + return $this->files->run([$target => $staged], fn () => $callback($target)); + } finally { + rescue(fn () => $this->files->delete($staged)); + } + } +} diff --git a/app/Services/Extensions/ExtensionPackageLocator.php b/app/Services/Extensions/ExtensionPackageLocator.php new file mode 100644 index 000000000..cb7dbef48 --- /dev/null +++ b/app/Services/Extensions/ExtensionPackageLocator.php @@ -0,0 +1,88 @@ +locate($source); + + try { + return $callback($package['directory']); + } finally { + if ($package['workdir'] !== null) { + rescue(fn () => File::deleteDirectory($package['workdir'])); + } + } + } + + /** @return array{directory: string, workdir: string|null} */ + public function locate(string $source): array + { + if (is_dir($source)) { + return ['directory' => $this->locatePackageRoot($source), 'workdir' => null]; + } + + throw_unless(is_file($source), InvalidExtensionException::class, "No extension package at {$source}."); + $workdir = $this->extract($source); + + try { + return ['directory' => $this->locatePackageRoot($workdir), 'workdir' => $workdir]; + } catch (Throwable $throwable) { + rescue(fn () => File::deleteDirectory($workdir)); + + throw $throwable; + } + } + + private function extract(string $archive): string + { + $zip = new ZipArchive; + throw_if($zip->open($archive) !== true, InvalidExtensionException::class, "Unable to open archive {$archive}."); + + $workdir = storage_path('app'.DIRECTORY_SEPARATOR.'extensions-tmp'.DIRECTORY_SEPARATOR.Str::random(12)); + File::ensureDirectoryExists($workdir); + + try { + throw_unless($zip->extractTo($workdir), InvalidExtensionException::class, "Unable to extract {$archive}."); + + return $workdir; + } catch (Throwable $throwable) { + rescue(fn () => File::deleteDirectory($workdir)); + + throw $throwable; + } finally { + $zip->close(); + } + } + + private function locatePackageRoot(string $directory): string + { + if (is_file($directory.DIRECTORY_SEPARATOR.ExtensionManifest::FILENAME)) { + return $directory; + } + + $candidates = glob($directory.'/*/'.ExtensionManifest::FILENAME) ?: []; + if (count($candidates) === 1) { + return dirname($candidates[0]); + } + + throw new InvalidExtensionException('Could not locate a single '.ExtensionManifest::FILENAME." inside {$directory}."); + } +} diff --git a/app/Services/Extensions/ExtensionPermissionRegistry.php b/app/Services/Extensions/ExtensionPermissionRegistry.php new file mode 100644 index 000000000..1f4adf5ac --- /dev/null +++ b/app/Services/Extensions/ExtensionPermissionRegistry.php @@ -0,0 +1,54 @@ +`. Populated by ExtensionProvider::registerPermissions() while + * providers boot; consumed through SubuserPermissionCatalog. + */ +class ExtensionPermissionRegistry +{ + public const string KEY_REGEX = '/^[a-z][a-z0-9-]{0,47}$/'; + + /** OpenAPI pattern every extension permission matches: `ext..`. */ + public const string PERMISSION_PATTERN = '^ext\.[a-z][a-z0-9-]{0,47}\.[a-z][a-z0-9-]{0,47}$'; + + /** @var array}> */ + private array $groups = []; + + /** The permission group an extension's keys live under, e.g. `ext.votes`. */ + public static function group(string $identifier): string + { + return 'ext.'.$identifier; + } + + /** + * @param array $keys permission key => description + */ + public function register(string $identifier, string $description, array $keys): void + { + throw_if($keys === [], InvalidArgumentException::class, sprintf('Extension "%s" must register at least one permission.', $identifier)); + + foreach (array_keys($keys) as $key) { + throw_unless(preg_match(self::KEY_REGEX, $key) === 1, InvalidArgumentException::class, sprintf('Extension permission "%s" must match %s.', $key, self::KEY_REGEX)); + } + + $this->groups[self::group($identifier)] = ['description' => $description, 'keys' => $keys]; + } + + /** @return array}> */ + public function all(): array + { + return $this->groups; + } + + public function unregister(string $identifier): void + { + unset($this->groups[self::group($identifier)]); + } +} diff --git a/app/Services/Extensions/ExtensionProviderLoader.php b/app/Services/Extensions/ExtensionProviderLoader.php new file mode 100644 index 000000000..cc8928e9a --- /dev/null +++ b/app/Services/Extensions/ExtensionProviderLoader.php @@ -0,0 +1,142 @@ + */ + private array $autoloadedPaths = []; + + /** @var array */ + private array $providers = []; + + public function __construct( + private readonly Application $app, + private readonly ExtensionRepository $extensions, + ) {} + + /** + * @param Collection $enabled + */ + public function registerProviders(Collection $enabled): void + { + $this->registerAutoloader($enabled); + + $registered = []; + foreach ($enabled as $manifest) { + if (isset($this->providers[$manifest->id])) { + continue; + } + + $provider = null; + try { + foreach (array_keys($manifest->requiredExtensions) as $dependency) { + throw_unless(in_array($dependency, $registered, true) || isset($this->providers[$dependency]), InvalidExtensionException::class, "Required extension \"{$dependency}\" failed to load."); + } + + $this->registerComposerAutoloader($manifest); + if ($manifest->provider === null) { + $registered[] = $manifest->id; + + continue; + } + + $provider = $this->makeProvider($manifest); + $provider->beginRegistration(); + $this->app->register($provider, force: true); + $provider->commitRegistration(); + $this->providers[$manifest->id] = $provider; + $registered[] = $manifest->id; + } catch (Throwable $exception) { + $provider?->discardRegistration(); + $this->extensions->recordFailure( + $manifest->id, + $exception->getMessage(), + $exception, + $this->registeredProvider($provider) ? 'boot' : 'register', + ); + } + } + + $this->extensions->clearErrors($registered); + } + + public function bootProviders(): void + { + // Providers are booted by Application::register() because the extension + // loader runs from an app-booted callback. + } + + /** + * @param Collection $manifests + */ + public function registerAutoloader(Collection $manifests): void + { + foreach ($manifests as $manifest) { + foreach ($manifest->autoload as $prefix => $src) { + $path = $manifest->path($src); + $key = $prefix.'|'.$path; + + if (isset($this->autoloadedPaths[$key])) { + continue; + } + + $this->loader()->addPsr4($prefix, $path); + $this->autoloadedPaths[$key] = true; + } + } + } + + private function registerComposerAutoloader(ExtensionManifest $manifest): void + { + $path = $manifest->path('vendor', 'autoload.php'); + if (! is_file($path) || isset($this->autoloadedPaths[$path])) { + return; + } + + $loader = require $path; + throw_unless($loader instanceof ClassLoader, InvalidExtensionException::class, 'Extension vendor/autoload.php must return a Composer ClassLoader.'); + $loader->unregister(); + $loader->register(prepend: false); + $this->autoloadedPaths[$path] = true; + } + + private function makeProvider(ExtensionManifest $manifest): ExtensionProvider + { + if ($manifest->provider === null || ! class_exists($manifest->provider)) { + throw new InvalidExtensionException("Provider class {$manifest->provider} was not found via the manifest autoload map."); + } + + if (! is_subclass_of($manifest->provider, ExtensionProvider::class)) { + throw new InvalidExtensionException("{$manifest->provider} must extend ".ExtensionProvider::class.'.'); + } + + return new ($manifest->provider)($this->app, $manifest); + } + + private function loader(): ClassLoader + { + if (! $this->classLoader instanceof ClassLoader) { + $this->classLoader = new ClassLoader; + $this->classLoader->register(); + } + + return $this->classLoader; + } + + private function registeredProvider(?ExtensionProvider $provider): bool + { + return $provider instanceof ExtensionProvider && $this->app->getProvider($provider::class) === $provider; + } +} diff --git a/app/Services/Extensions/ExtensionRegistration.php b/app/Services/Extensions/ExtensionRegistration.php new file mode 100644 index 000000000..9ece1606e --- /dev/null +++ b/app/Services/Extensions/ExtensionRegistration.php @@ -0,0 +1,121 @@ +|null */ + private ?array $pending = null; + + private bool $active = true; + + public function __construct( + private readonly Application $app, + private readonly Router $router, + private readonly ExtensionSettingsRegistry $settings, + private readonly ExtensionPermissionRegistry $permissions, + private readonly ExtensionActionDecorators $actions, + private readonly ExtensionConsoleRegistry $console, + private readonly ExtensionHeadTags $headTags, + ) {} + + public function begin(): void + { + $this->pending = []; + $this->active = false; + } + + /** @param Closure(): void $registration */ + public function defer(Closure $registration): void + { + if ($this->pending === null) { + $registration(); + + return; + } + + $this->pending[] = $registration; + } + + public function commit(string $identifier): void + { + if ($this->pending === null) { + return; + } + + $definition = $this->settings->get($identifier); + $permissions = $this->permissions->all()[ExtensionPermissionRegistry::group($identifier)] ?? null; + $actions = $this->actions->snapshot(); + $console = $this->console->snapshot(); + $headTags = $this->headTags->snapshot(); + $router = clone $this->router; + $routes = $this->router->getRoutes(); + if ($routes instanceof RouteCollection) { + $router->setRoutes(clone $routes); + } + + Route::swap($router); + $registrations = $this->pending; + $this->pending = null; + try { + foreach ($registrations as $registration) { + $registration(); + } + + $routes = $router->getRoutes(); + if ($routes instanceof RouteCollection) { + $routes->refreshNameLookups(); + $routes->refreshActionLookups(); + $this->router->setRoutes($routes); + } + + $this->active = true; + } catch (Throwable $throwable) { + $this->settings->unregister($identifier); + if ($definition instanceof ExtensionSettingsDefinition) { + $this->settings->register($identifier, $definition); + } + + $this->permissions->unregister($identifier); + if ($permissions !== null) { + $this->permissions->register($identifier, $permissions['description'], $permissions['keys']); + } + + $this->actions->restore($actions); + $this->console->restore($console); + $this->headTags->restore($headTags); + + throw $throwable; + } finally { + Route::swap($this->router); + $routes = $this->router->getRoutes(); + if ($routes instanceof RouteCollection) { + $this->router->setRoutes($routes); + } + + $this->app->instance('routes', $routes); + $this->pending = null; + } + } + + public function discard(): void + { + $this->pending = null; + $this->active = false; + } + + public function isActive(): bool + { + return $this->active; + } +} diff --git a/app/Services/Extensions/ExtensionRepository.php b/app/Services/Extensions/ExtensionRepository.php new file mode 100644 index 000000000..c8a7a0fda --- /dev/null +++ b/app/Services/Extensions/ExtensionRepository.php @@ -0,0 +1,247 @@ +|null */ + private ?Collection $discovered = null; + + /** @var Collection|null */ + private ?Collection $enabled = null; + + /** @var array in-memory discovery errors keyed by directory name */ + private array $discoveryErrors = []; + + /** @var array */ + private array $settings = []; + + /** @var array Provider failures in this application instance, retained across discovery refreshes. */ + private array $failedProviders = []; + + public function __construct( + private readonly ExtensionManifestValidator $validator, + private readonly ExtensionAssetPublisher $assets, + private readonly Dispatcher $events, + private readonly ExtensionSettingsRegistry $settingsRegistry, + private readonly ExtensionCompatibility $compatibility, + ) {} + + public function directory(): string + { + return mb_rtrim(JsonValueGuard::string(config('extensions.directory')), '/\\'); + } + + /** + * @return Collection + */ + public function discovered(): Collection + { + if ($this->discovered instanceof Collection) { + return $this->discovered; + } + + $manifests = []; + foreach (glob($this->directory().'/*/'.ExtensionManifest::FILENAME) ?: [] as $file) { + $directory = dirname($file); + + try { + $manifest = $this->validator->fromDirectory($directory); + if ($manifest->id !== basename($directory)) { + throw new InvalidExtensionException(sprintf('Extension directory "%s" must match its manifest id "%s".', basename($directory), $manifest->id)); + } + + $manifests[$manifest->id] = $manifest; + } catch (InvalidExtensionException $exception) { + $this->discoveryErrors[basename($directory)] = $exception->getMessage(); + Log::warning('[extensions] Skipping extension', ['directory' => $directory, 'exception' => $exception]); + } + } + + return $this->discovered = collect($manifests); + } + + /** + * @return array + */ + public function discoveryErrors(): array + { + return $this->discoveryErrors; + } + + public function flushDiscovery(): void + { + $this->discovered = null; + $this->enabled = null; + $this->discoveryErrors = []; + } + + /** + * @return Collection + */ + public function records(): Collection + { + return rescue(function (): Collection { + if (! Schema::hasTable('extensions')) { + return $this->recordCollection([]); + } + + $records = []; + foreach (Extension::query()->get() as $extension) { + $records[$extension->identifier] = $extension; + } + + return $this->recordCollection($records); + }, fn (): Collection => $this->recordCollection([])); + } + + /** + * @return Collection + */ + public function enabled(): Collection + { + if ($this->enabled instanceof Collection) { + return $this->enabled; + } + + $configured = $this->configuredEnabled()->reject(fn (ExtensionManifest $manifest): bool => isset($this->failedProviders[$manifest->id])); + $result = $this->compatibility->resolve($configured); + foreach ($result['errors'] as $identifier => $reason) { + $this->recordFailure($identifier, $reason, phase: 'compatibility'); + } + + return $this->enabled = $result['manifests']; + } + + /** Whether an extension's runtime registrations may run right now. */ + public function isAvailable(string $identifier): bool + { + return config('extensions.enabled') && $this->enabled()->has($identifier); + } + + /** @return Collection */ + public function configuredEnabled(): Collection + { + $discovered = $this->discovered(); + if ($discovered->isEmpty()) { + return $discovered; + } + + $records = $this->records(); + + return $discovered->filter(function (ExtensionManifest $manifest) use ($records): bool { + $record = $records->get($manifest->id); + + return $record !== null && $record->enabled; + }); + } + + /** + * The enabled frontend extensions for the SPA to load. Signed-in users receive + * each extension's frontend settings; everyone else only those marked ->public(). + * + * @return array, components: list, development: array{url: string, version: string}|null}> + */ + public function frontendPayload(bool $authenticated): array + { + $enabled = $this->enabled()->filter(fn (ExtensionManifest $manifest): bool => $manifest->hasUi()); + $configured = $authenticated ? $enabled : $enabled->filter(fn (ExtensionManifest $manifest): bool => ($this->settingsRegistry->get($manifest->id)?->publicConfigKeys() ?? []) !== []); + if ($configured->isNotEmpty()) { + rescue(fn () => ExtensionSettings::preload(array_values($configured->map(fn (ExtensionManifest $manifest): ExtensionSettings => $this->settings($manifest->id))->all())), report: false); + } + + return $enabled->map(fn (ExtensionManifest $manifest): array => [ + 'id' => $manifest->id, + 'version' => $manifest->version, + 'entry' => $this->assets->entryUrl($manifest), + 'prefix' => $manifest->uiPrefix, + 'config' => (object) $this->frontendConfig($manifest->id, ! $authenticated), + 'screens' => $manifest->screens, + 'components' => $manifest->components, + 'development' => $this->assets->developmentPayload($manifest->id), + ]) + ->values() + ->all(); + } + + public function recordFailure(string $identifier, string $reason, ?Throwable $exception = null, string $phase = 'runtime'): void + { + if (in_array($phase, ['register', 'boot'], true)) { + $this->failedProviders[$identifier] = true; + $this->enabled = null; + } + + rescue(fn (): int => Extension::query()->where('identifier', $identifier)->update(['error' => $reason]), report: false); + + $context = array_filter(['exception' => $exception]); + $exception instanceof Throwable + ? Log::error("[extensions] Failed to load \"{$identifier}\": {$reason}", $context) + : Log::warning("[extensions] Skipping \"{$identifier}\": {$reason}", $context); + + rescue(fn () => $this->events->dispatch(new ExtensionLoadFailed($identifier, $phase, $reason, $exception))); + } + + public function clearError(string $identifier): void + { + $this->clearErrors([$identifier]); + } + + /** @param list $identifiers */ + public function clearErrors(array $identifiers): void + { + if ($identifiers === []) { + return; + } + + foreach ($identifiers as $identifier) { + if (! isset($this->failedProviders[$identifier])) { + continue; + } + + unset($this->failedProviders[$identifier]); + $this->enabled = null; + } + + rescue(fn (): int => Extension::query()->whereIn('identifier', $identifiers)->whereNotNull('error')->update(['error' => null]), report: false); + } + + public function settings(string $identifier): ExtensionSettings + { + // One instance per extension per request so the per-instance row cache + // in ExtensionSettings actually coalesces reads. + return $this->settings[$identifier] ??= new ExtensionSettings($identifier); + } + + /** + * @param array $records + * @return Collection + */ + private function recordCollection(array $records): Collection + { + return collect($records); + } + + /** + * The ->frontend()-marked settings for one extension, exposed to its bundle + * as ctx.config; with $publicOnly just the ->public() ones, for guests. + * Never allowed to break page rendering. + * + * @return ExtensionSettingValues + */ + private function frontendConfig(string $identifier, bool $publicOnly): array + { + return rescue(fn (): array => $this->settingsRegistry->get($identifier)?->frontendConfig($publicOnly) ?? [], []); + } +} diff --git a/app/Services/Extensions/ExtensionRuntimeRefresher.php b/app/Services/Extensions/ExtensionRuntimeRefresher.php new file mode 100644 index 000000000..d5a977d9c --- /dev/null +++ b/app/Services/Extensions/ExtensionRuntimeRefresher.php @@ -0,0 +1,20 @@ +application->getCachedRoutesPath()); + Cache::forever('illuminate:queue:restart', now()->getTimestamp()); + } +} diff --git a/app/Services/Extensions/ExtensionSettingDefinition.php b/app/Services/Extensions/ExtensionSettingDefinition.php new file mode 100644 index 000000000..e1987e880 --- /dev/null +++ b/app/Services/Extensions/ExtensionSettingDefinition.php @@ -0,0 +1,423 @@ +secret(). */ + private const array RICH_FIELDS = ['color', 'textarea', 'multiselect', 'list', 'file']; + + /** @var (Closure(ExtensionSettingValue): ExtensionSettingValue)|null */ + private ?Closure $normalizer = null; + + /** @var (Closure(ExtensionSettingValue): ExtensionSettingValue)|null */ + private ?Closure $publicSerializer = null; + + private ?string $label = null; + + private ?string $help = null; + + private ?string $tab = null; + + private string $field = 'text'; + + /** @var list */ + private array $options = []; + + private bool $frontend = false; + + private bool $guests = false; + + private bool $secret = false; + + /** @var 'string'|'number'|'boolean'|'array'|'object'|'null'|'json'|null */ + private ?string $frontendType = null; + + private ?int $maxLength = null; + + private ?int $maxItems = null; + + /** @var ValidationRuleSet rules every item of a list field must pass */ + private array $itemRules = []; + + private ?int $maxKilobytes = null; + + /** @var list content types a file field accepts */ + private array $mimes = []; + + /** + * @param ExtensionSettingValue $default + * @param ValidationRuleSet $rules + */ + public function __construct( + public readonly string $key, + public readonly string $input, + public readonly mixed $default, + public readonly array $rules = [], + public readonly ?string $public = null, + ) {} + + /** + * @param ExtensionSettingValue $default + * @param ValidationRuleSet $rules + */ + public static function make(string $key, string $input, mixed $default, array $rules = [], ?string $public = null): self + { + return new self($key, $input, $default, $rules, $public); + } + + /** @param callable(ExtensionSettingValue): ExtensionSettingValue $normalizer */ + public function normalizeUsing(callable $normalizer): self + { + $this->normalizer = $normalizer instanceof Closure ? $normalizer : Closure::fromCallable($normalizer); + + return $this; + } + + /** @param callable(ExtensionSettingValue): ExtensionSettingValue $serializer */ + public function publicUsing(callable $serializer): self + { + $this->publicSerializer = $serializer instanceof Closure ? $serializer : Closure::fromCallable($serializer); + + return $this; + } + + /** Human label shown on the auto-rendered admin settings form. */ + public function label(string $label): self + { + $this->label = $label; + + return $this; + } + + /** Help text shown under the field on the auto-rendered admin settings form. */ + public function help(string $help): self + { + $this->help = $help; + + return $this; + } + + /** + * Section the field is shown in on the auto-rendered admin settings form, picked from + * a dropdown. Sections appear in the order their first field is defined; once any + * field names one, fields without one are shown under "General". + */ + public function tab(string $tab): self + { + $tab = mb_trim($tab); + throw_if($tab === '' || mb_strlen($tab) > 64, InvalidArgumentException::class, 'An extension settings tab name must be 1 to 64 characters.'); + $this->tab = $tab; + + return $this; + } + + /** + * Form control for the auto-rendered admin settings form: one of + * text, password, number, toggle, select, color, textarea, multiselect, + * list, file. The last five have their own methods (color(), textarea(), + * multiselect(), list(), file()) which also take their limits; naming them + * here applies the defaults. + * + * @param list $options select or multiselect choices + */ + public function field(string $field, array $options = []): self + { + if (! in_array($field, self::FIELDS, true)) { + throw new InvalidArgumentException(sprintf('Unknown settings field type "%s"; expected one of %s.', $field, implode(', ', self::FIELDS))); + } + + return match ($field) { + 'color' => $this->color(), + 'textarea' => $this->textarea(), + 'multiselect' => $this->multiselect($options), + 'list' => $this->list(), + 'file' => $this->file(), + default => $this->useField($field, $options), + }; + } + + /** + * A colour picker. The value is a hex colour (#rgb, #rgba, #rrggbb, + * #rrggbbaa) or a numeric oklch() colour - the syntaxes theme tokens use - + * stored in canonical lower-case form. Anything else is rejected, so the + * value is safe to write into a style rule. Clearing it restores the default. + */ + public function color(): self + { + throw_unless($this->default === null || ExtensionSettingValueGuard::color($this->default) !== null, InvalidArgumentException::class, 'A color setting defaults to a hex or oklch() colour, or null.'); + + return $this->useField('color'); + } + + /** A multi-line string of at most $maxLength characters. */ + public function textarea(int $maxLength = 5000): self + { + throw_unless(ExtensionSettingValueGuard::text($this->default) !== null, InvalidArgumentException::class, 'A textarea setting defaults to a string.'); + throw_if($maxLength < 1, InvalidArgumentException::class, 'A textarea setting needs a positive maximum length.'); + $this->maxLength = $maxLength; + + return $this->useField('textarea'); + } + + /** + * Any number of the declared choices. The value is the list of chosen option + * values, deduplicated and in declaration order. + * + * @param list $options + */ + public function multiselect(array $options): self + { + throw_unless(ExtensionSettingValueGuard::strings($this->default) !== null, InvalidArgumentException::class, 'A multiselect setting defaults to a list.'); + throw_if($options === [] || array_any($options, fn (array $option): bool => $option['value'] === true || $option['value'] === false), InvalidArgumentException::class, 'A multiselect setting needs string or integer choices.'); + + return $this->useField('multiselect', $options); + } + + /** + * An ordered list of strings. Every item must pass $itemRules (it is always + * a string) and the list holds at most $maxItems items. + * + * @param ValidationRuleSet $itemRules + */ + public function list(array $itemRules = ['max:255'], int $maxItems = 50): self + { + throw_unless(ExtensionSettingValueGuard::strings($this->default) !== null, InvalidArgumentException::class, 'A list setting defaults to a list of strings.'); + throw_if($maxItems < 1, InvalidArgumentException::class, 'A list setting needs a positive maximum item count.'); + $this->itemRules = $itemRules; + $this->maxItems = $maxItems; + + return $this->useField('list'); + } + + /** + * A file an administrator uploads from the settings form. The panel decides + * the type from the file's content, stores it under a random name and serves + * it from a fixed public URL; that URL (or the default, a URL or null, while + * nothing is uploaded) is the setting's value. It is not part of a settings + * update: uploading or clearing goes through its own admin endpoint. + * + * @param list $mimes accepted content types, from ExtensionSettingFiles::TYPES. SVG is only accepted when listed here. + */ + public function file(array $mimes = ExtensionSettingFiles::IMAGES, int $maxKilobytes = 1024): self + { + throw_unless($this->default === null || ExtensionSettingValueGuard::text($this->default) !== null, InvalidArgumentException::class, 'A file setting defaults to a URL or null.'); + throw_if($mimes === [] || array_diff($mimes, array_keys(ExtensionSettingFiles::TYPES)) !== [], InvalidArgumentException::class, sprintf('A file setting accepts only these types: %s.', implode(', ', array_keys(ExtensionSettingFiles::TYPES)))); + throw_if($maxKilobytes < 1 || $maxKilobytes > ExtensionSettingFiles::MAX_KILOBYTES, InvalidArgumentException::class, sprintf('A file setting is limited to between 1 and %d KB.', ExtensionSettingFiles::MAX_KILOBYTES)); + $this->mimes = $mimes; + $this->maxKilobytes = $maxKilobytes; + + return $this->useField('file'); + } + + /** + * Expose this setting's public value to the extension's frontend bundle via + * ctx.config. Off by default - frontend values are visible to every logged-in + * user, so never mark secrets (even masked ones) unless that is intended. + */ + public function frontend(bool $frontend = true): self + { + throw_if($frontend && $this->secret, InvalidArgumentException::class, 'Secret extension settings cannot be exposed to frontend bundles.'); + throw_if(! $frontend && $this->guests, InvalidArgumentException::class, 'Public extension settings must stay exposed to frontend bundles.'); + $this->frontend = $frontend; + + return $this; + } + + /** + * Also deliver this frontend setting to visitors who are not signed in (the + * login page, for example). Only for values that are safe for anyone on the + * internet to read; every other frontend setting stays signed-in only. + */ + public function public(): self + { + throw_if($this->secret, InvalidArgumentException::class, 'Secret extension settings cannot be public.'); + throw_unless($this->frontend, InvalidArgumentException::class, 'Only frontend extension settings can be public; call ->frontend() first.'); + $this->guests = true; + + return $this; + } + + public function secret(): self + { + throw_if($this->frontend, InvalidArgumentException::class, 'Secret extension settings cannot be exposed to frontend bundles.'); + throw_if(in_array($this->field, self::RICH_FIELDS, true), InvalidArgumentException::class, sprintf('A %s extension setting cannot be secret.', $this->field)); + $this->secret = true; + $this->field = 'password'; + + return $this; + } + + public function isSecret(): bool + { + return $this->secret; + } + + public function isFrontend(): bool + { + return $this->frontend; + } + + public function isPublic(): bool + { + return $this->guests; + } + + public function isFile(): bool + { + return $this->field === 'file'; + } + + /** @return array{mimes: list, max_kilobytes: int} */ + public function fileConstraints(): array + { + return ['mimes' => $this->mimes, 'max_kilobytes' => $this->maxKilobytes ?? 0]; + } + + public function frontendType(string $type): self + { + throw_unless(in_array($type, ['string', 'number', 'boolean', 'array', 'object', 'null', 'json'], true), InvalidArgumentException::class, 'Invalid frontend setting type.'); + $this->frontendType = $type; + + return $this; + } + + /** + * The type declared with frontendType(), or the one the field implies. + * + * @return 'string'|'number'|'boolean'|'array'|'object'|'null'|'json' + */ + public function declaredFrontendType(): string + { + return $this->frontendType ?? match ($this->field) { + 'textarea' => 'string', + 'color', 'file' => ExtensionSettingValueGuard::text($this->default) === null ? 'json' : 'string', + 'multiselect', 'list' => 'array', + default => 'json', + }; + } + + /** + * Rules for a partial update, keyed by input name: the input is optional + * and, when submitted, must pass the definition's rules and those of its + * field type. Inputs without rules of their own are accepted as given. + * + * @return NormalizedValidationRules + */ + public function validationRules(): array + { + $rules = in_array('sometimes', $this->rules, true) ? $this->rules : ['sometimes', ...$this->rules]; + + return match ($this->field) { + 'color' => [$this->input => [...$rules, 'nullable', new ValidExtensionSettingColor]], + 'textarea' => [$this->input => [...$rules, 'nullable', 'string', 'max:'.$this->maxLength]], + 'multiselect' => [ + $this->input => [...$rules, 'array', 'list'], + $this->input.'.*' => ['distinct', Rule::in($this->choices())], + ], + 'list' => [ + $this->input => [...$rules, 'array', 'list', 'max:'.$this->maxItems], + $this->input.'.*' => ['string', ...$this->itemRules], + ], + 'file' => [$this->input => ['prohibited']], + default => [$this->input => $rules], + }; + } + + /** + * Coerce a submitted or stored value to the field type's shape, then apply + * normalizeUsing(). A value that does not fit falls back to the default. + * + * @param ExtensionSettingValue $value + * @return ExtensionSettingValue + */ + public function normalize(mixed $value): mixed + { + $value = match ($this->field) { + 'color' => ExtensionSettingValueGuard::color($value) ?? $this->default, + 'textarea' => $value === null ? '' : (ExtensionSettingValueGuard::text($value) ?? $this->default), + 'multiselect' => ExtensionSettingValueGuard::choices($value, $this->choices()) ?? $this->default, + 'list' => ExtensionSettingValueGuard::strings($value) ?? $this->default, + default => $value, + }; + + return $this->normalizer instanceof Closure ? ($this->normalizer)($value) : $value; + } + + /** + * @param ExtensionSettingValue $value + * @return ExtensionSettingValue + */ + public function serializePublic(mixed $value): mixed + { + if ($this->secret) { + return $value === null || $value === '' ? null : '********'; + } + + return $this->publicSerializer instanceof Closure ? ($this->publicSerializer)($value) : $value; + } + + public function publicName(): string + { + return $this->public ?? $this->input; + } + + /** + * Schema entry for the auto-rendered admin settings form. `value` is the + * current public serialization; secrets serialized through publicUsing() + * therefore stay masked here too. `constraints` carries the limits the + * field's control enforces up front, and `visibility` who receives the value. + * + * @param ExtensionSettingValue $currentValue + * @return ExtensionSettingField + */ + public function describe(mixed $currentValue): array + { + return [ + 'input' => $this->input, + 'label' => $this->label ?? Str::headline($this->input), + 'help' => $this->help, + 'tab' => $this->tab, + 'field' => $this->field, + 'options' => $this->options, + 'value' => $this->serializePublic($currentValue), + 'constraints' => [ + 'max_length' => $this->maxLength, + 'max_items' => $this->maxItems, + 'max_kilobytes' => $this->maxKilobytes, + 'accept' => $this->mimes, + ], + 'visibility' => match (true) { + $this->guests => 'public', + $this->frontend => 'frontend', + default => 'admin', + }, + ]; + } + + /** @param list $options */ + private function useField(string $field, array $options = []): self + { + throw_if($this->secret && in_array($field, self::RICH_FIELDS, true), InvalidArgumentException::class, sprintf('A secret extension setting cannot use the %s field.', $field)); + $this->field = $field; + $this->options = $options; + + return $this; + } + + /** @return list */ + private function choices(): array + { + return array_values(array_filter(array_column($this->options, 'value'), fn (string|int|bool $value): bool => $value !== true && $value !== false)); + } +} diff --git a/app/Services/Extensions/ExtensionSettingFiles.php b/app/Services/Extensions/ExtensionSettingFiles.php new file mode 100644 index 000000000..ad4357c3e --- /dev/null +++ b/app/Services/Extensions/ExtensionSettingFiles.php @@ -0,0 +1,238 @@ + 'png', + 'image/jpeg' => 'jpg', + 'image/gif' => 'gif', + 'image/webp' => 'webp', + 'image/avif' => 'avif', + 'image/x-icon' => 'ico', + 'image/svg+xml' => 'svg', + 'font/woff2' => 'woff2', + 'font/woff' => 'woff', + ]; + + /** The default allow-list: raster images only. SVG has to be listed explicitly. */ + public const array IMAGES = ['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/avif']; + + public const string NAME_PATTERN = '/\A[a-f0-9]{40}\.(?:png|jpg|gif|webp|avif|ico|svg|woff2|woff)\z/'; + + /** Hard ceiling for any `file` setting, whatever its definition declares. */ + public const int MAX_KILOBYTES = 10240; + + public const string ROUTE_PREFIX = 'extension-files'; + + private const string DIRECTORY = 'extension-files'; + + private const int MAX_DIMENSION = 10000; + + /** The public URL (a path on this panel) a stored file is served from. */ + public static function url(string $extension, string $name): string + { + return '/'.self::ROUTE_PREFIX.'/'.$extension.'/'.$name; + } + + /** + * Validate an upload against a definition's limits and store it under a + * fresh random name. + * + * @param list $mimes allowed types, keys of self::TYPES + * @return string the stored name, which is the setting's value + */ + public function store(string $extension, UploadedFile $upload, array $mimes, int $maxKilobytes): string + { + $this->assertExtension($extension); + $bytes = $upload->isValid() ? $upload->getContent() : ''; + if ($bytes === '') { + $this->reject('The uploaded file is empty or could not be read.'); + } + + if (mb_strlen($bytes, '8bit') > min($maxKilobytes, self::MAX_KILOBYTES) * 1024) { + $this->reject(sprintf('The file is larger than the allowed %d KB.', min($maxKilobytes, self::MAX_KILOBYTES))); + } + + $mime = $this->detect($bytes); + if ($mime === null || ! in_array($mime, $mimes, true)) { + $this->reject(sprintf('Unsupported file type. Allowed: %s.', implode(', ', $mimes))); + } + + $this->assertContent($mime, $bytes); + + $disk = $this->disk(); + do { + $name = bin2hex(random_bytes(20)).'.'.self::TYPES[$mime]; + } while ($disk->exists($this->path($extension, $name))); + + if (! $disk->put($this->path($extension, $name), $bytes)) { + $this->reject('The file could not be saved.'); + } + + return $name; + } + + /** + * The contents and served type of a stored file. The type comes from the + * stored name, which was derived from the content at upload time. + * + * @return array{contents: string, mime: string}|null + */ + public function read(string $extension, string $name): ?array + { + if (preg_match(ExtensionManifest::ID_REGEX, $extension) !== 1 || ExtensionSettingValueGuard::fileReference($name) === null) { + return null; + } + + $contents = $this->disk()->get($this->path($extension, $name)); + $mime = array_search(pathinfo($name, PATHINFO_EXTENSION), self::TYPES, true); + + return $contents === null || $mime === false ? null : ['contents' => $contents, 'mime' => $mime]; + } + + public function delete(string $extension, string $name): void + { + $this->assertExtension($extension); + if (ExtensionSettingValueGuard::fileReference($name) !== null) { + $this->disk()->delete($this->path($extension, $name)); + } + } + + /** + * Remove every file an extension uploaded, and the stored settings that + * referenced them, so a later reinstall starts from its defaults. + */ + public function purge(string $extension): void + { + $this->assertExtension($extension); + $this->disk()->deleteDirectory(self::DIRECTORY.'/'.$extension); + + $references = []; + foreach (ExtensionSetting::query()->where('extension', $extension)->where('is_secret', false)->whereNotNull('value')->get() as $row) { + $encoded = $row->value; + if ($encoded === null) { + continue; + } + + $value = rescue(fn (): bool|float|int|string|array|null => ExtensionSettingValueGuard::decode($encoded), report: false); + if (ExtensionSettingValueGuard::fileReference($value) !== null) { + $references[] = $row->id; + } + } + + if ($references !== []) { + ExtensionSetting::query()->whereIn('id', $references)->delete(); + } + } + + private function disk(): Filesystem + { + return Storage::disk(JsonValueGuard::string(config('extensions.files_disk'))); + } + + private function path(string $extension, string $name): string + { + return self::DIRECTORY.'/'.$extension.'/'.$name; + } + + private function assertExtension(string $extension): void + { + throw_unless(preg_match(ExtensionManifest::ID_REGEX, $extension) === 1, ValidationException::withMessages(['file' => 'Invalid extension id.'])); + } + + private function reject(string $message): never + { + throw ValidationException::withMessages(['file' => $message]); + } + + /** The type of the bytes, from their signature alone. */ + private function detect(string $bytes): ?string + { + return match (true) { + str_starts_with($bytes, "\x89PNG\r\n\x1a\n") => 'image/png', + str_starts_with($bytes, "\xFF\xD8\xFF") => 'image/jpeg', + str_starts_with($bytes, 'GIF87a'), str_starts_with($bytes, 'GIF89a') => 'image/gif', + str_starts_with($bytes, 'RIFF') && mb_substr($bytes, 8, 4, '8bit') === 'WEBP' => 'image/webp', + mb_substr($bytes, 4, 4, '8bit') === 'ftyp' && str_contains(mb_substr($bytes, 8, 24, '8bit'), 'avif') => 'image/avif', + str_starts_with($bytes, "\x00\x00\x01\x00") => 'image/x-icon', + str_starts_with($bytes, 'wOF2') => 'font/woff2', + str_starts_with($bytes, 'wOFF') => 'font/woff', + $this->looksLikeSvg($bytes) => 'image/svg+xml', + default => null, + }; + } + + /** Checks beyond the signature: raster images must decode, SVG must be inert. */ + private function assertContent(string $mime, string $bytes): void + { + if ($mime === 'image/svg+xml') { + $this->assertSafeSvg($bytes); + + return; + } + + if (! in_array($mime, ['image/png', 'image/jpeg', 'image/gif', 'image/webp'], true)) { + // Fonts carry no dimensions, and not every PHP build can read AVIF or ICO headers. + return; + } + + $size = @getimagesizefromstring($bytes); + if ($size === false || $size['mime'] !== $mime) { + $this->reject('The image is corrupt or unreadable.'); + } + + if ($size[0] < 1 || $size[1] < 1 || $size[0] > self::MAX_DIMENSION || $size[1] > self::MAX_DIMENSION) { + $this->reject(sprintf('The image has unreasonable dimensions (max %d px per side).', self::MAX_DIMENSION)); + } + } + + private function looksLikeSvg(string $bytes): bool + { + return preg_match('/\A(?:\xEF\xBB\xBF)?\s*(?:<\?xml[^>]*\?>\s*)?(?:\s*)*]/is', mb_substr($bytes, 0, 2048, '8bit')) === 1; + } + + /** + * Reject SVGs carrying active or external content. The sandboxing policy the + * file route serves them with is the real defence; this is a second layer. + */ + private function assertSafeSvg(string $bytes): void + { + if (preg_match('/reject('The SVG contains active or external content and was rejected.'); + } + + $previous = libxml_use_internal_errors(true); + + try { + $document = new DOMDocument; + $root = @$document->loadXML($bytes, LIBXML_NONET) ? $document->documentElement : null; + if (! $root instanceof DOMElement || $root->localName !== 'svg') { + $this->reject('The SVG is not valid XML.'); + } + } finally { + libxml_clear_errors(); + libxml_use_internal_errors($previous); + } + } +} diff --git a/app/Services/Extensions/ExtensionSettingValueGuard.php b/app/Services/Extensions/ExtensionSettingValueGuard.php new file mode 100644 index 000000000..dc8acfc74 --- /dev/null +++ b/app/Services/Extensions/ExtensionSettingValueGuard.php @@ -0,0 +1,160 @@ +\d{1,3}(?:\.\d{1,6})?|\.\d{1,6}))/'; + + /** + * @return ExtensionSettingValue + */ + public static function decode(string $encoded, bool $secret = false): bool|float|int|string|array|null + { + $value = JsonValueGuard::decode($encoded); + if (! $secret) { + return $value; + } + + throw_unless(is_string($value), UnexpectedValueException::class, 'Encrypted extension settings must be strings.'); + + return JsonValueGuard::decode(Crypt::decryptString($value)); + } + + /** @param ExtensionSettingValue $value */ + public static function encode(mixed $value, bool $secret = false): string + { + $encoded = json_encode($value, JSON_THROW_ON_ERROR); + + return $secret ? json_encode(Crypt::encryptString($encoded), JSON_THROW_ON_ERROR) : $encoded; + } + + /** + * @phpstan-assert ExtensionSettingValue $value + */ + public static function assertValue(mixed $value, int $remainingDepth = 10): void + { + JsonValueGuard::assertValue($value, $remainingDepth); + } + + /** @phpstan-assert ExtensionSettingValues $value */ + public static function assertValues(mixed $value): void + { + throw_unless(is_array($value), UnexpectedValueException::class, 'Extension settings must be an object.'); + + foreach ($value as $key => $item) { + throw_unless(is_string($key), UnexpectedValueException::class, 'Extension setting names must be strings.'); + + self::assertValue($item); + } + } + + /** + * The canonical form of a colour setting (lower case, single spaces), or + * null when the value is not a colour this panel accepts. + * + * @param ExtensionSettingValue $value + */ + public static function color(bool|float|int|string|array|null $value): ?string + { + if (! is_string($value) || mb_strlen($value) > 64) { + return null; + } + + $color = preg_replace(['/\s+/', '/ ?\/ ?/'], [' ', ' / '], mb_strtolower(mb_trim($value))) ?? ''; + $color = str_replace(['( ', ' )'], ['(', ')'], $color); + + return preg_match(self::COLOR_PATTERN, $color) === 1 ? $color : null; + } + + /** + * A multi-line text setting with its line endings normalized, or null when + * the value is not a string. + * + * @param ExtensionSettingValue $value + */ + public static function text(bool|float|int|string|array|null $value): ?string + { + return is_string($value) ? str_replace(["\r\n", "\r"], "\n", $value) : null; + } + + /** + * The string items of a list setting, in order, or null when the value is + * not a list. + * + * @param ExtensionSettingValue $value + * @return list|null + */ + public static function strings(bool|float|int|string|array|null $value): ?array + { + if (! is_array($value) || ! array_is_list($value)) { + return null; + } + + return array_values(array_filter($value, is_string(...))); + } + + /** + * The declared choices present in a multiselect value, deduplicated and in + * declaration order, or null when the value is not a list. Anything that is + * not a declared choice is dropped. + * + * @param ExtensionSettingValue $value + * @param list $choices + * @return list|null + */ + public static function choices(bool|float|int|string|array|null $value, array $choices): ?array + { + if (! is_array($value) || ! array_is_list($value)) { + return null; + } + + $selected = []; + foreach ($value as $item) { + if (is_string($item) || is_int($item)) { + // SAFETY: only strings and integers reach this cast, and both stringify losslessly. + $selected[(string) $item] = true; + } + } + + // SAFETY: declared choices are strings or integers, which stringify losslessly. + return array_values(array_filter($choices, fn (string|int $choice): bool => isset($selected[(string) $choice]))); + } + + /** + * The stored name of an uploaded settings file, or null when the value is not one. + * + * @param ExtensionSettingValue $value + */ + public static function fileReference(bool|float|int|string|array|null $value): ?string + { + return is_string($value) && preg_match(ExtensionSettingFiles::NAME_PATTERN, $value) === 1 ? $value : null; + } + + /** + * @param ExtensionSettingValue $value + * @param 'string'|'number'|'boolean'|'array'|'object'|'null'|'json' $type + */ + public static function assertFrontendType(mixed $value, string $type): void + { + $valid = match ($type) { + 'string' => is_string($value), + 'number' => is_int($value) || is_float($value), + 'boolean' => is_bool($value), + 'array' => is_array($value) && array_is_list($value), + 'object' => is_array($value) && $value !== [] && array_all(array_keys($value), fn (int|string $key): bool => is_string($key)), + 'null' => $value === null, + 'json' => true, + }; + throw_unless($valid, UnexpectedValueException::class, "Extension frontend setting does not match its declared {$type} type."); + } +} diff --git a/app/Services/Extensions/ExtensionSettings.php b/app/Services/Extensions/ExtensionSettings.php new file mode 100644 index 000000000..da92e5f12 --- /dev/null +++ b/app/Services/Extensions/ExtensionSettings.php @@ -0,0 +1,199 @@ +exists, InvalidArgumentException::class, 'Scoped settings require a persisted user or server.'); + } + + /** @param list $settings */ + public static function preload(array $settings): void + { + $pending = []; + foreach ($settings as $setting) { + if ($setting->loaded === null) { + $pending[$setting->extension.'|'.$setting->scope()] = $setting; + } + } + + if ($pending === []) { + return; + } + + $rows = ExtensionSetting::query() + ->whereIn('extension', array_map(fn (self $setting): string => $setting->extension, $pending)) + ->whereIn('scope', array_map(fn (self $setting): string => $setting->scope(), $pending)) + ->get()->groupBy(fn (ExtensionSetting $row): string => $row->extension.'|'.$row->scope); + foreach ($pending as $identifier => $setting) { + try { + $values = []; + foreach ($rows->get($identifier) ?? [] as $row) { + $values[$row->key] = $row->value === null ? null : ExtensionSettingValueGuard::decode($row->value, $row->is_secret); + } + + $setting->loaded = $values; + } catch (Throwable) { + // Leave invalid settings to the existing per-extension error boundary. + } + } + } + + /** The id of the extension these settings belong to. */ + public function extension(): string + { + return $this->extension; + } + + public function forUser(User $user): self + { + return new self($this->extension, $user); + } + + public function forServer(Server $server): self + { + return new self($this->extension, $server); + } + + /** + * @param ExtensionSettingValue $default + * @return ExtensionSettingValue + */ + public function get(string $key, mixed $default = null): mixed + { + $loaded = $this->loaded ??= $this->all(); + + return array_key_exists($key, $loaded) ? $loaded[$key] : $default; + } + + /** @return ExtensionSettingValues */ + public function all(): array + { + $values = []; + foreach ($this->query()->get() as $row) { + $values[$row->key] = $row->value === null ? null : ExtensionSettingValueGuard::decode($row->value, $row->is_secret); + } + + return $this->loaded = $values; + } + + /** @param ExtensionSettingValue $value */ + public function set(string $key, mixed $value): void + { + $this->setMany([$key => $value]); + } + + /** @param ExtensionSettingValue $value */ + public function setSecret(string $key, mixed $value): void + { + $this->setManySecrets([$key => $value], [$key]); + } + + /** @param ExtensionSettingValues $values */ + public function setMany(array $values): void + { + $this->persist($values, []); + } + + /** + * @param ExtensionSettingValues $values + * @param list $secretKeys + */ + public function setManySecrets(array $values, array $secretKeys): void + { + $this->persist($values, $secretKeys); + } + + public function forget(string $key): void + { + $this->query() + ->where('key', $key) + ->delete(); + + unset($this->loaded[$key]); + } + + /** @return ExtensionSettingValues keys matching the prefix, prefix stripped */ + public function getByPrefix(string $prefix): array + { + return $this->query() + ->where('key', 'like', str_replace(['%', '_'], ['\\%', '\\_'], $prefix).'%') + ->get() + ->mapWithKeys(fn (ExtensionSetting $setting): array => [ + mb_substr($setting->key, mb_strlen($prefix)) => $setting->value === null ? null : ExtensionSettingValueGuard::decode($setting->value, $setting->is_secret), + ]) + ->all(); + } + + public function forgetByPrefix(string $prefix): void + { + $this->query() + ->where('key', 'like', str_replace(['%', '_'], ['\\%', '\\_'], $prefix).'%') + ->delete(); + + $this->loaded = null; + } + + /** + * @param ExtensionSettingValues $values + * @param list $secretKeys + */ + private function persist(array $values, array $secretKeys): void + { + if ($values === []) { + return; + } + + $rows = []; + foreach ($values as $key => $value) { + $rows[] = [ + 'extension' => $this->extension, + 'key' => $key, + 'scope' => $this->scope(), + 'user_id' => $this->subject instanceof User ? $this->subject->id : null, + 'server_id' => $this->subject instanceof Server ? $this->subject->id : null, + 'is_secret' => in_array($key, $secretKeys, true), + 'value' => ExtensionSettingValueGuard::encode($value, in_array($key, $secretKeys, true)), + ]; + } + + ExtensionSetting::query()->upsert($rows, ['extension', 'scope', 'key'], ['value', 'is_secret', 'updated_at']); + + if ($this->loaded !== null) { + $this->loaded = array_replace($this->loaded, $values); + } + } + + private function scope(): string + { + return match (true) { + $this->subject instanceof User => 'user:'.$this->subject->id, + $this->subject instanceof Server => 'server:'.$this->subject->id, + default => 'global', + }; + } + + /** @return Builder */ + private function query(): Builder + { + return ExtensionSetting::query()->where('extension', $this->extension)->where('scope', $this->scope()); + } +} diff --git a/app/Services/Extensions/ExtensionSettingsDefinition.php b/app/Services/Extensions/ExtensionSettingsDefinition.php new file mode 100644 index 000000000..8a850795c --- /dev/null +++ b/app/Services/Extensions/ExtensionSettingsDefinition.php @@ -0,0 +1,227 @@ + */ + private array $definitions; + + /** @param array $definitions */ + public function __construct( + private readonly ExtensionSettings $settings, + array $definitions, + ) { + $this->definitions = []; + foreach ($definitions as $definition) { + $this->definitions[$definition->key] = $definition; + } + } + + public function forUser(User $user): self + { + return new self($this->settings->forUser($user), array_values($this->definitions)); + } + + public function forServer(Server $server): self + { + return new self($this->settings->forServer($server), array_values($this->definitions)); + } + + /** The id of the extension these settings belong to. */ + public function extension(): string + { + return $this->settings->extension(); + } + + /** + * The setting's current value. A file setting reads as the public URL of + * its uploaded file, or its default while nothing is uploaded. + * + * @return ExtensionSettingValue + */ + public function get(string $key): mixed + { + $definition = $this->definitions[$key] ?? null; + if ($definition === null) { + throw new InvalidArgumentException(sprintf('Unknown extension setting "%s".', $key)); + } + + if ($definition->isFile()) { + $name = $this->storedFile($definition); + + return $definition->normalize($name === null ? $definition->default : ExtensionSettingFiles::url($this->extension(), $name)); + } + + return $definition->normalize($this->settings->get($definition->key, $definition->default)); + } + + /** @return ExtensionSettingValues */ + public function publicSettings(): array + { + $values = []; + foreach ($this->definitions as $definition) { + $values[$definition->publicName()] = $definition->serializePublic($this->get($definition->key)); + } + + return $values; + } + + /** + * Rules for a partial update: every input is optional and, when submitted, must pass + * its definition's rules and those of its field type. Inputs without rules of their + * own are accepted as given. File inputs are prohibited: files are uploaded and + * cleared through replaceFile(). + * + * @return NormalizedValidationRules + */ + public function validationRules(): array + { + $rules = []; + foreach ($this->definitions as $definition) { + $rules = [...$rules, ...$definition->validationRules()]; + } + + return $rules; + } + + /** @param ExtensionSettingValues $input */ + public function update(array $input): void + { + $input = $this->withoutBlankSecrets($input); + $values = []; + $secretKeys = []; + foreach ($this->definitions as $definition) { + if ($definition->isFile() || ! array_key_exists($definition->input, $input)) { + continue; + } + + $values[$definition->key] = $definition->normalize($input[$definition->input]); + if ($definition->isSecret()) { + $secretKeys[] = $definition->key; + } + } + + if ($secretKeys === []) { + $this->settings->setMany($values); + + return; + } + + $this->settings->setManySecrets($values, $secretKeys); + } + + /** + * @param ExtensionSettingValues $input + * @return ExtensionSettingValues + */ + public function withoutBlankSecrets(array $input): array + { + foreach ($this->definitions as $definition) { + if ($definition->isSecret() && in_array($input[$definition->input] ?? null, ['', null], true)) { + unset($input[$definition->input]); + } + } + + return $input; + } + + /** + * Field schema for the auto-rendered admin settings form, in definition + * order, with each entry carrying its current public value. + * + * @return list + */ + public function schema(): array + { + return array_values(array_map( + fn (ExtensionSettingDefinition $definition): array => $definition->describe($this->get($definition->key)), + $this->definitions, + )); + } + + /** The file setting behind an input name, or null when the input is not a file setting. */ + public function fileField(string $input): ?ExtensionSettingDefinition + { + return array_find($this->definitions, fn (ExtensionSettingDefinition $definition): bool => $definition->input === $input && $definition->isFile()); + } + + /** + * Point a file setting at a newly stored file, or clear it with null. + * + * @return string|null the stored name it pointed at before, which the caller deletes + */ + public function replaceFile(string $input, ?string $name): ?string + { + $definition = $this->fileField($input); + throw_unless($definition instanceof ExtensionSettingDefinition, InvalidArgumentException::class, sprintf('Extension setting "%s" is not a file setting.', $input)); + throw_if($name !== null && ExtensionSettingValueGuard::fileReference($name) === null, InvalidArgumentException::class, 'Invalid stored file name.'); + + $previous = $this->storedFile($definition); + if ($name === null) { + $this->settings->forget($definition->key); + } else { + $this->settings->set($definition->key, $name); + } + + return $previous; + } + + /** + * Values exposed to the extension's frontend bundle as ctx.config: only + * definitions explicitly marked ->frontend(), keyed by public name. These + * are visible to every logged-in user. With $publicOnly, only those also + * marked ->public(), which is what visitors who are not signed in receive. + * + * @return ExtensionSettingValues + */ + public function frontendConfig(bool $publicOnly = false): array + { + $config = []; + foreach ($this->definitions as $definition) { + if (! $definition->isFrontend() || ($publicOnly && ! $definition->isPublic())) { + continue; + } + + $value = $definition->serializePublic($this->get($definition->key)); + ExtensionSettingValueGuard::assertFrontendType($value, $definition->declaredFrontendType()); + $config[$definition->publicName()] = $value; + } + + return $config; + } + + /** @return array */ + public function frontendConfigTypes(): array + { + $types = []; + foreach ($this->definitions as $definition) { + if ($definition->isFrontend()) { + $types[$definition->publicName()] = $definition->declaredFrontendType(); + } + } + + return $types; + } + + /** @return list public names of the frontend settings that guests receive too */ + public function publicConfigKeys(): array + { + return array_values(array_map( + fn (ExtensionSettingDefinition $definition): string => $definition->publicName(), + array_filter($this->definitions, fn (ExtensionSettingDefinition $definition): bool => $definition->isPublic()), + )); + } + + private function storedFile(ExtensionSettingDefinition $definition): ?string + { + return ExtensionSettingValueGuard::fileReference($this->settings->get($definition->key)); + } +} diff --git a/app/Services/Extensions/ExtensionSettingsRegistry.php b/app/Services/Extensions/ExtensionSettingsRegistry.php new file mode 100644 index 000000000..0f91c76d3 --- /dev/null +++ b/app/Services/Extensions/ExtensionSettingsRegistry.php @@ -0,0 +1,37 @@ + */ + private array $definitions = []; + + public function register(string $identifier, ExtensionSettingsDefinition $definition): void + { + $this->definitions[$identifier] = $definition; + } + + public function get(string $identifier): ?ExtensionSettingsDefinition + { + return $this->definitions[$identifier] ?? null; + } + + public function unregister(string $identifier): void + { + unset($this->definitions[$identifier]); + } + + public function has(string $identifier): bool + { + return isset($this->definitions[$identifier]); + } +} diff --git a/app/Services/Extensions/ExtensionStylesheetInspector.php b/app/Services/Extensions/ExtensionStylesheetInspector.php new file mode 100755 index 000000000..83b26c73f --- /dev/null +++ b/app/Services/Extensions/ExtensionStylesheetInspector.php @@ -0,0 +1,154 @@ +hasUi() || ! is_dir($manifest->path('dist'))) { + return null; + } + + foreach (File::allFiles($manifest->path('dist')) as $file) { + if ($file->getExtension() !== 'css') { + continue; + } + + $foreign = $this->foreign($file->getContents(), $manifest->uiPrefix); + $found = [...$foreign['utilities'], ...$foreign['theme']]; + if ($found === []) { + continue; + } + + $listed = implode(', ', array_slice($found, 0, self::REPORTED)).(count($found) > self::REPORTED ? ', ...' : ''); + $what = match (true) { + $foreign['utilities'] === [] => 'Tailwind theme variables', + $foreign['theme'] === [] => 'Tailwind utilities', + default => 'Tailwind utilities and theme variables', + }; + $prefix = $manifest->uiPrefix ?? ExtensionManifest::defaultUiPrefix($manifest->id); + $problem = $manifest->uiPrefix === null + ? "but declares no Tailwind prefix - add \"prefix\": \"{$prefix}\" to \"ui\" in ".ExtensionManifest::FILENAME.', build' + : "without its \"{$prefix}\" prefix, which override the panel's or another extension's styles - build"; + + return "Extension \"{$manifest->id}\" ships {$what} in dist/{$file->getRelativePathname()} ({$listed}) {$problem} Tailwind with `prefix({$prefix})`, write its classes as `{$prefix}:flex` (see the SDK README, \"Styling\") and rebuild."; + } + + return null; + } + + /** + * The selectors in `@layer utilities` that are not built on a utility class with the + * given prefix and the custom properties declared in `@layer theme` without it. With no + * prefix every rule and property in those layers is reported. + * + * @return array{utilities: list, theme: list} + */ + public function foreign(string $css, ?string $prefix): array + { + $class = $prefix === null ? null : '.'.$prefix.'\\:'; + $property = $prefix === null ? null : '--'.$prefix.'-'; + $utilities = []; + $theme = []; + // The prelude of every block that is open at the cursor. + $blocks = []; + // The prelude or declaration being read: its finished comma separated parts and the open one. + $parts = []; + $part = ''; + $depth = 0; + preg_match_all(self::TOKENS, $css, $tokens); + + foreach ($tokens[0] as $token) { + if (str_starts_with($token, '/*')) { + continue; + } + + if ($token === ',' && $depth === 0) { + $parts[] = $part; + $part = ''; + + continue; + } + + if (! in_array($token, ['{', '}', ';'], true)) { + $depth += match ($token) { + '(', '[' => 1, + ')', ']' => -1, + default => 0, + }; + $part .= $token; + + continue; + } + + $selectors = array_map(trim(...), [...$parts, $part]); + if ($token === '{') { + if ($this->layer($blocks) === 'utilities' && ! str_starts_with($selectors[0], '@') && $this->groupsRules($blocks)) { + $utilities = [...$utilities, ...array_filter($selectors, fn (string $selector): bool => $selector !== '' && ($class === null || ! str_contains($selector, $class)))]; + } + + $blocks[] = implode(',', $selectors); + } elseif ($this->layer($blocks) === 'theme' && preg_match('/^(--[\w-]+)\s*:/', $selectors[0], $matches) === 1 && ($property === null || ! str_starts_with($matches[1], $property))) { + $theme[] = $matches[1]; + } + + if ($token === '}') { + array_pop($blocks); + } + + $parts = []; + $part = ''; + $depth = 0; + } + + return ['utilities' => array_values(array_unique($utilities)), 'theme' => array_values(array_unique($theme))]; + } + + /** + * The cascade layer the open blocks sit in. + * + * @param list $blocks + */ + private function layer(array $blocks): ?string + { + foreach ($blocks as $prelude) { + if (preg_match('/^@layer\s+([\w.-]+)$/', $prelude, $matches) === 1) { + return $matches[1]; + } + } + + return null; + } + + /** + * Whether every open block only groups style rules, so the next rule is a top-level one + * rather than a nested rule (`&:hover`) or a keyframe. A minifier may still hoist the + * utility class into a pseudo-class (`:where(.hw\:space-y-2 > *)`), which is why the + * class is looked for anywhere in such a rule's selector. + * + * @param list $blocks + */ + private function groupsRules(array $blocks): bool + { + return array_all($blocks, fn (string $prelude): bool => preg_match('/^@(layer|media|supports|container|starting-style)\b/', $prelude) === 1); + } +} diff --git a/app/Services/Extensions/Scaffolding/ExtensionScaffolder.php b/app/Services/Extensions/Scaffolding/ExtensionScaffolder.php new file mode 100644 index 000000000..77f89b187 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/ExtensionScaffolder.php @@ -0,0 +1,199 @@ +// and returns the created package path. The manifest + * is re-validated through the normal loader before returning, so a scaffold + * that succeeds is guaranteed installable. + */ + public function scaffold( + string $id, + ?string $name = null, + ?string $description = null, + ?string $author = null, + bool $ui = true, + ?string $outDir = null, + bool $force = false, + ?string $prefix = null, + ): string { + $this->files = []; + + throw_unless(preg_match(ExtensionManifest::ID_REGEX, $id), InvalidExtensionException::class, "Extension id \"{$id}\" must match ".ExtensionManifest::ID_REGEX.'.'); + + throw_if(in_array($id, ExtensionManifest::RESERVED_IDS, true), InvalidExtensionException::class, "Extension id \"{$id}\" is reserved."); + + $prefix ??= ExtensionManifest::defaultUiPrefix($id); + throw_unless(ExtensionManifest::isUsableUiPrefix($prefix), InvalidExtensionException::class, "Tailwind prefix \"{$prefix}\" must match ".ExtensionManifest::UI_PREFIX_REGEX.' and must not be a Tailwind variant, theme namespace or panel name.'); + + $target = mb_rtrim($outDir ?? JsonValueGuard::string(config('extensions.directory')), '/\\').DIRECTORY_SEPARATOR.$id; + throw_if(is_dir($target) && ! $force, InvalidExtensionException::class, "{$target} already exists - pass --force to overwrite it."); + + File::deleteDirectory($target); + File::ensureDirectoryExists($target); + + $namespace = Str::studly(str_replace('-', '_', $id)); + $replacements = [ + '{{id}}' => $id, + '{{name}}' => $name ?: Str::headline($id), + '{{description}}' => $description ?? '', + '{{author}}' => $author ?? '', + '{{namespace}}' => $namespace, + '{{provider}}' => $namespace.'Provider', + '{{sdkDependency}}' => $this->sdkDependency($target), + '{{prefix}}' => $prefix, + ]; + + $this->writeManifest($target, $id, $namespace, $replacements, $ui); + + $this->stub($target, 'provider.stub', 'src/'.$namespace.'Provider.php', $replacements); + $this->stub($target, 'controller.stub', 'src/Http/Controllers/StatusController.php', $replacements); + $this->stub($target, 'routes-client.stub', 'routes/client.php', $replacements); + $this->stub($target, 'gitignore.stub', '.gitignore', $replacements); + + File::ensureDirectoryExists($target.'/database/migrations'); + + if ($ui) { + $this->stub($target, 'client-index.stub', 'src/client/index.tsx', $replacements); + $this->stub($target, 'client-server-screen.stub', 'src/client/screens/ServerScreen.tsx', $replacements); + $this->stub($target, 'vite.config.stub', 'vite.config.mjs', $replacements); + $this->stub($target, 'tsconfig.stub', 'tsconfig.json', $replacements); + $this->stub($target, 'package.stub', 'package.json', $replacements); + $this->stub($target, 'client-styles.stub', 'src/client/styles.css', $replacements); + $this->stub($target, 'postcss.config.stub', 'postcss.config.mjs', $replacements); + $this->stub($target, 'vitest.config.stub', 'vitest.config.mjs', $replacements); + $this->stub($target, 'client-test.stub', 'src/client/screens/ServerScreen.spec.tsx', $replacements); + $this->stub($target, 'openapi.config.stub', 'openapi-ts.config.ts', $replacements); + $this->stub($target, 'externalize-api.stub', 'scripts/externalize-api.mjs', $replacements); + $this->stub($target, 'ci.stub', '.github/workflows/ci.yml', $replacements); + } + + $replacements['{{frontend}}'] = $ui + ? strtr($this->stubContents('readme-frontend.stub'), $replacements) + : ''; + $this->stub($target, 'readme.stub', 'README.md', $replacements); + + // A scaffold the panel itself cannot load is a bug - fail loudly here. + $this->validator->fromDirectory($target); + + return $target; + } + + /** @return string[] package-relative paths created by the last scaffold() call */ + public function files(): array + { + return $this->files; + } + + /** + * @param array $replacements stub placeholder => literal substitution + */ + private function writeManifest(string $target, string $id, string $namespace, array $replacements, bool $ui): void + { + $manifest = array_filter([ + '$schema' => $ui ? './node_modules/@pterodactyl/sdk/manifest.schema.json' : null, + 'id' => $id, + 'name' => $replacements['{{name}}'], + 'version' => '1.0.0', + 'requires' => ['panel' => '^2.0.0-dev', 'sdk' => '^2.0.0-beta.4', 'php' => '^8.3'], + 'description' => $replacements['{{description}}'] ?: null, + 'author' => $replacements['{{author}}'] ?: null, + 'provider' => $namespace.'\\'.$namespace.'Provider', + 'autoload' => [$namespace.'\\' => 'src'], + 'ui' => $ui ? ['entry' => ExtensionManifest::UI_ENTRY, 'mode' => 'native', 'prefix' => $replacements['{{prefix}}'], 'screens' => [['id' => 'main', 'area' => 'server', 'path' => $id, 'nav' => ['label' => $replacements['{{name}}']]]]] : null, + ], fn (array|string|null $value): bool => $value !== null); + + File::put( + $target.DIRECTORY_SEPARATOR.ExtensionManifest::FILENAME, + json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)."\n", + ); + $this->files[] = ExtensionManifest::FILENAME; + } + + /** + * @param array $replacements stub placeholder => literal substitution + */ + private function stub(string $target, string $stub, string $relative, array $replacements): void + { + $path = $target.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $relative); + + File::ensureDirectoryExists(dirname($path)); + File::put($path, strtr($this->stubContents($stub), $replacements)); + $this->files[] = $relative; + } + + private function stubContents(string $stub): string + { + $contents = file_get_contents(__DIR__.'/stubs/'.$stub); + throw_if($contents === false, InvalidExtensionException::class, "Unable to read extension scaffold stub [{$stub}]."); + + return $contents; + } + + /** + * The @pterodactyl/sdk devDependency for the generated package.json: a + * relative file: link to the panel's own SDK package when it is present + * (npm publish is still pending), otherwise the SDK's version range. + */ + private function sdkDependency(string $target): string + { + $sdk = base_path('packages'.DIRECTORY_SEPARATOR.'sdk'); + if (! is_file($sdk.DIRECTORY_SEPARATOR.'package.json')) { + return '^2.0.0-beta.4'; + } + + $relative = $this->relativePath($target, $sdk); + if ($relative !== null) { + return 'file:'.$relative; + } + + $version = File::json($sdk.DIRECTORY_SEPARATOR.'package.json')['version'] ?? null; + + return '^'.(is_string($version) ? $version : '2.0.0-beta.4'); + } + + private function relativePath(string $from, string $to): ?string + { + $from = realpath($from); + $to = realpath($to); + if ($from === false || $to === false) { + return null; + } + + $fromParts = explode(DIRECTORY_SEPARATOR, $from); + $toParts = explode(DIRECTORY_SEPARATOR, $to); + $shared = 0; + while (isset($fromParts[$shared], $toParts[$shared]) && $fromParts[$shared] === $toParts[$shared]) { + $shared++; + } + + // Different roots (e.g. Windows drives) - no relative path exists. + if ($shared === 0) { + return null; + } + + return str_repeat('../', count($fromParts) - $shared).implode('/', array_slice($toParts, $shared)); + } +} diff --git a/app/Services/Extensions/Scaffolding/stubs/ci.stub b/app/Services/Extensions/Scaffolding/stubs/ci.stub new file mode 100644 index 000000000..556766d28 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/ci.stub @@ -0,0 +1,21 @@ +name: Extension CI +on: [push, pull_request] +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - uses: actions/checkout@v4 + with: + repository: pterodactyl/panel-next + ref: 2.0-develop + path: .panel + - run: npm ci && npm run sdk:generate && npm run sdk:testing + working-directory: .panel + - run: npm pkg set 'devDependencies.@pterodactyl/sdk=file:./.panel/packages/sdk' && npm install + - run: npm run typecheck + - run: npm test + - run: npm run build diff --git a/app/Services/Extensions/Scaffolding/stubs/client-index.stub b/app/Services/Extensions/Scaffolding/stubs/client-index.stub new file mode 100644 index 000000000..460f4e5d3 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/client-index.stub @@ -0,0 +1,10 @@ +import './styles.css'; +import { definePterodactylExtension } from '@pterodactyl/sdk'; + +export default definePterodactylExtension({ + setup({ screens }) { + screens.register('main', () => import('./screens/ServerScreen')); + // Declare paths, navigation, and permissions in extension.json ui.screens. + // Use slots.register('server.console.before', Component) for core anchors. + }, +}); diff --git a/app/Services/Extensions/Scaffolding/stubs/client-server-screen.stub b/app/Services/Extensions/Scaffolding/stubs/client-server-screen.stub new file mode 100644 index 000000000..7f84cc1e3 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/client-server-screen.stub @@ -0,0 +1,13 @@ +import { ServerContentBlock, TitledGreyBox } from '@pterodactyl/sdk'; + +export default function ServerScreen() { + return ( + + +

+ Edit src/client/screens/ServerScreen.tsx to build this page. +

+
+
+ ); +} diff --git a/app/Services/Extensions/Scaffolding/stubs/client-styles.stub b/app/Services/Extensions/Scaffolding/stubs/client-styles.stub new file mode 100644 index 000000000..5a580793b --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/client-styles.stub @@ -0,0 +1,4 @@ +@import 'tailwindcss/theme.css' layer(theme) prefix({{prefix}}); +@import 'tailwindcss/utilities.css' layer(utilities) prefix({{prefix}}); +@import '@pterodactyl/sdk/theme.css'; +@source './**/*.{ts,tsx}'; diff --git a/app/Services/Extensions/Scaffolding/stubs/client-test.stub b/app/Services/Extensions/Scaffolding/stubs/client-test.stub new file mode 100644 index 000000000..da1c3810c --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/client-test.stub @@ -0,0 +1,12 @@ +import { afterEach, expect, test } from 'vitest'; +import { cleanup, render, screen } from '@testing-library/react'; +import { createExtensionTestHost, createTestServer } from '@pterodactyl/sdk/testing'; +import ServerScreen from './ServerScreen'; + +const host = createExtensionTestHost({ extensionId: '{{id}}', server: createTestServer() }); +afterEach(() => { cleanup(); host.dispose(); }); + +test('renders inside the panel host', async () => { + render(, { wrapper: host.Wrapper }); + expect(await screen.findByText('Edit src/client/screens/ServerScreen.tsx to build this page.')).toBeTruthy(); +}); diff --git a/app/Services/Extensions/Scaffolding/stubs/controller.stub b/app/Services/Extensions/Scaffolding/stubs/controller.stub new file mode 100644 index 000000000..37eb129aa --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/controller.stub @@ -0,0 +1,23 @@ +settings('{{id}}') + return new JsonResponse([ + 'extension' => '{{id}}', + 'status' => 'ok', + ]); + } +} diff --git a/app/Services/Extensions/Scaffolding/stubs/externalize-api.stub b/app/Services/Extensions/Scaffolding/stubs/externalize-api.stub new file mode 100644 index 000000000..c7b648f38 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/externalize-api.stub @@ -0,0 +1,3 @@ +import { externalizeExtensionApi } from '@pterodactyl/sdk/openapi'; + +await externalizeExtensionApi('src/client/generated'); diff --git a/app/Services/Extensions/Scaffolding/stubs/gitignore.stub b/app/Services/Extensions/Scaffolding/stubs/gitignore.stub new file mode 100644 index 000000000..3d2bc6269 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/gitignore.stub @@ -0,0 +1,2 @@ +/dist/ +/node_modules/ diff --git a/app/Services/Extensions/Scaffolding/stubs/openapi.config.stub b/app/Services/Extensions/Scaffolding/stubs/openapi.config.stub new file mode 100644 index 000000000..11633eb55 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/openapi.config.stub @@ -0,0 +1,12 @@ +import { defineConfig } from '@hey-api/openapi-ts'; + +export default defineConfig({ + input: './openapi.yaml', + output: { path: './src/client/generated', clean: true }, + plugins: [ + '@hey-api/typescript', + { name: '@hey-api/client-axios', baseUrl: false, throwOnError: true }, + { name: '@hey-api/sdk', client: '@hey-api/client-axios', paramsStructure: 'grouped' }, + { name: '@tanstack/react-query', queryKeys: true, queryOptions: true, mutationKeys: true, mutationOptions: true }, + ], +}); diff --git a/app/Services/Extensions/Scaffolding/stubs/package.stub b/app/Services/Extensions/Scaffolding/stubs/package.stub new file mode 100644 index 000000000..e74034784 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/package.stub @@ -0,0 +1,43 @@ +{ + "name": "{{id}}", + "private": true, + "version": "1.0.0", + "type": "module", + "scripts": { + "build": "vite build", + "dev": "vite build --watch", + "typecheck": "tsc", + "test": "vitest run", + "test:watch": "vitest", + "api:generate": "openapi-ts && node scripts/externalize-api.mjs" + }, + "devDependencies": { + "@pterodactyl/sdk": "{{sdkDependency}}", + "@tanstack/react-query": "^5", + "@base-ui/react": "^1.6.0", + "@tanstack/form-core": "^1.33.0", + "@tanstack/react-form": "^1.33.0", + "@tanstack/react-router": "^1.170.17", + "axios": "^1.18.1", + "lucide-react": "^1.17.0", + "sonner": "^2.0.7", + "@types/react": "^19", + "@types/react-dom": "^19", + "react": "^19.2.0", + "react-dom": "^19.2.0", + "typescript": "^6", + "vite": "^8", + "vitest": "^4.1.9", + "jsdom": "^26.1.0", + "@testing-library/react": "^16", + "@testing-library/dom": "^10", + "@hey-api/openapi-ts": "0.99.0", + "@types/node": "^22", + "tailwindcss": "^4.3.0", + "@tailwindcss/postcss": "^4", + "postcss": "^8.5.6" + }, + "overrides": { + "js-yaml": "^4.3.2" + } +} diff --git a/app/Services/Extensions/Scaffolding/stubs/postcss.config.stub b/app/Services/Extensions/Scaffolding/stubs/postcss.config.stub new file mode 100644 index 000000000..d1840a7c4 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/postcss.config.stub @@ -0,0 +1 @@ +export default { plugins: { '@tailwindcss/postcss': {} } }; diff --git a/app/Services/Extensions/Scaffolding/stubs/provider.stub b/app/Services/Extensions/Scaffolding/stubs/provider.stub new file mode 100644 index 000000000..c0dcd6b62 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/provider.stub @@ -0,0 +1,29 @@ +registerApiRoutes(); + + // Uncomment as the extension grows: + // $this->loadExtensionMigrations(); + // $this->loadExtensionTranslations(); + // $this->registerCommands([...]) and $this->registerSchedule(fn (Schedule $schedule) => ...) + // $this->wrapAction(Contract::class, fn (Contract $inner): Contract => new Wrapper($inner)); + // $this->registerHeadTags([['tag' => 'meta', 'name' => 'theme-color', 'content' => '#0f172a']]); + // $this->registerRootRoutes(...) for prefixes claimed under "routes.root" in extension.json + } +} diff --git a/app/Services/Extensions/Scaffolding/stubs/readme-frontend.stub b/app/Services/Extensions/Scaffolding/stubs/readme-frontend.stub new file mode 100644 index 000000000..dad9a65ea --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/readme-frontend.stub @@ -0,0 +1,55 @@ +## Frontend + +The UI entry (`src/client/index.tsx`) is compiled against `@pterodactyl/sdk` to a +single prebuilt ESM file — the panel dynamic-imports it at boot and resolves +React, TanStack Query, and the SDK through its import map, so the bundle stays +tiny and shares the panel's runtime. + +```sh +npm install +npm run build # or: npm run dev (rebuild on change) +npm run typecheck +npm test +``` + +`dist/client.js` must exist before the extension is enabled; it is published to +`/assets/extensions/{{id}}/` on install/enable. + +A `file:` SDK dependency is a link into the panel checkout. `preserveSymlinks` in +`tsconfig.json` makes the SDK's types use this package's React and TanStack Query +instead of the panel's copies; keep it. + + +Screen metadata is declared in `extension.json` under `ui.screens`. The client entry registers the implementation with `screens.register('main', importer)`. Keep both IDs in sync. The panel renders while extensions load; errors and loading are isolated per mount. Reload the panel after enabling, disabling, updating, or changing extension configuration. + +Tests use the real SDK with `createExtensionTestHost`, including the host query cache, +router, permissions, and websocket events. CI runs types, tests, and a production build. + +To generate a client for this extension, export its routes from the panel after Scribe +generation, then run the generator in this package: + +```sh +php /path/to/panel/scripts/generate-extension-openapi.php {{id}} /path/to/panel/storage/app/private/scribe/openapi.yaml /path/to/{{id}}/openapi.yaml +npm run api:generate +``` + +The generated client uses `@pterodactyl/sdk/api` and the panel's shared authentication +and transport. Commit generated sources and the OpenAPI input with your extension. +Use `p:extension:doctor`, `p:extension:dev --watch`, and `p:extension:pack` from the panel +for validation, successful-build publishing, and runtime-only packaging. + +`src/client/styles.css` compiles Tailwind with this extension's own prefix, `{{prefix}}` +(`ui.prefix` in `extension.json`), and without resetting the panel, so its utilities never +collide with the panel's or another extension's: write `{{prefix}}:flex`, `{{prefix}}:lg:hidden`, +`{{prefix}}:hover:bg-accent`, `{{prefix}}:mt-4!` and `@apply {{prefix}}:flex`. Unprefixed classes are not in +the extension's stylesheet, and `p:extension:doctor` and the installer reject a build whose +prefix is not the declared one. The SDK theme maps the same live tokens as core, so use +`{{prefix}}:bg-card`, `{{prefix}}:text-foreground`, and `{{prefix}}:border-border` instead of palette +colors. Pass `prefix: '{{prefix}}'` to the SDK test hosts when a test asserts merged classes. +CSS loads before extension setup. + +Run `php artisan p:extension:types /path/to/{{id}}` to generate literal screen ids and +configuration keys after loading the provider. Declare frontend settings with +`->frontend()->frontendType('string')` and add `->public()` to those guests may read; use +`defineConfiguredExtension` with a runtime +parser and the generated types. Secret definitions use `->secret()` and stay backend-only. diff --git a/app/Services/Extensions/Scaffolding/stubs/readme.stub b/app/Services/Extensions/Scaffolding/stubs/readme.stub new file mode 100644 index 000000000..e3762f505 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/readme.stub @@ -0,0 +1,22 @@ +# {{name}} + +A Pterodactyl panel extension, scaffolded by `p:extension:make`. + +## Layout + +- `extension.json` — the manifest; `provider` is the boot entry point. +- `src/` — PSR-4 PHP (`{{namespace}}\`), booted through `src/{{provider}}.php`. + Runs fully trusted, in-process, with the same middleware stacks core uses. +- `routes/client.php` — mounted at `/api/client/extensions/{{id}}`. Add + `routes/admin.php` / `routes/application.php` for the other API surfaces. +- `database/migrations/` — extension-owned migrations. Prefix tables with + `ext_{{id}}_` by convention. + +{{frontend}}## Install + +```sh +php artisan p:extension:install /path/to/{{id}} --enable +``` + +Package for distribution by zipping the directory as `{{id}}.pteroext` +(exclude `node_modules/`; include `dist/`). diff --git a/app/Services/Extensions/Scaffolding/stubs/routes-client.stub b/app/Services/Extensions/Scaffolding/stubs/routes-client.stub new file mode 100644 index 000000000..d2fbe1fc2 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/routes-client.stub @@ -0,0 +1,7 @@ +name('status'); diff --git a/app/Services/Extensions/Scaffolding/stubs/tsconfig.stub b/app/Services/Extensions/Scaffolding/stubs/tsconfig.stub new file mode 100644 index 000000000..0e47da55a --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/tsconfig.stub @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "preserveSymlinks": true, + "jsx": "react-jsx", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "types": ["vite/client"], + "strict": true, + "noEmit": true, + "skipLibCheck": true + }, + "include": ["src/client/**/*"] +} diff --git a/app/Services/Extensions/Scaffolding/stubs/vite.config.stub b/app/Services/Extensions/Scaffolding/stubs/vite.config.stub new file mode 100644 index 000000000..346c85f5e --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/vite.config.stub @@ -0,0 +1,3 @@ +import { defineExtensionConfig } from '@pterodactyl/sdk/vite'; + +export default defineExtensionConfig({ entry: 'src/client/index.tsx' }); diff --git a/app/Services/Extensions/Scaffolding/stubs/vitest.config.stub b/app/Services/Extensions/Scaffolding/stubs/vitest.config.stub new file mode 100644 index 000000000..23ab3d493 --- /dev/null +++ b/app/Services/Extensions/Scaffolding/stubs/vitest.config.stub @@ -0,0 +1,8 @@ +import { defineConfig } from 'vitest/config'; +import { pterodactylTestAliases, pterodactylTestSetup, pterodactylTestDirectory } from '@pterodactyl/sdk/vitest'; + +export default defineConfig({ + server: { fs: { allow: [process.cwd(), pterodactylTestDirectory] } }, + resolve: { alias: pterodactylTestAliases() }, + test: { environment: 'jsdom', setupFiles: [pterodactylTestSetup] }, +}); diff --git a/app/Services/FilesystemChanges.php b/app/Services/FilesystemChanges.php new file mode 100644 index 000000000..a3b323f07 --- /dev/null +++ b/app/Services/FilesystemChanges.php @@ -0,0 +1,84 @@ + $replacements Target paths mapped to staged paths, or null for removal. + * @param Closure(): T $callback + * @return T + */ + public function run(array $replacements, Closure $callback): mixed + { + $backups = []; + + try { + foreach ($replacements as $target => $staged) { + $backup = File::exists($target) ? dirname($target).'/.previous-'.Str::random(12) : null; + if ($backup !== null) { + $this->move($target, $backup); + } + + $backups[$target] = $backup; + if ($staged !== null) { + File::ensureDirectoryExists(dirname($target)); + $this->move($staged, $target); + } + } + + $result = $callback(); + } catch (Throwable $throwable) { + foreach (array_reverse($backups, true) as $target => $backup) { + rescue(fn () => $this->restore($target, $backup)); + } + + throw $throwable; + } + + foreach ($backups as $backup) { + if ($backup !== null) { + rescue(fn () => $this->delete($backup)); + } + } + + return $result; + } + + public function delete(string $path): void + { + if (File::isDirectory($path)) { + File::deleteDirectory($path); + } else { + File::delete($path); + } + + clearstatcache(true, $path); + throw_if(File::exists($path), RuntimeException::class, "Unable to remove files at {$path}."); + } + + private function restore(string $target, ?string $backup): void + { + $this->delete($target); + if ($backup !== null) { + $this->move($backup, $target); + } + } + + private function move(string $from, string $to): void + { + throw_unless(File::move($from, $to), RuntimeException::class, "Unable to move {$from} to {$to}; the original remains at {$from}."); + } +} diff --git a/app/Services/Helpers/AssetHashService.php b/app/Services/Helpers/AssetHashService.php index 725a56669..fcffe3216 100644 --- a/app/Services/Helpers/AssetHashService.php +++ b/app/Services/Helpers/AssetHashService.php @@ -1,29 +1,49 @@ 'resources/scripts/ext-runtime/react.ts', + 'react/jsx-runtime' => 'resources/scripts/ext-runtime/react-jsx-runtime.ts', + 'react-dom' => 'resources/scripts/ext-runtime/react-dom.ts', + 'react-dom/client' => 'resources/scripts/ext-runtime/react-dom-client.ts', + '@tanstack/react-query' => 'resources/scripts/ext-runtime/tanstack-react-query.ts', + '@pterodactyl/sdk' => 'resources/scripts/sdk/index.ts', + '@pterodactyl/sdk/api' => 'resources/scripts/sdk/api.ts', + ]; - private Filesystem $filesystem; + /** @var ViteManifest|null */ + protected static ?array $manifest = null; - protected static mixed $manifest = null; + private readonly Filesystem $filesystem; /** * AssetHashService constructor. + * + * @param string|null $publicPath Directory holding the built assets; defaults to the public path. */ - public function __construct(FilesystemManager $filesystem) + public function __construct(FilesystemManager $filesystem, ?string $publicPath = null) { - $this->filesystem = $filesystem->createLocalDriver(['root' => public_path()]); + $this->filesystem = $filesystem->createLocalDriver(['root' => $publicPath ?? public_path()]); } /** @@ -31,10 +51,9 @@ class AssetHashService */ public function url(string $resource): string { - $file = last(explode('/', $resource)); - $data = Arr::get($this->manifest(), $file) ?? $file; + $entry = $this->entry($resource); - return str_replace($file, Arr::get($data, 'src') ?? $file, $resource); + return $entry === null ? $resource : $this->assetUrl($entry['file']); } /** @@ -42,10 +61,7 @@ class AssetHashService */ public function integrity(string $resource): string { - $file = last(explode('/', $resource)); - $data = array_get($this->manifest(), $file, $file); - - return Arr::get($data, 'integrity') ?? ''; + return $this->entry($resource)['integrity'] ?? ''; } /** @@ -53,24 +69,32 @@ class AssetHashService */ public function css(string $resource): string { - $attributes = [ - 'href' => $this->url($resource), - 'rel' => 'stylesheet preload', - 'as' => 'style', - 'crossorigin' => 'anonymous', - 'referrerpolicy' => 'no-referrer', - ]; + return $this->stylesheetTag($this->url($resource), $this->integrity($resource)); + } - if (config('pterodactyl.assets.use_hash')) { - $attributes['integrity'] = $this->integrity($resource); + /** + * Return stylesheet tags for CSS emitted with a JS entry. + */ + public function cssImports(string $resource): string + { + $entry = $this->entry($resource); + if ($entry === null) { + return ''; } - $output = ' $value) { - $output .= " $key=\"$value\""; + $tags = []; + foreach ($entry['css'] ?? [] as $file) { + if ($file === '') { + continue; + } + + $tags[] = $this->stylesheetTag( + $this->assetUrl($file), + $entry['cssIntegrity'][$file] ?? '' + ); } - return $output . '>'; + return implode('', $tags); } /** @@ -81,6 +105,9 @@ class AssetHashService $attributes = [ 'src' => $this->url($resource), 'crossorigin' => 'anonymous', + // Vite emits ES modules (required for code-splitting / dynamic import), + // so the entry script must be loaded as a module. + 'type' => 'module', ]; if (config('pterodactyl.assets.use_hash')) { @@ -92,24 +119,139 @@ class AssetHashService $output .= " $key=\"$value\""; } - return $output . '>'; + return $output.'>'; + } + + /** + * Build the '; } /** * Get the asset manifest and store it in the cache for quicker lookups. + * + * @return ViteManifest Vite's manifest, keyed by source path. */ protected function manifest(): array { if (static::$manifest === null) { - self::$manifest = json_decode( - $this->filesystem->get(self::MANIFEST_PATH), - true - ); + $contents = $this->filesystem->get(self::MANIFEST_PATH); + throw_if($contents === null, ManifestDoesNotExistException::class); + + self::$manifest = $this->parseManifest($contents); } $manifest = static::$manifest; - if ($manifest === null) { - throw new ManifestDoesNotExistException(); + throw_if($manifest === null, ManifestDoesNotExistException::class); + + return $manifest; + } + + private function stylesheetTag(string $href, string $integrity = ''): string + { + $attributes = [ + 'href' => $href, + 'rel' => 'stylesheet', + 'crossorigin' => 'anonymous', + 'referrerpolicy' => 'no-referrer', + ]; + + if (config('pterodactyl.assets.use_hash') && $integrity !== '') { + $attributes['integrity'] = $integrity; + } + + $output = ' $value) { + $output .= " $key=\"$value\""; + } + + return $output.'>'; + } + + /** @return ViteManifestEntry|null */ + private function entry(string $resource): ?array + { + $key = $resource === 'main.js' ? self::MAIN_ENTRY : $resource; + + return $this->manifest()[$key] ?? null; + } + + private function assetUrl(string $file): string + { + return '/assets/'.mb_ltrim($file, '/'); + } + + /** @return ViteManifest */ + private function parseManifest(string $contents): array + { + $decoded = JsonValueGuard::decodeArray8($contents); + $manifest = []; + + foreach ($decoded as $source => $value) { + if (! is_string($source) || ! is_array($value) || ! is_string($value['file'] ?? null)) { + continue; + } + + $entry = ['file' => $value['file']]; + if (is_string($value['integrity'] ?? null)) { + $entry['integrity'] = $value['integrity']; + } + + $css = $value['css'] ?? null; + if (is_array($css) && array_is_list($css)) { + $files = []; + foreach ($css as $file) { + if (is_string($file)) { + $files[] = $file; + } + } + + $entry['css'] = $files; + } + + $cssIntegrity = $value['cssIntegrity'] ?? null; + if (is_array($cssIntegrity)) { + $hashes = []; + foreach ($cssIntegrity as $file => $hash) { + if (is_string($file) && is_string($hash)) { + $hashes[$file] = $hash; + } + } + + $entry['cssIntegrity'] = $hashes; + } + + $manifest[$source] = $entry; } return $manifest; diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index a2d30255b..03b506986 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -1,18 +1,22 @@ cacheVersionData(); - } + ) {} /** * Get the latest version of the panel from the CDN servers. */ public function getPanel(): string { - return Arr::get(self::$result, 'panel') ?? 'error'; + return $this->versionData()['panel'] ?? 'error'; } /** @@ -37,7 +39,7 @@ class SoftwareVersionService */ public function getDaemon(): string { - return Arr::get(self::$result, 'wings') ?? 'error'; + return $this->versionData()['wings'] ?? 'error'; } /** @@ -45,7 +47,7 @@ class SoftwareVersionService */ public function getDiscord(): string { - return Arr::get(self::$result, 'discord') ?? 'https://pterodactyl.io/discord'; + return $this->versionData()['discord'] ?? 'https://pterodactyl.io/discord'; } /** @@ -53,7 +55,7 @@ class SoftwareVersionService */ public function getDonations(): string { - return Arr::get(self::$result, 'donations') ?? 'https://github.com/sponsors/matthewpi'; + return $this->versionData()['donations'] ?? 'https://github.com/sponsors/matthewpi'; } /** @@ -65,7 +67,7 @@ class SoftwareVersionService return true; } - return version_compare(config('app.version'), $this->getPanel()) >= 0; + return version_compare(JsonValueGuard::string(config('app.version')), $this->getPanel()) >= 0; } /** @@ -82,21 +84,56 @@ class SoftwareVersionService /** * Keeps the versioning cache up-to-date with the latest results from the CDN. + * + * @return SoftwareVersionData + */ + protected function versionData(): array + { + $this->result ??= $this->cacheVersionData(); + + return $this->result; + } + + /** + * @return SoftwareVersionData */ protected function cacheVersionData(): array { - return $this->cache->remember(self::VERSION_CACHE_KEY, CarbonImmutable::now()->addMinutes(config('pterodactyl.cdn.cache_time', 60)), function () { + $cached = $this->cache->remember(self::VERSION_CACHE_KEY, CarbonImmutable::now()->addMinutes(JsonValueGuard::integer(config('pterodactyl.cdn.cache_time', 60))), function (): array { try { - $response = $this->client->request('GET', config('pterodactyl.cdn.url')); + $response = $this->client->request('GET', JsonValueGuard::string(config('pterodactyl.cdn.url')), ['timeout' => 5, 'connect_timeout' => 2]); if ($response->getStatusCode() === 200) { - return json_decode($response->getBody(), true); + return JsonValueGuard::decodeArray8($response->getBody()->__toString()); } - throw new CdnVersionFetchingException(); - } catch (\Exception) { + throw new CdnVersionFetchingException; + } catch (Exception) { return []; } }); + + return $this->normalizeVersionData($cached); + } + + /** + * @param JsonInputValue $value + * @return SoftwareVersionData + */ + private function normalizeVersionData(mixed $value): array + { + if (! is_array($value)) { + return []; + } + + $normalized = []; + foreach (['panel', 'wings', 'discord', 'donations'] as $key) { + $item = $value[$key] ?? null; + if (is_string($item)) { + $normalized[$key] = $item; + } + } + + return $normalized; } } diff --git a/app/Services/Locations/LocationCreationService.php b/app/Services/Locations/LocationCreationService.php deleted file mode 100644 index b1a3ec995..000000000 --- a/app/Services/Locations/LocationCreationService.php +++ /dev/null @@ -1,26 +0,0 @@ -repository->create($data); - } -} diff --git a/app/Services/Locations/LocationDeletionService.php b/app/Services/Locations/LocationDeletionService.php deleted file mode 100644 index 0e335946c..000000000 --- a/app/Services/Locations/LocationDeletionService.php +++ /dev/null @@ -1,37 +0,0 @@ -id : $location; - - $count = $this->nodeRepository->findCountWhere([['location_id', '=', $location]]); - if ($count > 0) { - throw new HasActiveNodesException(trans('exceptions.locations.has_nodes')); - } - - return $this->repository->delete($location); - } -} diff --git a/app/Services/Locations/LocationUpdateService.php b/app/Services/Locations/LocationUpdateService.php deleted file mode 100644 index cf24459e9..000000000 --- a/app/Services/Locations/LocationUpdateService.php +++ /dev/null @@ -1,29 +0,0 @@ -id : $location; - - return $this->repository->update($location, $data); - } -} diff --git a/app/Services/Nests/NestCreationService.php b/app/Services/Nests/NestCreationService.php deleted file mode 100644 index 7fbb1eb72..000000000 --- a/app/Services/Nests/NestCreationService.php +++ /dev/null @@ -1,33 +0,0 @@ -repository->create([ - 'uuid' => Uuid::uuid4()->toString(), - 'author' => $author ?? $this->config->get('pterodactyl.service.author'), - 'name' => array_get($data, 'name'), - 'description' => array_get($data, 'description'), - ], true, true); - } -} diff --git a/app/Services/Nests/NestDeletionService.php b/app/Services/Nests/NestDeletionService.php deleted file mode 100644 index bb5271133..000000000 --- a/app/Services/Nests/NestDeletionService.php +++ /dev/null @@ -1,34 +0,0 @@ -serverRepository->findCountWhere([['nest_id', '=', $nest]]); - if ($count > 0) { - throw new HasActiveServersException(trans('exceptions.nest.delete_has_servers')); - } - - return $this->repository->delete($nest); - } -} diff --git a/app/Services/Nests/NestUpdateService.php b/app/Services/Nests/NestUpdateService.php deleted file mode 100644 index 772421e42..000000000 --- a/app/Services/Nests/NestUpdateService.php +++ /dev/null @@ -1,30 +0,0 @@ -repository->withoutFreshModel()->update($nest, $data); - } -} diff --git a/app/Services/Nodes/NodeCreationService.php b/app/Services/Nodes/NodeCreationService.php deleted file mode 100644 index b21589c4a..000000000 --- a/app/Services/Nodes/NodeCreationService.php +++ /dev/null @@ -1,33 +0,0 @@ -toString(); - $data['daemon_token'] = app(Encrypter::class)->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)); - $data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH); - - return $this->repository->create($data, true, true); - } -} diff --git a/app/Services/Nodes/NodeDeletionService.php b/app/Services/Nodes/NodeDeletionService.php deleted file mode 100644 index f7966e009..000000000 --- a/app/Services/Nodes/NodeDeletionService.php +++ /dev/null @@ -1,41 +0,0 @@ -id; - } - - $servers = $this->serverRepository->setColumns('id')->findCountWhere([['node_id', '=', $node]]); - if ($servers > 0) { - throw new HasActiveServersException($this->translator->get('exceptions.node.servers_attached')); - } - - return $this->repository->delete($node); - } -} diff --git a/app/Services/Nodes/NodeJWTService.php b/app/Services/Nodes/NodeJWTService.php index e757f49ad..cb43c5bd6 100644 --- a/app/Services/Nodes/NodeJWTService.php +++ b/app/Services/Nodes/NodeJWTService.php @@ -1,33 +1,41 @@ */ private array $scopes; private ?User $user = null; - private \DateTimeImmutable $expiresAt; + private DateTimeImmutable $expiresAt; private ?string $subject = null; /** * Set the claims to include in this JWT. + * + * @param JwtClaims $claims */ public function setClaims(array $claims): self { @@ -38,7 +46,7 @@ class NodeJWTService public function setScopes(JwtScope ...$scopes): self { - $this->scopes = $scopes; + $this->scopes = array_values($scopes); return $this; } @@ -54,7 +62,7 @@ class NodeJWTService return $this; } - public function setExpiresAt(\DateTimeImmutable $date): self + public function setExpiresAt(DateTimeImmutable $date): self { $this->expiresAt = $date; @@ -73,12 +81,23 @@ class NodeJWTService */ public function handle(Node $node, ?string $identifiedBy): UnencryptedToken { - $identifier = hash('sha256', $identifiedBy); - $config = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($node->getDecryptedKey())); + $identifier = hash('sha256', $identifiedBy ?? ''); - $builder = $config->builder(new TimestampDates()) - ->issuedBy(config('app.url')) - ->permittedFor($node->getConnectionAddress()) + // The daemon key is a decrypted, randomly generated token (see + // Node::DAEMON_TOKEN_LENGTH) and the connection address is built from a + // literal "://" separator, so neither is ever empty in practice. Guard + // explicitly anyway rather than trusting that invariant blindly. + $nodeKey = $node->getDecryptedKey(); + throw_if($nodeKey === '', InvalidArgumentException::class, 'Cannot generate a JWT for a node with an empty signing key.'); + + $connectionAddress = $node->getConnectionAddress(); + throw_if($connectionAddress === '', InvalidArgumentException::class, 'Cannot generate a JWT for a node with an empty connection address.'); + + $config = Configuration::forSymmetricSigner(new Sha256, InMemory::plainText($nodeKey)); + + $builder = $config->builder(new TimestampDates) + ->issuedBy(JsonValueGuard::nonEmptyString(config('app.url'))) + ->permittedFor($connectionAddress) ->identifiedBy($identifier) ->withHeader('jti', $identifier) ->issuedAt(CarbonImmutable::now()) @@ -88,7 +107,7 @@ class NodeJWTService $builder = $builder->expiresAt($this->expiresAt); } - if (!empty($this->subject)) { + if (! empty($this->subject)) { $builder = $builder->relatedTo($this->subject)->withHeader('sub', $this->subject); } @@ -96,11 +115,11 @@ class NodeJWTService $builder = $builder->withClaim($key, $value); } - Assert::notEmpty($this->scopes, 'Cannot generate a JWT without providing at least one scope.'); + throw_if($this->scopes === [], InvalidArgumentException::class, 'Cannot generate a JWT without providing at least one scope.'); - $builder = $builder->withClaim('scope', implode(' ', array_map(fn ($scope) => $scope->value, $this->scopes))); + $builder = $builder->withClaim('scope', implode(' ', array_map(fn (JwtScope $scope): string => $scope->value, $this->scopes))); - if (!is_null($this->user)) { + if ($this->user instanceof User) { $builder = $builder->withClaim('user_uuid', $this->user->uuid); } diff --git a/app/Services/Nodes/NodeUpdateService.php b/app/Services/Nodes/NodeUpdateService.php deleted file mode 100644 index 11078af53..000000000 --- a/app/Services/Nodes/NodeUpdateService.php +++ /dev/null @@ -1,80 +0,0 @@ -encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)); - $data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH); - } - - [$updated, $exception] = $this->connection->transaction(function () use ($data, $node) { - /** @var Node $updated */ - $updated = $this->repository->withFreshModel()->update($node->id, $data, true, true); - - try { - // If we're changing the FQDN for the node, use the newly provided FQDN for the connection - // address. This should alleviate issues where the node gets pointed to a "valid" FQDN that - // isn't actually running the daemon software, and therefore you can't actually change it - // back. - // - // This makes more sense anyways, because only the Panel uses the FQDN for connecting, the - // node doesn't actually care about this. - // - // @see https://github.com/pterodactyl/panel/issues/1931 - $node->fqdn = $updated->fqdn; - - $this->configurationRepository->setNode($node)->update($updated); - } catch (DaemonConnectionException $exception) { - Log::warning($exception, ['node_id' => $node->id]); - - // Never actually throw these exceptions up the stack. If we were able to change the settings - // but something went wrong with Wings we just want to store the update and let the user manually - // make changes as needed. - // - // This avoids issues with proxies such as Cloudflare which will see Wings as offline and then - // inject their own response pages, causing this logic to get fucked up. - // - // @see https://github.com/pterodactyl/panel/issues/2712 - return [$updated, true]; - } - - return [$updated, false]; - }); - - if ($exception) { - throw new ConfigurationNotPersistedException(trans('exceptions.node.daemon_off_config_updated')); - } - - return $updated; - } -} diff --git a/app/Services/Schedules/ProcessScheduleService.php b/app/Services/Schedules/ProcessScheduleService.php deleted file mode 100644 index ddaa10bc7..000000000 --- a/app/Services/Schedules/ProcessScheduleService.php +++ /dev/null @@ -1,86 +0,0 @@ -tasks()->orderBy('sequence_id')->first(); - if (is_null($task)) { - throw new DisplayException('Cannot process schedule for task execution: no tasks are registered.'); - } - - $this->connection->transaction(function () use ($schedule, $task) { - $schedule->forceFill([ - 'is_processing' => true, - 'next_run_at' => $schedule->getNextRunDate(), - ])->saveOrFail(); - - $task->update(['is_queued' => true]); - }); - - $job = new RunTaskJob($task, $now); - if ($schedule->only_when_online) { - // Check that the server is currently in a starting or running state before executing - // this schedule if this option has been set. - try { - $details = $this->serverRepository->setServer($schedule->server)->getDetails(); - $state = $details['state'] ?? 'offline'; - // If the server is stopping or offline just do nothing with this task. - if (in_array($state, ['offline', 'stopping'])) { - $job->failed(); - - return; - } - } catch (\Exception $exception) { - if (!$exception instanceof DaemonConnectionException) { - // If we encountered some exception during this process that wasn't just an - // issue connecting to Wings run the failed sequence for a job. Otherwise we - // can just quietly mark the task as completed without actually running anything. - $job->failed($exception); - } - $job->failed(); - - return; - } - } - - if (!$now) { - $this->dispatcher->dispatch($job->delay($task->time_offset)); - } else { - // When using dispatchNow the RunTaskJob::failed() function is not called automatically - // so we need to manually trigger it and then continue with the exception throw. - // - // @see https://github.com/pterodactyl/panel/issues/2550 - try { - $this->dispatcher->dispatchNow($job); - } catch (\Exception $exception) { - $job->failed($exception); - - throw $exception; - } - } - } -} diff --git a/app/Services/Servers/BuildModificationService.php b/app/Services/Servers/BuildModificationService.php deleted file mode 100644 index 620deddd9..000000000 --- a/app/Services/Servers/BuildModificationService.php +++ /dev/null @@ -1,131 +0,0 @@ -connection->transaction(function () use ($server, $data) { - $this->processAllocations($server, $data); - - if (isset($data['allocation_id']) && $data['allocation_id'] != $server->allocation_id) { - try { - Allocation::query()->where('id', $data['allocation_id'])->where('server_id', $server->id)->firstOrFail(); - } catch (ModelNotFoundException) { - throw new DisplayException('The requested default allocation is not currently assigned to this server.'); - } - } - - // If any of these values are passed through in the data array go ahead and set - // them correctly on the server model. - $merge = Arr::only($data, ['oom_disabled', 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', 'allocation_id']); - - $server->forceFill(array_merge($merge, [ - 'database_limit' => Arr::get($data, 'database_limit', 0) ?? null, - 'allocation_limit' => Arr::get($data, 'allocation_limit', 0) ?? null, - 'backup_limit' => Arr::get($data, 'backup_limit', 0) ?? 0, - ]))->saveOrFail(); - - return $server->refresh(); - }); - - $updateData = $this->structureService->handle($server); - - // Because Wings always fetches an updated configuration from the Panel when booting - // a server this type of exception can be safely "ignored" and just written to the logs. - // Ideally this request succeeds, so we can apply resource modifications on the fly, but - // if it fails we can just continue on as normal. - if (!empty($updateData['build'])) { - try { - $this->daemonServerRepository->setServer($server)->sync(); - } catch (DaemonConnectionException $exception) { - Log::warning($exception, ['server_id' => $server->id]); - } - } - - return $server; - } - - /** - * Process the allocations being assigned in the data and ensure they are available for a server. - * - * @throws DisplayException - */ - private function processAllocations(Server $server, array &$data): void - { - if (empty($data['add_allocations']) && empty($data['remove_allocations'])) { - return; - } - - // Handle the addition of allocations to this server. Only assign allocations that are not currently - // assigned to a different server, and only allocations on the same node as the server. - if (!empty($data['add_allocations'])) { - $query = Allocation::query() - ->where('node_id', $server->node_id) - ->whereIn('id', $data['add_allocations']) - ->whereNull('server_id'); - - // Keep track of all the allocations we're just now adding so that we can use the first - // one to reset the default allocation to. - $freshlyAllocated = $query->pluck('id')->first(); // @phpstan-ignore larastan.noUnnecessaryCollectionCall - - $query->update(['server_id' => $server->id, 'notes' => null]); - } - - if (!empty($data['remove_allocations'])) { - foreach ($data['remove_allocations'] as $allocation) { - // If we are attempting to remove the default allocation for the server, see if we can reassign - // to the first provided value in add_allocations. If there is no new first allocation then we - // will throw an exception back. - if ($allocation === ($data['allocation_id'] ?? $server->allocation_id)) { - if (empty($freshlyAllocated)) { - throw new DisplayException('You are attempting to delete the default allocation for this server but there is no fallback allocation to use.'); - } - - // Update the default allocation to be the first allocation that we are creating. - $data['allocation_id'] = $freshlyAllocated; - } - } - - // Remove any of the allocations we got that are currently assigned to this server on - // this node. Also set the notes to null, otherwise when re-allocated to a new server those - // notes will be carried over. - Allocation::query()->where('node_id', $server->node_id) - ->where('server_id', $server->id) - // Only remove the allocations that we didn't also attempt to add to the server... - ->whereIn('id', array_diff($data['remove_allocations'], $data['add_allocations'] ?? [])) - ->update([ - 'notes' => null, - 'server_id' => null, - ]); - } - } -} diff --git a/app/Services/Servers/DetailsModificationService.php b/app/Services/Servers/DetailsModificationService.php deleted file mode 100644 index e4a1b6f91..000000000 --- a/app/Services/Servers/DetailsModificationService.php +++ /dev/null @@ -1,54 +0,0 @@ -connection->transaction(function () use ($data, $server) { - $original = $server->user; - - $server->forceFill([ - 'external_id' => Arr::get($data, 'external_id'), - 'owner_id' => Arr::get($data, 'owner_id'), - 'name' => Arr::get($data, 'name'), - 'description' => Arr::get($data, 'description') ?? '', - ])->saveOrFail(); - - // If the owner_id value is changed we need to revoke any tokens that exist for the server - // on the Wings instance so that the old owner no longer has any permission to access the - // websockets. - if (! $server->refresh()->user->is($original)) { - RevokeSftpAccessJob::dispatch($original->uuid, $server); - } - - return $server; - }); - } -} diff --git a/app/Services/Servers/EnvironmentService.php b/app/Services/Servers/EnvironmentService.php index 8f45bab2d..86c51fe92 100644 --- a/app/Services/Servers/EnvironmentService.php +++ b/app/Services/Servers/EnvironmentService.php @@ -1,18 +1,24 @@ */ private array $additional = []; /** * Dynamically configure additional environment variables to be assigned * with a specific server. */ + /** @param callable(Server): ApiScalar $closure */ public function setEnvironmentKey(string $key, callable $closure): void { $this->additional[$key] = $closure; @@ -20,6 +26,8 @@ class EnvironmentService /** * Return the dynamically added additional keys. + * + * @return array */ public function getEnvironmentKeys(): array { @@ -29,38 +37,74 @@ class EnvironmentService /** * Take all of the environment variables configured for this server and return * them in an easy to process format. + * + * @return array environment variable name => value */ public function handle(Server $server): array { - $variables = $server->variables->toBase()->mapWithKeys(function (EggVariable $variable) { - return [$variable->env_variable => $variable->server_value ?? $variable->default_value]; - }); + $server->loadMissing('location'); + + $variables = []; + foreach ($this->variables($server) as $variable) { + $variables[$variable->env_variable] = $this->environmentValue( + $variable->env_variable, + $variable->server_value ?? $variable->default_value, + ); + } // Process environment variables defined in this file. This is done first // in order to allow run-time and config defined variables to take // priority over built-in values. foreach ($this->getEnvironmentMappings() as $key => $object) { - $variables->put($key, object_get($server, $object)); + $variables[$key] = $this->environmentValue($key, data_get($server, $object)); } // Process variables set in the configuration file. - foreach (config('pterodactyl.environment_variables', []) as $key => $object) { - $variables->put( + foreach ($this->configuredEnvironmentVariables() as $key => $source) { + $variables[$key] = $this->environmentValue( $key, - is_callable($object) ? call_user_func($object, $server) : object_get($server, $object) + is_string($source) ? data_get($server, $source) : $source($server), ); } // Process dynamically included environment variables. foreach ($this->additional as $key => $closure) { - $variables->put($key, call_user_func($closure, $server)); + $variables[$key] = $this->environmentValue($key, $closure($server)); } - return $variables->toArray(); + return $variables; + } + + /** + * Resolve an egg's variables with the values overridden for this server. When + * the list endpoint has eagerly loaded both relationships this avoids issuing + * a query for every transformed server. + * + * @return Collection + */ + public function variables(Server $server): Collection + { + if (! $server->relationLoaded('egg') + || ! $server->egg?->relationLoaded('variables') + || ! $server->relationLoaded('serverVariables') + ) { + return $server->variables()->get(); + } + + $overrides = $server->serverVariables->pluck('variable_value', 'variable_id'); + + return $server->egg->variables->map(function (EggVariable $variable) use ($overrides): EggVariable { + $resolved = clone $variable; + $resolved->setAttribute('server_value', $overrides->get($variable->id)); + + return $resolved; + }); } /** * Return a mapping of Panel default environment variables. + * + * @return array environment variable name => server attribute path */ private function getEnvironmentMappings(): array { @@ -70,4 +114,34 @@ class EnvironmentService 'P_SERVER_UUID' => 'uuid', ]; } + + /** @return array */ + private function configuredEnvironmentVariables(): array + { + $configured = config('pterodactyl.environment_variables', []); + throw_unless(is_array($configured), InvalidArgumentException::class, 'Configured server environment variables must be an array.'); + + $variables = []; + foreach ($configured as $key => $source) { + throw_if(! is_string($key) || (! is_string($source) && ! is_callable($source)), InvalidArgumentException::class, 'Each configured server environment variable must map a string key to an attribute path or callable.'); + + $variables[$key] = $source; + } + + return $variables; + } + + /** + * @phpstan-assert ApiScalar $value + * + * @return ApiScalar + */ + private function environmentValue(string $key, mixed $value): bool|float|int|string|null + { + if ($value === null || is_bool($value) || is_float($value) || is_int($value) || is_string($value)) { + return $value; + } + + throw new InvalidArgumentException(sprintf('Server environment variable "%s" must resolve to a JSON scalar.', $key)); + } } diff --git a/app/Services/Servers/GetUserPermissionsService.php b/app/Services/Servers/GetUserPermissionsService.php index ae91cb33f..a484bb525 100644 --- a/app/Services/Servers/GetUserPermissionsService.php +++ b/app/Services/Servers/GetUserPermissionsService.php @@ -1,9 +1,11 @@ */ public function handle(Server $server, User $user): array { @@ -26,7 +30,6 @@ class GetUserPermissionsService return $permissions; } - /** @var \Pterodactyl\Models\Subuser|null $subuserPermissions */ $subuserPermissions = $server->subusers()->where('user_id', $user->id)->first(); return $subuserPermissions ? $subuserPermissions->permissions : []; diff --git a/app/Services/Servers/MountListService.php b/app/Services/Servers/MountListService.php new file mode 100644 index 000000000..d8b35b6aa --- /dev/null +++ b/app/Services/Servers/MountListService.php @@ -0,0 +1,20 @@ + + */ + public function handle(Server $server): Collection + { + return Mount::query()->availableToServer($server)->get(); + } +} diff --git a/app/Services/Servers/ReinstallServerService.php b/app/Services/Servers/ReinstallServerService.php deleted file mode 100644 index 182223828..000000000 --- a/app/Services/Servers/ReinstallServerService.php +++ /dev/null @@ -1,35 +0,0 @@ -connection->transaction(function () use ($server) { - $server->fill(['status' => Server::STATUS_INSTALLING])->save(); - - $this->daemonServerRepository->setServer($server)->reinstall(); - - return $server->refresh(); - }); - } -} diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 72f327796..49fbec45d 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -1,46 +1,59 @@ $override server attributes to override on a cloned model + * @return array */ public function handle(Server $server, array $override = [], bool $legacy = false): array { $clone = $server; // If any overrides have been set on this call make sure to update them on the // cloned instance so that the configuration generated uses them. - if (!empty($override)) { - $clone = $server->fresh(); + if ($override !== []) { + $clone = $server->fresh() ?? throw new UnexpectedValueException('The server no longer exists in the database.'); foreach ($override as $key => $value) { $clone->setAttribute($key, $value); } } + $clone->loadMissing(['egg', 'allocation', 'allocations', 'mounts']); + $egg = $clone->egg ?? throw new UnexpectedValueException('The server does not have an egg relationship.'); + $allocation = $clone->allocation ?? throw new UnexpectedValueException('The server does not have a primary allocation.'); + return $legacy - ? $this->returnLegacyFormat($clone) - : $this->returnCurrentFormat($clone); + ? $this->returnLegacyFormat($clone, $egg, $allocation) + : $this->returnCurrentFormat($clone, $egg, $allocation); } /** * Returns the new data format used for the Wings daemon. + * + * @return array */ - protected function returnCurrentFormat(Server $server): array + protected function returnCurrentFormat(Server $server, Egg $egg, Allocation $allocation): array { return [ 'uuid' => $server->uuid, @@ -63,30 +76,28 @@ class ServerConfigurationStructureService ], 'container' => [ 'image' => $server->image, - // This field is deprecated — use the value in the "build" block. + // This field is deprecated - use the value in the "build" block. // // TODO: remove this key in V2. 'oom_disabled' => $server->oom_disabled, 'requires_rebuild' => false, ], 'allocations' => [ - 'force_outgoing_ip' => $server->egg->force_outgoing_ip, + 'force_outgoing_ip' => $egg->force_outgoing_ip, 'default' => [ - 'ip' => $server->allocation->ip, - 'port' => $server->allocation->port, + 'ip' => $allocation->ip, + 'port' => $allocation->port, ], 'mappings' => $server->getAllocationMappings(), ], - 'mounts' => $server->mounts->map(function (Mount $mount) { - return [ - 'source' => $mount->source, - 'target' => $mount->target, - 'read_only' => $mount->read_only, - ]; - }), + 'mounts' => $server->mounts->map(fn (Mount $mount): array => [ + 'source' => $mount->source, + 'target' => $mount->target, + 'read_only' => $mount->read_only, + ])->values()->all(), 'egg' => [ - 'id' => $server->egg->uuid, - 'file_denylist' => $server->egg->inherit_file_denylist, + 'id' => $egg->uuid, + 'file_denylist' => $egg->inherit_file_denylist, ], ]; } @@ -95,20 +106,26 @@ class ServerConfigurationStructureService * Returns the legacy server data format to continue support for old egg configurations * that have not yet been updated. * + * @return array + * * @deprecated */ - protected function returnLegacyFormat(Server $server): array + protected function returnLegacyFormat(Server $server, Egg $egg, Allocation $allocation): array { return [ 'uuid' => $server->uuid, 'build' => [ 'default' => [ - 'ip' => $server->allocation->ip, - 'port' => $server->allocation->port, + 'ip' => $allocation->ip, + 'port' => $allocation->port, ], - 'ports' => $server->allocations->groupBy('ip')->map(function ($item) { - return $item->pluck('port'); - })->toArray(), + 'ports' => $server->allocations + ->groupBy('ip') + ->map(fn (Collection $allocations): array => $allocations + ->map(fn (Allocation $allocation): int => $allocation->port) + ->values() + ->all()) + ->all(), 'env' => $this->environment->handle($server), 'oom_disabled' => $server->oom_disabled, 'memory' => (int) $server->memory, @@ -120,7 +137,7 @@ class ServerConfigurationStructureService 'image' => $server->image, ], 'service' => [ - 'egg' => $server->egg->uuid, + 'egg' => $egg->uuid, 'skip_scripts' => $server->skip_scripts, ], 'rebuild' => false, diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php deleted file mode 100644 index 6f900b12d..000000000 --- a/app/Services/Servers/ServerCreationService.php +++ /dev/null @@ -1,216 +0,0 @@ -configureDeployment($data, $deployment); - $data['allocation_id'] = $allocation->id; - $data['node_id'] = $allocation->node_id; - } - - // Auto-configure the node based on the selected allocation - // if no node was defined. - if (empty($data['node_id'])) { - Assert::false(empty($data['allocation_id']), 'Expected a non-empty allocation_id in server creation data.'); - - $data['node_id'] = Allocation::query()->findOrFail($data['allocation_id'])->node_id; - } - - if (empty($data['nest_id'])) { - Assert::false(empty($data['egg_id']), 'Expected a non-empty egg_id in server creation data.'); - - $data['nest_id'] = Egg::query()->findOrFail($data['egg_id'])->nest_id; - } - - $eggVariableData = $this->validatorService - ->setUserLevel(User::USER_LEVEL_ADMIN) - ->handle(Arr::get($data, 'egg_id'), Arr::get($data, 'environment', [])); - - // Due to the design of the Daemon, we need to persist this server to the disk - // before we can actually create it on the Daemon. - // - // If that connection fails out we will attempt to perform a cleanup by just - // deleting the server itself from the system. - /** @var Server $server */ - $server = $this->connection->transaction(function () use ($data, $eggVariableData) { - // Create the server and assign any additional allocations to it. - $server = $this->createModel($data); - - $this->storeAssignedAllocations($server, $data); - $this->storeEggVariables($server, $eggVariableData); - - return $server; - }, 5); - - try { - $this->daemonServerRepository->setServer($server)->create( - Arr::get($data, 'start_on_completion', false) ?? false - ); - } catch (DaemonConnectionException $exception) { - $this->serverDeletionService->withForce()->handle($server); - - throw $exception; - } - - return $server; - } - - /** - * Gets an allocation to use for automatic deployment. - * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException - * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException - */ - private function configureDeployment(array $data, DeploymentObject $deployment): Allocation - { - /** @var Collection $nodes */ - $nodes = $this->findViableNodesService->setLocations($deployment->getLocations()) - ->setDisk(Arr::get($data, 'disk')) - ->setMemory(Arr::get($data, 'memory')) - ->handle(); - - return $this->allocationSelectionService->setDedicated($deployment->isDedicated()) - ->setNodes($nodes->pluck('id')->toArray()) - ->setPorts($deployment->getPorts()) - ->handle(); - } - - /** - * Store the server in the database and return the model. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - private function createModel(array $data): Server - { - $uuid = $this->generateUniqueUuidCombo(); - - /** @var Server $model */ - $model = $this->repository->create([ - 'external_id' => Arr::get($data, 'external_id'), - 'uuid' => $uuid, - 'uuidShort' => substr($uuid, 0, 8), - 'node_id' => Arr::get($data, 'node_id'), - 'name' => Arr::get($data, 'name'), - 'description' => Arr::get($data, 'description') ?? '', - 'status' => Server::STATUS_INSTALLING, - 'skip_scripts' => Arr::get($data, 'skip_scripts') ?? isset($data['skip_scripts']), - 'owner_id' => Arr::get($data, 'owner_id'), - 'memory' => Arr::get($data, 'memory'), - 'swap' => Arr::get($data, 'swap'), - 'disk' => Arr::get($data, 'disk'), - 'io' => Arr::get($data, 'io'), - 'cpu' => Arr::get($data, 'cpu'), - 'threads' => Arr::get($data, 'threads'), - 'oom_disabled' => Arr::get($data, 'oom_disabled') ?? true, - 'allocation_id' => Arr::get($data, 'allocation_id'), - 'nest_id' => Arr::get($data, 'nest_id'), - 'egg_id' => Arr::get($data, 'egg_id'), - 'startup' => Arr::get($data, 'startup'), - 'image' => Arr::get($data, 'image'), - 'database_limit' => Arr::get($data, 'database_limit') ?? 0, - 'allocation_limit' => Arr::get($data, 'allocation_limit') ?? 0, - 'backup_limit' => Arr::get($data, 'backup_limit') ?? 0, - ]); - - return $model; - } - - /** - * Configure the allocations assigned to this server. - */ - private function storeAssignedAllocations(Server $server, array $data): void - { - $records = [$data['allocation_id']]; - if (isset($data['allocation_additional']) && is_array($data['allocation_additional'])) { - $records = array_merge($records, $data['allocation_additional']); - } - - Allocation::query()->whereIn('id', $records)->update([ - 'server_id' => $server->id, - ]); - } - - /** - * Process environment variables passed for this server and store them in the database. - */ - private function storeEggVariables(Server $server, Collection $variables): void - { - $records = $variables->map(function ($result) use ($server) { - return [ - 'server_id' => $server->id, - 'variable_id' => $result->id, - 'variable_value' => $result->value ?? '', - ]; - })->toArray(); - - if (!empty($records)) { - $this->serverVariableRepository->insert($records); - } - } - - /** - * Create a unique UUID and UUID-Short combo for a server. - */ - private function generateUniqueUuidCombo(): string - { - $uuid = Uuid::uuid4()->toString(); - - if (!$this->repository->isUniqueUuidCombo($uuid, substr($uuid, 0, 8))) { - return $this->generateUniqueUuidCombo(); - } - - return $uuid; - } -} diff --git a/app/Services/Servers/ServerDeletionService.php b/app/Services/Servers/ServerDeletionService.php deleted file mode 100644 index b06329ea4..000000000 --- a/app/Services/Servers/ServerDeletionService.php +++ /dev/null @@ -1,87 +0,0 @@ -force = $bool; - - return $this; - } - - /** - * Delete a server from the panel, clear any allocation notes, and remove any associated databases from hosts. - * - * @throws \Throwable - * @throws \Pterodactyl\Exceptions\DisplayException - */ - public function handle(Server $server): void - { - try { - $this->daemonServerRepository->setServer($server)->delete(); - } catch (DaemonConnectionException $exception) { - // If there is an error not caused a 404 error and this isn't a forced delete, - // go ahead and bail out. We specifically ignore a 404 since that can be assumed - // to be a safe error, meaning the server doesn't exist at all on Wings so there - // is no reason we need to bail out from that. - if (!$this->force && $exception->getStatusCode() !== Response::HTTP_NOT_FOUND) { - throw $exception; - } - - Log::warning($exception); - } - - $this->connection->transaction(function () use ($server) { - foreach ($server->databases as $database) { - try { - $this->databaseManagementService->delete($database); - } catch (\Exception $exception) { - if (!$this->force) { - throw $exception; - } - - // Oh well, just try to delete the database entry we have from the database - // so that the server itself can be deleted. This will leave it dangling on - // the host instance, but we couldn't delete it anyways so not sure how we would - // handle this better anyways. - // - // @see https://github.com/pterodactyl/panel/issues/2085 - $database->delete(); - - Log::warning($exception); - } - } - - // clear any allocation notes for the server - $server->allocations()->update(['notes' => null]); - - - $server->delete(); - }); - } -} diff --git a/app/Services/Servers/ServerFinderService.php b/app/Services/Servers/ServerFinderService.php new file mode 100644 index 000000000..ced869df2 --- /dev/null +++ b/app/Services/Servers/ServerFinderService.php @@ -0,0 +1,15 @@ +where('external_id', $externalId)->firstOrFail(); + } +} diff --git a/app/Services/Servers/ServerInstallService.php b/app/Services/Servers/ServerInstallService.php new file mode 100644 index 000000000..37266db3d --- /dev/null +++ b/app/Services/Servers/ServerInstallService.php @@ -0,0 +1,40 @@ +resolveForNode($request, $uuid); + $egg = $server->egg; + throw_unless($egg instanceof Egg, NotFoundHttpException::class, 'The requested server does not have an egg assigned.'); + + return [ + 'container_image' => $egg->copy_script_container, + 'entrypoint' => $egg->copy_script_entry, + 'script' => $egg->copy_script_install, + ]; + } + + public function resolveForNode(Request $request, string $uuid): Server + { + $server = Server::query()->with('node')->whereUuidOrShort($uuid)->firstOrFail(); + + throw_unless($server->node->is(RemoteRequestNode::get($request)), HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); + + return $server; + } +} diff --git a/app/Services/Servers/StartupCommandService.php b/app/Services/Servers/StartupCommandService.php index efdbbc5c4..788340374 100644 --- a/app/Services/Servers/StartupCommandService.php +++ b/app/Services/Servers/StartupCommandService.php @@ -1,22 +1,32 @@ memory, $server->allocation->ip, $server->allocation->port]; + $server->loadMissing('allocation'); + $allocation = $server->allocation ?? throw new UnexpectedValueException('The server does not have a primary allocation.'); - foreach ($server->variables as $variable) { - $find[] = '{{' . $variable->env_variable . '}}'; - $replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]'; + $variables = $this->environmentService->variables($server); + + $find = ['{{SERVER_MEMORY}}', '{{SERVER_IP}}', '{{SERVER_PORT}}']; + $replace = [(string) $server->memory, $allocation->ip, (string) $allocation->port]; + + foreach ($variables as $variable) { + $find[] = '{{'.$variable->env_variable.'}}'; + $replace[] = (string) (($variable->user_viewable && ! $hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]'); } return str_replace($find, $replace, $server->startup); diff --git a/app/Services/Servers/StartupModificationService.php b/app/Services/Servers/StartupModificationService.php deleted file mode 100644 index 539757900..000000000 --- a/app/Services/Servers/StartupModificationService.php +++ /dev/null @@ -1,88 +0,0 @@ -connection->transaction(function () use ($server, $data) { - if (!empty($data['environment'])) { - $egg = $this->isUserLevel(User::USER_LEVEL_ADMIN) ? ($data['egg_id'] ?? $server->egg_id) : $server->egg_id; - - $results = $this->validatorService - ->setUserLevel($this->getUserLevel()) - ->handle($egg, $data['environment']); - - foreach ($results as $result) { - ServerVariable::query()->updateOrCreate( - [ - 'server_id' => $server->id, - 'variable_id' => $result->id, - ], - ['variable_value' => $result->value ?? ''] - ); - } - } - - if ($this->isUserLevel(User::USER_LEVEL_ADMIN)) { - $this->updateAdministrativeSettings($data, $server); - } - - // Calling ->refresh() rather than ->fresh() here causes it to return the - // variables as triplicates for some reason? Not entirely sure, should dig - // in more to figure it out, but luckily we have a test case covering this - // specific call so we can be assured we're not breaking it _here_ at least. - // - // TODO(dane): this seems like a red-flag for the code powering the relationship - // that should be looked into more. - return $server->fresh(); - }); - } - - /** - * Update certain administrative settings for a server in the DB. - */ - protected function updateAdministrativeSettings(array $data, Server &$server): void - { - $eggId = Arr::get($data, 'egg_id'); - - if (is_digit($eggId) && $server->egg_id !== (int) $eggId) { - /** @var Egg $egg */ - $egg = Egg::query()->findOrFail($data['egg_id']); - - $server = $server->forceFill([ - 'egg_id' => $egg->id, - 'nest_id' => $egg->nest_id, - ]); - } - - $server->fill([ - 'startup' => $data['startup'] ?? $server->startup, - 'skip_scripts' => $data['skip_scripts'] ?? isset($data['skip_scripts']), - 'image' => $data['docker_image'] ?? $server->image, - ])->save(); - } -} diff --git a/app/Services/Servers/SubuserPermissionCatalog.php b/app/Services/Servers/SubuserPermissionCatalog.php new file mode 100644 index 000000000..51532f0f7 --- /dev/null +++ b/app/Services/Servers/SubuserPermissionCatalog.php @@ -0,0 +1,42 @@ +}> + */ + public function groups(): Collection + { + return Permission::permissions()->merge($this->extensions->all()); + } + + /** + * Every grantable permission key, such as `control.console` or `ext.votes.view`. + * + * @return list + */ + public function keys(): array + { + $keys = []; + foreach ($this->groups() as $prefix => $group) { + foreach (array_keys($group['keys']) as $key) { + $keys[] = "{$prefix}.{$key}"; + } + } + + return $keys; + } +} diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php deleted file mode 100644 index eb9237c5d..000000000 --- a/app/Services/Servers/SuspensionService.php +++ /dev/null @@ -1,61 +0,0 @@ -isSuspended()) { - return; - } - - // Check if the server is currently being transferred. - if (!is_null($server->transfer)) { - throw new ConflictHttpException('Cannot toggle suspension status on a server that is currently being transferred.'); - } - - // Update the server's suspension status. - $server->update([ - 'status' => $isSuspending ? Server::STATUS_SUSPENDED : null, - ]); - - try { - // Tell wings to re-sync the server state. - $this->daemonServerRepository->setServer($server)->sync(); - } catch (\Exception $exception) { - // Rollback the server's suspension status if wings fails to sync the server. - $server->update([ - 'status' => $isSuspending ? null : Server::STATUS_SUSPENDED, - ]); - throw $exception; - } - } -} diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index 676a84aba..624aa7f9f 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -1,13 +1,18 @@ $fields environment variable name => submitted value + * @return Collection + * * @throws ValidationException */ - public function handle(int $egg, array $fields = []): Collection + public function handle(Egg $egg, array $fields = []): Collection { - $query = EggVariable::query()->where('egg_id', $egg); - if (!$this->isUserLevel(User::USER_LEVEL_ADMIN)) { + $query = $egg->variables(); + if (! $this->isUserLevel(User::USER_LEVEL_ADMIN)) { // Don't attempt to validate variables if they aren't user editable, // and we're not running this at an admin level. $query = $query->where('user_editable', true)->where('user_viewable', true); } - /** @var \Pterodactyl\Models\EggVariable[] $variables */ $variables = $query->get(); - - $data = $rules = $customAttributes = []; + $data = []; + $rules = []; + $customAttributes = []; foreach ($variables as $variable) { - $data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable); - $rules['environment.' . $variable->env_variable] = $variable->rules; - $customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); + $data['environment'][$variable->env_variable] = Arr::get($fields, $variable->env_variable); + $rules['environment.'.$variable->env_variable] = $variable->rules; + $customAttributes['environment.'.$variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); } $validator = $this->validator->make($data, $rules, [], $customAttributes); - if ($validator->fails()) { - throw new ValidationException($validator); - } + throw_if($validator->fails(), ValidationException::class, $validator); - return Collection::make($variables)->map(function ($item) use ($fields) { - return (object) [ - 'id' => $item->id, - 'key' => $item->env_variable, - 'value' => $fields[$item->env_variable] ?? null, - ]; - }); + return $variables->map(fn (EggVariable $item): ValidatedEggVariable => new ValidatedEggVariable( + $item->id, + $item->env_variable, + $fields[$item->env_variable] ?? null, + )); } } diff --git a/app/Services/Subusers/SubuserCreationService.php b/app/Services/Subusers/SubuserCreationService.php deleted file mode 100644 index f77393d63..000000000 --- a/app/Services/Subusers/SubuserCreationService.php +++ /dev/null @@ -1,74 +0,0 @@ -connection->transaction(function () use ($server, $email, $permissions) { - try { - $user = $this->userRepository->findFirstWhere([['email', '=', $email]]); - - if ($server->owner_id === $user->id) { - throw new UserIsServerOwnerException(trans('exceptions.subusers.user_is_owner')); - } - - $subuserCount = $this->subuserRepository->findCountWhere([['user_id', '=', $user->id], ['server_id', '=', $server->id]]); - if ($subuserCount !== 0) { - throw new ServerSubuserExistsException(trans('exceptions.subusers.subuser_exists')); - } - } catch (RecordNotFoundException) { - // Just cap the username generated at 64 characters at most and then append a random string - // to the end to make it "unique"... - $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64) . Str::random(3); - - $user = $this->userCreationService->handle([ - 'email' => $email, - 'username' => $username, - 'name_first' => 'Server', - 'name_last' => 'Subuser', - 'root_admin' => false, - ]); - } - - return $this->subuserRepository->create([ - 'user_id' => $user->id, - 'server_id' => $server->id, - 'permissions' => array_unique($permissions), - ]); - }); - } -} diff --git a/app/Services/Tags/TagBackfiller.php b/app/Services/Tags/TagBackfiller.php new file mode 100644 index 000000000..ee827f496 --- /dev/null +++ b/app/Services/Tags/TagBackfiller.php @@ -0,0 +1,222 @@ + + */ + private array $pending = []; + + /** + * Intended attachments as [cache key, egg id] pairs. + * + * @var array + */ + private array $attachments = []; + + public function __construct(private readonly ConnectionInterface $db, private readonly bool $dryRun = false) {} + + /** + * Convert every nest into tags on its eggs. + * + * @return int the number of pivot rows written + */ + public function backfill(): int + { + $this->plan(); + + if ($this->dryRun) { + return count(array_unique(array_map( + fn (array $pair): string => $pair[0].':'.$pair[1], + $this->attachments, + ))); + } + + $this->createTags(); + + return $this->attachTags($this->tagIdsBySlug()); + } + + /** + * Work out every tag that needs to exist and every egg it needs to land on, + * without touching the database beyond two reads. + */ + private function plan(): void + { + $nests = $this->db->table('nests')->orderBy('id')->get(['id', 'name']); + $eggsByNest = $this->db->table('eggs')->orderBy('id')->get(['id', 'nest_id'])->groupBy('nest_id'); + + foreach ($nests as $nest) { + $nestId = filter_var($nest->id, FILTER_VALIDATE_INT); + throw_if($nestId === false || ! is_string($nest->name), UnexpectedValueException::class, 'The legacy nest query returned a malformed row.'); + + $name = mb_trim($nest->name); + $eggIds = []; + foreach ($eggsByNest->get($nestId, collect())->pluck('id') as $eggId) { + $parsedEggId = filter_var($eggId, FILTER_VALIDATE_INT); + throw_if($parsedEggId === false, UnexpectedValueException::class, 'The legacy egg query returned a malformed identifier.'); + + $eggIds[] = $parsedEggId; + } + + if ($eggIds === []) { + continue; + } + + $special = EggSpecificTags::tryFromSlug($name); + + // The built-in game tag the nest names, so gating survives the cutover. + if ($special instanceof EggSpecificTags) { + $this->queue($special->value, $special->friendlyName(), null, $eggIds); + } + + // A generic tag preserving the nest's grouping, but only if it grouped + // more than one egg. A slug naming a built-in game folds into the + // canonical tag above instead of duplicating it with different casing. + if (count($eggIds) < 2 || $name === '' || TagSlug::isReserved($name)) { + continue; + } + + $slug = $special instanceof EggSpecificTags ? $special->value : $name; + $label = $special instanceof EggSpecificTags ? $special->friendlyName() : $name; + + $this->queue($slug, $label, $nestId, $eggIds); + } + } + + /** + * Queue a tag and its attachments. The first nest to claim a slug also supplies + * its legacy nest id; a later nest folding onto the same slug does not overwrite + * it, since only one nest can be the tag's origin. + * + * @param list $eggIds + */ + private function queue(string $slug, string $name, ?int $legacyNestId, array $eggIds): void + { + $key = $this->cacheKey($slug); + + if (! isset($this->pending[$key])) { + $this->pending[$key] = ['slug' => $slug, 'name' => $name, 'legacy_nest_id' => $legacyNestId]; + } elseif (($this->pending[$key]['legacy_nest_id']) === null) { + $this->pending[$key]['legacy_nest_id'] = $legacyNestId; + } + + foreach ($eggIds as $eggId) { + $this->attachments[] = [$key, $eggId]; + } + } + + /** + * Insert every planned tag, ignoring the ones that already exist. insertOrIgnore + * carries the whole self-healing story: a slug the database already holds - by + * an earlier run, a concurrent writer, or a collation equivalence the PHP-side + * folding in {@see cacheKey} cannot predict, such as accent folding - is skipped + * here and picked up by {@see tagIdsBySlug} instead. + */ + private function createTags(): void + { + $now = now(); + + $rows = array_map(fn (array $tag): array => [ + 'name' => $tag['name'], + 'slug' => $tag['slug'], + 'legacy_nest_id' => $tag['legacy_nest_id'], + 'created_at' => $now, + 'updated_at' => $now, + ], array_values($this->pending)); + + foreach (array_chunk($rows, self::CHUNK_SIZE) as $chunk) { + $this->db->table('tags')->insertOrIgnore($chunk); + } + } + + /** + * Read back the id of every tag this run needs, keyed the way the planning pass + * keyed its slugs. Always a database read: the ids are auto-increment, so they + * cannot be known before the insert, and whichever row survived a collision is + * the one the pivot rows must point at. + * + * @return array + */ + private function tagIdsBySlug(): array + { + $slugs = array_column($this->pending, 'slug'); + $ids = []; + + foreach (array_chunk($slugs, self::CHUNK_SIZE) as $chunk) { + foreach ($this->db->table('tags')->whereIn('slug', $chunk)->get(['id', 'slug']) as $tag) { + $id = filter_var($tag->id, FILTER_VALIDATE_INT); + throw_if($id === false || ! is_string($tag->slug), UnexpectedValueException::class, 'The tag lookup returned a malformed row.'); + + $ids[$this->cacheKey($tag->slug)] = $id; + } + } + + return $ids; + } + + /** + * Write the pivot rows, dropping duplicates and any attachment whose tag could + * not be resolved. + * + * @param array $tagIds + * @return int the number of rows the database reported inserted + */ + private function attachTags(array $tagIds): int + { + $rows = []; + + foreach ($this->attachments as [$key, $eggId]) { + if (! isset($tagIds[$key])) { + continue; + } + + // De-duplicate before the insert rather than leaning on the primary key, + // so a nest whose name folds onto its own game tag does not queue the + // same row twice. + $rows[$tagIds[$key].':'.$eggId] = [ + 'tag_id' => $tagIds[$key], + 'kind' => 'egg', + 'taggable_type' => 'egg', + 'taggable_id' => $eggId, + ]; + } + + $inserted = 0; + + foreach (array_chunk(array_values($rows), self::CHUNK_SIZE) as $chunk) { + $inserted += $this->db->table('taggables')->insertOrIgnore($chunk); + } + + return $inserted; + } + + /** + * Cache key for a slug, folded the way the `tags_slug_unique` index compares + * values: the default collation is case-insensitive and ignores trailing spaces. + * Insertion always keeps the verbatim slug; only lookups fold. + */ + private function cacheKey(string $slug): string + { + return mb_strtolower(mb_rtrim($slug)); + } +} diff --git a/app/Services/Tags/TagResolutionService.php b/app/Services/Tags/TagResolutionService.php new file mode 100644 index 000000000..b50136882 --- /dev/null +++ b/app/Services/Tags/TagResolutionService.php @@ -0,0 +1,64 @@ + $value !== ''))); + if ($values === []) { + return []; + } + + $tags = Tag::matchingKeysOrSlugs($values); + $byId = $tags->keyBy('id'); + $bySlug = $tags->keyBy('slug'); + $ids = []; + + foreach ($values as $value) { + // A purely numeric value is either an existing tag id or a leftover + // legacy nest id - never a slug to create (see TagSlug). Resolve it if it + // names a real tag, and drop it otherwise rather than materialising a + // tag whose name is a stale nest id. + if (TagSlug::isReserved($value)) { + $existing = $byId->get($value)?->id; + + if (($existing) !== null) { + $ids[] = $existing; + } + + continue; + } + + // Treat it as a new tag name. The slug is the typed text verbatim, so a + // name keeps the exact casing and spacing entered, and matches a + // backfilled nest tag of the same name. Typing an exact built-in slug + // still resolves to its canonical, enum-named tag. + $name = EggSpecificTags::tryFrom($value)?->friendlyName() ?? $value; + + $ids[] = ($bySlug->get($value) ?? Tag::query()->firstOrCreate(['slug' => $value], ['name' => $name]))->id; + } + + return array_values(array_unique($ids)); + } +} diff --git a/app/Services/Telemetry/TelemetryCollectionService.php b/app/Services/Telemetry/TelemetryCollectionService.php index 1ece48141..d2f36c7c3 100644 --- a/app/Services/Telemetry/TelemetryCollectionService.php +++ b/app/Services/Telemetry/TelemetryCollectionService.php @@ -1,65 +1,45 @@ collect(); - } catch (\Exception) { - return; - } - - Http::post('https://telemetry.pterodactyl.io', $data); - } - /** * Collects telemetry data and returns it as an array. * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @return ApiPayload */ public function collect(): array { - $uuid = $this->settingsRepository->get('app:telemetry:uuid'); - if (is_null($uuid)) { + $uuid = Setting::fetch('app:telemetry:uuid'); + if (($uuid) === null) { $uuid = Uuid::uuid4()->toString(); - $this->settingsRepository->set('app:telemetry:uuid', $uuid); + Setting::put('app:telemetry:uuid', $uuid); } - $nodes = Node::all()->map(function ($node) { + $nodes = Node::all()->map(function (Node $node): ?array { try { - $info = $this->daemonConfigurationRepository->setNode($node)->getSystemInformation(2); - } catch (\Exception) { + $info = Daemon::node($node)->systemInformation(2); + } catch (Exception) { return null; } @@ -101,9 +81,9 @@ class TelemetryCollectionService 'osType' => Arr::get($info, 'system.os_type', ''), ], ]; - })->filter(fn ($node) => !is_null($node))->toArray(); + })->filter(fn (?array $node): bool => $node !== null)->all(); - return [ + $payload = [ 'id' => $uuid, 'panel' => [ @@ -121,24 +101,24 @@ class TelemetryCollectionService 'database' => [ 'type' => config('database.default'), - 'version' => DB::getPdo()->getAttribute(\PDO::ATTR_SERVER_VERSION), + 'version' => DB::getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION), ], ], ], 'resources' => [ 'allocations' => [ - 'count' => Allocation::count(), - 'used' => Allocation::whereNotNull('server_id')->count(), + 'count' => Allocation::query()->count(), + 'used' => Allocation::query()->whereNotNull('server_id')->count(), ], 'backups' => [ - 'count' => Backup::count(), - 'bytes' => Backup::sum('bytes'), + 'count' => Backup::query()->count(), + 'bytes' => Backup::query()->sum('bytes'), ], 'eggs' => [ - 'count' => Egg::count(), + 'count' => Egg::query()->count(), // Egg UUIDs are generated randomly on import, so there is not a consistent way to // determine if servers are using default eggs or not. // 'server_usage' => Egg::all() @@ -148,39 +128,32 @@ class TelemetryCollectionService ], 'locations' => [ - 'count' => Location::count(), + 'count' => Location::query()->count(), ], 'mounts' => [ - 'count' => Mount::count(), - ], - - 'nests' => [ - 'count' => Nest::count(), - // Nest UUIDs are generated randomly on import, so there is not a consistent way to - // determine if servers are using default eggs or not. - // 'server_usage' => Nest::all() - // ->flatMap(fn (Nest $nest) => [$nest->uuid => $nest->eggs->sum(fn (Egg $egg) => $egg->servers->count())]) - // ->filter(fn (int $count) => $count > 0) - // ->toArray(), + 'count' => Mount::query()->count(), ], 'nodes' => [ - 'count' => Node::count(), + 'count' => Node::query()->count(), ], 'servers' => [ - 'count' => Server::count(), - 'suspended' => Server::where('status', Server::STATUS_SUSPENDED)->count(), + 'count' => Server::query()->count(), + 'suspended' => Server::query()->where('status', Server::STATUS_SUSPENDED)->count(), ], 'users' => [ - 'count' => User::count(), - 'admins' => User::where('root_admin', true)->count(), + 'count' => User::query()->count(), + 'admins' => User::query()->where('root_admin', true)->count(), ], ], 'nodes' => $nodes, ]; + JsonValueGuard::assertPayload($payload); + + return $payload; } } diff --git a/app/Services/Themes/ThemeService.php b/app/Services/Themes/ThemeService.php new file mode 100644 index 000000000..3ccc86a97 --- /dev/null +++ b/app/Services/Themes/ThemeService.php @@ -0,0 +1,65 @@ + + */ + public function discovered(): array + { + $themes = []; + foreach (glob($this->directory().'/*/'.self::MANIFEST) ?: [] as $file) { + $contents = file_get_contents($file); + if ($contents === false) { + continue; + } + + $data = json_decode($contents, true); + if (! is_array($data)) { + continue; + } + + $id = $data['id'] ?? null; + if (! is_string($id) || ! preg_match('/^[a-z][a-z0-9-]{0,47}$/', $id) || $id !== basename(dirname($file))) { + continue; + } + + $themes[$id] = [ + 'id' => $id, + 'name' => is_string($data['name'] ?? null) ? $data['name'] : $id, + 'version' => is_string($data['version'] ?? null) ? $data['version'] : '0.0.0', + 'directory' => dirname($file), + ]; + } + + return $themes; + } +} diff --git a/app/Services/Users/ToggleTwoFactorService.php b/app/Services/Users/ToggleTwoFactorService.php deleted file mode 100644 index 8ed71eb1f..000000000 --- a/app/Services/Users/ToggleTwoFactorService.php +++ /dev/null @@ -1,89 +0,0 @@ -encrypter->decrypt($user->totp_secret); - - $isValidToken = $this->google2FA->verifyKey($secret, $token, config()->get('pterodactyl.auth.2fa.window')); - - if (!$isValidToken) { - throw new TwoFactorAuthenticationTokenInvalid(); - } - - return $this->connection->transaction(function () use ($user, $toggleState) { - // Now that we're enabling 2FA on the account, generate 10 recovery tokens for the account - // and store them hashed in the database. We'll return them to the caller so that the user - // can see and save them. - // - // If a user is unable to login with a 2FA token they can provide one of these backup codes - // which will then be marked as deleted from the database and will also bypass 2FA protections - // on their account. - $tokens = []; - if ((!$toggleState && !$user->use_totp) || $toggleState) { - $inserts = []; - for ($i = 0; $i < 10; ++$i) { - $token = Str::random(10); - - $inserts[] = [ - 'user_id' => $user->id, - 'token' => password_hash($token, PASSWORD_DEFAULT), - // insert() won't actually set the time on the models, so make sure we do this - // manually here. - 'created_at' => Carbon::now(), - ]; - - $tokens[] = $token; - } - - // Before inserting any new records make sure all of the old ones are deleted to avoid - // any issues or storing an unnecessary number of tokens in the database. - $this->recoveryTokenRepository->deleteWhere(['user_id' => $user->id]); - - // Bulk insert the hashed tokens. - $this->recoveryTokenRepository->insert($inserts); - } - - $this->repository->withoutFreshModel()->update($user->id, [ - 'totp_authenticated_at' => null, - 'use_totp' => (is_null($toggleState) ? !$user->use_totp : $toggleState), - ]); - - return $tokens; - }); - } -} diff --git a/app/Services/Users/TwoFactorSetupService.php b/app/Services/Users/TwoFactorSetupService.php deleted file mode 100644 index c48a99dbd..000000000 --- a/app/Services/Users/TwoFactorSetupService.php +++ /dev/null @@ -1,59 +0,0 @@ -config->get('pterodactyl.auth.2fa.bytes', 16); ++$i) { - $secret .= substr(self::VALID_BASE32_CHARACTERS, random_int(0, 31), 1); - } - } catch (\Exception $exception) { - throw new \RuntimeException($exception->getMessage(), 0, $exception); - } - - $this->repository->withoutFreshModel()->update($user->id, [ - 'totp_secret' => $this->encrypter->encrypt($secret), - ]); - - $company = urlencode(preg_replace('/\s/', '', $this->config->get('app.name'))); - - return [ - 'image_url_data' => sprintf( - 'otpauth://totp/%1$s:%2$s?secret=%3$s&issuer=%1$s', - rawurlencode($company), - rawurlencode($user->email), - rawurlencode($secret), - ), - 'secret' => $secret, - ]; - } -} diff --git a/app/Services/Users/UserCreationService.php b/app/Services/Users/UserCreationService.php deleted file mode 100644 index ed92d7b58..000000000 --- a/app/Services/Users/UserCreationService.php +++ /dev/null @@ -1,58 +0,0 @@ -hasher->make($data['password']); - } - - $this->connection->beginTransaction(); - if (!isset($data['password']) || empty($data['password'])) { - $generateResetToken = true; - $data['password'] = $this->hasher->make(str_random(30)); - } - - /** @var User $user */ - $user = $this->repository->create(array_merge($data, [ - 'uuid' => Uuid::uuid4()->toString(), - ]), true, true); - - if (isset($generateResetToken)) { - $token = $this->passwordBroker->createToken($user); - } - - $this->connection->commit(); - $user->notify(new AccountCreated($user, $token ?? null)); - - return $user; - } -} diff --git a/app/Services/Users/UserFinderService.php b/app/Services/Users/UserFinderService.php new file mode 100644 index 000000000..79de8b625 --- /dev/null +++ b/app/Services/Users/UserFinderService.php @@ -0,0 +1,15 @@ +where('external_id', $externalId)->firstOrFail(); + } +} diff --git a/app/Services/Users/UserUpdateService.php b/app/Services/Users/UserUpdateService.php deleted file mode 100644 index 83846040e..000000000 --- a/app/Services/Users/UserUpdateService.php +++ /dev/null @@ -1,42 +0,0 @@ -hasher->make($data['password']); - } else { - unset($data['password']); - } - - $user->forceFill($data)->saveOrFail(); - - if (isset($data['password'])) { - PasswordChanged::dispatch($user); - } - - return $user->refresh(); - } -} diff --git a/app/Support/ActivityLogFilters.php b/app/Support/ActivityLogFilters.php new file mode 100644 index 000000000..3e7efc59e --- /dev/null +++ b/app/Support/ActivityLogFilters.php @@ -0,0 +1,39 @@ +where('activity_logs.actor_type', (new User)->getMorphClass()) + ->whereIn('activity_logs.actor_id', User::query() + ->where(function (Builder $builder) use ($term): void { + $builder->where('username', 'like', '%'.$term.'%') + ->orWhere('email', 'like', '%'.$term.'%'); + }) + ->select('id')); + }); + } + + public static function actorId(int $id): AllowedFilter + { + return AllowedFilter::callback('user_id', function (Builder $query) use ($id): void { + $query->where('activity_logs.actor_type', (new User)->getMorphClass()) + ->where('activity_logs.actor_id', $id); + }); + } +} diff --git a/app/Support/Alerts/AlertsMessageBag.php b/app/Support/Alerts/AlertsMessageBag.php new file mode 100644 index 000000000..477abeebf --- /dev/null +++ b/app/Support/Alerts/AlertsMessageBag.php @@ -0,0 +1,82 @@ +message('success', $message); + } + + public function danger(string $message): self + { + return $this->message('danger', $message); + } + + public function warning(string $message): self + { + return $this->message('warning', $message); + } + + public function info(string $message): self + { + return $this->message('info', $message); + } + + public function flash(): self + { + if ($this->type === null || $this->message === null) { + return $this; + } + + $messages = $this->getMessages(); + $messages[$this->type][] = $this->message; + + $this->session->flash(self::SESSION_KEY, $messages); + + return $this; + } + + /** + * @return array> + */ + public function getMessages(): array + { + $messages = $this->session->get(self::SESSION_KEY, []); + if (! is_array($messages)) { + return []; + } + + $normalized = []; + foreach ($messages as $type => $items) { + if (! is_string($type) || ! is_array($items) || ! array_is_list($items)) { + continue; + } + + $normalized[$type] = array_values(array_filter($items, is_string(...))); + } + + return $normalized; + } + + private function message(string $type, string $message): self + { + $this->type = $type; + $this->message = $message; + + return $this; + } +} diff --git a/app/Support/DatabaseName.php b/app/Support/DatabaseName.php new file mode 100644 index 000000000..9004d5a88 --- /dev/null +++ b/app/Support/DatabaseName.php @@ -0,0 +1,13 @@ + */ + public static function decodeArray8(string $encoded): array + { + $value = self::decode8($encoded); + throw_unless(is_array($value), UnexpectedValueException::class, 'The JSON value must be an array.'); + + return $value; + } + + /** + * @phpstan-assert JsonValue $value + */ + public static function assertValue(mixed $value, int $remainingDepth = 10): void + { + if ($value === null || is_bool($value) || is_float($value) || is_int($value) || is_string($value)) { + return; + } + + if ($value instanceof JsonEmptyObject) { + return; + } + + throw_if(! is_array($value) || $remainingDepth === 0, UnexpectedValueException::class, 'JSON values must be scalars or arrays nested at most 10 levels.'); + + foreach ($value as $nestedValue) { + self::assertValue($nestedValue, $remainingDepth - 1); + } + } + + /** @phpstan-assert ApiPayload $value */ + public static function assertPayload(mixed $value): void + { + self::assertValue($value); + throw_unless(is_array($value), UnexpectedValueException::class, 'API payloads must be arrays.'); + + foreach (array_keys($value) as $key) { + throw_unless(is_string($key), UnexpectedValueException::class, 'API payload keys must be strings.'); + } + } + + /** @phpstan-assert ApiScalar $value */ + public static function assertScalar(mixed $value): void + { + throw_if($value !== null && ! is_bool($value) && ! is_float($value) && ! is_int($value) && ! is_string($value), UnexpectedValueException::class, 'Expected a scalar JSON value.'); + } + + /** + * @phpstan-assert ApiScalar $value + * + * @return ApiScalar + */ + public static function scalar(mixed $value): bool|float|int|string|null + { + self::assertScalar($value); + + return $value; + } + + /** @phpstan-assert string $value */ + public static function string(mixed $value): string + { + throw_unless(is_string($value), UnexpectedValueException::class, 'Expected a string value.'); + + return $value; + } + + /** + * @phpstan-assert non-empty-string $value + * + * @return non-empty-string + */ + public static function nonEmptyString(mixed $value): string + { + $value = self::string($value); + throw_if($value === '', UnexpectedValueException::class, 'Expected a non-empty string value.'); + + return $value; + } + + /** @phpstan-assert string|null $value */ + public static function nullableString(mixed $value): ?string + { + throw_if($value !== null && ! is_string($value), UnexpectedValueException::class, 'Expected a nullable string value.'); + + return $value; + } + + /** @phpstan-assert ApiScalar $value */ + public static function nullableScalarString(mixed $value): ?string + { + $value = self::scalar($value); + + // SAFETY: assertScalar() limits the value to JSON scalars, all of which have a defined string representation. + return $value === null ? null : (string) $value; + } + + /** @phpstan-assert bool $value */ + public static function boolean(mixed $value): bool + { + throw_unless(is_bool($value), UnexpectedValueException::class, 'Expected a boolean value.'); + + return $value; + } + + /** @phpstan-assert int|null $value */ + public static function nullableInteger(mixed $value): ?int + { + throw_if($value !== null && ! is_int($value), UnexpectedValueException::class, 'Expected a nullable integer value.'); + + return $value; + } + + /** @phpstan-assert int|string $value */ + public static function integer(mixed $value): int + { + if (is_int($value)) { + return $value; + } + + if (is_string($value)) { + $integer = filter_var($value, FILTER_VALIDATE_INT); + if ($integer !== false) { + return $integer; + } + } + + throw new UnexpectedValueException('Expected an integer value.'); + } + + /** + * @phpstan-assert array $value + * + * @return array + */ + public static function jsonArray(mixed $value): array + { + self::assertValue($value); + throw_unless(is_array($value), UnexpectedValueException::class, 'Expected a JSON array.'); + + return $value; + } + + /** + * @phpstan-assert list $value + * + * @return list + */ + public static function stringList(mixed $value): array + { + throw_if(! is_array($value) || ! array_is_list($value), UnexpectedValueException::class, 'Expected a list of strings.'); + + foreach ($value as $item) { + throw_unless(is_string($item), UnexpectedValueException::class, 'Expected a list of strings.'); + } + + return $value; + } + + /** + * @phpstan-assert list $value + * + * @return list + */ + public static function integerList(mixed $value): array + { + throw_if(! is_array($value) || ! array_is_list($value), UnexpectedValueException::class, 'Expected a list of integers.'); + + foreach ($value as $item) { + throw_unless(is_int($item), UnexpectedValueException::class, 'Expected a list of integers.'); + } + + return $value; + } + + /** + * @param list $value + * @return list + */ + public static function normalizedIntegerList(array $value): array + { + return array_map(self::integer(...), $value); + } + + /** + * @phpstan-assert list $value + * + * @return list + */ + public static function integerStringList(mixed $value): array + { + throw_if(! is_array($value) || ! array_is_list($value), UnexpectedValueException::class, 'Expected a list of integers or strings.'); + + foreach ($value as $item) { + throw_if(! is_int($item) && ! is_string($item), UnexpectedValueException::class, 'Expected a list of integers or strings.'); + } + + return $value; + } + + /** @phpstan-assert array $value */ + public static function assertScalarPayload(mixed $value): void + { + throw_unless(is_array($value), UnexpectedValueException::class, 'Expected a scalar payload.'); + + foreach ($value as $key => $item) { + throw_unless(is_string($key), UnexpectedValueException::class, 'Scalar payload keys must be strings.'); + + self::assertScalar($item); + } + } + + /** @phpstan-assert array $value */ + public static function assertPayload9(mixed $value): void + { + self::assertValue($value, 9); + throw_unless(is_array($value), UnexpectedValueException::class, 'OpenAPI schema payloads must be arrays.'); + + foreach (array_keys($value) as $key) { + throw_unless(is_string($key), UnexpectedValueException::class, 'OpenAPI schema keys must be strings.'); + } + } + + /** @phpstan-assert OpenApiSchemaMap $value */ + public static function assertOpenApiSchemaMap(mixed $value): void + { + throw_unless(is_array($value), UnexpectedValueException::class, 'OpenAPI schema maps must be arrays.'); + + foreach ($value as $key => $schema) { + throw_unless(is_string($key), UnexpectedValueException::class, 'OpenAPI schema map keys must be strings.'); + + self::assertPayload9($schema); + } + } + + /** @phpstan-assert OpenApiSchemaInput $value */ + public static function assertOpenApiSchemaInput(mixed $value): void + { + throw_unless(is_array($value), UnexpectedValueException::class, 'OpenAPI schemas must be arrays.'); + + foreach ($value as $key => $item) { + throw_unless(is_string($key), UnexpectedValueException::class, 'OpenAPI schema keys must be strings.'); + + if ($key === 'properties') { + self::assertOpenApiSchemaMap($item); + } else { + self::assertValue($item, 8); + } + } + } + + /** @phpstan-assert OpenApiOperation $value */ + public static function assertOpenApiOperation(mixed $value): void + { + throw_unless(is_array($value), UnexpectedValueException::class, 'OpenAPI operations must be arrays.'); + + foreach (array_keys($value) as $key) { + throw_unless(is_string($key), UnexpectedValueException::class, 'OpenAPI operation keys must be strings.'); + } + + } + + /** @phpstan-assert OpenApiContent $value */ + public static function assertOpenApiContent(mixed $value): void + { + throw_unless(is_array($value), UnexpectedValueException::class, 'OpenAPI content must be an array.'); + + foreach ($value as $contentType => $media) { + throw_if(! is_string($contentType) || ! is_array($media), UnexpectedValueException::class, 'OpenAPI media entries must be string-keyed arrays.'); + + } + } + + /** @phpstan-assert list $value */ + public static function assertStringList(mixed $value): void + { + throw_if(! is_array($value) || ! array_is_list($value), UnexpectedValueException::class, 'Expected a list of strings.'); + + foreach ($value as $item) { + throw_unless(is_string($item), UnexpectedValueException::class, 'Expected a list of strings.'); + } + } + + /** @phpstan-assert ApiValue8 $value */ + private static function assertValue8(mixed $value): void + { + self::assertValue($value, 8); + } +} diff --git a/app/Support/JsonValueTree.php b/app/Support/JsonValueTree.php new file mode 100644 index 000000000..0b1ecf7ea --- /dev/null +++ b/app/Support/JsonValueTree.php @@ -0,0 +1,77 @@ + $value */ + private function __construct(private bool|float|int|string|array|JsonEmptyObject|null $value) {} + + /** @param JsonInputValue $value */ + public static function from(mixed $value): self + { + if (! is_array($value)) { + return new self($value); + } + + $children = []; + foreach ($value as $key => $child) { + $children[$key] = self::from($child); + } + + return new self($children); + } + + /** @param Closure(string): string $mapper */ + public function mapStrings(Closure $mapper): self + { + if (is_string($this->value)) { + return new self($mapper($this->value)); + } + + if (! is_array($this->value)) { + return $this; + } + + $children = []; + foreach ($this->value as $key => $child) { + $children[$key] = $child->mapStrings($mapper); + } + + return new self($children); + } + + public function arraySize(): ?int + { + return is_array($this->value) ? count($this->value) : null; + } + + /** @return JsonValue */ + public function toValue(): bool|float|int|string|array|null + { + return JsonValueGuard::decode(json_encode($this, JSON_THROW_ON_ERROR)); + } + + /** @return ApiValue8 */ + public function toValue8(): bool|float|int|string|array|null + { + return JsonValueGuard::decode8(json_encode($this, JSON_THROW_ON_ERROR)); + } + + /** @return array */ + public function toArray8(): array + { + return JsonValueGuard::decodeArray8(json_encode($this, JSON_THROW_ON_ERROR)); + } + + /** @return ApiScalar|JsonEmptyObject|array */ + public function jsonSerialize(): bool|float|int|string|array|JsonEmptyObject|null + { + return $this->value; + } +} diff --git a/app/Support/ValidationRuleSubset.php b/app/Support/ValidationRuleSubset.php new file mode 100644 index 000000000..672314546 --- /dev/null +++ b/app/Support/ValidationRuleSubset.php @@ -0,0 +1,25 @@ + $keys + * @return NormalizedValidationRules + */ + public static function select(array $rules, array $keys): array + { + $selected = []; + foreach ($keys as $key) { + if (array_key_exists($key, $rules)) { + $selected[$key] = $rules[$key]; + } + } + + return $selected; + } +} diff --git a/app/Traits/Commands/EnvironmentWriterTrait.php b/app/Traits/Commands/EnvironmentWriterTrait.php index 8d6681623..62cc6ad6c 100644 --- a/app/Traits/Commands/EnvironmentWriterTrait.php +++ b/app/Traits/Commands/EnvironmentWriterTrait.php @@ -1,5 +1,7 @@ $values keyed by environment variable name + * * @throws PterodactylException */ public function writeToEnvironment(array $values = []): void { $path = base_path('.env'); - if (!file_exists($path)) { - throw new PterodactylException('Cannot locate .env file, was this software installed correctly?'); - } + throw_unless(file_exists($path), PterodactylException::class, 'Cannot locate .env file, was this software installed correctly?'); $saveContents = file_get_contents($path); - collect($values)->each(function ($value, $key) use (&$saveContents) { - $key = strtoupper($key); - $saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value)); + throw_if($saveContents === false, PterodactylException::class, 'Unable to read the contents of the .env file.'); - if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) { - $saveContents = $saveContents . PHP_EOL . $saveValue; + collect($values)->each(function ($value, $key) use (&$saveContents): void { + $key = mb_strtoupper($key); + // SAFETY: EnvironmentValue is restricted to JSON scalars, which have deterministic string representations for .env persistence. + $saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value === null ? null : (string) $value)); + + if (preg_match_all('/^'.$key.'=(.*)$/m', $saveContents) < 1) { + $saveContents = $saveContents.PHP_EOL.$saveValue; } else { - $saveContents = preg_replace('/^' . $key . '=(.*)$/m', $saveValue, $saveContents); + // preg_replace() only returns null on a PCRE engine failure (e.g. the + // backtrack limit); keep the existing contents rather than losing them. + $saveContents = preg_replace('/^'.$key.'=(.*)$/m', $saveValue, $saveContents) ?? $saveContents; } }); diff --git a/app/Traits/Controllers/JavascriptInjection.php b/app/Traits/Controllers/JavascriptInjection.php deleted file mode 100644 index 44fec983a..000000000 --- a/app/Traits/Controllers/JavascriptInjection.php +++ /dev/null @@ -1,28 +0,0 @@ -request = $request; - - return $this; - } - - /** - * Injects the exact array passed in, nothing more. - */ - public function plainInject(array $args = []): string - { - return \JavaScript::put($args); - } -} diff --git a/app/Traits/Helpers/AvailableLanguages.php b/app/Traits/Helpers/AvailableLanguages.php index d487e8ecc..2c32516c2 100644 --- a/app/Traits/Helpers/AvailableLanguages.php +++ b/app/Traits/Helpers/AvailableLanguages.php @@ -1,43 +1,31 @@ language code mapped to its display name */ public function getAvailableLanguages(bool $localize = false): array { - return collect($this->getFilesystemInstance()->directories(resource_path('lang')))->mapWithKeys(function ($path) use ($localize) { + $languages = []; + foreach (JsonValueGuard::stringList(File::directories(resource_path('lang'))) as $path) { $code = basename($path); - $value = $localize ? $this->getIsoInstance()->nativeByCode1($code) : $this->getIsoInstance()->languageByCode1($code); + $value = Locale::getDisplayLanguage($code, $localize ? $code : 'en') ?: $code; + $languages[$code] = Str::title($value); + } - return [$code => title_case($value)]; - })->toArray(); - } - - /** - * Return an instance of the filesystem for getting a folder listing. - */ - private function getFilesystemInstance(): Filesystem - { - return $this->filesystem = $this->filesystem ?: app()->make(Filesystem::class); - } - - /** - * Return an instance of the ISO639 class for generating names. - */ - private function getIsoInstance(): ISO639 - { - return $this->iso639 = $this->iso639 ?: app()->make(ISO639::class); + return $languages; } } diff --git a/app/Traits/Helpers/ThrottlesLogins.php b/app/Traits/Helpers/ThrottlesLogins.php new file mode 100644 index 000000000..03b7eeaf5 --- /dev/null +++ b/app/Traits/Helpers/ThrottlesLogins.php @@ -0,0 +1,78 @@ +throttleKey($request), $this->maxLoginAttempts()); + } + + protected function incrementLoginAttempts(Request $request): void + { + RateLimiter::hit($this->throttleKey($request), $this->lockoutDecayMinutes() * 60); + } + + protected function clearLoginAttempts(Request $request): void + { + RateLimiter::clear($this->throttleKey($request)); + } + + protected function fireLockoutEvent(Request $request): void + { + event(new Lockout($request)); + } + + /** + * @throws ValidationException + */ + protected function sendLockoutResponse(Request $request): never + { + $seconds = RateLimiter::availableIn($this->throttleKey($request)); + + throw ValidationException::withMessages([ + $this->throttleUsernameField() => [trans('auth.throttle', [ + 'seconds' => $seconds, + 'minutes' => ceil($seconds / 60), + ])], + ])->status(Response::HTTP_TOO_MANY_REQUESTS); + } + + protected function throttleKey(Request $request): string + { + $login = $request->string($this->throttleUsernameField())->toString(); + + return Str::transliterate(Str::lower($login).'|'.($request->ip() ?? 'unknown')); + } + + protected function throttleUsernameField(): string + { + return 'email'; + } + + protected function maxLoginAttempts(): int + { + return config()->integer('auth.lockout.attempts', 3); + } + + /** How long a lockout lasts, in minutes. */ + protected function lockoutDecayMinutes(): int + { + return config()->integer('auth.lockout.time', 2); + } +} diff --git a/app/Traits/Services/HasUserLevels.php b/app/Traits/Services/HasUserLevels.php index 33be0fbf1..a827d5a26 100644 --- a/app/Traits/Services/HasUserLevels.php +++ b/app/Traits/Services/HasUserLevels.php @@ -1,5 +1,7 @@ updatedModel; - } - - /** - * If called a fresh model will be returned from the database. This is used - * for API calls, but is unnecessary for UI based updates where the page is - * being reloaded and a fresh model will be pulled anyways. - */ - public function returnUpdatedModel(bool $toggle = true): self - { - $this->updatedModel = $toggle; - - return $this; - } -} diff --git a/app/Traits/Services/ValidatesValidationRules.php b/app/Traits/Services/ValidatesValidationRules.php deleted file mode 100644 index 115649b0d..000000000 --- a/app/Traits/Services/ValidatesValidationRules.php +++ /dev/null @@ -1,32 +0,0 @@ -getValidator()->make(['__TEST' => 'test'], ['__TEST' => $rules])->fails(); - } catch (\BadMethodCallException $exception) { - $matches = []; - if (preg_match('/Method \[(.+)\] does not exist\./', $exception->getMessage(), $matches)) { - throw new BadValidationRuleException(trans('exceptions.nest.variables.bad_validation_rule', ['rule' => Str::snake(str_replace('validate', '', array_get($matches, 1, 'unknownRule')))]), $exception); - } - - throw $exception; - } - } -} diff --git a/app/Transformers/Api/Admin/ActivityLogTransformer.php b/app/Transformers/Api/Admin/ActivityLogTransformer.php new file mode 100644 index 000000000..406eac4f2 --- /dev/null +++ b/app/Transformers/Api/Admin/ActivityLogTransformer.php @@ -0,0 +1,54 @@ + 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'integer'], ['type' => 'number'], ['type' => 'boolean'], ['type' => 'array', 'items' => ['type' => 'string']], ['type' => 'object', 'additionalProperties' => ['type' => 'string']]]], 'example' => ['old' => 'old-user@example.com', 'new' => 'new-user@example.com']])] +class ActivityLogTransformer extends BaseAdminTransformer +{ + use FormatsActivityLogs; + + protected array $includeRelations = [ + 'actor' => ['relation' => 'actor', 'transformer' => UserTransformer::class], + ]; + + /** + * @var list + */ + protected array $availableIncludes = ['actor']; + + public function getResourceName(): string + { + return ActivityLog::RESOURCE_NAME; + } + + /** + * Reaching this transformer already requires an administrative read permission, so + * the originating address is never masked the way it is on the client API. + * + * @return array{id: string, batch: string|null, event: string, is_api: bool, ip: string|null, description: string|null, properties: object, has_additional_metadata: bool, timestamp: string} + */ + public function transform(ActivityLog $model): array + { + return $this->activityAttributes($model, true); + } + + public function includeActor(ActivityLog $model): NullResource|Item + { + if (! $model->actor instanceof User) { + return $this->null(); + } + + return $this->item($model->actor, $this->makeTransformer(UserTransformer::class), User::RESOURCE_NAME); + } +} diff --git a/app/Transformers/Api/Admin/AllocationTransformer.php b/app/Transformers/Api/Admin/AllocationTransformer.php new file mode 100644 index 000000000..830bba45b --- /dev/null +++ b/app/Transformers/Api/Admin/AllocationTransformer.php @@ -0,0 +1,76 @@ + ['relation' => 'node', 'transformer' => NodeTransformer::class], + 'server' => ['relation' => 'server', 'transformer' => ServerTransformer::class], + ]; + + /** + * @var list + */ + protected array $availableIncludes = ['node', 'server']; + + public function getResourceName(): string + { + return Allocation::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(Allocation $allocation): array + { + $allocation->loadMissing('server'); + + return [ + 'id' => $allocation->id, + 'ip' => $allocation->ip, + 'alias' => $allocation->ip_alias, + 'port' => $allocation->port, + 'notes' => $allocation->notes, + 'server_id' => $allocation->server_id, + 'server_name' => $allocation->server?->name, + 'assigned' => ($allocation->server_id) !== null, + ]; + } + + public function includeNode(Allocation $allocation): Item|NullResource + { + $allocation->loadMissing('node'); + + return $this->item( + $allocation->getRelation('node'), + $this->makeTransformer(NodeTransformer::class), + Node::RESOURCE_NAME + ); + } + + public function includeServer(Allocation $allocation): Item|NullResource + { + $allocation->loadMissing('server'); + + if (($allocation->getRelation('server')) === null) { + return $this->null(); + } + + return $this->item( + $allocation->getRelation('server'), + $this->makeTransformer(ServerTransformer::class), + Server::RESOURCE_NAME + ); + } +} diff --git a/app/Transformers/Api/Admin/ApiKeyTransformer.php b/app/Transformers/Api/Admin/ApiKeyTransformer.php new file mode 100644 index 000000000..6d4fb117d --- /dev/null +++ b/app/Transformers/Api/Admin/ApiKeyTransformer.php @@ -0,0 +1,52 @@ + 'object', 'required' => ['id', 'username', 'email'], 'properties' => ['id' => ['type' => 'integer', 'example' => 1], 'username' => ['type' => 'string', 'example' => 'admin'], 'email' => ['type' => 'string', 'example' => 'admin@example.com']]])] +class ApiKeyTransformer extends BaseAdminTransformer +{ + public function getResourceName(): string + { + return ApiKey::RESOURCE_NAME; + } + + /** Never exposes the token; the plaintext secret is only returned once on create. */ + /** + * @return ApiPayload + */ + public function transform(ApiKey $model): array + { + $permissions = []; + foreach (AdminAcl::getResourceList() as $resource) { + $column = AdminAcl::COLUMN_IDENTIFIER.$resource; + $permission = $model->getAttribute($column); + if ($permission === null) { + $permission = AdminAcl::NONE; + } elseif (! is_int($permission)) { + throw new UnexpectedValueException("The API key permission [{$column}] must be an integer."); + } + + $permissions[$column] = $permission; + } + + return array_merge([ + 'identifier' => $model->identifier, + 'memo' => $model->memo, + 'created_by' => [ + 'id' => $model->user->id, + 'username' => $model->user->username, + 'email' => $model->user->email, + ], + 'last_used_at' => $model->last_used_at ? $this->formatTimestamp($model->last_used_at) : null, + 'created_at' => $this->formatTimestamp($model->created_at), + 'relationships' => [], + ], $permissions); + } +} diff --git a/app/Transformers/Api/Admin/BackupTransformer.php b/app/Transformers/Api/Admin/BackupTransformer.php new file mode 100644 index 000000000..4f7a7ad52 --- /dev/null +++ b/app/Transformers/Api/Admin/BackupTransformer.php @@ -0,0 +1,33 @@ + $backup->uuid, + 'name' => $backup->name, + 'ignored_files' => $backup->ignored_files, + 'checksum' => $backup->checksum, + 'bytes' => $backup->bytes, + 'is_successful' => $backup->is_successful, + 'is_locked' => $backup->is_locked, + 'created_at' => $this->formatTimestamp($backup->created_at), + 'completed_at' => $backup->completed_at ? $this->formatTimestamp($backup->completed_at) : null, + ]; + } +} diff --git a/app/Transformers/Api/Admin/BaseAdminTransformer.php b/app/Transformers/Api/Admin/BaseAdminTransformer.php new file mode 100644 index 000000000..fef669afc --- /dev/null +++ b/app/Transformers/Api/Admin/BaseAdminTransformer.php @@ -0,0 +1,26 @@ + $abstract + * @return T + */ + protected function makeTransformer(string $abstract): self + { + throw_unless(is_subclass_of($abstract, self::class), InvalidTransformerLevelException::class, "Transformer [$abstract] must extend ".self::class.'.'); + + return parent::makeTransformer($abstract); + } +} diff --git a/app/Transformers/Api/Admin/DatabaseHostTransformer.php b/app/Transformers/Api/Admin/DatabaseHostTransformer.php new file mode 100644 index 000000000..c1010f063 --- /dev/null +++ b/app/Transformers/Api/Admin/DatabaseHostTransformer.php @@ -0,0 +1,93 @@ + ['relation' => 'node', 'transformer' => NodeTransformer::class], + 'databases' => ['relation' => 'databases.server'], + ]; + + /** + * @var list + */ + protected array $availableIncludes = ['node', 'databases']; + + public function getResourceName(): string + { + return DatabaseHost::RESOURCE_NAME; + } + + /** The host password is never exposed through the API surface. */ + /** + * @return ApiPayload + */ + public function transform(DatabaseHost $model): array + { + return [ + 'id' => $model->id, + 'name' => $model->name, + 'host' => $model->host, + 'port' => $model->port, + 'username' => $model->username, + 'max_databases' => $model->max_databases, + 'databases_count' => $model->databases_count ?? $model->databases()->count(), + 'node_id' => $model->node_id, + 'relationships' => [], + 'created_at' => $this->formatTimestamp($model->created_at), + 'updated_at' => $this->formatTimestamp($model->updated_at), + ]; + } + + public function includeNode(DatabaseHost $model): Item|NullResource + { + $model->loadMissing('node'); + + if (! $model->getRelation('node')) { + return $this->null(); + } + + return $this->item( + $model->getRelation('node'), + $this->makeTransformer(NodeTransformer::class), + 'node' + ); + } + + public function includeDatabases(DatabaseHost $model): Collection|NullResource + { + $model->loadMissing('databases.server'); + + return $this->collection($model->getRelation('databases'), function (Database $database): array { + $server = $database->getRelation('server'); + throw_unless($server instanceof Server, UnexpectedValueException::class, 'Database transformations require the server relation.'); + + return [ + 'server' => [ + 'id' => $server->id, + 'name' => $server->name, + ], + 'name' => $database->database, + 'username' => $database->username, + 'connections_from' => $database->remote, + 'max_connections' => $database->max_connections, + ]; + }, Database::RESOURCE_NAME); + } +} diff --git a/app/Transformers/Api/Admin/EggTransformer.php b/app/Transformers/Api/Admin/EggTransformer.php new file mode 100644 index 000000000..1ca38204e --- /dev/null +++ b/app/Transformers/Api/Admin/EggTransformer.php @@ -0,0 +1,123 @@ + 'object', 'additionalProperties' => ['type' => 'string'], 'example' => ['Java 23' => 'ghcr.io/pterodactyl/yolks:java_23']])] +#[ResponseField('config.files', schema: ['type' => 'object', 'additionalProperties' => ['type' => 'object', 'properties' => ['parser' => ['type' => 'string'], 'find' => ['type' => 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'number'], ['type' => 'boolean'], ['type' => 'object', 'additionalProperties' => ['type' => 'string']]]]]]], 'example' => ['server.properties' => ['parser' => 'properties', 'find' => ['server-port' => '{{server.build.default.port}}']]]])] +#[ResponseField('config.logs', schema: ['type' => 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'number'], ['type' => 'boolean']]], 'example' => ['custom' => true, 'location' => 'logs/latest.log']])] +#[ResponseField('config.startup', schema: ['type' => 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'array', 'items' => ['type' => 'string']]]], 'example' => ['done' => ['Done']]])] +#[ResponseField('config.file_denylist', schema: ['type' => 'array', 'nullable' => true, 'items' => ['type' => 'string'], 'example' => ['secret.txt']])] +#[ResponseField('force_outgoing_ip', 'boolean', nullable: true)] +#[ResponseField('script.privileged', 'boolean', nullable: true)] +class EggTransformer extends BaseAdminTransformer +{ + protected array $includeRelations = [ + 'variables' => ['relation' => 'variables', 'transformer' => EggVariableTransformer::class], + 'tags' => ['relation' => 'tags', 'transformer' => TagTransformer::class], + 'servers' => ['relation' => 'servers', 'transformer' => ServerTransformer::class], + ]; + + /** + * @var list + */ + protected array $availableIncludes = ['variables', 'tags', 'servers']; + + public function getResourceName(): string + { + return Egg::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(Egg $model): array + { + $files = json_decode($model->config_files ?? 'null', true, 512, JSON_THROW_ON_ERROR); + if (empty($files)) { + $files = new JsonEmptyObject; + } + + $payload = [ + 'id' => $model->id, + 'uuid' => $model->uuid, + 'author' => $model->author, + 'name' => $model->name, + 'description' => $model->description, + 'features' => $model->features, + // "docker_image" is deprecated in favor of "docker_images"; kept for external compatibility. + 'docker_image' => count($model->docker_images) > 0 ? Arr::first($model->docker_images) : '', + 'docker_images' => $model->docker_images, + 'force_outgoing_ip' => $model->force_outgoing_ip, + 'config' => [ + 'files' => $files, + 'startup' => json_decode($model->config_startup ?? 'null', true), + 'stop' => $model->config_stop, + 'logs' => json_decode($model->config_logs ?? 'null', true), + 'file_denylist' => $model->file_denylist, + 'extends' => $model->config_from, + ], + 'startup' => $model->startup, + 'script' => [ + 'privileged' => $model->script_is_privileged, + 'install' => $model->script_install, + 'entry' => $model->script_entry, + 'container' => $model->script_container, + 'extends' => $model->copy_script_from, + ], + 'relationships' => [], + $model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at), + $model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at), + ]; + JsonValueGuard::assertPayload($payload); + + return $payload; + } + + public function includeVariables(Egg $model): Collection|NullResource + { + $model->loadMissing('variables'); + + return $this->collection( + $model->getRelation('variables'), + $this->makeTransformer(EggVariableTransformer::class), + EggVariable::RESOURCE_NAME + ); + } + + public function includeTags(Egg $model): Collection|NullResource + { + $model->loadMissing('tags'); + + return $this->collection( + $model->getRelation('tags'), + $this->makeTransformer(TagTransformer::class), + Tag::RESOURCE_NAME + ); + } + + public function includeServers(Egg $model): Collection|NullResource + { + $model->loadMissing('servers'); + + return $this->collection( + $model->getRelation('servers'), + $this->makeTransformer(ServerTransformer::class), + Server::RESOURCE_NAME + ); + } +} diff --git a/app/Transformers/Api/Admin/EggVariableTransformer.php b/app/Transformers/Api/Admin/EggVariableTransformer.php new file mode 100644 index 000000000..9ff11f01d --- /dev/null +++ b/app/Transformers/Api/Admin/EggVariableTransformer.php @@ -0,0 +1,38 @@ + $model->id, + 'egg_id' => $model->egg_id, + 'name' => $model->name, + 'description' => $model->description, + 'env_variable' => $model->env_variable, + 'default_value' => $model->default_value, + 'user_viewable' => $model->user_viewable, + 'user_editable' => $model->user_editable, + 'rules' => $model->rules, + 'sort_order' => $model->sort_order, + 'created_at' => $this->formatTimestamp($model->created_at), + 'updated_at' => $this->formatTimestamp($model->updated_at), + ]; + } +} diff --git a/app/Transformers/Api/Admin/LocationTransformer.php b/app/Transformers/Api/Admin/LocationTransformer.php new file mode 100644 index 000000000..a4b87df77 --- /dev/null +++ b/app/Transformers/Api/Admin/LocationTransformer.php @@ -0,0 +1,67 @@ + ['relation' => 'nodes', 'transformer' => NodeTransformer::class], + 'servers' => ['relation' => 'servers', 'transformer' => ServerTransformer::class], + ]; + + /** + * @var list + */ + protected array $availableIncludes = ['nodes', 'servers']; + + public function getResourceName(): string + { + return Location::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(Location $location): array + { + return [ + 'id' => $location->id, + 'short' => $location->short, + 'long' => $location->long, + 'nodes_count' => $location->nodes_count ?? $location->nodes()->count(), + 'servers_count' => $location->servers_count ?? $location->servers()->count(), + 'created_at' => $this->formatTimestamp($location->created_at), + 'updated_at' => $this->formatTimestamp($location->updated_at), + ]; + } + + public function includeNodes(Location $location): Collection|NullResource + { + $location->loadMissing('nodes'); + + return $this->collection( + $location->getRelation('nodes'), + $this->makeTransformer(NodeTransformer::class), + 'node' + ); + } + + public function includeServers(Location $location): Collection|NullResource + { + $location->loadMissing('servers'); + + return $this->collection( + $location->getRelation('servers'), + $this->makeTransformer(ServerTransformer::class), + 'server' + ); + } +} diff --git a/app/Transformers/Api/Admin/MountTransformer.php b/app/Transformers/Api/Admin/MountTransformer.php new file mode 100644 index 000000000..66376f175 --- /dev/null +++ b/app/Transformers/Api/Admin/MountTransformer.php @@ -0,0 +1,88 @@ + ['relation' => 'eggs', 'transformer' => EggTransformer::class], + 'nodes' => ['relation' => 'nodes', 'transformer' => NodeTransformer::class], + 'servers' => ['relation' => 'servers', 'transformer' => ServerTransformer::class], + ]; + + // Only list includes with an implemented include*() method; Fractal would 500 on an unimplemented one. + /** + * @var list + */ + protected array $availableIncludes = [ + 'eggs', + 'nodes', + 'servers', + ]; + + public function getResourceName(): string + { + return Mount::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(Mount $mount): array + { + return [ + 'id' => $mount->id, + 'uuid' => $mount->uuid, + 'name' => $mount->name, + 'description' => $mount->description, + 'source' => $mount->source, + 'target' => $mount->target, + 'read_only' => (bool) $mount->read_only, + 'user_mountable' => (bool) $mount->user_mountable, + 'eggs_count' => (int) ($mount->eggs_count ?? 0), + 'nodes_count' => (int) ($mount->nodes_count ?? 0), + 'servers_count' => (int) ($mount->servers_count ?? 0), + ]; + } + + public function includeEggs(Mount $mount): Collection|NullResource + { + $mount->loadMissing('eggs'); + + return $this->collection( + $mount->getRelation('eggs'), + $this->makeTransformer(EggTransformer::class), + 'egg' + ); + } + + public function includeNodes(Mount $mount): Collection|NullResource + { + $mount->loadMissing('nodes'); + + return $this->collection( + $mount->getRelation('nodes'), + $this->makeTransformer(NodeTransformer::class), + 'node' + ); + } + + public function includeServers(Mount $mount): Collection|NullResource + { + $mount->loadMissing('servers'); + + return $this->collection( + $mount->getRelation('servers'), + $this->makeTransformer(ServerTransformer::class), + 'server' + ); + } +} diff --git a/app/Transformers/Api/Admin/NodeTransformer.php b/app/Transformers/Api/Admin/NodeTransformer.php new file mode 100644 index 000000000..5bf0b68e7 --- /dev/null +++ b/app/Transformers/Api/Admin/NodeTransformer.php @@ -0,0 +1,96 @@ + 'memory', 'servers as sum_disk' => 'disk']; + + protected array $includeRelations = [ + 'allocations' => ['relation' => 'allocations', 'transformer' => AllocationTransformer::class], + 'location' => ['relation' => 'location', 'transformer' => LocationTransformer::class], + 'servers' => ['relation' => 'servers', 'transformer' => ServerTransformer::class], + ]; + + /** + * @var list + */ + protected array $availableIncludes = ['allocations', 'location', 'servers']; + + public function getResourceName(): string + { + return Node::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(Node $node): array + { + $attributes = $node->attributesToArray(); + JsonValueGuard::assertValue($attributes); + + $response = []; + foreach ($attributes as $key => $value) { + // Normalize the legacy mixed-case daemonSFTP key before snake_casing. + $key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key; + + $response[Str::snake($key)] = $value; + } + + $response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at); + $response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at); + + unset($response['sum_memory'], $response['sum_disk']); + $response['allocated_resources'] = $node->allocatedResources(); + $response['relationships'] = []; + + JsonValueGuard::assertPayload($response); + + return $response; + } + + public function includeAllocations(Node $node): Collection|NullResource + { + $node->loadMissing('allocations.server'); + + return $this->collection( + $node->getRelation('allocations'), + $this->makeTransformer(AllocationTransformer::class), + 'allocation' + ); + } + + public function includeLocation(Node $node): Item|NullResource + { + $node->loadMissing('location'); + + return $this->item( + $node->getRelation('location'), + $this->makeTransformer(LocationTransformer::class), + 'location' + ); + } + + public function includeServers(Node $node): Collection|NullResource + { + $node->loadMissing('servers'); + + return $this->collection( + $node->getRelation('servers'), + $this->makeTransformer(ServerTransformer::class), + 'server' + ); + } +} diff --git a/app/Transformers/Api/Admin/ServerDatabaseTransformer.php b/app/Transformers/Api/Admin/ServerDatabaseTransformer.php new file mode 100644 index 000000000..0a9f1bc10 --- /dev/null +++ b/app/Transformers/Api/Admin/ServerDatabaseTransformer.php @@ -0,0 +1,57 @@ + + */ + protected array $availableIncludes = ['password']; + + public function getResourceName(): string + { + return Database::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(Database $model): array + { + $model->loadMissing('host'); + $host = $model->host; + + return [ + 'id' => Hashids::encode($model->id), + 'host' => [ + 'address' => $host->host, + 'port' => $host->port, + ], + 'name' => $model->database, + 'username' => $model->username, + 'connections_from' => $model->remote, + 'max_connections' => $model->max_connections, + 'relationships' => [], + ]; + } + + /** No per-server subuser permission check here; admin API access is gated on root-admin alone. */ + public function includePassword(Database $database): Item + { + return $this->item($database, fn (Database $model): array => [ + 'password' => Crypt::decrypt($model->password), + ], 'database_password'); + } +} diff --git a/app/Transformers/Api/Admin/ServerTransferTransformer.php b/app/Transformers/Api/Admin/ServerTransferTransformer.php new file mode 100644 index 000000000..5f91b889e --- /dev/null +++ b/app/Transformers/Api/Admin/ServerTransferTransformer.php @@ -0,0 +1,34 @@ + $model->id, + 'server_id' => $model->server_id, + 'old_node' => $model->old_node, + 'new_node' => $model->new_node, + 'old_allocation' => $model->old_allocation, + 'new_allocation' => $model->new_allocation, + 'successful' => $model->successful, + 'archived' => $model->archived, + $model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at), + $model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at), + ]; + } +} diff --git a/app/Transformers/Api/Admin/ServerTransformer.php b/app/Transformers/Api/Admin/ServerTransformer.php new file mode 100644 index 000000000..131eabd59 --- /dev/null +++ b/app/Transformers/Api/Admin/ServerTransformer.php @@ -0,0 +1,205 @@ + 'object', 'additionalProperties' => ['nullable' => true, 'oneOf' => [['type' => 'string'], ['type' => 'number']]], 'example' => ['SERVER_JARFILE' => 'server.jar']])] +class ServerTransformer extends BaseAdminTransformer +{ + protected array $eagerLoads = ['egg.variables', 'serverVariables', 'location']; + + protected array $includeRelations = [ + 'allocation' => ['relation' => 'allocation', 'transformer' => AllocationTransformer::class], + 'allocations' => ['relation' => 'allocations', 'transformer' => AllocationTransformer::class], + 'user' => ['relation' => 'user', 'transformer' => UserTransformer::class], + 'location' => ['relation' => 'location', 'transformer' => LocationTransformer::class], + 'node' => ['relation' => 'node', 'transformer' => NodeTransformer::class], + 'subusers' => ['relation' => 'subusers', 'transformer' => SubuserTransformer::class], + 'egg' => ['relation' => 'egg', 'transformer' => EggTransformer::class], + 'databases' => ['relation' => 'databases', 'transformer' => ServerDatabaseTransformer::class], + ]; + + // Only list includes with an implemented include*() method; Fractal would 500 on an unimplemented one. + /** + * @var list + */ + protected array $availableIncludes = [ + 'allocation', + 'allocations', + 'user', + 'subusers', + 'egg', + 'variables', + 'location', + 'node', + 'databases', + ]; + + public function __construct(private readonly EnvironmentService $environmentService) {} + + public function getResourceName(): string + { + return Server::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(Server $server): array + { + $payload = [ + 'id' => $server->getKey(), + 'external_id' => $server->external_id, + 'uuid' => $server->uuid, + 'identifier' => $server->uuidShort, + 'name' => $server->name, + 'description' => $server->description, + 'status' => $server->status, + // This field is deprecated, please use "status". + 'suspended' => $server->isSuspended(), + 'limits' => [ + 'memory' => $server->memory, + 'swap' => $server->swap, + 'disk' => $server->disk, + 'io' => $server->io, + 'cpu' => $server->cpu, + 'threads' => $server->threads, + 'oom_disabled' => $server->oom_disabled, + ], + 'feature_limits' => [ + 'databases' => $server->database_limit, + 'allocations' => $server->allocation_limit, + 'backups' => $server->backup_limit, + ], + 'user' => $server->owner_id, + 'node' => $server->node_id, + 'allocation' => $server->allocation_id, + 'egg' => $server->egg_id, + 'container' => [ + 'startup_command' => $server->startup, + 'image' => $server->image, + 'skip_scripts' => $server->skip_scripts, + // Deprecated, use "status". + 'installed' => $server->isInstalled() ? 1 : 0, + 'environment' => $this->environmentService->handle($server), + ], + 'relationships' => [], + $server->getUpdatedAtColumn() => $this->formatTimestamp($server->updated_at), + $server->getCreatedAtColumn() => $this->formatTimestamp($server->created_at), + ]; + JsonValueGuard::assertPayload($payload); + + return $payload; + } + + public function includeAllocation(Server $server): Item|NullResource + { + $server->loadMissing('allocation'); + + return $this->item( + $server->getRelation('allocation'), + $this->makeTransformer(AllocationTransformer::class), + Allocation::RESOURCE_NAME + ); + } + + public function includeAllocations(Server $server): Collection|NullResource + { + $server->loadMissing('allocations.server'); + + return $this->collection( + $server->getRelation('allocations'), + $this->makeTransformer(AllocationTransformer::class), + 'allocation' + ); + } + + public function includeUser(Server $server): Item|NullResource + { + $server->loadMissing('user'); + + return $this->item( + $server->getRelation('user'), + $this->makeTransformer(UserTransformer::class), + 'user' + ); + } + + public function includeLocation(Server $server): Item|NullResource + { + $server->loadMissing('location'); + + return $this->item( + $server->getRelation('location'), + $this->makeTransformer(LocationTransformer::class), + 'location' + ); + } + + public function includeNode(Server $server): Item|NullResource + { + $server->loadMissing('node'); + + return $this->item( + $server->getRelation('node'), + $this->makeTransformer(NodeTransformer::class), + 'node' + ); + } + + public function includeSubusers(Server $server): Collection|NullResource + { + $server->loadMissing('subusers'); + + return $this->collection( + $server->getRelation('subusers'), + $this->makeTransformer(SubuserTransformer::class), + 'subuser' + ); + } + + public function includeEgg(Server $server): Item|NullResource + { + $server->loadMissing('egg'); + + return $this->item( + $server->getRelation('egg'), + $this->makeTransformer(EggTransformer::class), + 'egg' + ); + } + + public function includeVariables(Server $server): Collection|NullResource + { + return $this->collection( + $this->environmentService->variables($server), + $this->makeTransformer(ServerVariableTransformer::class), + 'server_variable' + ); + } + + public function includeDatabases(Server $server): Collection|NullResource + { + $server->loadMissing('databases'); + + return $this->collection( + $server->getRelation('databases'), + $this->makeTransformer(ServerDatabaseTransformer::class), + 'databases' + ); + } +} diff --git a/app/Transformers/Api/Admin/ServerVariableTransformer.php b/app/Transformers/Api/Admin/ServerVariableTransformer.php new file mode 100644 index 000000000..ba6d8c9e9 --- /dev/null +++ b/app/Transformers/Api/Admin/ServerVariableTransformer.php @@ -0,0 +1,29 @@ +attributesToArray(); + JsonValueGuard::assertPayload($attributes); + + return $attributes; + } +} diff --git a/app/Transformers/Api/Admin/SubuserTransformer.php b/app/Transformers/Api/Admin/SubuserTransformer.php new file mode 100644 index 000000000..f5f252b35 --- /dev/null +++ b/app/Transformers/Api/Admin/SubuserTransformer.php @@ -0,0 +1,30 @@ + $subuser->id, + 'user_id' => $subuser->user_id, + 'server_id' => $subuser->server_id, + 'permissions' => $subuser->permissions, + 'created_at' => $this->formatTimestamp($subuser->created_at), + 'updated_at' => $this->formatTimestamp($subuser->updated_at), + ]; + } +} diff --git a/app/Transformers/Api/Admin/TagTransformer.php b/app/Transformers/Api/Admin/TagTransformer.php new file mode 100644 index 000000000..561ea36b6 --- /dev/null +++ b/app/Transformers/Api/Admin/TagTransformer.php @@ -0,0 +1,77 @@ + ['relation' => 'eggs', 'transformer' => EggTransformer::class], + 'nodes' => ['relation' => 'nodes', 'transformer' => NodeTransformer::class], + ]; + + /** + * @var list + */ + protected array $availableIncludes = ['eggs', 'nodes']; + + public function getResourceName(): string + { + return Tag::RESOURCE_NAME; + } + + /** + * The name and colour are the effective ones: a built-in game tag reports the + * label and colour owned by the EggSpecificTags enum rather than whatever is + * stored, so a client never has to know that distinction to render a tag. + * + * @return ApiPayload + */ + public function transform(Tag $model): array + { + return [ + 'id' => $model->id, + 'name' => $model->effectiveName(), + 'slug' => $model->slug, + 'color' => $model->effectiveColor(), + 'is_predefined' => $model->isPredefined(), + 'legacy_nest_id' => $model->legacy_nest_id, + 'eggs_count' => (int) ($model->eggs_count ?? 0), + 'nodes_count' => (int) ($model->nodes_count ?? 0), + 'created_at' => $this->formatTimestamp($model->created_at), + 'updated_at' => $this->formatTimestamp($model->updated_at), + ]; + } + + public function includeEggs(Tag $model): Collection|NullResource + { + $model->loadMissing('eggs'); + + return $this->collection( + $model->getRelation('eggs'), + $this->makeTransformer(EggTransformer::class), + Egg::RESOURCE_NAME + ); + } + + public function includeNodes(Tag $model): Collection|NullResource + { + $model->loadMissing('nodes'); + + return $this->collection( + $model->getRelation('nodes'), + $this->makeTransformer(NodeTransformer::class), + Node::RESOURCE_NAME + ); + } +} diff --git a/app/Transformers/Api/Admin/UserTransformer.php b/app/Transformers/Api/Admin/UserTransformer.php new file mode 100644 index 000000000..3acf398b6 --- /dev/null +++ b/app/Transformers/Api/Admin/UserTransformer.php @@ -0,0 +1,64 @@ + ['relation' => 'servers', 'transformer' => ServerTransformer::class], + ]; + + // Only list includes with an implemented include*() method; Fractal would 500 on an unimplemented one. + /** + * @var list + */ + protected array $availableIncludes = ['servers']; + + public function getResourceName(): string + { + return User::RESOURCE_NAME; + } + + /** + * @return ApiPayload + */ + public function transform(User $user): array + { + return [ + 'id' => $user->id, + 'external_id' => $user->external_id, + 'uuid' => $user->uuid, + 'username' => $user->username, + 'email' => $user->email, + 'first_name' => $user->name_first, + 'last_name' => $user->name_last, + 'language' => $user->language, + 'root_admin' => (bool) $user->root_admin, + '2fa' => (bool) $user->use_totp, + 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), + 'servers_count' => (int) ($user->servers_count ?? 0), + 'subuser_of_count' => (int) ($user->subuser_of_count ?? 0), + 'created_at' => $this->formatTimestamp($user->created_at), + 'updated_at' => $this->formatTimestamp($user->updated_at), + 'relationships' => [], + ]; + } + + public function includeServers(User $user): Collection|NullResource + { + $user->loadMissing('servers'); + + return $this->collection( + $user->getRelation('servers'), + $this->makeTransformer(ServerTransformer::class), + 'server' + ); + } +} diff --git a/app/Transformers/Api/Application/AllocationTransformer.php b/app/Transformers/Api/Application/AllocationTransformer.php index fcd65f98f..98525e6a2 100644 --- a/app/Transformers/Api/Application/AllocationTransformer.php +++ b/app/Transformers/Api/Application/AllocationTransformer.php @@ -1,18 +1,28 @@ ['relation' => 'node', 'transformer' => NodeTransformer::class, 'ability' => AdminAcl::RESOURCE_NODES], + 'server' => ['relation' => 'server', 'transformer' => ServerTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + ]; + /** * Relationships that can be loaded onto allocation transformations. + * + * @var list */ protected array $availableIncludes = ['node', 'server']; @@ -26,6 +36,8 @@ class AllocationTransformer extends BaseTransformer /** * Return a generic transformed allocation array. + * + * @return ApiPayload */ public function transform(Allocation $allocation): array { @@ -35,18 +47,18 @@ class AllocationTransformer extends BaseTransformer 'alias' => $allocation->ip_alias, 'port' => $allocation->port, 'notes' => $allocation->notes, - 'assigned' => !is_null($allocation->server_id), + 'assigned' => ($allocation->server_id) !== null, ]; } /** * Load the node relationship onto a given transformation. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeNode(Allocation $allocation): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_NODES)) { + if (! $this->authorize(AdminAcl::RESOURCE_NODES)) { return $this->null(); } @@ -60,11 +72,11 @@ class AllocationTransformer extends BaseTransformer /** * Load the server relationship onto a given transformation. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeServer(Allocation $allocation): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS) || !$allocation->server) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS) || ! $allocation->server) { return $this->null(); } diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index a74f32fce..eef0769eb 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -1,46 +1,102 @@ transform(Model $model) */ abstract class BaseTransformer extends TransformerAbstract { - public const RESPONSE_TIMEZONE = 'UTC'; + public const string RESPONSE_TIMEZONE = 'UTC'; - protected Request $request; + /** @var list */ + protected array $eagerLoads = []; - /** - * BaseTransformer constructor. - */ - public function __construct() - { - // Transformers allow for dependency injection on the handle method. - if (method_exists($this, 'handle')) { - Container::getInstance()->call([$this, 'handle']); - } - } + /** @var list */ + protected array $eagerLoadCounts = []; + + /** @var array relation alias => column */ + protected array $eagerLoadSums = []; + + /** @var array, ability?: string}> */ + protected array $includeRelations = []; + + private ?Request $request = null; /** * Return the resource name for the JSONAPI output. */ abstract public function getResourceName(): string; + /** + * Batch dependencies across the entire resource before Fractal visits individual models. + * Only declared includes are loaded; serialization retains its own authorization checks. + * + * @param ModelCollection $models + */ + public function prepareCollection(ModelCollection $models, Scope $scope): void + { + if ($models->isEmpty()) { + return; + } + + $models->loadMissing($this->eagerLoads); + foreach ($this->eagerLoadCounts as $relation) { + $models->reject(fn (Model $model): bool => array_key_exists($relation.'_count', $model->getAttributes()))->loadCount($relation); + } + + foreach ($this->eagerLoadSums as $relation => $column) { + $alias = explode(' as ', $relation)[1]; + $models->reject(fn (Model $model): bool => array_key_exists($alias, $model->getAttributes()))->loadSum($relation, $column); + } + + foreach ($this->includeRelations as $include => $definition) { + if ((! in_array($include, $this->getDefaultIncludes(), true) && ! $scope->isRequested($include)) || $scope->isExcluded($include)) { + continue; + } + + if (isset($definition['ability']) && ! $this->authorize($definition['ability'])) { + continue; + } + + $models->loadMissing($definition['relation']); + if (! isset($definition['transformer'])) { + continue; + } + + // A relation value is a Model, a Collection of Models, or null; flattening one + // level and keeping only Models covers all three without a runtime type check. + $related = new ModelCollection( + $models->pluck($definition['relation'])->flatten(1)->whereInstanceOf(Model::class)->values()->all(), + ); + + $transformer = $this->makeTransformer($definition['transformer']); + $childScope = $scope->embedChildScope($include, new ResourceCollection($related, $transformer)); + $transformer->prepareCollection($related, $childScope); + } + } + /** * Sets the request on the instance. */ - public function setRequest(Request $request): self + public function setRequest(Request $request): static { $this->request = $request; @@ -48,11 +104,11 @@ abstract class BaseTransformer extends TransformerAbstract } /** - * Returns a new transformer instance with the request set on the instance. + * The request this transformer serializes for; the current request unless one was set. */ - public static function fromRequest(Request $request): static + protected function request(): Request { - return app(static::class)->setRequest($request); + return $this->request ??= RequestFacade::instance(); } /** @@ -60,14 +116,14 @@ abstract class BaseTransformer extends TransformerAbstract * to access a different resource. This is used when including other * models on a transformation request. * - * @deprecated — prefer $user->can/cannot methods + * @deprecated - prefer $user->can/cannot methods */ protected function authorize(string $resource): bool { $allowed = [ApiKey::TYPE_ACCOUNT, ApiKey::TYPE_APPLICATION]; - $token = $this->request->user()?->currentAccessToken(); - if (!$token instanceof ApiKey || !in_array($token->key_type, $allowed)) { + $token = $this->request()->user()?->currentAccessToken(); + if (! $token instanceof ApiKey || ! in_array($token->key_type, $allowed)) { return false; } @@ -75,7 +131,7 @@ abstract class BaseTransformer extends TransformerAbstract // the user is a root admin at the moment. In a future release we'll be rolling // out more specific permissions for keys. if ($token->key_type === ApiKey::TYPE_ACCOUNT) { - return $this->request->user()->root_admin; + return $this->request()->user()->root_admin; } return AdminAcl::check($token, $resource); @@ -87,28 +143,36 @@ abstract class BaseTransformer extends TransformerAbstract * * @template T of \Pterodactyl\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract - * + * @param class-string $abstract * @return T * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException * * @noinspection PhpDocSignatureInspection */ - protected function makeTransformer(string $abstract) + protected function makeTransformer(string $abstract): self { - Assert::subclassOf($abstract, self::class); // @phpstan-ignore staticMethod.alreadyNarrowedType + throw_unless(is_subclass_of($abstract, self::class), InvalidTransformerLevelException::class, "Transformer [$abstract] must extend ".self::class.'.'); - return $abstract::fromRequest($this->request); + $transformer = App::make($abstract); + throw_unless($transformer instanceof $abstract, UnexpectedValueException::class, "The container did not resolve transformer [$abstract]."); + + return $transformer->setRequest($this->request()); } /** * Return an ISO-8601 formatted timestamp to use in the API response. */ - protected function formatTimestamp(string $timestamp): string + protected function formatTimestamp(CarbonInterface|string|null $timestamp): string { - return CarbonImmutable::createFromFormat(CarbonInterface::DEFAULT_TO_STRING_FORMAT, $timestamp) - ->setTimezone(self::RESPONSE_TIMEZONE) - ->toAtomString(); + throw_if($timestamp === null, UnexpectedValueException::class, 'Cannot format a missing model timestamp.'); + + $value = $timestamp instanceof CarbonInterface + ? CarbonImmutable::instance($timestamp) + : CarbonImmutable::createFromFormat(CarbonInterface::DEFAULT_TO_STRING_FORMAT, $timestamp); + + throw_unless($value instanceof CarbonImmutable, UnexpectedValueException::class, "The model timestamp does not match Laravel's storage format."); + + return $value->setTimezone(self::RESPONSE_TIMEZONE)->toAtomString(); } } diff --git a/app/Transformers/Api/Application/DatabaseHostTransformer.php b/app/Transformers/Api/Application/DatabaseHostTransformer.php index 019fdf261..da2b31062 100644 --- a/app/Transformers/Api/Application/DatabaseHostTransformer.php +++ b/app/Transformers/Api/Application/DatabaseHostTransformer.php @@ -1,15 +1,25 @@ ['relation' => 'databases', 'transformer' => ServerDatabaseTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVER_DATABASES], + ]; + + /** + * @var list + */ protected array $availableIncludes = [ 'databases', ]; @@ -24,6 +34,8 @@ class DatabaseHostTransformer extends BaseTransformer /** * Transform database host into a representation for the application API. + * + * @return ApiPayload */ public function transform(DatabaseHost $model): array { @@ -42,11 +54,11 @@ class DatabaseHostTransformer extends BaseTransformer /** * Include the databases associated with this host. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeDatabases(DatabaseHost $model): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/EggTransformer.php b/app/Transformers/Api/Application/EggTransformer.php index 9ed5736b4..0e4ff47df 100644 --- a/app/Transformers/Api/Application/EggTransformer.php +++ b/app/Transformers/Api/Application/EggTransformer.php @@ -1,28 +1,51 @@ 'object', 'additionalProperties' => ['type' => 'string'], 'example' => ['Java 23' => 'ghcr.io/pterodactyl/yolks:java_23']])] +#[ResponseField('config.files', schema: ['type' => 'object', 'additionalProperties' => ['type' => 'object', 'properties' => ['parser' => ['type' => 'string'], 'find' => ['type' => 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'number'], ['type' => 'boolean'], ['type' => 'object', 'additionalProperties' => ['type' => 'string']]]]]]], 'example' => ['server.properties' => ['parser' => 'properties', 'find' => ['server-port' => '{{server.build.default.port}}']]]])] +#[ResponseField('config.logs', schema: ['type' => 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'number'], ['type' => 'boolean']]], 'example' => ['custom' => true, 'location' => 'logs/latest.log']])] +#[ResponseField('config.file_denylist', schema: ['type' => 'array', 'nullable' => true, 'items' => ['type' => 'string'], 'example' => ['secret.txt']])] +#[ResponseField('config.startup', schema: ['type' => 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'array', 'items' => ['type' => 'string']]]], 'example' => ['done' => ['Done']]])] class EggTransformer extends BaseTransformer { + protected array $includeRelations = [ + 'servers' => ['relation' => 'servers', 'transformer' => ServerTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + 'config' => ['relation' => 'configFrom'], + 'script' => ['relation' => 'scriptFrom'], + 'variables' => ['relation' => 'variables', 'transformer' => EggVariableTransformer::class, 'ability' => AdminAcl::RESOURCE_EGGS], + 'tags' => ['relation' => 'tags', 'transformer' => TagTransformer::class, 'ability' => AdminAcl::RESOURCE_EGGS], + ]; + /** * Relationships that can be loaded onto this transformation. + * + * @var list */ protected array $availableIncludes = [ - 'nest', 'servers', 'config', 'script', 'variables', + 'tags', ]; /** @@ -37,20 +60,21 @@ class EggTransformer extends BaseTransformer * Transform an Egg model into a representation that can be consumed by * the application api. * - * @throws \JsonException + * @return ApiPayload + * + * @throws JsonException */ public function transform(Egg $model): array { - $files = json_decode($model->config_files, true, 512, JSON_THROW_ON_ERROR); + $files = json_decode($model->config_files ?? 'null', true, 512, JSON_THROW_ON_ERROR); if (empty($files)) { - $files = new \stdClass(); + $files = new JsonEmptyObject; } - return [ + $payload = [ 'id' => $model->id, 'uuid' => $model->uuid, 'name' => $model->name, - 'nest' => $model->nest_id, 'author' => $model->author, 'description' => $model->description, // "docker_image" is deprecated, but left here to avoid breaking too many things at once @@ -60,9 +84,9 @@ class EggTransformer extends BaseTransformer 'docker_images' => $model->docker_images, 'config' => [ 'files' => $files, - 'startup' => json_decode($model->config_startup, true), + 'startup' => json_decode($model->config_startup ?? 'null', true), 'stop' => $model->config_stop, - 'logs' => json_decode($model->config_logs, true), + 'logs' => json_decode($model->config_logs ?? 'null', true), 'file_denylist' => $model->file_denylist, 'extends' => $model->config_from, ], @@ -74,35 +98,23 @@ class EggTransformer extends BaseTransformer 'container' => $model->script_container, 'extends' => $model->copy_script_from, ], + 'relationships' => [], $model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at), $model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at), ]; - } + JsonValueGuard::assertPayload($payload); - /** - * Include the Nest relationship for the given Egg in the transformation. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeNest(Egg $model): Item|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) { - return $this->null(); - } - - $model->loadMissing('nest'); - - return $this->item($model->getRelation('nest'), $this->makeTransformer(NestTransformer::class), Nest::RESOURCE_NAME); + return $payload; } /** * Include the Servers relationship for the given Egg in the transformation. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeServers(Egg $model): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } @@ -117,20 +129,18 @@ class EggTransformer extends BaseTransformer */ public function includeConfig(Egg $model): Item|NullResource { - if (is_null($model->config_from)) { + if (($model->config_from) === null) { return $this->null(); } $model->loadMissing('configFrom'); - return $this->item($model, function (Egg $model) { - return [ - 'files' => json_decode($model->inherit_config_files), - 'startup' => json_decode($model->inherit_config_startup), - 'stop' => $model->inherit_config_stop, - 'logs' => json_decode($model->inherit_config_logs), - ]; - }); + return $this->item($model, fn (Egg $model): array => [ + 'files' => json_decode($model->inherit_config_files ?? 'null'), + 'startup' => json_decode($model->inherit_config_startup ?? 'null'), + 'stop' => $model->inherit_config_stop, + 'logs' => json_decode($model->inherit_config_logs ?? 'null'), + ]); } /** @@ -139,30 +149,28 @@ class EggTransformer extends BaseTransformer */ public function includeScript(Egg $model): Item|NullResource { - if (is_null($model->copy_script_from)) { + if (($model->copy_script_from) === null) { return $this->null(); } $model->loadMissing('scriptFrom'); - return $this->item($model, function (Egg $model) { - return [ - 'privileged' => $model->script_is_privileged, - 'install' => $model->copy_script_install, - 'entry' => $model->copy_script_entry, - 'container' => $model->copy_script_container, - ]; - }); + return $this->item($model, fn (Egg $model): array => [ + 'privileged' => $model->script_is_privileged, + 'install' => $model->copy_script_install, + 'entry' => $model->copy_script_entry, + 'container' => $model->copy_script_container, + ]); } /** * Include the variables that are defined for this Egg. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeVariables(Egg $model): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { + if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); } @@ -174,4 +182,20 @@ class EggTransformer extends BaseTransformer EggVariable::RESOURCE_NAME ); } + + /** + * Include the tags assigned to this Egg. + * + * @throws InvalidTransformerLevelException + */ + public function includeTags(Egg $model): Collection|NullResource + { + if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + return $this->null(); + } + + $model->loadMissing('tags'); + + return $this->collection($model->getRelation('tags'), $this->makeTransformer(TagTransformer::class), Tag::RESOURCE_NAME); + } } diff --git a/app/Transformers/Api/Application/EggVariableTransformer.php b/app/Transformers/Api/Application/EggVariableTransformer.php index 2088806d5..13b1095ea 100644 --- a/app/Transformers/Api/Application/EggVariableTransformer.php +++ b/app/Transformers/Api/Application/EggVariableTransformer.php @@ -1,9 +1,12 @@ toArray(); + $attributes = $model->attributesToArray(); + JsonValueGuard::assertPayload($attributes); + + return $attributes; } } diff --git a/app/Transformers/Api/Application/LocationTransformer.php b/app/Transformers/Api/Application/LocationTransformer.php index 8fea3feb3..76605720c 100644 --- a/app/Transformers/Api/Application/LocationTransformer.php +++ b/app/Transformers/Api/Application/LocationTransformer.php @@ -1,16 +1,26 @@ ['relation' => 'servers', 'transformer' => ServerTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + 'nodes' => ['relation' => 'nodes', 'transformer' => NodeTransformer::class, 'ability' => AdminAcl::RESOURCE_NODES], + ]; + /** * List of resources that can be included. + * + * @var list */ protected array $availableIncludes = ['nodes', 'servers']; @@ -24,6 +34,8 @@ class LocationTransformer extends BaseTransformer /** * Return a generic transformed location array. + * + * @return ApiPayload */ public function transform(Location $location): array { @@ -31,19 +43,18 @@ class LocationTransformer extends BaseTransformer 'id' => $location->id, 'short' => $location->short, 'long' => $location->long, + 'relationships' => [], $location->getUpdatedAtColumn() => $this->formatTimestamp($location->updated_at), $location->getCreatedAtColumn() => $this->formatTimestamp($location->created_at), ]; } /** - * Return the nodes associated with this location. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeServers(Location $location): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } @@ -55,11 +66,11 @@ class LocationTransformer extends BaseTransformer /** * Return the nodes associated with this location. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeNodes(Location $location): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_NODES)) { + if (! $this->authorize(AdminAcl::RESOURCE_NODES)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/NestTransformer.php b/app/Transformers/Api/Application/NestTransformer.php deleted file mode 100644 index 2f530d44e..000000000 --- a/app/Transformers/Api/Application/NestTransformer.php +++ /dev/null @@ -1,74 +0,0 @@ -toArray(); - - $response[$model->getUpdatedAtColumn()] = $this->formatTimestamp($model->updated_at); - $response[$model->getCreatedAtColumn()] = $this->formatTimestamp($model->created_at); - - return $response; - } - - /** - * Include the Eggs relationship on the given Nest model transformation. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeEggs(Nest $model): Collection|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { - return $this->null(); - } - - $model->loadMissing('eggs'); - - return $this->collection($model->getRelation('eggs'), $this->makeTransformer(EggTransformer::class), Egg::RESOURCE_NAME); - } - - /** - * Include the servers relationship on the given Nest model. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeServers(Nest $model): Collection|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { - return $this->null(); - } - - $model->loadMissing('servers'); - - return $this->collection($model->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), Server::RESOURCE_NAME); - } -} diff --git a/app/Transformers/Api/Application/NodeTransformer.php b/app/Transformers/Api/Application/NodeTransformer.php index 6347dfec3..bc6ba9d84 100644 --- a/app/Transformers/Api/Application/NodeTransformer.php +++ b/app/Transformers/Api/Application/NodeTransformer.php @@ -1,17 +1,32 @@ 'memory', 'servers as sum_disk' => 'disk']; + + protected array $includeRelations = [ + 'allocations' => ['relation' => 'allocations', 'transformer' => AllocationTransformer::class, 'ability' => AdminAcl::RESOURCE_ALLOCATIONS], + 'location' => ['relation' => 'location', 'transformer' => LocationTransformer::class, 'ability' => AdminAcl::RESOURCE_LOCATIONS], + 'servers' => ['relation' => 'servers', 'transformer' => ServerTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + ]; + /** * List of resources that can be included. + * + * @var list */ protected array $availableIncludes = ['allocations', 'location', 'servers']; @@ -26,38 +41,41 @@ class NodeTransformer extends BaseTransformer /** * Return a node transformed into a format that can be consumed by the * external administrative API. + * + * @return ApiPayload */ public function transform(Node $node): array { - $response = collect($node->toArray())->mapWithKeys(function ($value, $key) { + $attributes = $node->attributesToArray(); + JsonValueGuard::assertValue($attributes); + + $response = []; + foreach ($attributes as $key => $value) { // I messed up early in 2016 when I named this column as poorly // as I did. This is the tragic result of my mistakes. $key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key; - return [snake_case($key) => $value]; - })->toArray(); + $response[Str::snake($key)] = $value; + } $response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at); $response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at); - $resources = $node->servers()->select(['memory', 'disk'])->get(); + unset($response['sum_memory'], $response['sum_disk']); + $response['allocated_resources'] = $node->allocatedResources(); + $response['relationships'] = []; - $response['allocated_resources'] = [ - 'memory' => $resources->sum('memory'), - 'disk' => $resources->sum('disk'), - ]; + JsonValueGuard::assertPayload($response); return $response; } /** - * Return the nodes associated with this location. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeAllocations(Node $node): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { + if (! $this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { return $this->null(); } @@ -71,13 +89,11 @@ class NodeTransformer extends BaseTransformer } /** - * Return the nodes associated with this location. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeLocation(Node $node): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { + if (! $this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { return $this->null(); } @@ -91,13 +107,11 @@ class NodeTransformer extends BaseTransformer } /** - * Return the nodes associated with this location. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeServers(Node $node): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/ServerDatabaseTransformer.php b/app/Transformers/Api/Application/ServerDatabaseTransformer.php index 2590482d9..c5361bfc1 100644 --- a/app/Transformers/Api/Application/ServerDatabaseTransformer.php +++ b/app/Transformers/Api/Application/ServerDatabaseTransformer.php @@ -1,27 +1,29 @@ ['relation' => 'host', 'transformer' => DatabaseHostTransformer::class, 'ability' => AdminAcl::RESOURCE_DATABASE_HOSTS], + ]; /** - * Perform dependency injection. + * @var list */ - public function handle(Encrypter $encrypter) - { - $this->encrypter = $encrypter; - } + protected array $availableIncludes = ['password', 'host']; /** * Return the resource name for the JSONAPI output. @@ -33,6 +35,8 @@ class ServerDatabaseTransformer extends BaseTransformer /** * Transform a database model in a representation for the application API. + * + * @return ApiPayload */ public function transform(Database $model): array { @@ -54,21 +58,19 @@ class ServerDatabaseTransformer extends BaseTransformer */ public function includePassword(Database $model): Item { - return $this->item($model, function (Database $model) { - return [ - 'password' => $this->encrypter->decrypt($model->password), - ]; - }, 'database_password'); + return $this->item($model, fn (Database $model): array => [ + 'password' => Crypt::decrypt($model->password), + ], 'database_password'); } /** * Return the database host relationship for this server database. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeHost(Database $model): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) { + if (! $this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/ServerTransferTransformer.php b/app/Transformers/Api/Application/ServerTransferTransformer.php new file mode 100644 index 000000000..dc3d09809 --- /dev/null +++ b/app/Transformers/Api/Application/ServerTransferTransformer.php @@ -0,0 +1,34 @@ + $model->id, + 'server_id' => $model->server_id, + 'old_node' => $model->old_node, + 'new_node' => $model->new_node, + 'old_allocation' => $model->old_allocation, + 'new_allocation' => $model->new_allocation, + 'successful' => $model->successful, + 'archived' => $model->archived, + $model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at), + $model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at), + ]; + } +} diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index e5db01fb2..7d7100fda 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -1,26 +1,48 @@ 'object', 'additionalProperties' => ['nullable' => true, 'oneOf' => [['type' => 'string'], ['type' => 'number'], ['type' => 'boolean']]], 'example' => ['SERVER_JARFILE' => 'server.jar']])] class ServerTransformer extends BaseTransformer { - private EnvironmentService $environmentService; + protected array $eagerLoads = ['egg.variables', 'serverVariables', 'location']; + + protected array $includeRelations = [ + 'allocations' => ['relation' => 'allocations', 'transformer' => AllocationTransformer::class, 'ability' => AdminAcl::RESOURCE_ALLOCATIONS], + 'subusers' => ['relation' => 'subusers', 'transformer' => SubuserTransformer::class, 'ability' => AdminAcl::RESOURCE_USERS], + 'user' => ['relation' => 'user', 'transformer' => UserTransformer::class, 'ability' => AdminAcl::RESOURCE_USERS], + 'egg' => ['relation' => 'egg', 'transformer' => EggTransformer::class, 'ability' => AdminAcl::RESOURCE_EGGS], + 'location' => ['relation' => 'location', 'transformer' => LocationTransformer::class, 'ability' => AdminAcl::RESOURCE_LOCATIONS], + 'node' => ['relation' => 'node', 'transformer' => NodeTransformer::class, 'ability' => AdminAcl::RESOURCE_NODES], + 'databases' => ['relation' => 'databases', 'transformer' => ServerDatabaseTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVER_DATABASES], + 'transfer' => ['relation' => 'transfer', 'transformer' => ServerTransferTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + ]; /** * List of resources that can be included. + * + * @var list */ protected array $availableIncludes = [ 'allocations', 'user', 'subusers', - 'nest', 'egg', 'variables', 'location', @@ -29,13 +51,7 @@ class ServerTransformer extends BaseTransformer 'transfer', ]; - /** - * Perform dependency injection. - */ - public function handle(EnvironmentService $environmentService) - { - $this->environmentService = $environmentService; - } + public function __construct(private readonly EnvironmentService $environmentService) {} /** * Return the resource name for the JSONAPI output. @@ -47,10 +63,12 @@ class ServerTransformer extends BaseTransformer /** * Return a generic transformed server array. + * + * @return ApiPayload */ public function transform(Server $server): array { - return [ + $payload = [ 'id' => $server->getKey(), 'external_id' => $server->external_id, 'uuid' => $server->uuid, @@ -77,7 +95,6 @@ class ServerTransformer extends BaseTransformer 'user' => $server->owner_id, 'node' => $server->node_id, 'allocation' => $server->allocation_id, - 'nest' => $server->nest_id, 'egg' => $server->egg_id, 'container' => [ 'startup_command' => $server->startup, @@ -85,20 +102,25 @@ class ServerTransformer extends BaseTransformer // This field is deprecated, please use "status". 'installed' => $server->isInstalled() ? 1 : 0, 'environment' => $this->environmentService->handle($server), + 'skip_scripts' => $server->skip_scripts, ], + 'relationships' => [], $server->getUpdatedAtColumn() => $this->formatTimestamp($server->updated_at), $server->getCreatedAtColumn() => $this->formatTimestamp($server->created_at), ]; + JsonValueGuard::assertPayload($payload); + + return $payload; } /** * Return a generic array of allocations for this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeAllocations(Server $server): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { + if (! $this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { return $this->null(); } @@ -110,11 +132,11 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array of data about subusers for this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeSubusers(Server $server): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_USERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_USERS)) { return $this->null(); } @@ -124,13 +146,11 @@ class ServerTransformer extends BaseTransformer } /** - * Return a generic array of data about subusers for this server. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeUser(Server $server): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_USERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_USERS)) { return $this->null(); } @@ -139,30 +159,14 @@ class ServerTransformer extends BaseTransformer return $this->item($server->getRelation('user'), $this->makeTransformer(UserTransformer::class), 'user'); } - /** - * Return a generic array with nest information for this server. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includeNest(Server $server): Item|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) { - return $this->null(); - } - - $server->loadMissing('nest'); - - return $this->item($server->getRelation('nest'), $this->makeTransformer(NestTransformer::class), 'nest'); - } - /** * Return a generic array with egg information for this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeEgg(Server $server): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { + if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); } @@ -172,29 +176,25 @@ class ServerTransformer extends BaseTransformer } /** - * Return a generic array of data about subusers for this server. - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeVariables(Server $server): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } - $server->loadMissing('variables'); - - return $this->collection($server->getRelation('variables'), $this->makeTransformer(ServerVariableTransformer::class), 'server_variable'); + return $this->collection($this->environmentService->variables($server), $this->makeTransformer(ServerVariableTransformer::class), 'server_variable'); } /** * Return a generic array with location information for this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeLocation(Server $server): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { + if (! $this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { return $this->null(); } @@ -206,11 +206,11 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array with node information for this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeNode(Server $server): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_NODES)) { + if (! $this->authorize(AdminAcl::RESOURCE_NODES)) { return $this->null(); } @@ -222,11 +222,11 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array with database information for this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeDatabases(Server $server): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { return $this->null(); } @@ -234,4 +234,24 @@ class ServerTransformer extends BaseTransformer return $this->collection($server->getRelation('databases'), $this->makeTransformer(ServerDatabaseTransformer::class), 'databases'); } + + /** + * Return the active transfer for this server, when one exists. + * + * @throws InvalidTransformerLevelException + */ + public function includeTransfer(Server $server): Item|NullResource + { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + return $this->null(); + } + + $server->loadMissing('transfer'); + + if (($server->getRelation('transfer')) === null) { + return $this->null(); + } + + return $this->item($server->getRelation('transfer'), $this->makeTransformer(ServerTransferTransformer::class), 'server_transfer'); + } } diff --git a/app/Transformers/Api/Application/ServerVariableTransformer.php b/app/Transformers/Api/Application/ServerVariableTransformer.php index e27d1e013..16377af66 100644 --- a/app/Transformers/Api/Application/ServerVariableTransformer.php +++ b/app/Transformers/Api/Application/ServerVariableTransformer.php @@ -1,17 +1,23 @@ */ protected array $availableIncludes = ['parent']; @@ -25,25 +31,28 @@ class ServerVariableTransformer extends BaseTransformer /** * Return a generic transformed server variable array. + * + * @return ApiPayload */ public function transform(EggVariable $variable): array { - return $variable->toArray(); + $attributes = $variable->attributesToArray(); + JsonValueGuard::assertPayload($attributes); + + return $attributes; } /** * Return the parent service variable data. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeParent(EggVariable $variable): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { + if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); } - $variable->loadMissing('variable'); - - return $this->item($variable->getRelation('variable'), $this->makeTransformer(EggVariableTransformer::class), 'variable'); + return $this->item($variable, $this->makeTransformer(EggVariableTransformer::class), 'variable'); } } diff --git a/app/Transformers/Api/Application/SubuserTransformer.php b/app/Transformers/Api/Application/SubuserTransformer.php index 0a51d61d9..bb7b7cd2f 100644 --- a/app/Transformers/Api/Application/SubuserTransformer.php +++ b/app/Transformers/Api/Application/SubuserTransformer.php @@ -1,16 +1,26 @@ ['relation' => 'user', 'transformer' => UserTransformer::class, 'ability' => AdminAcl::RESOURCE_USERS], + 'server' => ['relation' => 'server', 'transformer' => ServerTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + ]; + /** * List of resources that can be included. + * + * @var list */ protected array $availableIncludes = ['user', 'server']; @@ -24,6 +34,8 @@ class SubuserTransformer extends BaseTransformer /** * Return a transformed Subuser model that can be consumed by external services. + * + * @return ApiPayload */ public function transform(Subuser $subuser): array { @@ -40,11 +52,11 @@ class SubuserTransformer extends BaseTransformer /** * Return a generic item of user for this subuser. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeUser(Subuser $subuser): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_USERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_USERS)) { return $this->null(); } @@ -56,11 +68,11 @@ class SubuserTransformer extends BaseTransformer /** * Return a generic item of server for this subuser. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeServer(Subuser $subuser): Item|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/TagTransformer.php b/app/Transformers/Api/Application/TagTransformer.php new file mode 100644 index 000000000..c8a56e272 --- /dev/null +++ b/app/Transformers/Api/Application/TagTransformer.php @@ -0,0 +1,93 @@ + ['relation' => 'eggs', 'transformer' => EggTransformer::class, 'ability' => AdminAcl::RESOURCE_EGGS], + 'nodes' => ['relation' => 'nodes', 'transformer' => NodeTransformer::class, 'ability' => AdminAcl::RESOURCE_NODES], + ]; + + /** + * Relationships that can be loaded onto this transformation. + * + * @var list + */ + protected array $availableIncludes = ['eggs', 'nodes']; + + /** + * Return the resource name for the JSONAPI output. + */ + public function getResourceName(): string + { + return Tag::RESOURCE_NAME; + } + + /** + * Transform a tag into its application API representation. Built-in game tags + * report the name and colour that the Panel assigns them. + * + * @return ApiPayload + */ + public function transform(Tag $model): array + { + return [ + 'id' => $model->id, + 'name' => $model->effectiveName(), + 'slug' => $model->slug, + 'color' => $model->effectiveColor(), + 'is_predefined' => $model->isPredefined(), + 'legacy_nest_id' => $model->legacy_nest_id, + 'relationships' => [], + $model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at), + $model->getUpdatedAtColumn() => $this->formatTimestamp($model->updated_at), + ]; + } + + /** + * Include the eggs that carry this tag. + * + * @throws InvalidTransformerLevelException + */ + public function includeEggs(Tag $model): Collection|NullResource + { + if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + return $this->null(); + } + + $model->loadMissing('eggs'); + + return $this->collection($model->getRelation('eggs'), $this->makeTransformer(EggTransformer::class), Egg::RESOURCE_NAME); + } + + /** + * Include the nodes that carry this tag, either as a game they accept or as a + * deployment reservation. + * + * @throws InvalidTransformerLevelException + */ + public function includeNodes(Tag $model): Collection|NullResource + { + if (! $this->authorize(AdminAcl::RESOURCE_NODES)) { + return $this->null(); + } + + $model->loadMissing('nodes'); + + return $this->collection($model->getRelation('nodes'), $this->makeTransformer(NodeTransformer::class), Node::RESOURCE_NAME); + } +} diff --git a/app/Transformers/Api/Application/UserTransformer.php b/app/Transformers/Api/Application/UserTransformer.php index 14e354b45..474f6a8ac 100644 --- a/app/Transformers/Api/Application/UserTransformer.php +++ b/app/Transformers/Api/Application/UserTransformer.php @@ -1,16 +1,25 @@ ['relation' => 'servers', 'transformer' => ServerTransformer::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + ]; + /** * List of resources that can be included. + * + * @var list */ protected array $availableIncludes = ['servers']; @@ -24,6 +33,8 @@ class UserTransformer extends BaseTransformer /** * Return a transformed User model that can be consumed by external services. + * + * @return ApiPayload */ public function transform(User $user): array { @@ -38,6 +49,7 @@ class UserTransformer extends BaseTransformer 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp, + 'relationships' => [], 'created_at' => $this->formatTimestamp($user->created_at), 'updated_at' => $this->formatTimestamp($user->updated_at), ]; @@ -46,11 +58,11 @@ class UserTransformer extends BaseTransformer /** * Return the servers associated with this user. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeServers(User $user): Collection|NullResource { - if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } diff --git a/app/Transformers/Api/Client/AccountTransformer.php b/app/Transformers/Api/Client/AccountTransformer.php index 1a14555d8..e609b2def 100644 --- a/app/Transformers/Api/Client/AccountTransformer.php +++ b/app/Transformers/Api/Client/AccountTransformer.php @@ -1,5 +1,7 @@ 'object', 'additionalProperties' => ['oneOf' => [['type' => 'string'], ['type' => 'integer'], ['type' => 'number'], ['type' => 'boolean'], ['type' => 'array', 'items' => ['type' => 'string']], ['type' => 'object', 'additionalProperties' => ['type' => 'string']]]], 'example' => ['old' => 'old-user@example.com', 'new' => 'new-user@example.com']])] class ActivityLogTransformer extends BaseClientTransformer { + use FormatsActivityLogs; + + protected array $includeRelations = [ + 'actor' => ['relation' => 'actor', 'transformer' => UserTransformer::class], + ]; + + /** + * @var list + */ protected array $availableIncludes = ['actor']; public function getResourceName(): string @@ -16,27 +34,17 @@ class ActivityLogTransformer extends BaseClientTransformer return ActivityLog::RESOURCE_NAME; } + /** + * @return array{id: string, batch: string|null, event: string, is_api: bool, ip: string|null, description: string|null, properties: object, has_additional_metadata: bool, timestamp: string} + */ public function transform(ActivityLog $model): array { - return [ - // This is not for security, it is only to provide a unique identifier to - // the front-end for each entry to improve rendering performance since there - // is nothing else sufficiently unique to key off at this point. - 'id' => sha1($model->id), - 'batch' => $model->batch, - 'event' => $model->event, - 'is_api' => !is_null($model->api_key_id), - 'ip' => $this->canViewIP($model->actor) ? $model->ip : null, - 'description' => $model->description, - 'properties' => $this->properties($model), - 'has_additional_metadata' => $this->hasAdditionalMetadata($model), - 'timestamp' => $model->timestamp->toAtomString(), - ]; + return $this->activityAttributes($model, $this->canViewIP($model)); } - public function includeActor(ActivityLog $model) + public function includeActor(ActivityLog $model): NullResource|Item { - if (!$model->actor instanceof User) { + if (! $model->actor instanceof User) { return $this->null(); } @@ -44,75 +52,27 @@ class ActivityLogTransformer extends BaseClientTransformer } /** - * Transforms any array values in the properties into a countable field for easier - * use within the translation outputs. + * Determines if the user can view the IP address in the output because they are an + * administrator, because they are the actor that performed the action, or because + * the entry has no actor at all and the action was performed against them. That last + * case covers anonymous attempts such as a failed log in, where the address belongs + * to whoever made the attempt rather than to an identified user. */ - protected function properties(ActivityLog $model): object + protected function canViewIP(ActivityLog $model): bool { - if (!$model->properties || $model->properties->isEmpty()) { - return (object) []; + $user = $this->getUser(); + if ($user->root_admin) { + return true; } - $properties = $model->properties - ->mapWithKeys(function ($value, $key) use ($model) { - if ($key === 'ip' && !optional($model->actor)->is($this->request->user())) { - return [$key => '[hidden]']; - } - - if (!is_array($value)) { - // Perform some directory normalization at this point. - if ($key === 'directory') { - $value = str_replace('//', '/', '/' . trim($value, '/') . '/'); - } - - return [$key => $value]; - } - - return [$key => $value, "{$key}_count" => count($value)]; - }); - - $keys = $properties->keys()->filter(fn ($key) => Str::endsWith($key, '_count'))->values(); - if ($keys->containsOneItem()) { - $properties = $properties->merge(['count' => $properties->get($keys[0])])->except($keys[0]); + $actor = $model->actor; + if ($actor instanceof Model) { + return $actor->is($user); } - return (object) $properties->toArray(); - } - - /** - * Determines if there are any log properties that we've not already exposed - * in the response language string and that are not just the IP address or - * the browser useragent. - * - * This is used by the front-end to selectively display an "additional metadata" - * button that is pointless if there is nothing the user can't already see from - * the event description. - */ - protected function hasAdditionalMetadata(ActivityLog $model): bool - { - if (is_null($model->properties) || $model->properties->isEmpty()) { - return false; - } - - $str = trans('activity.' . str_replace(':', '.', $model->event)); - preg_match_all('/:(?[\w.-]+\w)(?:[^\w:]?|$)/', $str, $matches); - - $exclude = array_merge($matches['key'], ['ip', 'useragent', 'using_sftp']); - foreach ($model->properties->keys() as $key) { - if (!in_array($key, $exclude, true)) { - return true; - } - } - - return false; - } - - /** - * Determines if the user can view the IP address in the output either because they are the - * actor that performed the action, or because they are an administrator on the Panel. - */ - protected function canViewIP(?Model $actor = null): bool - { - return optional($actor)->is($this->request->user()) || $this->request->user()->root_admin; + return $model->subjects->contains( + fn (ActivityLogSubject $subject): bool => $subject->subject_type === $user->getMorphClass() + && $subject->subject_id === $user->getKey() + ); } } diff --git a/app/Transformers/Api/Client/AllocationTransformer.php b/app/Transformers/Api/Client/AllocationTransformer.php index 2e63e2bc9..be192b694 100644 --- a/app/Transformers/Api/Client/AllocationTransformer.php +++ b/app/Transformers/Api/Client/AllocationTransformer.php @@ -1,11 +1,18 @@ loadMissing('server'); + $server = $model->server ?? throw new UnexpectedValueException('The allocation does not belong to a server.'); + return [ 'id' => $model->id, 'ip' => $model->ip, 'ip_alias' => $model->ip_alias, 'port' => $model->port, 'notes' => $model->notes, - 'is_default' => $model->server->allocation_id === $model->id, + 'is_default' => $server->allocation_id === $model->id, ]; } } diff --git a/app/Transformers/Api/Client/ApiKeyTransformer.php b/app/Transformers/Api/Client/ApiKeyTransformer.php index ee6efae21..c6f4cef6b 100644 --- a/app/Transformers/Api/Client/ApiKeyTransformer.php +++ b/app/Transformers/Api/Client/ApiKeyTransformer.php @@ -1,9 +1,13 @@ 'array', 'nullable' => true, 'items' => ['type' => 'string'], 'example' => ['127.0.0.1']])] class ApiKeyTransformer extends BaseClientTransformer { public function getResourceName(): string @@ -13,6 +17,8 @@ class ApiKeyTransformer extends BaseClientTransformer /** * Transform this model into a representation that can be consumed by a client. + * + * @return ApiPayload */ public function transform(ApiKey $model): array { @@ -21,7 +27,7 @@ class ApiKeyTransformer extends BaseClientTransformer 'description' => $model->memo, 'allowed_ips' => $model->allowed_ips, 'last_used_at' => $model->last_used_at ? $model->last_used_at->toAtomString() : null, - 'created_at' => $model->created_at->toAtomString(), + 'created_at' => $this->formatTimestamp($model->created_at), ]; } } diff --git a/app/Transformers/Api/Client/BackupTransformer.php b/app/Transformers/Api/Client/BackupTransformer.php index 298c99642..a36478a41 100644 --- a/app/Transformers/Api/Client/BackupTransformer.php +++ b/app/Transformers/Api/Client/BackupTransformer.php @@ -1,9 +1,14 @@ request->user(); + return $this->request()->user() ?? throw new UnexpectedValueException('Client API transformers require an authenticated user.'); } /** @@ -26,14 +30,20 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer */ protected function authorize(string $ability, ?Server $server = null): bool { - Assert::isInstanceOf($server, Server::class); + throw_unless($server instanceof Server, InvalidArgumentException::class, 'Expected a server when authorizing client transformer includes.'); - return $this->request->user()->can($ability, [$server]); + return $this->getUser()->can($ability, [$server]); } - protected function makeTransformer(string $abstract) + /** + * @template T of BaseClientTransformer + * + * @param class-string $abstract + * @return T + */ + protected function makeTransformer(string $abstract): self { - Assert::subclassOf($abstract, self::class); + throw_unless(is_subclass_of($abstract, self::class), InvalidTransformerLevelException::class, "Transformer [$abstract] must extend ".self::class.'.'); return parent::makeTransformer($abstract); } diff --git a/app/Transformers/Api/Client/DatabaseTransformer.php b/app/Transformers/Api/Client/DatabaseTransformer.php index 23e966637..cb0616d9b 100644 --- a/app/Transformers/Api/Client/DatabaseTransformer.php +++ b/app/Transformers/Api/Client/DatabaseTransformer.php @@ -1,45 +1,45 @@ */ - public function handle(Encrypter $encrypter, HashidsInterface $hashids) - { - $this->encrypter = $encrypter; - $this->hashids = $hashids; - } + protected array $availableIncludes = ['password']; public function getResourceName(): string { return Database::RESOURCE_NAME; } + /** + * @return ApiPayload + */ public function transform(Database $model): array { $model->loadMissing('host'); + $host = $model->host; return [ - 'id' => $this->hashids->encode($model->id), + 'id' => Hashids::encode($model->id), 'host' => [ - 'address' => $model->getRelation('host')->host, - 'port' => $model->getRelation('host')->port, + 'address' => $host->host, + 'port' => $host->port, ], 'name' => $model->database, 'username' => $model->username, @@ -53,14 +53,12 @@ class DatabaseTransformer extends BaseClientTransformer */ public function includePassword(Database $database): Item|NullResource { - if (!$this->request->user()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) { + if (! $this->getUser()->can(Permissions::DatabaseViewPassword->value, $database->server)) { return $this->null(); } - return $this->item($database, function (Database $model) { - return [ - 'password' => $this->encrypter->decrypt($model->password), - ]; - }, 'database_password'); + return $this->item($database, fn (Database $model): array => [ + 'password' => Crypt::decrypt($model->password), + ], 'database_password'); } } diff --git a/app/Transformers/Api/Client/EggTransformer.php b/app/Transformers/Api/Client/EggTransformer.php index 8e2e3474e..95a3d53f0 100644 --- a/app/Transformers/Api/Client/EggTransformer.php +++ b/app/Transformers/Api/Client/EggTransformer.php @@ -1,5 +1,7 @@ user_viewable) { - throw new \BadMethodCallException('Cannot transform a hidden egg variable in a client transformer.'); - } + throw_unless($variable->user_viewable, BadMethodCallException::class, 'Cannot transform a hidden egg variable in a client transformer.'); return [ 'name' => $variable->name, 'description' => $variable->description, 'env_variable' => $variable->env_variable, 'default_value' => $variable->default_value, - 'server_value' => $variable->server_value, + 'server_value' => $variable->server_value ?? null, 'is_editable' => $variable->user_editable, 'rules' => $variable->rules, ]; diff --git a/app/Transformers/Api/Client/FileObjectTransformer.php b/app/Transformers/Api/Client/FileObjectTransformer.php index 6278dad73..4f65f1df9 100644 --- a/app/Transformers/Api/Client/FileObjectTransformer.php +++ b/app/Transformers/Api/Client/FileObjectTransformer.php @@ -1,27 +1,31 @@ Arr::get($item, 'name'), - 'mode' => Arr::get($item, 'mode'), - 'mode_bits' => Arr::get($item, 'mode_bits'), - 'size' => Arr::get($item, 'size'), - 'is_file' => Arr::get($item, 'file', true), - 'is_symlink' => Arr::get($item, 'symlink', false), - 'mimetype' => Arr::get($item, 'mime', 'application/octet-stream'), - 'created_at' => Carbon::parse(Arr::get($item, 'created', ''))->toAtomString(), - 'modified_at' => Carbon::parse(Arr::get($item, 'modified', ''))->toAtomString(), + 'name' => $item['name'] ?? null, + 'mode' => $item['mode'] ?? null, + 'mode_bits' => $item['mode_bits'] ?? null, + 'size' => $item['size'] ?? null, + 'is_file' => $item['file'] ?? true, + 'is_symlink' => $item['symlink'] ?? false, + 'mimetype' => $item['mime'] ?? 'application/octet-stream', + 'created_at' => Date::parse($item['created'] ?? '')->toAtomString(), + 'modified_at' => Date::parse($item['modified'] ?? '')->toAtomString(), ]; } diff --git a/app/Transformers/Api/Client/ScheduleTransformer.php b/app/Transformers/Api/Client/ScheduleTransformer.php index e98dc7bc8..90daf2491 100644 --- a/app/Transformers/Api/Client/ScheduleTransformer.php +++ b/app/Transformers/Api/Client/ScheduleTransformer.php @@ -1,15 +1,30 @@ ['relation' => 'tasks', 'transformer' => TaskTransformer::class], + ]; + + /** + * @var list + */ protected array $availableIncludes = ['tasks']; + /** + * @var list + */ protected array $defaultIncludes = ['tasks']; public function getResourceName(): string @@ -19,6 +34,8 @@ class ScheduleTransformer extends BaseClientTransformer /** * Returns a transformed schedule model such that a client can view the information. + * + * @return ApiPayload */ public function transform(Schedule $model): array { @@ -45,7 +62,7 @@ class ScheduleTransformer extends BaseClientTransformer /** * Allows attaching the tasks specific to the schedule in the response. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeTasks(Schedule $model): Collection { diff --git a/app/Transformers/Api/Client/ServerTransformer.php b/app/Transformers/Api/Client/ServerTransformer.php index 747d2f2d8..ac1babefd 100644 --- a/app/Transformers/Api/Client/ServerTransformer.php +++ b/app/Transformers/Api/Client/ServerTransformer.php @@ -1,25 +1,58 @@ 'string', 'pattern' => '^serv_[a-zA-Z0-9]+$', 'example' => 'serv_1a2b3c4d'])] +#[ResponseField('description', example: 'Survival world', nullable: true)] +#[ResponseField('status', schema: ['type' => 'string', 'nullable' => true, 'enum' => ['installing', 'install_failed', 'reinstall_failed', 'suspended', 'restoring_backup', null], 'example' => null])] +#[ResponseField('limits.threads', schema: ['type' => 'string', 'nullable' => true, 'example' => '1,2'])] +#[ResponseField('feature_limits.databases', 'integer', example: 5, nullable: true)] +#[ResponseField('feature_limits.allocations', 'integer', example: 5, nullable: true)] +#[ResponseField('feature_limits.backups', 'integer', example: 5, nullable: true)] +#[ResponseField('egg_features', schema: ['type' => 'array', 'nullable' => true, 'items' => ['type' => 'string'], 'example' => ['eula']])] +#[ResponseField('egg_tags', schema: ['type' => 'array', 'items' => ['type' => 'string'], 'example' => ['minecraft']])] class ServerTransformer extends BaseClientTransformer { + protected array $eagerLoads = ['egg.variables', 'egg.configFrom', 'egg.tags', 'serverVariables', 'node', 'transfer', 'subusers', 'allocation']; + + protected array $includeRelations = [ + 'allocations' => ['relation' => 'allocations', 'transformer' => AllocationTransformer::class], + 'egg' => ['relation' => 'egg', 'transformer' => EggTransformer::class], + 'subusers' => ['relation' => 'subusers', 'transformer' => SubuserTransformer::class], + ]; + + /** + * @var list + */ protected array $defaultIncludes = ['allocations', 'variables']; + /** + * @var list + */ protected array $availableIncludes = ['egg', 'subusers']; + public function __construct( + private readonly EnvironmentService $environmentService, + private readonly StartupCommandService $startupCommandService, + ) {} + public function getResourceName(): string { return Server::RESOURCE_NAME; @@ -28,13 +61,15 @@ class ServerTransformer extends BaseClientTransformer /** * Transform a server model into a representation that can be returned * to a client. + * + * @return ApiPayload */ public function transform(Server $server): array { - /** @var StartupCommandService $service */ - $service = Container::getInstance()->make(StartupCommandService::class); + $user = $this->getUser(); - $user = $this->request->user(); + $server->loadMissing(['egg.tags', 'node', 'transfer']); + $egg = $server->egg ?? throw new UnexpectedValueException('The server does not have an egg relationship.'); return [ 'server_owner' => $user->id === $server->owner_id, @@ -42,9 +77,6 @@ class ServerTransformer extends BaseClientTransformer ? $server->identifier : $server->uuidShort, '__deprecated_uuid_short' => $server->uuidShort, - // In Pterodactyl 2.0 we'll be replacing `identifier` above with the actual - // "identifier" used internally. This is a completely different value compared - // to the current however, and would be quite a breaking change to URLs. 'server_identifier' => $server->identifier, 'internal_id' => $server->id, 'uuid' => $server->uuid, @@ -65,9 +97,10 @@ class ServerTransformer extends BaseClientTransformer 'threads' => $server->threads, 'oom_disabled' => $server->oom_disabled, ], - 'invocation' => $service->handle($server, !$user->can(Permission::ACTION_STARTUP_READ, $server)), + 'invocation' => $this->startupCommandService->handle($server, ! $user->can(Permissions::StartupRead->value, $server)), 'docker_image' => $server->image, - 'egg_features' => $server->egg->inherit_features, + 'egg_features' => $egg->inherit_features, + 'egg_tags' => $egg->tagSlugs(), 'feature_limits' => [ 'databases' => $server->database_limit, 'allocations' => $server->allocation_limit, @@ -77,21 +110,22 @@ class ServerTransformer extends BaseClientTransformer // This field is deprecated, please use "status". 'is_suspended' => $server->isSuspended(), // This field is deprecated, please use "status". - 'is_installing' => !$server->isInstalled(), - 'is_transferring' => !is_null($server->transfer), + 'is_installing' => ! $server->isInstalled(), + 'is_transferring' => ($server->transfer) !== null, + 'skip_scripts' => $server->skip_scripts, ]; } /** * Returns the allocations associated with this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeAllocations(Server $server): Collection { $transformer = $this->makeTransformer(AllocationTransformer::class); - $user = $this->request->user(); + $user = $this->getUser(); // While we include this permission, we do need to actually handle it slightly different here // for the purpose of keeping things functionally working. If the user doesn't have read permissions // for the allocations we'll only return the primary server allocation, and any notes associated @@ -99,27 +133,27 @@ class ServerTransformer extends BaseClientTransformer // // This allows us to avoid too much permission regression, without also hiding information that // is generally needed for the frontend to make sense when browsing or searching results. - if (!$user->can(Permission::ACTION_ALLOCATION_READ, $server)) { - $primary = clone $server->allocation; + if (! $user->can(Permissions::AllocationRead->value, $server)) { + $primary = clone ($server->allocation ?? throw new UnexpectedValueException('The server does not have a primary allocation.')); $primary->notes = null; return $this->collection([$primary], $transformer, Allocation::RESOURCE_NAME); } - return $this->collection($server->allocations, $transformer, Allocation::RESOURCE_NAME); + return $this->collection($server->loadMissing('allocations')->allocations, $transformer, Allocation::RESOURCE_NAME); } /** - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeVariables(Server $server): Collection|NullResource { - if (!$this->request->user()->can(Permission::ACTION_STARTUP_READ, $server)) { + if (! $this->getUser()->can(Permissions::StartupRead->value, $server)) { return $this->null(); } return $this->collection( - $server->variables->where('user_viewable', true), + $this->environmentService->variables($server)->where('user_viewable', true)->values(), $this->makeTransformer(EggVariableTransformer::class), EggVariable::RESOURCE_NAME ); @@ -128,21 +162,23 @@ class ServerTransformer extends BaseClientTransformer /** * Returns the egg associated with this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeEgg(Server $server): Item { - return $this->item($server->egg, $this->makeTransformer(EggTransformer::class), Egg::RESOURCE_NAME); + $egg = $server->egg ?? throw new UnexpectedValueException('The server does not have an egg relationship.'); + + return $this->item($egg, $this->makeTransformer(EggTransformer::class), Egg::RESOURCE_NAME); } /** * Returns the subusers associated with this server. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @throws InvalidTransformerLevelException */ public function includeSubusers(Server $server): Collection|NullResource { - if (!$this->request->user()->can(Permission::ACTION_USER_READ, $server)) { + if (! $this->getUser()->can(Permissions::UserRead->value, $server)) { return $this->null(); } diff --git a/app/Transformers/Api/Client/StatsTransformer.php b/app/Transformers/Api/Client/StatsTransformer.php index 6b323b315..3f1a0c919 100644 --- a/app/Transformers/Api/Client/StatsTransformer.php +++ b/app/Transformers/Api/Client/StatsTransformer.php @@ -1,8 +1,10 @@ Arr::get($data, 'state', 'stopped'), - 'is_suspended' => Arr::get($data, 'is_suspended', false), + 'current_state' => $state->state, + 'is_suspended' => $state->isSuspended, 'resources' => [ - 'memory_bytes' => Arr::get($data, 'utilization.memory_bytes', 0), - 'cpu_absolute' => Arr::get($data, 'utilization.cpu_absolute', 0), - 'disk_bytes' => Arr::get($data, 'utilization.disk_bytes', 0), - 'network_rx_bytes' => Arr::get($data, 'utilization.network.rx_bytes', 0), - 'network_tx_bytes' => Arr::get($data, 'utilization.network.tx_bytes', 0), - 'uptime' => Arr::get($data, 'utilization.uptime', 0), + 'memory_bytes' => $state->memoryBytes, + 'cpu_absolute' => $state->cpuAbsolute, + 'disk_bytes' => $state->diskBytes, + 'network_rx_bytes' => $state->networkRxBytes, + 'network_tx_bytes' => $state->networkTxBytes, + 'uptime' => $state->uptime, ], ]; } diff --git a/app/Transformers/Api/Client/SubuserTransformer.php b/app/Transformers/Api/Client/SubuserTransformer.php index 2902d1f7a..e3b01cc70 100644 --- a/app/Transformers/Api/Client/SubuserTransformer.php +++ b/app/Transformers/Api/Client/SubuserTransformer.php @@ -1,11 +1,18 @@ 'array', 'items' => ['type' => 'string'], 'example' => ['control.console', 'file.read']])] class SubuserTransformer extends BaseClientTransformer { + protected array $eagerLoads = ['user']; + /** * Return the resource name for the JSONAPI output. */ @@ -17,12 +24,14 @@ class SubuserTransformer extends BaseClientTransformer /** * Transforms a subuser into a model that can be shown to a front-end user. * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + * @return ApiPayload + * + * @throws InvalidTransformerLevelException */ public function transform(Subuser $model): array { return array_merge( - $this->makeTransformer(UserTransformer::class)->transform($model->user), + $this->makeTransformer(UserTransformer::class)->transform($model->loadMissing('user')->user), ['permissions' => $model->permissions] ); } diff --git a/app/Transformers/Api/Client/TaskTransformer.php b/app/Transformers/Api/Client/TaskTransformer.php index 25b9eebc8..02c0a316f 100644 --- a/app/Transformers/Api/Client/TaskTransformer.php +++ b/app/Transformers/Api/Client/TaskTransformer.php @@ -1,9 +1,13 @@ $model->name, 'fingerprint' => $model->fingerprint, 'public_key' => $model->public_key, - 'created_at' => $model->created_at->toAtomString(), + 'created_at' => $this->formatTimestamp($model->created_at), ]; } } diff --git a/app/Transformers/Api/Client/UserTransformer.php b/app/Transformers/Api/Client/UserTransformer.php index 559aa190d..a722bc8e1 100644 --- a/app/Transformers/Api/Client/UserTransformer.php +++ b/app/Transformers/Api/Client/UserTransformer.php @@ -1,5 +1,7 @@ $model->identifier, 'username' => $model->username, 'email' => $model->email, - 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($model->email)), + 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($model->email)), '2fa_enabled' => $model->use_totp, - 'created_at' => $model->created_at->toAtomString(), + 'created_at' => $this->formatTimestamp($model->created_at), ]; } } diff --git a/app/Transformers/Concerns/FormatsActivityLogs.php b/app/Transformers/Concerns/FormatsActivityLogs.php new file mode 100644 index 000000000..d13661de4 --- /dev/null +++ b/app/Transformers/Concerns/FormatsActivityLogs.php @@ -0,0 +1,106 @@ + sha1((string) $model->id), + 'batch' => $model->batch, + 'event' => $model->event, + 'is_api' => ($model->api_key_id ?? 0) > 0, + 'ip' => $canViewIp ? $model->ip : null, + 'description' => $model->description, + 'properties' => $this->activityProperties($model, $canViewIp), + 'has_additional_metadata' => $this->activityHasAdditionalMetadata($model), + 'timestamp' => $model->timestamp->toAtomString(), + ]; + } + + /** + * Transforms any array values in the properties into a countable field for easier + * use within the translation outputs. + */ + protected function activityProperties(ActivityLog $model, bool $canViewIp): object + { + $values = $model->propertyValues(); + if ($values === []) { + return new stdClass; + } + + $properties = collect($values) + ->mapWithKeys(function (array|bool|float|int|string|null $value, string $key) use ($canViewIp): array { + if ($key === 'ip' && ! $canViewIp) { + return [$key => '[hidden]']; + } + + $arraySize = JsonValueTree::from($value)->arraySize(); + if ($arraySize === null) { + // Perform some directory normalization at this point. + if ($key === 'directory') { + $value = str_replace('//', '/', '/'.mb_trim(JsonValueGuard::string($value), '/').'/'); + } + + return [$key => $value]; + } + + return [$key => $value, "{$key}_count" => $arraySize]; + }); + + $keys = $properties->keys()->filter(fn (int|string $key): bool => Str::endsWith((string) $key, '_count'))->values(); + if ($keys->containsOneItem()) { + $countKey = $keys->first(); + if ($countKey !== null) { + $properties = $properties->merge(['count' => $properties->get($countKey)])->except($countKey); + } + } + + // SAFETY: JSON object properties are string-keyed, and object casting preserves those keys for response encoding. + return (object) $properties->all(); + } + + /** + * Determines if there are any log properties that we've not already exposed + * in the response language string and that are not just the IP address or + * the browser useragent. + * + * This is used by the front-end to selectively display an "additional metadata" + * button that is pointless if there is nothing the user can't already see from + * the event description. + */ + protected function activityHasAdditionalMetadata(ActivityLog $model): bool + { + $properties = $model->propertyValues(); + if ($properties === []) { + return false; + } + + $str = trans('activity.'.str_replace(':', '.', $model->event)); + preg_match_all('/:(?[\w.-]+\w)(?:[^\w:]?|$)/', JsonValueGuard::string($str), $matches); + + $exclude = array_merge($matches['key'], ['ip', 'useragent', 'using_sftp']); + foreach (array_keys($properties) as $key) { + if (! in_array($key, $exclude, true)) { + return true; + } + } + + return false; + } +} diff --git a/app/Validation/ActivityLogRules.php b/app/Validation/ActivityLogRules.php new file mode 100644 index 000000000..5ad8017f7 --- /dev/null +++ b/app/Validation/ActivityLogRules.php @@ -0,0 +1,23 @@ + ['sometimes', 'array'], + 'filter.user' => ['sometimes', 'nullable', 'string'], + 'filter.user_id' => ['sometimes', 'nullable', 'integer', 'min:1'], + 'filter.event' => ['sometimes', 'nullable', 'string'], + 'filter.event_name' => ['sometimes', 'nullable', 'string'], + 'filter.ip' => ['sometimes', 'nullable', 'string'], + 'page' => ['sometimes', 'integer', 'min:1'], + 'per_page' => ['sometimes', 'integer', 'min:1'], + ]; + } +} diff --git a/app/Validation/AllocationRules.php b/app/Validation/AllocationRules.php new file mode 100644 index 000000000..98e1d4574 --- /dev/null +++ b/app/Validation/AllocationRules.php @@ -0,0 +1,40 @@ +where(function (Builder $query): void { + $query->whereNull('server_id'); + }); + } + + /** + * Validation rules for allocation attributes, consumed by the requests that + * accept them. + * + * @return NormalizedValidationRules + */ + public static function rules(): array + { + return [ + 'node_id' => ['required', 'exists:nodes,id'], + 'ip' => ['required', 'ip'], + 'port' => ['required', 'numeric', 'between:1024,65535'], + 'ip_alias' => ['nullable', 'string'], + 'server_id' => ['nullable', 'exists:servers,id'], + 'notes' => ['nullable', 'string', 'max:256'], + ]; + } +} diff --git a/app/Validation/ApiKeyRules.php b/app/Validation/ApiKeyRules.php new file mode 100644 index 000000000..fd3bbf0fc --- /dev/null +++ b/app/Validation/ApiKeyRules.php @@ -0,0 +1,38 @@ + ['required', 'exists:users,id'], + 'key_type' => ['present', 'integer', 'min:0', 'max:4'], + 'identifier' => ['required', 'string', 'size:16', 'unique:api_keys,identifier'], + 'token' => ['required', 'string'], + 'memo' => ['required', 'nullable', 'string', 'max:500'], + 'allowed_ips' => ['nullable', 'array'], + 'allowed_ips.*' => ['string'], + 'last_used_at' => ['nullable', 'date'], + 'expires_at' => ['nullable', 'date'], + 'r_'.AdminAcl::RESOURCE_USERS => ['integer', 'min:0', 'max:3'], + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => ['integer', 'min:0', 'max:3'], + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => ['integer', 'min:0', 'max:3'], + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => ['integer', 'min:0', 'max:3'], + 'r_'.AdminAcl::RESOURCE_EGGS => ['integer', 'min:0', 'max:3'], + 'r_'.AdminAcl::RESOURCE_LOCATIONS => ['integer', 'min:0', 'max:3'], + 'r_'.AdminAcl::RESOURCE_NODES => ['integer', 'min:0', 'max:3'], + 'r_'.AdminAcl::RESOURCE_SERVERS => ['integer', 'min:0', 'max:3'], + ]; + } +} diff --git a/app/Validation/DatabaseHostRules.php b/app/Validation/DatabaseHostRules.php new file mode 100644 index 000000000..f5f49ef78 --- /dev/null +++ b/app/Validation/DatabaseHostRules.php @@ -0,0 +1,25 @@ + ['required', 'string', 'max:191'], + 'host' => ['required', 'string', 'regex:/^[\w\-\.]+$/'], + 'port' => ['required', 'numeric', 'between:1,65535'], + 'username' => ['required', 'string', 'max:32'], + 'password' => ['nullable', 'string'], + 'node_id' => ['sometimes', 'nullable', 'integer', 'exists:nodes,id'], + ]; + } +} diff --git a/app/Validation/DatabaseRules.php b/app/Validation/DatabaseRules.php new file mode 100644 index 000000000..f69a52865 --- /dev/null +++ b/app/Validation/DatabaseRules.php @@ -0,0 +1,26 @@ + ['required', 'numeric', 'exists:servers,id'], + 'database_host_id' => ['required', 'exists:database_hosts,id'], + 'database' => ['required', 'string', 'alpha_dash', 'between:3,48'], + 'username' => ['string', 'alpha_dash', 'between:3,100'], + 'max_connections' => ['nullable', 'integer'], + 'remote' => ['required', 'string', 'regex:/^[\w\-\/.%:]+$/'], + 'password' => ['string'], + ]; + } +} diff --git a/app/Validation/LocationRules.php b/app/Validation/LocationRules.php new file mode 100644 index 000000000..8c8010945 --- /dev/null +++ b/app/Validation/LocationRules.php @@ -0,0 +1,25 @@ + ['required', 'string', 'between:1,60', Rule::unique('locations', 'short')->ignore($ignore)], + 'long' => ['string', 'nullable', 'between:1,191'], + ]; + } +} diff --git a/app/Validation/MountRules.php b/app/Validation/MountRules.php new file mode 100644 index 000000000..cb8e16e76 --- /dev/null +++ b/app/Validation/MountRules.php @@ -0,0 +1,30 @@ + ['required', 'string', 'min:2', 'max:64', Rule::unique('mounts', 'name')->ignore($ignore)], + 'description' => ['nullable', 'string', 'max:191'], + 'source' => ['required', 'string', new NotIn(Mount::$invalidSourcePaths)], + 'target' => ['required', 'string', new NotIn(Mount::$invalidTargetPaths)], + 'read_only' => ['sometimes', 'boolean'], + 'user_mountable' => ['sometimes', 'boolean'], + ]; + } +} diff --git a/app/Validation/NodeRules.php b/app/Validation/NodeRules.php new file mode 100644 index 000000000..57dab1b43 --- /dev/null +++ b/app/Validation/NodeRules.php @@ -0,0 +1,35 @@ + ['required', 'regex:/^([\w .-]{1,100})$/'], + 'description' => ['string', 'nullable'], + 'location_id' => ['required', 'exists:locations,id'], + 'public' => ['boolean'], + 'fqdn' => ['required', 'string'], + 'scheme' => ['required'], + 'behind_proxy' => ['boolean'], + 'memory' => ['required', 'numeric', 'min:1'], + 'memory_overallocate' => ['required', 'numeric', 'min:-1'], + 'disk' => ['required', 'numeric', 'min:1'], + 'disk_overallocate' => ['required', 'numeric', 'min:-1'], + 'daemonBase' => ['sometimes', 'required', 'regex:/^([\/][\d\w.\-\/]+)$/'], + 'daemonSFTP' => ['required', 'numeric', 'between:1,65535'], + 'daemonListen' => ['required', 'numeric', 'between:1,65535'], + 'maintenance_mode' => ['boolean'], + 'upload_size' => ['int', 'min:1'], + ]; + } +} diff --git a/app/Validation/ScheduleRules.php b/app/Validation/ScheduleRules.php new file mode 100644 index 000000000..8ea1719e9 --- /dev/null +++ b/app/Validation/ScheduleRules.php @@ -0,0 +1,31 @@ + ['required', 'exists:servers,id'], + 'name' => ['required', 'string', 'max:191'], + 'cron_day_of_week' => ['required', 'string'], + 'cron_month' => ['required', 'string'], + 'cron_day_of_month' => ['required', 'string'], + 'cron_hour' => ['required', 'string'], + 'cron_minute' => ['required', 'string'], + 'is_active' => ['boolean'], + 'is_processing' => ['boolean'], + 'only_when_online' => ['boolean'], + 'last_run_at' => ['nullable', 'date'], + 'next_run_at' => ['nullable', 'date'], + ]; + } +} diff --git a/app/Validation/ServerRules.php b/app/Validation/ServerRules.php new file mode 100644 index 000000000..3f644f99d --- /dev/null +++ b/app/Validation/ServerRules.php @@ -0,0 +1,44 @@ + ['sometimes', 'nullable', 'string', 'between:1,191', Rule::unique('servers', 'external_id')->ignore($ignore)], + 'owner_id' => ['required', 'integer', 'exists:users,id'], + 'name' => ['required', 'string', 'min:1', 'max:191'], + 'node_id' => ['required', 'exists:nodes,id'], + 'description' => ['string'], + 'status' => ['nullable', 'string'], + 'memory' => ['required', 'numeric', 'min:0'], + 'swap' => ['required', 'numeric', 'min:-1'], + 'io' => ['required', 'numeric', 'between:10,1000'], + 'cpu' => ['required', 'numeric', 'min:0'], + 'threads' => ['nullable', 'regex:/^[0-9-,]+$/'], + 'oom_disabled' => ['sometimes', 'boolean'], + 'disk' => ['required', 'numeric', 'min:0'], + 'allocation_id' => ['required', 'bail', Rule::unique('servers', 'allocation_id')->ignore($ignore), 'exists:allocations,id'], + 'egg_id' => ['required', 'exists:eggs,id'], + 'startup' => ['required', 'string'], + 'skip_scripts' => ['sometimes', 'boolean'], + 'image' => ['required', 'string', 'max:191', 'regex:/^~?[\w\.\/\-:@ ]*$/'], + 'database_limit' => ['present', 'nullable', 'integer', 'min:0'], + 'allocation_limit' => ['sometimes', 'nullable', 'integer', 'min:0'], + 'backup_limit' => ['present', 'nullable', 'integer', 'min:0'], + ]; + } +} diff --git a/app/Validation/TagRules.php b/app/Validation/TagRules.php new file mode 100644 index 000000000..740595c4e --- /dev/null +++ b/app/Validation/TagRules.php @@ -0,0 +1,29 @@ + ['required', 'string', 'between:1,191'], + 'slug' => ['required', 'string', 'between:1,191', Rule::unique('tags', 'slug')->ignore($ignore)], + // Custom tags store an optional chip colour; built-in tags ignore it - their + // colour is owned by EggSpecificTags. Null clears it. + 'color' => ['nullable', 'string', 'hex_color'], + 'legacy_nest_id' => ['sometimes', 'nullable', 'integer'], + ]; + } +} diff --git a/app/Validation/UserRules.php b/app/Validation/UserRules.php new file mode 100644 index 000000000..441c9bd0f --- /dev/null +++ b/app/Validation/UserRules.php @@ -0,0 +1,40 @@ + + */ + public const array PASSWORD = ['string', 'min:8']; + + /** + * Validation rules for the user requests and p:user:make. + * + * @return NormalizedValidationRules + */ + public static function rules(?User $ignore = null): array + { + return [ + 'email' => ['required', 'email:strict', 'between:1,191', new UserEmail, Rule::unique('users', 'email')->ignore($ignore)], + 'external_id' => ['sometimes', 'nullable', 'string', 'max:191', Rule::unique('users', 'external_id')->ignore($ignore)], + 'username' => ['required', 'between:1,191', Rule::unique('users', 'username')->ignore($ignore), new Username], + 'name_first' => ['required', 'string', 'between:1,191'], + 'name_last' => ['required', 'string', 'between:1,191'], + 'password' => ['sometimes', 'nullable', ...self::PASSWORD], + 'root_admin' => ['boolean'], + 'language' => ['string', new In(array_keys((new User)->getAvailableLanguages()))], + ]; + } +} diff --git a/app/Validation/UserSSHKeyRules.php b/app/Validation/UserSSHKeyRules.php new file mode 100644 index 000000000..f8f284e17 --- /dev/null +++ b/app/Validation/UserSSHKeyRules.php @@ -0,0 +1,67 @@ + + */ + private const array PUBLIC_KEY_PREFIXES = [ + 'ssh-rsa ', + 'ssh-ed25519 ', + 'ecdsa-sha2-', + 'sk-ssh-ed25519@openssh.com ', + 'sk-ecdsa-sha2-nistp256@openssh.com ', + '-----BEGIN PUBLIC KEY-----', + '-----BEGIN RSA PUBLIC KEY-----', + '-----BEGIN EC PUBLIC KEY-----', + '-----BEGIN DSA PUBLIC KEY-----', + '---- BEGIN SSH2 PUBLIC KEY ----', + ]; + + /** + * Validation rules for the client SSH key request. + * + * @return NormalizedValidationRules + */ + public static function rules(): array + { + return [ + 'name' => ['required', 'string'], + 'fingerprint' => ['required', 'string'], + 'public_key' => ['required', 'string', 'max:'.self::PUBLIC_KEY_MAX_LENGTH], + ]; + } + + /** + * Whether a value is a supported public key format that is safe to parse: not empty, + * no longer than the limit, without NUL bytes, and starting with a known key prefix. + * Certificates are not public keys and are rejected. + */ + public static function isSupportedPublicKey(string $value): bool + { + $value = mb_trim($value); + + if ($value === '' || mb_strlen($value) > self::PUBLIC_KEY_MAX_LENGTH || str_contains($value, "\0")) { + return false; + } + + foreach (self::PUBLIC_KEY_PREFIXES as $prefix) { + if (str_starts_with($value, $prefix)) { + return true; + } + } + + return false; + } +} diff --git a/app/helpers.php b/app/helpers.php deleted file mode 100644 index 59aa7166a..000000000 --- a/app/helpers.php +++ /dev/null @@ -1,35 +0,0 @@ -{$segment}; - } - - return $object; - } -} diff --git a/artisan b/artisan index 240ab7a91..c35e31d6a 100755 --- a/artisan +++ b/artisan @@ -1,53 +1,18 @@ #!/usr/bin/env php make(Illuminate\Contracts\Console\Kernel::class); - -$status = $kernel->handle( - $input = new Symfony\Component\Console\Input\ArgvInput(), - new Symfony\Component\Console\Output\ConsoleOutput() -); - -/* -|-------------------------------------------------------------------------- -| Shutdown The Application -|-------------------------------------------------------------------------- -| -| Once Artisan has finished running, we will fire off the shutdown events -| so that any final work may be done by the application before we shut -| down the process. This is the last thing to happen to the request. -| -*/ - -$kernel->terminate($input, $status); +$status = $app->handleCommand(new ArgvInput); exit($status); diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 808bb186f..000000000 --- a/babel.config.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = function (api) { - let targets = {}; - const plugins = [ - 'babel-plugin-macros', - 'styled-components', - 'react-hot-loader/babel', - '@babel/transform-runtime', - '@babel/transform-react-jsx', - '@babel/proposal-class-properties', - '@babel/proposal-object-rest-spread', - '@babel/proposal-optional-chaining', - '@babel/proposal-nullish-coalescing-operator', - '@babel/syntax-dynamic-import', - ]; - - if (api.env('test')) { - targets = { node: 'current' }; - plugins.push('@babel/transform-modules-commonjs'); - } - - return { - plugins, - presets: [ - '@babel/typescript', - ['@babel/env', { - modules: false, - useBuiltIns: 'entry', - corejs: 3, - targets, - }], - '@babel/react', - ] - }; -}; diff --git a/bootstrap/app.php b/bootstrap/app.php index 74bae64a8..5f48d6a3d 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,59 +1,137 @@ withRouting(using: function (): void { + Route::middleware('web')->group(function (): void { + Route::middleware(['auth.session', RequireTwoFactorAuthentication::class]) + ->group(base_path('routes/base.php')); + + Route::middleware('guest')->prefix('/auth')->group(base_path('routes/auth.php')); + }); + + Route::middleware(['api', RequireTwoFactorAuthentication::class])->group(function (): void { + Route::middleware(['application-api', 'throttle:api.application']) + ->prefix('/api/application') + ->scopeBindings() + ->group(base_path('routes/api-application.php')); + + Route::middleware(['client-api', 'throttle:api.client']) + ->prefix('/api/client') + ->scopeBindings() + ->group(base_path('routes/api-client.php')); + + Route::middleware(['admin-api', 'throttle:api.admin']) + ->prefix('/api/admin') + ->scopeBindings() + ->group(base_path('routes/api-admin.php')); + }); + + Route::middleware('daemon') + ->prefix('/api/remote') + ->scopeBindings() + ->group(base_path('routes/api-remote.php')); + }) + ->withMiddleware(function (Middleware $middleware): void { + $middleware->append(SetSecurityHeaders::class); + + $middleware->trimStrings(except: [ + 'password', + 'password_confirmation', + fn (Request $request): bool => $request->is('api/client/servers/*/files', 'api/client/servers/*/files/*'), + ]); + + $middleware->preventRequestForgery(except: ['remote/*', 'daemon/*']); + + $middleware->redirectGuestsTo('/auth/login'); + + $middleware->priority([SubstituteClientBindings::class]); + + $middleware->web(append: LanguageMiddleware::class); + + $middleware->group('api', [ + EnsureStatefulRequests::class, + 'auth:sanctum', + IsValidJson::class, + TrackAPIKey::class, + RequireTwoFactorAuthentication::class, + AuthenticateIPAccess::class, + ]); + + $middleware->group('application-api', [SubstituteBindings::class, AuthenticateApplicationUser::class]); + $middleware->group('client-api', [SubstituteClientBindings::class, RequireClientApiKey::class]); + $middleware->group('admin-api', [SubstituteBindings::class, AuthenticateAdmin::class]); + $middleware->group('daemon', [SubstituteBindings::class, DaemonAuthenticate::class]); + + $middleware->alias([ + 'guest' => RedirectIfAuthenticated::class, + 'recaptcha' => VerifyReCaptcha::class, + 'node.maintenance' => MaintenanceMiddleware::class, + ]); + }) + ->withSchedule(new Scheduler) + ->withExceptions(function (Exceptions $exceptions): void { + if (config('app.exceptions.report_all', false)) { + $exceptions->stopIgnoring([ + AuthenticationException::class, + AuthorizationException::class, + HttpException::class, + ModelNotFoundException::class, + TokenMismatchException::class, + ValidationException::class, + ]); + } + + $exceptions->dontFlash(['token', 'secret', 'password', 'password_confirmation']); + + $exceptions->render(fn (ValidationException $e, Request $request): ?JsonResponse => $request->expectsJson() ? ApiErrorResponse::validation($e) : null); + + $exceptions->render(fn (AuthenticationException $e, Request $request): JsonResponse|RedirectResponse => $request->expectsJson() + ? ApiErrorResponse::render($e) + : redirect()->guest('/auth/login')); + + $exceptions->render(fn (Throwable $e, Request $request): ?JsonResponse => $request->expectsJson() && ! $e instanceof HttpResponseException + ? ApiErrorResponse::render($e) + : null); + }) + ->create(); if (isset($_ENV['APP_STORAGE_PATH'])) { $app->useStoragePath($_ENV['APP_STORAGE_PATH']); } -/* -|-------------------------------------------------------------------------- -| Bind Important Interfaces -|-------------------------------------------------------------------------- -| -| Next, we need to bind some important interfaces into the container so -| we will be able to resolve them when needed. The kernels serve the -| incoming requests to this application from both the web and CLI. -| -*/ - -$app->singleton( - Illuminate\Contracts\Http\Kernel::class, - Pterodactyl\Http\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Console\Kernel::class, - Pterodactyl\Console\Kernel::class -); - -$app->singleton( - Illuminate\Contracts\Debug\ExceptionHandler::class, - Pterodactyl\Exceptions\Handler::class -); - -/* -|-------------------------------------------------------------------------- -| Return The Application -|-------------------------------------------------------------------------- -| -| This script returns the application instance. The instance is given to -| the calling script so we can separate the building of the instances -| from the actual running of the application and sending responses. -| -*/ - return $app; diff --git a/bootstrap/providers.php b/bootstrap/providers.php new file mode 100644 index 000000000..245c509d9 --- /dev/null +++ b/bootstrap/providers.php @@ -0,0 +1,17 @@ +make(Kernel::class); /* @@ -17,16 +17,12 @@ $kernel = $app->make(Kernel::class); */ $kernel->bootstrap(); -// Register the collision service provider so that errors during the test -// setup process are output nicely. -(new Provider())->register(); +$output = new ConsoleOutput; -$output = new ConsoleOutput(); - -$prefix = 'database.connections.' . config('database.default'); -if (!Str::contains(config("$prefix.database"), 'test')) { - $output->writeln(PHP_EOL . 'Cannot run test process against non-testing database.'); - $output->writeln(PHP_EOL . 'Environment is currently pointed at: "' . config("$prefix.database") . '".'); +$prefix = 'database.connections.'.config('database.default'); +if (! Str::contains(config("$prefix.database"), 'test')) { + $output->writeln(PHP_EOL.'Cannot run test process against non-testing database.'); + $output->writeln(PHP_EOL.'Environment is currently pointed at: "'.config("$prefix.database").'".'); exit(1); } @@ -34,12 +30,17 @@ if (!Str::contains(config("$prefix.database"), 'test')) { * Perform database migrations and reseeding before continuing with * running the tests. */ -if (!env('SKIP_MIGRATIONS')) { - $output->writeln(PHP_EOL . 'Refreshing database for Integration tests...'); +if (! env('SKIP_MIGRATIONS')) { + $output->writeln(PHP_EOL.'Refreshing database for Integration tests...'); $kernel->call('migrate:fresh'); - $output->writeln('Seeding database for Integration tests...' . PHP_EOL); + $output->writeln('Seeding database for Integration tests...'.PHP_EOL); $kernel->call('db:seed'); } else { - $output->writeln(PHP_EOL . 'Skipping database migrations...' . PHP_EOL); + $output->writeln(PHP_EOL.'Skipping database migrations...'.PHP_EOL); } + +// Pop the error and exception handlers the bootstrap-level application installed so +// PHPUnit starts from a clean handler baseline; each test boots its own application. +restore_error_handler(); +restore_exception_handler(); diff --git a/composer.json b/composer.json index b797fdc4c..5e82379e6 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ } ], "require": { - "php": "^8.2 || ^8.3", + "php": "^8.3", + "ext-intl": "*", "ext-json": "*", "ext-mbstring": "*", "ext-pdo": "*", @@ -25,50 +26,46 @@ "ext-posix": "*", "ext-zip": "*", "aws/aws-sdk-php": "^3.369", + "composer/semver": "^3.4", "guzzlehttp/guzzle": "^7.9.2", "hashids/hashids": "^5.0.2", - "laracasts/utilities": "~3.2.3", - "laravel/framework": "^11.31.0", - "laravel/helpers": "^1.8.0", + "knuckleswtf/scribe": "^5.11", + "laravel/framework": "^13.0", "laravel/sanctum": "^4.2.0", - "laravel/tinker": "^2.10.0", - "laravel/ui": "~4.5.2", + "laravel/tinker": "^3.0", "lcobucci/jwt": "^5.6.0", "league/flysystem-aws-s3-v3": "^3.30.1", "league/flysystem-memory": "^3.29.0", - "matriphe/iso-639": "~2.0", "phpseclib/phpseclib": "^3.0.47", "pragmarx/google2fa": "~8.0.3", "predis/predis": "^3.3.0", - "prologue/alerts": "^1.3.0", - "psr/cache": "^3.0.0", "s1lentium/iptools": "~1.2.0", "spatie/laravel-fractal": "^6.3.2", "spatie/laravel-query-builder": "^6.3.6", - "staudenmeir/belongs-to-through": "^2.16.0", "symfony/http-client": "^7.4.0", "symfony/mailgun-mailer": "^7.4.0", "symfony/postmark-mailer": "^7.4.0", - "symfony/yaml": "^7.4.0", - "webmozart/assert": "^1.11.0" + "symfony/yaml": "^7.4.0" }, "require-dev": { "barryvdh/laravel-ide-helper": "^3.6", + "driftingly/rector-laravel": "^2.6", "fakerphp/faker": "^1.24", - "friendsofphp/php-cs-fixer": "~3.64.0", - "itsgoingd/clockwork": "^5.3", "larastan/larastan": "^3.8", + "laravel/pint": "^1.29", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.5", - "phpstan/phpstan": "^2.1", - "phpstan/phpstan-webmozart-assert": "^2.0", - "phpunit/phpunit": "^10.5.62", - "spatie/laravel-ignition": "^2.9" + "pestphp/pest": "^4.0", + "pestphp/pest-plugin-laravel": "^4.0", + "pestphp/pest-plugin-type-coverage": "^4.0", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan-strict-rules": "^2.0", + "rector/rector": "^2.6", + "roave/security-advisories": "dev-latest", + "spaze/phpstan-disallowed-calls": "^4.14", + "symplify/phpstan-rules": "^14.10" }, "autoload": { - "files": [ - "app/helpers.php" - ], "psr-4": { "Pterodactyl\\": "app/", "Database\\Factories\\": "database/Factories/", @@ -77,12 +74,47 @@ }, "autoload-dev": { "psr-4": { - "Pterodactyl\\Tests\\": "tests/" - } + "Pterodactyl\\Tests\\": "tests/", + "Rules\\": "tools/phpstan/rules/src/", + "Rules\\Tests\\": "tools/phpstan/rules/tests/" + }, + "classmap": [ + "tools/phpstan/rules/tests/Rules/data/" + ] }, "scripts": { - "cs:fix": "php-cs-fixer fix", - "cs:check": "php-cs-fixer fix --dry-run --diff --verbose", + "lint": [ + "rector", + "pint --parallel --cache-file=.pint.cache app bootstrap/app.php bootstrap/tests.php config database routes tests" + ], + "test:lint": [ + "pint --test --parallel --cache-file=.pint.cache app bootstrap/app.php bootstrap/tests.php config database routes tests", + "rector --dry-run" + ], + "test:types": "phpstan analyse -c phpstan-rules.neon --memory-limit=2G", + "test:type-coverage": [ + "@putenv __PEST_PLUGIN_ENV=1", + "@php -d variables_order=EGPCS vendor/bin/pest --type-coverage --min=100" + ], + "test:unit": "@php -d memory_limit=2G vendor/bin/pest --bootstrap vendor/autoload.php tests/Unit", + "test:integration": "@php -d memory_limit=2G vendor/bin/pest tests/Integration", + "test": [ + "@test:type-coverage", + "@test:unit", + "@test:integration", + "@test:lint", + "@test:types" + ], + "docs:openapi": "@php artisan scribe:generate --force --no-upgrade-check", + "docs:openapi:test": "@php vendor/bin/pest --bootstrap vendor/autoload.php tests/Architecture/OpenApiContractTest.php", + "docs:openapi:responses": [ + "@putenv OPENAPI_VALIDATE=1", + "@php -d memory_limit=2G vendor/bin/pest --testsuite Integration" + ], + "docs:openapi:verify": [ + "@docs:openapi", + "@docs:openapi:test" + ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi || true" @@ -104,9 +136,22 @@ "preferred-install": "dist", "sort-packages": true, "platform": { - "php": "8.2.0" + "php": "8.3.0" + }, + "allow-plugins": { + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true } }, "minimum-stability": "stable", - "prefer-stable": true + "prefer-stable": true, + "extra": { + "phpstan/extension-installer": { + "ignore": [ + "phpstan/phpstan-strict-rules", + "spaze/phpstan-disallowed-calls", + "symplify/phpstan-rules" + ] + } + } } diff --git a/composer.lock b/composer.lock index 1d5f43165..22a256a45 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4040741d3196c70ae44e03a7cdfca6e4", + "content-hash": "76b13d29c1814ba270a94f2be184e4c9", "packages": [ { "name": "aws/aws-crt-php", @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.369.34", + "version": "3.394.1", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "5db21cd0e5c8a5b5344596649033acf861a5e117" + "reference": "577edcbe852e463a1a52c269917303f850359e4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/5db21cd0e5c8a5b5344596649033acf861a5e117", - "reference": "5db21cd0e5c8a5b5344596649033acf861a5e117", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/577edcbe852e463a1a52c269917303f850359e4e", + "reference": "577edcbe852e463a1a52c269917303f850359e4e", "shasum": "" }, "require": { @@ -79,10 +79,10 @@ "ext-json": "*", "ext-pcre": "*", "ext-simplexml": "*", - "guzzlehttp/guzzle": "^7.4.5", - "guzzlehttp/promises": "^2.0", - "guzzlehttp/psr7": "^2.4.5", - "mtdowling/jmespath.php": "^2.8.0", + "guzzlehttp/guzzle": "^7.8.2 || ^8.0", + "guzzlehttp/promises": "^2.0.3 || ^3.0", + "guzzlehttp/psr7": "^2.6.3 || ^3.0", + "mtdowling/jmespath.php": "^2.9.1", "php": ">=8.1", "psr/http-message": "^1.0 || ^2.0", "symfony/filesystem": "^v5.4.45 || ^v6.4.3 || ^v7.1.0 || ^v8.0.0" @@ -92,12 +92,12 @@ "aws/aws-php-sns-message-validator": "~1.0", "behat/behat": "~3.0", "composer/composer": "^2.7.8", - "dms/phpunit-arraysubset-asserts": "^0.4.0", + "dms/phpunit-arraysubset-asserts": "^v0.5.0", "doctrine/cache": "~1.4", "ext-dom": "*", "ext-openssl": "*", "ext-sockets": "*", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.0", "psr/cache": "^2.0 || ^3.0", "psr/simple-cache": "^2.0 || ^3.0", "sebastian/comparator": "^1.2.3 || ^4.0 || ^5.0", @@ -135,11 +135,11 @@ "authors": [ { "name": "Amazon Web Services", - "homepage": "http://aws.amazon.com" + "homepage": "https://aws.amazon.com" } ], "description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project", - "homepage": "http://aws.amazon.com/sdkforphp", + "homepage": "https://aws.amazon.com/sdk-for-php", "keywords": [ "amazon", "aws", @@ -153,29 +153,28 @@ "support": { "forum": "https://github.com/aws/aws-sdk-php/discussions", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.369.34" + "source": "https://github.com/aws/aws-sdk-php/tree/3.394.1" }, - "time": "2026-02-13T19:09:12+00:00" + "time": "2026-08-26T18:32:55+00:00" }, { "name": "brick/math", - "version": "0.14.1", + "version": "0.18.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "f05858549e5f9d7bb45875a75583240a38a281d0" + "reference": "82944324d1c1bdb2c2618e89978d4e2ad78d69ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/f05858549e5f9d7bb45875a75583240a38a281d0", - "reference": "f05858549e5f9d7bb45875a75583240a38a281d0", + "url": "https://api.github.com/repos/brick/math/zipball/82944324d1c1bdb2c2618e89978d4e2ad78d69ad", + "reference": "82944324d1c1bdb2c2618e89978d4e2ad78d69ad", "shasum": "" }, "require": { "php": "^8.2" }, "require-dev": { - "php-coveralls/php-coveralls": "^2.2", "phpstan/phpstan": "2.1.22", "phpunit/phpunit": "^11.5" }, @@ -207,7 +206,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.14.1" + "source": "https://github.com/brick/math/tree/0.18.0" }, "funding": [ { @@ -215,7 +214,7 @@ "type": "github" } ], - "time": "2025-11-24T14:40:29+00:00" + "time": "2026-06-14T18:21:03+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -286,6 +285,83 @@ ], "time": "2024-02-09T16:56:22+00:00" }, + { + "name": "composer/semver", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2025-08-20T19:15:30+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -659,6 +735,140 @@ ], "time": "2025-03-06T22:45:56+00:00" }, + { + "name": "fakerphp/faker", + "version": "v1.24.1", + "source": { + "type": "git", + "url": "https://github.com/FakerPHP/Faker.git", + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "psr/container": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "conflict": { + "fzaninotto/faker": "*" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "doctrine/persistence": "^1.3 || ^2.0", + "ext-intl": "*", + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^5.4.16" + }, + "suggest": { + "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", + "ext-curl": "Required by Faker\\Provider\\Image to download images.", + "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", + "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", + "ext-mbstring": "Required for multibyte Unicode string functionality." + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "support": { + "issues": "https://github.com/FakerPHP/Faker/issues", + "source": "https://github.com/FakerPHP/Faker/tree/v1.24.1" + }, + "time": "2024-11-21T13:46:39+00:00" + }, + { + "name": "filp/whoops", + "version": "2.18.4", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d", + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "psr/log": "^1.0.1 || ^2.0 || ^3.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^4.0 || ^5.0" + }, + "suggest": { + "symfony/var-dumper": "Pretty print complex values better with var-dumper available", + "whoops/soap": "Formats errors as SOAP responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Whoops\\": "src/Whoops/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://filp.github.io/whoops/", + "keywords": [ + "error", + "exception", + "handling", + "library", + "throwable", + "whoops" + ], + "support": { + "issues": "https://github.com/filp/whoops/issues", + "source": "https://github.com/filp/whoops/tree/2.18.4" + }, + "funding": [ + { + "url": "https://github.com/denis-sokolov", + "type": "github" + } + ], + "time": "2025-08-08T12:00:00+00:00" + }, { "name": "fruitcake/php-cors", "version": "v1.4.0", @@ -732,24 +942,24 @@ }, { "name": "graham-campbell/result-type", - "version": "v1.1.3", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945" + "reference": "adccca3324eece92ca35463648c12b9e6293c05b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/adccca3324eece92ca35463648c12b9e6293c05b", + "reference": "adccca3324eece92ca35463648c12b9e6293c05b", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3" + "phpoption/phpoption": "^1.10" }, "require-dev": { - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + "phpunit/phpunit": "^8.5.52 || ^9.6.34 || ^10.5.63 || ^11.5.55 || ^12.5.14" }, "type": "library", "autoload": { @@ -778,7 +988,7 @@ ], "support": { "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3" + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.2.0" }, "funding": [ { @@ -790,29 +1000,30 @@ "type": "tidelift" } ], - "time": "2024-07-20T21:45:45+00:00" + "time": "2026-08-24T09:06:52+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "7.10.0", + "version": "7.15.5", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4" + "reference": "ee80339fd9177ba44c49cdb653ff02a4d1106b9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", - "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee80339fd9177ba44c49cdb653ff02a4d1106b9a", + "reference": "ee80339fd9177ba44c49cdb653ff02a4d1106b9a", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^2.3", - "guzzlehttp/psr7": "^2.8", + "guzzlehttp/promises": "^2.5.3", + "guzzlehttp/psr7": "^2.13.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/polyfill-php80": "^1.25" }, "provide": { "psr/http-client-implementation": "1.0" @@ -820,9 +1031,10 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", - "guzzle/client-integration-tests": "3.0.2", + "guzzle/client-integration-tests": "3.0.3", + "guzzlehttp/test-server": "^0.7", "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "phpunit/phpunit": "^8.5.52 || ^9.6.34", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -900,7 +1112,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.10.0" + "source": "https://github.com/guzzle/guzzle/tree/7.15.5" }, "funding": [ { @@ -916,28 +1128,29 @@ "type": "tidelift" } ], - "time": "2025-08-23T22:36:01+00:00" + "time": "2026-08-24T09:21:06+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.3.0", + "version": "2.5.3", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "481557b130ef3790cf82b713667b43030dc9c957" + "reference": "cde49999552d185d64715fe9c1f77a2aadd2f9f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957", - "reference": "481557b130ef3790cf82b713667b43030dc9c957", + "url": "https://api.github.com/repos/guzzle/promises/zipball/cde49999552d185d64715fe9c1f77a2aadd2f9f1", + "reference": "cde49999552d185d64715fe9c1f77a2aadd2f9f1", "shasum": "" }, "require": { - "php": "^7.2.5 || ^8.0" + "php": "^7.2.5 || ^8.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.44 || ^9.6.25" + "phpunit/phpunit": "^8.5.52 || ^9.6.34" }, "type": "library", "extra": { @@ -983,7 +1196,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.3.0" + "source": "https://github.com/guzzle/promises/tree/2.5.3" }, "funding": [ { @@ -999,27 +1212,29 @@ "type": "tidelift" } ], - "time": "2025-08-22T14:34:08+00:00" + "time": "2026-08-24T09:11:28+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.8.0", + "version": "2.13.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "21dc724a0583619cd1652f673303492272778051" + "reference": "95e7828100de18b4e269fb1703be530082d5166d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051", - "reference": "21dc724a0583619cd1652f673303492272778051", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/95e7828100de18b4e269fb1703be530082d5166d", + "reference": "95e7828100de18b4e269fb1703be530082d5166d", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" + "ralouphie/getallheaders": "^3.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/polyfill-php80": "^1.25" }, "provide": { "psr/http-factory-implementation": "1.0", @@ -1027,8 +1242,9 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "0.9.0", - "phpunit/phpunit": "^8.5.44 || ^9.6.25" + "http-interop/http-factory-tests": "1.1.0", + "jshttp/mime-db": "1.54.0.1", + "phpunit/phpunit": "^8.5.52 || ^9.6.34" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -1099,7 +1315,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.8.0" + "source": "https://github.com/guzzle/psr7/tree/2.13.1" }, "funding": [ { @@ -1115,30 +1331,30 @@ "type": "tidelift" } ], - "time": "2025-08-23T21:21:41+00:00" + "time": "2026-08-24T09:13:11+00:00" }, { "name": "guzzlehttp/uri-template", - "version": "v1.0.5", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/guzzle/uri-template.git", - "reference": "4f4bbd4e7172148801e76e3decc1e559bdee34e1" + "reference": "7a466ad606491eb6528c717482f7cca77f1851f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/uri-template/zipball/4f4bbd4e7172148801e76e3decc1e559bdee34e1", - "reference": "4f4bbd4e7172148801e76e3decc1e559bdee34e1", + "url": "https://api.github.com/repos/guzzle/uri-template/zipball/7a466ad606491eb6528c717482f7cca77f1851f3", + "reference": "7a466ad606491eb6528c717482f7cca77f1851f3", "shasum": "" }, "require": { - "php": "^7.2.5 || ^8.0", - "symfony/polyfill-php80": "^1.24" + "php": "^7.4 || ^8.0", + "symfony/polyfill-php80": "^1.25" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.44 || ^9.6.25", - "uri-template/tests": "1.0.0" + "phpunit/phpunit": "^9.6.34", + "uri-template/tests": "1.0.2" }, "type": "library", "extra": { @@ -1185,7 +1401,7 @@ ], "support": { "issues": "https://github.com/guzzle/uri-template/issues", - "source": "https://github.com/guzzle/uri-template/tree/v1.0.5" + "source": "https://github.com/guzzle/uri-template/tree/v2.0.1" }, "funding": [ { @@ -1201,7 +1417,7 @@ "type": "tidelift" } ], - "time": "2025-08-22T14:27:06+00:00" + "time": "2026-08-24T17:13:02+00:00" }, { "name": "hashids/hashids", @@ -1273,43 +1489,67 @@ "time": "2023-02-23T15:00:54+00:00" }, { - "name": "laracasts/utilities", - "version": "3.2.4", + "name": "knuckleswtf/scribe", + "version": "5.11.0", "source": { "type": "git", - "url": "https://github.com/laracasts/PHP-Vars-To-Js-Transformer.git", - "reference": "6bbd3a4c9602c2e44ee6e08d7f3fee62b6aa4146" + "url": "https://github.com/knuckleswtf/scribe.git", + "reference": "71c8c4acac495401ab8af1a68a46f09d45aff426" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laracasts/PHP-Vars-To-Js-Transformer/zipball/6bbd3a4c9602c2e44ee6e08d7f3fee62b6aa4146", - "reference": "6bbd3a4c9602c2e44ee6e08d7f3fee62b6aa4146", + "url": "https://api.github.com/repos/knuckleswtf/scribe/zipball/71c8c4acac495401ab8af1a68a46f09d45aff426", + "reference": "71c8c4acac495401ab8af1a68a46f09d45aff426", "shasum": "" }, "require": { - "illuminate/support": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "php": ">=5.5.0|>=7.2.5|>=8.0.0" + "ext-fileinfo": "*", + "ext-pdo": "*", + "fakerphp/faker": "^1.23.1", + "laravel/framework": "^9.21 || ^10.0 || ^11.0 || ^12.0 || ^13.0", + "league/flysystem": "^3.0", + "mpociot/reflection-docblock": "^1.0.1", + "nikic/php-parser": "^5.0", + "nunomaduro/collision": "^6.0 || ^7.0 || ^8.0", + "parsedown/parsedown": "^1.7", + "php": ">=8.1", + "ramsey/uuid": "^4.2.2", + "shalvah/upgrader": "^0.6.0", + "symfony/var-exporter": "^6.0 || ^7.0 || ^8.0", + "symfony/yaml": "^6.0 || ^7.0 || ^8.0" + }, + "replace": { + "mpociot/laravel-apidoc-generator": "*" }, "require-dev": { - "phpspec/phpspec": ">=2.0" + "dms/phpunit-arraysubset-asserts": "^0.5.0", + "laravel/legacy-factories": "^1.3.0", + "laravel/pint": "^1.20", + "league/fractal": "^0.20", + "nikic/fast-route": "^1.3", + "orchestra/testbench": "^7.0 || ^8.0 || ^9.10 || ^10.0 || ^11.0", + "pestphp/pest": "^1.21 || ^2.0 || ^3.0 || ^4.0", + "phpstan/phpstan": "^2.1.5", + "phpunit/phpunit": "^9.0 || ^10.0 || ^11.0 || ^12.0", + "spatie/ray": "^1.41", + "symfony/css-selector": "^6.0 || ^7.0 || ^8.0", + "symfony/dom-crawler": "^6.0 || ^7.0 || ^8.0" }, "type": "library", "extra": { "laravel": { - "aliases": { - "JavaScript": "Laracasts\\Utilities\\JavaScript\\JavaScriptFacade" - }, "providers": [ - "Laracasts\\Utilities\\JavaScript\\JavaScriptServiceProvider" + "Knuckles\\Scribe\\ScribeServiceProvider" ] } }, "autoload": { "files": [ - "src/helpers.php" + "src/Config/helpers.php" ], "psr-4": { - "Laracasts\\Utilities\\JavaScript\\": "src/" + "Knuckles\\Camel\\": "camel/", + "Knuckles\\Scribe\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1318,41 +1558,48 @@ ], "authors": [ { - "name": "Jeffrey Way", - "email": "jeffrey@laracasts.com" + "name": "Shalvah" } ], - "description": "Transform your PHP to JavaScript", + "description": "Generate API documentation for humans from your Laravel codebase.✍", + "homepage": "https://github.com/knuckleswtf/scribe", "keywords": [ - "javascript", + "api", + "documentation", "laravel" ], "support": { - "issues": "https://github.com/laracasts/PHP-Vars-To-Js-Transformer/issues", - "source": "https://github.com/laracasts/PHP-Vars-To-Js-Transformer/tree/3.2.4" + "issues": "https://github.com/knuckleswtf/scribe/issues", + "source": "https://github.com/knuckleswtf/scribe/tree/5.11.0" }, - "time": "2025-02-27T15:16:31+00:00" + "funding": [ + { + "url": "https://patreon.com/shalvah", + "type": "patreon" + } + ], + "time": "2026-06-08T15:39:10+00:00" }, { "name": "laravel/framework", - "version": "v11.47.0", + "version": "v13.29.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "86693ffa1ba32f56f8c44e31416c6665095a62c5" + "reference": "6e2c363716964d8238cee7097b258119a984f0cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/86693ffa1ba32f56f8c44e31416c6665095a62c5", - "reference": "86693ffa1ba32f56f8c44e31416c6665095a62c5", + "url": "https://api.github.com/repos/laravel/framework/zipball/6e2c363716964d8238cee7097b258119a984f0cf", + "reference": "6e2c363716964d8238cee7097b258119a984f0cf", "shasum": "" }, "require": { - "brick/math": "^0.9.3|^0.10.2|^0.11|^0.12|^0.13|^0.14", + "brick/math": "^0.14.2 || ^0.15 || ^0.16 || ^0.17 || ^0.18 || ^0.19", "composer-runtime-api": "^2.2", "doctrine/inflector": "^2.0.5", "dragonmantank/cron-expression": "^3.4", - "egulias/email-validator": "^3.2.1|^4.0", + "egulias/email-validator": "^4.0", "ext-ctype": "*", "ext-filter": "*", "ext-hash": "*", @@ -1361,34 +1608,39 @@ "ext-session": "*", "ext-tokenizer": "*", "fruitcake/php-cors": "^1.3", - "guzzlehttp/guzzle": "^7.8.2", - "guzzlehttp/uri-template": "^1.0", - "laravel/prompts": "^0.1.18|^0.2.0|^0.3.0", - "laravel/serializable-closure": "^1.3|^2.0", - "league/commonmark": "^2.7", + "guzzlehttp/guzzle": "^7.8.2 || ^8.0", + "guzzlehttp/promises": "^2.0.3 || ^3.0", + "guzzlehttp/psr7": "^2.9 || ^3.0", + "guzzlehttp/uri-template": "^1.0 || ^2.0", + "laravel/prompts": "^0.3.11", + "laravel/serializable-closure": "^2.0.10", + "league/commonmark": "^2.8.1", "league/flysystem": "^3.25.1", "league/flysystem-local": "^3.25.1", "league/uri": "^7.5.1", - "monolog/monolog": "^3.0", - "nesbot/carbon": "^2.72.6|^3.8.4", + "monolog/monolog": "^3.10", + "nesbot/carbon": "^3.8.4", "nunomaduro/termwind": "^2.0", - "php": "^8.2", - "psr/container": "^1.1.1|^2.0.1", - "psr/log": "^1.0|^2.0|^3.0", - "psr/simple-cache": "^1.0|^2.0|^3.0", + "php": "^8.3", + "psr/container": "^1.1.1 || ^2.0.1", + "psr/http-message": "^1.0 || ^2.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0", "ramsey/uuid": "^4.7", - "symfony/console": "^7.0.3", - "symfony/error-handler": "^7.0.3", - "symfony/finder": "^7.0.3", - "symfony/http-foundation": "^7.2.0", - "symfony/http-kernel": "^7.0.3", - "symfony/mailer": "^7.0.3", - "symfony/mime": "^7.0.3", - "symfony/polyfill-php83": "^1.31", - "symfony/process": "^7.0.3", - "symfony/routing": "^7.0.3", - "symfony/uid": "^7.0.3", - "symfony/var-dumper": "^7.0.3", + "symfony/console": "^7.4.0 || ^8.0.0", + "symfony/error-handler": "^7.4.0 || ^8.0.0", + "symfony/finder": "^7.4.0 || ^8.0.0", + "symfony/http-foundation": "^7.4.0 || ^8.0.0", + "symfony/http-kernel": "^7.4.0 || ^8.0.0", + "symfony/mailer": "^7.4.0 || ^8.0.0", + "symfony/mime": "^7.4.0 || ^8.0.0", + "symfony/polyfill-php84": "^1.36", + "symfony/polyfill-php85": "^1.36", + "symfony/polyfill-php86": "^1.36", + "symfony/process": "^7.4.5 || ^8.0.5", + "symfony/routing": "^7.4.0 || ^8.0.0", + "symfony/uid": "^7.4.0 || ^8.0.0", + "symfony/var-dumper": "^7.4.0 || ^8.0.0", "tijsverkoyen/css-to-inline-styles": "^2.2.5", "vlucas/phpdotenv": "^5.6.1", "voku/portable-ascii": "^2.0.2" @@ -1397,9 +1649,9 @@ "tightenco/collect": "<5.5.33" }, "provide": { - "psr/container-implementation": "1.1|2.0", - "psr/log-implementation": "1.0|2.0|3.0", - "psr/simple-cache-implementation": "1.0|2.0|3.0" + "psr/container-implementation": "1.1 || 2.0", + "psr/log-implementation": "1.0 || 2.0 || 3.0", + "psr/simple-cache-implementation": "1.0 || 2.0 || 3.0" }, "replace": { "illuminate/auth": "self.version", @@ -1420,6 +1672,8 @@ "illuminate/filesystem": "self.version", "illuminate/hashing": "self.version", "illuminate/http": "self.version", + "illuminate/image": "self.version", + "illuminate/json-schema": "self.version", "illuminate/log": "self.version", "illuminate/macroable": "self.version", "illuminate/mail": "self.version", @@ -1429,6 +1683,7 @@ "illuminate/process": "self.version", "illuminate/queue": "self.version", "illuminate/redis": "self.version", + "illuminate/reflection": "self.version", "illuminate/routing": "self.version", "illuminate/session": "self.version", "illuminate/support": "self.version", @@ -1443,8 +1698,7 @@ "aws/aws-sdk-php": "^3.322.9", "ext-gmp": "*", "fakerphp/faker": "^1.24", - "guzzlehttp/promises": "^2.0.3", - "guzzlehttp/psr7": "^2.4", + "intervention/image": "^4.0", "laravel/pint": "^1.18", "league/flysystem-aws-s3-v3": "^3.25.1", "league/flysystem-ftp": "^3.25.1", @@ -1452,22 +1706,24 @@ "league/flysystem-read-only": "^3.25.1", "league/flysystem-sftp-v3": "^3.25.1", "mockery/mockery": "^1.6.10", - "orchestra/testbench-core": "^9.16.1", - "pda/pheanstalk": "^5.0.6", + "opis/json-schema": "^2.4.1", + "orchestra/testbench-core": "^11.0.0", + "pda/pheanstalk": "^7.0.0 || ^8.0.0", "php-http/discovery": "^1.15", "phpstan/phpstan": "^2.0", - "phpunit/phpunit": "^10.5.35|^11.3.6|^12.0.1", - "predis/predis": "^2.3", - "resend/resend-php": "^0.10.0", - "symfony/cache": "^7.0.3", - "symfony/http-client": "^7.0.3", - "symfony/psr-http-message-bridge": "^7.0.3", - "symfony/translation": "^7.0.3" + "phpunit/phpunit": "^11.5.50 || ^12.5.8 || ^13.0.3", + "predis/predis": "^2.3 || ^3.0", + "rector/rector": "2.6.3", + "resend/resend-php": "^1.0", + "symfony/cache": "^7.4.0 || ^8.0.0", + "symfony/http-client": "^7.4.0 || ^8.0.0", + "symfony/psr-http-message-bridge": "^7.4.0 || ^8.0.0", + "symfony/translation": "^7.4.0 || ^8.0.0" }, "suggest": { "ably/ably-php": "Required to use the Ably broadcast driver (^1.0).", "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.322.9).", - "brianium/paratest": "Required to run tests in parallel (^7.0|^8.0).", + "brianium/paratest": "Required to run tests in parallel (^7.0 || ^8.0).", "ext-apcu": "Required to use the APC cache driver.", "ext-fileinfo": "Required to use the Filesystem class.", "ext-ftp": "Required to use the Flysystem FTP driver.", @@ -1476,9 +1732,10 @@ "ext-pcntl": "Required to use all features of the queue worker and console signal trapping.", "ext-pdo": "Required to use all database features.", "ext-posix": "Required to use all features of the queue worker.", - "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0|^6.0).", - "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", + "ext-redis": "Required to use the Redis cache and queue drivers (^4.0 || ^5.0 || ^6.0).", + "fakerphp/faker": "Required to generate fake data using the fake() helper (^1.23).", "filp/whoops": "Required for friendly error pages in development (^2.14.3).", + "intervention/image": "Required to use the image processing features (^4.0).", "laravel/tinker": "Required to use the tinker console command (^2.0).", "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^3.25.1).", "league/flysystem-ftp": "Required to use the Flysystem FTP driver (^3.25.1).", @@ -1486,24 +1743,24 @@ "league/flysystem-read-only": "Required to use read-only disks (^3.25.1)", "league/flysystem-sftp-v3": "Required to use the Flysystem SFTP driver (^3.25.1).", "mockery/mockery": "Required to use mocking (^1.6).", - "pda/pheanstalk": "Required to use the beanstalk queue driver (^5.0).", + "pda/pheanstalk": "Required to use the beanstalk queue driver (^7.0 || ^8.0).", "php-http/discovery": "Required to use PSR-7 bridging features (^1.15).", - "phpunit/phpunit": "Required to use assertions and run tests (^10.5.35|^11.3.6|^12.0.1).", - "predis/predis": "Required to use the predis connector (^2.3).", - "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", - "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0).", - "resend/resend-php": "Required to enable support for the Resend mail transport (^0.10.0).", - "symfony/cache": "Required to PSR-6 cache bridge (^7.0).", - "symfony/filesystem": "Required to enable support for relative symbolic links (^7.0).", - "symfony/http-client": "Required to enable support for the Symfony API mail transports (^7.0).", - "symfony/mailgun-mailer": "Required to enable support for the Mailgun mail transport (^7.0).", - "symfony/postmark-mailer": "Required to enable support for the Postmark mail transport (^7.0).", - "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^7.0)." + "phpunit/phpunit": "Required to use assertions and run tests (^11.5.50 || ^12.5.8 || ^13.0.3).", + "predis/predis": "Required to use the predis connector (^2.3 || ^3.0).", + "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0 || ^7.0).", + "resend/resend-php": "Required to enable support for the Resend mail transport (^0.10.0 || ^1.0).", + "spatie/fork": "Required to use the 'fork' concurrency driver (^1.2).", + "symfony/cache": "Required to PSR-6 cache bridge (^7.4 || ^8.0).", + "symfony/filesystem": "Required to enable support for relative symbolic links (^7.4 || ^8.0).", + "symfony/http-client": "Required to enable support for the Symfony API mail transports (^7.4 || ^8.0).", + "symfony/mailgun-mailer": "Required to enable support for the Mailgun mail transport (^7.4 || ^8.0).", + "symfony/postmark-mailer": "Required to enable support for the Postmark mail transport (^7.4 || ^8.0).", + "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^7.4 || ^8.0)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "11.x-dev" + "dev-master": "13.0.x-dev" } }, "autoload": { @@ -1514,6 +1771,7 @@ "src/Illuminate/Filesystem/functions.php", "src/Illuminate/Foundation/helpers.php", "src/Illuminate/Log/functions.php", + "src/Illuminate/Reflection/helpers.php", "src/Illuminate/Support/functions.php", "src/Illuminate/Support/helpers.php" ], @@ -1522,7 +1780,8 @@ "Illuminate\\Support\\": [ "src/Illuminate/Macroable/", "src/Illuminate/Collections/", - "src/Illuminate/Conditionable/" + "src/Illuminate/Conditionable/", + "src/Illuminate/Reflection/" ] } }, @@ -1546,91 +1805,34 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2025-11-28T18:20:11+00:00" - }, - { - "name": "laravel/helpers", - "version": "v1.8.2", - "source": { - "type": "git", - "url": "https://github.com/laravel/helpers.git", - "reference": "98499eea4c1cca76fb0fb37ed365a468773daf0a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/helpers/zipball/98499eea4c1cca76fb0fb37ed365a468773daf0a", - "reference": "98499eea4c1cca76fb0fb37ed365a468773daf0a", - "shasum": "" - }, - "require": { - "illuminate/support": "~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "php": "^7.2.0|^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^7.0|^8.0|^9.0|^10.0|^11.0|^12.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "files": [ - "src/helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - }, - { - "name": "Dries Vints", - "email": "dries@laravel.com" - } - ], - "description": "Provides backwards compatibility for helpers in the latest Laravel release.", - "keywords": [ - "helpers", - "laravel" - ], - "support": { - "source": "https://github.com/laravel/helpers/tree/v1.8.2" - }, - "time": "2025-11-25T14:46:28+00:00" + "time": "2026-08-25T20:57:16+00:00" }, { "name": "laravel/prompts", - "version": "v0.3.8", + "version": "v0.3.24", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "096748cdfb81988f60090bbb839ce3205ace0d35" + "reference": "5d3cdef29e93ca3b62b1871359db3078cd99908b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/096748cdfb81988f60090bbb839ce3205ace0d35", - "reference": "096748cdfb81988f60090bbb839ce3205ace0d35", + "url": "https://api.github.com/repos/laravel/prompts/zipball/5d3cdef29e93ca3b62b1871359db3078cd99908b", + "reference": "5d3cdef29e93ca3b62b1871359db3078cd99908b", "shasum": "" }, "require": { "composer-runtime-api": "^2.2", "ext-mbstring": "*", "php": "^8.1", - "symfony/console": "^6.2|^7.0" + "symfony/console": "^6.2|^7.0|^8.0" }, "conflict": { "illuminate/console": ">=10.17.0 <10.25.0", "laravel/framework": ">=10.17.0 <10.25.0" }, "require-dev": { - "illuminate/collections": "^10.0|^11.0|^12.0", + "illuminate/collections": "^10.0|^11.0|^12.0|^13.0", "mockery/mockery": "^1.5", "pestphp/pest": "^2.3|^3.4|^4.0", "phpstan/phpstan": "^1.12.28", @@ -1660,36 +1862,36 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.8" + "source": "https://github.com/laravel/prompts/tree/v0.3.24" }, - "time": "2025-11-21T20:52:52+00:00" + "time": "2026-08-20T12:55:36+00:00" }, { "name": "laravel/sanctum", - "version": "v4.2.1", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/laravel/sanctum.git", - "reference": "f5fb373be39a246c74a060f2cf2ae2c2145b3664" + "reference": "fee27a573d1a013af3721d86153a65e0b11927e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sanctum/zipball/f5fb373be39a246c74a060f2cf2ae2c2145b3664", - "reference": "f5fb373be39a246c74a060f2cf2ae2c2145b3664", + "url": "https://api.github.com/repos/laravel/sanctum/zipball/fee27a573d1a013af3721d86153a65e0b11927e6", + "reference": "fee27a573d1a013af3721d86153a65e0b11927e6", "shasum": "" }, "require": { "ext-json": "*", - "illuminate/console": "^11.0|^12.0", - "illuminate/contracts": "^11.0|^12.0", - "illuminate/database": "^11.0|^12.0", - "illuminate/support": "^11.0|^12.0", + "illuminate/console": "^11.0|^12.0|^13.0", + "illuminate/contracts": "^11.0|^12.0|^13.0", + "illuminate/database": "^11.0|^12.0|^13.0", + "illuminate/support": "^11.0|^12.0|^13.0", "php": "^8.2", - "symfony/console": "^7.0" + "symfony/console": "^7.0|^8.0" }, "require-dev": { "mockery/mockery": "^1.6", - "orchestra/testbench": "^9.15|^10.8", + "orchestra/testbench": "^9.15|^10.8|^11.0", "phpstan/phpstan": "^1.10" }, "type": "library", @@ -1725,31 +1927,31 @@ "issues": "https://github.com/laravel/sanctum/issues", "source": "https://github.com/laravel/sanctum" }, - "time": "2025-11-21T13:59:03+00:00" + "time": "2026-06-23T18:26:55+00:00" }, { "name": "laravel/serializable-closure", - "version": "v2.0.7", + "version": "v2.0.16", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "cb291e4c998ac50637c7eeb58189c14f5de5b9dd" + "reference": "7cfc24e4fa2cca045fb8dd2a797a2b2b13b655ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/cb291e4c998ac50637c7eeb58189c14f5de5b9dd", - "reference": "cb291e4c998ac50637c7eeb58189c14f5de5b9dd", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/7cfc24e4fa2cca045fb8dd2a797a2b2b13b655ed", + "reference": "7cfc24e4fa2cca045fb8dd2a797a2b2b13b655ed", "shasum": "" }, "require": { "php": "^8.1" }, "require-dev": { - "illuminate/support": "^10.0|^11.0|^12.0", + "illuminate/support": "^10.0|^11.0|^12.0|^13.0", "nesbot/carbon": "^2.67|^3.0", "pestphp/pest": "^2.36|^3.0|^4.0", "phpstan/phpstan": "^2.0", - "symfony/var-dumper": "^6.2.0|^7.0.0" + "symfony/var-dumper": "^6.2.0|^7.0.0|^8.0.0" }, "type": "library", "extra": { @@ -1786,37 +1988,37 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2025-11-21T20:52:36+00:00" + "time": "2026-08-18T20:28:54+00:00" }, { "name": "laravel/tinker", - "version": "v2.10.2", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "3bcb5f62d6f837e0f093a601e26badafb127bd4c" + "reference": "4faba77764bd33411735936acdf30446d058c78b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/3bcb5f62d6f837e0f093a601e26badafb127bd4c", - "reference": "3bcb5f62d6f837e0f093a601e26badafb127bd4c", + "url": "https://api.github.com/repos/laravel/tinker/zipball/4faba77764bd33411735936acdf30446d058c78b", + "reference": "4faba77764bd33411735936acdf30446d058c78b", "shasum": "" }, "require": { - "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "php": "^7.2.5|^8.0", - "psy/psysh": "^0.11.1|^0.12.0", - "symfony/var-dumper": "^4.3.4|^5.0|^6.0|^7.0" + "illuminate/console": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", + "php": "^8.1", + "psy/psysh": "^0.12.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0|^8.0" }, "require-dev": { "mockery/mockery": "~1.3.3|^1.4.2", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^8.5.8|^9.3.3|^10.0" + "phpunit/phpunit": "^10.5|^11.5" }, "suggest": { - "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0)." + "illuminate/database": "The Illuminate Database package (^8.0|^9.0|^10.0|^11.0|^12.0|^13.0)." }, "type": "library", "extra": { @@ -1824,6 +2026,9 @@ "providers": [ "Laravel\\Tinker\\TinkerServiceProvider" ] + }, + "branch-alias": { + "dev-master": "3.x-dev" } }, "autoload": { @@ -1850,72 +2055,9 @@ ], "support": { "issues": "https://github.com/laravel/tinker/issues", - "source": "https://github.com/laravel/tinker/tree/v2.10.2" + "source": "https://github.com/laravel/tinker/tree/v3.0.2" }, - "time": "2025-11-20T16:29:12+00:00" - }, - { - "name": "laravel/ui", - "version": "v4.5.2", - "source": { - "type": "git", - "url": "https://github.com/laravel/ui.git", - "reference": "c75396f63268c95b053c8e4814eb70e0875e9628" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/ui/zipball/c75396f63268c95b053c8e4814eb70e0875e9628", - "reference": "c75396f63268c95b053c8e4814eb70e0875e9628", - "shasum": "" - }, - "require": { - "illuminate/console": "^9.21|^10.0|^11.0", - "illuminate/filesystem": "^9.21|^10.0|^11.0", - "illuminate/support": "^9.21|^10.0|^11.0", - "illuminate/validation": "^9.21|^10.0|^11.0", - "php": "^8.0", - "symfony/console": "^6.0|^7.0" - }, - "require-dev": { - "orchestra/testbench": "^7.35|^8.15|^9.0", - "phpunit/phpunit": "^9.3|^10.4|^11.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Laravel\\Ui\\UiServiceProvider" - ] - }, - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "Laravel\\Ui\\": "src/", - "Illuminate\\Foundation\\Auth\\": "auth-backend/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "Laravel UI utilities and presets.", - "keywords": [ - "laravel", - "ui" - ], - "support": { - "source": "https://github.com/laravel/ui/tree/v4.5.2" - }, - "time": "2024-05-08T18:07:10+00:00" + "time": "2026-03-17T14:54:13+00:00" }, { "name": "lcobucci/jwt", @@ -1992,16 +2134,16 @@ }, { "name": "league/commonmark", - "version": "2.8.0", + "version": "2.10.0", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "4efa10c1e56488e658d10adf7b7b7dcd19940bfb" + "reference": "d2d1aa8b35e072966c89bc0c66cf926e56767dc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/4efa10c1e56488e658d10adf7b7b7dcd19940bfb", - "reference": "4efa10c1e56488e658d10adf7b7b7dcd19940bfb", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d2d1aa8b35e072966c89bc0c66cf926e56767dc4", + "reference": "d2d1aa8b35e072966c89bc0c66cf926e56767dc4", "shasum": "" }, "require": { @@ -2023,12 +2165,12 @@ "github/gfm": "0.29.0", "michelf/php-markdown": "^1.4 || ^2.0", "nyholm/psr7": "^1.5", - "phpstan/phpstan": "^1.8.2", - "phpunit/phpunit": "^9.5.21 || ^10.5.9 || ^11.0.0", + "phpstan/phpstan": "^2.0.0", + "phpunit/phpunit": "^9.5.21 || ^10.5.9 || ^11.0.0 || ^12.0.0 || ^13.0.0", "scrutinizer/ocular": "^1.8.1", - "symfony/finder": "^5.3 | ^6.0 | ^7.0", - "symfony/process": "^5.4 | ^6.0 | ^7.0", - "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 | ^7.0", + "symfony/finder": "^5.3 | ^6.0 | ^7.0 || ^8.0", + "symfony/process": "^5.4 | ^6.0 | ^7.0 || ^8.0", + "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 | ^7.0 || ^8.0", "unleashedtech/php-coding-standard": "^3.1.1", "vimeo/psalm": "^4.24.0 || ^5.0.0 || ^6.0.0" }, @@ -2038,7 +2180,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.9-dev" + "dev-main": "2.11-dev" } }, "autoload": { @@ -2095,7 +2237,7 @@ "type": "tidelift" } ], - "time": "2025-11-26T21:48:24+00:00" + "time": "2026-08-11T16:06:25+00:00" }, { "name": "league/config", @@ -2181,16 +2323,16 @@ }, { "name": "league/flysystem", - "version": "3.30.2", + "version": "3.35.3", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "5966a8ba23e62bdb518dd9e0e665c2dbd4b5b277" + "reference": "5fc8404762179ae514678487b23494fd69b2309c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/5966a8ba23e62bdb518dd9e0e665c2dbd4b5b277", - "reference": "5966a8ba23e62bdb518dd9e0e665c2dbd4b5b277", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/5fc8404762179ae514678487b23494fd69b2309c", + "reference": "5fc8404762179ae514678487b23494fd69b2309c", "shasum": "" }, "require": { @@ -2258,26 +2400,26 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.30.2" + "source": "https://github.com/thephpleague/flysystem/tree/3.35.3" }, - "time": "2025-11-10T17:13:11+00:00" + "time": "2026-08-22T12:55:54+00:00" }, { "name": "league/flysystem-aws-s3-v3", - "version": "3.30.1", + "version": "3.35.3", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git", - "reference": "d286e896083bed3190574b8b088b557b59eb66f5" + "reference": "b03780cb97585ee7e48977f40ed599b33b751634" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/d286e896083bed3190574b8b088b557b59eb66f5", - "reference": "d286e896083bed3190574b8b088b557b59eb66f5", + "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/b03780cb97585ee7e48977f40ed599b33b751634", + "reference": "b03780cb97585ee7e48977f40ed599b33b751634", "shasum": "" }, "require": { - "aws/aws-sdk-php": "^3.295.10", + "aws/aws-sdk-php": "^3.371.5", "league/flysystem": "^3.10.0", "league/mime-type-detection": "^1.0.0", "php": "^8.0.2" @@ -2313,22 +2455,22 @@ "storage" ], "support": { - "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.30.1" + "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.35.3" }, - "time": "2025-10-20T15:27:33+00:00" + "time": "2026-08-08T16:19:23+00:00" }, { "name": "league/flysystem-local", - "version": "3.30.2", + "version": "3.35.3", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-local.git", - "reference": "ab4f9d0d672f601b102936aa728801dd1a11968d" + "reference": "a099b24dce160f3b2239043d13d47c4a1a214ea4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/ab4f9d0d672f601b102936aa728801dd1a11968d", - "reference": "ab4f9d0d672f601b102936aa728801dd1a11968d", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/a099b24dce160f3b2239043d13d47c4a1a214ea4", + "reference": "a099b24dce160f3b2239043d13d47c4a1a214ea4", "shasum": "" }, "require": { @@ -2362,22 +2504,22 @@ "local" ], "support": { - "source": "https://github.com/thephpleague/flysystem-local/tree/3.30.2" + "source": "https://github.com/thephpleague/flysystem-local/tree/3.35.3" }, - "time": "2025-11-10T11:23:37+00:00" + "time": "2026-08-12T13:29:21+00:00" }, { "name": "league/flysystem-memory", - "version": "3.29.0", + "version": "3.31.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-memory.git", - "reference": "219c79ad8b1d614a58ac17b775bfb3a6b7228126" + "reference": "b2d1700ed1215684e7276e55bcacf350e0e06ff9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-memory/zipball/219c79ad8b1d614a58ac17b775bfb3a6b7228126", - "reference": "219c79ad8b1d614a58ac17b775bfb3a6b7228126", + "url": "https://api.github.com/repos/thephpleague/flysystem-memory/zipball/b2d1700ed1215684e7276e55bcacf350e0e06ff9", + "reference": "b2d1700ed1215684e7276e55bcacf350e0e06ff9", "shasum": "" }, "require": { @@ -2410,9 +2552,9 @@ "memory" ], "support": { - "source": "https://github.com/thephpleague/flysystem-memory/tree/3.29.0" + "source": "https://github.com/thephpleague/flysystem-memory/tree/3.31.0" }, - "time": "2024-08-09T21:24:39+00:00" + "time": "2026-01-23T15:30:45+00:00" }, { "name": "league/fractal", @@ -2486,16 +2628,16 @@ }, { "name": "league/mime-type-detection", - "version": "1.16.0", + "version": "1.17.0", "source": { "type": "git", "url": "https://github.com/thephpleague/mime-type-detection.git", - "reference": "2d6702ff215bf922936ccc1ad31007edc76451b9" + "reference": "f5f47eff7c48ed1003069a2ca67f316fb4021c76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/2d6702ff215bf922936ccc1ad31007edc76451b9", - "reference": "2d6702ff215bf922936ccc1ad31007edc76451b9", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/f5f47eff7c48ed1003069a2ca67f316fb4021c76", + "reference": "f5f47eff7c48ed1003069a2ca67f316fb4021c76", "shasum": "" }, "require": { @@ -2505,7 +2647,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", "phpstan/phpstan": "^0.12.68", - "phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0" + "phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0 || ^11.0 || ^12.0" }, "type": "library", "autoload": { @@ -2526,7 +2668,7 @@ "description": "Mime-type detection for Flysystem", "support": { "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.16.0" + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.17.0" }, "funding": [ { @@ -2538,24 +2680,24 @@ "type": "tidelift" } ], - "time": "2024-09-21T08:32:55+00:00" + "time": "2026-07-09T11:49:27+00:00" }, { "name": "league/uri", - "version": "7.6.0", + "version": "7.8.1", "source": { "type": "git", "url": "https://github.com/thephpleague/uri.git", - "reference": "f625804987a0a9112d954f9209d91fec52182344" + "reference": "08cf38e3924d4f56238125547b5720496fac8fd4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/f625804987a0a9112d954f9209d91fec52182344", - "reference": "f625804987a0a9112d954f9209d91fec52182344", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/08cf38e3924d4f56238125547b5720496fac8fd4", + "reference": "08cf38e3924d4f56238125547b5720496fac8fd4", "shasum": "" }, "require": { - "league/uri-interfaces": "^7.6", + "league/uri-interfaces": "^7.8.1", "php": "^8.1", "psr/http-factory": "^1" }, @@ -2569,11 +2711,11 @@ "ext-gmp": "to improve IPV4 host parsing", "ext-intl": "to handle IDN host with the best performance", "ext-uri": "to use the PHP native URI class", - "jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain", - "league/uri-components": "Needed to easily manipulate URI objects components", - "league/uri-polyfill": "Needed to backport the PHP URI extension for older versions of PHP", + "jeremykendall/php-domain-parser": "to further parse the URI host and resolve its Public Suffix and Top Level Domain", + "league/uri-components": "to provide additional tools to manipulate URI objects components", + "league/uri-polyfill": "to backport the PHP URI extension for older versions of PHP", "php-64bit": "to improve IPV4 host parsing", - "rowbot/url": "to handle WHATWG URL", + "rowbot/url": "to handle URLs using the WHATWG URL Living Standard specification", "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" }, "type": "library", @@ -2628,7 +2770,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri/tree/7.6.0" + "source": "https://github.com/thephpleague/uri/tree/7.8.1" }, "funding": [ { @@ -2636,20 +2778,20 @@ "type": "github" } ], - "time": "2025-11-18T12:17:23+00:00" + "time": "2026-03-15T20:22:25+00:00" }, { "name": "league/uri-interfaces", - "version": "7.6.0", + "version": "7.8.1", "source": { "type": "git", "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "ccbfb51c0445298e7e0b7f4481b942f589665368" + "reference": "85d5c77c5d6d3af6c54db4a78246364908f3c928" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/ccbfb51c0445298e7e0b7f4481b942f589665368", - "reference": "ccbfb51c0445298e7e0b7f4481b942f589665368", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/85d5c77c5d6d3af6c54db4a78246364908f3c928", + "reference": "85d5c77c5d6d3af6c54db4a78246364908f3c928", "shasum": "" }, "require": { @@ -2662,7 +2804,7 @@ "ext-gmp": "to improve IPV4 host parsing", "ext-intl": "to handle IDN host with the best performance", "php-64bit": "to improve IPV4 host parsing", - "rowbot/url": "to handle WHATWG URL", + "rowbot/url": "to handle URLs using the WHATWG URL Living Standard specification", "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" }, "type": "library", @@ -2712,7 +2854,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri-interfaces/tree/7.6.0" + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.8.1" }, "funding": [ { @@ -2720,76 +2862,20 @@ "type": "github" } ], - "time": "2025-11-18T12:17:23+00:00" - }, - { - "name": "matriphe/iso-639", - "version": "v2.0.10", - "source": { - "type": "git", - "url": "https://github.com/matriphe/php-iso-639.git", - "reference": "aa2ddce7eb9000570e6398bf52f114ebf9f0691a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/matriphe/php-iso-639/zipball/aa2ddce7eb9000570e6398bf52f114ebf9f0691a", - "reference": "aa2ddce7eb9000570e6398bf52f114ebf9f0691a", - "shasum": "" - }, - "require": { - "php": "8.*" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.75", - "phpunit/phpunit": ">=10" - }, - "suggest": { - "ext-mbstring": "For better multibyte character support in text transformations", - "ext-xdebug": "For code coverage when running tests" - }, - "type": "library", - "autoload": { - "psr-4": { - "Matriphe\\ISO639\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Muhammad Zamroni", - "email": "halo@matriphe.com" - } - ], - "description": "PHP library to convert ISO-639-1 code to language name.", - "keywords": [ - "639", - "iso", - "iso-639", - "lang", - "language", - "laravel" - ], - "support": { - "issues": "https://github.com/matriphe/php-iso-639/issues", - "source": "https://github.com/matriphe/php-iso-639/tree/v2.0.10" - }, - "time": "2025-10-05T21:40:44+00:00" + "time": "2026-03-08T20:05:35+00:00" }, { "name": "monolog/monolog", - "version": "3.9.0", + "version": "3.10.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "10d85740180ecba7896c87e06a166e0c95a0e3b6" + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/10d85740180ecba7896c87e06a166e0c95a0e3b6", - "reference": "10d85740180ecba7896c87e06a166e0c95a0e3b6", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/b321dd6749f0bf7189444158a3ce785cc16d69b0", + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0", "shasum": "" }, "require": { @@ -2807,7 +2893,7 @@ "graylog2/gelf-php": "^1.4.2 || ^2.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.2", - "mongodb/mongodb": "^1.8", + "mongodb/mongodb": "^1.8 || ^2.0", "php-amqplib/php-amqplib": "~2.4 || ^3", "php-console/php-console": "^3.1.8", "phpstan/phpstan": "^2", @@ -2867,7 +2953,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/3.9.0" + "source": "https://github.com/Seldaek/monolog/tree/3.10.0" }, "funding": [ { @@ -2879,20 +2965,73 @@ "type": "tidelift" } ], - "time": "2025-03-24T10:02:05+00:00" + "time": "2026-01-02T08:56:05+00:00" }, { - "name": "mtdowling/jmespath.php", - "version": "2.8.0", + "name": "mpociot/reflection-docblock", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/jmespath/jmespath.php.git", - "reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc" + "url": "https://github.com/mpociot/reflection-docblock.git", + "reference": "c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/a2a865e05d5f420b50cc2f85bb78d565db12a6bc", - "reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc", + "url": "https://api.github.com/repos/mpociot/reflection-docblock/zipball/c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587", + "reference": "c8b2e2b1f5cebbb06e2b5ccbf2958f2198867587", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mpociot": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "support": { + "issues": "https://github.com/mpociot/reflection-docblock/issues", + "source": "https://github.com/mpociot/reflection-docblock/tree/master" + }, + "time": "2016-06-20T20:53:12+00:00" + }, + { + "name": "mtdowling/jmespath.php", + "version": "2.9.2", + "source": { + "type": "git", + "url": "https://github.com/jmespath/jmespath.php.git", + "reference": "2157c5e50e813ec6a96c1eed3be7f64a20fb32a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/2157c5e50e813ec6a96c1eed3be7f64a20fb32a8", + "reference": "2157c5e50e813ec6a96c1eed3be7f64a20fb32a8", "shasum": "" }, "require": { @@ -2901,7 +3040,7 @@ }, "require-dev": { "composer/xdebug-handler": "^3.0.3", - "phpunit/phpunit": "^8.5.33" + "phpunit/phpunit": "^8.5.52" }, "bin": [ "bin/jp.php" @@ -2909,7 +3048,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "2.9-dev" } }, "autoload": { @@ -2943,22 +3082,22 @@ ], "support": { "issues": "https://github.com/jmespath/jmespath.php/issues", - "source": "https://github.com/jmespath/jmespath.php/tree/2.8.0" + "source": "https://github.com/jmespath/jmespath.php/tree/2.9.2" }, - "time": "2024-09-04T18:46:31+00:00" + "time": "2026-07-06T18:56:19+00:00" }, { "name": "nesbot/carbon", - "version": "3.11.0", + "version": "3.13.2", "source": { "type": "git", "url": "https://github.com/CarbonPHP/carbon.git", - "reference": "bdb375400dcd162624531666db4799b36b64e4a1" + "reference": "a1c54919f5fff9800cd03c32bd01defd5a4061cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/bdb375400dcd162624531666db4799b36b64e4a1", - "reference": "bdb375400dcd162624531666db4799b36b64e4a1", + "url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/a1c54919f5fff9800cd03c32bd01defd5a4061cb", + "reference": "a1c54919f5fff9800cd03c32bd01defd5a4061cb", "shasum": "" }, "require": { @@ -2982,7 +3121,7 @@ "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan": "^2.1.22", "phpunit/phpunit": "^10.5.53", - "squizlabs/php_codesniffer": "^3.13.4" + "squizlabs/php_codesniffer": "^3.13.4 || ^4.0.0" }, "bin": [ "bin/carbon" @@ -3025,14 +3164,14 @@ } ], "description": "An API extension for DateTime that supports 281 different languages.", - "homepage": "https://carbon.nesbot.com", + "homepage": "https://carbonphp.github.io/carbon/", "keywords": [ "date", "datetime", "time" ], "support": { - "docs": "https://carbon.nesbot.com/docs", + "docs": "https://carbonphp.github.io/carbon/guide/getting-started/introduction.html", "issues": "https://github.com/CarbonPHP/carbon/issues", "source": "https://github.com/CarbonPHP/carbon" }, @@ -3050,20 +3189,20 @@ "type": "tidelift" } ], - "time": "2025-12-02T21:04:28+00:00" + "time": "2026-08-08T11:40:35+00:00" }, { "name": "nette/schema", - "version": "v1.3.3", + "version": "v1.3.6", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "2befc2f42d7c715fd9d95efc31b1081e5d765004" + "reference": "c54350438cd6914616f790a49cb424605f421562" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/2befc2f42d7c715fd9d95efc31b1081e5d765004", - "reference": "2befc2f42d7c715fd9d95efc31b1081e5d765004", + "url": "https://api.github.com/repos/nette/schema/zipball/c54350438cd6914616f790a49cb424605f421562", + "reference": "c54350438cd6914616f790a49cb424605f421562", "shasum": "" }, "require": { @@ -3071,8 +3210,10 @@ "php": "8.1 - 8.5" }, "require-dev": { - "nette/tester": "^2.5.2", - "phpstan/phpstan-nette": "^2.0@stable", + "nette/phpstan-rules": "^1.0", + "nette/tester": "^2.6", + "phpstan/extension-installer": "^1.4@stable", + "phpstan/phpstan": "^2.1.39@stable", "tracy/tracy": "^2.8" }, "type": "library", @@ -3113,22 +3254,22 @@ ], "support": { "issues": "https://github.com/nette/schema/issues", - "source": "https://github.com/nette/schema/tree/v1.3.3" + "source": "https://github.com/nette/schema/tree/v1.3.6" }, - "time": "2025-10-30T22:57:59+00:00" + "time": "2026-08-16T21:58:41+00:00" }, { "name": "nette/utils", - "version": "v4.1.0", + "version": "v4.1.5", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "fa1f0b8261ed150447979eb22e373b7b7ad5a8e0" + "reference": "b043439dbdf954e6c28b5ea7e34b0100f83165e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/fa1f0b8261ed150447979eb22e373b7b7ad5a8e0", - "reference": "fa1f0b8261ed150447979eb22e373b7b7ad5a8e0", + "url": "https://api.github.com/repos/nette/utils/zipball/b043439dbdf954e6c28b5ea7e34b0100f83165e0", + "reference": "b043439dbdf954e6c28b5ea7e34b0100f83165e0", "shasum": "" }, "require": { @@ -3140,13 +3281,15 @@ }, "require-dev": { "jetbrains/phpstorm-attributes": "^1.2", + "nette/phpstan-rules": "^1.0", "nette/tester": "^2.5", - "phpstan/phpstan-nette": "^2.0@stable", + "phpstan/extension-installer": "^1.4@stable", + "phpstan/phpstan": "^2.1@stable", "tracy/tracy": "^2.9" }, "suggest": { "ext-gd": "to use Image", - "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()", + "ext-iconv": "to use Strings::chr(), ord() and reverse()", "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", @@ -3202,26 +3345,25 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.1.0" + "source": "https://github.com/nette/utils/tree/v4.1.5" }, - "time": "2025-12-01T17:49:23+00:00" + "time": "2026-07-17T23:02:45+00:00" }, { "name": "nikic/php-parser", - "version": "v5.6.2", + "version": "v5.8.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "3a454ca033b9e06b63282ce19562e892747449bb" + "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb", - "reference": "3a454ca033b9e06b63282ce19562e892747449bb", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/044a6a392ff8ad0d61f14370a5fbbd0a0107152f", + "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f", "shasum": "" }, "require": { - "ext-ctype": "*", "ext-json": "*", "ext-tokenizer": "*", "php": ">=7.4" @@ -3260,37 +3402,133 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.8.0" }, - "time": "2025-10-21T19:32:17+00:00" + "time": "2026-07-04T14:30:18+00:00" }, { - "name": "nunomaduro/termwind", - "version": "v2.3.3", + "name": "nunomaduro/collision", + "version": "v8.9.5", "source": { "type": "git", - "url": "https://github.com/nunomaduro/termwind.git", - "reference": "6fb2a640ff502caace8e05fd7be3b503a7e1c017" + "url": "https://github.com/nunomaduro/collision.git", + "reference": "fb53eacd509a1d303858e2d20cfebf2d630254ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/6fb2a640ff502caace8e05fd7be3b503a7e1c017", - "reference": "6fb2a640ff502caace8e05fd7be3b503a7e1c017", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/fb53eacd509a1d303858e2d20cfebf2d630254ec", + "reference": "fb53eacd509a1d303858e2d20cfebf2d630254ec", + "shasum": "" + }, + "require": { + "filp/whoops": "^2.18.4", + "nunomaduro/termwind": "^2.4.0", + "php": "^8.2.0", + "symfony/console": "^7.4.14 || ^8.1.1" + }, + "conflict": { + "laravel/framework": "<11.48.0 || >=14.0.0", + "phpunit/phpunit": "<11.5.50 || >=14.0.0" + }, + "require-dev": { + "brianium/paratest": "^7.8.5", + "larastan/larastan": "^3.10.0", + "laravel/framework": "^11.48.0 || ^12.56.0 || ^13.20.0", + "laravel/pint": "^1.29.3", + "orchestra/testbench-core": "^9.12.0 || ^10.12.1 || ^11.3.5", + "pestphp/pest": "^3.8.5 || ^4.7.5 || ^5.0.0", + "sebastian/environment": "^7.2.1 || ^8.1.2 || ^9.3.2" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" + ] + }, + "branch-alias": { + "dev-8.x": "8.x-dev" + } + }, + "autoload": { + "files": [ + "./src/Adapters/Phpunit/Autoload.php" + ], + "psr-4": { + "NunoMaduro\\Collision\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Cli error handling for console/command-line PHP applications.", + "keywords": [ + "artisan", + "cli", + "command-line", + "console", + "dev", + "error", + "handling", + "laravel", + "laravel-zero", + "php", + "symfony" + ], + "support": { + "issues": "https://github.com/nunomaduro/collision/issues", + "source": "https://github.com/nunomaduro/collision" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2026-07-15T19:09:14+00:00" + }, + { + "name": "nunomaduro/termwind", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/termwind.git", + "reference": "712a31b768f5daea284c2169a7d227031001b9a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/712a31b768f5daea284c2169a7d227031001b9a8", + "reference": "712a31b768f5daea284c2169a7d227031001b9a8", "shasum": "" }, "require": { "ext-mbstring": "*", "php": "^8.2", - "symfony/console": "^7.3.6" + "symfony/console": "^7.4.4 || ^8.0.4" }, "require-dev": { - "illuminate/console": "^11.46.1", - "laravel/pint": "^1.25.1", + "illuminate/console": "^11.47.0", + "laravel/pint": "^1.27.1", "mockery/mockery": "^1.6.12", - "pestphp/pest": "^2.36.0 || ^3.8.4 || ^4.1.3", + "pestphp/pest": "^2.36.0 || ^3.8.4 || ^4.3.2", "phpstan/phpstan": "^1.12.32", "phpstan/phpstan-strict-rules": "^1.6.2", - "symfony/var-dumper": "^7.3.5", + "symfony/var-dumper": "^7.3.5 || ^8.0.4", "thecodingmachine/phpstan-strict-rules": "^1.0.0" }, "type": "library", @@ -3322,7 +3560,7 @@ "email": "enunomaduro@gmail.com" } ], - "description": "Its like Tailwind CSS, but for the console.", + "description": "It's like Tailwind CSS, but for the console.", "keywords": [ "cli", "console", @@ -3333,7 +3571,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v2.3.3" + "source": "https://github.com/nunomaduro/termwind/tree/v2.4.0" }, "funding": [ { @@ -3349,7 +3587,7 @@ "type": "github" } ], - "time": "2025-11-20T02:34:59+00:00" + "time": "2026-02-16T23:10:27+00:00" }, { "name": "paragonie/constant_time_encoding", @@ -3471,17 +3709,67 @@ "time": "2020-10-15T08:29:30+00:00" }, { - "name": "phpoption/phpoption", - "version": "1.9.4", + "name": "parsedown/parsedown", + "version": "1.8.0", "source": { "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d" + "url": "https://github.com/parsedown/parsedown.git", + "reference": "96baaad00f71ba04d76e45b4620f54d3beabd6f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d", - "reference": "638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d", + "url": "https://api.github.com/repos/parsedown/parsedown/zipball/96baaad00f71ba04d76e45b4620f54d3beabd6f7", + "reference": "96baaad00f71ba04d76e45b4620f54d3beabd6f7", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5|^8.5|^9.6" + }, + "type": "library", + "autoload": { + "psr-0": { + "Parsedown": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "description": "Parser for Markdown.", + "homepage": "http://parsedown.org", + "keywords": [ + "markdown", + "parser" + ], + "support": { + "issues": "https://github.com/parsedown/parsedown/issues", + "source": "https://github.com/parsedown/parsedown/tree/1.8.0" + }, + "time": "2026-02-16T11:41:01+00:00" + }, + { + "name": "phpoption/phpoption", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "67b192b6a42ec03944b972d6e633ddec78ad2c6d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/67b192b6a42ec03944b972d6e633ddec78ad2c6d", + "reference": "67b192b6a42ec03944b972d6e633ddec78ad2c6d", "shasum": "" }, "require": { @@ -3489,7 +3777,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.44 || ^9.6.25 || ^10.5.53 || ^11.5.34" + "phpunit/phpunit": "^8.5.54 || ^9.6.36 || ^10.5.64 || ^11.5.56 || ^12.5.33" }, "type": "library", "extra": { @@ -3531,7 +3819,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.4" + "source": "https://github.com/schmittjoh/php-option/tree/1.10.0" }, "funding": [ { @@ -3543,20 +3831,20 @@ "type": "tidelift" } ], - "time": "2025-08-21T11:53:16+00:00" + "time": "2026-08-24T00:54:40+00:00" }, { "name": "phpseclib/phpseclib", - "version": "3.0.47", + "version": "3.0.57", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d" + "reference": "d17e0ddaeaf6f22f7e007cbb437d78792fe2a0e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/9d6ca36a6c2dd434765b1071b2644a1c683b385d", - "reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d17e0ddaeaf6f22f7e007cbb437d78792fe2a0e4", + "reference": "d17e0ddaeaf6f22f7e007cbb437d78792fe2a0e4", "shasum": "" }, "require": { @@ -3637,7 +3925,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.47" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.57" }, "funding": [ { @@ -3653,7 +3941,7 @@ "type": "tidelift" } ], - "time": "2025-10-06T01:07:24+00:00" + "time": "2026-08-26T12:13:21+00:00" }, { "name": "pragmarx/google2fa", @@ -3709,16 +3997,16 @@ }, { "name": "predis/predis", - "version": "v3.3.0", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/predis/predis.git", - "reference": "153097374b39a2f737fe700ebcd725642526cdec" + "reference": "2ff20c08bb63697245ffee3f198d1673086c302d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/predis/predis/zipball/153097374b39a2f737fe700ebcd725642526cdec", - "reference": "153097374b39a2f737fe700ebcd725642526cdec", + "url": "https://api.github.com/repos/predis/predis/zipball/2ff20c08bb63697245ffee3f198d1673086c302d", + "reference": "2ff20c08bb63697245ffee3f198d1673086c302d", "shasum": "" }, "require": { @@ -3760,7 +4048,7 @@ ], "support": { "issues": "https://github.com/predis/predis/issues", - "source": "https://github.com/predis/predis/tree/v3.3.0" + "source": "https://github.com/predis/predis/tree/v3.6.0" }, "funding": [ { @@ -3768,125 +4056,7 @@ "type": "github" } ], - "time": "2025-11-24T17:48:50+00:00" - }, - { - "name": "prologue/alerts", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/prologuephp/alerts.git", - "reference": "0a73c65c70d4838a79cc927e8c966a00b2cefcfc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/prologuephp/alerts/zipball/0a73c65c70d4838a79cc927e8c966a00b2cefcfc", - "reference": "0a73c65c70d4838a79cc927e8c966a00b2cefcfc", - "shasum": "" - }, - "require": { - "illuminate/config": "~9|^10|^11.0|^12.0", - "illuminate/session": "~9|^10|^11.0|^12.0", - "illuminate/support": "~9|^10|^11.0|^12.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^9|^10.5" - }, - "type": "library", - "extra": { - "laravel": { - "aliases": { - "Alert": "Prologue\\Alerts\\Facades\\Alert" - }, - "providers": [ - "Prologue\\Alerts\\AlertsServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Prologue\\Alerts\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dries Vints", - "email": "dries.vints@gmail.com", - "homepage": "http://driesvints.com", - "role": "Creator" - }, - { - "name": "Cristian Tabacitu", - "email": "hello@tabacitu.ro", - "homepage": "http://tabacitu.ro", - "role": "Maintainer" - } - ], - "description": "Prologue Alerts is a package that handles global site messages.", - "keywords": [ - "alerts", - "laravel", - "messages" - ], - "support": { - "issues": "https://github.com/prologuephp/alerts/issues", - "source": "https://github.com/prologuephp/alerts/tree/1.3.0" - }, - "time": "2025-02-24T15:15:54+00:00" - }, - { - "name": "psr/cache", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/3.0.0" - }, - "time": "2021-02-03T23:26:27+00:00" + "time": "2026-08-14T23:07:56+00:00" }, { "name": "psr/clock", @@ -4302,16 +4472,16 @@ }, { "name": "psy/psysh", - "version": "v0.12.20", + "version": "v0.12.24", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "19678eb6b952a03b8a1d96ecee9edba518bb0373" + "reference": "ca0fdcf8a7617afa3adfdf1b5fef573dffb69ca1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/19678eb6b952a03b8a1d96ecee9edba518bb0373", - "reference": "19678eb6b952a03b8a1d96ecee9edba518bb0373", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/ca0fdcf8a7617afa3adfdf1b5fef573dffb69ca1", + "reference": "ca0fdcf8a7617afa3adfdf1b5fef573dffb69ca1", "shasum": "" }, "require": { @@ -4375,9 +4545,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.12.20" + "source": "https://github.com/bobthecow/psysh/tree/v0.12.24" }, - "time": "2026-02-11T15:05:28+00:00" + "time": "2026-06-29T15:41:09+00:00" }, { "name": "ralouphie/getallheaders", @@ -4501,20 +4671,20 @@ }, { "name": "ramsey/uuid", - "version": "4.9.1", + "version": "4.9.3", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440" + "reference": "1df15849d00943a67d677dc9cfd80795f038c9f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/81f941f6f729b1e3ceea61d9d014f8b6c6800440", - "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/1df15849d00943a67d677dc9cfd80795f038c9f8", + "reference": "1df15849d00943a67d677dc9cfd80795f038c9f8", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", + "brick/math": ">=0.8.16 <=0.18", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" }, @@ -4573,9 +4743,9 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.9.1" + "source": "https://github.com/ramsey/uuid/tree/4.9.3" }, - "time": "2025-09-04T20:59:21+00:00" + "time": "2026-06-18T03:57:49+00:00" }, { "name": "s1lentium/iptools", @@ -4633,17 +4803,75 @@ "time": "2022-08-17T14:28:59+00:00" }, { - "name": "spatie/fractalistic", - "version": "2.11.0", + "name": "shalvah/upgrader", + "version": "0.6.0", "source": { "type": "git", - "url": "https://github.com/spatie/fractalistic.git", - "reference": "046c535f30b31a9356fc034ce75e8ee74614ed4f" + "url": "https://github.com/shalvah/upgrader.git", + "reference": "d95ed17fe9f5e1ee7d47ad835595f1af080a867f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/fractalistic/zipball/046c535f30b31a9356fc034ce75e8ee74614ed4f", - "reference": "046c535f30b31a9356fc034ce75e8ee74614ed4f", + "url": "https://api.github.com/repos/shalvah/upgrader/zipball/d95ed17fe9f5e1ee7d47ad835595f1af080a867f", + "reference": "d95ed17fe9f5e1ee7d47ad835595f1af080a867f", + "shasum": "" + }, + "require": { + "illuminate/support": ">=8.0", + "nikic/php-parser": "^5.0", + "php": ">=8.0" + }, + "require-dev": { + "dms/phpunit-arraysubset-asserts": "^0.2.0", + "pestphp/pest": "^1.21", + "phpstan/phpstan": "^1.0", + "spatie/ray": "^1.33" + }, + "type": "library", + "autoload": { + "psr-4": { + "Shalvah\\Upgrader\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Shalvah", + "email": "hello@shalvah.me" + } + ], + "description": "Create automatic upgrades for your package.", + "homepage": "http://github.com/shalvah/upgrader", + "keywords": [ + "upgrade" + ], + "support": { + "issues": "https://github.com/shalvah/upgrader/issues", + "source": "https://github.com/shalvah/upgrader/tree/0.6.0" + }, + "funding": [ + { + "url": "https://patreon.com/shalvah", + "type": "patreon" + } + ], + "time": "2024-02-20T11:51:46+00:00" + }, + { + "name": "spatie/fractalistic", + "version": "2.11.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/fractalistic.git", + "reference": "85d6ff9a93f00d902e17924bb1475163b373c890" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/fractalistic/zipball/85d6ff9a93f00d902e17924bb1475163b373c890", + "reference": "85d6ff9a93f00d902e17924bb1475163b373c890", "shasum": "" }, "require": { @@ -4651,7 +4879,7 @@ "php": "^7.4|^8.0" }, "require-dev": { - "illuminate/pagination": "~5.3.0|~5.4.0|^9.0", + "illuminate/pagination": "~5.3.0|~5.4.0|^9.0|^13.0", "pestphp/pest": "^1.22", "phpunit/phpunit": "^9.0" }, @@ -4684,7 +4912,7 @@ ], "support": { "issues": "https://github.com/spatie/fractalistic/issues", - "source": "https://github.com/spatie/fractalistic/tree/2.11.0" + "source": "https://github.com/spatie/fractalistic/tree/2.11.1" }, "funding": [ { @@ -4692,25 +4920,25 @@ "type": "github" } ], - "time": "2025-01-27T09:52:33+00:00" + "time": "2026-02-21T21:10:25+00:00" }, { "name": "spatie/laravel-fractal", - "version": "6.3.2", + "version": "6.4.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-fractal.git", - "reference": "d078aa670233100e1309a0a7096c42f5b605ef29" + "reference": "d34114259233540dcb405e45dff863164fb426c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-fractal/zipball/d078aa670233100e1309a0a7096c42f5b605ef29", - "reference": "d078aa670233100e1309a0a7096c42f5b605ef29", + "url": "https://api.github.com/repos/spatie/laravel-fractal/zipball/d34114259233540dcb405e45dff863164fb426c5", + "reference": "d34114259233540dcb405e45dff863164fb426c5", "shasum": "" }, "require": { - "illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0", - "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", "league/fractal": "^0.20.1|^0.20", "nesbot/carbon": "^2.63|^3.0", "php": "^8.0", @@ -4719,8 +4947,8 @@ }, "require-dev": { "ext-json": "*", - "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", - "pestphp/pest": "^1.22|^2.34|^3.0" + "orchestra/testbench": "^7.0|^8.0|^9.2|^10.0|^11.0", + "pestphp/pest": "^1.22|^2.34|^3.0|^4.0" }, "type": "library", "extra": { @@ -4765,7 +4993,7 @@ "transform" ], "support": { - "source": "https://github.com/spatie/laravel-fractal/tree/6.3.2" + "source": "https://github.com/spatie/laravel-fractal/tree/6.4.0" }, "funding": [ { @@ -4773,33 +5001,33 @@ "type": "custom" } ], - "time": "2025-02-14T10:43:50+00:00" + "time": "2026-02-21T15:58:07+00:00" }, { "name": "spatie/laravel-package-tools", - "version": "1.92.7", + "version": "1.93.2", "source": { "type": "git", "url": "https://github.com/spatie/laravel-package-tools.git", - "reference": "f09a799850b1ed765103a4f0b4355006360c49a5" + "reference": "e927d5b5b05e9fecae098e559e51918aa608ad02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/f09a799850b1ed765103a4f0b4355006360c49a5", - "reference": "f09a799850b1ed765103a4f0b4355006360c49a5", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/e927d5b5b05e9fecae098e559e51918aa608ad02", + "reference": "e927d5b5b05e9fecae098e559e51918aa608ad02", "shasum": "" }, "require": { - "illuminate/contracts": "^9.28|^10.0|^11.0|^12.0", - "php": "^8.0" + "illuminate/contracts": "^10.0|^11.0|^12.0|^13.0", + "php": "^8.1" }, "require-dev": { "mockery/mockery": "^1.5", - "orchestra/testbench": "^7.7|^8.0|^9.0|^10.0", - "pestphp/pest": "^1.23|^2.1|^3.1", - "phpunit/php-code-coverage": "^9.0|^10.0|^11.0", - "phpunit/phpunit": "^9.5.24|^10.5|^11.5", - "spatie/pest-plugin-test-time": "^1.1|^2.2" + "orchestra/testbench": "^8.0|^9.2|^10.0|^11.0", + "pestphp/pest": "^2.1|^3.1|^4.0", + "phpunit/php-code-coverage": "^10.0|^11.0|^12.0", + "phpunit/phpunit": "^10.5|^11.5|^12.5", + "spatie/pest-plugin-test-time": "^2.2|^3.0" }, "type": "library", "autoload": { @@ -4826,7 +5054,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-package-tools/issues", - "source": "https://github.com/spatie/laravel-package-tools/tree/1.92.7" + "source": "https://github.com/spatie/laravel-package-tools/tree/1.93.2" }, "funding": [ { @@ -4834,26 +5062,26 @@ "type": "github" } ], - "time": "2025-07-17T15:46:43+00:00" + "time": "2026-08-26T09:13:25+00:00" }, { "name": "spatie/laravel-query-builder", - "version": "6.3.6", + "version": "6.4.4", "source": { "type": "git", "url": "https://github.com/spatie/laravel-query-builder.git", - "reference": "b9a5af31c79ae8fb79ae0aa8ba2b9e7180f39481" + "reference": "ab9c4c369fc913d6c020a0f6776f3c82f3e523fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-query-builder/zipball/b9a5af31c79ae8fb79ae0aa8ba2b9e7180f39481", - "reference": "b9a5af31c79ae8fb79ae0aa8ba2b9e7180f39481", + "url": "https://api.github.com/repos/spatie/laravel-query-builder/zipball/ab9c4c369fc913d6c020a0f6776f3c82f3e523fb", + "reference": "ab9c4c369fc913d6c020a0f6776f3c82f3e523fb", "shasum": "" }, "require": { - "illuminate/database": "^10.0|^11.0|^12.0", - "illuminate/http": "^10.0|^11.0|^12.0", - "illuminate/support": "^10.0|^11.0|^12.0", + "illuminate/database": "^10.0|^11.0|^12.0|^13.0", + "illuminate/http": "^10.0|^11.0|^12.0|^13.0", + "illuminate/support": "^10.0|^11.0|^12.0|^13.0", "php": "^8.2", "spatie/laravel-package-tools": "^1.11" }, @@ -4861,7 +5089,7 @@ "ext-json": "*", "larastan/larastan": "^2.7 || ^3.3", "mockery/mockery": "^1.4", - "orchestra/testbench": "^7.0|^8.0|^10.0", + "orchestra/testbench": "^7.0|^8.0|^10.0|^11.0", "pestphp/pest": "^2.0|^3.7|^4.0", "phpunit/phpunit": "^10.0|^11.5.3|^12.0", "spatie/invade": "^2.0" @@ -4908,87 +5136,20 @@ "type": "custom" } ], - "time": "2025-10-20T09:50:21+00:00" - }, - { - "name": "staudenmeir/belongs-to-through", - "version": "v2.16.4", - "source": { - "type": "git", - "url": "https://github.com/staudenmeir/belongs-to-through.git", - "reference": "451496e4272c11d87b404791acdd352c606f29c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/staudenmeir/belongs-to-through/zipball/451496e4272c11d87b404791acdd352c606f29c0", - "reference": "451496e4272c11d87b404791acdd352c606f29c0", - "shasum": "" - }, - "require": { - "illuminate/database": "^11.0", - "php": "^8.2" - }, - "require-dev": { - "barryvdh/laravel-ide-helper": "^3.0", - "larastan/larastan": "^3.0", - "laravel/framework": "^11.0", - "mockery/mockery": "^1.5.1", - "orchestra/testbench-core": "^9.5", - "phpunit/phpunit": "^11.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Staudenmeir\\BelongsToThrough\\IdeHelperServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Znck\\Eloquent\\": "src/", - "Staudenmeir\\BelongsToThrough\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rahul Kadyan", - "email": "hi@znck.me" - }, - { - "name": "Jonas Staudenmeir", - "email": "mail@jonas-staudenmeir.de" - } - ], - "description": "Laravel Eloquent BelongsToThrough relationships", - "support": { - "issues": "https://github.com/staudenmeir/belongs-to-through/issues", - "source": "https://github.com/staudenmeir/belongs-to-through/tree/v2.16.4" - }, - "funding": [ - { - "url": "https://paypal.me/JonasStaudenmeir", - "type": "custom" - } - ], - "time": "2025-02-20T19:20:43+00:00" + "time": "2026-03-08T13:45:05+00:00" }, { "name": "symfony/clock", - "version": "v7.4.0", + "version": "v7.4.8", "source": { "type": "git", "url": "https://github.com/symfony/clock.git", - "reference": "9169f24776edde469914c1e7a1442a50f7a4e110" + "reference": "674fa3b98e21531dd040e613479f5f6fa8f32111" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/clock/zipball/9169f24776edde469914c1e7a1442a50f7a4e110", - "reference": "9169f24776edde469914c1e7a1442a50f7a4e110", + "url": "https://api.github.com/repos/symfony/clock/zipball/674fa3b98e21531dd040e613479f5f6fa8f32111", + "reference": "674fa3b98e21531dd040e613479f5f6fa8f32111", "shasum": "" }, "require": { @@ -5033,7 +5194,7 @@ "time" ], "support": { - "source": "https://github.com/symfony/clock/tree/v7.4.0" + "source": "https://github.com/symfony/clock/tree/v7.4.8" }, "funding": [ { @@ -5053,20 +5214,20 @@ "type": "tidelift" } ], - "time": "2025-11-12T15:39:26+00:00" + "time": "2026-03-24T13:12:05+00:00" }, { "name": "symfony/console", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0bc0f45254b99c58d45a8fbf9fb955d46cbd1bb8" + "reference": "962e18f09ebe68a49039b4c82fc0ea4871824fca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0bc0f45254b99c58d45a8fbf9fb955d46cbd1bb8", - "reference": "0bc0f45254b99c58d45a8fbf9fb955d46cbd1bb8", + "url": "https://api.github.com/repos/symfony/console/zipball/962e18f09ebe68a49039b4c82fc0ea4871824fca", + "reference": "962e18f09ebe68a49039b4c82fc0ea4871824fca", "shasum": "" }, "require": { @@ -5131,7 +5292,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.4.0" + "source": "https://github.com/symfony/console/tree/v7.4.17" }, "funding": [ { @@ -5151,20 +5312,20 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2026-08-21T12:09:28+00:00" }, { "name": "symfony/css-selector", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "ab862f478513e7ca2fe9ec117a6f01a8da6e1135" + "reference": "e3822e1cb7013a0a99b3c578130458927ec4eb89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/ab862f478513e7ca2fe9ec117a6f01a8da6e1135", - "reference": "ab862f478513e7ca2fe9ec117a6f01a8da6e1135", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/e3822e1cb7013a0a99b3c578130458927ec4eb89", + "reference": "e3822e1cb7013a0a99b3c578130458927ec4eb89", "shasum": "" }, "require": { @@ -5200,7 +5361,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v7.4.0" + "source": "https://github.com/symfony/css-selector/tree/v7.4.17" }, "funding": [ { @@ -5220,20 +5381,20 @@ "type": "tidelift" } ], - "time": "2025-10-30T13:39:42+00:00" + "time": "2026-08-21T17:40:08+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.6.0", + "version": "v3.7.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" + "reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", - "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/f3202fa1b5097b0af062dc978b32ecf63404e31d", + "reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d", "shasum": "" }, "require": { @@ -5246,7 +5407,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.6-dev" + "dev-main": "3.7-dev" } }, "autoload": { @@ -5271,7 +5432,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.7.1" }, "funding": [ { @@ -5282,25 +5443,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-25T14:21:43+00:00" + "time": "2026-06-05T06:23:12+00:00" }, { "name": "symfony/error-handler", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "48be2b0653594eea32dcef130cca1c811dcf25c2" + "reference": "8373921e231e190a88e2ad526951bbaa791576fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/48be2b0653594eea32dcef130cca1c811dcf25c2", - "reference": "48be2b0653594eea32dcef130cca1c811dcf25c2", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/8373921e231e190a88e2ad526951bbaa791576fa", + "reference": "8373921e231e190a88e2ad526951bbaa791576fa", "shasum": "" }, "require": { @@ -5349,7 +5514,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v7.4.0" + "source": "https://github.com/symfony/error-handler/tree/v7.4.17" }, "funding": [ { @@ -5369,20 +5534,20 @@ "type": "tidelift" } ], - "time": "2025-11-05T14:29:59+00:00" + "time": "2026-08-21T17:40:08+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "9dddcddff1ef974ad87b3708e4b442dc38b2261d" + "reference": "d269974ee93c61d03620ffee358355bfdb471d66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9dddcddff1ef974ad87b3708e4b442dc38b2261d", - "reference": "9dddcddff1ef974ad87b3708e4b442dc38b2261d", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d269974ee93c61d03620ffee358355bfdb471d66", + "reference": "d269974ee93c61d03620ffee358355bfdb471d66", "shasum": "" }, "require": { @@ -5434,7 +5599,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v7.4.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v7.4.17" }, "funding": [ { @@ -5454,20 +5619,20 @@ "type": "tidelift" } ], - "time": "2025-10-28T09:38:46+00:00" + "time": "2026-08-21T17:40:08+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.6.0", + "version": "v3.7.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "59eb412e93815df44f05f342958efa9f46b1e586" + "reference": "c7de7a00ffb67842132da02ea92988a39ccd9f4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586", - "reference": "59eb412e93815df44f05f342958efa9f46b1e586", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c7de7a00ffb67842132da02ea92988a39ccd9f4e", + "reference": "c7de7a00ffb67842132da02ea92988a39ccd9f4e", "shasum": "" }, "require": { @@ -5481,7 +5646,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.6-dev" + "dev-main": "3.7-dev" } }, "autoload": { @@ -5514,7 +5679,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.6.0" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.7.1" }, "funding": [ { @@ -5525,25 +5690,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-25T14:21:43+00:00" + "time": "2026-06-05T06:23:12+00:00" }, { "name": "symfony/filesystem", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "d551b38811096d0be9c4691d406991b47c0c630a" + "reference": "ee7bc7bca4c7079b88e57d5000aeeb20df570c8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/d551b38811096d0be9c4691d406991b47c0c630a", - "reference": "d551b38811096d0be9c4691d406991b47c0c630a", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/ee7bc7bca4c7079b88e57d5000aeeb20df570c8d", + "reference": "ee7bc7bca4c7079b88e57d5000aeeb20df570c8d", "shasum": "" }, "require": { @@ -5580,7 +5749,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.4.0" + "source": "https://github.com/symfony/filesystem/tree/v7.4.17" }, "funding": [ { @@ -5600,20 +5769,20 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2026-08-21T12:09:28+00:00" }, { "name": "symfony/finder", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "340b9ed7320570f319028a2cbec46d40535e94bd" + "reference": "5ce28827081f6d1f0c32eaf3882750f19cb5bbe6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/340b9ed7320570f319028a2cbec46d40535e94bd", - "reference": "340b9ed7320570f319028a2cbec46d40535e94bd", + "url": "https://api.github.com/repos/symfony/finder/zipball/5ce28827081f6d1f0c32eaf3882750f19cb5bbe6", + "reference": "5ce28827081f6d1f0c32eaf3882750f19cb5bbe6", "shasum": "" }, "require": { @@ -5648,7 +5817,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.4.0" + "source": "https://github.com/symfony/finder/tree/v7.4.17" }, "funding": [ { @@ -5668,20 +5837,20 @@ "type": "tidelift" } ], - "time": "2025-11-05T05:42:40+00:00" + "time": "2026-08-21T12:09:28+00:00" }, { "name": "symfony/http-client", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "ee5e0e0139ab506f6063a230e631bed677c650a4" + "reference": "d0aca330a822fe40376cd04c335cb48a24743d0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/ee5e0e0139ab506f6063a230e631bed677c650a4", - "reference": "ee5e0e0139ab506f6063a230e631bed677c650a4", + "url": "https://api.github.com/repos/symfony/http-client/zipball/d0aca330a822fe40376cd04c335cb48a24743d0c", + "reference": "d0aca330a822fe40376cd04c335cb48a24743d0c", "shasum": "" }, "require": { @@ -5749,7 +5918,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.4.0" + "source": "https://github.com/symfony/http-client/tree/v7.4.17" }, "funding": [ { @@ -5769,20 +5938,20 @@ "type": "tidelift" } ], - "time": "2025-11-20T12:32:50+00:00" + "time": "2026-08-21T17:40:08+00:00" }, { "name": "symfony/http-client-contracts", - "version": "v3.6.0", + "version": "v3.7.1", "source": { "type": "git", "url": "https://github.com/symfony/http-client-contracts.git", - "reference": "75d7043853a42837e68111812f4d964b01e5101c" + "reference": "41fc42d276aeff21192465331ebbab7d83a743c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/75d7043853a42837e68111812f4d964b01e5101c", - "reference": "75d7043853a42837e68111812f4d964b01e5101c", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/41fc42d276aeff21192465331ebbab7d83a743c0", + "reference": "41fc42d276aeff21192465331ebbab7d83a743c0", "shasum": "" }, "require": { @@ -5795,7 +5964,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.6-dev" + "dev-main": "3.7-dev" } }, "autoload": { @@ -5831,7 +6000,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/http-client-contracts/tree/v3.6.0" + "source": "https://github.com/symfony/http-client-contracts/tree/v3.7.1" }, "funding": [ { @@ -5842,25 +6011,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-04-29T11:18:49+00:00" + "time": "2026-06-05T06:23:12+00:00" }, { "name": "symfony/http-foundation", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "769c1720b68e964b13b58529c17d4a385c62167b" + "reference": "2ebe78c083501dfb9509b31a7aedcae4d60a391f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/769c1720b68e964b13b58529c17d4a385c62167b", - "reference": "769c1720b68e964b13b58529c17d4a385c62167b", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/2ebe78c083501dfb9509b31a7aedcae4d60a391f", + "reference": "2ebe78c083501dfb9509b31a7aedcae4d60a391f", "shasum": "" }, "require": { @@ -5909,7 +6082,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v7.4.0" + "source": "https://github.com/symfony/http-foundation/tree/v7.4.17" }, "funding": [ { @@ -5929,20 +6102,20 @@ "type": "tidelift" } ], - "time": "2025-11-13T08:49:24+00:00" + "time": "2026-08-20T09:55:18+00:00" }, { "name": "symfony/http-kernel", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "7348193cd384495a755554382e4526f27c456085" + "reference": "aa160388d444210e3d01bbb4c5c53af4cd763df4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/7348193cd384495a755554382e4526f27c456085", - "reference": "7348193cd384495a755554382e4526f27c456085", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/aa160388d444210e3d01bbb4c5c53af4cd763df4", + "reference": "aa160388d444210e3d01bbb4c5c53af4cd763df4", "shasum": "" }, "require": { @@ -5984,7 +6157,7 @@ "symfony/config": "^6.4|^7.0|^8.0", "symfony/console": "^6.4|^7.0|^8.0", "symfony/css-selector": "^6.4|^7.0|^8.0", - "symfony/dependency-injection": "^6.4|^7.0|^8.0", + "symfony/dependency-injection": "^6.4.1|^7.0.1|^8.0", "symfony/dom-crawler": "^6.4|^7.0|^8.0", "symfony/expression-language": "^6.4|^7.0|^8.0", "symfony/finder": "^6.4|^7.0|^8.0", @@ -6000,7 +6173,7 @@ "symfony/validator": "^6.4|^7.0|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0", "symfony/var-exporter": "^6.4|^7.0|^8.0", - "twig/twig": "^3.12" + "twig/twig": "^3.12|^4.0" }, "type": "library", "autoload": { @@ -6028,7 +6201,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.4.0" + "source": "https://github.com/symfony/http-kernel/tree/v7.4.17" }, "funding": [ { @@ -6048,20 +6221,20 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:38:24+00:00" + "time": "2026-08-22T13:41:33+00:00" }, { "name": "symfony/mailer", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "a3d9eea8cfa467ece41f0f54ba28185d74bd53fd" + "reference": "b17c9bf3a551d5f635638a3b6c05f06c4dc87584" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/a3d9eea8cfa467ece41f0f54ba28185d74bd53fd", - "reference": "a3d9eea8cfa467ece41f0f54ba28185d74bd53fd", + "url": "https://api.github.com/repos/symfony/mailer/zipball/b17c9bf3a551d5f635638a3b6c05f06c4dc87584", + "reference": "b17c9bf3a551d5f635638a3b6c05f06c4dc87584", "shasum": "" }, "require": { @@ -6112,7 +6285,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v7.4.0" + "source": "https://github.com/symfony/mailer/tree/v7.4.17" }, "funding": [ { @@ -6132,20 +6305,20 @@ "type": "tidelift" } ], - "time": "2025-11-21T15:26:00+00:00" + "time": "2026-08-21T17:40:08+00:00" }, { "name": "symfony/mailgun-mailer", - "version": "v7.4.0", + "version": "v7.4.16", "source": { "type": "git", "url": "https://github.com/symfony/mailgun-mailer.git", - "reference": "ffbcdbf93ed0700f083a6307acfb8f78dd3f091b" + "reference": "b3a98d48ada684b176c7c1fe9b3e8b1004e2aebf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailgun-mailer/zipball/ffbcdbf93ed0700f083a6307acfb8f78dd3f091b", - "reference": "ffbcdbf93ed0700f083a6307acfb8f78dd3f091b", + "url": "https://api.github.com/repos/symfony/mailgun-mailer/zipball/b3a98d48ada684b176c7c1fe9b3e8b1004e2aebf", + "reference": "b3a98d48ada684b176c7c1fe9b3e8b1004e2aebf", "shasum": "" }, "require": { @@ -6185,7 +6358,7 @@ "description": "Symfony Mailgun Mailer Bridge", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailgun-mailer/tree/v7.4.0" + "source": "https://github.com/symfony/mailgun-mailer/tree/v7.4.16" }, "funding": [ { @@ -6205,20 +6378,20 @@ "type": "tidelift" } ], - "time": "2025-08-04T07:05:15+00:00" + "time": "2026-07-31T12:37:14+00:00" }, { "name": "symfony/mime", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "bdb02729471be5d047a3ac4a69068748f1a6be7a" + "reference": "bf328d82105831db3e409195db0540ff57f27c80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/bdb02729471be5d047a3ac4a69068748f1a6be7a", - "reference": "bdb02729471be5d047a3ac4a69068748f1a6be7a", + "url": "https://api.github.com/repos/symfony/mime/zipball/bf328d82105831db3e409195db0540ff57f27c80", + "reference": "bf328d82105831db3e409195db0540ff57f27c80", "shasum": "" }, "require": { @@ -6229,20 +6402,20 @@ }, "conflict": { "egulias/email-validator": "~3.0.0", - "phpdocumentor/reflection-docblock": "<3.2.2", - "phpdocumentor/type-resolver": "<1.4.0", + "phpdocumentor/reflection-docblock": "<5.2|>=7", + "phpdocumentor/type-resolver": "<1.5.1", "symfony/mailer": "<6.4", "symfony/serializer": "<6.4.3|>7.0,<7.0.3" }, "require-dev": { "egulias/email-validator": "^2.1.10|^3.1|^4", "league/html-to-markdown": "^5.0", - "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", + "phpdocumentor/reflection-docblock": "^5.2|^6.0", "symfony/dependency-injection": "^6.4|^7.0|^8.0", "symfony/process": "^6.4|^7.0|^8.0", "symfony/property-access": "^6.4|^7.0|^8.0", "symfony/property-info": "^6.4|^7.0|^8.0", - "symfony/serializer": "^6.4.3|^7.0.3|^8.0" + "symfony/serializer": "^6.4.44|^7.4.17|^8.1.5" }, "type": "library", "autoload": { @@ -6274,7 +6447,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v7.4.0" + "source": "https://github.com/symfony/mime/tree/v7.4.17" }, "funding": [ { @@ -6294,20 +6467,20 @@ "type": "tidelift" } ], - "time": "2025-11-16T10:14:42+00:00" + "time": "2026-08-22T09:04:42+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.33.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + "reference": "141046a8f9477948ff284fa65be2095baafb94f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/141046a8f9477948ff284fa65be2095baafb94f2", + "reference": "141046a8f9477948ff284fa65be2095baafb94f2", "shasum": "" }, "require": { @@ -6357,7 +6530,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.37.0" }, "funding": [ { @@ -6377,20 +6550,20 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2026-04-10T16:19:22+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.33.0", + "version": "v1.41.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70" + "reference": "bb899c1db0aa8127dc3afe8cda4a67eb24915f8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70", - "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/bb899c1db0aa8127dc3afe8cda4a67eb24915f8d", + "reference": "bb899c1db0aa8127dc3afe8cda4a67eb24915f8d", "shasum": "" }, "require": { @@ -6439,7 +6612,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.41.0" }, "funding": [ { @@ -6459,20 +6632,20 @@ "type": "tidelift" } ], - "time": "2025-06-27T09:58:17+00:00" + "time": "2026-07-28T08:25:59+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.33.0", + "version": "v1.42.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3" + "reference": "51b5ff5ba85452b31ec6f55490b08148612339d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/9614ac4d8061dc257ecc64cba1b140873dce8ad3", - "reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/51b5ff5ba85452b31ec6f55490b08148612339d9", + "reference": "51b5ff5ba85452b31ec6f55490b08148612339d9", "shasum": "" }, "require": { @@ -6526,7 +6699,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.42.0" }, "funding": [ { @@ -6546,20 +6719,20 @@ "type": "tidelift" } ], - "time": "2024-09-10T14:38:51+00:00" + "time": "2026-08-24T10:51:20+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.33.0", + "version": "v1.42.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "3833d7255cc303546435cb650316bff708a1c75c" + "reference": "aa20edea75bd9c48cfecc8360922e5a6e5c44502" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", - "reference": "3833d7255cc303546435cb650316bff708a1c75c", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/aa20edea75bd9c48cfecc8360922e5a6e5c44502", + "reference": "aa20edea75bd9c48cfecc8360922e5a6e5c44502", "shasum": "" }, "require": { @@ -6611,7 +6784,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.42.0" }, "funding": [ { @@ -6631,20 +6804,20 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2026-08-07T06:33:24+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.33.0", + "version": "v1.38.2", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", "shasum": "" }, "require": { @@ -6696,7 +6869,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.38.2" }, "funding": [ { @@ -6716,20 +6889,20 @@ "type": "tidelift" } ], - "time": "2024-12-23T08:48:59+00:00" + "time": "2026-05-27T06:59:30+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.33.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dfb55726c3a76ea3b6459fcfda1ec2d80a682411", + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411", "shasum": "" }, "require": { @@ -6780,7 +6953,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.37.0" }, "funding": [ { @@ -6800,20 +6973,20 @@ "type": "tidelift" } ], - "time": "2025-01-02T08:10:11+00:00" + "time": "2026-04-10T16:19:22+00:00" }, { "name": "symfony/polyfill-php83", - "version": "v1.33.0", + "version": "v1.41.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php83.git", - "reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5" + "reference": "5ea99087fb99c273a9b9236ed4c31e78b16103c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/17f6f9a6b1735c0f163024d959f700cfbc5155e5", - "reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5", + "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/5ea99087fb99c273a9b9236ed4c31e78b16103c6", + "reference": "5ea99087fb99c273a9b9236ed4c31e78b16103c6", "shasum": "" }, "require": { @@ -6860,7 +7033,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php83/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-php83/tree/v1.41.0" }, "funding": [ { @@ -6880,20 +7053,100 @@ "type": "tidelift" } ], - "time": "2025-07-08T02:45:35+00:00" + "time": "2026-07-01T12:47:55+00:00" }, { - "name": "symfony/polyfill-php85", - "version": "v1.33.0", + "name": "symfony/polyfill-php84", + "version": "v1.38.1", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php85.git", - "reference": "d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91" + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "f4e1dfaee5b74aba5964fe1fd4dfc7ba5e3085fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91", - "reference": "d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/f4e1dfaee5b74aba5964fe1fd4dfc7ba5e3085fa", + "reference": "f4e1dfaee5b74aba5964fe1fd4dfc7ba5e3085fa", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.38.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-05-26T12:51:13+00:00" + }, + { + "name": "symfony/polyfill-php85", + "version": "v1.41.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php85.git", + "reference": "255fab485aaa1006ed411040c42aecd7b5302d7a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/255fab485aaa1006ed411040c42aecd7b5302d7a", + "reference": "255fab485aaa1006ed411040c42aecd7b5302d7a", "shasum": "" }, "require": { @@ -6940,7 +7193,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php85/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-php85/tree/v1.41.0" }, "funding": [ { @@ -6960,20 +7213,100 @@ "type": "tidelift" } ], - "time": "2025-06-23T16:12:55+00:00" + "time": "2026-07-01T12:47:55+00:00" }, { - "name": "symfony/polyfill-uuid", - "version": "v1.33.0", + "name": "symfony/polyfill-php86", + "version": "v1.41.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-uuid.git", - "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2" + "url": "https://github.com/symfony/polyfill-php86.git", + "reference": "6bc356ed3d8dbfeea8f0de235e34d670704e880e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/21533be36c24be3f4b1669c4725c7d1d2bab4ae2", - "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2", + "url": "https://api.github.com/repos/symfony/polyfill-php86/zipball/6bc356ed3d8dbfeea8f0de235e34d670704e880e", + "reference": "6bc356ed3d8dbfeea8f0de235e34d670704e880e", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php86\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.6+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php86/tree/v1.41.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-07-02T13:42:24+00:00" + }, + { + "name": "symfony/polyfill-uuid", + "version": "v1.37.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-uuid.git", + "reference": "26dfec253c4cf3e51b541b52ddf7e42cb0908e94" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/26dfec253c4cf3e51b541b52ddf7e42cb0908e94", + "reference": "26dfec253c4cf3e51b541b52ddf7e42cb0908e94", "shasum": "" }, "require": { @@ -7023,7 +7356,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/polyfill-uuid/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.37.0" }, "funding": [ { @@ -7043,20 +7376,20 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2026-04-10T16:19:22+00:00" }, { "name": "symfony/postmark-mailer", - "version": "v7.4.0", + "version": "v7.4.13", "source": { "type": "git", "url": "https://github.com/symfony/postmark-mailer.git", - "reference": "67eab9e06ff2adf74152df2ac95a07cef48eb7c5" + "reference": "ffda8a32cfbef6cd33ed544e811eb992d6f62347" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/postmark-mailer/zipball/67eab9e06ff2adf74152df2ac95a07cef48eb7c5", - "reference": "67eab9e06ff2adf74152df2ac95a07cef48eb7c5", + "url": "https://api.github.com/repos/symfony/postmark-mailer/zipball/ffda8a32cfbef6cd33ed544e811eb992d6f62347", + "reference": "ffda8a32cfbef6cd33ed544e811eb992d6f62347", "shasum": "" }, "require": { @@ -7097,7 +7430,7 @@ "description": "Symfony Postmark Mailer Bridge", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/postmark-mailer/tree/v7.4.0" + "source": "https://github.com/symfony/postmark-mailer/tree/v7.4.13" }, "funding": [ { @@ -7117,20 +7450,20 @@ "type": "tidelift" } ], - "time": "2025-08-04T07:05:15+00:00" + "time": "2026-05-23T16:05:06+00:00" }, { "name": "symfony/process", - "version": "v7.4.5", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "608476f4604102976d687c483ac63a79ba18cc97" + "reference": "058d17fc284cce14efb2385783b55014a461b176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/608476f4604102976d687c483ac63a79ba18cc97", - "reference": "608476f4604102976d687c483ac63a79ba18cc97", + "url": "https://api.github.com/repos/symfony/process/zipball/058d17fc284cce14efb2385783b55014a461b176", + "reference": "058d17fc284cce14efb2385783b55014a461b176", "shasum": "" }, "require": { @@ -7162,7 +7495,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.4.5" + "source": "https://github.com/symfony/process/tree/v7.4.17" }, "funding": [ { @@ -7182,20 +7515,20 @@ "type": "tidelift" } ], - "time": "2026-01-26T15:07:59+00:00" + "time": "2026-08-21T17:40:08+00:00" }, { "name": "symfony/routing", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "4720254cb2644a0b876233d258a32bf017330db7" + "reference": "ddd558991e98f693ae6bf5063cc1b0362c6bbec3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/4720254cb2644a0b876233d258a32bf017330db7", - "reference": "4720254cb2644a0b876233d258a32bf017330db7", + "url": "https://api.github.com/repos/symfony/routing/zipball/ddd558991e98f693ae6bf5063cc1b0362c6bbec3", + "reference": "ddd558991e98f693ae6bf5063cc1b0362c6bbec3", "shasum": "" }, "require": { @@ -7247,7 +7580,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v7.4.0" + "source": "https://github.com/symfony/routing/tree/v7.4.17" }, "funding": [ { @@ -7267,20 +7600,20 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2026-08-17T13:12:36+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.6.1", + "version": "v3.7.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43" + "reference": "c0a284bab1ed8aa0417e3d69250ab437739563a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43", - "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/c0a284bab1ed8aa0417e3d69250ab437739563a0", + "reference": "c0a284bab1ed8aa0417e3d69250ab437739563a0", "shasum": "" }, "require": { @@ -7298,7 +7631,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.6-dev" + "dev-main": "3.7-dev" } }, "autoload": { @@ -7334,7 +7667,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.6.1" + "source": "https://github.com/symfony/service-contracts/tree/v3.7.1" }, "funding": [ { @@ -7354,20 +7687,20 @@ "type": "tidelift" } ], - "time": "2025-07-15T11:30:57+00:00" + "time": "2026-06-16T09:55:08+00:00" }, { "name": "symfony/string", - "version": "v7.4.0", + "version": "v7.4.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003" + "reference": "e394af32256bf9e7bf80849d95e589167c10097b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/d50e862cb0a0e0886f73ca1f31b865efbb795003", - "reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003", + "url": "https://api.github.com/repos/symfony/string/zipball/e394af32256bf9e7bf80849d95e589167c10097b", + "reference": "e394af32256bf9e7bf80849d95e589167c10097b", "shasum": "" }, "require": { @@ -7425,7 +7758,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.4.0" + "source": "https://github.com/symfony/string/tree/v7.4.15" }, "funding": [ { @@ -7445,20 +7778,20 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2026-07-28T07:33:02+00:00" }, { "name": "symfony/translation", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "2d01ca0da3f092f91eeedb46f24aa30d2fca8f68" + "reference": "2ee1e4a3b32a528a642babe041ff7c440b213b4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/2d01ca0da3f092f91eeedb46f24aa30d2fca8f68", - "reference": "2d01ca0da3f092f91eeedb46f24aa30d2fca8f68", + "url": "https://api.github.com/repos/symfony/translation/zipball/2ee1e4a3b32a528a642babe041ff7c440b213b4b", + "reference": "2ee1e4a3b32a528a642babe041ff7c440b213b4b", "shasum": "" }, "require": { @@ -7525,7 +7858,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v7.4.0" + "source": "https://github.com/symfony/translation/tree/v7.4.17" }, "funding": [ { @@ -7545,20 +7878,20 @@ "type": "tidelift" } ], - "time": "2025-11-27T13:27:24+00:00" + "time": "2026-08-21T17:40:08+00:00" }, { "name": "symfony/translation-contracts", - "version": "v3.6.1", + "version": "v3.7.1", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "65a8bc82080447fae78373aa10f8d13b38338977" + "reference": "ccb206b98faccc511ebae8e5fad50f2dc0b30621" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/65a8bc82080447fae78373aa10f8d13b38338977", - "reference": "65a8bc82080447fae78373aa10f8d13b38338977", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/ccb206b98faccc511ebae8e5fad50f2dc0b30621", + "reference": "ccb206b98faccc511ebae8e5fad50f2dc0b30621", "shasum": "" }, "require": { @@ -7571,7 +7904,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.6-dev" + "dev-main": "3.7-dev" } }, "autoload": { @@ -7607,7 +7940,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.6.1" + "source": "https://github.com/symfony/translation-contracts/tree/v3.7.1" }, "funding": [ { @@ -7627,20 +7960,20 @@ "type": "tidelift" } ], - "time": "2025-07-15T13:41:35+00:00" + "time": "2026-06-05T06:23:12+00:00" }, { "name": "symfony/uid", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/uid.git", - "reference": "2498e9f81b7baa206f44de583f2f48350b90142c" + "reference": "69d732355a139c6f8881337d28515aa01f12b8be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/uid/zipball/2498e9f81b7baa206f44de583f2f48350b90142c", - "reference": "2498e9f81b7baa206f44de583f2f48350b90142c", + "url": "https://api.github.com/repos/symfony/uid/zipball/69d732355a139c6f8881337d28515aa01f12b8be", + "reference": "69d732355a139c6f8881337d28515aa01f12b8be", "shasum": "" }, "require": { @@ -7685,7 +8018,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/uid/tree/v7.4.0" + "source": "https://github.com/symfony/uid/tree/v7.4.17" }, "funding": [ { @@ -7705,20 +8038,20 @@ "type": "tidelift" } ], - "time": "2025-09-25T11:02:55+00:00" + "time": "2026-08-11T07:38:58+00:00" }, { "name": "symfony/var-dumper", - "version": "v7.4.0", + "version": "v7.4.17", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "41fd6c4ae28c38b294b42af6db61446594a0dece" + "reference": "53712df8727da1744490202eeb9cb50d4b95419d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/41fd6c4ae28c38b294b42af6db61446594a0dece", - "reference": "41fd6c4ae28c38b294b42af6db61446594a0dece", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/53712df8727da1744490202eeb9cb50d4b95419d", + "reference": "53712df8727da1744490202eeb9cb50d4b95419d", "shasum": "" }, "require": { @@ -7734,7 +8067,7 @@ "symfony/http-kernel": "^6.4|^7.0|^8.0", "symfony/process": "^6.4|^7.0|^8.0", "symfony/uid": "^6.4|^7.0|^8.0", - "twig/twig": "^3.12" + "twig/twig": "^3.12|^4.0" }, "bin": [ "Resources/bin/var-dump-server" @@ -7772,7 +8105,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.4.0" + "source": "https://github.com/symfony/var-dumper/tree/v7.4.17" }, "funding": [ { @@ -7792,20 +8125,101 @@ "type": "tidelift" } ], - "time": "2025-10-27T20:36:44+00:00" + "time": "2026-08-21T12:09:28+00:00" }, { - "name": "symfony/yaml", - "version": "v7.4.0", + "name": "symfony/var-exporter", + "version": "v7.4.16", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "6c84a4b55aee4cd02034d1c528e83f69ddf63810" + "url": "https://github.com/symfony/var-exporter.git", + "reference": "ca31404415670aa3834809005b529df1b84f0790" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/6c84a4b55aee4cd02034d1c528e83f69ddf63810", - "reference": "6c84a4b55aee4cd02034d1c528e83f69ddf63810", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/ca31404415670aa3834809005b529df1b84f0790", + "reference": "ca31404415670aa3834809005b529df1b84f0790", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "require-dev": { + "symfony/property-access": "^6.4|^7.0|^8.0", + "symfony/serializer": "^6.4|^7.0|^8.0", + "symfony/var-dumper": "^6.4|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "lazy-loading", + "proxy", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v7.4.16" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-07-30T12:37:26+00:00" + }, + { + "name": "symfony/yaml", + "version": "v7.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "0b040d7b66ceb10b7bb24c8e6656257932693a12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/0b040d7b66ceb10b7bb24c8e6656257932693a12", + "reference": "0b040d7b66ceb10b7bb24c8e6656257932693a12", "shasum": "" }, "require": { @@ -7848,7 +8262,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.4.0" + "source": "https://github.com/symfony/yaml/tree/v7.4.17" }, "funding": [ { @@ -7868,27 +8282,27 @@ "type": "tidelift" } ], - "time": "2025-11-16T10:14:42+00:00" + "time": "2026-08-21T12:09:28+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", - "version": "v2.3.0", + "version": "v2.4.0", "source": { "type": "git", "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", - "reference": "0d72ac1c00084279c1816675284073c5a337c20d" + "reference": "f0292ccf0ec75843d65027214426b6b163b48b41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/0d72ac1c00084279c1816675284073c5a337c20d", - "reference": "0d72ac1c00084279c1816675284073c5a337c20d", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/f0292ccf0ec75843d65027214426b6b163b48b41", + "reference": "f0292ccf0ec75843d65027214426b6b163b48b41", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "php": "^7.4 || ^8.0", - "symfony/css-selector": "^5.4 || ^6.0 || ^7.0" + "symfony/css-selector": "^5.4 || ^6.0 || ^7.0 || ^8.0" }, "require-dev": { "phpstan/phpstan": "^2.0", @@ -7921,32 +8335,32 @@ "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", "support": { "issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues", - "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.3.0" + "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.4.0" }, - "time": "2024-12-21T16:25:41+00:00" + "time": "2025-12-02T11:56:42+00:00" }, { "name": "vlucas/phpdotenv", - "version": "v5.6.2", + "version": "v5.7.0", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af" + "reference": "301c07936b16d88628b126b01d082ba153cf4c40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/24ac4c74f91ee2c193fa1aaa5c249cb0822809af", - "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/301c07936b16d88628b126b01d082ba153cf4c40", + "reference": "301c07936b16d88628b126b01d082ba153cf4c40", "shasum": "" }, "require": { "ext-pcre": "*", - "graham-campbell/result-type": "^1.1.3", + "graham-campbell/result-type": "^1.2", "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3", - "symfony/polyfill-ctype": "^1.24", - "symfony/polyfill-mbstring": "^1.24", - "symfony/polyfill-php80": "^1.24" + "phpoption/phpoption": "^1.10", + "symfony/polyfill-ctype": "^1.26", + "symfony/polyfill-mbstring": "^1.26", + "symfony/polyfill-php80": "^1.26" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", @@ -7987,7 +8401,7 @@ "homepage": "https://github.com/vlucas" } ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "description": "Loads environment variables from `.env` to `$_ENV` and `$_SERVER` automagically, and optionally to `getenv()`.", "keywords": [ "dotenv", "env", @@ -7995,7 +8409,7 @@ ], "support": { "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.2" + "source": "https://github.com/vlucas/phpdotenv/tree/v5.7.0" }, "funding": [ { @@ -8007,27 +8421,27 @@ "type": "tidelift" } ], - "time": "2025-04-30T23:37:27+00:00" + "time": "2026-08-24T18:07:49+00:00" }, { "name": "voku/portable-ascii", - "version": "2.0.3", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/voku/portable-ascii.git", - "reference": "b1d923f88091c6bf09699efcd7c8a1b1bfd7351d" + "reference": "8e1051fe39379367aecf014f41744ce7539a856f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b1d923f88091c6bf09699efcd7c8a1b1bfd7351d", - "reference": "b1d923f88091c6bf09699efcd7c8a1b1bfd7351d", + "url": "https://api.github.com/repos/voku/portable-ascii/zipball/8e1051fe39379367aecf014f41744ce7539a856f", + "reference": "8e1051fe39379367aecf014f41744ce7539a856f", "shasum": "" }, "require": { - "php": ">=7.0.0" + "php": ">=7.1.0" }, "require-dev": { - "phpunit/phpunit": "~6.0 || ~7.0 || ~9.0" + "phpunit/phpunit": "~8.5 || ~9.6 || ~10.5 || ~11.5" }, "suggest": { "ext-intl": "Use Intl for transliterator_transliterate() support" @@ -8057,7 +8471,7 @@ ], "support": { "issues": "https://github.com/voku/portable-ascii/issues", - "source": "https://github.com/voku/portable-ascii/tree/2.0.3" + "source": "https://github.com/voku/portable-ascii/tree/2.1.1" }, "funding": [ { @@ -8081,102 +8495,45 @@ "type": "tidelift" } ], - "time": "2024-11-21T01:49:47+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.12.1", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "9be6926d8b485f55b9229203f962b51ed377ba68" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/9be6926d8b485f55b9229203f962b51ed377ba68", - "reference": "9be6926d8b485f55b9229203f962b51ed377ba68", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-date": "*", - "ext-filter": "*", - "php": "^7.2 || ^8.0" - }, - "suggest": { - "ext-intl": "", - "ext-simplexml": "", - "ext-spl": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.12.1" - }, - "time": "2025-10-29T15:56:20+00:00" + "time": "2026-04-26T05:33:54+00:00" } ], "packages-dev": [ { "name": "barryvdh/laravel-ide-helper", - "version": "v3.6.0", + "version": "v3.7.0", "source": { "type": "git", "url": "https://github.com/barryvdh/laravel-ide-helper.git", - "reference": "8d00250cba25728373e92c1d8dcebcbf64623d29" + "reference": "ad7e37676f1ff985d55ef1b6b96a0c0a40f2609a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/8d00250cba25728373e92c1d8dcebcbf64623d29", - "reference": "8d00250cba25728373e92c1d8dcebcbf64623d29", + "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/ad7e37676f1ff985d55ef1b6b96a0c0a40f2609a", + "reference": "ad7e37676f1ff985d55ef1b6b96a0c0a40f2609a", "shasum": "" }, "require": { "barryvdh/reflection-docblock": "^2.4", "composer/class-map-generator": "^1.0", "ext-json": "*", - "illuminate/console": "^11.15 || ^12", - "illuminate/database": "^11.15 || ^12", - "illuminate/filesystem": "^11.15 || ^12", - "illuminate/support": "^11.15 || ^12", + "illuminate/console": "^11.15 || ^12 || ^13.0", + "illuminate/database": "^11.15 || ^12 || ^13.0", + "illuminate/filesystem": "^11.15 || ^12 || ^13.0", + "illuminate/support": "^11.15 || ^12 || ^13.0", "php": "^8.2" }, "require-dev": { "ext-pdo_sqlite": "*", "friendsofphp/php-cs-fixer": "^3", - "illuminate/config": "^11.15 || ^12", - "illuminate/view": "^11.15 || ^12", + "illuminate/config": "^11.15 || ^12 || ^13.0", + "illuminate/view": "^11.15 || ^12 || ^13.0", + "larastan/larastan": "^3.1", "mockery/mockery": "^1.4", - "orchestra/testbench": "^9.2 || ^10", - "phpunit/phpunit": "^10.5 || ^11.5.3", + "orchestra/testbench": "^9.2 || ^10 || ^11.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.5 || ^11.5.3 || ^12.5.12", "spatie/phpunit-snapshot-assertions": "^4 || ^5", - "vimeo/psalm": "^5.4", "vlucas/phpdotenv": "^5" }, "suggest": { @@ -8190,7 +8547,7 @@ ] }, "branch-alias": { - "dev-master": "3.5-dev" + "dev-master": "3.6-dev" } }, "autoload": { @@ -8223,7 +8580,7 @@ ], "support": { "issues": "https://github.com/barryvdh/laravel-ide-helper/issues", - "source": "https://github.com/barryvdh/laravel-ide-helper/tree/v3.6.0" + "source": "https://github.com/barryvdh/laravel-ide-helper/tree/v3.7.0" }, "funding": [ { @@ -8235,20 +8592,20 @@ "type": "github" } ], - "time": "2025-07-17T20:11:57+00:00" + "time": "2026-03-17T14:12:51+00:00" }, { "name": "barryvdh/reflection-docblock", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/barryvdh/ReflectionDocBlock.git", - "reference": "d103774cbe7e94ddee7e4870f97f727b43fe7201" + "reference": "4f5ba70c30c81f2ce03a16a9965832cfcc31ed3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/ReflectionDocBlock/zipball/d103774cbe7e94ddee7e4870f97f727b43fe7201", - "reference": "d103774cbe7e94ddee7e4870f97f727b43fe7201", + "url": "https://api.github.com/repos/barryvdh/ReflectionDocBlock/zipball/4f5ba70c30c81f2ce03a16a9965832cfcc31ed3b", + "reference": "4f5ba70c30c81f2ce03a16a9965832cfcc31ed3b", "shasum": "" }, "require": { @@ -8285,36 +8642,61 @@ } ], "support": { - "source": "https://github.com/barryvdh/ReflectionDocBlock/tree/v2.4.0" + "source": "https://github.com/barryvdh/ReflectionDocBlock/tree/v2.4.1" }, - "time": "2025-07-17T06:07:30+00:00" + "time": "2026-03-05T20:09:01+00:00" }, { - "name": "clue/ndjson-react", - "version": "v1.3.0", + "name": "brianium/paratest", + "version": "v7.20.0", "source": { "type": "git", - "url": "https://github.com/clue/reactphp-ndjson.git", - "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" + "url": "https://github.com/paratestphp/paratest.git", + "reference": "81c80677c9ec0ed4ef16b246167f11dec81a6e3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", - "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/81c80677c9ec0ed4ef16b246167f11dec81a6e3d", + "reference": "81c80677c9ec0ed4ef16b246167f11dec81a6e3d", "shasum": "" }, "require": { - "php": ">=5.3", - "react/stream": "^1.2" + "ext-dom": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-simplexml": "*", + "fidry/cpu-core-counter": "^1.3.0", + "jean85/pretty-package-versions": "^2.1.1", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0", + "phpunit/php-code-coverage": "^12.5.3 || ^13.0.1", + "phpunit/php-file-iterator": "^6.0.1 || ^7", + "phpunit/php-timer": "^8 || ^9", + "phpunit/phpunit": "^12.5.14 || ^13.0.5", + "sebastian/environment": "^8.0.3 || ^9", + "symfony/console": "^7.4.7 || ^8.0.7", + "symfony/process": "^7.4.5 || ^8.0.5" }, "require-dev": { - "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", - "react/event-loop": "^1.2" + "doctrine/coding-standard": "^14.0.0", + "ext-pcntl": "*", + "ext-pcov": "*", + "ext-posix": "*", + "phpstan/phpstan": "^2.1.44", + "phpstan/phpstan-deprecation-rules": "^2.0.4", + "phpstan/phpstan-phpunit": "^2.0.16", + "phpstan/phpstan-strict-rules": "^2.0.10", + "symfony/filesystem": "^7.4.6 || ^8.0.6" }, + "bin": [ + "bin/paratest", + "bin/paratest_for_phpstorm" + ], "type": "library", "autoload": { "psr-4": { - "Clue\\React\\NDJson\\": "src/" + "ParaTest\\": [ + "src/" + ] } }, "notification-url": "https://packagist.org/downloads/", @@ -8323,48 +8705,52 @@ ], "authors": [ { - "name": "Christian Lück", - "email": "christian@clue.engineering" + "name": "Brian Scaturro", + "email": "scaturrob@gmail.com", + "role": "Developer" + }, + { + "name": "Filippo Tessarotto", + "email": "zoeslam@gmail.com", + "role": "Developer" } ], - "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", - "homepage": "https://github.com/clue/reactphp-ndjson", + "description": "Parallel testing for PHP", + "homepage": "https://github.com/paratestphp/paratest", "keywords": [ - "NDJSON", - "json", - "jsonlines", - "newline", - "reactphp", - "streaming" + "concurrent", + "parallel", + "phpunit", + "testing" ], "support": { - "issues": "https://github.com/clue/reactphp-ndjson/issues", - "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" + "issues": "https://github.com/paratestphp/paratest/issues", + "source": "https://github.com/paratestphp/paratest/tree/v7.20.0" }, "funding": [ { - "url": "https://clue.engineering/support", - "type": "custom" + "url": "https://github.com/sponsors/Slamdunk", + "type": "github" }, { - "url": "https://github.com/clue", - "type": "github" + "url": "https://paypal.me/filippotessarotto", + "type": "paypal" } ], - "time": "2022-12-23T10:58:28+00:00" + "time": "2026-03-29T15:46:14+00:00" }, { "name": "composer/class-map-generator", - "version": "1.7.0", + "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/composer/class-map-generator.git", - "reference": "2373419b7709815ed323ebf18c3c72d03ff4a8a6" + "reference": "86d8208fc3c649a3a999daf1a63c25201be2990f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/class-map-generator/zipball/2373419b7709815ed323ebf18c3c72d03ff4a8a6", - "reference": "2373419b7709815ed323ebf18c3c72d03ff4a8a6", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/86d8208fc3c649a3a999daf1a63c25201be2990f", + "reference": "86d8208fc3c649a3a999daf1a63c25201be2990f", "shasum": "" }, "require": { @@ -8408,7 +8794,7 @@ ], "support": { "issues": "https://github.com/composer/class-map-generator/issues", - "source": "https://github.com/composer/class-map-generator/tree/1.7.0" + "source": "https://github.com/composer/class-map-generator/tree/1.7.3" }, "funding": [ { @@ -8420,32 +8806,33 @@ "type": "github" } ], - "time": "2025-11-19T10:41:15+00:00" + "time": "2026-05-05T09:17:07+00:00" }, { "name": "composer/pcre", - "version": "3.3.2", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + "reference": "d5a341b3fb61f3001970940afb1d332968a183ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", - "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "url": "https://api.github.com/repos/composer/pcre/zipball/d5a341b3fb61f3001970940afb1d332968a183ed", + "reference": "d5a341b3fb61f3001970940afb1d332968a183ed", "shasum": "" }, "require": { "php": "^7.4 || ^8.0" }, "conflict": { - "phpstan/phpstan": "<1.11.10" + "phpstan/phpstan": "<2.2.2" }, "require-dev": { - "phpstan/phpstan": "^1.12 || ^2", - "phpstan/phpstan-strict-rules": "^1 || ^2", - "phpunit/phpunit": "^8 || ^9" + "phpstan/phpstan": "^2", + "phpstan/phpstan-deprecation-rules": "^2", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "^9" }, "type": "library", "extra": { @@ -8483,88 +8870,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.3.2" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2024-11-12T16:29:46+00:00" - }, - { - "name": "composer/semver", - "version": "3.4.4", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", - "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.11", - "symfony/phpunit-bridge": "^3 || ^7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "support": { - "irc": "ircs://irc.libera.chat:6697/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.4.4" + "source": "https://github.com/composer/pcre/tree/3.4.0" }, "funding": [ { @@ -8576,7 +8882,7 @@ "type": "github" } ], - "time": "2025-08-20T19:15:30+00:00" + "time": "2026-06-07T11:47:49+00:00" }, { "name": "composer/xdebug-handler", @@ -8645,114 +8951,110 @@ "time": "2024-05-06T16:37:16+00:00" }, { - "name": "evenement/evenement", - "version": "v3.0.2", + "name": "doctrine/deprecations", + "version": "1.1.6", "source": { "type": "git", - "url": "https://github.com/igorw/evenement.git", - "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" + "url": "https://github.com/doctrine/deprecations.git", + "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", - "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", + "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", "shasum": "" }, "require": { - "php": ">=7.0" - }, - "require-dev": { - "phpunit/phpunit": "^9 || ^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Evenement\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "Événement is a very simple event dispatching library for PHP", - "keywords": [ - "event-dispatcher", - "event-emitter" - ], - "support": { - "issues": "https://github.com/igorw/evenement/issues", - "source": "https://github.com/igorw/evenement/tree/v3.0.2" - }, - "time": "2023-08-08T05:53:35+00:00" - }, - { - "name": "fakerphp/faker", - "version": "v1.24.1", - "source": { - "type": "git", - "url": "https://github.com/FakerPHP/Faker.git", - "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", - "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0", - "psr/container": "^1.0 || ^2.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" + "php": "^7.1 || ^8.0" }, "conflict": { - "fzaninotto/faker": "*" + "phpunit/phpunit": "<=7.5 || >=14" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "doctrine/persistence": "^1.3 || ^2.0", - "ext-intl": "*", - "phpunit/phpunit": "^9.5.26", - "symfony/phpunit-bridge": "^5.4.16" + "doctrine/coding-standard": "^9 || ^12 || ^14", + "phpstan/phpstan": "1.4.10 || 2.1.30", + "phpstan/phpstan-phpunit": "^1.0 || ^2", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12.4 || ^13.0", + "psr/log": "^1 || ^2 || ^3" }, "suggest": { - "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", - "ext-curl": "Required by Faker\\Provider\\Image to download images.", - "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", - "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", - "ext-mbstring": "Required for multibyte Unicode string functionality." + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" }, "type": "library", "autoload": { "psr-4": { - "Faker\\": "src/Faker/" + "Doctrine\\Deprecations\\": "src" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", "support": { - "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.24.1" + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/1.1.6" }, - "time": "2024-11-21T13:46:39+00:00" + "time": "2026-02-07T07:09:04+00:00" + }, + { + "name": "driftingly/rector-laravel", + "version": "2.6.2", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "c0f9a2ff7365cec45d4dc64223608e7cec74604a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/c0f9a2ff7365cec45d4dc64223608e7cec74604a", + "reference": "c0f9a2ff7365cec45d4dc64223608e7cec74604a", + "shasum": "" + }, + "require": { + "php": ">=8.3", + "rector/rector": "^2.6.4", + "symplify/rule-doc-generator-contracts": "^11.2", + "webmozart/assert": "^1.11 || ^2.0" + }, + "require-dev": { + "boundwize/structarmed": "^0.16", + "nette/utils": "^4.0", + "nikic/php-parser": "^5.6", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan": "^2.2", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpstan/phpstan-webmozart-assert": "^2.0", + "phpunit/phpunit": "^10.5", + "symplify/rule-doc-generator": "^12.2", + "tightenco/duster": "^3.1", + "tracy/tracy": "^2.10" + }, + "type": "rector-extension", + "extra": { + "rector": { + "includes": [ + "config/config.php" + ] + } + }, + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/2.6.2" + }, + "time": "2026-08-29T21:42:57+00:00" }, { "name": "fidry/cpu-core-counter", @@ -8815,195 +9117,23 @@ ], "time": "2025-08-14T07:29:31+00:00" }, - { - "name": "filp/whoops", - "version": "2.18.4", - "source": { - "type": "git", - "url": "https://github.com/filp/whoops.git", - "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d", - "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", - "symfony/var-dumper": "^4.0 || ^5.0" - }, - "suggest": { - "symfony/var-dumper": "Pretty print complex values better with var-dumper available", - "whoops/soap": "Formats errors as SOAP responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Whoops\\": "src/Whoops/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Filipe Dobreira", - "homepage": "https://github.com/filp", - "role": "Developer" - } - ], - "description": "php error handling for cool kids", - "homepage": "https://filp.github.io/whoops/", - "keywords": [ - "error", - "exception", - "handling", - "library", - "throwable", - "whoops" - ], - "support": { - "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.18.4" - }, - "funding": [ - { - "url": "https://github.com/denis-sokolov", - "type": "github" - } - ], - "time": "2025-08-08T12:00:00+00:00" - }, - { - "name": "friendsofphp/php-cs-fixer", - "version": "v3.64.0", - "source": { - "type": "git", - "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "58dd9c931c785a79739310aef5178928305ffa67" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/58dd9c931c785a79739310aef5178928305ffa67", - "reference": "58dd9c931c785a79739310aef5178928305ffa67", - "shasum": "" - }, - "require": { - "clue/ndjson-react": "^1.0", - "composer/semver": "^3.4", - "composer/xdebug-handler": "^3.0.3", - "ext-filter": "*", - "ext-json": "*", - "ext-tokenizer": "*", - "fidry/cpu-core-counter": "^1.0", - "php": "^7.4 || ^8.0", - "react/child-process": "^0.6.5", - "react/event-loop": "^1.0", - "react/promise": "^2.0 || ^3.0", - "react/socket": "^1.0", - "react/stream": "^1.0", - "sebastian/diff": "^4.0 || ^5.0 || ^6.0", - "symfony/console": "^5.4 || ^6.0 || ^7.0", - "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", - "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", - "symfony/finder": "^5.4 || ^6.0 || ^7.0", - "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", - "symfony/polyfill-mbstring": "^1.28", - "symfony/polyfill-php80": "^1.28", - "symfony/polyfill-php81": "^1.28", - "symfony/process": "^5.4 || ^6.0 || ^7.0", - "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" - }, - "require-dev": { - "facile-it/paraunit": "^1.3 || ^2.3", - "infection/infection": "^0.29.5", - "justinrainbow/json-schema": "^5.2", - "keradus/cli-executor": "^2.1", - "mikey179/vfsstream": "^1.6.11", - "php-coveralls/php-coveralls": "^2.7", - "php-cs-fixer/accessible-object": "^1.1", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5", - "phpunit/phpunit": "^9.6.19 || ^10.5.21 || ^11.2", - "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", - "symfony/yaml": "^5.4 || ^6.0 || ^7.0" - }, - "suggest": { - "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters." - }, - "bin": [ - "php-cs-fixer" - ], - "type": "application", - "autoload": { - "psr-4": { - "PhpCsFixer\\": "src/" - }, - "exclude-from-classmap": [ - "src/Fixer/Internal/*" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - } - ], - "description": "A tool to automatically fix PHP code style", - "keywords": [ - "Static code analysis", - "fixer", - "standards", - "static analysis" - ], - "support": { - "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.64.0" - }, - "funding": [ - { - "url": "https://github.com/keradus", - "type": "github" - } - ], - "time": "2024-08-30T23:09:38+00:00" - }, { "name": "hamcrest/hamcrest-php", - "version": "v2.1.1", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487" + "reference": "b61cd040da1a4925bc90a51c074f5297e7c0fa52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487", - "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b61cd040da1a4925bc90a51c074f5297e7c0fa52", + "reference": "b61cd040da1a4925bc90a51c074f5297e7c0fa52", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-dom": "*", "php": "^7.4|^8.0" }, "replace": { @@ -9012,13 +9142,15 @@ "kodova/hamcrest-php": "*" }, "require-dev": { + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-phpunit": "^2.0", "phpunit/php-file-iterator": "^1.4 || ^2.0 || ^3.0", "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -9036,22 +9168,22 @@ ], "support": { "issues": "https://github.com/hamcrest/hamcrest-php/issues", - "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.1.1" + "source": "https://github.com/hamcrest/hamcrest-php/tree/v3.0.0" }, - "time": "2025-04-30T06:54:44+00:00" + "time": "2026-03-17T11:56:53+00:00" }, { "name": "iamcal/sql-parser", - "version": "v0.6", + "version": "v0.7", "source": { "type": "git", "url": "https://github.com/iamcal/SQLParser.git", - "reference": "947083e2dca211a6f12fb1beb67a01e387de9b62" + "reference": "610392f38de49a44dab08dc1659960a29874c4b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/iamcal/SQLParser/zipball/947083e2dca211a6f12fb1beb67a01e387de9b62", - "reference": "947083e2dca211a6f12fb1beb67a01e387de9b62", + "url": "https://api.github.com/repos/iamcal/SQLParser/zipball/610392f38de49a44dab08dc1659960a29874c4b8", + "reference": "610392f38de49a44dab08dc1659960a29874c4b8", "shasum": "" }, "require-dev": { @@ -9077,50 +9209,45 @@ "description": "MySQL schema parser", "support": { "issues": "https://github.com/iamcal/SQLParser/issues", - "source": "https://github.com/iamcal/SQLParser/tree/v0.6" + "source": "https://github.com/iamcal/SQLParser/tree/v0.7" }, - "time": "2025-03-17T16:59:46+00:00" + "time": "2026-01-28T22:20:33+00:00" }, { - "name": "itsgoingd/clockwork", - "version": "v5.3.5", + "name": "jean85/pretty-package-versions", + "version": "2.1.1", "source": { "type": "git", - "url": "https://github.com/itsgoingd/clockwork.git", - "reference": "d928483e231f042dbff9258795cb17aadaebc7d0" + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/itsgoingd/clockwork/zipball/d928483e231f042dbff9258795cb17aadaebc7d0", - "reference": "d928483e231f042dbff9258795cb17aadaebc7d0", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a", + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a", "shasum": "" }, "require": { - "ext-json": "*", - "php": ">=7.1" + "composer-runtime-api": "^2.1.0", + "php": "^7.4|^8.0" }, - "suggest": { - "ext-pdo": "Needed in order to use a SQL database for metadata storage", - "ext-pdo_mysql": "Needed in order to use MySQL for metadata storage", - "ext-pdo_postgres": "Needed in order to use Postgres for metadata storage", - "ext-pdo_sqlite": "Needed in order to use a SQLite for metadata storage", - "ext-redis": "Needed in order to use Redis for metadata storage", - "php-http/discovery": "Vanilla integration - required for the middleware zero-configuration setup" + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.2", + "jean85/composer-provided-replaced-stub-package": "^1.0", + "phpstan/phpstan": "^2.0", + "phpunit/phpunit": "^7.5|^8.5|^9.6", + "rector/rector": "^2.0", + "vimeo/psalm": "^4.3 || ^5.0" }, "type": "library", "extra": { - "laravel": { - "aliases": { - "Clockwork": "Clockwork\\Support\\Laravel\\Facade" - }, - "providers": [ - "Clockwork\\Support\\Laravel\\ClockworkServiceProvider" - ] + "branch-alias": { + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "Clockwork\\": "Clockwork/" + "Jean85\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -9129,70 +9256,59 @@ ], "authors": [ { - "name": "itsgoingd", - "email": "itsgoingd@luzer.sk", - "homepage": "https://twitter.com/itsgoingd" + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" } ], - "description": "php dev tools in your browser", - "homepage": "https://underground.works/clockwork", + "description": "A library to get pretty versions strings of installed dependencies", "keywords": [ - "Devtools", - "debugging", - "laravel", - "logging", - "lumen", - "profiling", - "slim" + "composer", + "package", + "release", + "versions" ], "support": { - "issues": "https://github.com/itsgoingd/clockwork/issues", - "source": "https://github.com/itsgoingd/clockwork/tree/v5.3.5" + "issues": "https://github.com/Jean85/pretty-package-versions/issues", + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.1" }, - "funding": [ - { - "url": "https://github.com/itsgoingd", - "type": "github" - } - ], - "time": "2025-09-14T15:34:49+00:00" + "time": "2025-03-19T14:43:43+00:00" }, { "name": "larastan/larastan", - "version": "v3.8.0", + "version": "v3.10.0", "source": { "type": "git", "url": "https://github.com/larastan/larastan.git", - "reference": "d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e" + "reference": "2970f83398154178a739609c244577267c7ee8eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/larastan/larastan/zipball/d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e", - "reference": "d13ef96d652d1b2a8f34f1760ba6bf5b9c98112e", + "url": "https://api.github.com/repos/larastan/larastan/zipball/2970f83398154178a739609c244577267c7ee8eb", + "reference": "2970f83398154178a739609c244577267c7ee8eb", "shasum": "" }, "require": { "ext-json": "*", - "iamcal/sql-parser": "^0.6.0", - "illuminate/console": "^11.44.2 || ^12.4.1", - "illuminate/container": "^11.44.2 || ^12.4.1", - "illuminate/contracts": "^11.44.2 || ^12.4.1", - "illuminate/database": "^11.44.2 || ^12.4.1", - "illuminate/http": "^11.44.2 || ^12.4.1", - "illuminate/pipeline": "^11.44.2 || ^12.4.1", - "illuminate/support": "^11.44.2 || ^12.4.1", + "iamcal/sql-parser": "^0.7.0", + "illuminate/console": "^11.44.2 || ^12.4.1 || ^13", + "illuminate/container": "^11.44.2 || ^12.4.1 || ^13", + "illuminate/contracts": "^11.44.2 || ^12.4.1 || ^13", + "illuminate/database": "^11.44.2 || ^12.4.1 || ^13", + "illuminate/http": "^11.44.2 || ^12.4.1 || ^13", + "illuminate/pipeline": "^11.44.2 || ^12.4.1 || ^13", + "illuminate/support": "^11.44.2 || ^12.4.1 || ^13", "php": "^8.2", - "phpstan/phpstan": "^2.1.29" + "phpstan/phpstan": "^2.2.0" }, "require-dev": { - "doctrine/coding-standard": "^13", - "laravel/framework": "^11.44.2 || ^12.7.2", + "doctrine/coding-standard": "^14", + "laravel/framework": "^11.44.2 || ^12.7.2 || ^13", "mockery/mockery": "^1.6.12", "nikic/php-parser": "^5.4", - "orchestra/canvas": "^v9.2.2 || ^10.0.1", - "orchestra/testbench-core": "^9.12.0 || ^10.1", + "orchestra/canvas": "^v9.2.2 || ^10.0.1 || ^11", + "orchestra/testbench-core": "^9.12.0 || ^10.1 || ^11", "phpstan/phpstan-deprecation-rules": "^2.0.1", - "phpunit/phpunit": "^10.5.35 || ^11.5.15" + "phpunit/phpunit": "^10.5.35 || ^11.5.15 || ^12.5.8 || ^13.1.8" }, "suggest": { "orchestra/testbench": "Using Larastan for analysing a package needs Testbench", @@ -9237,7 +9353,7 @@ ], "support": { "issues": "https://github.com/larastan/larastan/issues", - "source": "https://github.com/larastan/larastan/tree/v3.8.0" + "source": "https://github.com/larastan/larastan/tree/v3.10.0" }, "funding": [ { @@ -9245,33 +9361,102 @@ "type": "github" } ], - "time": "2025-10-27T23:09:14+00:00" + "time": "2026-05-28T08:00:58+00:00" }, { - "name": "mockery/mockery", - "version": "1.6.12", + "name": "laravel/pint", + "version": "v1.30.5", "source": { "type": "git", - "url": "https://github.com/mockery/mockery.git", - "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699" + "url": "https://github.com/laravel/pint.git", + "reference": "fe4148c503a0e266353d61396b79bbf7f35122df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/1f4efdd7d3beafe9807b08156dfcb176d18f1699", - "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699", + "url": "https://api.github.com/repos/laravel/pint/zipball/fe4148c503a0e266353d61396b79bbf7f35122df", + "reference": "fe4148c503a0e266353d61396b79bbf7f35122df", "shasum": "" }, "require": { - "hamcrest/hamcrest-php": "^2.0.1", - "lib-pcre": ">=7.0", + "ext-json": "*", + "ext-mbstring": "*", + "ext-tokenizer": "*", + "ext-xml": "*", + "php": "^8.3.0" + }, + "require-dev": { + "composer/semver": "^3.4.4", + "friendsofphp/php-cs-fixer": "^3.95.18", + "illuminate/view": "^13.24.0", + "larastan/larastan": "^3.10.0", + "laravel-zero/framework": "^13.0.0", + "laravel/agent-detector": "^2.0.2", + "laravel/prompts": "^0.3.22", + "mockery/mockery": "^1.6.12", + "nunomaduro/termwind": "^2.4.0", + "pestphp/pest": "^4.7.8" + }, + "bin": [ + "builds/pint" + ], + "type": "project", + "autoload": { + "psr-4": { + "App\\": "app/", + "Database\\Seeders\\": "database/seeders/", + "Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "An opinionated code formatter for PHP.", + "homepage": "https://laravel.com", + "keywords": [ + "dev", + "format", + "formatter", + "lint", + "linter", + "php" + ], + "support": { + "issues": "https://github.com/laravel/pint/issues", + "source": "https://github.com/laravel/pint" + }, + "time": "2026-08-10T15:35:50+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.6.15", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "967a801bd188989a5669bd280f252d51c0fdc9ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/967a801bd188989a5669bd280f252d51c0fdc9ee", + "reference": "967a801bd188989a5669bd280f252d51c0fdc9ee", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0 || ^3.0", "php": ">=7.3" }, "conflict": { "phpunit/phpunit": "<8.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.6.17", - "symplify/easy-coding-standard": "^12.1.14" + "phpunit/phpunit": "^9.6.36", + "symplify/easy-coding-standard": "^13.2.17" }, "type": "library", "autoload": { @@ -9328,24 +9513,24 @@ "security": "https://github.com/mockery/mockery/security/advisories", "source": "https://github.com/mockery/mockery" }, - "time": "2024-05-16T03:13:13+00:00" + "time": "2026-08-19T19:37:52+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.13.4", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + "reference": "8680aa248f8e07bc8fb43f56f0f5fc77a0c96aae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", - "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8680aa248f8e07bc8fb43f56f0f5fc77a0c96aae", + "reference": "8680aa248f8e07bc8fb43f56f0f5fc77a0c96aae", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.0" }, "conflict": { "doctrine/collections": "<1.6.8", @@ -9380,68 +9565,56 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" + "source": "https://github.com/myclabs/DeepCopy/tree/1.14.0" }, "funding": [ { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" + "url": "https://github.com/mnapoli", + "type": "github" } ], - "time": "2025-08-01T08:46:24+00:00" + "time": "2026-08-11T10:17:44+00:00" }, { - "name": "nunomaduro/collision", - "version": "v8.5.0", + "name": "nunomaduro/pokio", + "version": "v1.0.1", "source": { "type": "git", - "url": "https://github.com/nunomaduro/collision.git", - "reference": "f5c101b929c958e849a633283adff296ed5f38f5" + "url": "https://github.com/nunomaduro/pokio.git", + "reference": "fc7884ebc5b0fabd6e267c0b4e6f750ba69cee5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/f5c101b929c958e849a633283adff296ed5f38f5", - "reference": "f5c101b929c958e849a633283adff296ed5f38f5", + "url": "https://api.github.com/repos/nunomaduro/pokio/zipball/fc7884ebc5b0fabd6e267c0b4e6f750ba69cee5b", + "reference": "fc7884ebc5b0fabd6e267c0b4e6f750ba69cee5b", "shasum": "" }, "require": { - "filp/whoops": "^2.16.0", - "nunomaduro/termwind": "^2.1.0", - "php": "^8.2.0", - "symfony/console": "^7.1.5" + "php": "^8.3.0" }, "conflict": { - "laravel/framework": "<11.0.0 || >=12.0.0", - "phpunit/phpunit": "<10.5.1 || >=12.0.0" + "symplify/easy-parallel": "<11.2.2" }, "require-dev": { - "larastan/larastan": "^2.9.8", - "laravel/framework": "^11.28.0", - "laravel/pint": "^1.18.1", - "laravel/sail": "^1.36.0", - "laravel/sanctum": "^4.0.3", - "laravel/tinker": "^2.10.0", - "orchestra/testbench-core": "^9.5.3", - "pestphp/pest": "^2.36.0 || ^3.4.0", - "sebastian/environment": "^6.1.0 || ^7.2.0" + "laravel/pint": "^1.29.0", + "peckphp/peck": "^0.1.3", + "pestphp/pest": "^4.5.0", + "pestphp/pest-plugin-type-coverage": "^4.0.3", + "phpstan/phpstan": "^2.1.46", + "symfony/var-dumper": "^7.4.8 || ^8.0.8" }, "type": "library", "extra": { - "laravel": { - "providers": [ - "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" - ] - }, "branch-alias": { - "dev-8.x": "8.x-dev" + "dev-main": "0.1.x-dev" } }, "autoload": { "files": [ - "./src/Adapters/Phpunit/Autoload.php" + "src/Functions.php" ], "psr-4": { - "NunoMaduro\\Collision\\": "src/" + "Pokio\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -9454,22 +9627,16 @@ "email": "enunomaduro@gmail.com" } ], - "description": "Cli error handling for console/command-line PHP applications.", + "description": "Pokio is a dead simple asynchronous API for PHP that just works", "keywords": [ - "artisan", - "cli", - "command-line", - "console", - "error", - "handling", - "laravel", - "laravel-zero", + "asynchronous", + "library", "php", - "symfony" + "pokio" ], "support": { - "issues": "https://github.com/nunomaduro/collision/issues", - "source": "https://github.com/nunomaduro/collision" + "issues": "https://github.com/nunomaduro/pokio/issues", + "source": "https://github.com/nunomaduro/pokio/tree/v1.0.1" }, "funding": [ { @@ -9485,7 +9652,540 @@ "type": "patreon" } ], - "time": "2024-10-15T16:06:32+00:00" + "time": "2026-04-12T12:06:31+00:00" + }, + { + "name": "pestphp/pest", + "version": "v4.7.8", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest.git", + "reference": "5b2293f67adcf1b2320b33f521b94a692d18f360" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest/zipball/5b2293f67adcf1b2320b33f521b94a692d18f360", + "reference": "5b2293f67adcf1b2320b33f521b94a692d18f360", + "shasum": "" + }, + "require": { + "brianium/paratest": "^7.20.0", + "composer/xdebug-handler": "^3.0.5", + "nunomaduro/collision": "^8.9.5", + "nunomaduro/termwind": "^2.4.0", + "pestphp/pest-plugin": "^4.0.0", + "pestphp/pest-plugin-arch": "^4.0.2", + "pestphp/pest-plugin-mutate": "^4.0.1", + "pestphp/pest-plugin-profanity": "^4.2.1", + "php": "^8.3.0", + "phpunit/phpunit": "^12.5.33", + "symfony/process": "^7.4.13|^8.1.0" + }, + "conflict": { + "filp/whoops": "<2.18.3", + "phpunit/phpunit": ">12.5.33", + "sebastian/exporter": "<7.0.0", + "webmozart/assert": "<1.11.0" + }, + "require-dev": { + "mrpunyapal/peststan": "^0.2.12", + "pestphp/pest-dev-tools": "^4.1.0", + "pestphp/pest-plugin-browser": "^4.3.1", + "pestphp/pest-plugin-type-coverage": "^4.0.4", + "psy/psysh": "^0.12.24" + }, + "bin": [ + "bin/pest" + ], + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\Mutate\\Plugins\\Mutate", + "Pest\\Plugins\\Configuration", + "Pest\\Plugins\\Bail", + "Pest\\Plugins\\Cache", + "Pest\\Plugins\\Coverage", + "Pest\\Plugins\\Init", + "Pest\\Plugins\\Environment", + "Pest\\Plugins\\Help", + "Pest\\Plugins\\Memory", + "Pest\\Plugins\\Only", + "Pest\\Plugins\\Printer", + "Pest\\Plugins\\ProcessIsolation", + "Pest\\Plugins\\Profile", + "Pest\\Plugins\\Retry", + "Pest\\Plugins\\Snapshot", + "Pest\\Plugins\\Verbose", + "Pest\\Plugins\\Version", + "Pest\\Plugins\\Shard", + "Pest\\Plugins\\Parallel" + ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "files": [ + "src/Functions.php", + "src/Pest.php" + ], + "psr-4": { + "Pest\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "The elegant PHP Testing Framework.", + "keywords": [ + "framework", + "pest", + "php", + "test", + "testing", + "unit" + ], + "support": { + "issues": "https://github.com/pestphp/pest/issues", + "source": "https://github.com/pestphp/pest/tree/v4.7.8" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2026-08-03T20:49:44+00:00" + }, + { + "name": "pestphp/pest-plugin", + "version": "v4.0.0", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin.git", + "reference": "9d4b93d7f73d3f9c3189bb22c220fef271cdf568" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/9d4b93d7f73d3f9c3189bb22c220fef271cdf568", + "reference": "9d4b93d7f73d3f9c3189bb22c220fef271cdf568", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0.0", + "composer-runtime-api": "^2.2.2", + "php": "^8.3" + }, + "conflict": { + "pestphp/pest": "<4.0.0" + }, + "require-dev": { + "composer/composer": "^2.8.10", + "pestphp/pest": "^4.0.0", + "pestphp/pest-dev-tools": "^4.0.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Pest\\Plugin\\Manager" + }, + "autoload": { + "psr-4": { + "Pest\\Plugin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Pest plugin manager", + "keywords": [ + "framework", + "manager", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin/tree/v4.0.0" + }, + "funding": [ + { + "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2025-08-20T12:35:58+00:00" + }, + { + "name": "pestphp/pest-plugin-arch", + "version": "v4.0.2", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-arch.git", + "reference": "3fb0d02a91b9da504b139dc7ab2a31efb7c3215c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/3fb0d02a91b9da504b139dc7ab2a31efb7c3215c", + "reference": "3fb0d02a91b9da504b139dc7ab2a31efb7c3215c", + "shasum": "" + }, + "require": { + "pestphp/pest-plugin": "^4.0.0", + "php": "^8.3", + "ta-tikoma/phpunit-architecture-test": "^0.8.7" + }, + "require-dev": { + "pestphp/pest": "^4.4.6", + "pestphp/pest-dev-tools": "^4.1.0" + }, + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\Arch\\Plugin" + ] + } + }, + "autoload": { + "files": [ + "src/Autoload.php" + ], + "psr-4": { + "Pest\\Arch\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Arch plugin for Pest PHP.", + "keywords": [ + "arch", + "architecture", + "framework", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-arch/tree/v4.0.2" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2026-04-10T17:20:19+00:00" + }, + { + "name": "pestphp/pest-plugin-laravel", + "version": "v4.1.0", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-laravel.git", + "reference": "3057a36669ff11416cc0dc2b521b3aec58c488d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/3057a36669ff11416cc0dc2b521b3aec58c488d0", + "reference": "3057a36669ff11416cc0dc2b521b3aec58c488d0", + "shasum": "" + }, + "require": { + "laravel/framework": "^11.45.2|^12.52.0|^13.0", + "pestphp/pest": "^4.4.1", + "php": "^8.3.0" + }, + "require-dev": { + "laravel/dusk": "^8.3.6", + "orchestra/testbench": "^9.13.0|^10.9.0|^11.0", + "pestphp/pest-dev-tools": "^4.1.0" + }, + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\Laravel\\Plugin" + ] + }, + "laravel": { + "providers": [ + "Pest\\Laravel\\PestServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/Autoload.php" + ], + "psr-4": { + "Pest\\Laravel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Pest Laravel Plugin", + "keywords": [ + "framework", + "laravel", + "pest", + "php", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-laravel/tree/v4.1.0" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2026-02-21T00:29:45+00:00" + }, + { + "name": "pestphp/pest-plugin-mutate", + "version": "v4.0.1", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-mutate.git", + "reference": "d9b32b60b2385e1688a68cc227594738ec26d96c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-mutate/zipball/d9b32b60b2385e1688a68cc227594738ec26d96c", + "reference": "d9b32b60b2385e1688a68cc227594738ec26d96c", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^5.6.1", + "pestphp/pest-plugin": "^4.0.0", + "php": "^8.3", + "psr/simple-cache": "^3.0.0" + }, + "require-dev": { + "pestphp/pest": "^4.0.0", + "pestphp/pest-dev-tools": "^4.0.0", + "pestphp/pest-plugin-type-coverage": "^4.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Pest\\Mutate\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + }, + { + "name": "Sandro Gehri", + "email": "sandrogehri@gmail.com" + } + ], + "description": "Mutates your code to find untested cases", + "keywords": [ + "framework", + "mutate", + "mutation", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-mutate/tree/v4.0.1" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/gehrisandro", + "type": "github" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2025-08-21T20:19:25+00:00" + }, + { + "name": "pestphp/pest-plugin-profanity", + "version": "v4.2.1", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-profanity.git", + "reference": "343cfa6f3564b7e35df0ebb77b7fa97039f72b27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-profanity/zipball/343cfa6f3564b7e35df0ebb77b7fa97039f72b27", + "reference": "343cfa6f3564b7e35df0ebb77b7fa97039f72b27", + "shasum": "" + }, + "require": { + "pestphp/pest-plugin": "^4.0.0", + "php": "^8.3" + }, + "require-dev": { + "faissaloux/pest-plugin-inside": "^1.9", + "pestphp/pest": "^4.0.0", + "pestphp/pest-dev-tools": "^4.0.0" + }, + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\Profanity\\Plugin" + ] + } + }, + "autoload": { + "psr-4": { + "Pest\\Profanity\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Pest Profanity Plugin", + "keywords": [ + "framework", + "pest", + "php", + "plugin", + "profanity", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-profanity/tree/v4.2.1" + }, + "time": "2025-12-08T00:13:17+00:00" + }, + { + "name": "pestphp/pest-plugin-type-coverage", + "version": "v4.0.4", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-type-coverage.git", + "reference": "f485d40ec4e2081f9d3456c00f2c008f145d7896" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-type-coverage/zipball/f485d40ec4e2081f9d3456c00f2c008f145d7896", + "reference": "f485d40ec4e2081f9d3456c00f2c008f145d7896", + "shasum": "" + }, + "require": { + "nunomaduro/pokio": "^1.0.0", + "pestphp/pest-plugin": "^4.0.0", + "php": "^8.3", + "phpstan/phpstan": "^1.12.24|^2.1.46", + "tomasvotruba/type-coverage": "^1.0.0|^2.1.0" + }, + "require-dev": { + "pestphp/pest": "^4.4.5", + "pestphp/pest-dev-tools": "^4.1.0" + }, + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\TypeCoverage\\Plugin" + ] + } + }, + "autoload": { + "psr-4": { + "Pest\\TypeCoverage\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Type Coverage plugin for Pest PHP.", + "keywords": [ + "coverage", + "framework", + "pest", + "php", + "plugin", + "test", + "testing", + "type-coverage", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-type-coverage/tree/v4.0.4" + }, + "funding": [ + { + "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2026-04-06T14:00:30+00:00" }, { "name": "phar-io/manifest", @@ -9606,12 +10306,283 @@ "time": "2022-02-21T01:04:05+00:00" }, { - "name": "phpstan/phpstan", - "version": "2.1.33", + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9e800e6bee7d5bd02784d4c6069b48032d16224f", - "reference": "9e800e6bee7d5bd02784d4c6069b48032d16224f", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "6.0.3", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "7bae67520aa9f5ecc506d646810bd40d9da54582" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/7bae67520aa9f5ecc506d646810bd40d9da54582", + "reference": "7bae67520aa9f5ecc506d646810bd40d9da54582", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.1", + "ext-filter": "*", + "php": "^7.4 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^2.0", + "phpstan/phpdoc-parser": "^2.0", + "webmozart/assert": "^1.9.1 || ^2" + }, + "require-dev": { + "mockery/mockery": "~1.3.5 || ~1.6.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "psalm/phar": "^5.26", + "shipmonk/dead-code-detector": "^0.5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/6.0.3" + }, + "time": "2026-03-18T20:49:53+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "327a05bbee54120d4786a0dc67aad30226ad4cf9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/327a05bbee54120d4786a0dc67aad30226ad4cf9", + "reference": "327a05bbee54120d4786a0dc67aad30226ad4cf9", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.4 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "psalm/phar": "^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev", + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/2.0.0" + }, + "time": "2026-01-06T21:53:42+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" + }, + "time": "2024-09-04T20:21:43+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "2.3.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "fb19eedd2bb67ff8cf7a5502ad329e701d6398a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fb19eedd2bb67ff8cf7a5502ad329e701d6398a3", + "reference": "fb19eedd2bb67ff8cf7a5502ad329e701d6398a3", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^5.3.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.3" + }, + "time": "2026-07-08T07:01:06+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "2.2.14", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9c672e7a8e791dfc3d30e55f683e73fc0b63a3ac", + "reference": "9c672e7a8e791dfc3d30e55f683e73fc0b63a3ac", "shasum": "" }, "require": { @@ -9634,6 +10605,17 @@ "license": [ "MIT" ], + "authors": [ + { + "name": "Ondřej Mirtes" + }, + { + "name": "Markus Staab" + }, + { + "name": "Vincent Langlet" + } + ], "description": "PHPStan - PHP Static Analysis Tool", "keywords": [ "dev", @@ -9656,40 +10638,38 @@ "type": "github" } ], - "time": "2025-12-05T10:24:31+00:00" + "time": "2026-09-12T21:39:33+00:00" }, { - "name": "phpstan/phpstan-webmozart-assert", - "version": "2.0.0", + "name": "phpstan/phpstan-strict-rules", + "version": "2.0.12", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan-webmozart-assert.git", - "reference": "0c641817d2a8f05c7157f92d91986e74d3c8ab0c" + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "2bc5ae19ae965663b62ac907ee6342c3903ec93b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-webmozart-assert/zipball/0c641817d2a8f05c7157f92d91986e74d3c8ab0c", - "reference": "0c641817d2a8f05c7157f92d91986e74d3c8ab0c", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/2bc5ae19ae965663b62ac907ee6342c3903ec93b", + "reference": "2bc5ae19ae965663b62ac907ee6342c3903ec93b", "shasum": "" }, "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.0" + "phpstan/phpstan": "^2.1.52" }, "require-dev": { - "nikic/php-parser": "^5.1", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-phpunit": "^2.0", - "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^9.6", - "webmozart/assert": "^1.11.0" + "shipmonk/name-collision-detector": "^2.1" }, "type": "phpstan-extension", "extra": { "phpstan": { "includes": [ - "extension.neon" + "rules.neon" ] } }, @@ -9702,44 +10682,45 @@ "license": [ "MIT" ], - "description": "PHPStan webmozart/assert extension", + "description": "Extra strict and opinionated rules for PHPStan", + "keywords": [ + "static analysis" + ], "support": { - "issues": "https://github.com/phpstan/phpstan-webmozart-assert/issues", - "source": "https://github.com/phpstan/phpstan-webmozart-assert/tree/2.0.0" + "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/2.0.12" }, - "time": "2024-10-14T03:45:26+00:00" + "time": "2026-07-19T07:24:06+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.16", + "version": "12.5.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "7e308268858ed6baedc8704a304727d20bc07c77" + "reference": "186dab580576598076de6818596d12b61801880e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77", - "reference": "7e308268858ed6baedc8704a304727d20bc07c77", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/186dab580576598076de6818596d12b61801880e", + "reference": "186dab580576598076de6818596d12b61801880e", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.19.1 || ^5.1.0", - "php": ">=8.1", - "phpunit/php-file-iterator": "^4.1.0", - "phpunit/php-text-template": "^3.0.1", - "sebastian/code-unit-reverse-lookup": "^3.0.0", - "sebastian/complexity": "^3.2.0", - "sebastian/environment": "^6.1.0", - "sebastian/lines-of-code": "^2.0.2", - "sebastian/version": "^4.0.1", - "theseer/tokenizer": "^1.2.3" + "nikic/php-parser": "^5.7.0", + "php": ">=8.3", + "phpunit/php-text-template": "^5.0", + "sebastian/complexity": "^5.0", + "sebastian/environment": "^8.1.2", + "sebastian/lines-of-code": "^4.0.1", + "sebastian/version": "^6.0", + "theseer/tokenizer": "^2.0.1" }, "require-dev": { - "phpunit/phpunit": "^10.1" + "phpunit/phpunit": "^12.5.28" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -9748,7 +10729,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.1.x-dev" + "dev-main": "12.5.x-dev" } }, "autoload": { @@ -9777,40 +10758,52 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.16" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/12.5.7" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/php-code-coverage", + "type": "tidelift" } ], - "time": "2024-08-22T04:31:57+00:00" + "time": "2026-06-01T13:24:19+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "4.1.0", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + "reference": "a248d1640ab059b075f53a2ef0f9856e864e06b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a248d1640ab059b075f53a2ef0f9856e864e06b5", + "reference": "a248d1640ab059b075f53a2ef0f9856e864e06b5", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.5.33" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -9838,36 +10831,48 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/6.0.2" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/php-file-iterator", + "type": "tidelift" } ], - "time": "2023-08-31T06:24:48+00:00" + "time": "2026-08-25T14:40:53+00:00" }, { "name": "phpunit/php-invoker", - "version": "4.0.0", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + "reference": "12b54e689b07a25a9b41e57736dfab6ec9ae5406" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/12b54e689b07a25a9b41e57736dfab6ec9ae5406", + "reference": "12b54e689b07a25a9b41e57736dfab6ec9ae5406", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { "ext-pcntl": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.0" }, "suggest": { "ext-pcntl": "*" @@ -9875,7 +10880,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -9901,7 +10906,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + "security": "https://github.com/sebastianbergmann/php-invoker/security/policy", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/6.0.0" }, "funding": [ { @@ -9909,32 +10915,32 @@ "type": "github" } ], - "time": "2023-02-03T06:56:09+00:00" + "time": "2025-02-07T04:58:58+00:00" }, { "name": "phpunit/php-text-template", - "version": "3.0.1", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + "reference": "e1367a453f0eda562eedb4f659e13aa900d66c53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/e1367a453f0eda562eedb4f659e13aa900d66c53", + "reference": "e1367a453f0eda562eedb4f659e13aa900d66c53", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -9961,7 +10967,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + "source": "https://github.com/sebastianbergmann/php-text-template/tree/5.0.0" }, "funding": [ { @@ -9969,32 +10975,32 @@ "type": "github" } ], - "time": "2023-08-31T14:07:24+00:00" + "time": "2025-02-07T04:59:16+00:00" }, { "name": "phpunit/php-timer", - "version": "6.0.0", + "version": "8.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + "reference": "f258ce36aa457f3aa3339f9ed4c81fc66dc8c2cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/f258ce36aa457f3aa3339f9ed4c81fc66dc8c2cc", + "reference": "f258ce36aa457f3aa3339f9ed4c81fc66dc8c2cc", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-main": "8.0-dev" } }, "autoload": { @@ -10020,7 +11026,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + "security": "https://github.com/sebastianbergmann/php-timer/security/policy", + "source": "https://github.com/sebastianbergmann/php-timer/tree/8.0.0" }, "funding": [ { @@ -10028,52 +11035,49 @@ "type": "github" } ], - "time": "2023-02-03T06:57:52+00:00" + "time": "2025-02-07T04:59:38+00:00" }, { "name": "phpunit/phpunit", - "version": "10.5.63", + "version": "12.5.33", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "33198268dad71e926626b618f3ec3966661e4d90" + "reference": "b98e028a26c5c5ba7e4a54be96ccf35f2914d184" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/33198268dad71e926626b618f3ec3966661e4d90", - "reference": "33198268dad71e926626b618f3ec3966661e4d90", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b98e028a26c5c5ba7e4a54be96ccf35f2914d184", + "reference": "b98e028a26c5c5ba7e4a54be96ccf35f2914d184", "shasum": "" }, "require": { "ext-dom": "*", + "ext-filter": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", - "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.13.4", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", - "php": ">=8.1", - "phpunit/php-code-coverage": "^10.1.16", - "phpunit/php-file-iterator": "^4.1.0", - "phpunit/php-invoker": "^4.0.0", - "phpunit/php-text-template": "^3.0.1", - "phpunit/php-timer": "^6.0.0", - "sebastian/cli-parser": "^2.0.1", - "sebastian/code-unit": "^2.0.0", - "sebastian/comparator": "^5.0.5", - "sebastian/diff": "^5.1.1", - "sebastian/environment": "^6.1.0", - "sebastian/exporter": "^5.1.4", - "sebastian/global-state": "^6.0.2", - "sebastian/object-enumerator": "^5.0.0", - "sebastian/recursion-context": "^5.0.1", - "sebastian/type": "^4.0.0", - "sebastian/version": "^4.0.1" - }, - "suggest": { - "ext-soap": "To be able to generate mocks based on WSDL files" + "php": ">=8.3", + "phpunit/php-code-coverage": "^12.5.7", + "phpunit/php-file-iterator": "^6.0.1", + "phpunit/php-invoker": "^6.0.0", + "phpunit/php-text-template": "^5.0.0", + "phpunit/php-timer": "^8.0.0", + "sebastian/cli-parser": "^4.2.1", + "sebastian/comparator": "^7.1.8", + "sebastian/diff": "^7.0.0", + "sebastian/environment": "^8.1.2", + "sebastian/exporter": "^7.0.3", + "sebastian/global-state": "^8.0.3", + "sebastian/object-enumerator": "^7.0.0", + "sebastian/recursion-context": "^7.0.1", + "sebastian/type": "^6.0.4", + "sebastian/version": "^6.0.0", + "staabm/side-effects-detector": "^1.0.5" }, "bin": [ "phpunit" @@ -10081,7 +11085,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.5-dev" + "dev-main": "12.5-dev" } }, "autoload": { @@ -10113,582 +11117,1243 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.63" + "source": "https://github.com/sebastianbergmann/phpunit/tree/12.5.33" }, "funding": [ { - "url": "https://phpunit.de/sponsors.html", - "type": "custom" - }, - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - }, - { - "url": "https://liberapay.com/sebastianbergmann", - "type": "liberapay" - }, - { - "url": "https://thanks.dev/u/gh/sebastianbergmann", - "type": "thanks_dev" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", - "type": "tidelift" + "url": "https://phpunit.de/sponsoring.html", + "type": "other" } ], - "time": "2026-01-27T05:48:37+00:00" + "time": "2026-07-28T13:58:09+00:00" }, { - "name": "react/cache", - "version": "v1.2.0", + "name": "rector/rector", + "version": "2.6.7", "source": { "type": "git", - "url": "https://github.com/reactphp/cache.git", - "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" + "url": "https://github.com/rectorphp/rector.git", + "reference": "f4aa224edb9b0630fb43826d4cb6a49b62e48d4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", - "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/f4aa224edb9b0630fb43826d4cb6a49b62e48d4c", + "reference": "f4aa224edb9b0630fb43826d4cb6a49b62e48d4c", "shasum": "" }, "require": { - "php": ">=5.3.0", - "react/promise": "^3.0 || ^2.0 || ^1.1" + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.2.14" }, - "require-dev": { - "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" + "bin": [ + "bin/rector" ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async, Promise-based cache interface for ReactPHP", - "keywords": [ - "cache", - "caching", - "promise", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/cache/issues", - "source": "https://github.com/reactphp/cache/tree/v1.2.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2022-11-30T15:59:55+00:00" - }, - { - "name": "react/child-process", - "version": "v0.6.6", - "source": { - "type": "git", - "url": "https://github.com/reactphp/child-process.git", - "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/child-process/zipball/1721e2b93d89b745664353b9cfc8f155ba8a6159", - "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.0", - "react/event-loop": "^1.2", - "react/stream": "^1.4" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/socket": "^1.16", - "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\ChildProcess\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Event-driven library for executing child processes with ReactPHP.", - "keywords": [ - "event-driven", - "process", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/child-process/issues", - "source": "https://github.com/reactphp/child-process/tree/v0.6.6" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2025-01-01T16:37:48+00:00" - }, - { - "name": "react/dns", - "version": "v1.14.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/dns.git", - "reference": "7562c05391f42701c1fccf189c8225fece1cd7c3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/dns/zipball/7562c05391f42701c1fccf189c8225fece1cd7c3", - "reference": "7562c05391f42701c1fccf189c8225fece1cd7c3", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "react/cache": "^1.0 || ^0.6 || ^0.5", - "react/event-loop": "^1.2", - "react/promise": "^3.2 || ^2.7 || ^1.2.1" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4.3 || ^3 || ^2", - "react/promise-timer": "^1.11" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Dns\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Async DNS resolver for ReactPHP", - "keywords": [ - "async", - "dns", - "dns-resolver", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/dns/issues", - "source": "https://github.com/reactphp/dns/tree/v1.14.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2025-11-18T19:34:28+00:00" - }, - { - "name": "react/event-loop", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/event-loop.git", - "reference": "ba276bda6083df7e0050fd9b33f66ad7a4ac747a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/ba276bda6083df7e0050fd9b33f66ad7a4ac747a", - "reference": "ba276bda6083df7e0050fd9b33f66ad7a4ac747a", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" - }, - "suggest": { - "ext-pcntl": "For signal handling support when using the StreamSelectLoop" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\EventLoop\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", - "keywords": [ - "asynchronous", - "event-loop" - ], - "support": { - "issues": "https://github.com/reactphp/event-loop/issues", - "source": "https://github.com/reactphp/event-loop/tree/v1.6.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2025-11-17T20:46:25+00:00" - }, - { - "name": "react/promise", - "version": "v3.3.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "23444f53a813a3296c1368bb104793ce8d88f04a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/23444f53a813a3296c1368bb104793ce8d88f04a", - "reference": "23444f53a813a3296c1368bb104793ce8d88f04a", - "shasum": "" - }, - "require": { - "php": ">=7.1.0" - }, - "require-dev": { - "phpstan/phpstan": "1.12.28 || 1.4.10", - "phpunit/phpunit": "^9.6 || ^7.5" - }, "type": "library", "autoload": { "files": [ - "src/functions_include.php" - ], - "psr-4": { - "React\\Promise\\": "src/" - } + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "homepage": "https://getrector.com/", "keywords": [ - "promise", - "promises" + "automation", + "dev", + "migration", + "refactoring" ], "support": { - "issues": "https://github.com/reactphp/promise/issues", - "source": "https://github.com/reactphp/promise/tree/v3.3.0" + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/2.6.7" }, "funding": [ { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" + "url": "https://github.com/tomasvotruba", + "type": "github" } ], - "time": "2025-08-19T18:57:03+00:00" + "time": "2026-09-13T20:17:44+00:00" }, { - "name": "react/socket", - "version": "v1.17.0", + "name": "roave/security-advisories", + "version": "dev-latest", "source": { "type": "git", - "url": "https://github.com/reactphp/socket.git", - "reference": "ef5b17b81f6f60504c539313f94f2d826c5faa08" + "url": "https://github.com/Roave/SecurityAdvisories.git", + "reference": "eddf5ff07ff44f9c121b404971f5577e81602779" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/socket/zipball/ef5b17b81f6f60504c539313f94f2d826c5faa08", - "reference": "ef5b17b81f6f60504c539313f94f2d826c5faa08", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/eddf5ff07ff44f9c121b404971f5577e81602779", + "reference": "eddf5ff07ff44f9c121b404971f5577e81602779", "shasum": "" }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.0", - "react/dns": "^1.13", - "react/event-loop": "^1.2", - "react/promise": "^3.2 || ^2.6 || ^1.2.1", - "react/stream": "^1.4" - }, - "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4.3 || ^3.3 || ^2", - "react/promise-stream": "^1.4", - "react/promise-timer": "^1.11" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Socket\\": "src/" - } + "conflict": { + "3f/pygmentize": "<1.2", + "adaptcms/adaptcms": "<=1.3", + "adawolfa/isdoc": "<1.4.3|>=1.5,<1.5.1|>=1.6,<1.6.1", + "admidio/admidio": "<=5.0.11", + "adodb/adodb-php": "<=5.22.9", + "aheinze/cockpit": "<2.2", + "aimeos/ai-admin-graphql": ">=2022.04.1,<2022.10.10|>=2023.04.1,<2023.10.6|>=2024.04.1,<2024.07.2", + "aimeos/ai-admin-jsonadm": "<2020.10.13|>=2021.04.1,<2021.10.6|>=2022.04.1,<2022.10.3|>=2023.04.1,<2023.10.4|==2024.04.1", + "aimeos/ai-client-html": ">=2020.04.1,<2020.10.27|>=2021.04.1,<2021.10.22|>=2022.04.1,<2022.10.13|>=2023.04.1,<2023.10.15|>=2024.04.1,<2024.04.7", + "aimeos/ai-cms-grapesjs": ">=2021.04.1,<2021.10.8|>=2022.04.1,<2022.10.9|>=2023.04.1,<2023.10.15|>=2024.04.1,<2024.10.8|>=2025.04.1,<2025.10.2", + "aimeos/ai-controller-frontend": "<2020.10.15|>=2021.04.1,<2021.10.8|>=2022.04.1,<2022.10.8|>=2023.04.1,<2023.10.9|==2024.04.1", + "aimeos/aimeos-core": ">=2022.04.1,<2022.10.17|>=2023.04.1,<2023.10.17|>=2024.04.1,<2024.04.7", + "aimeos/aimeos-laravel": "==2021.10", + "aimeos/aimeos-typo3": "<19.10.12|>=20,<20.10.5", + "aimeos/pagible": "<0.10.4", + "airesvsg/acf-to-rest-api": "<=3.1", + "akaunting/akaunting": "<2.1.13", + "akeneo/pim-community-dev": "<5.0.119|>=6,<6.0.53", + "alextselegidis/easyappointments": "<=1.5.2", + "alexusmai/laravel-file-manager": "<=3.3.1", + "algolia/algoliasearch-magento-2": "<=3.16.1|>=3.17.0.0-beta1,<=3.17.1", + "almirhodzic/nova-toggle-5": "<1.3", + "alt-design/alt-redirect": "<1.6.4", + "altcha-org/altcha": "<1.3.1", + "alterphp/easyadmin-extension-bundle": ">=1.2,<1.2.11|>=1.3,<1.3.1", + "amazing/media2click": ">=1,<1.3.3", + "ameos/ameos_tarteaucitron": "<1.2.23", + "amphp/artax": "<1.0.6|>=2,<2.0.6", + "amphp/http": "<=1.7.2|>=2,<=2.1", + "amphp/http-client": ">=4,<4.4", + "amphp/http-server": ">=2.0.0.0-RC1-dev,<2.1.10|>=3.0.0.0-beta1,<3.4.4", + "anchorcms/anchor-cms": "<=0.12.7", + "andreapollastri/cipi": "<=3.1.15", + "andrewhaine/silverstripe-form-capture": ">=0.2,<=0.2.3|>=1,<1.0.2|>=2,<2.2.5", + "aoe/restler": "<1.7.1", + "apache-solr-for-typo3/solr": "<11.6.6|>=12,<12.1.4|>=13,<13.1.4", + "apache/thrift": "<0.24", + "apereo/phpcas": "<1.6", + "api-platform/core": "<4.1.30|>=4.2,<4.2.26|>=4.3,<4.3.12", + "api-platform/graphql": "<3.4.17|>=4,<4.0.22|>=4.1,<4.1.5", + "api-platform/hal": ">=4,<4.1.29|>=4.2,<4.2.25|>=4.3,<4.3.8", + "api-platform/json-api": ">=4,<4.1.29|>=4.2,<4.2.25|>=4.3,<4.3.8", + "appwrite/server-ce": "<=1.2.1", + "arc/web": "<3", + "area17/twill": "<1.2.5|>=2,<2.5.3", + "artesaos/seotools": "<0.17.2", + "asymmetricrypt/asymmetricrypt": "<9.9.99", + "athlon1600/php-proxy": "<=5.1", + "athlon1600/php-proxy-app": "<=3", + "athlon1600/youtube-downloader": "<=4", + "aureuserp/aureuserp": "<1.3.0.0-beta1", + "austintoddj/canvas": "<=3.4.2", + "auth0/auth0-php": ">=3.3,<=8.18", + "auth0/login": "<=7.20", + "auth0/symfony": "<=5.8", + "auth0/wordpress": "<=5.5", + "automad/automad": "<=2.0.0.0-beta27", + "automattic/jetpack": "<9.8", + "awesome-support/awesome-support": "<=6.0.7", + "aws/aws-sdk-php": "<=3.371.3", + "ayacoo/redirect-tab": "<2.1.2|>=3,<3.1.7|>=4,<4.0.5", + "azuracast/azuracast": "<=0.23.5", + "b13/seo_basics": "<0.8.2", + "backdrop/backdrop": "<=1.32", + "backpack/crud": "<6.8.15|>=7,<7.0.47", + "backpack/filemanager": "<2.0.2|>=3,<3.0.9", + "bacula-web/bacula-web": "<9.7.1", + "badaso/core": "<=2.9.11", + "bagisto/bagisto": "<=2.3.15", + "barrelstrength/sprout-base-email": "<1.2.7", + "barrelstrength/sprout-forms": "<3.9", + "barryvdh/laravel-translation-manager": "<0.6.8", + "barzahlen/barzahlen-php": "<2.0.1", + "baserproject/basercms": "<=5.2.2", + "bassjobsen/bootstrap-3-typeahead": ">4.0.2", + "bbpress/bbpress": "<2.6.5", + "bcit-ci/codeigniter": "<3.1.3", + "bcosca/fatfree": "<3.7.2", + "bedita/bedita": "<4", + "bednee/cooluri": "<1.0.30", + "bigfork/silverstripe-form-capture": ">=3,<3.1.1", + "billabear/billabear": "<=2025.01.03", + "billz/raspap-webgui": "<3.3.6", + "binarytorch/larecipe": "<2.8.1", + "bk2k/bootstrap-package": ">=7.1,<7.1.2|>=8,<8.0.8|>=9,<9.0.4|>=9.1,<9.1.3|>=10,<10.0.10|>=11,<11.0.3", + "blueimp/jquery-file-upload": "==6.4.4", + "bmarshall511/wordpress_zero_spam": "<5.2.13", + "bolt/bolt": "<3.7.2", + "bolt/core": "<=4.2", + "born05/craft-twofactorauthentication": "<3.3.4", + "bottelet/flarepoint": "<2.2.1", + "bref/bref": "<2.1.17", + "brightlocal/phpwhois": "<=4.2.5", + "brotkrueml/codehighlight": "<2.7", + "brotkrueml/schema": "<1.13.1|>=2,<2.5.1", + "brotkrueml/typo3-matomo-integration": "<1.3.2", + "buddypress/buddypress": "<14.5", + "bugsnag/bugsnag-laravel": ">=2,<2.0.2", + "bvbmedia/multishop": "<2.0.39", + "bytefury/crater": "<6.0.2", + "cachethq/cachet": "<2.5.1", + "cadmium-org/cadmium-cms": "<=0.4.9", + "cakephp/authentication": "<2.11.1|>=3,<3.3.6|>=4,<4.1.1", + "cakephp/cakephp": "<4.5.12|>=4.6,<4.6.5|>=5,<5.1.10|>=5.2,<5.2.15|>=5.3,<5.3.7", + "cakephp/database": ">=4.2,<4.2.12|>=4.3,<4.3.11|>=4.4,<4.4.10|>=5.1,<5.1.10|>=5.2,<5.2.15|>=5.3,<5.3.7", + "cakephp/debug_kit": "<4.10.3|>=5,<5.2.4", + "cakephp/queue": ">=0.1.10,<2.3.1", + "cardgate/magento2": "<2.0.33", + "cardgate/woocommerce": "<=3.1.15", + "cart2quote/module-quotation": ">=4.1.6,<4.4.6|>=5,<5.4.4", + "cart2quote/module-quotation-encoded": ">=4.1.6,<=4.4.5|>=5,<5.4.4", + "cartalyst/sentry": "<2.1.7", + "catfan/medoo": "<1.7.5", + "causal/oidc": "<4", + "cecil/cecil": "<7.47.1", + "centreon/centreon": "<22.10.15", + "cesargb/laravel-magiclink": ">=2,<2.25.1", + "cesnet/simplesamlphp-module-proxystatistics": "<3.1", + "chriskacerguis/codeigniter-restserver": "<=2.7.1", + "chrome-php/chrome": "<1.14", + "ci4-cms-erp/ci4ms": "<=0.31.8", + "civicrm/civicrm-core": ">=4.2,<4.2.9|>=4.3,<4.3.3", + "ckeditor/ckeditor": "<4.25", + "clickstorm/cs-seo": ">=6,<6.8|>=7,<7.5|>=8,<8.4|>=9,<9.3", + "co-stack/fal_sftp": "<0.2.6", + "cockpit-hq/cockpit": "<=2.14", + "code16/sharp": "<9.22.3", + "codeception/codeception": "<3.1.3|>=4,<4.1.22", + "codeigniter/framework": "<3.1.10", + "codeigniter4/framework": "<4.7.4", + "codeigniter4/shield": "<1.0.0.0-beta8", + "codiad/codiad": "<=2.8.4", + "codingms/additional-tca": ">=1.7,<1.15.17|>=1.16,<1.16.9", + "codingms/modules": "<7.10.4|>=8,<8.1.4", + "commerceteam/commerce": ">=0.9.6,<0.9.9", + "components/jquery": ">=1.0.3,<3.5", + "composer/composer": "<2.2.30|>=2.3,<2.10.3", + "concrete5/concrete5": "<9.5.2", + "concrete5/core": "<8.5.8|>=9,<9.1", + "contao-components/colorbox": ">=1,<1.6.4.3-dev", + "contao-components/mediaelement": ">=2.14.2,<2.21.1", + "contao/comments-bundle": ">=2,<5.3.50|>=5.4,<5.7.12", + "contao/contao": ">=3,<3.5.37|>=4,<5.3.50|>=5.4,<5.7.12", + "contao/core": "<3.5.39", + "contao/core-bundle": "<5.3.50|>=5.4,<5.7.12", + "contao/listing-bundle": ">=3,<=3.5.30|>=4,<4.4.8", + "contao/managed-edition": "<=1.5", + "contao/newsletter-bundle": ">=5,<5.3.50|>=5.4,<5.7.12", + "coreshop/core-shop": "<4.1.9|==5", + "corveda/phpsandbox": "<1.3.5", + "cosenary/instagram": "<=2.3", + "cotonti/cotonti": "<=1", + "couleurcitron/tarteaucitron-wp": "<0.3", + "cpsit/typo3-mailqueue": "<0.4.5|>=0.5,<0.5.2", + "craftcms/aws-s3": ">=2.0.2,<=2.2.4", + "craftcms/azure-blob": ">=2.0.0.0-beta1,<=2.1", + "craftcms/cms": "<4.18.3|>=5,<5.10.8", + "craftcms/commerce": ">=4,<=4.11.1|>=5,<=5.6.4", + "craftcms/composer": ">=4.0.0.0-RC1-dev,<=4.10|>=5.0.0.0-RC1-dev,<=5.5.1", + "craftcms/craft": ">=3.5,<=4.16.17|>=5.0.0.0-RC1-dev,<=5.8.21", + "craftcms/google-cloud": ">=2.0.0.0-beta1,<=2.2", + "craftcms/webhooks": ">=3,<3.2", + "croogo/croogo": "<=4.0.7", + "cuyz/valinor": "<0.12", + "czim/file-handling": "<1.5|>=2,<2.3", + "czproject/git-php": "<4.0.3", + "damienharper/auditor-bundle": "<5.2.6", + "dapphp/securimage": "<3.6.6", + "darylldoyle/safe-svg": "<1.9.10", + "datadog/dd-trace": ">=0.30,<0.30.2", + "datahihi1/tiny-env": "<1.0.3|>=1.0.9,<1.0.11", + "datatables/datatables": "<1.10.10", + "david-garcia/phpwhois": "<=4.3.1", + "dbrisinajumi/d2files": "<1", + "dcat/laravel-admin": "<=2.1.3|==2.2.0.0-beta|==2.2.2.0-beta", + "dedoc/scramble": ">=0.13.2,<0.13.22", + "derhansen/fe_change_pwd": "<2.0.5|>=3,<3.0.3", + "derhansen/sf_event_mgt": "<5.9.3|>=6,<6.7.2|>=7,<7.9.3|>=8,<8.6.2|>=9,<9.0.3", + "desperado/xml-bundle": "<=0.1.7", + "dev-lancer/minecraft-motd-parser": "<=1.0.5", + "devcode-it/openstamanager": "<=2.10.1", + "devgroup/dotplant": "<2020.09.14-dev", + "digimix/wp-svg-upload": "<=1", + "directmailteam/direct-mail": "<6.0.3|>=7,<7.0.3|>=8,<9.5.2", + "directorytree/imapengine": "<1.22.3", + "dl/yag": "<3.0.1", + "dmk/webkitpdf": "<1.1.4", + "dnadesign/silverstripe-elemental": "<5.3.12", + "doctrine/annotations": "<1.2.7", + "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", + "doctrine/common": "<2.4.3|>=2.5,<2.5.1", + "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2|>=3,<3.1.4", + "doctrine/doctrine-bundle": "<1.5.2", + "doctrine/doctrine-module": "<0.7.2", + "doctrine/mongodb-odm": "<1.0.2", + "doctrine/mongodb-odm-bundle": "<3.0.1", + "doctrine/orm": ">=1,<1.2.4|>=2,<2.4.8|>=2.5,<2.5.1|>=2.8.3,<2.8.4", + "dolibarr/dolibarr": "<=23.0.2", + "dompdf/dompdf": "<3.1.6", + "doublethreedigital/guest-entries": "<3.1.2", + "dreamfactory/df-core": "<1.0.4", + "drupal-pattern-lab/unified-twig-extensions": "<=0.1", + "drupal/access_code": "<2.0.5", + "drupal/acquia_dam": "<1.1.5", + "drupal/admin_audit_trail": "<1.0.5", + "drupal/ai": "<1.0.5", + "drupal/alogin": "<2.0.6", + "drupal/cache_utility": "<1.2.1", + "drupal/civictheme": "<1.12", + "drupal/commerce_alphabank_redirect": "<1.0.3", + "drupal/commerce_eurobank_redirect": "<2.1.1", + "drupal/config_split": "<1.10|>=2,<2.0.2", + "drupal/core": ">=6,<6.38|>=7,<7.103|>=8,<10.5.10|>=10.6,<10.6.9|>=11,<11.2.12|>=11.3,<11.3.10", + "drupal/core-recommended": ">=7,<7.102|>=8,<10.2.11|>=10.3,<10.3.9|>=11,<11.0.8", + "drupal/currency": "<3.5", + "drupal/drupal": ">=5,<5.11|>=6,<6.38|>=7,<7.102|>=8,<10.2.11|>=10.3,<10.3.9|>=11,<11.0.8", + "drupal/email_tfa": "<2.0.6", + "drupal/formatter_suite": "<2.1", + "drupal/gdpr": "<3.0.1|>=3.1,<3.1.2", + "drupal/google_tag": "<1.8|>=2,<2.0.8", + "drupal/ignition": "<1.0.4", + "drupal/json_field": "<1.5", + "drupal/lightgallery": "<1.6", + "drupal/link_field_display_mode_formatter": "<1.6", + "drupal/matomo": "<1.24", + "drupal/oauth2_client": "<4.1.3", + "drupal/oauth2_server": "<2.1", + "drupal/obfuscate": "<2.0.1", + "drupal/plausible_tracking": "<1.0.2", + "drupal/quick_node_block": "<2", + "drupal/rapidoc_elements_field_formatter": "<1.0.1", + "drupal/reverse_proxy_header": "<1.1.2", + "drupal/simple_multistep": "<2", + "drupal/simple_oauth": ">=6,<6.0.7", + "drupal/spamspan": "<3.2.1", + "drupal/tfa": "<1.10", + "drupal/umami_analytics": "<1.0.1", + "duncanmcclean/guest-entries": "<3.1.2", + "dweeves/magmi": "<=0.7.24", + "easycorp/easyadmin-bundle": ">=4,<4.29.16|>=5,<5.5.1", + "ec-cube/ec-cube": "<2.4.4|>=2.11,<=2.17.1|>=3,<=3.0.18.0-patch4|>=4,<=4.3.1", + "ecodev/newsletter": "<=4", + "ectouch/ectouch": "<=2.7.2", + "egroupware/egroupware": "<23.1.20260601|>=26.0.20251208,<26.5.20260507", + "elefant/cms": "<2.0.7", + "elgg/elgg": "<3.3.24|>=4,<4.0.5", + "elijaa/phpmemcacheadmin": "<=1.3", + "elmsln/haxcms": "<11.0.14", + "encore/laravel-admin": "<=1.8.19", + "endroid/qr-code-bundle": "<3.4.2", + "enhavo/enhavo-app": "<=0.13.1", + "enshrined/svg-sanitize": "<0.22", + "erusev/parsedown": "<1.7.2", + "ether/logs": "<3.0.4", + "evolutioncms/evolution": "<=3.2.3", + "evoweb/sf-register": "<13.2.4|>=14,<14.0.2", + "exceedone/exment": "<4.4.3|>=5,<5.0.3", + "exceedone/laravel-admin": "<2.2.3|==3", + "ezsystems/demobundle": ">=5.4,<5.4.6.1-dev", + "ezsystems/ez-support-tools": ">=2.2,<2.2.3", + "ezsystems/ezdemo-ls-extension": ">=5.4,<5.4.2.1-dev", + "ezsystems/ezfind-ls": ">=5.3,<5.3.6.1-dev|>=5.4,<5.4.11.1-dev|>=2017.12,<2017.12.0.1-dev", + "ezsystems/ezplatform": "<=1.13.6|>=2,<=2.5.24", + "ezsystems/ezplatform-admin-ui": ">=1.3,<1.3.5|>=1.4,<1.4.6|>=1.5,<1.5.29|>=2.3,<2.3.39|>=3.3,<3.3.39", + "ezsystems/ezplatform-admin-ui-assets": ">=4,<4.2.1|>=5,<5.0.1|>=5.1,<5.1.1|>=5.3.0.0-beta1,<5.3.5", + "ezsystems/ezplatform-graphql": ">=1.0.0.0-RC1-dev,<1.0.13|>=2.0.0.0-beta1,<2.3.12", + "ezsystems/ezplatform-http-cache": "<2.3.16", + "ezsystems/ezplatform-kernel": "<=1.2.5|>=1.3,<1.3.35", + "ezsystems/ezplatform-rest": ">=1.2,<=1.2.2|>=1.3,<1.3.8", + "ezsystems/ezplatform-richtext": ">=2.3,<2.3.26|>=3.3,<3.3.40", + "ezsystems/ezplatform-solr-search-engine": ">=1.7,<1.7.12|>=2,<2.0.2|>=3.3,<3.3.15", + "ezsystems/ezplatform-user": ">=1,<1.0.1", + "ezsystems/ezpublish-kernel": "<=6.13.8.1|>=7,<7.5.31", + "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.6,<=2019.03.5.1", + "ezsystems/platform-ui-assets-bundle": ">=4.2,<4.2.3", + "ezsystems/repository-forms": ">=2.3,<2.3.2.1-dev|>=2.5,<2.5.15", + "ezyang/htmlpurifier": "<=4.2", + "facade/ignition": "<1.16.15|>=2,<2.4.2|>=2.5,<2.5.2", + "facturascripts/facturascripts": "<=2026.2", + "fastly/magento2": "<1.2.26", + "feehi/cms": "<=2.1.1", + "feehi/feehicms": "<=2.1.1", + "fenom/fenom": "<=2.12.1", + "filament/actions": ">=3.2,<3.2.123|>=4,<=4.11.3|>=5,<=5.6.3", + "filament/filament": ">=3,<=3.3.51|>=4,<4.12.6|>=5,<5.7.6", + "filament/forms": ">=3,<=3.3.52", + "filament/infolists": ">=3,<3.2.115|>=4,<=4.11.4|>=5,<=5.6.4", + "filament/tables": ">=3,<=3.3.50|>=4,<=4.11.4|>=5,<=5.6.4", + "filegator/filegator": "<7.8", + "filp/whoops": "<2.1.13", + "fineuploader/php-traditional-server": "<=1.2.2", + "firebase/php-jwt": "<7", + "fisharebest/webtrees": "<=2.1.18", + "fixpunkt/fp-masterquiz": "<2.2.1|>=3,<3.5.2", + "fixpunkt/fp-newsletter": "<1.1.1|>=1.2,<2.1.2|>=2.2,<3.2.6", + "flarum/core": "<=1.8.15|>=2.0.0.0-beta1,<=2.0.0.0-beta8", + "flarum/flarum": "<0.1.0.0-beta8", + "flarum/framework": "<1.8.10", + "flarum/mentions": "<1.6.3", + "flarum/nicknames": "<1.8.3", + "flarum/sticky": ">=0.1.0.0-beta14,<=0.1.0.0-beta15", + "flarum/tags": "<=0.1.0.0-beta13", + "flightphp/core": "<3.18.1", + "floriangaerber/magnesium": "<0.3.1", + "fluidtypo3/vhs": "<5.1.1", + "fof/byobu": ">=0.3.0.0-beta2,<1.1.7", + "fof/pretty-mail": "<=1.1.2", + "fof/upload": "<1.2.3", + "foodcoopshop/foodcoopshop": ">=3.2,<3.6.1", + "fooman/tcpdf": "<6.2.22", + "forkcms/forkcms": "<5.11.1", + "fossar/tcpdf-parser": "<6.2.22", + "francoisjacquet/rosariosis": "<=11.5.1", + "frappant/frp-form-answers": "<5.0.5|>=6,<6.1.3|>=7,<7.1.1", + "friendsofsymfony/oauth2-php": "<1.3", + "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", + "friendsofsymfony/user-bundle": ">=1,<1.3.5", + "friendsofsymfony1/swiftmailer": ">=4,<5.4.13|>=6,<6.2.5", + "friendsofsymfony1/symfony1": ">=1.1,<1.5.19", + "friendsoftypo3/mediace": ">=7.6.2,<7.6.5", + "friendsoftypo3/openid": ">=4.5,<4.5.31|>=4.7,<4.7.16|>=6,<6.0.11|>=6.1,<6.1.6", + "friendsoftypo3/tt-address": "<8.1.2|>=9,<9.1.1|>=10,<10.0.1", + "froala/wysiwyg-editor": "<=4.3", + "frosh/adminer-platform": "<2.2.1", + "froxlor/froxlor": "<2.3.8", + "frozennode/administrator": "<=5.0.12", + "fuel/core": "<1.8.1", + "funadmin/funadmin": "<=7.1.0.0-RC6", + "gaoming13/wechat-php-sdk": "<=1.10.2", + "genix/cms": "<=1.1.11", + "georgringer/news": "<10.0.4|>=11,<11.4.4|>=12,<12.3.2|>=13,<13.0.2|>=14,<14.0.3", + "geshi/geshi": "<=1.0.9.1", + "getformwork/formwork": "<=2.3.3", + "getgrav/grav": "<=2.0.19", + "getgrav/grav-plugin-api": "<1.0.0.0-beta15", + "getgrav/grav-plugin-form": "<9.1", + "getkirby/cms": "<4.9.5|>=5,<5.5.2", + "getkirby/kirby": "<3.9.8.3-dev|>=3.10,<3.10.1.2-dev|>=4,<4.7.1", + "getkirby/panel": "<2.5.14", + "getkirby/starterkit": "<=3.7.0.2", + "gilacms/gila": "<=1.15.4", + "gleez/cms": "<=1.3|==2", + "globalpayments/php-sdk": "<2", + "goalgorilla/open_social": "<12.3.11|>=12.4,<12.4.10|>=13.0.0.0-alpha1,<13.0.0.0-alpha11", + "gogentooss/samlbase": "<1.2.7", + "goodoneuz/pay-uz": "<=2.2.24", + "google/protobuf": "<4.33.6", + "gos/web-socket-bundle": "<1.10.4|>=2,<2.6.1|>=3,<3.3", + "gp247/core": "<1.1.24", + "gree/jose": "<2.2.1", + "gregwar/rst": "<1.0.3", + "grumpydictator/firefly-iii": "<=6.6.2", + "gugoan/economizzer": "<=0.9.0.0-beta1", + "guzzlehttp/guzzle": "<7.15.2|>=8,<8.0.1", + "guzzlehttp/guzzle-services": "<1.5.4", + "guzzlehttp/oauth-subscriber": "<0.8.1", + "guzzlehttp/psr7": "<2.12.3", + "haffner/jh_captcha": "<=2.1.3|>=3,<=3.0.2", + "handcraftedinthealps/goodby-csv": "<1.4.3", + "harvesthq/chosen": "<1.8.7", + "helloxz/imgurl": "<=2.31", + "hhxsv5/laravel-s": "<3.7.36", + "hillelcoren/invoice-ninja": "<5.3.35", + "himiklab/yii2-jqgrid-widget": "<1.0.8", + "hjue/justwriting": "<=1", + "hov/jobfair": "<1.0.13|>=2,<2.0.2", + "httpsoft/http-message": "<1.0.12", + "hybridauth/hybridauth": "<=3.12.2", + "hyn/multi-tenant": ">=5.6,<5.7.2", + "ibexa/admin-ui": ">=4.2,<4.2.3|>=4.6,<4.6.25|>=5,<5.0.3", + "ibexa/admin-ui-assets": ">=4.6.0.0-alpha1,<4.6.21", + "ibexa/core": ">=4,<4.0.7|>=4.1,<4.1.4|>=4.2,<4.2.3|>=4.5,<4.5.6|>=4.6,<4.6.2", + "ibexa/fieldtype-richtext": ">=4.6,<4.6.25|>=5,<5.0.3", + "ibexa/graphql": ">=2.5,<2.5.31|>=3.3,<3.3.28|>=4.2,<4.2.3", + "ibexa/http-cache": ">=4.6,<4.6.14", + "ibexa/post-install": "<1.0.16|>=4.6,<4.6.14", + "ibexa/solr": ">=4.5,<4.5.4", + "ibexa/user": ">=4,<4.4.3|>=5,<5.0.4", + "icecoder/icecoder": "<=8.1", + "idno/known": "<1.6.4", + "ilicmiljan/secure-props": ">=1.2,<1.2.2", + "illuminate/auth": "<5.5.10", + "illuminate/cookie": ">=4,<=4.0.11|>=4.1,<6.18.31|>=7,<7.22.4", + "illuminate/database": "<6.20.26|>=7,<7.30.5|>=8,<8.40", + "illuminate/encryption": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", + "illuminate/mail": ">=9,<12.60|>=13,<13.10", + "illuminate/view": "<6.20.42|>=7,<7.30.6|>=8,<8.75", + "imdbphp/imdbphp": "<=5.1.1", + "impresscms/impresscms": "<=1.4.5", + "impresspages/impresspages": "<1.0.13", + "in2code/femanager": "<6.4.5|>=7,<7.5.5|>=8,<8.4.2|>=13,<13.3.5", + "in2code/ipandlanguageredirect": "<5.1.2", + "in2code/lux": "<17.6.1|>=18,<24.0.2", + "in2code/powermail": "<10.9.3|>=11,<12.6.1|>=13,<13.2.1", + "innologi/typo3-appointments": "<2.0.6", + "intelliants/subrion": "<4.2.2", + "inter-mediator/inter-mediator": "==5.5", + "intercom/intercom-php": "==5.0.2", + "invoiceninja/invoiceninja": "<5.13.4", + "ipl/web": "<=0.10.2|>=0.11,<=0.13", + "islandora/crayfish": "<4.1", + "islandora/islandora": ">=2,<2.4.1", + "ivankristianto/phpwhois": "<=4.3", + "j0k3r/graby": "<=2.5", + "jackalope/jackalope-doctrine-dbal": "<1.7.4", + "jambagecom/div2007": "<0.10.2", + "james-heinrich/getid3": "<1.9.21", + "james-heinrich/phpthumb": "<=1.7.23", + "jasig/phpcas": "<1.3.3", + "jbartels/wec-map": "<3.0.3", + "jcbrand/converse.js": "<3.3.3", + "jleehr/canto-saas-api": "<=2", + "joedolson/my-calendar": "<3.7.7", + "joelbutcher/socialstream": "<5.6|>=6,<6.2", + "johnbillion/query-monitor": "<3.20.4", + "johnbillion/wp-crontrol": "<1.16.2|>=1.17,<1.19.2", + "joomla/application": "<1.0.13", + "joomla/archive": "<1.1.12|>=2,<2.0.1", + "joomla/database": ">=1,<2.2|>=3,<3.4", + "joomla/filesystem": "<1.6.2|>=2,<2.0.1", + "joomla/filter": "<2.0.6|>=3,<3.0.5|==4", + "joomla/framework": "<1.5.7|>=2.5.4,<=3.8.12", + "joomla/input": ">=2,<2.0.2", + "joomla/joomla-cms": "<3.9.12|>=4,<4.4.13|>=5,<5.2.6", + "joomla/joomla-platform": "<1.5.4", + "joomla/session": "<1.3.1", + "joyqi/hyper-down": "<=2.4.27", + "jsdecena/laracom": "<2.0.9", + "jsmitty12/phpwhois": "<5.1", + "juzaweb/cms": "<=3.4.2", + "jweiland/clubdirectory": "<6.0.2|>=7,<7.0.2|>=8,<8.1.3", + "jweiland/events2": "<8.6.3|>=9,<9.4.2|>=10,<10.2.12", + "jweiland/kk-downloader": "<1.2.2", + "jweiland/pforum": "<4.0.4|>=5,<5.0.1|>=6,<6.2.4", + "jweiland/telephonedirectory": "<4.1.1|>=5,<5.0.1|>=6,<6.2", + "jweiland/yellowpages2": "<6.1.6|>=7,<7.0.3|>=8,<8.1.2", + "kantorge/yaffa": "<=2", + "kazist/phpwhois": "<=4.2.6", + "kelvinmo/simplejwt": "<=1.1", + "kelvinmo/simplexrd": "<3.1.1", + "kevinpapst/kimai2": "<1.16.7", + "khodakhah/nodcms": "<=3.4.1", + "kimai/kimai": "<2.59", + "kitodo/presentation": "<3.2.3|>=3.3,<3.3.4", + "klaviyo/magento2-extension": ">=1,<3", + "knplabs/knp-snappy": "<=1.7", + "kohana/core": "<3.3.3", + "koillection/koillection": "<1.8.4", + "krayin/laravel-crm": "<=2.2", + "kreait/firebase-php": ">=3.2,<3.8.1", + "kumbiaphp/kumbiapp": "<=1.1.1", + "la-haute-societe/tcpdf": "<6.2.22", + "laktak/hjson": "<2.3", + "laminas/laminas-diactoros": "<2.18.1|==2.19|==2.20|==2.21|==2.22|==2.23|>=2.24,<2.24.2|>=2.25,<2.25.2", + "laminas/laminas-form": "<2.17.1|>=3,<3.0.2|>=3.1,<3.1.1", + "laminas/laminas-http": "<2.14.2", + "lara-zeus/artemis": ">=1,<=1.0.6", + "lara-zeus/dynamic-dashboard": ">=3,<=3.0.1", + "laravel/fortify": "<1.11.1", + "laravel/framework": "<12.61.1|>=13,<13.12", + "laravel/laravel": ">=5.4,<5.4.22", + "laravel/passport": ">=13,<13.7.1", + "laravel/pulse": "<1.3.1", + "laravel/reverb": "<1.7", + "laravel/socialite": ">=1,<2.0.10", + "latte/latte": "<2.10.8", + "lavalite/cms": "<=10.1", + "lavitto/typo3-form-to-database": "<2.2.5|>=3,<3.2.2|>=4,<4.2.3|>=5,<5.0.2", + "lcobucci/jwt": ">=3.4,<3.4.6|>=4,<4.0.4|>=4.1,<4.1.5", + "league/commonmark": "<2.10", + "league/flysystem": "<1.1.4|>=2,<2.1.1", + "league/oauth2-server": ">=8.3.2,<8.4.2|>=8.5,<8.5.3", + "leantime/leantime": "<3.3", + "lexik/jwt-authentication-bundle": "<2.10.7|>=2.11,<2.11.3", + "libreform/libreform": ">=2,<=2.0.8", + "librenms/librenms": "<26.7", + "liftkit/database": "<2.13.2", + "lightsaml/lightsaml": "<1.3.5", + "limesurvey/limesurvey": "<=7.0.0.0-beta1", + "livehelperchat/livehelperchat": "<=3.91", + "livewire-filemanager/filemanager": "<=1.0.4", + "livewire/livewire": "<2.12.7|>=3.0.0.0-beta1,<=3.8.2|>=4.0.0.0-beta1,<=4.3.3", + "livewire/volt": "<1.7", + "lms/routes": "<2.1.1", + "localizationteam/l10nmgr": "<7.4|>=8,<8.7|>=9,<9.2", + "lochmueller/html5videoplayer-powermail": "<=0.2.1", + "lomkit/laravel-rest-api": "<2.13", + "luracast/restler": "<3.1", + "luyadev/yii-helpers": "<1.2.1", + "maatwebsite/excel": ">=3.1.8,<3.1.70", + "macropay-solutions/laravel-crud-wizard-free": "<3.4.17", + "maestroerror/php-heic-to-jpg": "<1.0.5", + "magento/community-edition": "<2.4.6.0-patch13|>=2.4.7.0-beta1,<2.4.7.0-patch8|>=2.4.8.0-beta1,<2.4.8.0-patch3|>=2.4.9.0-alpha1,<2.4.9.0-alpha3|==2.4.9", + "magento/core": "<=1.9.4.5", + "magento/magento1ce": "<1.9.4.3-dev", + "magento/magento1ee": ">=1,<1.14.4.3-dev", + "magento/product-community-edition": "<2.4.4.0-patch9|>=2.4.5,<2.4.5.0-patch8|>=2.4.6,<2.4.6.0-patch6|>=2.4.7,<2.4.7.0-patch1", + "magento/project-community-edition": "<=2.0.2", + "magneto/core": "<1.9.4.4-dev", + "mahocommerce/maho": "<25.9", + "maikuolan/phpmussel": ">=1,<1.6", + "mainwp/mainwp": "<=4.4.3.3", + "manogi/nova-tiptap": "<=3.2.6", + "mantisbt/mantisbt": "<=2.28.3", + "marcwillmann/turn": "<0.3.3", + "markhuot/craftql": "<=1.3.7", + "marshmallow/nova-tiptap": "<5.7", + "mask/mask": "<8.3.12|>=9,<9.0.11", + "matomo/matomo": "<1.11", + "matyhtf/framework": "<3.0.6", + "mautic/core": "<5.2.11|>=6,<6.0.9|>=7,<7.1.2", + "mautic/core-lib": ">=1.0.0.0-beta,<4.4.13|>=5.0.0.0-alpha,<5.1.1", + "mautic/grapes-js-builder-bundle": ">=4,<4.4.18|>=5,<5.2.9|>=6,<6.0.7", + "maximebf/debugbar": "<1.19", + "mckenziearts/livewire-markdown-editor": "<1.3", + "mcp/sdk": ">=0.5,<0.7.1", + "mdanter/ecc": "<2", + "mediawiki/abuse-filter": "<1.39.9|>=1.40,<1.41.3|>=1.42,<1.42.2", + "mediawiki/cargo": "<3.8.3", + "mediawiki/core": "<1.39.5|==1.40", + "mediawiki/data-transfer": ">=1.39,<1.39.11|>=1.41,<1.41.3|>=1.42,<1.42.2", + "mediawiki/maps": "<12.1.3", + "mediawiki/matomo": "<2.4.3", + "mediawiki/semantic-media-wiki": "<4.0.2", + "mehrwert/phpmyadmin": "<3.2", + "melisplatform/melis-asset-manager": "<5.0.1", + "melisplatform/melis-cms": "<5.3.4", + "melisplatform/melis-cms-slider": "<5.3.1", + "melisplatform/melis-core": "<5.3.11", + "melisplatform/melis-front": "<5.0.1", + "mezzio/mezzio-swoole": "<3.7|>=4,<4.3", + "mgallegos/laravel-jqgrid": "<=1.3", + "microsoft/microsoft-graph": ">=1.16,<1.109.1|>=2,<2.0.1", + "microsoft/microsoft-graph-beta": "<2.0.1", + "microsoft/microsoft-graph-core": "<2.0.2", + "microweber/microweber": "<=2.0.20", + "mikehaertl/php-shellcommand": "<1.6.1", + "mineadmin/mineadmin": "<3.2.0.0-alpha2", + "miniorange/miniorange-saml": "<1.4.3", + "miraheze/ts-portal": "<=33", + "mittwald/typo3_forum": "<1.2.1", + "mix/mix": ">=2,<=2.2.17", + "mmc/ceselector": "<3.0.3|>=4,<4.0.2|>=5,<5.0.1|>=6,<6.0.1", + "mobiledetect/mobiledetectlib": "<2.8.32", + "modx/revolution": "<=3.1", + "mojo42/jirafeau": "<4.4", + "mongodb/mongodb": "<1.21.4|>=2,<2.4.1", + "mongodb/mongodb-extension": "<1.21.2", + "monolog/monolog": ">=1.8,<1.12", + "moodle/moodle": "<4.5.9|>=5.0.0.0-beta,<5.0.5|>=5.1.0.0-beta,<5.1.2", + "moonshine/moonshine": "<=3.12.5", + "mos/cimage": "<0.7.19", + "movim/moxl": ">=0.8,<=0.10", + "movingbytes/social-network": "<=1.2.1", + "mpdf/mpdf": "<=7.1.7", + "mtdowling/jmespath.php": "<2.9.1", + "munkireport/comment": "<4", + "munkireport/managedinstalls": "<2.6", + "munkireport/munki_facts": "<1.5", + "munkireport/reportdata": "<3.5", + "munkireport/softwareupdate": "<1.6", + "mustache/mustache": ">=2,<2.14.1", + "mwdelaney/wp-enable-svg": "<=0.2", + "nabeel/phpvms": "<7.0.6", + "namshi/jose": "<2.2", + "nasirkhan/laravel-starter": "<11.11", + "nategood/httpful": "<1", + "neoan3-apps/template": "<1.1.1", + "neorazorx/facturascripts": "<2022.04", + "neos/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", + "neos/form": ">=1.2,<4.3.3|>=5,<5.0.9|>=5.1,<5.1.3", + "neos/media-browser": "<7.3.19|>=8,<8.0.16|>=8.1,<8.1.11|>=8.2,<8.2.11|>=8.3,<8.3.9", + "neos/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<5.3.10|>=7,<7.0.9|>=7.1,<7.1.7|>=7.2,<7.2.6|>=7.3,<7.3.4|>=8,<8.0.2", + "neos/swiftmailer": "<5.4.5", + "nesbot/carbon": "<2.72.6|>=3,<3.8.4", + "netcarver/textile": "<=4.1.2", + "netgen/tagsbundle": ">=3.4,<3.4.11|>=4,<4.0.15", + "nette/application": ">=2,<2.0.19|>=2.1,<2.1.13|>=2.2,<2.2.10|>=2.3,<2.3.14|>=2.4,<2.4.16|>=3,<3.0.6", + "nette/nette": ">=2,<2.0.19|>=2.1,<2.1.13", + "neuron-core/neuron-ai": "<=2.8.11", + "nilsteampassnet/teampass": "<3.1.3.1-dev", + "nitsan/ns-backup": "<13.0.1", + "nonfiction/nterchange": "<4.1.1", + "notrinos/notrinos-erp": "<=1", + "noumo/easyii": "<=0.9", + "novaksolutions/infusionsoft-php-sdk": "<1", + "novosga/novosga": "<=2.2.12", + "nukeviet/nukeviet": "<4.6.00", + "nyholm/psr7": "<1.6.1", + "nystudio107/craft-seomatic": "<3.4.12", + "nzedb/nzedb": "<0.8", + "nzo/url-encryptor-bundle": ">=4,<4.3.2|>=5,<5.0.1", + "october/backend": "<1.1.2", + "october/cms": "<1.0.469|==1.0.469|==1.0.471|==1.1.1", + "october/october": "<3.7.14|>=4,<4.1.10|>=4.3,<4.3.4", + "october/rain": "<=3.7.13|>=4,<=4.1.9", + "october/system": "<3.7.17|>=4,<4.2.23", + "oliverklee/phpunit": "<3.5.15", + "omeka/omeka-s": "<4.0.3", + "onelogin/php-saml": "<2.21.1|>=3,<3.8.1|>=4,<4.3.1", + "oneup/uploader-bundle": ">=1,<1.9.3|>=2,<2.1.5", + "open-web-analytics/open-web-analytics": "<1.8.1", + "opencart/opencart": ">=0", + "openid/php-openid": "<2.3", + "openmage/magento-lts": "<=20.17", + "opensolutions/vimbadmin": "<=3.0.15", + "opensource-workshop/connect-cms": "<1.41.1|>=2,<2.41.1", + "orchid/platform": ">=8,<14.43", + "oro/calendar-bundle": ">=4.2,<=4.2.6|>=5,<=5.0.6|>=5.1,<5.1.1", + "oro/commerce": ">=4.1,<5.0.11|>=5.1,<5.1.1", + "oro/crm": ">=1.7,<1.7.4|>=3.1,<4.1.17|>=4.2,<4.2.7", + "oro/crm-call-bundle": ">=4.2,<=4.2.5|>=5,<5.0.4|>=5.1,<5.1.1", + "oro/customer-portal": ">=4.1,<=4.1.13|>=4.2,<=4.2.10|>=5,<=5.0.11|>=5.1,<=5.1.3", + "oro/platform": ">=1.7,<1.7.4|>=3.1,<3.1.29|>=4.1,<4.1.17|>=4.2,<=4.2.10|>=5,<=5.0.12|>=5.1,<=5.1.3", + "oveleon/contao-cookiebar": "<1.16.3|>=2,<2.1.3", + "oxid-esales/oxideshop-ce": "<4.5|>=6,<6.14.4", + "oxid-esales/oxideshop-metapackage-ce": ">=6,<6.5.5", + "oxid-esales/paymorrow-module": ">=1,<1.0.2|>=2,<2.0.1", + "oxid-esales/smarty-component": "<1.0.1", + "packbackbooks/lti-1-3-php-library": "<5", + "padraic/humbug_get_contents": "<1.1.2", + "pagarme/pagarme-php": "<3", + "pagekit/pagekit": "<=1.0.18", + "paragonie/ecc": "<2.0.1", + "paragonie/random_compat": "<2", + "paragonie/sodium_compat": "<1.24.1|>=2,<2.5.1", + "passbolt/passbolt_api": "<4.6.2", + "paymenter/paymenter": "<=1.5.4", + "paypal/adaptivepayments-sdk-php": "<=3.9.2", + "paypal/invoice-sdk-php": "<=3.9", + "paypal/merchant-sdk-php": "<3.12", + "paypal/permissions-sdk-php": "<=3.9.1", + "pear/archive_tar": "<1.4.14", + "pear/auth": "<1.2.4", + "pear/crypt_gpg": "<1.6.7", + "pear/http_request2": "<2.7", + "pear/pear": "<=1.10.1", + "pegasus/google-for-jobs": "<1.5.1|>=2,<2.1.1", + "personnummer/personnummer": "<3.0.2", + "ph7software/ph7builder": "<=17.9.1", + "phalcon/cphalcon": "<=5.15", + "phanan/koel": "<=9.7", + "pheditor/pheditor": "<2.0.8", + "phenx/php-svg-lib": "<0.5.2", + "php-censor/php-censor": "<2.0.13|>=2.1,<2.1.5", + "php-mod/curl": "<2.3.2", + "php-standard-library/h2": ">=6.1,<6.1.2|>=6.2,<6.2.1", + "php-standard-library/php-standard-library": ">=6.1,<6.1.2|>=6.2,<6.2.1", + "phpbb/phpbb": "<3.3.16|==4.0.0.0-alpha1", + "phpcsstandards/phpcsutils": ">=1.0.0.0-alpha1,<1.2.3", + "phpems/phpems": ">=6,<=6.1.3", + "phpfastcache/phpfastcache": "<6.1.5|>=7,<7.1.2|>=8,<8.0.7", + "phpmailer/phpmailer": "<6.5", + "phpmussel/phpmussel": ">=1,<1.6", + "phpmyadmin/phpmyadmin": "<5.2.2", + "phpmyfaq/phpmyfaq": "<=4.1.4", + "phpoffice/common": "<0.2.9", + "phpoffice/math": "<=0.2", + "phpoffice/phpexcel": "<=1.8.2", + "phpoffice/phpspreadsheet": "<=1.30.5|>=2,<=2.1.17|>=2.2,<=2.4.6|>=3,<=3.10.6|>=4,<=5.8", + "phppgadmin/phppgadmin": "<=7.13", + "phpseclib/phpseclib": "<=2.0.54|>=3,<=3.0.53", + "phpservermon/phpservermon": "<3.6", + "phpsysinfo/phpsysinfo": "<=3.4.5", + "phpunit/phpunit": "<8.5.52|>=9,<9.6.33|>=10,<10.5.62|>=11,<11.5.50|>=12,<12.5.8|>=12.5.21,<12.5.22|>=13.1.5,<13.1.6", + "phpwhois/phpwhois": "<=4.2.5", + "phpxmlrpc/extras": "<0.6.1", + "phpxmlrpc/phpxmlrpc": "<4.9.2", + "phraseanet/phraseanet": "==4.0.3", + "pi/pi": "<=2.5", + "pimcore/admin-ui-classic-bundle": "<1.7.18|>=2.0.0.0-RC1-dev,<=2.3.5", + "pimcore/customer-management-framework-bundle": "<4.2.1", + "pimcore/data-hub": "<1.2.4", + "pimcore/data-importer": "<1.8.9|>=1.9,<1.9.3", + "pimcore/demo": "<10.3", + "pimcore/ecommerce-framework-bundle": "<1.0.10", + "pimcore/perspective-editor": "<1.5.1", + "pimcore/pimcore": "<=12.3.9|>=2026.1,<=2026.1.5", + "pimcore/studio-backend-bundle": "<2025.4.6|>=2026.1,<2026.1.6", + "pimcore/web2print-tools-bundle": "<=5.2.1|>=6.0.0.0-RC1-dev,<=6.1", + "piwik/piwik": "<1.11", + "pixelfed/pixelfed": "<0.12.5", + "plank/laravel-mediable": "<7", + "plotly/plotly.js": "<2.25.2", + "pocketmine/bedrock-protocol": "<8.0.2", + "pocketmine/pocketmine-mp": "<5.42.1", + "pocketmine/raklib": ">=0.14,<0.14.6|>=0.15,<0.15.1", + "pontedilana/php-weasyprint": "<=2.5.1", + "poweradmin/poweradmin": "<4.2.5|>=4.3,<4.3.4", + "predis/predis": ">=3.0.0.0-RC1-dev,<3.3", + "pressbooks/pressbooks": "<5.18", + "prestashop/autoupgrade": ">=4,<4.10.1", + "prestashop/blockreassurance": "<=5.1.3", + "prestashop/blockwishlist": ">=2,<2.1.1", + "prestashop/contactform": ">=1.0.1,<4.3", + "prestashop/gamification": "<2.3.2", + "prestashop/prestashop": "<8.2.6|>=9,<9.1.1", + "prestashop/productcomments": "<5.0.2", + "prestashop/ps_checkout": "<5.3", + "prestashop/ps_contactinfo": "<=3.3.2", + "prestashop/ps_emailsubscription": "<2.6.1", + "prestashop/ps_facetedsearch": "<4.0.4", + "prestashop/ps_linklist": "<3.1", + "privatebin/privatebin": "<=2.0.4", + "processwire/processwire": "<=3.0.255", + "propel/propel": ">=2.0.0.0-alpha1,<2.0.0.0-alpha8", + "propel/propel1": ">=1,<1.7.2", + "psy/psysh": "<=0.11.22|>=0.12,<=0.12.18", + "pterodactyl/panel": "<=1.12.4", + "ptheofan/yii2-statemachine": ">=2.0.0.0-RC1-dev,<=2", + "ptrofimov/beanstalk_console": "<1.7.14", + "pubnub/pubnub": "<6.1", + "punktde/pt_extbase": "<1.5.1", + "pusher/pusher-php-server": "<2.2.1", + "putyourlightson/craft-sprig": ">=2,<2.15.2|>=3,<3.7.2", + "pwweb/laravel-core": "<=0.3.6.0-beta", + "pxlrbt/filament-excel": "<1.1.14|>=2.0.0.0-alpha,<2.3.3", + "pyrocms/pyrocms": "<=3.9.1", + "qcubed/qcubed": "<=3.1.1", + "quickapps/cms": "<=2.0.0.0-beta2", + "rainlab/blog-plugin": "<1.4.1", + "rainlab/debugbar-plugin": "<3.1", + "rainlab/user-plugin": "<=1.4.5", + "ralffreit/mfa-email": "<1.0.7|==2", + "rankmath/seo-by-rank-math": "<=1.0.95", + "rap2hpoutre/laravel-log-viewer": "<0.13", + "react/http": ">=0.6,<1.11.1", + "really-simple-plugins/complianz-gdpr": "<6.4.2", + "redaxo/source": "<5.21.1", + "remdex/livehelperchat": "<4.29", + "renolit/reint-downloadmanager": "<4.0.2|>=5,<5.0.1", + "reportico-web/reportico": "<=8.1", + "rhukster/dom-sanitizer": "<1.0.10", + "rmccue/requests": ">=1.6,<1.8", + "roadiz/documents": "<2.3.42|>=2.4,<2.5.44|>=2.6,<2.6.28|>=2.7,<2.7.9", + "roadiz/openid": "<2.3.43|>=2.5,<2.5.45|>=2.6,<2.6.31|>=2.7,<2.7.18", + "robrichards/xmlseclibs": "<3.1.5", + "roots/soil": "<4.1", + "roundcube/roundcubemail": "<1.5.10|>=1.6,<1.6.11|>=1.7.0.0-beta,<1.7.0.0-RC5-dev", + "rudloff/alltube": "<3.0.3", + "rudloff/rtmpdump-bin": "<=2.3.1", + "s-cart/core": "<=9.0.5", + "s-cart/s-cart": "<6.9", + "s9y/serendipity": "<2.6", + "sabberworm/php-css-parser": ">=1,<1.0.1|>=2,<2.0.1|>=3,<3.0.1|>=4,<4.0.1|>=5,<5.0.9|>=5.1,<5.1.3|>=5.2,<5.2.1|>=6,<6.0.2|>=7,<7.0.4|>=8,<8.0.1|>=8.1,<8.1.1|>=8.2,<8.2.1|>=8.3,<8.3.1", + "sabre/dav": ">=1.6,<1.7.11|>=1.8,<1.8.9", + "saloonphp/saloon": "<4", + "samwilson/unlinked-wikibase": "<1.42", + "scheb/two-factor-bundle": "<3.26|>=4,<4.11", + "sensiolabs/connect": "<4.2.3", + "serluck/phpwhois": "<=4.2.6", + "setasign/fpdi": "<2.6.7", + "sfroemken/url_redirect": "<=1.2.1", + "sheng/yiicms": "<1.2.1", + "shlinkio/shlink": "<=5.0.1", + "shopper/cart": "<2.8", + "shopper/framework": "<2.9.2", + "shopware/core": "<6.6.10.18-dev|>=6.7,<6.7.10.1-dev", + "shopware/platform": "<6.6.10.18-dev|>=6.7,<6.7.10.1-dev", + "shopware/production": "<=6.3.5.2", + "shopware/shopware": "<=6.3.5.2|>=6.4.6,<6.6.10.10-dev|>=6.7,<6.7.6.1-dev", + "shopware/storefront": "<6.6.10.10-dev|>=6.7,<6.7.5.1-dev", + "shopxo/shopxo": "<=6.4", + "showdoc/showdoc": "<3.8.1", + "shuchkin/simplexlsx": ">=1.0.12,<1.1.13", + "silverstripe-australia/advancedreports": ">=1,<=2", + "silverstripe/admin": "<1.13.19|>=2,<2.1.8", + "silverstripe/assets": "<2.4.5|>=3,<3.1.3", + "silverstripe/cms": "<6.2.1", + "silverstripe/comments": ">=1.3,<3.1.1", + "silverstripe/forum": "<0.6.2|>=0.7,<0.7.4", + "silverstripe/framework": "<6.2.2", + "silverstripe/graphql": ">=2,<2.0.5|>=3,<3.8.2|>=4,<4.3.7|>=5,<5.1.3", + "silverstripe/hybridsessions": ">=1,<2.4.1|>=2.5,<2.5.1", + "silverstripe/recipe-cms": ">=4.5,<4.5.3", + "silverstripe/registry": ">=2.1,<2.1.2|>=2.2,<2.2.1", + "silverstripe/reports": "<5.2.3", + "silverstripe/restfulserver": ">=1,<1.0.9|>=2,<2.0.4|>=2.1,<2.1.2", + "silverstripe/silverstripe-omnipay": "<2.5.2|>=3,<3.0.2|>=3.1,<3.1.4|>=3.2,<3.2.1", + "silverstripe/subsites": ">=2,<2.6.1", + "silverstripe/taxonomy": ">=1.3,<1.3.1|>=2,<2.0.1", + "silverstripe/userforms": "<6.4.9|>=7,<7.0.7|>=7.1,<7.1.1", + "silverstripe/versioned": "<3.2.1", + "silverstripe/versioned-admin": ">=1,<1.11.1", + "simogeo/filemanager": "<=2.5", + "simple-updates/phpwhois": "<=1", + "simplesamlphp/saml2": "<4.19.3|>=4.20,<=4.20.2|>=5,<5.0.6|>=6,<6.2.1", + "simplesamlphp/saml2-legacy": "<4.19.3|>=4.20,<=4.20.2", + "simplesamlphp/simplesamlphp": "<=2.4.6|>=2.5,<=2.5.1", + "simplesamlphp/simplesamlphp-module-casserver": "<=7.0.2", + "simplesamlphp/simplesamlphp-module-infocard": "<1.0.1", + "simplesamlphp/simplesamlphp-module-openid": "<1", + "simplesamlphp/simplesamlphp-module-openidprovider": "<0.9", + "simplesamlphp/xml-common": "<1.20", + "simplesamlphp/xml-security": "<1.13.9|>=2,<2.3.1", + "simplito/elliptic-php": "<1.0.6", + "sitegeist/fluid-components": "<3.5", + "sjbr/sr-feuser-register": "<2.6.2|>=5.1,<12.5", + "sjbr/sr-freecap": "<2.4.6|>=2.5,<2.5.3", + "sjbr/static-info-tables": "<2.3.1", + "slim/psr7": "<1.4.1|>=1.5,<1.5.1|>=1.6,<1.6.1", + "slim/slim": "<2.6|>=4.4,<=4.15.1", + "slub/slub-events": "<3.0.3", + "smarty/smarty": "<4.5.7|>=5,<5.8.4", + "snipe/snipe-it": "<8.6.3", + "socalnick/scn-social-auth": "<1.15.2", + "socialiteproviders/steam": "<1.1", + "solidinvoice/solidinvoice": "<=2.3.15", + "solspace/craft-freeform": "<4.1.29|>=5,<=5.14.6", + "soosyze/soosyze": "<=2", + "spatie/browsershot": "<5.0.5", + "spatie/image-optimizer": "<1.7.3", + "spatie/laravel-medialibrary": "<11.23", + "spatie/schema-org": ">=3.23.1,<3.23.2|>=4,<4.0.2", + "spencer14420/sp-php-email-handler": "<1", + "spipu/html2pdf": "<5.2.8", + "spiral/roadrunner": "<2025.1", + "spomky-labs/otphp": "<11.4.3", + "spoon/library": "<1.4.1", + "spoonity/tcpdf": "<6.2.22", + "squizlabs/php_codesniffer": "<3.13.6|>=4,<4.0.2", + "ssddanbrown/bookstack": "<24.05.1", + "starcitizentools/citizen-skin": ">=1.9.4,<3.9", + "starcitizentools/short-description": ">=4,<4.0.1", + "starcitizentools/tabber-neue": ">=1.9.1,<2.7.2|>=3,<3.1.1", + "starcitizenwiki/embedvideo": "<=4", + "statamic/cms": "<5.74.3|>=6,<=6.30", + "stormpath/sdk": "<9.9.99", + "studio-42/elfinder": "<2.1.70", + "studiomitte/friendlycaptcha": "<0.1.4", + "subhh/libconnect": "<7.0.8|>=8,<8.1", + "sukohi/surpass": "<1", + "sulu/form-bundle": ">=2,<2.5.3", + "sulu/sulu": "<=2.6.24|>=3,<3.0.8", + "sumocoders/framework-user-bundle": "<1.4", + "superbig/craft-audit": "<3.0.2", + "svewap/a21glossary": "<=0.4.10", + "swag/paypal": "<5.4.4", + "swiftmailer/swiftmailer": "<6.2.5", + "swiftyedit/swiftyedit": "<1.2", + "sylius/admin-bundle": ">=1,<1.0.17|>=1.1,<1.1.9|>=1.2,<1.2.2", + "sylius/grid": ">=1,<1.1.19|>=1.2,<1.2.18|>=1.3,<1.3.13|>=1.4,<1.4.5|>=1.5,<1.5.1", + "sylius/grid-bundle": "<1.10.1", + "sylius/mollie-plugin": "<2.2.8|>=3,<3.2.4|>=3.3,<3.3.1", + "sylius/paypal-plugin": "<1.6.2|>=1.7,<1.7.2|>=2,<2.0.2", + "sylius/resource-bundle": ">=1,<1.3.14|>=1.4,<1.4.7|>=1.5,<1.5.2|>=1.6,<1.6.4", + "sylius/sylius": "<1.9.12|>=1.10,<1.10.16|>=1.11,<1.11.17|>=1.12,<=1.12.22|>=1.13,<=1.13.14|>=1.14,<=1.14.17|>=2,<2.0.18|>=2.1,<2.1.15|>=2.2,<2.2.6", + "symbiote/silverstripe-advancedworkflow": "<6.4.5|>=7,<7.1.3|>=7.2,<7.2.1", + "symbiote/silverstripe-multivaluefield": ">=3,<3.1", + "symbiote/silverstripe-queuedjobs": ">=3,<3.0.2|>=3.1,<3.1.4|>=4,<4.0.7|>=4.1,<4.1.2|>=4.2,<4.2.4|>=4.3,<4.3.3|>=4.4,<4.4.3|>=4.5,<4.5.1|>=4.6,<4.6.4", + "symbiote/silverstripe-seed": "<6.0.3", + "symbiote/silverstripe-versionedfiles": "<=2.0.3", + "symfont/process": ">=0", + "symfony/cache": "<5.4.52|>=6,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/dependency-injection": ">=2,<2.0.17|>=2.7,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7", + "symfony/dom-crawler": "<5.4.52|>=6,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/error-handler": ">=4.4,<4.4.4|>=5,<5.0.4", + "symfony/form": ">=2.3,<2.3.35|>=2.4,<2.6.12|>=2.7,<2.7.50|>=2.8,<2.8.49|>=3,<3.4.20|>=4,<4.0.15|>=4.1,<4.1.9|>=4.2,<4.2.1", + "symfony/framework-bundle": ">=2,<2.3.18|>=2.4,<2.4.8|>=2.5,<2.5.2|>=2.7,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7|>=5.3.14,<5.3.15|>=5.4.3,<5.4.4|>=6.0.3,<6.0.4", + "symfony/html-sanitizer": ">=6.1,<6.4.41|>=7,<7.4.13|>=8,<8.0.13", + "symfony/http-client": ">=4.3,<5.4.53|>=6,<6.4.15|>=7,<7.1.8", + "symfony/http-foundation": "<5.4.50|>=6,<6.4.41|>=7,<7.4.13|>=8,<8.0.13", + "symfony/http-kernel": ">=2,<4.4.50|>=5,<5.4.20|>=6,<6.0.20|>=6.1,<6.1.12|>=6.2,<6.2.6|>=7.4,<7.4.12|>=8,<8.0.12", + "symfony/intl": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/json-path": ">=7.3,<7.4.12|>=8,<8.0.12", + "symfony/lox24-notifier": ">=7.1,<7.4.12|>=8,<8.0.12", + "symfony/mailer": "<5.4.52|>=6,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/mailjet-mailer": ">=6.4,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/mailomat-mailer": ">=7.2,<7.4.13|>=8,<8.0.13", + "symfony/mailtrap-mailer": ">=7.2,<7.4.12|>=8,<8.0.12", + "symfony/maker-bundle": ">=1.27,<1.29.2|>=1.30,<1.31.1", + "symfony/mime": "<5.4.52|>=6,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/monolog-bridge": "<5.4.52|>=6,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/phpunit-bridge": ">=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7", + "symfony/polyfill": ">=1,<1.10|>=1.17.1,<1.38.1", + "symfony/polyfill-intl-idn": ">=1.17.1,<1.38.1", + "symfony/polyfill-php55": ">=1,<1.10", + "symfony/process": "<5.4.51|>=6,<6.4.33|>=7,<7.1.7|>=7.3,<7.3.11|>=7.4,<7.4.5|>=8,<8.0.5", + "symfony/proxy-manager-bridge": ">=2.7,<2.7.51|>=2.8,<2.8.50|>=3,<3.4.26|>=4,<4.1.12|>=4.2,<4.2.7", + "symfony/routing": "<5.4.53|>=6,<6.4.41|>=7,<7.4.13|>=8,<8.0.13", + "symfony/runtime": ">=5.3,<5.4.52|>=6,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/security": ">=2,<2.7.51|>=2.8,<3.4.49|>=4,<4.4.24|>=5,<5.2.8", + "symfony/security-bundle": ">=2,<4.4.50|>=5,<5.4.20|>=6,<6.0.20|>=6.1,<6.1.12|>=6.2,<6.4.10|>=7,<7.0.10|>=7.1,<7.1.3", + "symfony/security-core": ">=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8,<3.4.49|>=4,<4.4.24|>=5,<5.2.9", + "symfony/security-csrf": ">=2.4,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", + "symfony/security-guard": ">=2.8,<3.4.48|>=4,<4.4.23|>=5,<5.2.8", + "symfony/security-http": "<5.4.53|>=6,<6.4.41|>=7,<7.4.13|>=8,<8.0.13", + "symfony/serializer": ">=2,<2.0.11|>=4.1,<4.4.35|>=5,<5.3.12", + "symfony/symfony": "<5.4.53|>=6,<6.4.41|>=7,<7.4.13|>=8,<8.0.13", + "symfony/translation": ">=2,<2.0.17", + "symfony/twig-bridge": ">=2,<4.4.51|>=5,<5.4.31|>=6,<6.3.8|>=6.4.24,<6.4.40", + "symfony/twilio-notifier": ">=6.4,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symfony/ux-autocomplete": "<2.36|>=3,<3.1", + "symfony/ux-icons": ">=2.17,<2.36.1|>=3,<3.2", + "symfony/ux-live-component": "<2.36|>=3,<3.1", + "symfony/ux-toolkit": ">=2.32,<2.36.1|>=3,<3.2", + "symfony/ux-twig-component": "<2.25.1", + "symfony/validator": "<5.4.43|>=6,<6.4.11|>=7,<7.1.4", + "symfony/var-exporter": ">=4.2,<4.2.12|>=4.3,<4.3.8", + "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4|>=7.2.9,<7.4.12|>=8,<8.0.12", + "symfony/webhook": ">=6.3,<6.3.8", + "symfony/yaml": "<5.4.52|>=6,<6.4.40|>=7,<7.4.12|>=8,<8.0.12", + "symphonycms/symphony-2": "<2.6.4", + "syssy/syssy-typo3-extension": "<3.0.6", + "t3/dce": "<0.11.5|>=2.2,<2.6.2", + "t3g/svg-sanitizer": "<1.0.3", + "t3s/content-consent": "<1.0.3|>=2,<2.0.2", + "tastyigniter/tastyigniter": "<4", + "tcg/voyager": "<=1.8", + "tecnickcom/tc-lib-pdf-font": "<2.6.4", + "tecnickcom/tcpdf": "<6.8", + "terminal42/contao-tablelookupwizard": "<3.3.5", + "thelia/backoffice-default-template": ">=2.1,<2.1.2", + "thelia/thelia": ">=2.0.0.0-beta1,<2.1.3", + "theonedemon/phpwhois": "<=4.2.5", + "thinkcmf/thinkcmf": "<6.0.8", + "thorsten/phpmyfaq": "<4.2.0.0-alpha", + "tikiwiki/tiki-manager": "<=17.1", + "timber/timber": ">=0.16.6,<1.23.1|>=1.24,<1.24.1|>=2,<2.1", + "tinymce/tinymce": "<7.9.3|>=8,<8.5.1", + "tinymighty/wiki-seo": "<1.2.2", + "titon/framework": "<9.9.99", + "tltneon/lgsl": "<7", + "tobiasbg/tablepress": "<=2.0.0.0-RC1", + "tomasnorre/crawler": "<11.0.13|>=12,<12.0.11", + "topthink/framework": "<6.0.17|>=6.1,<=8.0.4", + "topthink/think": "<=6.1.1", + "topthink/thinkphp": "<=3.2.3|>=6.1.3,<=8.0.4", + "torrentpier/torrentpier": "<=2.8.8", + "tpwd/ke_search": "<5.6.2|>=6,<6.6.1|>=7,<7.0.1", + "tribalsystems/zenario": "<=9.7.61188", + "truckersmp/phpwhois": "<=4.3.1", + "ttskch/pagination-service-provider": "<1", + "twbs/bootstrap": "<3.4.1|>=4,<4.3.1", + "twig/cssinliner-extra": "<3.26", + "twig/intl-extra": "<3.26", + "twig/markdown-extra": "<3.26", + "twig/twig": "<3.27", + "typicms/core": "<12.0.5|>=13,<13.0.9|>=14,<14.0.27|>=15,<15.0.29|>=16,<16.1.7", + "typo3/cms": "<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", + "typo3/cms-backend": "<10.4.60|>=11,<11.5.54|>=12,<12.4.49|>=13,<13.4.35|>=14,<14.3.7", + "typo3/cms-belog": ">=10,<=10.4.47|>=11,<=11.5.41|>=12,<=12.4.24|>=13,<=13.4.2", + "typo3/cms-beuser": ">=9,<9.5.55|>=10,<10.4.54|>=11,<11.5.48|>=12,<12.4.37|>=13,<13.4.18", + "typo3/cms-core": "<10.4.57|>=11,<11.5.51|>=12,<12.4.46|>=13,<13.4.34|>=14,<14.3.6", + "typo3/cms-dashboard": ">=10,<10.4.54|>=11,<11.5.48|>=12,<12.4.37|>=13,<13.4.18", + "typo3/cms-extbase": "<6.2.24|>=7,<7.6.8|==8.1.1", + "typo3/cms-extensionmanager": ">=10,<=10.4.47|>=11,<=11.5.41|>=12,<=12.4.24|>=13,<=13.4.2", + "typo3/cms-felogin": ">=4.2,<4.2.3", + "typo3/cms-filelist": ">=11,<11.5.51|>=12,<12.4.46|>=13,<13.4.31|>=14,<14.3.3", + "typo3/cms-fluid": "<4.3.4|>=4.4,<4.4.1|>=8,<8.7.23|>=9,<9.5.4", + "typo3/cms-form": "<10.4.57|>=11,<11.5.51|>=12,<12.4.46|>=13,<13.4.31|>=14,<14.3.5", + "typo3/cms-frontend": "<4.3.9|>=4.4,<4.4.5", + "typo3/cms-indexed-search": ">=10,<=10.4.47|>=11,<=11.5.41|>=12,<=12.4.24|>=13,<13.4.31|>=14,<14.3.3", + "typo3/cms-install": "<4.1.14|>=4.2,<4.2.16|>=4.3,<4.3.9|>=4.4,<4.4.5|>=12.2,<12.4.8|==13.4.2", + "typo3/cms-lowlevel": ">=11,<=11.5.41|>=14.2,<14.3.7", + "typo3/cms-recordlist": ">=11,<11.5.48", + "typo3/cms-recycler": "<10.4.57|>=11,<11.5.51|>=12,<12.4.46|>=13,<13.4.31|>=14,<14.3.3", + "typo3/cms-redirects": ">=10,<=10.4.54|>=11,<=11.5.48|>=12,<=12.4.40|>=13,<=13.4.22|>=14,<=14.0.1", + "typo3/cms-rte-ckeditor": ">=9.5,<9.5.42|>=10,<10.4.39|>=11,<11.5.30", + "typo3/cms-scheduler": ">=11,<=11.5.41", + "typo3/cms-setup": ">=9,<=9.5.50|>=10,<=10.4.49|>=11,<=11.5.43|>=12,<=12.4.30|>=13,<=13.4.11", + "typo3/cms-webhooks": ">=12,<=12.4.30|>=13,<=13.4.11", + "typo3/cms-workspaces": ">=9,<9.5.55|>=10,<10.4.54|>=11,<11.5.48|>=12,<12.4.37|>=13,<13.4.18", + "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", + "typo3/html-sanitizer": "<2.3.2", + "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.3.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<3.3.23|>=4,<4.0.17|>=4.1,<4.1.16|>=4.2,<4.2.12|>=4.3,<4.3.3", + "typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1", + "typo3/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", + "typo3fluid/fluid": ">=2,<2.0.8|>=2.1,<2.1.7|>=2.2,<2.2.4|>=2.3,<2.3.7|>=2.4,<2.4.4|>=2.5,<2.5.11|>=2.6,<2.6.10", + "ua-parser/uap-php": "<3.8", + "uasoft-indonesia/badaso": "<=2.9.7", + "unisharp/laravel-filemanager": "<2.9.1", + "universal-omega/dynamic-page-list3": "<3.6.4", + "unopim/unopim": "<=0.3", + "userfrosting/userfrosting": ">=0.3.1,<4.6.3", + "usmanhalalit/pixie": "<1.0.3|>=2,<2.0.2", + "uvdesk/community-skeleton": "<=1.1.1", + "uvdesk/core-framework": "<=1.1.1", + "vanilla/safecurl": "<0.9.2", + "verbb/comments": "<1.5.5", + "verbb/formie": "<3.1.28", + "verbb/image-resizer": "<2.0.9", + "verbb/knock-knock": "<1.2.8", + "verot/class.upload.php": "<=2.1.6", + "vertexvaar/falsftp": "<0.2.6", + "villagedefrance/opencart-overclocked": "<=1.11.1", + "vova07/yii2-fileapi-widget": "<0.1.9", + "vrana/adminer": "<5.4.2", + "vufind/vufind": ">=2,<9.1.1", + "waldhacker/hcaptcha": "<2.1.2", + "wallabag/tcpdf": "<6.2.22", + "wallabag/wallabag": "<2.6.11", + "wanglelecc/laracms": "<=1.0.3", + "wapplersystems/a21glossary": "<=0.4.10", + "web-auth/webauthn-framework": ">=3.3,<3.3.4|>=4.5,<4.9|>=5.2,<5.2.4|>=5.3,<5.3.1", + "web-auth/webauthn-lib": ">=4.5,<5.3.5", + "web-auth/webauthn-symfony-bundle": "<5.3.4", + "web-feet/coastercms": "==5.5", + "web-token/jwt-bundle": "<3.4.10|>=4,<4.0.7|>=4.1,<4.1.7", + "web-token/jwt-experimental": "<4.1.7", + "web-token/jwt-framework": "<3.4.10|>=4,<4.0.7|>=4.1,<4.1.7", + "web-token/jwt-library": "<3.4.10|>=4,<4.0.7|>=4.1,<4.1.7", + "web-tp3/wec_map": "<3.0.3", + "webbuilders-group/silverstripe-kapost-bridge": "<0.4", + "webcoast/deferred-image-processing": "<1.0.2", + "webklex/laravel-imap": "<5.3", + "webklex/php-imap": "<5.3", + "webonyx/graphql-php": "<=15.32.2", + "webpa/webpa": "<3.1.2", + "webreinvent/vaahcms": "<=2.3.1", + "wikibase/wikibase": "<=1.39.3", + "wikimedia/parsoid": "<0.12.2", + "willdurand/js-translation-bundle": "<2.1.1", + "winter/wn-backend-module": "<1.2.14", + "winter/wn-cms-module": "<=1.2.12", + "winter/wn-dusk-plugin": "<2.1", + "winter/wn-system-module": "<1.2.13", + "wintercms/winter": "<=1.2.3", + "wireui/wireui": "<1.19.3|>=2,<2.1.3", + "wnx/laravel-backup-restore": "<=1.9.3", + "woocommerce/woocommerce": "<6.6|>=8.8,<8.8.5|>=8.9,<8.9.3", + "wp-cli/wp-cli": ">=0.12,<2.5", + "wp-coding-standards/wpcs": ">=0.14.1,<3.4.1", + "wp-graphql/wp-graphql": "<=2.6", + "wp-premium/gravityforms": "<2.4.21", + "wpanel/wpanel4-cms": "<=4.3.1", + "wpcloud/wp-stateless": "<3.2", + "wpglobus/wpglobus": "<=1.9.6", + "wpmetabox/meta-box": "<5.11.2", + "wwbn/avideo": "<=29", + "xataface/xataface": "<3", + "xpressengine/xpressengine": "<3.0.15", + "yab/quarx": "<2.4.5", + "yansongda/pay": "<=3.7.19", + "yeswiki/yeswiki": "<4.6.6", + "yetiforce/yetiforce-crm": "<6.5", + "yidashi/yii2cmf": "<=2", + "yii2mod/yii2-cms": "<1.9.2", + "yiisoft/yii": "<1.1.31", + "yiisoft/yii2": "<2.0.55", + "yiisoft/yii2-authclient": "<2.2.15", + "yiisoft/yii2-bootstrap": "<2.0.4", + "yiisoft/yii2-dev": "<=2.0.45", + "yiisoft/yii2-elasticsearch": "<2.0.5", + "yiisoft/yii2-gii": "<=2.2.4", + "yiisoft/yii2-jui": "<2.0.4", + "yiisoft/yii2-redis": "<2.0.20", + "yikesinc/yikes-inc-easy-mailchimp-extender": "<6.8.6", + "yoast-seo-for-typo3/yoast_seo": "<7.2.3", + "yoast/duplicate-post": "<=4.5", + "yourls/yourls": "<=1.10.3", + "yuan1994/tpadmin": "<=1.3.12", + "yungifez/skuul": "<=2.6.5", + "z-push/z-push-dev": "<2.7.6", + "zencart/zencart": "<=1.5.7.0-beta", + "zendesk/zendesk_api_client_php": "<2.2.11", + "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", + "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-db": "<2.2.10|>=2.3,<2.3.5", + "zendframework/zend-developer-tools": ">=1.2.2,<1.2.3", + "zendframework/zend-diactoros": "<1.8.4", + "zendframework/zend-feed": "<2.10.3", + "zendframework/zend-form": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-http": "<2.8.1", + "zendframework/zend-json": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zend-ldap": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.8|>=2.3,<2.3.3", + "zendframework/zend-mail": "<2.4.11|>=2.5,<2.7.2", + "zendframework/zend-navigation": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-session": ">=2,<2.2.9|>=2.3,<2.3.4", + "zendframework/zend-validator": ">=2.3,<2.3.6", + "zendframework/zend-view": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-xmlrpc": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zendframework": "<=3", + "zendframework/zendframework1": "<1.12.20", + "zendframework/zendopenid": "<2.0.2", + "zendframework/zendrest": "<2.0.2", + "zendframework/zendservice-amazon": "<2.0.3", + "zendframework/zendservice-api": "<1", + "zendframework/zendservice-audioscrobbler": "<2.0.2", + "zendframework/zendservice-nirvanix": "<2.0.2", + "zendframework/zendservice-slideshare": "<2.0.2", + "zendframework/zendservice-technorati": "<2.0.2", + "zendframework/zendservice-windowsazure": "<2.0.2", + "zendframework/zendxml": ">=1,<1.0.1", + "zenstruck/collection": "<0.2.1", + "zetacomponents/mail": "<1.8.2", + "zf-commons/zfc-user": "<1.2.2", + "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", + "zfr/zfr-oauth2-server-module": "<0.1.2", + "zoujingli/thinkadmin": "<=6.1.53", + "zumba/json-serializer": "<3.2.3" }, + "default-branch": true, + "type": "metapackage", "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "role": "maintainer" }, { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" + "name": "Ilya Tribusean", + "email": "slash3b@gmail.com", + "role": "maintainer" } ], - "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", "keywords": [ - "Connection", - "Socket", - "async", - "reactphp", - "stream" + "dev" ], "support": { - "issues": "https://github.com/reactphp/socket/issues", - "source": "https://github.com/reactphp/socket/tree/v1.17.0" + "issues": "https://github.com/Roave/SecurityAdvisories/issues", + "source": "https://github.com/Roave/SecurityAdvisories/tree/latest" }, "funding": [ { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2025-11-19T20:47:34+00:00" - }, - { - "name": "react/stream", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/stream.git", - "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d", - "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.8", - "react/event-loop": "^1.2" - }, - "require-dev": { - "clue/stream-filter": "~1.2", - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Stream\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" + "url": "https://github.com/Ocramius", + "type": "github" }, { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" + "url": "https://tidelift.com/funding/github/packagist/roave/security-advisories", + "type": "tidelift" } ], - "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", - "keywords": [ - "event-driven", - "io", - "non-blocking", - "pipe", - "reactphp", - "readable", - "stream", - "writable" - ], - "support": { - "issues": "https://github.com/reactphp/stream/issues", - "source": "https://github.com/reactphp/stream/tree/v1.4.0" - }, - "funding": [ - { - "url": "https://opencollective.com/reactphp", - "type": "open_collective" - } - ], - "time": "2024-06-11T12:45:25+00:00" + "time": "2026-09-14T17:48:00+00:00" }, { "name": "sebastian/cli-parser", - "version": "2.0.1", + "version": "4.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084" + "reference": "7d05781b13f7dec9043a629a21d086ed74582a15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084", - "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/7d05781b13f7dec9043a629a21d086ed74582a15", + "reference": "7d05781b13f7dec9043a629a21d086ed74582a15", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.5.25" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "4.2-dev" } }, "autoload": { @@ -10712,155 +12377,59 @@ "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/4.2.1" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" - } - ], - "time": "2024-03-02T07:12:49+00:00" - }, - { - "name": "sebastian/code-unit", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "require-dev": { - "phpunit/phpunit": "^10.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ + }, { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Collection of value objects that represent the PHP code units", - "homepage": "https://github.com/sebastianbergmann/code-unit", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" - }, - "funding": [ + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-02-03T06:58:43+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "require-dev": { - "phpunit/phpunit": "^10.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "url": "https://tidelift.com/funding/github/packagist/sebastian/cli-parser", + "type": "tidelift" } ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-02-03T06:59:15+00:00" + "time": "2026-05-17T05:29:34+00:00" }, { "name": "sebastian/comparator", - "version": "5.0.5", + "version": "7.1.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55dfef806eb7dfeb6e7a6935601fef866f8ca48d" + "reference": "7c65c1e79836812819705b473a90c12399542485" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55dfef806eb7dfeb6e7a6935601fef866f8ca48d", - "reference": "55dfef806eb7dfeb6e7a6935601fef866f8ca48d", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/7c65c1e79836812819705b473a90c12399542485", + "reference": "7c65c1e79836812819705b473a90c12399542485", "shasum": "" }, "require": { "ext-dom": "*", "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/diff": "^5.0", - "sebastian/exporter": "^5.0" + "php": ">=8.3", + "sebastian/diff": "^7.0", + "sebastian/exporter": "^7.0.3" }, "require-dev": { - "phpunit/phpunit": "^10.5" + "phpunit/phpunit": "^12.5.25" + }, + "suggest": { + "ext-bcmath": "For comparing BcMath\\Number objects" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "7.1-dev" } }, "autoload": { @@ -10900,7 +12469,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/comparator/tree/7.1.8" }, "funding": [ { @@ -10920,33 +12489,33 @@ "type": "tidelift" } ], - "time": "2026-01-24T09:25:16+00:00" + "time": "2026-05-21T04:45:25+00:00" }, { "name": "sebastian/complexity", - "version": "3.2.0", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68ff824baeae169ec9f2137158ee529584553799" + "reference": "bad4316aba5303d0221f43f8cee37eb58d384bbb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", - "reference": "68ff824baeae169ec9f2137158ee529584553799", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/bad4316aba5303d0221f43f8cee37eb58d384bbb", + "reference": "bad4316aba5303d0221f43f8cee37eb58d384bbb", "shasum": "" }, "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "nikic/php-parser": "^5.0", + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.2-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -10970,7 +12539,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/5.0.0" }, "funding": [ { @@ -10978,33 +12547,33 @@ "type": "github" } ], - "time": "2023-12-21T08:37:17+00:00" + "time": "2025-02-07T04:55:25+00:00" }, { "name": "sebastian/diff", - "version": "5.1.1", + "version": "7.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" + "reference": "cd4cabe39f8a4e8ee6818ba99f10a05561ea4ad6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", - "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/cd4cabe39f8a4e8ee6818ba99f10a05561ea4ad6", + "reference": "cd4cabe39f8a4e8ee6818ba99f10a05561ea4ad6", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0", - "symfony/process": "^6.4" + "phpunit/phpunit": "^12.5.33", + "symfony/process": "^7.4.17" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -11037,35 +12606,47 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" + "source": "https://github.com/sebastianbergmann/diff/tree/7.0.1" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/diff", + "type": "tidelift" } ], - "time": "2024-03-02T07:15:17+00:00" + "time": "2026-08-25T15:35:54+00:00" }, { "name": "sebastian/environment", - "version": "6.1.0", + "version": "8.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "8074dbcd93529b357029f5cc5058fd3e43666984" + "reference": "9d32c685773823b1983e256ae4ecd48a10d6e439" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984", - "reference": "8074dbcd93529b357029f5cc5058fd3e43666984", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/9d32c685773823b1983e256ae4ecd48a10d6e439", + "reference": "9d32c685773823b1983e256ae4ecd48a10d6e439", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.5.26" }, "suggest": { "ext-posix": "*" @@ -11073,7 +12654,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.1-dev" + "dev-main": "8.1-dev" } }, "autoload": { @@ -11101,42 +12682,54 @@ "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", "security": "https://github.com/sebastianbergmann/environment/security/policy", - "source": "https://github.com/sebastianbergmann/environment/tree/6.1.0" + "source": "https://github.com/sebastianbergmann/environment/tree/8.1.2" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/environment", + "type": "tidelift" } ], - "time": "2024-03-23T08:47:14+00:00" + "time": "2026-05-25T13:40:20+00:00" }, { "name": "sebastian/exporter", - "version": "5.1.4", + "version": "7.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "0735b90f4da94969541dac1da743446e276defa6" + "reference": "c5e21b5de653ce0a769fb36f5cdfcb5e7a32cf23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0735b90f4da94969541dac1da743446e276defa6", - "reference": "0735b90f4da94969541dac1da743446e276defa6", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c5e21b5de653ce0a769fb36f5cdfcb5e7a32cf23", + "reference": "c5e21b5de653ce0a769fb36f5cdfcb5e7a32cf23", "shasum": "" }, "require": { "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/recursion-context": "^5.0" + "php": ">=8.3", + "sebastian/recursion-context": "^7.0.1" }, "require-dev": { - "phpunit/phpunit": "^10.5" + "phpunit/phpunit": "^12.5.25" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -11179,7 +12772,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/7.0.3" }, "funding": [ { @@ -11199,35 +12792,35 @@ "type": "tidelift" } ], - "time": "2025-09-24T06:09:11+00:00" + "time": "2026-05-20T04:37:17+00:00" }, { "name": "sebastian/global-state", - "version": "6.0.2", + "version": "8.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9" + "reference": "b164d3274d6537ab462591c5755f76a8f5b1aae9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", - "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/b164d3274d6537ab462591c5755f76a8f5b1aae9", + "reference": "b164d3274d6537ab462591c5755f76a8f5b1aae9", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=8.3", + "sebastian/object-reflector": "^5.0", + "sebastian/recursion-context": "^7.0.1" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.5.28" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-main": "8.0-dev" } }, "autoload": { @@ -11253,41 +12846,53 @@ "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", "security": "https://github.com/sebastianbergmann/global-state/security/policy", - "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2" + "source": "https://github.com/sebastianbergmann/global-state/tree/8.0.3" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/global-state", + "type": "tidelift" } ], - "time": "2024-03-02T07:19:19+00:00" + "time": "2026-06-01T15:10:33+00:00" }, { "name": "sebastian/lines-of-code", - "version": "2.0.2", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" + "reference": "d543b8ef219dcd8da262cbb958639a96bedba10e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d543b8ef219dcd8da262cbb958639a96bedba10e", + "reference": "d543b8ef219dcd8da262cbb958639a96bedba10e", "shasum": "" }, "require": { - "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "nikic/php-parser": "^5.7.0", + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.5.25" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -11311,42 +12916,54 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/4.0.1" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/lines-of-code", + "type": "tidelift" } ], - "time": "2023-12-21T08:38:20+00:00" + "time": "2026-05-19T16:22:07+00:00" }, { "name": "sebastian/object-enumerator", - "version": "5.0.0", + "version": "7.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + "reference": "1effe8e9b8e068e9ae228e542d5d11b5d16db894" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1effe8e9b8e068e9ae228e542d5d11b5d16db894", + "reference": "1effe8e9b8e068e9ae228e542d5d11b5d16db894", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=8.3", + "sebastian/object-reflector": "^5.0", + "sebastian/recursion-context": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -11368,7 +12985,8 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/object-enumerator/security/policy", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/7.0.0" }, "funding": [ { @@ -11376,32 +12994,32 @@ "type": "github" } ], - "time": "2023-02-03T07:08:32+00:00" + "time": "2025-02-07T04:57:48+00:00" }, { "name": "sebastian/object-reflector", - "version": "3.0.0", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + "reference": "4bfa827c969c98be1e527abd576533293c634f6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/4bfa827c969c98be1e527abd576533293c634f6a", + "reference": "4bfa827c969c98be1e527abd576533293c634f6a", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -11423,7 +13041,8 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + "security": "https://github.com/sebastianbergmann/object-reflector/security/policy", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/5.0.0" }, "funding": [ { @@ -11431,32 +13050,32 @@ "type": "github" } ], - "time": "2023-02-03T07:06:18+00:00" + "time": "2025-02-07T04:58:17+00:00" }, { "name": "sebastian/recursion-context", - "version": "5.0.1", + "version": "7.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "47e34210757a2f37a97dcd207d032e1b01e64c7a" + "reference": "0b01998a7d5b1f122911a66bebcb8d46f0c82d8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/47e34210757a2f37a97dcd207d032e1b01e64c7a", - "reference": "47e34210757a2f37a97dcd207d032e1b01e64c7a", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/0b01998a7d5b1f122911a66bebcb8d46f0c82d8c", + "reference": "0b01998a7d5b1f122911a66bebcb8d46f0c82d8c", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.5" + "phpunit/phpunit": "^12.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "7.0-dev" } }, "autoload": { @@ -11487,7 +13106,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/7.0.1" }, "funding": [ { @@ -11507,32 +13126,32 @@ "type": "tidelift" } ], - "time": "2025-08-10T07:50:56+00:00" + "time": "2025-08-13T04:44:59+00:00" }, { "name": "sebastian/type", - "version": "4.0.0", + "version": "6.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + "reference": "82ff822c2edc46724be9f7411d3163021f602773" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/82ff822c2edc46724be9f7411d3163021f602773", + "reference": "82ff822c2edc46724be9f7411d3163021f602773", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^12.5.25" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -11555,37 +13174,50 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + "security": "https://github.com/sebastianbergmann/type/security/policy", + "source": "https://github.com/sebastianbergmann/type/tree/6.0.4" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/type", + "type": "tidelift" } ], - "time": "2023-02-03T07:10:45+00:00" + "time": "2026-05-20T06:45:45+00:00" }, { "name": "sebastian/version", - "version": "4.0.1", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + "reference": "3e6ccf7657d4f0a59200564b08cead899313b53c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/3e6ccf7657d4f0a59200564b08cead899313b53c", + "reference": "3e6ccf7657d4f0a59200564b08cead899313b53c", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -11608,7 +13240,8 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + "security": "https://github.com/sebastianbergmann/version/security/policy", + "source": "https://github.com/sebastianbergmann/version/tree/6.0.0" }, "funding": [ { @@ -11616,36 +13249,46 @@ "type": "github" } ], - "time": "2023-02-07T11:34:05+00:00" + "time": "2025-02-07T05:00:38+00:00" }, { - "name": "spatie/backtrace", - "version": "1.8.1", + "name": "spaze/phpstan-disallowed-calls", + "version": "v4.14.0", "source": { "type": "git", - "url": "https://github.com/spatie/backtrace.git", - "reference": "8c0f16a59ae35ec8c62d85c3c17585158f430110" + "url": "https://github.com/spaze/phpstan-disallowed-calls.git", + "reference": "90210a86e93e3a96f9a7fded9f5a8b3ee40925dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/backtrace/zipball/8c0f16a59ae35ec8c62d85c3c17585158f430110", - "reference": "8c0f16a59ae35ec8c62d85c3c17585158f430110", + "url": "https://api.github.com/repos/spaze/phpstan-disallowed-calls/zipball/90210a86e93e3a96f9a7fded9f5a8b3ee40925dd", + "reference": "90210a86e93e3a96f9a7fded9f5a8b3ee40925dd", "shasum": "" }, "require": { - "php": "^7.3 || ^8.0" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^1.12.6 || ^2.0" }, "require-dev": { - "ext-json": "*", - "laravel/serializable-closure": "^1.3 || ^2.0", - "phpunit/phpunit": "^9.3 || ^11.4.3", - "spatie/phpunit-snapshot-assertions": "^4.2 || ^5.1.6", - "symfony/var-dumper": "^5.1 || ^6.0 || ^7.0" + "nette/neon": "^3.3.1", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.2 || ^2.0", + "phpunit/phpunit": "^9.6 || ^10.1 || ^11.0 || ^12.0 || ^13.0", + "shipmonk/dead-code-detector": "^1.1", + "spaze/coding-standard": "^1.8" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } }, - "type": "library", "autoload": { "psr-4": { - "Spatie\\Backtrace\\": "src" + "Spaze\\PHPStan\\Rules\\Disallowed\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -11654,528 +13297,225 @@ ], "authors": [ { - "name": "Freek Van de Herten", - "email": "freek@spatie.be", - "homepage": "https://spatie.be", - "role": "Developer" + "name": "Michal Špaček", + "email": "mail@michalspacek.cz", + "homepage": "https://www.michalspacek.cz" } ], - "description": "A better backtrace", - "homepage": "https://github.com/spatie/backtrace", + "description": "PHPStan rules to detect disallowed method & function calls, constant, namespace, attribute, property & superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.", "keywords": [ - "Backtrace", - "spatie" + "static analysis" ], "support": { - "issues": "https://github.com/spatie/backtrace/issues", - "source": "https://github.com/spatie/backtrace/tree/1.8.1" + "issues": "https://github.com/spaze/phpstan-disallowed-calls/issues", + "source": "https://github.com/spaze/phpstan-disallowed-calls/tree/v4.14.0" }, "funding": [ { - "url": "https://github.com/sponsors/spatie", + "url": "https://github.com/spaze", "type": "github" - }, - { - "url": "https://spatie.be/open-source/support-us", - "type": "other" } ], - "time": "2025-08-26T08:22:30+00:00" + "time": "2026-08-02T15:18:24+00:00" }, { - "name": "spatie/error-solutions", - "version": "1.1.3", + "name": "staabm/side-effects-detector", + "version": "1.0.5", "source": { "type": "git", - "url": "https://github.com/spatie/error-solutions.git", - "reference": "e495d7178ca524f2dd0fe6a1d99a1e608e1c9936" + "url": "https://github.com/staabm/side-effects-detector.git", + "reference": "d8334211a140ce329c13726d4a715adbddd0a163" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/error-solutions/zipball/e495d7178ca524f2dd0fe6a1d99a1e608e1c9936", - "reference": "e495d7178ca524f2dd0fe6a1d99a1e608e1c9936", + "url": "https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163", + "reference": "d8334211a140ce329c13726d4a715adbddd0a163", "shasum": "" }, "require": { - "php": "^8.0" + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0" }, "require-dev": { - "illuminate/broadcasting": "^10.0|^11.0|^12.0", - "illuminate/cache": "^10.0|^11.0|^12.0", - "illuminate/support": "^10.0|^11.0|^12.0", - "livewire/livewire": "^2.11|^3.5.20", - "openai-php/client": "^0.10.1", - "orchestra/testbench": "8.22.3|^9.0|^10.0", - "pestphp/pest": "^2.20|^3.0", - "phpstan/phpstan": "^2.1", - "psr/simple-cache": "^3.0", - "psr/simple-cache-implementation": "^3.0", - "spatie/ray": "^1.28", - "symfony/cache": "^5.4|^6.0|^7.0", - "symfony/process": "^5.4|^6.0|^7.0", - "vlucas/phpdotenv": "^5.5" - }, - "suggest": { - "openai-php/client": "Require get solutions from OpenAI", - "simple-cache-implementation": "To cache solutions from OpenAI" + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^1.12.6", + "phpunit/phpunit": "^9.6.21", + "symfony/var-dumper": "^5.4.43", + "tomasvotruba/type-coverage": "1.0.0", + "tomasvotruba/unused-public": "1.0.0" }, "type": "library", "autoload": { - "psr-4": { - "Spatie\\Ignition\\": "legacy/ignition", - "Spatie\\ErrorSolutions\\": "src", - "Spatie\\LaravelIgnition\\": "legacy/laravel-ignition" - } + "classmap": [ + "lib/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Ruben Van Assche", - "email": "ruben@spatie.be", - "role": "Developer" - } - ], - "description": "This is my package error-solutions", - "homepage": "https://github.com/spatie/error-solutions", + "description": "A static analysis tool to detect side effects in PHP code", "keywords": [ - "error-solutions", - "spatie" + "static analysis" ], "support": { - "issues": "https://github.com/spatie/error-solutions/issues", - "source": "https://github.com/spatie/error-solutions/tree/1.1.3" + "issues": "https://github.com/staabm/side-effects-detector/issues", + "source": "https://github.com/staabm/side-effects-detector/tree/1.0.5" }, "funding": [ { - "url": "https://github.com/Spatie", + "url": "https://github.com/staabm", "type": "github" } ], - "time": "2025-02-14T12:29:50+00:00" + "time": "2024-10-20T05:08:20+00:00" }, { - "name": "spatie/flare-client-php", - "version": "1.10.1", + "name": "symplify/phpstan-rules", + "version": "14.10.0", "source": { "type": "git", - "url": "https://github.com/spatie/flare-client-php.git", - "reference": "bf1716eb98bd689451b071548ae9e70738dce62f" + "url": "https://github.com/symplify/phpstan-rules.git", + "reference": "dc1035ded416b99313d6a14e69923f5e018a6b40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/flare-client-php/zipball/bf1716eb98bd689451b071548ae9e70738dce62f", - "reference": "bf1716eb98bd689451b071548ae9e70738dce62f", + "url": "https://api.github.com/repos/symplify/phpstan-rules/zipball/dc1035ded416b99313d6a14e69923f5e018a6b40", + "reference": "dc1035ded416b99313d6a14e69923f5e018a6b40", "shasum": "" }, "require": { - "illuminate/pipeline": "^8.0|^9.0|^10.0|^11.0|^12.0", - "php": "^8.0", - "spatie/backtrace": "^1.6.1", - "symfony/http-foundation": "^5.2|^6.0|^7.0", - "symfony/mime": "^5.2|^6.0|^7.0", - "symfony/process": "^5.2|^6.0|^7.0", - "symfony/var-dumper": "^5.2|^6.0|^7.0" + "nette/utils": "^3.2|^4.0", + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.1.33", + "webmozart/assert": "^1.12 || ^2.0" }, - "require-dev": { - "dms/phpunit-arraysubset-asserts": "^0.5.0", - "pestphp/pest": "^1.20|^2.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "spatie/pest-plugin-snapshots": "^1.0|^2.0" - }, - "type": "library", + "type": "phpstan-extension", "extra": { - "branch-alias": { - "dev-main": "1.3.x-dev" - } - }, - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "Spatie\\FlareClient\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Send PHP errors to Flare", - "homepage": "https://github.com/spatie/flare-client-php", - "keywords": [ - "exception", - "flare", - "reporting", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/flare-client-php/issues", - "source": "https://github.com/spatie/flare-client-php/tree/1.10.1" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2025-02-14T13:42:06+00:00" - }, - { - "name": "spatie/ignition", - "version": "1.15.1", - "source": { - "type": "git", - "url": "https://github.com/spatie/ignition.git", - "reference": "31f314153020aee5af3537e507fef892ffbf8c85" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/ignition/zipball/31f314153020aee5af3537e507fef892ffbf8c85", - "reference": "31f314153020aee5af3537e507fef892ffbf8c85", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-mbstring": "*", - "php": "^8.0", - "spatie/error-solutions": "^1.0", - "spatie/flare-client-php": "^1.7", - "symfony/console": "^5.4|^6.0|^7.0", - "symfony/var-dumper": "^5.4|^6.0|^7.0" - }, - "require-dev": { - "illuminate/cache": "^9.52|^10.0|^11.0|^12.0", - "mockery/mockery": "^1.4", - "pestphp/pest": "^1.20|^2.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "psr/simple-cache-implementation": "*", - "symfony/cache": "^5.4|^6.0|^7.0", - "symfony/process": "^5.4|^6.0|^7.0", - "vlucas/phpdotenv": "^5.5" - }, - "suggest": { - "openai-php/client": "Require get solutions from OpenAI", - "simple-cache-implementation": "To cache solutions from OpenAI" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.5.x-dev" - } - }, - "autoload": { - "psr-4": { - "Spatie\\Ignition\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Spatie", - "email": "info@spatie.be", - "role": "Developer" - } - ], - "description": "A beautiful error page for PHP applications.", - "homepage": "https://flareapp.io/ignition", - "keywords": [ - "error", - "flare", - "laravel", - "page" - ], - "support": { - "docs": "https://flareapp.io/docs/ignition-for-laravel/introduction", - "forum": "https://twitter.com/flareappio", - "issues": "https://github.com/spatie/ignition/issues", - "source": "https://github.com/spatie/ignition" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2025-02-21T14:31:39+00:00" - }, - { - "name": "spatie/laravel-ignition", - "version": "2.9.1", - "source": { - "type": "git", - "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "1baee07216d6748ebd3a65ba97381b051838707a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/1baee07216d6748ebd3a65ba97381b051838707a", - "reference": "1baee07216d6748ebd3a65ba97381b051838707a", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "illuminate/support": "^10.0|^11.0|^12.0", - "php": "^8.1", - "spatie/ignition": "^1.15", - "symfony/console": "^6.2.3|^7.0", - "symfony/var-dumper": "^6.2.3|^7.0" - }, - "require-dev": { - "livewire/livewire": "^2.11|^3.3.5", - "mockery/mockery": "^1.5.1", - "openai-php/client": "^0.8.1|^0.10", - "orchestra/testbench": "8.22.3|^9.0|^10.0", - "pestphp/pest": "^2.34|^3.7", - "phpstan/extension-installer": "^1.3.1", - "phpstan/phpstan-deprecation-rules": "^1.1.1|^2.0", - "phpstan/phpstan-phpunit": "^1.3.16|^2.0", - "vlucas/phpdotenv": "^5.5" - }, - "suggest": { - "openai-php/client": "Require get solutions from OpenAI", - "psr/simple-cache-implementation": "Needed to cache solutions from OpenAI" - }, - "type": "library", - "extra": { - "laravel": { - "aliases": { - "Flare": "Spatie\\LaravelIgnition\\Facades\\Flare" - }, - "providers": [ - "Spatie\\LaravelIgnition\\IgnitionServiceProvider" + "phpstan": { + "includes": [ + "config/services/services.neon" ] } }, "autoload": { "files": [ - "src/helpers.php" + "src/functions/fast-functions.php" ], "psr-4": { - "Spatie\\LaravelIgnition\\": "src" + "Symplify\\PHPStanRules\\": "src" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Spatie", - "email": "info@spatie.be", - "role": "Developer" - } - ], - "description": "A beautiful error page for Laravel applications.", - "homepage": "https://flareapp.io/ignition", - "keywords": [ - "error", - "flare", - "laravel", - "page" - ], + "description": "Set of Symplify rules for PHPStan", "support": { - "docs": "https://flareapp.io/docs/ignition-for-laravel/introduction", - "forum": "https://twitter.com/flareappio", - "issues": "https://github.com/spatie/laravel-ignition/issues", - "source": "https://github.com/spatie/laravel-ignition" + "issues": "https://github.com/symplify/phpstan-rules/issues", + "source": "https://github.com/symplify/phpstan-rules/tree/14.10.0" }, "funding": [ { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2025-02-20T13:13:55+00:00" - }, - { - "name": "symfony/options-resolver", - "version": "v7.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "b38026df55197f9e39a44f3215788edf83187b80" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/b38026df55197f9e39a44f3215788edf83187b80", - "reference": "b38026df55197f9e39a44f3215788edf83187b80", - "shasum": "" - }, - "require": { - "php": ">=8.2", - "symfony/deprecation-contracts": "^2.5|^3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an improved replacement for the array_replace PHP function", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.4.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", + "url": "https://www.paypal.me/rectorphp", "type": "custom" }, { - "url": "https://github.com/fabpot", + "url": "https://github.com/tomasvotruba", "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2025-11-12T15:39:26+00:00" + "time": "2026-05-22T09:35:51+00:00" }, { - "name": "symfony/polyfill-php81", - "version": "v1.33.0", + "name": "symplify/rule-doc-generator-contracts", + "version": "11.2.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + "url": "https://github.com/symplify/rule-doc-generator-contracts.git", + "reference": "479cfcfd46047f80624aba931d9789e50475b5c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "url": "https://api.github.com/repos/symplify/rule-doc-generator-contracts/zipball/479cfcfd46047f80624aba931d9789e50475b5c6", + "reference": "479cfcfd46047f80624aba931d9789e50475b5c6", "shasum": "" }, "require": { - "php": ">=7.2" + "php": ">=8.1" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpstan/extension-installer": "^1.2", + "rector/rector": "^0.15.10", + "symplify/easy-ci": "^11.1", + "symplify/easy-coding-standard": "^11.1", + "symplify/easy-testing": "^11.1", + "symplify/phpstan-extensions": "^11.1", + "symplify/phpstan-rules": "11.2.3.72", + "tomasvotruba/unused-public": "^0.0.34" }, "type": "library", "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" + "branch-alias": { + "dev-main": "11.2-dev" } }, "autoload": { - "files": [ - "bootstrap.php" - ], "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] + "Symplify\\RuleDocGenerator\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], + "description": "Contracts for production code of RuleDocGenerator", "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" + "source": "https://github.com/symplify/rule-doc-generator-contracts/tree/11.2.0" }, "funding": [ { - "url": "https://symfony.com/sponsor", + "url": "https://www.paypal.me/rectorphp", "type": "custom" }, { - "url": "https://github.com/fabpot", + "url": "https://github.com/tomasvotruba", "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2024-03-18T22:02:54+00:00" }, { - "name": "symfony/stopwatch", - "version": "v7.4.0", + "name": "ta-tikoma/phpunit-architecture-test", + "version": "0.8.7", "source": { "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "8a24af0a2e8a872fb745047180649b8418303084" + "url": "https://github.com/ta-tikoma/phpunit-architecture-test.git", + "reference": "1248f3f506ca9641d4f68cebcd538fa489754db8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/8a24af0a2e8a872fb745047180649b8418303084", - "reference": "8a24af0a2e8a872fb745047180649b8418303084", + "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/1248f3f506ca9641d4f68cebcd538fa489754db8", + "reference": "1248f3f506ca9641d4f68cebcd538fa489754db8", "shasum": "" }, "require": { - "php": ">=8.2", - "symfony/service-contracts": "^2.5|^3" + "nikic/php-parser": "^4.18.0 || ^5.0.0", + "php": "^8.1.0", + "phpdocumentor/reflection-docblock": "^5.3.0 || ^6.0.0", + "phpunit/phpunit": "^10.5.5 || ^11.0.0 || ^12.0.0 || ^13.0.0", + "symfony/finder": "^6.4.0 || ^7.0.0 || ^8.0.0" + }, + "require-dev": { + "laravel/pint": "^1.13.7", + "phpstan/phpstan": "^1.10.52" }, "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "PHPUnit\\Architecture\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -12183,58 +13523,47 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Ni Shi", + "email": "futik0ma011@gmail.com" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" } ], - "description": "Provides a way to profile code", - "homepage": "https://symfony.com", + "description": "Methods for testing application architecture", + "keywords": [ + "architecture", + "phpunit", + "stucture", + "test", + "testing" + ], "support": { - "source": "https://github.com/symfony/stopwatch/tree/v7.4.0" + "issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues", + "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.7" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2025-08-04T07:05:15+00:00" + "time": "2026-02-17T17:25:14+00:00" }, { "name": "theseer/tokenizer", - "version": "1.3.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "b7489ce515e168639d17feec34b8847c326b0b3c" + "reference": "7989e43bf381af0eac72e4f0ca5bcbfa81658be4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c", - "reference": "b7489ce515e168639d17feec34b8847c326b0b3c", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/7989e43bf381af0eac72e4f0ca5bcbfa81658be4", + "reference": "7989e43bf381af0eac72e4f0ca5bcbfa81658be4", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": "^7.2 || ^8.0" + "php": "^8.1" }, "type": "library", "autoload": { @@ -12256,7 +13585,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.3.1" + "source": "https://github.com/theseer/tokenizer/tree/2.0.1" }, "funding": [ { @@ -12264,16 +13593,142 @@ "type": "github" } ], - "time": "2025-11-17T20:03:58+00:00" + "time": "2025-12-08T11:19:18+00:00" + }, + { + "name": "tomasvotruba/type-coverage", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/TomasVotruba/type-coverage.git", + "reference": "4087caa4639bdd4c646f2984bc333efeddf69e4b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TomasVotruba/type-coverage/zipball/4087caa4639bdd4c646f2984bc333efeddf69e4b", + "reference": "4087caa4639bdd4c646f2984bc333efeddf69e4b", + "shasum": "" + }, + "require": { + "nette/utils": "^3.2 || ^4.0", + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.33" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "config/extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "TomasVotruba\\TypeCoverage\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Measure type coverage of your project", + "keywords": [ + "phpstan-extension", + "static analysis" + ], + "support": { + "issues": "https://github.com/TomasVotruba/type-coverage/issues", + "source": "https://github.com/TomasVotruba/type-coverage/tree/2.2.1" + }, + "funding": [ + { + "url": "https://www.paypal.me/rectorphp", + "type": "custom" + }, + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2026-05-26T08:14:01+00:00" + }, + { + "name": "webmozart/assert", + "version": "2.4.1", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "2ccb7c2e821038c03a3e6e1700c570c158c55f70" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/2ccb7c2e821038c03a3e6e1700c570c158c55f70", + "reference": "2ccb7c2e821038c03a3e6e1700c570c158c55f70", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-filter": "*", + "php": "^8.2" + }, + "suggest": { + "ext-intl": "", + "ext-simplexml": "", + "ext-spl": "" + }, + "type": "library", + "extra": { + "psalm": { + "pluginClass": "Webmozart\\Assert\\PsalmPlugin" + }, + "branch-alias": { + "dev-master": "2.0-dev", + "dev-feature/2-0": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + }, + { + "name": "Woody Gilk", + "email": "woody.gilk@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/2.4.1" + }, + "time": "2026-06-15T15:31:57+00:00" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "roave/security-advisories": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^8.2 || ^8.3", + "php": "^8.3", + "ext-intl": "*", "ext-json": "*", "ext-mbstring": "*", "ext-pdo": "*", @@ -12283,7 +13738,7 @@ }, "platform-dev": {}, "platform-overrides": { - "php": "8.2.0" + "php": "8.3.0" }, "plugin-api-version": "2.9.0" } diff --git a/config/activity.php b/config/activity.php index 6c492d334..a602bb575 100644 --- a/config/activity.php +++ b/config/activity.php @@ -1,5 +1,7 @@ env('APP_ACTIVITY_PRUNE_DAYS', 90), diff --git a/config/addons.php b/config/addons.php index f15e97990..1b30e1bc3 100644 --- a/config/addons.php +++ b/config/addons.php @@ -1,5 +1,7 @@ /hooks/" during lifecycle events such as post-install | (see the p:environment:addons:run-hooks command). These scripts run with - | the privileges of the invoking process — often root during an upgrade — so + | the privileges of the invoking process - often root during an upgrade - so | only enable this if you trust every installed addon. | */ diff --git a/config/app.php b/config/app.php index 475591a0d..743639df1 100644 --- a/config/app.php +++ b/config/app.php @@ -1,5 +1,13 @@ env('APP_REPORT_ALL_EXCEPTIONS', false), ], - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ - - 'providers' => [ - /* - * Laravel Framework Service Providers... - */ - Illuminate\Auth\AuthServiceProvider::class, - Illuminate\Broadcasting\BroadcastServiceProvider::class, - Illuminate\Bus\BusServiceProvider::class, - Illuminate\Cache\CacheServiceProvider::class, - Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, - Illuminate\Cookie\CookieServiceProvider::class, - Illuminate\Database\DatabaseServiceProvider::class, - Illuminate\Encryption\EncryptionServiceProvider::class, - Illuminate\Filesystem\FilesystemServiceProvider::class, - Illuminate\Foundation\Providers\FoundationServiceProvider::class, - Illuminate\Hashing\HashServiceProvider::class, - Illuminate\Mail\MailServiceProvider::class, - Illuminate\Notifications\NotificationServiceProvider::class, - Illuminate\Pagination\PaginationServiceProvider::class, - Illuminate\Pipeline\PipelineServiceProvider::class, - Illuminate\Queue\QueueServiceProvider::class, - Illuminate\Redis\RedisServiceProvider::class, - Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, - Illuminate\Session\SessionServiceProvider::class, - Illuminate\Translation\TranslationServiceProvider::class, - Illuminate\Validation\ValidationServiceProvider::class, - Illuminate\View\ViewServiceProvider::class, - - /* - * Application Service Providers... - */ - Pterodactyl\Providers\ActivityLogServiceProvider::class, - Pterodactyl\Providers\AppServiceProvider::class, - Pterodactyl\Providers\AuthServiceProvider::class, - Pterodactyl\Providers\BackupsServiceProvider::class, - Pterodactyl\Providers\BladeServiceProvider::class, - Pterodactyl\Providers\EventServiceProvider::class, - Pterodactyl\Providers\HashidsServiceProvider::class, - Pterodactyl\Providers\RouteServiceProvider::class, - Pterodactyl\Providers\RepositoryServiceProvider::class, - Pterodactyl\Providers\ViewComposerServiceProvider::class, - - /* - * Additional Dependencies - */ - Prologue\Alerts\AlertsServiceProvider::class, - ], - /* |-------------------------------------------------------------------------- | Class Aliases @@ -218,15 +168,13 @@ return [ | */ - 'aliases' => Illuminate\Support\Facades\Facade::defaultAliases()->merge([ - 'Alert' => Prologue\Alerts\Facades\Alert::class, - 'Carbon' => Carbon\Carbon::class, - 'JavaScript' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class, - 'Theme' => Pterodactyl\Extensions\Facades\Theme::class, + 'aliases' => Facade::defaultAliases()->merge([ + 'Alert' => Alert::class, + 'Carbon' => Carbon::class, // Custom Facades - 'Activity' => Pterodactyl\Facades\Activity::class, - 'LogBatch' => Pterodactyl\Facades\LogBatch::class, - 'LogTarget' => Pterodactyl\Facades\LogTarget::class, + 'Activity' => Activity::class, + 'LogBatch' => LogBatch::class, + 'LogTarget' => LogTarget::class, ])->toArray(), ]; diff --git a/config/auth.php b/config/auth.php index 76db06571..1fb2f9c84 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,5 +1,9 @@ [ 'users' => [ 'driver' => 'eloquent', - 'model' => Pterodactyl\Models\User::class, + 'model' => User::class, ], ], diff --git a/config/backups.php b/config/backups.php index e4825673e..cd820715c 100644 --- a/config/backups.php +++ b/config/backups.php @@ -1,5 +1,7 @@ env('AWS_BACKUPS_BUCKET') ?? '', + 'prefix' => env('AWS_BACKUPS_BUCKET', ''), 'endpoint' => env('AWS_ENDPOINT'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), diff --git a/config/broadcasting.php b/config/broadcasting.php index 81add6d89..5f9549144 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -1,5 +1,7 @@ env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - 'host' => env('PUSHER_HOST', 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com', + 'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'port' => env('PUSHER_PORT', 443), 'scheme' => env('PUSHER_SCHEME', 'https'), 'encrypted' => true, diff --git a/config/cache.php b/config/cache.php index ce38d7983..15e682ad0 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,5 +1,7 @@ env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'pterodactyl'), '_') . '_cache_'), + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'pterodactyl'), '_').'_cache_'), ]; diff --git a/config/compile.php b/config/compile.php index cbf7739a6..df78d6250 100644 --- a/config/compile.php +++ b/config/compile.php @@ -1,5 +1,7 @@ explode(',', env('APP_CORS_ALLOWED_ORIGINS') ?? ''), + 'allowed_origins' => explode(',', env('APP_CORS_ALLOWED_ORIGINS', '')), /* * Patterns that can be used with `preg_match` to match the origin. diff --git a/config/database.php b/config/database.php index 6b1a18f10..45e414abb 100644 --- a/config/database.php +++ b/config/database.php @@ -1,5 +1,7 @@ [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'pterodactyl'), '_') . '_database_'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'pterodactyl'), '_').'_database_'), ], 'default' => [ diff --git a/config/egg_features/eula.php b/config/egg_features/eula.php index e5fb8727b..7dcad2c35 100644 --- a/config/egg_features/eula.php +++ b/config/egg_features/eula.php @@ -1,5 +1,7 @@ env('PTERODACTYL_EXTENSIONS_ENABLED', true), + + 'panel_version' => config('app.version') === 'canary' ? '2.0.0-dev' : config('app.version'), + 'sdk_version' => '2.0.0-beta.4', + 'progress_retention_seconds' => 3600, + + // How long the result of a head tag callback (registerHeadTags) is cached; 0 disables it. + 'head_tags_cache_seconds' => 60, + + // Requests per minute each client may make to an extension's root path routes. + 'root_routes_per_minute' => 120, + + // Where extension packages are installed. + 'directory' => env('PTERODACTYL_EXTENSIONS_DIRECTORY', base_path('extensions')), + + // Where enabled extensions' built frontend assets are published. + 'assets_directory' => public_path('assets/extensions'), + + // The filesystem disk that holds files uploaded through `file` settings. They are + // served by the panel from /extension-files, so the disk does not need to be public. + 'files_disk' => env('PTERODACTYL_EXTENSIONS_FILES_DISK', 'local'), +]; diff --git a/config/filesystems.php b/config/filesystems.php index 917a75681..e774bef75 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -1,5 +1,7 @@ [ 'driver' => 'local', 'root' => storage_path('app/public'), - 'url' => env('APP_URL') . '/storage', + 'url' => env('APP_URL').'/storage', 'visibility' => 'public', 'throw' => false, ], diff --git a/config/fractal.php b/config/fractal.php index 833cf2b95..16380466c 100644 --- a/config/fractal.php +++ b/config/fractal.php @@ -1,5 +1,9 @@ League\Fractal\Serializer\JsonApiSerializer::class, + 'default_serializer' => JsonApiSerializer::class, /* |-------------------------------------------------------------------------- diff --git a/config/hashids.php b/config/hashids.php index 199de1a32..d4931b8c9 100644 --- a/config/hashids.php +++ b/config/hashids.php @@ -1,5 +1,7 @@ 1, 'application' => env('APP_API_APPLICATION_RATELIMIT', 256), + + 'admin_period' => 1, + 'admin' => env('APP_API_ADMIN_RATELIMIT', 256), ], ]; diff --git a/config/ide-helper.php b/config/ide-helper.php index ada07696d..4f71d9222 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -1,5 +1,12 @@ false, 'helper_files' => [ - base_path() . '/vendor/laravel/framework/src/Illuminate/Support/helpers.php', - base_path() . '/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php', + base_path().'/vendor/laravel/framework/src/Illuminate/Support/helpers.php', + base_path().'/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php', ], /* @@ -183,8 +190,8 @@ return [ */ 'extra' => [ - 'Eloquent' => ['Illuminate\Database\Eloquent\Builder', 'Illuminate\Database\Query\Builder'], - 'Session' => ['Illuminate\Session\Store'], + 'Eloquent' => [Builder::class, Illuminate\Database\Query\Builder::class], + 'Session' => [Store::class], ], 'magic' => [], @@ -287,7 +294,7 @@ return [ | */ 'macro_default_return_types' => [ - Illuminate\Http\Client\Factory::class => Illuminate\Http\Client\PendingRequest::class, + Factory::class => PendingRequest::class, ], /* diff --git a/config/javascript.php b/config/javascript.php deleted file mode 100644 index 57504395d..000000000 --- a/config/javascript.php +++ /dev/null @@ -1,30 +0,0 @@ - [ - 'layouts.scripts', - ], - - /* - |-------------------------------------------------------------------------- - | JavaScript Namespace - |-------------------------------------------------------------------------- - | - | By default, we'll add variables to the global window object. However, - | it's recommended that you change this to some namespace - anything. - | That way, you can access vars, like "SomeNamespace.someVariable." - | - */ - 'js_namespace' => 'Pterodactyl', -]; diff --git a/config/logging.php b/config/logging.php index 4a7a9e0a5..3d4de979f 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,5 +1,7 @@ [ 'host' => env('PAPERTRAIL_URL'), 'port' => env('PAPERTRAIL_PORT'), - 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), ], 'processors' => [PsrLogMessageProcessor::class], ], diff --git a/config/mail.php b/config/mail.php index a62b40bda..c92701b8a 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,5 +1,7 @@ [ - 'info', - 'warning', - 'danger', - 'success', - ], - - /* - |-------------------------------------------------------------------------- - | Session Key - |-------------------------------------------------------------------------- - | - | The session key which is used to store flashed messages into the current - | session. This can be changed if it conflicts with another key. - | - */ - - 'session_key' => 'alert_messages', -]; diff --git a/config/pterodactyl.php b/config/pterodactyl.php index 23d382a2e..19a6488f7 100644 --- a/config/pterodactyl.php +++ b/config/pterodactyl.php @@ -1,5 +1,7 @@ explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( '%s%s', 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', - Laravel\Sanctum\Sanctum::currentApplicationUrlWithPort() + Sanctum::currentApplicationUrlWithPort() ))), /* @@ -57,8 +64,8 @@ return [ */ 'middleware' => [ - 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, - 'encrypt_cookies' => Pterodactyl\Http\Middleware\EncryptCookies::class, - 'verify_csrf_token' => Pterodactyl\Http\Middleware\VerifyCsrfToken::class, + 'authenticate_session' => AuthenticateSession::class, + 'encrypt_cookies' => EncryptCookies::class, + 'verify_csrf_token' => PreventRequestForgery::class, ], ]; diff --git a/config/scribe.php b/config/scribe.php new file mode 100644 index 000000000..6d2561679 --- /dev/null +++ b/config/scribe.php @@ -0,0 +1,291 @@ + for the generated documentation. + 'title' => config('app.name').' API Reference', + + // A short description of your API. Will be included in the docs webpage, Postman collection and OpenAPI spec. + 'description' => 'OpenAPI reference for the Application, Client, and Admin APIs.', + + // Text to place in the "Introduction" section, right after the `description`. Markdown and HTML are supported. + 'intro_text' => <<<'INTRO' + This documentation aims to provide all the information you need to work with our API. + + + INTRO, + + // The base URL displayed in the docs. + // If you're using `laravel` type, you can set this to a dynamic string, like '{{ config("app.tenant_url") }}' to get a dynamic base URL. + 'base_url' => config('app.url'), + + // Routes to include in the docs + 'routes' => [ + [ + 'match' => [ + // Match only routes whose paths match this pattern (use * as a wildcard to match any characters). Example: 'users/*'. + 'prefixes' => [ + 'api/application*', + 'api/client*', + 'api/admin*', + ], + + // Match only routes whose domains match this pattern (use * as a wildcard to match any characters). Example: 'api.*'. + 'domains' => ['*'], + ], + + // Include these routes even if they did not match the rules above. + 'include' => [ + 'GET /sanctum/csrf-cookie', + 'POST /auth/login', + 'POST /auth/login/checkpoint', + 'POST /auth/logout', + 'POST /auth/password', + 'POST /auth/password/reset', + ], + + // Exclude these routes even if they matched the rules above. + 'exclude' => [ + // 'GET /health', 'admin.*' + ], + ], + ], + + // The type of documentation output to generate. + // - "static" will generate a static HTMl page in the /public/docs folder, + // - "laravel" will generate the documentation as a Blade view, so you can add routing and authentication. + // - "external_static" and "external_laravel" do the same as above, but pass the OpenAPI spec as a URL to an external UI template + 'type' => 'laravel', + + // See https://scribe.knuckles.wtf/laravel/reference/config#theme for supported options + 'theme' => 'default', + + 'static' => [ + // HTML documentation, assets and Postman collection will be generated to this folder. + // Source Markdown will still be in resources/docs. + 'output_path' => 'public/docs', + ], + + 'laravel' => [ + // Whether to automatically create a docs route for you to view your generated docs. You can still set up routing manually. + 'add_routes' => false, + + // URL path to use for the docs endpoint (if `add_routes` is true). + // By default, `/docs` opens the HTML page, `/docs.postman` opens the Postman collection, and `/docs.openapi` the OpenAPI spec. + 'docs_url' => '/docs', + + // Directory within `public` in which to store CSS and JS assets. + // By default, assets are stored in `public/vendor/scribe`. + // If set, assets will be stored in `public/{{assets_directory}}` + 'assets_directory' => null, + + // Middleware to attach to the docs endpoint (if `add_routes` is true). + 'middleware' => [], + ], + + 'external' => [ + 'html_attributes' => [], + ], + + 'try_it_out' => [ + // Add a Try It Out button to your endpoints so consumers can test endpoints right from their browser. + // Don't forget to enable CORS headers for your endpoints. + 'enabled' => false, + + // The base URL to use in the API tester. Leave as null to be the same as the displayed URL (`scribe.base_url`). + 'base_url' => null, + + // [Laravel Sanctum] Fetch a CSRF token before each request, and add it as an X-XSRF-TOKEN header. + 'use_csrf' => false, + + // The URL to fetch the CSRF token from (if `use_csrf` is true). + 'csrf_url' => '/sanctum/csrf-cookie', + ], + + // How is your API authenticated? This information will be used in the displayed docs, generated examples and response calls. + 'auth' => [ + // Set this to true if ANY endpoints in your API use authentication. + 'enabled' => true, + + // Set this to true if your API should be authenticated by default. If so, you must also set `enabled` (above) to true. + // You can then use @unauthenticated or @authenticated on individual endpoints to change their status from the default. + 'default' => true, + + // Where is the auth value meant to be sent in a request? + 'in' => AuthIn::BEARER->value, + + // The name of the auth parameter (e.g. token, key, apiKey) or header (e.g. Authorization, Api-Key). + 'name' => 'Authorization', + + // The value of the parameter to be used by Scribe to authenticate response calls. + // This will NOT be included in the generated documentation. If empty, Scribe will use a random value. + 'use_value' => env('SCRIBE_AUTH_KEY'), + + // Placeholder your users will see for the auth parameter in the example requests. + // Set this to null if you want Scribe to use a random value as placeholder instead. + 'placeholder' => '{YOUR_AUTH_KEY}', + + // Any extra authentication-related info for your users. Markdown and HTML are supported. + 'extra_info' => 'Application API requests require an application API token, or a client API token, that belongs to a root administrator. Admin API requests require a client API token that belongs to a root administrator, and reject application API tokens. Client API requests require a client API token.', + ], + + // Example requests for each endpoint will be shown in each of these languages. + // Supported options are: bash, javascript, php, python + // To add a language of your own, see https://scribe.knuckles.wtf/laravel/advanced/example-requests + // Note: does not work for `external` docs types + 'example_languages' => [ + 'bash', + 'javascript', + ], + + // Generate a Postman collection (v2.1.0) in addition to HTML docs. + // For 'static' docs, the collection will be generated to public/docs/collection.json. + // For 'laravel' docs, it will be generated to storage/app/scribe/collection.json. + // Setting `laravel.add_routes` to true (above) will also add a route for the collection. + 'postman' => [ + 'enabled' => true, + + 'overrides' => [ + // 'info.version' => '2.0.0', + ], + ], + + // Generate an OpenAPI spec in addition to docs webpage. + // For 'static' docs, the collection will be generated to public/docs/openapi.yaml. + // For 'laravel' docs, it will be generated to storage/app/scribe/openapi.yaml. + // Setting `laravel.add_routes` to true (above) will also add a route for the spec. + 'openapi' => [ + 'enabled' => true, + + // The OpenAPI spec version to generate. Supported versions: '3.0.3', '3.1.0'. + // OpenAPI 3.1 is more compatible with JSON Schema and is becoming the dominant version. + // See https://spec.openapis.org/oas/v3.1.0 for details on 3.1 changes. + 'version' => '3.0.3', + + 'overrides' => [ + // 'info.version' => '2.0.0', + ], + + // Additional generators to use when generating the OpenAPI spec. + // Should extend `Knuckles\Scribe\Writing\OpenApiSpecGenerators\OpenApiGenerator`. + 'generators' => [ + PterodactylOpenApiGenerator::class, + ], + ], + + 'groups' => [ + // Endpoints which don't have a @group will be placed in this default group. + 'default' => 'Endpoints', + + // By default, Scribe will sort groups alphabetically, and endpoints in the order their routes are defined. + // You can override this by listing the groups, subgroups and endpoints here in the order you want them. + // See https://scribe.knuckles.wtf/blog/laravel-v4#easier-sorting and https://scribe.knuckles.wtf/laravel/reference/config#order for details + // Note: does not work for `external` docs types + 'order' => [], + ], + + // Custom logo path. This will be used as the value of the src attribute for the tag, + // so make sure it points to an accessible URL or path. Set to false to not use a logo. + // For example, if your logo is in public/img: + // - 'logo' => '../img/logo.png' // for `static` type (output folder is public/docs) + // - 'logo' => 'img/logo.png' // for `laravel` type + 'logo' => false, + + // Customize the "Last updated" value displayed in the docs by specifying tokens and formats. + // Examples: + // - {date:F j Y} => March 28, 2022 + // - {git:short} => Short hash of the last Git commit + // Available tokens are `{date:}` and `{git:}`. + // The format you pass to `date` will be passed to PHP's `date()` function. + // The format you pass to `git` can be either "short" or "long". + // Note: does not work for `external` docs types + 'last_updated' => 'Last updated: {date:F j, Y}', + + 'examples' => [ + // Set this to any number to generate the same example values for parameters on each run, + 'faker_seed' => 1234, + + // With API resources and transformers, Scribe tries to generate example models to use in your API responses. + // By default, Scribe will try the model's factory, and if that fails, try fetching the first from the database. + // You can reorder or remove strategies here. + 'models_source' => ['factoryCreate', 'factoryMake', 'databaseFirst'], + ], + + // The strategies Scribe will use to extract information about your routes at each stage. + // Use configureStrategy() to specify settings for a strategy in the list. + // Use removeStrategies() to remove an included strategy. + 'strategies' => [ + 'metadata' => [ + GetFromDocBlocks::class, + GetFromMetadataAttributes::class, + ], + 'headers' => [ + ...Defaults::HEADERS_STRATEGIES, + StaticData::withSettings(data: [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]), + ], + 'urlParameters' => [ + ...Defaults::URL_PARAMETERS_STRATEGIES, + InferPterodactylUrlParameters::class, + ], + 'queryParameters' => removeStrategies( + Defaults::QUERY_PARAMETERS_STRATEGIES, + [GetFromFormRequest::class] + ), + 'bodyParameters' => [ + InferPterodactylBodyParameters::class, + ...removeStrategies( + Defaults::BODY_PARAMETERS_STRATEGIES, + [Strategies\BodyParameters\GetFromFormRequest::class] + ), + ], + 'responses' => [ + ...removeStrategies( + Defaults::RESPONSES_STRATEGIES, + [ + ResponseCalls::class, + UseResponseAttributes::class, + ] + ), + UsePterodactylResponseAttributes::class, + InferPterodactylResponses::class, + ], + 'responseFields' => [ + ...Defaults::RESPONSE_FIELDS_STRATEGIES, + ], + ], + + // For response calls, API resource responses and transformer responses, + // Scribe will try to start database transactions, so no changes are persisted to your database. + // Tell Scribe which connections should be transacted here. If you only use one db connection, you can leave this as is. + 'database_connections_to_transact' => [config('database.default')], + + 'fractal' => [ + // If you are using a custom serializer with league/fractal, you can specify it here. + 'serializer' => PterodactylSerializer::class, + ], +]; diff --git a/config/services.php b/config/services.php index f8360cd32..7b009f087 100644 --- a/config/services.php +++ b/config/services.php @@ -1,5 +1,7 @@ env( 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'pterodactyl'), '_') . '_session' + Str::slug(env('APP_NAME', 'pterodactyl'), '_').'_session' ), /* diff --git a/config/trustedproxy.php b/config/trustedproxy.php index 7e0166af8..136bdbfa1 100644 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -1,5 +1,7 @@ in_array(env('TRUSTED_PROXIES', []), ['*', '**']) ? - env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES') ?? ''), + 'proxies' => (function (): string|array { + $value = (string) env('TRUSTED_PROXIES', ''); + + return in_array($value, ['*', '**'], true) ? $value : array_values(array_filter(explode(',', $value))); + })(), ]; diff --git a/config/view.php b/config/view.php index 24dea7a4a..89d71777b 100644 --- a/config/view.php +++ b/config/view.php @@ -1,5 +1,7 @@ + */ +class ActivityLogFactory extends Factory +{ + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = ActivityLog::class; + + /** + * Define the model's default state. + */ + public function definition(): array + { + return [ + 'event' => 'user:account.email-changed', + 'ip' => fake()->ipv4(), + 'description' => null, + 'properties' => [ + 'old' => 'old-user@example.com', + 'new' => 'new-user@example.com', + ], + 'timestamp' => Date::now(), + ]; + } + + /** + * Assign a user actor to the activity log entry. + */ + public function withActor(): self + { + return $this->state([ + 'actor_id' => User::factory(), + 'actor_type' => 'user', + ]); + } +} diff --git a/database/Factories/AllocationFactory.php b/database/Factories/AllocationFactory.php index 4a5eb70c0..4a0a0648d 100644 --- a/database/Factories/AllocationFactory.php +++ b/database/Factories/AllocationFactory.php @@ -1,11 +1,17 @@ + */ class AllocationFactory extends Factory { /** @@ -21,8 +27,9 @@ class AllocationFactory extends Factory public function definition(): array { return [ - 'ip' => $this->faker->unique()->ipv4, - 'port' => $this->faker->unique()->numberBetween(1024, 65535), + 'node_id' => Node::factory()->withLocation(), + 'ip' => fake()->unique()->ipv4(), + 'port' => fake()->unique()->numberBetween(1024, 65535), ]; } @@ -33,4 +40,19 @@ class AllocationFactory extends Factory { return $this->for($server)->for($server->node); } + + /** + * Attaches the allocation to a freshly created server on the same node. + */ + public function withServer(): self + { + return $this->state(function (): array { + $server = Server::factory()->withRelationships()->create(); + + return [ + 'node_id' => $server->node_id, + 'server_id' => $server->id, + ]; + }); + } } diff --git a/database/Factories/ApiKeyFactory.php b/database/Factories/ApiKeyFactory.php index 40c78ce26..7f81de3a6 100644 --- a/database/Factories/ApiKeyFactory.php +++ b/database/Factories/ApiKeyFactory.php @@ -1,12 +1,18 @@ + */ class ApiKeyFactory extends Factory { /** @@ -24,13 +30,24 @@ class ApiKeyFactory extends Factory static $token; return [ + 'user_id' => User::factory(), 'key_type' => ApiKey::TYPE_APPLICATION, 'identifier' => ApiKey::generateTokenIdentifier(ApiKey::TYPE_APPLICATION), 'token' => $token ?: $token = encrypt(Str::random(ApiKey::KEY_LENGTH)), 'allowed_ips' => null, 'memo' => 'Test Function Key', - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => Date::now(), + 'updated_at' => Date::now(), ]; } + + /** + * Restrict the key to an example IP range for documentation purposes. + */ + public function withAllowedIps(): self + { + return $this->state([ + 'allowed_ips' => ['127.0.0.1'], + ]); + } } diff --git a/database/Factories/BackupFactory.php b/database/Factories/BackupFactory.php index 4333ee34e..2b76248d7 100644 --- a/database/Factories/BackupFactory.php +++ b/database/Factories/BackupFactory.php @@ -1,12 +1,18 @@ + */ class BackupFactory extends Factory { /** @@ -22,8 +28,10 @@ class BackupFactory extends Factory public function definition(): array { return [ + 'server_id' => Server::factory()->withRelationships(), 'uuid' => Uuid::uuid4()->toString(), - 'name' => $this->faker->sentence, + 'name' => fake()->sentence(), + 'ignored_files' => [], 'disk' => Backup::ADAPTER_WINGS, 'is_successful' => true, 'created_at' => CarbonImmutable::now(), diff --git a/database/Factories/DatabaseFactory.php b/database/Factories/DatabaseFactory.php index d3c6f2a57..91581f687 100644 --- a/database/Factories/DatabaseFactory.php +++ b/database/Factories/DatabaseFactory.php @@ -1,12 +1,19 @@ + */ class DatabaseFactory extends Factory { /** @@ -24,12 +31,22 @@ class DatabaseFactory extends Factory static $password; return [ + 'server_id' => Server::factory()->withRelationships(), + 'database_host_id' => DatabaseHost::factory(), 'database' => Str::random(10), 'username' => Str::random(10), 'remote' => '%', 'password' => $password ?: encrypt('test123'), - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => Date::now(), + 'updated_at' => Date::now(), ]; } + + public function withServerAndHost(): self + { + return $this->state(fn (): array => [ + 'server_id' => Server::factory()->withRelationships()->create()->id, + 'database_host_id' => DatabaseHost::factory()->create()->id, + ]); + } } diff --git a/database/Factories/DatabaseHostFactory.php b/database/Factories/DatabaseHostFactory.php index b65e856ea..cfd4e21cd 100644 --- a/database/Factories/DatabaseHostFactory.php +++ b/database/Factories/DatabaseHostFactory.php @@ -1,11 +1,17 @@ + */ class DatabaseHostFactory extends Factory { /** @@ -21,11 +27,12 @@ class DatabaseHostFactory extends Factory public function definition(): array { return [ - 'name' => $this->faker->colorName, - 'host' => $this->faker->unique()->ipv4, + 'node_id' => Node::factory()->withLocation(), + 'name' => fake()->colorName(), + 'host' => fake()->unique()->ipv4(), 'port' => 3306, - 'username' => $this->faker->colorName, - 'password' => Crypt::encrypt($this->faker->word), + 'username' => fake()->colorName(), + 'password' => Crypt::encrypt(fake()->word()), ]; } } diff --git a/database/Factories/EggFactory.php b/database/Factories/EggFactory.php index 4085b70e5..e88e527fc 100644 --- a/database/Factories/EggFactory.php +++ b/database/Factories/EggFactory.php @@ -1,11 +1,16 @@ + */ class EggFactory extends Factory { /** @@ -22,9 +27,18 @@ class EggFactory extends Factory { return [ 'uuid' => Uuid::uuid4()->toString(), - 'name' => $this->faker->name, - 'description' => implode(' ', $this->faker->sentences()), + 'author' => 'support@pterodactyl.io', + 'name' => fake()->name(), + 'description' => implode(' ', fake()->sentences()), + 'docker_images' => ['Java' => 'ghcr.io/pterodactyl/yolks:java_23'], + 'features' => ['eula'], + 'file_denylist' => ['secret.txt'], 'startup' => 'java -jar test.jar', + 'config_from' => null, + 'config_stop' => 'stop', + 'config_startup' => '{"done": ["Done"]}', + 'config_logs' => '{"custom": false, "location": "logs/latest.log"}', + 'config_files' => '{"server.properties": {"parser": "properties", "find": {"server-ip": "0.0.0.0", "server-port": "{{server.build.default.port}}"}}}', ]; } } diff --git a/database/Factories/EggVariableFactory.php b/database/Factories/EggVariableFactory.php index c2bce816b..2097b8283 100644 --- a/database/Factories/EggVariableFactory.php +++ b/database/Factories/EggVariableFactory.php @@ -1,11 +1,17 @@ + */ class EggVariableFactory extends Factory { /** @@ -21,13 +27,15 @@ class EggVariableFactory extends Factory public function definition(): array { return [ - 'name' => $this->faker->unique()->firstName, - 'description' => $this->faker->sentence(), - 'env_variable' => Str::upper(Str::replaceArray(' ', ['_'], $this->faker->words(2, true))), - 'default_value' => $this->faker->colorName, + 'egg_id' => Egg::factory(), + 'name' => fake()->unique()->firstName(), + 'description' => fake()->sentence(), + 'env_variable' => Str::upper(Str::replaceArray(' ', ['_'], fake()->words(2, true))), + 'default_value' => fake()->colorName(), 'user_viewable' => 0, 'user_editable' => 0, 'rules' => 'required|string', + 'sort_order' => 0, ]; } @@ -36,11 +44,9 @@ class EggVariableFactory extends Factory */ public function viewable(): static { - return $this->state(function (array $attributes) { - return [ - 'user_viewable' => 1, - ]; - }); + return $this->state(fn (array $attributes): array => [ + 'user_viewable' => 1, + ]); } /** @@ -48,10 +54,8 @@ class EggVariableFactory extends Factory */ public function editable(): static { - return $this->state(function (array $attributes) { - return [ - 'user_editable' => 1, - ]; - }); + return $this->state(fn (array $attributes): array => [ + 'user_editable' => 1, + ]); } } diff --git a/database/Factories/LocationFactory.php b/database/Factories/LocationFactory.php index 922149dfd..457b4edc9 100644 --- a/database/Factories/LocationFactory.php +++ b/database/Factories/LocationFactory.php @@ -1,12 +1,15 @@ + * @extends Factory */ class LocationFactory extends Factory { diff --git a/database/Factories/MountFactory.php b/database/Factories/MountFactory.php new file mode 100644 index 000000000..02833d664 --- /dev/null +++ b/database/Factories/MountFactory.php @@ -0,0 +1,39 @@ + + */ +class MountFactory extends Factory +{ + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = Mount::class; + + /** + * Define the model's default state. + */ + public function definition(): array + { + return [ + 'uuid' => Uuid::uuid4()->toString(), + 'name' => 'FactoryMount_'.Str::random(10), + 'description' => fake()->sentence(), + 'source' => '/mnt/'.Str::lower(Str::random(10)), + 'target' => '/mnt/'.Str::lower(Str::random(10)), + 'read_only' => false, + 'user_mountable' => false, + ]; + } +} diff --git a/database/Factories/NestFactory.php b/database/Factories/NestFactory.php deleted file mode 100644 index 9a5755ba1..000000000 --- a/database/Factories/NestFactory.php +++ /dev/null @@ -1,30 +0,0 @@ - Uuid::uuid4()->toString(), - 'author' => 'testauthor@example.com', - 'name' => $this->faker->word, - 'description' => null, - ]; - } -} diff --git a/database/Factories/NodeFactory.php b/database/Factories/NodeFactory.php index 1dbd5d9f5..5e1ae7739 100644 --- a/database/Factories/NodeFactory.php +++ b/database/Factories/NodeFactory.php @@ -1,13 +1,19 @@ + */ class NodeFactory extends Factory { /** @@ -25,8 +31,8 @@ class NodeFactory extends Factory return [ 'uuid' => Uuid::uuid4()->toString(), 'public' => true, - 'name' => 'FactoryNode_' . Str::random(10), - 'fqdn' => $this->faker->unique()->ipv4, + 'name' => 'FactoryNode_'.Str::random(10), + 'fqdn' => fake()->unique()->ipv4(), 'scheme' => 'http', 'behind_proxy' => false, 'memory' => 1024, @@ -41,4 +47,9 @@ class NodeFactory extends Factory 'daemonBase' => '/var/lib/pterodactyl/volumes', ]; } + + public function withLocation(): self + { + return $this->for(Location::factory()); + } } diff --git a/database/Factories/ScheduleFactory.php b/database/Factories/ScheduleFactory.php index 0a28f4c41..bb802c51e 100644 --- a/database/Factories/ScheduleFactory.php +++ b/database/Factories/ScheduleFactory.php @@ -1,10 +1,16 @@ + */ class ScheduleFactory extends Factory { /** @@ -20,7 +26,8 @@ class ScheduleFactory extends Factory public function definition(): array { return [ - 'name' => $this->faker->firstName(), + 'server_id' => Server::factory()->withRelationships(), + 'name' => fake()->firstName(), ]; } } diff --git a/database/Factories/ServerFactory.php b/database/Factories/ServerFactory.php index d89bd6a56..83541ac38 100644 --- a/database/Factories/ServerFactory.php +++ b/database/Factories/ServerFactory.php @@ -1,13 +1,23 @@ + */ class ServerFactory extends Factory { /** @@ -27,8 +37,8 @@ class ServerFactory extends Factory return [ 'uuid' => Uuid::uuid4()->toString(), 'uuidShort' => Str::lower(Str::random(8)), - 'name' => $this->faker->firstName, - 'description' => implode(' ', $this->faker->sentences()), + 'name' => fake()->firstName(), + 'description' => implode(' ', fake()->sentences()), 'skip_scripts' => 0, 'status' => null, 'memory' => 512, @@ -43,8 +53,30 @@ class ServerFactory extends Factory 'allocation_limit' => null, 'database_limit' => null, 'backup_limit' => 0, - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => Date::now(), + 'updated_at' => Date::now(), ]; } + + public function withRelationships(): self + { + return $this->state(function (): array { + $node = Node::factory()->withLocation()->create(); + $allocation = Allocation::factory()->for($node)->create(); + $egg = Egg::factory()->create(); + + EggVariable::factory()->create(['egg_id' => $egg->id, 'user_viewable' => 1, 'user_editable' => 1]); + + return [ + 'owner_id' => User::factory()->create()->id, + 'node_id' => $node->id, + 'allocation_id' => $allocation->id, + 'egg_id' => $egg->id, + 'allocation_limit' => 5, + 'database_limit' => 5, + ]; + })->afterCreating(function (Server $server): void { + $server->allocation()->update(['server_id' => $server->id]); + }); + } } diff --git a/database/Factories/ServerTransferFactory.php b/database/Factories/ServerTransferFactory.php index 37e56c617..29f2c0e24 100644 --- a/database/Factories/ServerTransferFactory.php +++ b/database/Factories/ServerTransferFactory.php @@ -1,10 +1,18 @@ + */ class ServerTransferFactory extends Factory { /** @@ -22,6 +30,11 @@ class ServerTransferFactory extends Factory public function definition() { return [ + 'server_id' => Server::factory()->withRelationships(), + 'old_node' => fn (array $attributes) => Server::query()->findOrFail($attributes['server_id'])->node_id, + 'old_allocation' => fn (array $attributes) => Server::query()->findOrFail($attributes['server_id'])->allocation_id, + 'new_node' => Node::factory()->withLocation(), + 'new_allocation' => fn (array $attributes) => Allocation::factory()->create(['node_id' => $attributes['new_node']])->id, 'old_additional_allocations' => [], 'new_additional_allocations' => [], 'successful' => null, diff --git a/database/Factories/SubuserFactory.php b/database/Factories/SubuserFactory.php index 7db93d4d1..f5d869046 100644 --- a/database/Factories/SubuserFactory.php +++ b/database/Factories/SubuserFactory.php @@ -1,11 +1,18 @@ + */ class SubuserFactory extends Factory { /** @@ -21,8 +28,10 @@ class SubuserFactory extends Factory public function definition(): array { return [ + 'user_id' => User::factory(), + 'server_id' => Server::factory()->withRelationships(), 'permissions' => [ - Permission::ACTION_WEBSOCKET_CONNECT, + Permissions::WebsocketConnect->value, ], ]; } diff --git a/database/Factories/TagFactory.php b/database/Factories/TagFactory.php new file mode 100644 index 000000000..77765dd18 --- /dev/null +++ b/database/Factories/TagFactory.php @@ -0,0 +1,51 @@ + + */ +class TagFactory extends Factory +{ + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = Tag::class; + + /** + * Define the model's default state. + */ + public function definition(): array + { + $name = fake()->unique()->words(2, true); + + return [ + 'name' => $name, + // Slugs are stored verbatim, so the factory does not transform the name + // beyond making it a single token that reads like a real tag. + 'slug' => str_replace(' ', '-', mb_strtolower($name)), + 'color' => fake()->hexColor(), + 'legacy_nest_id' => fake()->numberBetween(1, 1000), + ]; + } + + /** + * A built-in game tag, whose name and colour come from the EggSpecificTags enum + * rather than the stored columns. + */ + public function predefined(string $slug = 'minecraft'): self + { + return $this->state(fn (): array => [ + 'name' => $slug, + 'slug' => $slug, + 'color' => null, + ]); + } +} diff --git a/database/Factories/TaskFactory.php b/database/Factories/TaskFactory.php index 32bf950cc..09ff06ad2 100644 --- a/database/Factories/TaskFactory.php +++ b/database/Factories/TaskFactory.php @@ -1,8 +1,11 @@ $this->faker->numberBetween(1, 10), + 'schedule_id' => Schedule::factory(), + 'sequence_id' => fake()->numberBetween(1, 10), 'action' => 'command', 'payload' => 'test command', 'time_offset' => 120, diff --git a/database/Factories/UserFactory.php b/database/Factories/UserFactory.php index 8a4774676..42f511d81 100644 --- a/database/Factories/UserFactory.php +++ b/database/Factories/UserFactory.php @@ -1,14 +1,17 @@ + * @extends Factory */ class UserFactory extends Factory { @@ -22,16 +25,17 @@ class UserFactory extends Factory return [ 'external_id' => null, 'uuid' => Uuid::uuid4()->toString(), - 'username' => $this->faker->userName . '_' . Str::random(10), - 'email' => Str::random(32) . '@example.com', - 'name_first' => $this->faker->firstName, - 'name_last' => $this->faker->lastName, + 'username' => fake()->userName().'_'.Str::random(10), + 'email' => Str::random(32).'@example.com', + 'name_first' => fake()->firstName(), + 'name_last' => fake()->lastName(), 'password' => $password ?: $password = bcrypt('password'), + 'remember_token' => Str::random(10), 'language' => 'en', 'root_admin' => false, 'use_totp' => false, - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => Date::now(), + 'updated_at' => Date::now(), ]; } diff --git a/database/Factories/UserSSHKeyFactory.php b/database/Factories/UserSSHKeyFactory.php index ab20b251d..9f2b7e237 100644 --- a/database/Factories/UserSSHKeyFactory.php +++ b/database/Factories/UserSSHKeyFactory.php @@ -1,9 +1,12 @@ $this->faker->name(), + 'user_id' => User::factory(), + 'name' => fake()->name(), 'public_key' => $key->toString('PKCS8'), 'fingerprint' => $key->getFingerprint('sha256'), ]; diff --git a/database/Seeders/DatabaseSeeder.php b/database/Seeders/DatabaseSeeder.php index ae534fe6a..8aa52b128 100644 --- a/database/Seeders/DatabaseSeeder.php +++ b/database/Seeders/DatabaseSeeder.php @@ -1,5 +1,7 @@ call(NestSeeder::class); $this->call(EggSeeder::class); } } diff --git a/database/Seeders/EggSeeder.php b/database/Seeders/EggSeeder.php index 605c1ad91..98ed1a47b 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -1,82 +1,77 @@ importerService = $importerService; - $this->updateImporterService = $updateImporterService; - } + public function __construct(protected ImportsEggs $importer, protected UpdatesEggsFromImports $updater) {} /** * Run the egg seeder. */ - public function run() + public function run(): void { - foreach (static::$import as $nest) { - /* @noinspection PhpParamsInspection */ - $this->parseEggFiles( - Nest::query()->where('author', 'support@pterodactyl.io')->where('name', $nest)->firstOrFail() - ); + foreach (static::$import as $directory) { + $this->parseEggFiles($directory); } } /** - * Loop through the list of egg files and import them. + * Loop through the list of egg files in one directory and import them. + * + * Eggs are matched on author and name alone now that they are no longer scoped + * to a nest, so an egg only ever exists once across every seed directory. */ - protected function parseEggFiles(Nest $nest) + protected function parseEggFiles(string $directory) { - $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($nest->name))); + $files = new DirectoryIterator(database_path('Seeders/eggs/'.$directory)); - $this->command->alert('Updating Eggs for Nest: ' . $nest->name); - /** @var \DirectoryIterator $file */ + $this->command->alert('Updating Eggs from: '.$directory); + /** @var DirectoryIterator $file */ foreach ($files as $file) { - if (!$file->isFile() || !$file->isReadable()) { + if (! $file->isFile() || ! $file->isReadable()) { continue; } $decoded = json_decode(file_get_contents($file->getRealPath()), true, 512, JSON_THROW_ON_ERROR); $file = new UploadedFile($file->getPathname(), $file->getFilename(), 'application/json'); - $egg = $nest->eggs() + $egg = Egg::query() ->where('author', $decoded['author']) ->where('name', $decoded['name']) ->first(); if ($egg instanceof Egg) { - $this->updateImporterService->handle($egg, $file); - $this->command->info('Updated ' . $decoded['name']); + $this->updater->update($egg, $file); + $this->command->info('Updated '.$decoded['name']); } else { - $this->importerService->handle($file, $nest->id); - $this->command->comment('Created ' . $decoded['name']); + $this->importer->import($file); + $this->command->comment('Created '.$decoded['name']); } } diff --git a/database/Seeders/NestSeeder.php b/database/Seeders/NestSeeder.php deleted file mode 100644 index 4d2803e28..000000000 --- a/database/Seeders/NestSeeder.php +++ /dev/null @@ -1,108 +0,0 @@ -creationService = $creationService; - $this->repository = $repository; - } - - /** - * Run the seeder to add missing nests to the Panel. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - public function run() - { - $items = $this->repository->findWhere([ - 'author' => 'support@pterodactyl.io', - ])->keyBy('name')->toArray(); - - $this->createMinecraftNest(array_get($items, 'Minecraft')); - $this->createSourceEngineNest(array_get($items, 'Source Engine')); - $this->createVoiceServersNest(array_get($items, 'Voice Servers')); - $this->createRustNest(array_get($items, 'Rust')); - } - - /** - * Create the Minecraft nest to be used later on. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - private function createMinecraftNest(?array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Minecraft', - 'description' => 'Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!', - ], 'support@pterodactyl.io'); - } - } - - /** - * Create the Source Engine Games nest to be used later on. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - private function createSourceEngineNest(?array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Source Engine', - 'description' => 'Includes support for most Source Dedicated Server games.', - ], 'support@pterodactyl.io'); - } - } - - /** - * Create the Voice Servers nest to be used later on. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - private function createVoiceServersNest(?array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Voice Servers', - 'description' => 'Voice servers such as Mumble and Teamspeak 3.', - ], 'support@pterodactyl.io'); - } - } - - /** - * Create the Rust nest to be used later on. - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - */ - private function createRustNest(?array $nest = null) - { - if (is_null($nest)) { - $this->creationService->handle([ - 'name' => 'Rust', - 'description' => 'Rust - A game where you must fight to survive.', - ], 'support@pterodactyl.io'); - } - } -} diff --git a/database/migrations/2026_05_30_000000_require_complete_legacy_migration_history.php b/database/migrations/2026_05_30_000000_require_complete_legacy_migration_history.php new file mode 100644 index 000000000..767edb8fe --- /dev/null +++ b/database/migrations/2026_05_30_000000_require_complete_legacy_migration_history.php @@ -0,0 +1,42 @@ +map(fn (SplFileInfo $file): string => $file->getBasename('.php')); + + $recorded = DB::table('migrations')->whereIn('migration', $expected->all())->pluck('migration'); + $missing = $expected->diff($recorded)->sort()->values(); + + throw_if($missing->isNotEmpty(), RuntimeException::class, sprintf( + 'This database is missing %d Pterodactyl Panel 1.x migration(s), starting with %s. ' + .'Update the Panel to the latest 1.x release and run "php artisan migrate --force" there before upgrading to 2.x. ' + .'No changes were made.', + $missing->count(), + $missing->first(), + )); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // Nothing to reverse: this migration only reads. + } +}; diff --git a/database/migrations/2026_05_31_000000_add_sort_order_to_egg_variables_table.php b/database/migrations/2026_05_31_000000_add_sort_order_to_egg_variables_table.php new file mode 100644 index 000000000..259c66079 --- /dev/null +++ b/database/migrations/2026_05_31_000000_add_sort_order_to_egg_variables_table.php @@ -0,0 +1,29 @@ +unsignedInteger('sort_order')->nullable()->after('rules'); + }); + } + + public function down(): void + { + Schema::table('egg_variables', function (Blueprint $table): void { + $table->dropColumn('sort_order'); + }); + } +}; diff --git a/database/migrations/2026_07_06_000001_create_extensions_tables.php b/database/migrations/2026_07_06_000001_create_extensions_tables.php new file mode 100644 index 000000000..265b96a4a --- /dev/null +++ b/database/migrations/2026_07_06_000001_create_extensions_tables.php @@ -0,0 +1,38 @@ +id(); + $table->string('identifier', 48)->unique(); + $table->string('version', 64); + $table->boolean('enabled')->default(false); + $table->text('error')->nullable(); + $table->timestamps(); + }); + + Schema::create('extension_settings', function (Blueprint $table): void { + $table->id(); + $table->string('extension', 48); + $table->string('key', 191); + $table->json('value')->nullable(); + $table->timestamps(); + + $table->unique(['extension', 'key']); + }); + } + + public function down(): void + { + Schema::dropIfExists('extension_settings'); + Schema::dropIfExists('extensions'); + } +}; diff --git a/database/migrations/2026_07_07_000001_drop_extension_quarantine_column.php b/database/migrations/2026_07_07_000001_drop_extension_quarantine_column.php new file mode 100644 index 000000000..a5298e303 --- /dev/null +++ b/database/migrations/2026_07_07_000001_drop_extension_quarantine_column.php @@ -0,0 +1,32 @@ +dropColumn('quarantined_at'); + }); + } + + public function down(): void + { + if (! Schema::hasTable('extensions') || Schema::hasColumn('extensions', 'quarantined_at')) { + return; + } + + Schema::table('extensions', function (Blueprint $table): void { + $table->timestamp('quarantined_at')->nullable()->after('error'); + }); + } +}; diff --git a/database/migrations/2026_08_20_000001_create_tags_tables.php b/database/migrations/2026_08_20_000001_create_tags_tables.php new file mode 100644 index 000000000..90e615470 --- /dev/null +++ b/database/migrations/2026_08_20_000001_create_tags_tables.php @@ -0,0 +1,73 @@ +increments('id'); + $table->string('name'); + // Stored verbatim and never slugified: feature gating and the daemon + // configuration match on an exact string ("srcds", "rust"), so any + // transformation here would silently break those comparisons. + $table->string('slug'); + // Custom tags store their chip colour here. Built-in game tags ignore + // it — their colour comes from the EggSpecificTags enum. + $table->string('color', 32)->nullable(); + // The legacy nest a tag was migrated from, so the application API can + // still resolve a third-party billing module's nest_id to the tag (and + // its tagged eggs) once the Nest model is gone. Locations remain + // first-class, so they need no such mapping. + $table->unsignedInteger('legacy_nest_id')->nullable(); + $table->timestamps(); + + // The default utf8mb4_unicode_ci collation makes this case-insensitive, + // which is what TagBackfiller's slug folding assumes. + $table->unique('slug', 'tags_slug_unique'); + $table->index('legacy_nest_id', 'tags_legacy_nest_idx'); + }); + + // Polymorphic pivot attaching tags to nodes and eggs. taggable_type stores + // the registered morph-map alias ("node" / "egg"), not the FQCN. + Schema::create('taggables', function (Blueprint $table): void { + $table->unsignedInteger('tag_id'); + // How a tag attachment participates in deploy targeting. Only meaningful + // for node attachments: 'egg' marks a game the node accepts (OR-matched + // against the deploying egg's tags), 'deployment' marks a reservation the + // deploy must opt into (exact-matched against the deploy's tags). Egg + // attachments keep the default; their kind is implied by what they are + // attached to. The composite key deliberately excludes this column, so a + // tag holds exactly one kind per attachment. + $table->string('kind', 20)->default('egg'); + $table->string('taggable_type', 50); + $table->unsignedInteger('taggable_id'); + + // Composite natural key — there is no surrogate id to remap. + $table->primary(['tag_id', 'taggable_type', 'taggable_id'], 'taggables_primary'); + $table->index(['taggable_type', 'taggable_id'], 'taggables_taggable_idx'); + + $table->foreign('tag_id')->references('id')->on('tags')->cascadeOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('taggables'); + Schema::dropIfExists('tags'); + } +}; diff --git a/database/migrations/2026_08_20_000002_backfill_tags_from_nests.php b/database/migrations/2026_08_20_000002_backfill_tags_from_nests.php new file mode 100644 index 000000000..38db730d8 --- /dev/null +++ b/database/migrations/2026_08_20_000002_backfill_tags_from_nests.php @@ -0,0 +1,33 @@ +backfill(); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // Irreversible data backfill: tags created here are left in place on rollback. + } +}; diff --git a/database/migrations/2026_08_20_000003_make_eggs_nest_id_nullable.php b/database/migrations/2026_08_20_000003_make_eggs_nest_id_nullable.php new file mode 100644 index 000000000..cd855908c --- /dev/null +++ b/database/migrations/2026_08_20_000003_make_eggs_nest_id_nullable.php @@ -0,0 +1,35 @@ +unsignedInteger('nest_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + throw_if(DB::table('eggs')->whereNull('nest_id')->exists(), RuntimeException::class, 'Cannot restore required eggs.nest_id while top-level eggs still exist. Assign every egg to a legacy nest before rolling back.'); + + Schema::table('eggs', function (Blueprint $table): void { + $table->unsignedInteger('nest_id')->nullable(false)->change(); + }); + } +}; diff --git a/database/migrations/2026_08_20_000004_relax_nest_id_on_servers_table.php b/database/migrations/2026_08_20_000004_relax_nest_id_on_servers_table.php new file mode 100644 index 000000000..f1c55d452 --- /dev/null +++ b/database/migrations/2026_08_20_000004_relax_nest_id_on_servers_table.php @@ -0,0 +1,49 @@ +dropForeign(['nest_id']); + }); + + Schema::table('servers', function (Blueprint $table): void { + $table->unsignedInteger('nest_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + if (! Schema::hasColumn('servers', 'nest_id')) { + return; + } + + Schema::table('servers', function (Blueprint $table): void { + $table->unsignedInteger('nest_id')->nullable(false)->change(); + $table->foreign('nest_id')->references('id')->on('nests'); + }); + } +}; diff --git a/database/migrations/2026_10_02_215043_add_scope_and_secrets_to_extension_settings.php b/database/migrations/2026_10_02_215043_add_scope_and_secrets_to_extension_settings.php new file mode 100644 index 000000000..12d94da9c --- /dev/null +++ b/database/migrations/2026_10_02_215043_add_scope_and_secrets_to_extension_settings.php @@ -0,0 +1,38 @@ +string('scope', 64)->default('global'); + $table->unsignedInteger('user_id')->nullable(); + $table->unsignedInteger('server_id')->nullable(); + $table->boolean('is_secret')->default(false); + $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); + $table->foreign('server_id')->references('id')->on('servers')->cascadeOnDelete(); + $table->dropUnique(['extension', 'key']); + $table->unique(['extension', 'scope', 'key']); + }); + } + + public function down(): void + { + throw_if(DB::table('extension_settings')->where('scope', '!=', 'global')->orWhere('is_secret', true)->exists(), RuntimeException::class, 'Remove scoped settings and decrypt secrets before rolling back this migration.'); + + Schema::table('extension_settings', function (Blueprint $table): void { + $table->dropForeign(['user_id']); + $table->dropForeign(['server_id']); + $table->dropUnique(['extension', 'scope', 'key']); + $table->dropColumn(['scope', 'user_id', 'server_id', 'is_secret']); + $table->unique(['extension', 'key']); + }); + } +}; diff --git a/database/migrations/2026_10_04_090113_add_unique_server_user_to_subusers_table.php b/database/migrations/2026_10_04_090113_add_unique_server_user_to_subusers_table.php new file mode 100644 index 000000000..a58863679 --- /dev/null +++ b/database/migrations/2026_10_04_090113_add_unique_server_user_to_subusers_table.php @@ -0,0 +1,24 @@ +unique(['server_id', 'user_id']); + }); + } + + public function down(): void + { + Schema::table('subusers', function (Blueprint $table): void { + $table->dropUnique(['server_id', 'user_id']); + }); + } +}; diff --git a/database/migrations/2016_01_23_195641_add_allocations_table.php b/database/migrations/old/2016_01_23_195641_add_allocations_table.php similarity index 95% rename from database/migrations/2016_01_23_195641_add_allocations_table.php rename to database/migrations/old/2016_01_23_195641_add_allocations_table.php index e6306c3b2..5b58ba512 100644 --- a/database/migrations/2016_01_23_195641_add_allocations_table.php +++ b/database/migrations/old/2016_01_23_195641_add_allocations_table.php @@ -1,8 +1,10 @@ increments('id'); $table->mediumInteger('node')->unsigned(); $table->string('ip'); diff --git a/database/migrations/2016_01_23_195851_add_api_keys.php b/database/migrations/old/2016_01_23_195851_add_api_keys.php similarity index 86% rename from database/migrations/2016_01_23_195851_add_api_keys.php rename to database/migrations/old/2016_01_23_195851_add_api_keys.php index 1a7824b1c..eb3383586 100644 --- a/database/migrations/2016_01_23_195851_add_api_keys.php +++ b/database/migrations/old/2016_01_23_195851_add_api_keys.php @@ -1,8 +1,10 @@ increments('id'); $table->char('public', 16); $table->text('secret'); diff --git a/database/migrations/2016_01_23_200044_add_api_permissions.php b/database/migrations/old/2016_01_23_200044_add_api_permissions.php similarity index 93% rename from database/migrations/2016_01_23_200044_add_api_permissions.php rename to database/migrations/old/2016_01_23_200044_add_api_permissions.php index e587da0a3..7d78f6dbf 100644 --- a/database/migrations/2016_01_23_200044_add_api_permissions.php +++ b/database/migrations/old/2016_01_23_200044_add_api_permissions.php @@ -1,8 +1,10 @@ increments('id'); $table->mediumInteger('key_id')->unsigned(); $table->string('permission'); diff --git a/database/migrations/2016_01_23_200159_add_downloads.php b/database/migrations/old/2016_01_23_200159_add_downloads.php similarity index 86% rename from database/migrations/2016_01_23_200159_add_downloads.php rename to database/migrations/old/2016_01_23_200159_add_downloads.php index 9424578fb..58fd9f0ef 100644 --- a/database/migrations/2016_01_23_200159_add_downloads.php +++ b/database/migrations/old/2016_01_23_200159_add_downloads.php @@ -1,8 +1,10 @@ increments('id'); $table->char('token', 36)->unique(); $table->char('server', 36); diff --git a/database/migrations/2016_01_23_200421_create_failed_jobs_table.php b/database/migrations/old/2016_01_23_200421_create_failed_jobs_table.php similarity index 94% rename from database/migrations/2016_01_23_200421_create_failed_jobs_table.php rename to database/migrations/old/2016_01_23_200421_create_failed_jobs_table.php index 50d42ccc9..924f2502a 100644 --- a/database/migrations/2016_01_23_200421_create_failed_jobs_table.php +++ b/database/migrations/old/2016_01_23_200421_create_failed_jobs_table.php @@ -1,8 +1,10 @@ increments('id'); $table->text('connection'); $table->text('queue'); diff --git a/database/migrations/2016_01_23_200440_create_jobs_table.php b/database/migrations/old/2016_01_23_200440_create_jobs_table.php similarity index 90% rename from database/migrations/2016_01_23_200440_create_jobs_table.php rename to database/migrations/old/2016_01_23_200440_create_jobs_table.php index fe7f9686c..f89434f96 100644 --- a/database/migrations/2016_01_23_200440_create_jobs_table.php +++ b/database/migrations/old/2016_01_23_200440_create_jobs_table.php @@ -1,8 +1,10 @@ bigIncrements('id'); $table->string('queue'); $table->longText('payload'); diff --git a/database/migrations/2016_01_23_200528_add_locations.php b/database/migrations/old/2016_01_23_200528_add_locations.php similarity index 85% rename from database/migrations/2016_01_23_200528_add_locations.php rename to database/migrations/old/2016_01_23_200528_add_locations.php index 38d1e1710..cad9c5ca1 100644 --- a/database/migrations/2016_01_23_200528_add_locations.php +++ b/database/migrations/old/2016_01_23_200528_add_locations.php @@ -1,8 +1,10 @@ increments('id'); $table->string('short')->unique(); $table->string('long'); diff --git a/database/migrations/2016_01_23_200648_add_nodes.php b/database/migrations/old/2016_01_23_200648_add_nodes.php similarity index 93% rename from database/migrations/2016_01_23_200648_add_nodes.php rename to database/migrations/old/2016_01_23_200648_add_nodes.php index 371ebf049..a6051a695 100644 --- a/database/migrations/2016_01_23_200648_add_nodes.php +++ b/database/migrations/old/2016_01_23_200648_add_nodes.php @@ -1,8 +1,10 @@ increments('id'); $table->smallInteger('public')->unsigned(); $table->string('name'); diff --git a/database/migrations/2016_01_23_201433_add_password_resets.php b/database/migrations/old/2016_01_23_201433_add_password_resets.php similarity index 93% rename from database/migrations/2016_01_23_201433_add_password_resets.php rename to database/migrations/old/2016_01_23_201433_add_password_resets.php index 47c49146d..4c55fe715 100644 --- a/database/migrations/2016_01_23_201433_add_password_resets.php +++ b/database/migrations/old/2016_01_23_201433_add_password_resets.php @@ -1,8 +1,10 @@ string('email')->index(); $table->string('token')->index(); $table->timestamp('created_at'); diff --git a/database/migrations/2016_01_23_201531_add_permissions.php b/database/migrations/old/2016_01_23_201531_add_permissions.php similarity index 95% rename from database/migrations/2016_01_23_201531_add_permissions.php rename to database/migrations/old/2016_01_23_201531_add_permissions.php index 120a0e034..7479da624 100644 --- a/database/migrations/2016_01_23_201531_add_permissions.php +++ b/database/migrations/old/2016_01_23_201531_add_permissions.php @@ -1,8 +1,10 @@ increments('id'); $table->integer('user_id')->unsigned(); $table->integer('server_id')->unsigned(); diff --git a/database/migrations/2016_01_23_201649_add_server_variables.php b/database/migrations/old/2016_01_23_201649_add_server_variables.php similarity index 94% rename from database/migrations/2016_01_23_201649_add_server_variables.php rename to database/migrations/old/2016_01_23_201649_add_server_variables.php index 596c619d0..612cf7b72 100644 --- a/database/migrations/2016_01_23_201649_add_server_variables.php +++ b/database/migrations/old/2016_01_23_201649_add_server_variables.php @@ -1,8 +1,10 @@ increments('id'); $table->mediumInteger('server_id')->unsigned(); $table->mediumInteger('variable_id')->unsigned(); diff --git a/database/migrations/2016_01_23_201748_add_servers.php b/database/migrations/old/2016_01_23_201748_add_servers.php similarity index 94% rename from database/migrations/2016_01_23_201748_add_servers.php rename to database/migrations/old/2016_01_23_201748_add_servers.php index 901c1ff5c..63eb42c44 100644 --- a/database/migrations/2016_01_23_201748_add_servers.php +++ b/database/migrations/old/2016_01_23_201748_add_servers.php @@ -1,8 +1,10 @@ increments('id'); $table->char('uuid', 36)->unique(); $table->char('uuidShort', 8)->unique(); diff --git a/database/migrations/2016_01_23_202544_add_service_options.php b/database/migrations/old/2016_01_23_202544_add_service_options.php similarity index 95% rename from database/migrations/2016_01_23_202544_add_service_options.php rename to database/migrations/old/2016_01_23_202544_add_service_options.php index 382f67a1a..51a2dc8f1 100644 --- a/database/migrations/2016_01_23_202544_add_service_options.php +++ b/database/migrations/old/2016_01_23_202544_add_service_options.php @@ -1,8 +1,10 @@ increments('id'); $table->mediumInteger('parent_service')->unsigned(); $table->string('name'); diff --git a/database/migrations/2016_01_23_202731_add_service_varibles.php b/database/migrations/old/2016_01_23_202731_add_service_varibles.php similarity index 96% rename from database/migrations/2016_01_23_202731_add_service_varibles.php rename to database/migrations/old/2016_01_23_202731_add_service_varibles.php index bb96d83b6..967b4d5e1 100644 --- a/database/migrations/2016_01_23_202731_add_service_varibles.php +++ b/database/migrations/old/2016_01_23_202731_add_service_varibles.php @@ -1,8 +1,10 @@ increments('id'); $table->mediumInteger('option_id')->unsigned(); $table->string('name'); diff --git a/database/migrations/2016_01_23_202943_add_services.php b/database/migrations/old/2016_01_23_202943_add_services.php similarity index 87% rename from database/migrations/2016_01_23_202943_add_services.php rename to database/migrations/old/2016_01_23_202943_add_services.php index caddd964b..71d79c328 100644 --- a/database/migrations/2016_01_23_202943_add_services.php +++ b/database/migrations/old/2016_01_23_202943_add_services.php @@ -1,8 +1,10 @@ increments('id'); $table->string('name'); $table->text('description'); diff --git a/database/migrations/2016_01_23_203119_create_settings_table.php b/database/migrations/old/2016_01_23_203119_create_settings_table.php similarity index 83% rename from database/migrations/2016_01_23_203119_create_settings_table.php rename to database/migrations/old/2016_01_23_203119_create_settings_table.php index 40dec55c6..2b1d85d4c 100644 --- a/database/migrations/2016_01_23_203119_create_settings_table.php +++ b/database/migrations/old/2016_01_23_203119_create_settings_table.php @@ -1,8 +1,10 @@ string('key')->unique(); $table->text('value'); }); diff --git a/database/migrations/2016_01_23_203150_add_subusers.php b/database/migrations/old/2016_01_23_203150_add_subusers.php similarity index 87% rename from database/migrations/2016_01_23_203150_add_subusers.php rename to database/migrations/old/2016_01_23_203150_add_subusers.php index e7561c0fd..95ba138f1 100644 --- a/database/migrations/2016_01_23_203150_add_subusers.php +++ b/database/migrations/old/2016_01_23_203150_add_subusers.php @@ -1,8 +1,10 @@ increments('id'); $table->integer('user_id')->unsigned(); $table->integer('server_id')->unsigned(); diff --git a/database/migrations/2016_01_23_203159_add_users.php b/database/migrations/old/2016_01_23_203159_add_users.php similarity index 90% rename from database/migrations/2016_01_23_203159_add_users.php rename to database/migrations/old/2016_01_23_203159_add_users.php index 1b6f9b5bb..d0c685e63 100644 --- a/database/migrations/2016_01_23_203159_add_users.php +++ b/database/migrations/old/2016_01_23_203159_add_users.php @@ -1,8 +1,10 @@ increments('id'); $table->char('uuid', 36)->unique(); $table->string('email')->unique(); diff --git a/database/migrations/2016_01_23_203947_create_sessions_table.php b/database/migrations/old/2016_01_23_203947_create_sessions_table.php similarity index 87% rename from database/migrations/2016_01_23_203947_create_sessions_table.php rename to database/migrations/old/2016_01_23_203947_create_sessions_table.php index 7f708195e..5234592a2 100644 --- a/database/migrations/2016_01_23_203947_create_sessions_table.php +++ b/database/migrations/old/2016_01_23_203947_create_sessions_table.php @@ -1,8 +1,10 @@ string('id')->unique(); $table->integer('user_id')->nullable(); $table->string('ip_address', 45)->nullable(); diff --git a/database/migrations/2016_01_25_234418_rename_permissions_column.php b/database/migrations/old/2016_01_25_234418_rename_permissions_column.php similarity index 92% rename from database/migrations/2016_01_25_234418_rename_permissions_column.php rename to database/migrations/old/2016_01_25_234418_rename_permissions_column.php index 6b75986f9..72009e2ab 100644 --- a/database/migrations/2016_01_25_234418_rename_permissions_column.php +++ b/database/migrations/old/2016_01_25_234418_rename_permissions_column.php @@ -1,8 +1,10 @@ renameColumn('permissions', 'permission'); }); } @@ -21,7 +23,6 @@ class RenamePermissionsColumn extends Migration */ public function down(): void { - Schema::table('permissions', function (Blueprint $table) { - }); + Schema::table('permissions', function (Blueprint $table): void {}); } } diff --git a/database/migrations/2016_02_07_172148_add_databases_tables.php b/database/migrations/old/2016_02_07_172148_add_databases_tables.php similarity index 88% rename from database/migrations/2016_02_07_172148_add_databases_tables.php rename to database/migrations/old/2016_02_07_172148_add_databases_tables.php index 26fdbf389..b0513efbf 100644 --- a/database/migrations/2016_02_07_172148_add_databases_tables.php +++ b/database/migrations/old/2016_02_07_172148_add_databases_tables.php @@ -1,8 +1,10 @@ increments('id'); $table->integer('server')->unsigned(); $table->integer('db_server')->unsigned(); diff --git a/database/migrations/2016_02_07_181319_add_database_servers_table.php b/database/migrations/old/2016_02_07_181319_add_database_servers_table.php similarity index 95% rename from database/migrations/2016_02_07_181319_add_database_servers_table.php rename to database/migrations/old/2016_02_07_181319_add_database_servers_table.php index 16d2d3cf5..e6f52c1f4 100644 --- a/database/migrations/2016_02_07_181319_add_database_servers_table.php +++ b/database/migrations/old/2016_02_07_181319_add_database_servers_table.php @@ -1,8 +1,10 @@ increments('id'); $table->string('name'); $table->string('host'); diff --git a/database/migrations/2016_02_13_154306_add_service_option_default_startup.php b/database/migrations/old/2016_02_13_154306_add_service_option_default_startup.php similarity index 93% rename from database/migrations/2016_02_13_154306_add_service_option_default_startup.php rename to database/migrations/old/2016_02_13_154306_add_service_option_default_startup.php index a5d14b6d5..3f8c548c5 100644 --- a/database/migrations/2016_02_13_154306_add_service_option_default_startup.php +++ b/database/migrations/old/2016_02_13_154306_add_service_option_default_startup.php @@ -1,8 +1,10 @@ text('executable')->after('docker_image')->nullable()->default(null); $table->text('startup')->after('executable')->nullable()->default(null); }); @@ -22,7 +24,7 @@ class AddServiceOptionDefaultStartup extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropColumn('executable'); $table->dropColumn('startup'); }); diff --git a/database/migrations/2016_02_20_155318_add_unique_service_field.php b/database/migrations/old/2016_02_20_155318_add_unique_service_field.php similarity index 74% rename from database/migrations/2016_02_20_155318_add_unique_service_field.php rename to database/migrations/old/2016_02_20_155318_add_unique_service_field.php index 241e278ff..6452ce7c4 100644 --- a/database/migrations/2016_02_20_155318_add_unique_service_field.php +++ b/database/migrations/old/2016_02_20_155318_add_unique_service_field.php @@ -1,8 +1,10 @@ string('file')->unique()->change(); }); } @@ -21,7 +23,7 @@ class AddUniqueServiceField extends Migration */ public function down(): void { - Schema::table('services', function (Blueprint $table) { + Schema::table('services', function (Blueprint $table): void { $table->dropUnique(['file']); }); } diff --git a/database/migrations/2016_02_27_163411_add_tasks_table.php b/database/migrations/old/2016_02_27_163411_add_tasks_table.php similarity index 92% rename from database/migrations/2016_02_27_163411_add_tasks_table.php rename to database/migrations/old/2016_02_27_163411_add_tasks_table.php index 8fb1efb4a..12185a264 100644 --- a/database/migrations/2016_02_27_163411_add_tasks_table.php +++ b/database/migrations/old/2016_02_27_163411_add_tasks_table.php @@ -1,8 +1,10 @@ increments('id'); $table->integer('server')->unsigned(); $table->tinyInteger('active')->default(1); diff --git a/database/migrations/2016_02_27_163447_add_tasks_log_table.php b/database/migrations/old/2016_02_27_163447_add_tasks_log_table.php similarity index 87% rename from database/migrations/2016_02_27_163447_add_tasks_log_table.php rename to database/migrations/old/2016_02_27_163447_add_tasks_log_table.php index 6014a69b8..34dffc288 100644 --- a/database/migrations/2016_02_27_163447_add_tasks_log_table.php +++ b/database/migrations/old/2016_02_27_163447_add_tasks_log_table.php @@ -1,8 +1,10 @@ increments('id'); $table->integer('task_id')->unsigned(); $table->timestamp('run_time'); diff --git a/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php b/database/migrations/old/2016_03_18_155649_add_nullable_field_lastrun.php similarity index 55% rename from database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php rename to database/migrations/old/2016_03_18_155649_add_nullable_field_lastrun.php index 9d4752eb6..3ee6ebcb2 100644 --- a/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php +++ b/database/migrations/old/2016_03_18_155649_add_nullable_field_lastrun.php @@ -1,5 +1,7 @@ wrapTable('tasks'); - DB::statement('ALTER TABLE ' . $table . ' CHANGE `last_run` `last_run` TIMESTAMP NULL;'); + DB::statement('ALTER TABLE '.$table.' CHANGE `last_run` `last_run` TIMESTAMP NULL;'); } /** * Reverse the migrations. */ - public function down() + public function down(): void { $table = DB::getQueryGrammar()->wrapTable('tasks'); - DB::statement('ALTER TABLE ' . $table . ' CHANGE `last_run` `last_run` TIMESTAMP;'); + DB::statement('ALTER TABLE '.$table.' CHANGE `last_run` `last_run` TIMESTAMP;'); } } diff --git a/database/migrations/2016_08_30_212718_add_ip_alias.php b/database/migrations/old/2016_08_30_212718_add_ip_alias.php similarity index 95% rename from database/migrations/2016_08_30_212718_add_ip_alias.php rename to database/migrations/old/2016_08_30_212718_add_ip_alias.php index 17272a2cc..4a5f47654 100644 --- a/database/migrations/2016_08_30_212718_add_ip_alias.php +++ b/database/migrations/old/2016_08_30_212718_add_ip_alias.php @@ -1,8 +1,10 @@ text('ip_alias')->nullable()->after('ip'); }); @@ -32,7 +34,7 @@ class AddIpAlias extends Migration */ public function down(): void { - Schema::table('allocations', function (Blueprint $table) { + Schema::table('allocations', function (Blueprint $table): void { $table->dropColumn('ip_alias'); }); } diff --git a/database/migrations/2016_08_30_213301_modify_ip_storage_method.php b/database/migrations/old/2016_08_30_213301_modify_ip_storage_method.php similarity index 88% rename from database/migrations/2016_08_30_213301_modify_ip_storage_method.php rename to database/migrations/old/2016_08_30_213301_modify_ip_storage_method.php index 7c8b1d46b..3ef80a088 100644 --- a/database/migrations/2016_08_30_213301_modify_ip_storage_method.php +++ b/database/migrations/old/2016_08_30_213301_modify_ip_storage_method.php @@ -1,8 +1,10 @@ mediumInteger('allocation')->unsigned()->after('oom_disabled'); }); @@ -39,7 +41,7 @@ class ModifyIpStorageMethod extends Migration } // Updated the server allocations, remove old fields - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('ip'); $table->dropColumn('port'); }); @@ -50,7 +52,7 @@ class ModifyIpStorageMethod extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->text('ip')->after('allocation'); $table->integer('port')->unsigned()->after('ip'); }); @@ -72,7 +74,7 @@ class ModifyIpStorageMethod extends Migration } } - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('allocation'); }); } diff --git a/database/migrations/2016_09_01_193520_add_suspension_for_servers.php b/database/migrations/old/2016_09_01_193520_add_suspension_for_servers.php similarity index 76% rename from database/migrations/2016_09_01_193520_add_suspension_for_servers.php rename to database/migrations/old/2016_09_01_193520_add_suspension_for_servers.php index 19cd96522..f9a141e13 100644 --- a/database/migrations/2016_09_01_193520_add_suspension_for_servers.php +++ b/database/migrations/old/2016_09_01_193520_add_suspension_for_servers.php @@ -1,8 +1,10 @@ tinyInteger('suspended')->unsigned()->default(0)->after('active'); }); } @@ -21,7 +23,7 @@ class AddSuspensionForServers extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('suspended'); }); } diff --git a/database/migrations/2016_09_01_211924_remove_active_column.php b/database/migrations/old/2016_09_01_211924_remove_active_column.php similarity index 75% rename from database/migrations/2016_09_01_211924_remove_active_column.php rename to database/migrations/old/2016_09_01_211924_remove_active_column.php index 7450c932d..5aecec66b 100644 --- a/database/migrations/2016_09_01_211924_remove_active_column.php +++ b/database/migrations/old/2016_09_01_211924_remove_active_column.php @@ -1,8 +1,10 @@ dropColumn('active'); }); } @@ -21,7 +23,7 @@ class RemoveActiveColumn extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->tinyInteger('active')->after('name')->unsigned()->default(0); }); } diff --git a/database/migrations/2016_09_02_190647_add_sftp_password_storage.php b/database/migrations/old/2016_09_02_190647_add_sftp_password_storage.php similarity index 75% rename from database/migrations/2016_09_02_190647_add_sftp_password_storage.php rename to database/migrations/old/2016_09_02_190647_add_sftp_password_storage.php index 57ce1f3b5..afbfce874 100644 --- a/database/migrations/2016_09_02_190647_add_sftp_password_storage.php +++ b/database/migrations/old/2016_09_02_190647_add_sftp_password_storage.php @@ -1,8 +1,10 @@ text('sftp_password')->after('username')->nullable(); }); } @@ -21,7 +23,7 @@ class AddSftpPasswordStorage extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('sftp_password'); }); } diff --git a/database/migrations/2016_09_04_171338_update_jobs_tables.php b/database/migrations/old/2016_09_04_171338_update_jobs_tables.php similarity index 82% rename from database/migrations/2016_09_04_171338_update_jobs_tables.php rename to database/migrations/old/2016_09_04_171338_update_jobs_tables.php index 4c5bff23f..53bc3c5c1 100644 --- a/database/migrations/2016_09_04_171338_update_jobs_tables.php +++ b/database/migrations/old/2016_09_04_171338_update_jobs_tables.php @@ -1,8 +1,10 @@ dropIndex(['queue', 'reserved', 'reserved_at']); $table->dropColumn('reserved'); @@ -24,7 +26,7 @@ class UpdateJobsTables extends Migration */ public function down(): void { - Schema::table('jobs', function (Blueprint $table) { + Schema::table('jobs', function (Blueprint $table): void { $table->dropIndex(['queue', 'reserved_at']); $table->tinyInteger('reserved')->unsigned(); diff --git a/database/migrations/2016_09_04_172028_update_failed_jobs_table.php b/database/migrations/old/2016_09_04_172028_update_failed_jobs_table.php similarity index 93% rename from database/migrations/2016_09_04_172028_update_failed_jobs_table.php rename to database/migrations/old/2016_09_04_172028_update_failed_jobs_table.php index b5157a1ef..cdfb99fde 100644 --- a/database/migrations/2016_09_04_172028_update_failed_jobs_table.php +++ b/database/migrations/old/2016_09_04_172028_update_failed_jobs_table.php @@ -1,8 +1,10 @@ text('exception'); }); } @@ -21,7 +23,7 @@ class UpdateFailedJobsTable extends Migration */ public function down(): void { - Schema::table('failed_jobs', function (Blueprint $table) { + Schema::table('failed_jobs', function (Blueprint $table): void { $table->dropColumn('exception'); }); } diff --git a/database/migrations/2016_09_04_182835_create_notifications_table.php b/database/migrations/old/2016_09_04_182835_create_notifications_table.php similarity index 95% rename from database/migrations/2016_09_04_182835_create_notifications_table.php rename to database/migrations/old/2016_09_04_182835_create_notifications_table.php index 8918f3009..014fcfc89 100644 --- a/database/migrations/2016_09_04_182835_create_notifications_table.php +++ b/database/migrations/old/2016_09_04_182835_create_notifications_table.php @@ -1,8 +1,10 @@ string('id')->primary(); $table->string('type'); $table->morphs('notifiable'); diff --git a/database/migrations/2016_09_07_163017_add_unique_identifier.php b/database/migrations/old/2016_09_07_163017_add_unique_identifier.php similarity index 74% rename from database/migrations/2016_09_07_163017_add_unique_identifier.php rename to database/migrations/old/2016_09_07_163017_add_unique_identifier.php index 685a718a4..ef7df2f0b 100644 --- a/database/migrations/2016_09_07_163017_add_unique_identifier.php +++ b/database/migrations/old/2016_09_07_163017_add_unique_identifier.php @@ -1,8 +1,10 @@ char('author', 36)->after('id'); }); } @@ -21,7 +23,7 @@ class AddUniqueIdentifier extends Migration */ public function down(): void { - Schema::table('services', function (Blueprint $table) { + Schema::table('services', function (Blueprint $table): void { $table->dropColumn('author'); }); } diff --git a/database/migrations/2016_09_14_145945_allow_longer_regex_field.php b/database/migrations/old/2016_09_14_145945_allow_longer_regex_field.php similarity index 91% rename from database/migrations/2016_09_14_145945_allow_longer_regex_field.php rename to database/migrations/old/2016_09_14_145945_allow_longer_regex_field.php index 8d0ab04ac..084e328c6 100644 --- a/database/migrations/2016_09_14_145945_allow_longer_regex_field.php +++ b/database/migrations/old/2016_09_14_145945_allow_longer_regex_field.php @@ -1,8 +1,10 @@ text('regex')->change(); }); } @@ -21,7 +23,7 @@ class AllowLongerRegexField extends Migration */ public function down(): void { - Schema::table('service_variables', function (Blueprint $table) { + Schema::table('service_variables', function (Blueprint $table): void { $table->string('regex')->change(); }); } diff --git a/database/migrations/2016_09_17_194246_add_docker_image_column.php b/database/migrations/old/2016_09_17_194246_add_docker_image_column.php similarity index 82% rename from database/migrations/2016_09_17_194246_add_docker_image_column.php rename to database/migrations/old/2016_09_17_194246_add_docker_image_column.php index 0e66f649e..eecfe8d90 100644 --- a/database/migrations/2016_09_17_194246_add_docker_image_column.php +++ b/database/migrations/old/2016_09_17_194246_add_docker_image_column.php @@ -1,9 +1,11 @@ string('image')->after('daemonSecret'); }); // Populate the column - DB::transaction(function () { + DB::transaction(function (): void { $servers = DB::table('servers')->select( 'servers.id', 'service_options.docker_image as s_optionImage' @@ -35,7 +37,7 @@ class AddDockerImageColumn extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('image'); }); } diff --git a/database/migrations/2016_09_21_165554_update_servers_column_name.php b/database/migrations/old/2016_09_21_165554_update_servers_column_name.php similarity index 75% rename from database/migrations/2016_09_21_165554_update_servers_column_name.php rename to database/migrations/old/2016_09_21_165554_update_servers_column_name.php index 919cdcaab..6ea84aba6 100644 --- a/database/migrations/2016_09_21_165554_update_servers_column_name.php +++ b/database/migrations/old/2016_09_21_165554_update_servers_column_name.php @@ -1,8 +1,10 @@ renameColumn('server', 'server_id'); }); } @@ -21,7 +23,7 @@ class UpdateServersColumnName extends Migration */ public function down(): void { - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->renameColumn('server_id', 'server'); }); } diff --git a/database/migrations/2016_09_29_213518_rename_double_insurgency.php b/database/migrations/old/2016_09_29_213518_rename_double_insurgency.php similarity index 82% rename from database/migrations/2016_09_29_213518_rename_double_insurgency.php rename to database/migrations/old/2016_09_29_213518_rename_double_insurgency.php index 5f21c7036..04faff9f9 100644 --- a/database/migrations/2016_09_29_213518_rename_double_insurgency.php +++ b/database/migrations/old/2016_09_29_213518_rename_double_insurgency.php @@ -1,5 +1,7 @@ where('parent_service', 2)->where('id', 3)->where('name', 'Insurgency')->first(); if ($model) { $model->name = 'Team Fortress 2'; @@ -21,7 +23,5 @@ class RenameDoubleInsurgency extends Migration /** * Reverse the migrations. */ - public function down(): void - { - } + public function down(): void {} } diff --git a/database/migrations/2016_10_07_152117_build_api_log_table.php b/database/migrations/old/2016_10_07_152117_build_api_log_table.php similarity index 89% rename from database/migrations/2016_10_07_152117_build_api_log_table.php rename to database/migrations/old/2016_10_07_152117_build_api_log_table.php index 39356c5ba..c4b28c4fc 100644 --- a/database/migrations/2016_10_07_152117_build_api_log_table.php +++ b/database/migrations/old/2016_10_07_152117_build_api_log_table.php @@ -1,8 +1,10 @@ increments('id'); $table->boolean('authorized'); $table->text('error')->nullable(); diff --git a/database/migrations/2016_10_14_164802_update_api_keys.php b/database/migrations/old/2016_10_14_164802_update_api_keys.php similarity index 80% rename from database/migrations/2016_10_14_164802_update_api_keys.php rename to database/migrations/old/2016_10_14_164802_update_api_keys.php index b43eef1b1..39a4c705d 100644 --- a/database/migrations/2016_10_14_164802_update_api_keys.php +++ b/database/migrations/old/2016_10_14_164802_update_api_keys.php @@ -1,8 +1,10 @@ unsignedInteger('user')->after('id'); $table->text('memo')->after('allowed_ips')->nullable(); $table->timestamp('expires_at')->after('memo')->nullable(); @@ -23,7 +25,7 @@ class UpdateApiKeys extends Migration */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropColumn('user'); $table->dropColumn('memo'); $table->dropColumn('expires_at'); diff --git a/database/migrations/2016_10_23_181719_update_misnamed_bungee.php b/database/migrations/old/2016_10_23_181719_update_misnamed_bungee.php similarity index 86% rename from database/migrations/2016_10_23_181719_update_misnamed_bungee.php rename to database/migrations/old/2016_10_23_181719_update_misnamed_bungee.php index a9cf3a35c..e73024989 100644 --- a/database/migrations/2016_10_23_181719_update_misnamed_bungee.php +++ b/database/migrations/old/2016_10_23_181719_update_misnamed_bungee.php @@ -1,5 +1,7 @@ integer('node', false, true)->change(); $table->integer('owner', false, true)->change(); $table->integer('allocation', false, true)->change(); @@ -33,7 +35,7 @@ class AddForeignKeysServers extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['node']); $table->dropIndex(['node']); diff --git a/database/migrations/2016_10_23_201624_add_foreign_allocations.php b/database/migrations/old/2016_10_23_201624_add_foreign_allocations.php similarity index 96% rename from database/migrations/2016_10_23_201624_add_foreign_allocations.php rename to database/migrations/old/2016_10_23_201624_add_foreign_allocations.php index 7ae4b040d..745a0b052 100644 --- a/database/migrations/2016_10_23_201624_add_foreign_allocations.php +++ b/database/migrations/old/2016_10_23_201624_add_foreign_allocations.php @@ -1,9 +1,11 @@ integer('assigned_to', false, true)->nullable()->change(); $table->integer('node', false, true)->nullable(false)->change(); $table->foreign('assigned_to')->references('id')->on('servers'); @@ -25,7 +27,7 @@ class AddForeignAllocations extends Migration */ public function down(): void { - Schema::table('allocations', function (Blueprint $table) { + Schema::table('allocations', function (Blueprint $table): void { $table->dropForeign(['assigned_to']); $table->dropIndex(['assigned_to']); diff --git a/database/migrations/2016_10_23_202222_add_foreign_api_keys.php b/database/migrations/old/2016_10_23_202222_add_foreign_api_keys.php similarity index 76% rename from database/migrations/2016_10_23_202222_add_foreign_api_keys.php rename to database/migrations/old/2016_10_23_202222_add_foreign_api_keys.php index 44b11d0e5..63ee6e3f8 100644 --- a/database/migrations/2016_10_23_202222_add_foreign_api_keys.php +++ b/database/migrations/old/2016_10_23_202222_add_foreign_api_keys.php @@ -1,8 +1,10 @@ foreign('user')->references('id')->on('users'); }); } @@ -21,7 +23,7 @@ class AddForeignApiKeys extends Migration */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropForeign(['user']); $table->dropIndex(['user']); }); diff --git a/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php b/database/migrations/old/2016_10_23_202703_add_foreign_api_permissions.php similarity index 94% rename from database/migrations/2016_10_23_202703_add_foreign_api_permissions.php rename to database/migrations/old/2016_10_23_202703_add_foreign_api_permissions.php index 2494eaba7..6622af3c1 100644 --- a/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php +++ b/database/migrations/old/2016_10_23_202703_add_foreign_api_permissions.php @@ -1,8 +1,10 @@ integer('key_id', false, true)->nullable(false)->change(); $table->foreign('key_id')->references('id')->on('api_keys'); }); @@ -22,7 +24,7 @@ class AddForeignApiPermissions extends Migration */ public function down(): void { - Schema::table('api_permissions', function (Blueprint $table) { + Schema::table('api_permissions', function (Blueprint $table): void { $table->dropForeign(['key_id']); $table->dropIndex(['key_id']); diff --git a/database/migrations/2016_10_23_202953_add_foreign_database_servers.php b/database/migrations/old/2016_10_23_202953_add_foreign_database_servers.php similarity index 92% rename from database/migrations/2016_10_23_202953_add_foreign_database_servers.php rename to database/migrations/old/2016_10_23_202953_add_foreign_database_servers.php index 78ee8264d..b2f122d56 100644 --- a/database/migrations/2016_10_23_202953_add_foreign_database_servers.php +++ b/database/migrations/old/2016_10_23_202953_add_foreign_database_servers.php @@ -1,8 +1,10 @@ foreign('linked_node')->references('id')->on('nodes'); }); } @@ -21,7 +23,7 @@ class AddForeignDatabaseServers extends Migration */ public function down(): void { - Schema::table('database_servers', function (Blueprint $table) { + Schema::table('database_servers', function (Blueprint $table): void { $table->dropForeign(['linked_node']); $table->dropIndex(['linked_node']); }); diff --git a/database/migrations/2016_10_23_203105_add_foreign_databases.php b/database/migrations/old/2016_10_23_203105_add_foreign_databases.php similarity index 81% rename from database/migrations/2016_10_23_203105_add_foreign_databases.php rename to database/migrations/old/2016_10_23_203105_add_foreign_databases.php index bea43049b..ba1719ebf 100644 --- a/database/migrations/2016_10_23_203105_add_foreign_databases.php +++ b/database/migrations/old/2016_10_23_203105_add_foreign_databases.php @@ -1,8 +1,10 @@ foreign('server_id')->references('id')->on('servers'); $table->foreign('db_server')->references('id')->on('database_servers'); }); @@ -22,7 +24,7 @@ class AddForeignDatabases extends Migration */ public function down(): void { - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->dropForeign(['server_id']); $table->dropIndex(['server_id']); diff --git a/database/migrations/2016_10_23_203335_add_foreign_nodes.php b/database/migrations/old/2016_10_23_203335_add_foreign_nodes.php similarity index 81% rename from database/migrations/2016_10_23_203335_add_foreign_nodes.php rename to database/migrations/old/2016_10_23_203335_add_foreign_nodes.php index 375189a7f..77967db33 100644 --- a/database/migrations/2016_10_23_203335_add_foreign_nodes.php +++ b/database/migrations/old/2016_10_23_203335_add_foreign_nodes.php @@ -1,8 +1,10 @@ integer('location', false, true)->nullable(false)->change(); $table->foreign('location')->references('id')->on('locations'); }); @@ -22,7 +24,7 @@ class AddForeignNodes extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropForeign(['location']); $table->dropIndex(['location']); diff --git a/database/migrations/2016_10_23_203522_add_foreign_permissions.php b/database/migrations/old/2016_10_23_203522_add_foreign_permissions.php similarity index 95% rename from database/migrations/2016_10_23_203522_add_foreign_permissions.php rename to database/migrations/old/2016_10_23_203522_add_foreign_permissions.php index 78bbf32a5..baba744d8 100644 --- a/database/migrations/2016_10_23_203522_add_foreign_permissions.php +++ b/database/migrations/old/2016_10_23_203522_add_foreign_permissions.php @@ -1,8 +1,10 @@ foreign('user_id')->references('id')->on('users'); $table->foreign('server_id')->references('id')->on('servers'); }); @@ -22,7 +24,7 @@ class AddForeignPermissions extends Migration */ public function down(): void { - Schema::table('permissions', function (Blueprint $table) { + Schema::table('permissions', function (Blueprint $table): void { $table->dropForeign(['user_id']); $table->dropIndex(['user_id']); diff --git a/database/migrations/2016_10_23_203857_add_foreign_server_variables.php b/database/migrations/old/2016_10_23_203857_add_foreign_server_variables.php similarity index 95% rename from database/migrations/2016_10_23_203857_add_foreign_server_variables.php rename to database/migrations/old/2016_10_23_203857_add_foreign_server_variables.php index 3ccc3d183..957caf8ac 100644 --- a/database/migrations/2016_10_23_203857_add_foreign_server_variables.php +++ b/database/migrations/old/2016_10_23_203857_add_foreign_server_variables.php @@ -1,8 +1,10 @@ integer('server_id', false, true)->nullable()->change(); $table->integer('variable_id', false, true)->nullable(false)->change(); $table->foreign('server_id')->references('id')->on('servers'); @@ -24,7 +26,7 @@ class AddForeignServerVariables extends Migration */ public function down(): void { - Schema::table('server_variables', function (Blueprint $table) { + Schema::table('server_variables', function (Blueprint $table): void { $table->dropForeign(['server_id']); $table->dropForeign(['variable_id']); $table->mediumInteger('server_id', false, true)->nullable()->change(); diff --git a/database/migrations/2016_10_23_204157_add_foreign_service_options.php b/database/migrations/old/2016_10_23_204157_add_foreign_service_options.php similarity index 94% rename from database/migrations/2016_10_23_204157_add_foreign_service_options.php rename to database/migrations/old/2016_10_23_204157_add_foreign_service_options.php index 9f01905b7..c13b34a6c 100644 --- a/database/migrations/2016_10_23_204157_add_foreign_service_options.php +++ b/database/migrations/old/2016_10_23_204157_add_foreign_service_options.php @@ -1,8 +1,10 @@ integer('parent_service', false, true)->change(); $table->foreign('parent_service')->references('id')->on('services'); }); @@ -22,7 +24,7 @@ class AddForeignServiceOptions extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropForeign(['parent_service']); $table->dropIndex(['parent_service']); diff --git a/database/migrations/2016_10_23_204321_add_foreign_service_variables.php b/database/migrations/old/2016_10_23_204321_add_foreign_service_variables.php similarity index 93% rename from database/migrations/2016_10_23_204321_add_foreign_service_variables.php rename to database/migrations/old/2016_10_23_204321_add_foreign_service_variables.php index df998efaf..682c35ce2 100644 --- a/database/migrations/2016_10_23_204321_add_foreign_service_variables.php +++ b/database/migrations/old/2016_10_23_204321_add_foreign_service_variables.php @@ -1,8 +1,10 @@ integer('option_id', false, true)->change(); $table->foreign('option_id')->references('id')->on('service_options'); }); @@ -22,7 +24,7 @@ class AddForeignServiceVariables extends Migration */ public function down(): void { - Schema::table('service_variables', function (Blueprint $table) { + Schema::table('service_variables', function (Blueprint $table): void { $table->dropForeign(['option_id']); $table->dropIndex(['option_id']); diff --git a/database/migrations/2016_10_23_204454_add_foreign_subusers.php b/database/migrations/old/2016_10_23_204454_add_foreign_subusers.php similarity index 81% rename from database/migrations/2016_10_23_204454_add_foreign_subusers.php rename to database/migrations/old/2016_10_23_204454_add_foreign_subusers.php index ff4bb95a3..5260d352f 100644 --- a/database/migrations/2016_10_23_204454_add_foreign_subusers.php +++ b/database/migrations/old/2016_10_23_204454_add_foreign_subusers.php @@ -1,8 +1,10 @@ foreign('user_id')->references('id')->on('users'); $table->foreign('server_id')->references('id')->on('servers'); }); @@ -22,7 +24,7 @@ class AddForeignSubusers extends Migration */ public function down(): void { - Schema::table('subusers', function (Blueprint $table) { + Schema::table('subusers', function (Blueprint $table): void { $table->dropForeign(['user_id']); $table->dropIndex(['user_id']); diff --git a/database/migrations/2016_10_23_204610_add_foreign_tasks.php b/database/migrations/old/2016_10_23_204610_add_foreign_tasks.php similarity index 75% rename from database/migrations/2016_10_23_204610_add_foreign_tasks.php rename to database/migrations/old/2016_10_23_204610_add_foreign_tasks.php index f32d89230..8165e9050 100644 --- a/database/migrations/2016_10_23_204610_add_foreign_tasks.php +++ b/database/migrations/old/2016_10_23_204610_add_foreign_tasks.php @@ -1,8 +1,10 @@ foreign('server')->references('id')->on('servers'); }); } @@ -21,7 +23,7 @@ class AddForeignTasks extends Migration */ public function down(): void { - Schema::table('tasks', function (Blueprint $table) { + Schema::table('tasks', function (Blueprint $table): void { $table->dropForeign(['server']); }); } diff --git a/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php b/database/migrations/old/2016_11_04_000949_add_ark_service_option_fixed.php similarity index 96% rename from database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php rename to database/migrations/old/2016_11_04_000949_add_ark_service_option_fixed.php index c5fff5523..eb2cd0842 100644 --- a/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php +++ b/database/migrations/old/2016_11_04_000949_add_ark_service_option_fixed.php @@ -1,5 +1,7 @@ select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); // No SRCDS Service, Skipping - if (!$service) { + if (! $service) { return; } @@ -75,7 +77,7 @@ class AddArkServiceOptionFixed extends Migration */ public function down(): void { - DB::transaction(function () { + DB::transaction(function (): void { $service = DB::table('services')->select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); if ($service) { diff --git a/database/migrations/2016_11_11_220649_add_pack_support.php b/database/migrations/old/2016_11_11_220649_add_pack_support.php similarity index 96% rename from database/migrations/2016_11_11_220649_add_pack_support.php rename to database/migrations/old/2016_11_11_220649_add_pack_support.php index 8fd638ae6..36da1c8e1 100644 --- a/database/migrations/2016_11_11_220649_add_pack_support.php +++ b/database/migrations/old/2016_11_11_220649_add_pack_support.php @@ -1,8 +1,10 @@ increments('id'); $table->unsignedInteger('option'); $table->char('uuid', 36)->unique(); diff --git a/database/migrations/2016_11_11_231731_set_service_name_unique.php b/database/migrations/old/2016_11_11_231731_set_service_name_unique.php similarity index 74% rename from database/migrations/2016_11_11_231731_set_service_name_unique.php rename to database/migrations/old/2016_11_11_231731_set_service_name_unique.php index 261fdb356..d4a6db4ad 100644 --- a/database/migrations/2016_11_11_231731_set_service_name_unique.php +++ b/database/migrations/old/2016_11_11_231731_set_service_name_unique.php @@ -1,8 +1,10 @@ unique('name'); }); } @@ -21,7 +23,7 @@ class SetServiceNameUnique extends Migration */ public function down(): void { - Schema::table('services', function (Blueprint $table) { + Schema::table('services', function (Blueprint $table): void { $table->dropUnique('services_name_unique'); }); } diff --git a/database/migrations/2016_11_27_142519_add_pack_column.php b/database/migrations/old/2016_11_27_142519_add_pack_column.php similarity index 78% rename from database/migrations/2016_11_27_142519_add_pack_column.php rename to database/migrations/old/2016_11_27_142519_add_pack_column.php index 3911ecb41..8a487df33 100644 --- a/database/migrations/2016_11_27_142519_add_pack_column.php +++ b/database/migrations/old/2016_11_27_142519_add_pack_column.php @@ -1,8 +1,10 @@ unsignedInteger('pack')->nullable()->after('option'); $table->foreign('pack')->references('id')->on('service_packs'); @@ -23,7 +25,7 @@ class AddPackColumn extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['pack']); $table->dropColumn('pack'); }); diff --git a/database/migrations/2016_12_01_173018_add_configurable_upload_limit.php b/database/migrations/old/2016_12_01_173018_add_configurable_upload_limit.php similarity index 76% rename from database/migrations/2016_12_01_173018_add_configurable_upload_limit.php rename to database/migrations/old/2016_12_01_173018_add_configurable_upload_limit.php index c5136fe9e..9006dc6f1 100644 --- a/database/migrations/2016_12_01_173018_add_configurable_upload_limit.php +++ b/database/migrations/old/2016_12_01_173018_add_configurable_upload_limit.php @@ -1,8 +1,10 @@ unsignedInteger('upload_size')->after('disk_overallocate')->default(100); }); } @@ -21,7 +23,7 @@ class AddConfigurableUploadLimit extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropColumn('upload_size'); }); } diff --git a/database/migrations/2016_12_02_185206_correct_service_variables.php b/database/migrations/old/2016_12_02_185206_correct_service_variables.php similarity index 97% rename from database/migrations/2016_12_02_185206_correct_service_variables.php rename to database/migrations/old/2016_12_02_185206_correct_service_variables.php index d94b3b78b..183f1c4f0 100644 --- a/database/migrations/2016_12_02_185206_correct_service_variables.php +++ b/database/migrations/old/2016_12_02_185206_correct_service_variables.php @@ -1,5 +1,7 @@ where([ ['name', 'Spigot'], diff --git a/database/migrations/2017_01_03_150436_fix_misnamed_option_tag.php b/database/migrations/old/2017_01_03_150436_fix_misnamed_option_tag.php similarity index 92% rename from database/migrations/2017_01_03_150436_fix_misnamed_option_tag.php rename to database/migrations/old/2017_01_03_150436_fix_misnamed_option_tag.php index 35248d6bb..407893a6b 100644 --- a/database/migrations/2017_01_03_150436_fix_misnamed_option_tag.php +++ b/database/migrations/old/2017_01_03_150436_fix_misnamed_option_tag.php @@ -1,5 +1,7 @@ where([ ['name', 'Sponge (SpongeVanilla)'], ['tag', 'spigot'], diff --git a/database/migrations/2017_01_07_154228_create_node_configuration_tokens_table.php b/database/migrations/old/2017_01_07_154228_create_node_configuration_tokens_table.php similarity index 94% rename from database/migrations/2017_01_07_154228_create_node_configuration_tokens_table.php rename to database/migrations/old/2017_01_07_154228_create_node_configuration_tokens_table.php index c4369f975..747207f84 100644 --- a/database/migrations/2017_01_07_154228_create_node_configuration_tokens_table.php +++ b/database/migrations/old/2017_01_07_154228_create_node_configuration_tokens_table.php @@ -1,8 +1,10 @@ increments('id'); $table->char('token', 32); $table->timestamp('expires_at'); diff --git a/database/migrations/2017_01_12_135449_add_more_user_data.php b/database/migrations/old/2017_01_12_135449_add_more_user_data.php similarity index 80% rename from database/migrations/2017_01_12_135449_add_more_user_data.php rename to database/migrations/old/2017_01_12_135449_add_more_user_data.php index 82ae8c9e9..344bcb6e3 100644 --- a/database/migrations/2017_01_12_135449_add_more_user_data.php +++ b/database/migrations/old/2017_01_12_135449_add_more_user_data.php @@ -1,9 +1,11 @@ string('name_first')->after('email')->nullable(); $table->string('name_last')->after('name_first')->nullable(); $table->string('username')->after('uuid'); $table->boolean('gravatar')->after('totp_secret')->default(true); }); - DB::transaction(function () { + DB::transaction(function (): void { foreach (User::all() as &$user) { $user->username = $user->email; $user->save(); } }); - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->string('username')->unique()->change(); }); } @@ -36,7 +38,7 @@ class AddMoreUserData extends Migration */ public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->dropColumn('name_first'); $table->dropColumn('name_last'); $table->dropColumn('username'); diff --git a/database/migrations/2017_02_02_175548_UpdateColumnNames.php b/database/migrations/old/2017_02_02_175548_UpdateColumnNames.php similarity index 93% rename from database/migrations/2017_02_02_175548_UpdateColumnNames.php rename to database/migrations/old/2017_02_02_175548_UpdateColumnNames.php index 719513313..a5550ce78 100644 --- a/database/migrations/2017_02_02_175548_UpdateColumnNames.php +++ b/database/migrations/old/2017_02_02_175548_UpdateColumnNames.php @@ -1,8 +1,10 @@ dropForeign(['node']); $table->dropForeign(['owner']); $table->dropForeign(['allocation']); @@ -42,7 +44,7 @@ class UpdateColumnNames extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['node_id', 'owner_id', 'allocation_id', 'service_id', 'option_id']); $table->renameColumn('node_id', 'node'); diff --git a/database/migrations/2017_02_03_140948_UpdateNodesTable.php b/database/migrations/old/2017_02_03_140948_UpdateNodesTable.php similarity index 82% rename from database/migrations/2017_02_03_140948_UpdateNodesTable.php rename to database/migrations/old/2017_02_03_140948_UpdateNodesTable.php index e797cc704..e58ccf31d 100644 --- a/database/migrations/2017_02_03_140948_UpdateNodesTable.php +++ b/database/migrations/old/2017_02_03_140948_UpdateNodesTable.php @@ -1,8 +1,10 @@ dropForeign(['location']); $table->renameColumn('location', 'location_id'); @@ -24,7 +26,7 @@ class UpdateNodesTable extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropForeign(['location_id']); $table->renameColumn('location_id', 'location'); diff --git a/database/migrations/2017_02_03_155554_RenameColumns.php b/database/migrations/old/2017_02_03_155554_RenameColumns.php similarity index 96% rename from database/migrations/2017_02_03_155554_RenameColumns.php rename to database/migrations/old/2017_02_03_155554_RenameColumns.php index bd50e16be..b5551907e 100644 --- a/database/migrations/2017_02_03_155554_RenameColumns.php +++ b/database/migrations/old/2017_02_03_155554_RenameColumns.php @@ -1,8 +1,10 @@ dropForeign(['node']); $table->dropForeign(['assigned_to']); @@ -27,7 +29,7 @@ class RenameColumns extends Migration */ public function down(): void { - Schema::table('allocations', function (Blueprint $table) { + Schema::table('allocations', function (Blueprint $table): void { $table->dropForeign(['node_id']); $table->dropForeign(['server_id']); $table->dropIndex(['node_id']); diff --git a/database/migrations/2017_02_05_164123_AdjustColumnNames.php b/database/migrations/old/2017_02_05_164123_AdjustColumnNames.php similarity index 94% rename from database/migrations/2017_02_05_164123_AdjustColumnNames.php rename to database/migrations/old/2017_02_05_164123_AdjustColumnNames.php index 51c8818c7..20392bbb0 100644 --- a/database/migrations/2017_02_05_164123_AdjustColumnNames.php +++ b/database/migrations/old/2017_02_05_164123_AdjustColumnNames.php @@ -1,8 +1,10 @@ dropForeign(['parent_service']); $table->renameColumn('parent_service', 'service_id'); @@ -24,7 +26,7 @@ class AdjustColumnNames extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropForeign(['service_id']); $table->dropIndex(['service_id']); diff --git a/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php b/database/migrations/old/2017_02_05_164516_AdjustColumnNamesForServicePacks.php similarity index 95% rename from database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php rename to database/migrations/old/2017_02_05_164516_AdjustColumnNamesForServicePacks.php index 69dc33dda..221819597 100644 --- a/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php +++ b/database/migrations/old/2017_02_05_164516_AdjustColumnNamesForServicePacks.php @@ -1,8 +1,10 @@ dropForeign(['option']); $table->renameColumn('option', 'option_id'); @@ -24,7 +26,7 @@ class AdjustColumnNamesForServicePacks extends Migration */ public function down(): void { - Schema::table('service_packs', function (Blueprint $table) { + Schema::table('service_packs', function (Blueprint $table): void { $table->dropForeign(['option_id']); $table->dropIndex(['option_id']); diff --git a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php b/database/migrations/old/2017_02_09_174834_SetupPermissionsPivotTable.php similarity index 93% rename from database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php rename to database/migrations/old/2017_02_09_174834_SetupPermissionsPivotTable.php index bf6469506..dc04e63bb 100644 --- a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php +++ b/database/migrations/old/2017_02_09_174834_SetupPermissionsPivotTable.php @@ -1,10 +1,12 @@ unsignedInteger('subuser_id')->after('id'); }); - DB::transaction(function () { + DB::transaction(function (): void { foreach (Subuser::all() as &$subuser) { Permission::query()->where('user_id', $subuser->user_id)->where('server_id', $subuser->server_id)->update([ 'subuser_id' => $subuser->id, @@ -25,7 +27,7 @@ class SetupPermissionsPivotTable extends Migration } }); - Schema::table('permissions', function (Blueprint $table) { + Schema::table('permissions', function (Blueprint $table): void { $table->dropForeign(['server_id']); $table->dropForeign(['user_id']); @@ -42,13 +44,13 @@ class SetupPermissionsPivotTable extends Migration */ public function down(): void { - Schema::table('permissions', function (Blueprint $table) { + Schema::table('permissions', function (Blueprint $table): void { $table->unsignedInteger('server_id')->after('subuser_id'); $table->unsignedInteger('user_id')->after('server_id'); $table->timestamps(); }); - DB::transaction(function () { + DB::transaction(function (): void { foreach (Subuser::all() as &$subuser) { Permission::query()->where('subuser_id', $subuser->id)->update([ 'user_id' => $subuser->user_id, @@ -57,7 +59,7 @@ class SetupPermissionsPivotTable extends Migration } }); - Schema::table('permissions', function (Blueprint $table) { + Schema::table('permissions', function (Blueprint $table): void { $table->dropForeign(['subuser_id']); $table->dropIndex(['subuser_id']); $table->dropColumn('subuser_id'); diff --git a/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php b/database/migrations/old/2017_02_10_171858_UpdateAPIKeyColumnNames.php similarity index 81% rename from database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php rename to database/migrations/old/2017_02_10_171858_UpdateAPIKeyColumnNames.php index 8ae28c2c9..32a99629d 100644 --- a/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php +++ b/database/migrations/old/2017_02_10_171858_UpdateAPIKeyColumnNames.php @@ -1,8 +1,10 @@ dropForeign(['user']); $table->renameColumn('user', 'user_id'); @@ -24,7 +26,7 @@ class UpdateAPIKeyColumnNames extends Migration */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropForeign(['user_id']); $table->renameColumn('user_id', 'user'); diff --git a/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php b/database/migrations/old/2017_03_03_224254_UpdateNodeConfigTokensColumns.php similarity index 93% rename from database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php rename to database/migrations/old/2017_03_03_224254_UpdateNodeConfigTokensColumns.php index aab6c2b95..1209aa72c 100644 --- a/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php +++ b/database/migrations/old/2017_03_03_224254_UpdateNodeConfigTokensColumns.php @@ -1,8 +1,10 @@ dropForeign(['node']); $table->dropColumn('expires_at'); $table->renameColumn('node', 'node_id'); @@ -25,7 +27,7 @@ class UpdateNodeConfigTokensColumns extends Migration */ public function down(): void { - Schema::table('node_configuration_tokens', function (Blueprint $table) { + Schema::table('node_configuration_tokens', function (Blueprint $table): void { $table->dropForeign(['node_id']); $table->renameColumn('node_id', 'node'); $table->timestamp('expires_at')->after('token'); diff --git a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php b/database/migrations/old/2017_03_05_212803_DeleteServiceExecutableOption.php similarity index 83% rename from database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php rename to database/migrations/old/2017_03_05_212803_DeleteServiceExecutableOption.php index d697a3315..8007ce001 100644 --- a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php +++ b/database/migrations/old/2017_03_05_212803_DeleteServiceExecutableOption.php @@ -1,8 +1,10 @@ renameColumn('file', 'folder'); $table->dropColumn('executable'); $table->text('description')->nullable()->change(); @@ -24,7 +26,7 @@ class DeleteServiceExecutableOption extends Migration */ public function down(): void { - Schema::table('services', function (Blueprint $table) { + Schema::table('services', function (Blueprint $table): void { $table->string('executable')->after('folder'); $table->renameColumn('folder', 'file'); $table->text('description')->nullable(false)->change(); diff --git a/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php b/database/migrations/old/2017_03_10_162934_AddNewServiceOptionsColumns.php similarity index 96% rename from database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php rename to database/migrations/old/2017_03_10_162934_AddNewServiceOptionsColumns.php index 06c04694c..d16de4a86 100644 --- a/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php +++ b/database/migrations/old/2017_03_10_162934_AddNewServiceOptionsColumns.php @@ -1,8 +1,10 @@ dropColumn('executable'); $table->unsignedInteger('config_from')->nullable()->after('docker_image'); @@ -29,7 +31,7 @@ class AddNewServiceOptionsColumns extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropForeign(['config_from']); $table->dropColumn('config_from'); diff --git a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php b/database/migrations/old/2017_03_10_173607_MigrateToNewServiceSystem.php similarity index 87% rename from database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php rename to database/migrations/old/2017_03_10_173607_MigrateToNewServiceSystem.php index 40aef1524..9ba9bb42d 100644 --- a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php +++ b/database/migrations/old/2017_03_10_173607_MigrateToNewServiceSystem.php @@ -1,5 +1,7 @@ where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first(); - if (!$service) { + if (! $service) { return; } $options = DB::table('service_options')->where('service_id', $service->id)->get(); - $options->each(function ($item) { + $options->each(function ($item): void { if ($item->tag === 'srcds' && $item->name === 'Insurgency') { $item->tag = 'insurgency'; } elseif ($item->tag === 'srcds' && $item->name === 'Team Fortress 2') { @@ -24,6 +26,7 @@ class MigrateToNewServiceSystem extends Migration } elseif ($item->tag === 'srcds' && $item->name === 'Custom Source Engine Game') { $item->tag = 'source'; } + $item->save(); }); }); diff --git a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php b/database/migrations/old/2017_03_11_215455_ChangeServiceVariablesValidationRules.php similarity index 85% rename from database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php rename to database/migrations/old/2017_03_11_215455_ChangeServiceVariablesValidationRules.php index 3e7e5f18b..f3721b0b9 100644 --- a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php +++ b/database/migrations/old/2017_03_11_215455_ChangeServiceVariablesValidationRules.php @@ -1,8 +1,10 @@ renameColumn('regex', 'rules'); }); - DB::transaction(function () { + DB::transaction(function (): void { foreach (DB::table('service_variables')->get() as $variable) { - $variable->rules = ($variable->required) ? 'required|regex:' . $variable->rules : 'regex:' . $variable->rules; + $variable->rules = ($variable->required) ? 'required|regex:'.$variable->rules : 'regex:'.$variable->rules; $variable->save(); } }); - Schema::table('service_variables', function (Blueprint $table) { + Schema::table('service_variables', function (Blueprint $table): void { $table->dropColumn('required'); }); } @@ -32,12 +34,12 @@ class ChangeServiceVariablesValidationRules extends Migration */ public function down(): void { - Schema::table('service_variables', function (Blueprint $table) { + Schema::table('service_variables', function (Blueprint $table): void { $table->renameColumn('rules', 'regex'); $table->boolean('required')->default(true)->before('regex'); }); - DB::transaction(function () { + DB::transaction(function (): void { foreach (DB::table('service_variables')->get() as $variable) { $variable->regex = str_replace(['required|regex:', 'regex:'], '', $variable->regex); $variable->save(); diff --git a/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php b/database/migrations/old/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php similarity index 92% rename from database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php rename to database/migrations/old/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php index 26599246c..045f04280 100644 --- a/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php +++ b/database/migrations/old/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php @@ -1,12 +1,14 @@ text('index_file')->after('startup'); }); - DB::transaction(function () { + DB::transaction(function (): void { DB::table('services')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('folder', '!=', 'minecraft')->update([ 'index_file' => $this->default, ]); @@ -107,7 +109,7 @@ EOF; */ public function down(): void { - Schema::table('services', function (Blueprint $table) { + Schema::table('services', function (Blueprint $table): void { $table->dropColumn('index_file'); }); } diff --git a/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php b/database/migrations/old/2017_03_14_175631_RenameServicePacksToSingluarPacks.php similarity index 83% rename from database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php rename to database/migrations/old/2017_03_14_175631_RenameServicePacksToSingluarPacks.php index f73befdba..49142f240 100644 --- a/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php +++ b/database/migrations/old/2017_03_14_175631_RenameServicePacksToSingluarPacks.php @@ -1,8 +1,10 @@ dropForeign(['option_id']); }); Schema::rename('service_packs', 'packs'); - Schema::table('packs', function (Blueprint $table) { + Schema::table('packs', function (Blueprint $table): void { $table->foreign('option_id')->references('id')->on('service_options'); }); } @@ -27,13 +29,13 @@ class RenameServicePacksToSingluarPacks extends Migration */ public function down(): void { - Schema::table('packs', function (Blueprint $table) { + Schema::table('packs', function (Blueprint $table): void { $table->dropForeign(['option_id']); }); Schema::rename('packs', 'service_packs'); - Schema::table('service_packs', function (Blueprint $table) { + Schema::table('service_packs', function (Blueprint $table): void { $table->foreign('option_id')->references('id')->on('service_options'); }); } diff --git a/database/migrations/2017_03_14_200326_AddLockedStatusToTable.php b/database/migrations/old/2017_03_14_200326_AddLockedStatusToTable.php similarity index 75% rename from database/migrations/2017_03_14_200326_AddLockedStatusToTable.php rename to database/migrations/old/2017_03_14_200326_AddLockedStatusToTable.php index b396954e0..2427dd34b 100644 --- a/database/migrations/2017_03_14_200326_AddLockedStatusToTable.php +++ b/database/migrations/old/2017_03_14_200326_AddLockedStatusToTable.php @@ -1,8 +1,10 @@ boolean('locked')->default(false)->after('visible'); }); } @@ -21,7 +23,7 @@ class AddLockedStatusToTable extends Migration */ public function down(): void { - Schema::table('packs', function (Blueprint $table) { + Schema::table('packs', function (Blueprint $table): void { $table->dropColumn('locked'); }); } diff --git a/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php b/database/migrations/old/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php similarity index 93% rename from database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php rename to database/migrations/old/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php index c973faa55..a148a598b 100644 --- a/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php +++ b/database/migrations/old/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php @@ -1,8 +1,10 @@ dropForeign(['linked_node']); }); Schema::rename('database_servers', 'database_hosts'); - Schema::table('database_hosts', function (Blueprint $table) { + Schema::table('database_hosts', function (Blueprint $table): void { $table->renameColumn('linked_node', 'node_id'); $table->foreign('node_id')->references('id')->on('nodes'); @@ -29,13 +31,13 @@ class ReOrganizeDatabaseServersToDatabaseHost extends Migration */ public function down(): void { - Schema::table('database_hosts', function (Blueprint $table) { + Schema::table('database_hosts', function (Blueprint $table): void { $table->dropForeign(['node_id']); }); Schema::rename('database_hosts', 'database_servers'); - Schema::table('database_servers', function (Blueprint $table) { + Schema::table('database_servers', function (Blueprint $table): void { $table->renameColumn('node_id', 'linked_node'); $table->foreign('linked_node')->references('id')->on('nodes'); diff --git a/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php b/database/migrations/old/2017_03_16_181515_CleanupDatabasesDatabase.php similarity index 82% rename from database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php rename to database/migrations/old/2017_03_16_181515_CleanupDatabasesDatabase.php index 2b689c481..00261a838 100644 --- a/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php +++ b/database/migrations/old/2017_03_16_181515_CleanupDatabasesDatabase.php @@ -1,8 +1,10 @@ dropForeign(['db_server']); $table->renameColumn('db_server', 'database_host_id'); @@ -25,7 +27,7 @@ class CleanupDatabasesDatabase extends Migration */ public function down(): void { - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->dropForeign(['database_host_id']); $table->renameColumn('database_host_id', 'db_server'); diff --git a/database/migrations/2017_03_18_204953_AddForeignKeyToPacks.php b/database/migrations/old/2017_03_18_204953_AddForeignKeyToPacks.php similarity index 75% rename from database/migrations/2017_03_18_204953_AddForeignKeyToPacks.php rename to database/migrations/old/2017_03_18_204953_AddForeignKeyToPacks.php index bdd1f1a54..9dca40437 100644 --- a/database/migrations/2017_03_18_204953_AddForeignKeyToPacks.php +++ b/database/migrations/old/2017_03_18_204953_AddForeignKeyToPacks.php @@ -1,8 +1,10 @@ foreign('pack_id')->references('id')->on('packs'); }); } @@ -21,7 +23,7 @@ class AddForeignKeyToPacks extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['pack_id']); }); } diff --git a/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php b/database/migrations/old/2017_03_31_221948_AddServerDescriptionColumn.php similarity index 75% rename from database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php rename to database/migrations/old/2017_03_31_221948_AddServerDescriptionColumn.php index 69d044582..84d7a4dbf 100644 --- a/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php +++ b/database/migrations/old/2017_03_31_221948_AddServerDescriptionColumn.php @@ -1,8 +1,10 @@ text('description')->after('name'); }); } @@ -21,7 +23,7 @@ class AddServerDescriptionColumn extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('description'); }); } diff --git a/database/migrations/2017_04_02_163232_DropDeletedAtColumnFromServers.php b/database/migrations/old/2017_04_02_163232_DropDeletedAtColumnFromServers.php similarity index 75% rename from database/migrations/2017_04_02_163232_DropDeletedAtColumnFromServers.php rename to database/migrations/old/2017_04_02_163232_DropDeletedAtColumnFromServers.php index 0c193192b..74c46c65a 100644 --- a/database/migrations/2017_04_02_163232_DropDeletedAtColumnFromServers.php +++ b/database/migrations/old/2017_04_02_163232_DropDeletedAtColumnFromServers.php @@ -1,8 +1,10 @@ dropColumn('deleted_at'); }); } @@ -21,7 +23,7 @@ class DropDeletedAtColumnFromServers extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->timestamp('deleted_at')->nullable(); }); } diff --git a/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php b/database/migrations/old/2017_04_15_125021_UpgradeTaskSystem.php similarity index 85% rename from database/migrations/2017_04_15_125021_UpgradeTaskSystem.php rename to database/migrations/old/2017_04_15_125021_UpgradeTaskSystem.php index 68d9492e3..d4fd1faf7 100644 --- a/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php +++ b/database/migrations/old/2017_04_15_125021_UpgradeTaskSystem.php @@ -1,9 +1,11 @@ dropForeign(['server']); $table->renameColumn('server', 'server_id'); @@ -22,7 +24,7 @@ class UpgradeTaskSystem extends Migration $table->foreign('user_id')->references('id')->on('users'); }); - DB::transaction(function () { + DB::transaction(function (): void { foreach (Task::all() as $task) { $task->user_id = $task->server->owner_id; $task->save(); @@ -35,7 +37,7 @@ class UpgradeTaskSystem extends Migration */ public function down(): void { - Schema::table('tasks', function (Blueprint $table) { + Schema::table('tasks', function (Blueprint $table): void { // $table->dropForeign(['server_id']); // $table->dropForeign(['user_id']); diff --git a/database/migrations/2017_04_20_171943_AddScriptsToServiceOptions.php b/database/migrations/old/2017_04_20_171943_AddScriptsToServiceOptions.php similarity index 95% rename from database/migrations/2017_04_20_171943_AddScriptsToServiceOptions.php rename to database/migrations/old/2017_04_20_171943_AddScriptsToServiceOptions.php index 96a85be92..933eecc05 100644 --- a/database/migrations/2017_04_20_171943_AddScriptsToServiceOptions.php +++ b/database/migrations/old/2017_04_20_171943_AddScriptsToServiceOptions.php @@ -1,8 +1,10 @@ text('script_install')->after('startup')->nullable(); $table->boolean('script_is_privileged')->default(true)->after('startup'); $table->string('script_entry')->default('ash')->after('startup'); @@ -24,7 +26,7 @@ class AddScriptsToServiceOptions extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropColumn('script_install'); $table->dropColumn('script_is_privileged'); $table->dropColumn('script_entry'); diff --git a/database/migrations/2017_04_21_151432_AddServiceScriptTrackingToServers.php b/database/migrations/old/2017_04_21_151432_AddServiceScriptTrackingToServers.php similarity index 76% rename from database/migrations/2017_04_21_151432_AddServiceScriptTrackingToServers.php rename to database/migrations/old/2017_04_21_151432_AddServiceScriptTrackingToServers.php index 970b41773..ac9129a37 100644 --- a/database/migrations/2017_04_21_151432_AddServiceScriptTrackingToServers.php +++ b/database/migrations/old/2017_04_21_151432_AddServiceScriptTrackingToServers.php @@ -1,8 +1,10 @@ boolean('skip_scripts')->default(false)->after('description'); }); } @@ -21,7 +23,7 @@ class AddServiceScriptTrackingToServers extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('skip_scripts'); }); } diff --git a/database/migrations/2017_04_27_145300_AddCopyScriptFromColumn.php b/database/migrations/old/2017_04_27_145300_AddCopyScriptFromColumn.php similarity index 93% rename from database/migrations/2017_04_27_145300_AddCopyScriptFromColumn.php rename to database/migrations/old/2017_04_27_145300_AddCopyScriptFromColumn.php index 8888600fb..04d7fd28f 100644 --- a/database/migrations/2017_04_27_145300_AddCopyScriptFromColumn.php +++ b/database/migrations/old/2017_04_27_145300_AddCopyScriptFromColumn.php @@ -1,8 +1,10 @@ unsignedInteger('copy_script_from')->nullable()->after('script_container'); $table->foreign('copy_script_from')->references('id')->on('service_options'); @@ -23,7 +25,7 @@ class AddCopyScriptFromColumn extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropForeign(['copy_script_from']); $table->dropColumn('copy_script_from'); }); diff --git a/database/migrations/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php b/database/migrations/old/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php similarity index 77% rename from database/migrations/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php rename to database/migrations/old/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php index 96bb9aec5..6d8ccbb35 100644 --- a/database/migrations/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php +++ b/database/migrations/old/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php @@ -1,8 +1,10 @@ boolean('behind_proxy')->after('scheme')->default(false); }); } @@ -21,7 +23,7 @@ class AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropColumn('behind_proxy'); }); } diff --git a/database/migrations/2017_05_01_141528_DeleteDownloadTable.php b/database/migrations/old/2017_05_01_141528_DeleteDownloadTable.php similarity index 86% rename from database/migrations/2017_05_01_141528_DeleteDownloadTable.php rename to database/migrations/old/2017_05_01_141528_DeleteDownloadTable.php index 967c12615..a08b936ac 100644 --- a/database/migrations/2017_05_01_141528_DeleteDownloadTable.php +++ b/database/migrations/old/2017_05_01_141528_DeleteDownloadTable.php @@ -1,8 +1,10 @@ increments('id'); $table->char('token', 36)->unique(); $table->char('server', 36); diff --git a/database/migrations/2017_05_01_141559_DeleteNodeConfigurationTable.php b/database/migrations/old/2017_05_01_141559_DeleteNodeConfigurationTable.php similarity index 91% rename from database/migrations/2017_05_01_141559_DeleteNodeConfigurationTable.php rename to database/migrations/old/2017_05_01_141559_DeleteNodeConfigurationTable.php index d230bc19a..223a40585 100644 --- a/database/migrations/2017_05_01_141559_DeleteNodeConfigurationTable.php +++ b/database/migrations/old/2017_05_01_141559_DeleteNodeConfigurationTable.php @@ -1,8 +1,10 @@ increments('id'); $table->char('token', 32); $table->unsignedInteger('node_id'); $table->timestamps(); }); - Schema::table('node_configuration_tokens', function (Blueprint $table) { + Schema::table('node_configuration_tokens', function (Blueprint $table): void { $table->foreign('node_id')->references('id')->on('nodes'); }); } diff --git a/database/migrations/2017_06_10_152951_add_external_id_to_users.php b/database/migrations/old/2017_06_10_152951_add_external_id_to_users.php similarity index 76% rename from database/migrations/2017_06_10_152951_add_external_id_to_users.php rename to database/migrations/old/2017_06_10_152951_add_external_id_to_users.php index bccfb43fd..37b366207 100644 --- a/database/migrations/2017_06_10_152951_add_external_id_to_users.php +++ b/database/migrations/old/2017_06_10_152951_add_external_id_to_users.php @@ -1,8 +1,10 @@ unsignedInteger('external_id')->after('id')->nullable()->unique(); }); } @@ -21,7 +23,7 @@ class AddExternalIdToUsers extends Migration */ public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->dropColumn('external_id'); }); } diff --git a/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php b/database/migrations/old/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php similarity index 93% rename from database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php rename to database/migrations/old/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php index 6f36d0e05..083b7bd6a 100644 --- a/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php +++ b/database/migrations/old/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php @@ -1,8 +1,10 @@ dropForeign(['key_id']); $table->foreign('key_id')->references('id')->on('api_keys')->onDelete('cascade'); @@ -23,7 +25,7 @@ class ChangeForeignKeyToBeOnCascadeDelete extends Migration */ public function down(): void { - Schema::table('api_permissions', function (Blueprint $table) { + Schema::table('api_permissions', function (Blueprint $table): void { $table->dropForeign(['key_id']); $table->foreign('key_id')->references('id')->on('api_keys'); diff --git a/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php b/database/migrations/old/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php similarity index 88% rename from database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php rename to database/migrations/old/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php index 10058c8cc..9af4f39f3 100644 --- a/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php +++ b/database/migrations/old/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php @@ -1,8 +1,10 @@ dropForeign(['subuser_id']); $table->foreign('subuser_id')->references('id')->on('subusers')->onDelete('cascade'); }); - Schema::table('subusers', function (Blueprint $table) { + Schema::table('subusers', function (Blueprint $table): void { $table->dropForeign(['user_id']); $table->dropForeign(['server_id']); @@ -31,7 +33,7 @@ class ChangeUserPermissionsToDeleteOnUserDeletion extends Migration */ public function down(): void { - Schema::table('subusers', function (Blueprint $table) { + Schema::table('subusers', function (Blueprint $table): void { $table->dropForeign(['user_id']); $table->dropForeign(['server_id']); @@ -39,7 +41,7 @@ class ChangeUserPermissionsToDeleteOnUserDeletion extends Migration $table->foreign('server_id')->references('id')->on('servers'); }); - Schema::table('permissions', function (Blueprint $table) { + Schema::table('permissions', function (Blueprint $table): void { $table->dropForeign(['subuser_id']); $table->foreign('subuser_id')->references('id')->on('subusers'); diff --git a/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php b/database/migrations/old/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php similarity index 94% rename from database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php rename to database/migrations/old/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php index 8ac6eccec..fad0022e7 100644 --- a/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php +++ b/database/migrations/old/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php @@ -1,8 +1,10 @@ dropForeign(['server_id']); $table->foreign('server_id')->references('id')->on('servers')->onDelete('set null'); @@ -23,7 +25,7 @@ class SetAllocationToReferenceNullOnServerDelete extends Migration */ public function down(): void { - Schema::table('allocations', function (Blueprint $table) { + Schema::table('allocations', function (Blueprint $table): void { $table->dropForeign(['server_id']); $table->foreign('server_id')->references('id')->on('servers'); diff --git a/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php b/database/migrations/old/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php similarity index 95% rename from database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php rename to database/migrations/old/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php index ca5a4623f..3200cac2d 100644 --- a/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php +++ b/database/migrations/old/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php @@ -1,8 +1,10 @@ dropForeign(['server_id']); $table->dropForeign(['variable_id']); @@ -25,7 +27,7 @@ class CascadeDeletionWhenAServerOrVariableIsDeleted extends Migration */ public function down(): void { - Schema::table('server_variables', function (Blueprint $table) { + Schema::table('server_variables', function (Blueprint $table): void { $table->dropForeign(['server_id']); $table->dropForeign(['variable_id']); diff --git a/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php b/database/migrations/old/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php similarity index 79% rename from database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php rename to database/migrations/old/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php index cf0a4bba1..e5222e5c3 100644 --- a/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php +++ b/database/migrations/old/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php @@ -1,8 +1,10 @@ dropForeign(['server_id']); $table->foreign('server_id')->references('id')->on('servers')->onDelete('cascade'); @@ -21,7 +23,5 @@ class DeleteTaskWhenParentServerIsDeleted extends Migration /** * Reverse the migrations. */ - public function down(): void - { - } + public function down(): void {} } diff --git a/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php b/database/migrations/old/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php similarity index 94% rename from database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php rename to database/migrations/old/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php index 0eabe77db..dd773f66e 100644 --- a/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php +++ b/database/migrations/old/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php @@ -1,8 +1,10 @@ dropForeign(['node_id']); $table->foreign('node_id')->references('id')->on('nodes')->onDelete('set null'); }); @@ -22,7 +24,7 @@ class CascadeNullValuesForDatabaseHostWhenNodeIsDeleted extends Migration */ public function down(): void { - Schema::table('database_hosts', function (Blueprint $table) { + Schema::table('database_hosts', function (Blueprint $table): void { $table->dropForeign(['node_id']); $table->foreign('node_id')->references('id')->on('nodes'); }); diff --git a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php b/database/migrations/old/2017_08_05_144104_AllowNegativeValuesForOverallocation.php similarity index 82% rename from database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php rename to database/migrations/old/2017_08_05_144104_AllowNegativeValuesForOverallocation.php index 3fb457dc4..6471d678f 100644 --- a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php +++ b/database/migrations/old/2017_08_05_144104_AllowNegativeValuesForOverallocation.php @@ -1,8 +1,10 @@ integer('disk_overallocate')->default(0)->nullable(false)->change(); $table->integer('memory_overallocate')->default(0)->nullable(false)->change(); }); @@ -22,7 +24,7 @@ class AllowNegativeValuesForOverallocation extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { DB::statement('ALTER TABLE nodes MODIFY disk_overallocate MEDIUMINT UNSIGNED NULL, MODIFY memory_overallocate MEDIUMINT UNSIGNED NULL'); }); diff --git a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php b/database/migrations/old/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php similarity index 94% rename from database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php rename to database/migrations/old/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php index f2d8ad9bf..ab38a4a35 100644 --- a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php +++ b/database/migrations/old/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php @@ -1,8 +1,10 @@ unique(['node_id', 'ip', 'port']); }); } @@ -21,7 +23,7 @@ class SetAllocationUnqiueUsingMultipleFields extends Migration */ public function down(): void { - Schema::table('allocations', function (Blueprint $table) { + Schema::table('allocations', function (Blueprint $table): void { $table->dropForeign(['node_id']); $table->dropUnique(['node_id', 'ip', 'port']); $table->foreign('node_id')->references('id')->on('nodes'); diff --git a/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php b/database/migrations/old/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php similarity index 93% rename from database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php rename to database/migrations/old/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php index fbea750bc..ae5f0f75e 100644 --- a/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php +++ b/database/migrations/old/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php @@ -1,8 +1,10 @@ dropForeign(['service_id']); $table->foreign('service_id')->references('id')->on('services')->onDelete('cascade'); @@ -23,7 +25,7 @@ class CascadeDeletionWhenAParentServiceIsDeleted extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropForeign(['service_id']); $table->foreign('service_id')->references('id')->on('services'); diff --git a/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php b/database/migrations/old/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php similarity index 81% rename from database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php rename to database/migrations/old/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php index 7c59d801e..d1e359da7 100644 --- a/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php +++ b/database/migrations/old/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php @@ -1,8 +1,10 @@ dropForeign(['option_id']); $table->foreign('option_id')->references('id')->on('service_options')->onDelete('cascade'); @@ -23,7 +25,7 @@ class RemovePackWhenParentServiceOptionIsDeleted extends Migration */ public function down(): void { - Schema::table('packs', function (Blueprint $table) { + Schema::table('packs', function (Blueprint $table): void { $table->dropForeign(['option_id']); $table->foreign('option_id')->references('id')->on('service_options'); diff --git a/database/migrations/2017_09_10_225749_RenameTasksTableForStructureRefactor.php b/database/migrations/old/2017_09_10_225749_RenameTasksTableForStructureRefactor.php similarity index 94% rename from database/migrations/2017_09_10_225749_RenameTasksTableForStructureRefactor.php rename to database/migrations/old/2017_09_10_225749_RenameTasksTableForStructureRefactor.php index 14f60b3b6..b48ae9db8 100644 --- a/database/migrations/2017_09_10_225749_RenameTasksTableForStructureRefactor.php +++ b/database/migrations/old/2017_09_10_225749_RenameTasksTableForStructureRefactor.php @@ -1,7 +1,9 @@ increments('id'); $table->unsignedInteger('server_id'); $table->string('name')->nullable(); diff --git a/database/migrations/2017_09_10_230309_CreateNewTasksTableForSchedules.php b/database/migrations/old/2017_09_10_230309_CreateNewTasksTableForSchedules.php similarity index 90% rename from database/migrations/2017_09_10_230309_CreateNewTasksTableForSchedules.php rename to database/migrations/old/2017_09_10_230309_CreateNewTasksTableForSchedules.php index 969c15361..dd980cdb8 100644 --- a/database/migrations/2017_09_10_230309_CreateNewTasksTableForSchedules.php +++ b/database/migrations/old/2017_09_10_230309_CreateNewTasksTableForSchedules.php @@ -1,8 +1,10 @@ increments('id'); $table->unsignedInteger('schedule_id'); $table->unsignedInteger('sequence_id'); diff --git a/database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php b/database/migrations/old/2017_09_11_002938_TransferOldTasksToNewScheduler.php similarity index 93% rename from database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php rename to database/migrations/old/2017_09_11_002938_TransferOldTasksToNewScheduler.php index 4656e272e..ea32b9c0c 100644 --- a/database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php +++ b/database/migrations/old/2017_09_11_002938_TransferOldTasksToNewScheduler.php @@ -1,10 +1,12 @@ get(); - $tasks->each(function ($task) { + $tasks->each(function ($task): void { $schedule = DB::table('schedules')->insertGetId([ 'server_id' => $task->server_id, 'name' => null, @@ -55,7 +57,7 @@ class TransferOldTasksToNewScheduler extends Migration */ public function down(): void { - Schema::create('tasks_old', function (Blueprint $table) { + Schema::create('tasks_old', function (Blueprint $table): void { $table->increments('id'); $table->unsignedInteger('user_id')->nullable(); $table->unsignedInteger('server_id'); diff --git a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php b/database/migrations/old/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php similarity index 76% rename from database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php rename to database/migrations/old/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php index 7c0c57447..78c135614 100644 --- a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php +++ b/database/migrations/old/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php @@ -1,7 +1,10 @@ where('permission', 'like', '%-task%')->get(); foreach ($permissions as $record) { $parts = explode('-', $record->permission); - if (!in_array(array_get($parts, 1), ['tasks', 'task']) || count($parts) !== 2) { + if (! in_array(Arr::get($parts, 1), ['tasks', 'task']) || count($parts) !== 2) { continue; } - $newPermission = $parts[0] . '-' . str_replace('task', 'schedule', $parts[1]); + $newPermission = $parts[0].'-'.str_replace('task', 'schedule', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } @@ -31,11 +34,11 @@ class UpdateOldPermissionsToPointToNewScheduleSystem extends Migration $permissions = DB::table('permissions')->where('permission', 'like', '%-schedule%')->get(); foreach ($permissions as $record) { $parts = explode('-', $record->permission); - if (!in_array(array_get($parts, 1), ['schedules', 'schedule']) || count($parts) !== 2) { + if (! in_array(Arr::get($parts, 1), ['schedules', 'schedule']) || count($parts) !== 2) { continue; } - $newPermission = $parts[0] . '-' . str_replace('schedule', 'task', $parts[1]); + $newPermission = $parts[0].'-'.str_replace('schedule', 'task', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } diff --git a/database/migrations/2017_09_23_170933_CreateDaemonKeysTable.php b/database/migrations/old/2017_09_23_170933_CreateDaemonKeysTable.php similarity index 96% rename from database/migrations/2017_09_23_170933_CreateDaemonKeysTable.php rename to database/migrations/old/2017_09_23_170933_CreateDaemonKeysTable.php index 64ff02666..e3f4aa639 100644 --- a/database/migrations/2017_09_23_170933_CreateDaemonKeysTable.php +++ b/database/migrations/old/2017_09_23_170933_CreateDaemonKeysTable.php @@ -1,8 +1,10 @@ increments('id'); $table->unsignedInteger('server_id'); $table->unsignedInteger('user_id'); diff --git a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php b/database/migrations/old/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php similarity index 79% rename from database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php rename to database/migrations/old/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php index b284905a0..686580d18 100644 --- a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php +++ b/database/migrations/old/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php @@ -1,10 +1,13 @@ select('id', 'owner_id')->get(); - $servers->each(function ($server) use (&$inserts) { + $servers->each(function ($server) use (&$inserts): void { $inserts[] = [ 'user_id' => $server->owner_id, 'server_id' => $server->id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.Str::random(40), 'expires_at' => Carbon::now()->addMinutes(config('pterodactyl.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), ]; }); - DB::transaction(function () use ($inserts) { + DB::transaction(function () use ($inserts): void { DB::table('daemon_keys')->insert($inserts); }); - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropUnique(['daemonSecret']); $table->dropColumn('daemonSecret'); }); @@ -43,7 +46,7 @@ class RemoveDaemonSecretFromServersTable extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->char('daemonSecret', 36)->after('startup')->unique(); }); diff --git a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php b/database/migrations/old/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php similarity index 76% rename from database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php rename to database/migrations/old/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php index 9ea90cff2..b25ffbfcf 100644 --- a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php +++ b/database/migrations/old/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php @@ -1,10 +1,13 @@ get(); - $subusers->each(function ($subuser) use (&$inserts) { + $subusers->each(function ($subuser) use (&$inserts): void { $inserts[] = [ 'user_id' => $subuser->user_id, 'server_id' => $subuser->server_id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.Str::random(40), 'expires_at' => Carbon::now()->addMinutes(config('pterodactyl.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), ]; }); - DB::transaction(function () use ($inserts) { + DB::transaction(function () use ($inserts): void { DB::table('daemon_keys')->insert($inserts); }); - Schema::table('subusers', function (Blueprint $table) { + Schema::table('subusers', function (Blueprint $table): void { $table->dropUnique(['daemonSecret']); $table->dropColumn('daemonSecret'); }); @@ -42,16 +45,16 @@ class RemoveDaemonSecretFromSubusersTable extends Migration */ public function down(): void { - Schema::table('subusers', function (Blueprint $table) { + Schema::table('subusers', function (Blueprint $table): void { $table->char('daemonSecret', 36)->after('server_id'); }); $subusers = DB::table('subusers')->get(); - $subusers->each(function ($subuser) { + $subusers->each(function ($subuser): void { DB::table('daemon_keys')->where('user_id', $subuser->user_id)->where('server_id', $subuser->server_id)->delete(); }); - Schema::table('subusers', function (Blueprint $table) { + Schema::table('subusers', function (Blueprint $table): void { $table->unique('daemonSecret'); }); } diff --git a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php b/database/migrations/old/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php similarity index 85% rename from database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php rename to database/migrations/old/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php index aae62921a..dca177caf 100644 --- a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php +++ b/database/migrations/old/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php @@ -1,10 +1,12 @@ dropUnique(['name']); $table->dropUnique(['file']); @@ -24,14 +26,14 @@ class ChangeServicesToUseAMoreUniqueIdentifier extends Migration $table->dropColumn('index_file'); }); - DB::table('services')->get(['id', 'author', 'uuid'])->each(function ($service) { + DB::table('services')->get(['id', 'author', 'uuid'])->each(function ($service): void { DB::table('services')->where('id', $service->id)->update([ 'author' => ($service->author === 'ptrdctyl-v040-11e6-8b77-86f30ca893d3') ? 'support@pterodactyl.io' : 'unknown@unknown-author.com', 'uuid' => Uuid::uuid4()->toString(), ]); }); - Schema::table('services', function (Blueprint $table) { + Schema::table('services', function (Blueprint $table): void { $table->unique('uuid'); }); } @@ -41,7 +43,7 @@ class ChangeServicesToUseAMoreUniqueIdentifier extends Migration */ public function down(): void { - Schema::table('services', function (Blueprint $table) { + Schema::table('services', function (Blueprint $table): void { $table->dropColumn('uuid'); $table->string('folder')->nullable(); $table->text('startup')->nullable(); diff --git a/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php b/database/migrations/old/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php similarity index 83% rename from database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php rename to database/migrations/old/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php index 679a8b5e0..f23f5f90e 100644 --- a/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php +++ b/database/migrations/old/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php @@ -1,10 +1,13 @@ char('uuid', 36)->after('id'); $table->string('author')->after('service_id'); $table->dropColumn('tag'); }); - DB::transaction(function () { + DB::transaction(function (): void { DB::table('service_options')->select([ 'service_options.id', 'service_options.uuid', 'services.author AS service_author', - ])->join('services', 'services.id', '=', 'service_options.service_id')->get()->each(function ($option) { + ])->join('services', 'services.id', '=', 'service_options.service_id')->get()->each(function ($option): void { DB::table('service_options')->where('id', $option->id)->update([ 'author' => $option->service_author, 'uuid' => Uuid::uuid4()->toString(), @@ -32,7 +35,7 @@ class ChangeToABetterUniqueServiceConfiguration extends Migration }); }); - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->unique('uuid'); }); } @@ -42,16 +45,16 @@ class ChangeToABetterUniqueServiceConfiguration extends Migration */ public function down(): void { - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropColumn('uuid'); $table->dropColumn('author'); $table->string('tag'); }); - DB::transaction(function () { - DB::table('service_options')->select(['id', 'tag'])->get()->each(function ($option) { + DB::transaction(function (): void { + DB::table('service_options')->select(['id', 'tag'])->get()->each(function ($option): void { DB::table('service_options')->where('id', $option->id)->update([ - 'tag' => str_random(10), + 'tag' => Str::random(10), ]); }); }); diff --git a/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php b/database/migrations/old/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php similarity index 93% rename from database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php rename to database/migrations/old/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php index 9a64abf07..6872ee23a 100644 --- a/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php +++ b/database/migrations/old/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php @@ -1,8 +1,10 @@ dropForeign(['option_id']); $table->foreign('option_id')->references('id')->on('service_options')->onDelete('CASCADE'); @@ -23,7 +25,7 @@ class CascadeDeletionWhenServiceOptionIsDeleted extends Migration */ public function down(): void { - Schema::table('service_variables', function (Blueprint $table) { + Schema::table('service_variables', function (Blueprint $table): void { $table->dropForeign(['option_id']); $table->foreign('option_id')->references('id')->on('service_options'); diff --git a/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php b/database/migrations/old/2017_10_06_214026_ServicesToNestsConversion.php similarity index 89% rename from database/migrations/2017_10_06_214026_ServicesToNestsConversion.php rename to database/migrations/old/2017_10_06_214026_ServicesToNestsConversion.php index cea7460e6..c37a25db6 100644 --- a/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php +++ b/database/migrations/old/2017_10_06_214026_ServicesToNestsConversion.php @@ -1,8 +1,10 @@ dropForeign(['service_id']); $table->renameColumn('service_id', 'nest_id'); $table->foreign('nest_id')->references('id')->on('nests'); }); - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropForeign(['service_id']); $table->renameColumn('service_id', 'nest_id'); @@ -41,14 +43,14 @@ class ServicesToNestsConversion extends Migration Schema::rename('nests', 'services'); - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['nest_id']); $table->renameColumn('nest_id', 'service_id'); $table->foreign('service_id')->references('id')->on('services'); }); - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->dropForeign(['nest_id']); $table->renameColumn('nest_id', 'service_id'); diff --git a/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php b/database/migrations/old/2017_10_06_214053_ServiceOptionsToEggsConversion.php similarity index 85% rename from database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php rename to database/migrations/old/2017_10_06_214053_ServiceOptionsToEggsConversion.php index fa09ac624..ff80d9c34 100644 --- a/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php +++ b/database/migrations/old/2017_10_06_214053_ServiceOptionsToEggsConversion.php @@ -1,8 +1,10 @@ dropForeign(['config_from']); $table->dropForeign(['copy_script_from']); }); Schema::rename('service_options', 'eggs'); - Schema::table('packs', function (Blueprint $table) { + Schema::table('packs', function (Blueprint $table): void { $table->dropForeign(['option_id']); $table->renameColumn('option_id', 'egg_id'); $table->foreign('egg_id')->references('id')->on('eggs')->onDelete('CASCADE'); }); - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['option_id']); $table->renameColumn('option_id', 'egg_id'); $table->foreign('egg_id')->references('id')->on('eggs'); }); - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->foreign('config_from')->references('id')->on('eggs')->onDelete('SET NULL'); $table->foreign('copy_script_from')->references('id')->on('eggs')->onDelete('SET NULL'); }); - Schema::table('service_variables', function (Blueprint $table) { + Schema::table('service_variables', function (Blueprint $table): void { $table->dropForeign(['option_id']); $table->renameColumn('option_id', 'egg_id'); @@ -56,33 +58,33 @@ class ServiceOptionsToEggsConversion extends Migration { Schema::disableForeignKeyConstraints(); - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->dropForeign(['config_from']); $table->dropForeign(['copy_script_from']); }); Schema::rename('eggs', 'service_options'); - Schema::table('packs', function (Blueprint $table) { + Schema::table('packs', function (Blueprint $table): void { $table->dropForeign(['egg_id']); $table->renameColumn('egg_id', 'option_id'); $table->foreign('option_id')->references('id')->on('service_options')->onDelete('CASCADE'); }); - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['egg_id']); $table->renameColumn('egg_id', 'option_id'); $table->foreign('option_id')->references('id')->on('service_options'); }); - Schema::table('service_options', function (Blueprint $table) { + Schema::table('service_options', function (Blueprint $table): void { $table->foreign('config_from')->references('id')->on('service_options')->onDelete('SET NULL'); $table->foreign('copy_script_from')->references('id')->on('service_options')->onDelete('SET NULL'); }); - Schema::table('service_variables', function (Blueprint $table) { + Schema::table('service_variables', function (Blueprint $table): void { $table->dropForeign(['egg_id']); $table->renameColumn('egg_id', 'option_id'); diff --git a/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php b/database/migrations/old/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php similarity index 95% rename from database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php rename to database/migrations/old/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php index 5233ee9d0..42e77e023 100644 --- a/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php +++ b/database/migrations/old/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php @@ -1,8 +1,10 @@ dropForeign(['variable_id']); $table->foreign('variable_id')->references('id')->on('egg_variables')->onDelete('CASCADE'); @@ -33,7 +35,7 @@ class ServiceVariablesToEggVariablesConversion extends Migration Schema::rename('egg_variables', 'service_variables'); - Schema::table('server_variables', function (Blueprint $table) { + Schema::table('server_variables', function (Blueprint $table): void { $table->dropForeign(['variable_id']); $table->foreign('variable_id')->references('id')->on('service_variables')->onDelete('CASCADE'); diff --git a/database/migrations/2017_10_24_222238_RemoveLegacySFTPInformation.php b/database/migrations/old/2017_10_24_222238_RemoveLegacySFTPInformation.php similarity index 80% rename from database/migrations/2017_10_24_222238_RemoveLegacySFTPInformation.php rename to database/migrations/old/2017_10_24_222238_RemoveLegacySFTPInformation.php index c3ac7e4ab..5f27d3bed 100644 --- a/database/migrations/2017_10_24_222238_RemoveLegacySFTPInformation.php +++ b/database/migrations/old/2017_10_24_222238_RemoveLegacySFTPInformation.php @@ -1,8 +1,10 @@ dropUnique(['username']); $table->dropColumn('username'); @@ -24,7 +26,7 @@ class RemoveLegacySFTPInformation extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->string('username')->nullable()->after('image')->unique(); $table->text('sftp_password')->after('image'); }); diff --git a/database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php b/database/migrations/old/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php similarity index 79% rename from database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php rename to database/migrations/old/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php index b02e326c6..982e5c7a4 100644 --- a/database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php +++ b/database/migrations/old/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php @@ -1,11 +1,13 @@ text('totp_secret')->nullable()->change(); $table->timestampTz('totp_authenticated_at')->after('totp_secret')->nullable(); }); - DB::transaction(function () { - DB::table('users')->get()->each(function ($user) { + DB::transaction(function (): void { + DB::table('users')->get()->each(function ($user): void { if (is_null($user->totp_secret)) { return; } @@ -38,8 +40,8 @@ class Add2FaLastAuthorizationTimeColumn extends Migration */ public function down(): void { - DB::transaction(function () { - DB::table('users')->get()->each(function ($user) { + DB::transaction(function (): void { + DB::table('users')->get()->each(function ($user): void { if (is_null($user->totp_secret)) { return; } @@ -53,7 +55,7 @@ class Add2FaLastAuthorizationTimeColumn extends Migration DB::statement('ALTER TABLE users MODIFY totp_secret CHAR(16) DEFAULT NULL'); - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->dropColumn('totp_authenticated_at'); }); } diff --git a/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php b/database/migrations/old/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php similarity index 72% rename from database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php rename to database/migrations/old/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php index 229827dbc..374a442c2 100644 --- a/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php +++ b/database/migrations/old/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php @@ -1,12 +1,14 @@ get()->each(function ($item) { + DB::transaction(function (): void { + DB::table('api_keys')->get()->each(function ($item): void { try { $decrypted = Crypt::decrypt($item->secret); } catch (DecryptException) { - $decrypted = str_random(32); + $decrypted = Str::random(32); } finally { DB::table('api_keys')->where('id', $item->id)->update([ 'secret' => $decrypted, @@ -29,12 +31,12 @@ class MigratePubPrivFormatToSingleKey extends Migration }); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropColumn('public'); $table->renameColumn('secret', 'token'); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->char('token', 32)->change(); $table->unique('token'); }); @@ -45,25 +47,25 @@ class MigratePubPrivFormatToSingleKey extends Migration */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropUnique(['token']); $table->renameColumn('token', 'secret'); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropUnique('token'); $table->text('token')->change(); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->renameColumn('token', 'secret'); $table->text('secret')->nullable()->change(); $table->char('public', 16)->after('user_id'); }); - DB::transaction(function () { - DB::table('api_keys')->get()->each(function ($item) { + DB::transaction(function (): void { + DB::table('api_keys')->get()->each(function ($item): void { DB::table('api_keys')->where('id', $item->id)->update([ 'public' => Str::random(16), 'secret' => Crypt::encrypt($item->secret), diff --git a/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php b/database/migrations/old/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php similarity index 94% rename from database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php rename to database/migrations/old/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php index 9a0cc9114..72b51e418 100644 --- a/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php +++ b/database/migrations/old/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php @@ -1,8 +1,10 @@ dropForeign(['node_id']); $table->foreign('node_id')->references('id')->on('nodes')->onDelete('cascade'); @@ -23,7 +25,7 @@ class DropAllocationsWhenNodeIsDeleted extends Migration */ public function down(): void { - Schema::table('allocations', function (Blueprint $table) { + Schema::table('allocations', function (Blueprint $table): void { $table->dropForeign(['node_id']); $table->foreign('node_id')->references('id')->on('nodes'); diff --git a/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php b/database/migrations/old/2017_12_12_220426_MigrateSettingsTableToNewFormat.php similarity index 77% rename from database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php rename to database/migrations/old/2017_12_12_220426_MigrateSettingsTableToNewFormat.php index 8d639a37a..a6bc587be 100644 --- a/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php +++ b/database/migrations/old/2017_12_12_220426_MigrateSettingsTableToNewFormat.php @@ -1,9 +1,11 @@ truncate(); - Schema::table('settings', function (Blueprint $table) { + Schema::table('settings', function (Blueprint $table): void { $table->increments('id')->first(); }); } @@ -23,7 +25,7 @@ class MigrateSettingsTableToNewFormat extends Migration */ public function down(): void { - Schema::table('settings', function (Blueprint $table) { + Schema::table('settings', function (Blueprint $table): void { $table->dropColumn('id'); }); } diff --git a/database/migrations/2018_01_01_122821_AllowNegativeValuesForServerSwap.php b/database/migrations/old/2018_01_01_122821_AllowNegativeValuesForServerSwap.php similarity index 75% rename from database/migrations/2018_01_01_122821_AllowNegativeValuesForServerSwap.php rename to database/migrations/old/2018_01_01_122821_AllowNegativeValuesForServerSwap.php index 7ccae5d61..ad3c8143e 100644 --- a/database/migrations/2018_01_01_122821_AllowNegativeValuesForServerSwap.php +++ b/database/migrations/old/2018_01_01_122821_AllowNegativeValuesForServerSwap.php @@ -1,8 +1,10 @@ integer('swap')->change(); }); } @@ -21,7 +23,7 @@ class AllowNegativeValuesForServerSwap extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->unsignedInteger('swap')->change(); }); } diff --git a/database/migrations/2018_01_11_213943_AddApiKeyPermissionColumns.php b/database/migrations/old/2018_01_11_213943_AddApiKeyPermissionColumns.php similarity index 90% rename from database/migrations/2018_01_11_213943_AddApiKeyPermissionColumns.php rename to database/migrations/old/2018_01_11_213943_AddApiKeyPermissionColumns.php index 118a422f4..80914c413 100644 --- a/database/migrations/2018_01_11_213943_AddApiKeyPermissionColumns.php +++ b/database/migrations/old/2018_01_11_213943_AddApiKeyPermissionColumns.php @@ -1,8 +1,10 @@ unsignedTinyInteger('r_servers')->default(0); $table->unsignedTinyInteger('r_nodes')->default(0); $table->unsignedTinyInteger('r_allocations')->default(0); @@ -32,7 +34,7 @@ class AddApiKeyPermissionColumns extends Migration */ public function down(): void { - Schema::create('api_permissions', function (Blueprint $table) { + Schema::create('api_permissions', function (Blueprint $table): void { $table->increments('id'); $table->unsignedInteger('key_id'); $table->string('permission'); @@ -40,7 +42,7 @@ class AddApiKeyPermissionColumns extends Migration $table->foreign('key_id')->references('id')->on('api_keys')->onDelete('cascade'); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropColumn([ 'r_servers', 'r_nodes', diff --git a/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php b/database/migrations/old/2018_01_13_142012_SetupTableForKeyEncryption.php similarity index 77% rename from database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php rename to database/migrations/old/2018_01_13_142012_SetupTableForKeyEncryption.php index f45b5bd85..7dd208b83 100644 --- a/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php +++ b/database/migrations/old/2018_01_13_142012_SetupTableForKeyEncryption.php @@ -1,8 +1,10 @@ char('identifier', 16)->nullable()->unique()->after('user_id'); $table->dropUnique(['token']); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->text('token')->change(); }); } @@ -32,7 +34,7 @@ class SetupTableForKeyEncryption extends Migration */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropColumn('identifier'); $table->string('token', 32)->unique()->change(); }); diff --git a/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php b/database/migrations/old/2018_01_13_145209_AddLastUsedAtColumn.php similarity index 76% rename from database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php rename to database/migrations/old/2018_01_13_145209_AddLastUsedAtColumn.php index f78f7a5d1..25823db94 100644 --- a/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php +++ b/database/migrations/old/2018_01_13_145209_AddLastUsedAtColumn.php @@ -1,8 +1,10 @@ unsignedTinyInteger('key_type')->after('user_id')->default(0); $table->timestamp('last_used_at')->after('memo')->nullable(); $table->dropColumn('expires_at'); @@ -19,7 +21,7 @@ class AddLastUsedAtColumn extends Migration $table->dropForeign(['user_id']); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); }); } @@ -29,13 +31,13 @@ class AddLastUsedAtColumn extends Migration */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->timestamp('expires_at')->after('memo')->nullable(); $table->dropColumn('last_used_at', 'key_type'); $table->dropForeign(['user_id']); }); - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->foreign('user_id')->references('id')->on('users'); }); } diff --git a/database/migrations/2018_02_04_145617_AllowTextInUserExternalId.php b/database/migrations/old/2018_02_04_145617_AllowTextInUserExternalId.php similarity index 76% rename from database/migrations/2018_02_04_145617_AllowTextInUserExternalId.php rename to database/migrations/old/2018_02_04_145617_AllowTextInUserExternalId.php index 6166f016e..f762bd677 100644 --- a/database/migrations/2018_02_04_145617_AllowTextInUserExternalId.php +++ b/database/migrations/old/2018_02_04_145617_AllowTextInUserExternalId.php @@ -1,8 +1,10 @@ string('external_id')->nullable()->change(); }); } @@ -21,7 +23,7 @@ class AllowTextInUserExternalId extends Migration */ public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->unsignedInteger('external_id')->change(); }); } diff --git a/database/migrations/2018_02_10_151150_remove_unique_index_on_external_id_column.php b/database/migrations/old/2018_02_10_151150_remove_unique_index_on_external_id_column.php similarity index 75% rename from database/migrations/2018_02_10_151150_remove_unique_index_on_external_id_column.php rename to database/migrations/old/2018_02_10_151150_remove_unique_index_on_external_id_column.php index 64dbaf0dc..bf29544b8 100644 --- a/database/migrations/2018_02_10_151150_remove_unique_index_on_external_id_column.php +++ b/database/migrations/old/2018_02_10_151150_remove_unique_index_on_external_id_column.php @@ -1,8 +1,10 @@ dropUnique(['external_id']); }); } @@ -21,7 +23,7 @@ class RemoveUniqueIndexOnExternalIdColumn extends Migration */ public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->unique(['external_id']); }); } diff --git a/database/migrations/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php b/database/migrations/old/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php similarity index 79% rename from database/migrations/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php rename to database/migrations/old/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php index 99f1db454..8313c70bf 100644 --- a/database/migrations/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php +++ b/database/migrations/old/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php @@ -1,8 +1,10 @@ unique(['allocation_id']); }); } @@ -21,7 +23,7 @@ class EnsureUniqueAllocationIdOnServersTable extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropForeign(['allocation_id']); $table->dropUnique(['allocation_id']); diff --git a/database/migrations/2018_02_24_112356_add_external_id_column_to_servers_table.php b/database/migrations/old/2018_02_24_112356_add_external_id_column_to_servers_table.php similarity index 76% rename from database/migrations/2018_02_24_112356_add_external_id_column_to_servers_table.php rename to database/migrations/old/2018_02_24_112356_add_external_id_column_to_servers_table.php index c7d0f8fd4..fd3c8571c 100644 --- a/database/migrations/2018_02_24_112356_add_external_id_column_to_servers_table.php +++ b/database/migrations/old/2018_02_24_112356_add_external_id_column_to_servers_table.php @@ -1,8 +1,10 @@ string('external_id')->after('id')->nullable()->unique(); }); } @@ -21,7 +23,7 @@ class AddExternalIdColumnToServersTable extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('external_id'); }); } diff --git a/database/migrations/2018_02_25_160152_remove_default_null_value_on_table.php b/database/migrations/old/2018_02_25_160152_remove_default_null_value_on_table.php similarity index 84% rename from database/migrations/2018_02_25_160152_remove_default_null_value_on_table.php rename to database/migrations/old/2018_02_25_160152_remove_default_null_value_on_table.php index 2db2f375e..ad0372f85 100644 --- a/database/migrations/2018_02_25_160152_remove_default_null_value_on_table.php +++ b/database/migrations/old/2018_02_25_160152_remove_default_null_value_on_table.php @@ -1,9 +1,11 @@ string('external_id')->default(null)->change(); }); - DB::transaction(function () { + DB::transaction(function (): void { DB::table('users')->where('external_id', '=', 'NULL')->update([ 'external_id' => null, ]); diff --git a/database/migrations/2018_02_25_160604_define_unique_index_on_users_external_id.php b/database/migrations/old/2018_02_25_160604_define_unique_index_on_users_external_id.php similarity index 75% rename from database/migrations/2018_02_25_160604_define_unique_index_on_users_external_id.php rename to database/migrations/old/2018_02_25_160604_define_unique_index_on_users_external_id.php index 38469af23..c092ae892 100644 --- a/database/migrations/2018_02_25_160604_define_unique_index_on_users_external_id.php +++ b/database/migrations/old/2018_02_25_160604_define_unique_index_on_users_external_id.php @@ -1,8 +1,10 @@ index(['external_id']); }); } @@ -21,7 +23,7 @@ class DefineUniqueIndexOnUsersExternalId extends Migration */ public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->dropIndex(['external_id']); }); } diff --git a/database/migrations/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php b/database/migrations/old/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php similarity index 80% rename from database/migrations/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php rename to database/migrations/old/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php index 00fbd11c2..4d06e2cf3 100644 --- a/database/migrations/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php +++ b/database/migrations/old/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php @@ -1,8 +1,10 @@ unsignedInteger('database_limit')->after('installed')->nullable()->default(0); $table->unsignedInteger('allocation_limit')->after('installed')->nullable()->default(0); }); @@ -22,7 +24,7 @@ class AddDatabaseAndPortLimitColumnsToServersTable extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn(['database_limit', 'allocation_limit']); }); } diff --git a/database/migrations/2018_03_15_124536_add_description_to_nodes.php b/database/migrations/old/2018_03_15_124536_add_description_to_nodes.php similarity index 75% rename from database/migrations/2018_03_15_124536_add_description_to_nodes.php rename to database/migrations/old/2018_03_15_124536_add_description_to_nodes.php index a5c1b7542..bcef48e91 100644 --- a/database/migrations/2018_03_15_124536_add_description_to_nodes.php +++ b/database/migrations/old/2018_03_15_124536_add_description_to_nodes.php @@ -1,8 +1,10 @@ text('description')->after('name'); }); } @@ -21,7 +23,7 @@ class AddDescriptionToNodes extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropColumn('description'); }); } diff --git a/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php b/database/migrations/old/2018_05_04_123826_add_maintenance_to_nodes.php similarity index 76% rename from database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php rename to database/migrations/old/2018_05_04_123826_add_maintenance_to_nodes.php index e85eca8cd..29a9017f0 100644 --- a/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php +++ b/database/migrations/old/2018_05_04_123826_add_maintenance_to_nodes.php @@ -1,8 +1,10 @@ boolean('maintenance_mode')->after('behind_proxy')->default(false); }); } @@ -21,7 +23,7 @@ class AddMaintenanceToNodes extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropColumn('maintenance_mode'); }); } diff --git a/database/migrations/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php b/database/migrations/old/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php similarity index 93% rename from database/migrations/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php rename to database/migrations/old/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php index e7a4089fa..4876894b5 100644 --- a/database/migrations/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php +++ b/database/migrations/old/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php @@ -1,8 +1,10 @@ text('default_value')->change(); }); } @@ -21,7 +23,7 @@ class AllowEggVariablesToHaveLongerValues extends Migration */ public function down(): void { - Schema::table('egg_variables', function (Blueprint $table) { + Schema::table('egg_variables', function (Blueprint $table): void { $table->string('default_value')->change(); }); } diff --git a/database/migrations/2018_09_03_144005_allow_server_variables_to_have_longer_values.php b/database/migrations/old/2018_09_03_144005_allow_server_variables_to_have_longer_values.php similarity index 92% rename from database/migrations/2018_09_03_144005_allow_server_variables_to_have_longer_values.php rename to database/migrations/old/2018_09_03_144005_allow_server_variables_to_have_longer_values.php index a1d581819..f13abff2d 100644 --- a/database/migrations/2018_09_03_144005_allow_server_variables_to_have_longer_values.php +++ b/database/migrations/old/2018_09_03_144005_allow_server_variables_to_have_longer_values.php @@ -1,8 +1,10 @@ text('variable_value')->change(); }); } @@ -21,7 +23,7 @@ class AllowServerVariablesToHaveLongerValues extends Migration */ public function down(): void { - Schema::table('server_variables', function (Blueprint $table) { + Schema::table('server_variables', function (Blueprint $table): void { $table->string('variable_value')->change(); }); } diff --git a/database/migrations/2019_03_02_142328_set_allocation_limit_default_null.php b/database/migrations/old/2019_03_02_142328_set_allocation_limit_default_null.php similarity index 77% rename from database/migrations/2019_03_02_142328_set_allocation_limit_default_null.php rename to database/migrations/old/2019_03_02_142328_set_allocation_limit_default_null.php index 6d43197de..650643ce9 100644 --- a/database/migrations/2019_03_02_142328_set_allocation_limit_default_null.php +++ b/database/migrations/old/2019_03_02_142328_set_allocation_limit_default_null.php @@ -1,8 +1,10 @@ unsignedInteger('allocation_limit')->nullable()->default(null)->change(); }); } @@ -21,7 +23,7 @@ class SetAllocationLimitDefaultNull extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->unsignedInteger('allocation_limit')->nullable()->default(0)->change(); }); } diff --git a/database/migrations/2019_03_02_151321_fix_unique_index_to_account_for_host.php b/database/migrations/old/2019_03_02_151321_fix_unique_index_to_account_for_host.php similarity index 84% rename from database/migrations/2019_03_02_151321_fix_unique_index_to_account_for_host.php rename to database/migrations/old/2019_03_02_151321_fix_unique_index_to_account_for_host.php index de110a06b..087a882eb 100644 --- a/database/migrations/2019_03_02_151321_fix_unique_index_to_account_for_host.php +++ b/database/migrations/old/2019_03_02_151321_fix_unique_index_to_account_for_host.php @@ -1,8 +1,10 @@ dropUnique(['database']); $table->dropUnique(['username']); @@ -25,7 +27,7 @@ class FixUniqueIndexToAccountForHost extends Migration */ public function down(): void { - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->dropForeign(['database_host_id']); $table->dropUnique(['database_host_id', 'database']); diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/old/2020_03_22_163911_merge_permissions_table_into_subusers.php similarity index 82% rename from database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php rename to database/migrations/old/2020_03_22_163911_merge_permissions_table_into_subusers.php index b71189fe0..77afb1670 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/old/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -1,12 +1,13 @@ json('permissions')->nullable()->after('server_id'); }); $cursor = DB::table('permissions') ->select(['subuser_id']) - ->when(DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'mysql', function ($query) { + ->when(DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'mysql', function ($query): void { $query->selectRaw('group_concat(permission) as permissions'); }) - ->when(DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'pgsql', function ($query) { + ->when(DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'pgsql', function ($query): void { $query->selectRaw("string_agg(permission, ',') as permissions"); }) ->from('permissions') ->groupBy(['subuser_id']) ->cursor(); - DB::transaction(function () use (&$cursor) { - $cursor->each(function ($datum) { + DB::transaction(function () use (&$cursor): void { + $cursor->each(function ($datum): void { $updated = Collection::make(explode(',', $datum->permissions)) - ->map(function ($value) { - return self::$permissionsMap[$value] ?? null; - })->filter(function ($value) { - return !is_null($value) && $value !== Permission::ACTION_WEBSOCKET_CONNECT; - }) + ->map(fn ($value) => self::$permissionsMap[$value] ?? null)->filter(fn ($value): bool => ! is_null($value) && $value !== 'websocket.connect') // All subusers get this permission, so make sure it gets pushed into the array. - ->merge([Permission::ACTION_WEBSOCKET_CONNECT]) + ->merge(['websocket.connect']) ->unique() ->values() ->toJson(); @@ -110,20 +107,20 @@ class MergePermissionsTableIntoSubusers extends Migration $values = []; foreach (json_decode($datum->permissions, true) as $permission) { $v = $flipped[$permission] ?? null; - if (!empty($v)) { + if (! empty($v)) { $values[] = $datum->id; $values[] = $v; } } - if (!empty($values)) { - $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); + if ($values !== []) { + $string = 'VALUES '.implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); - DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); + DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) '.$string, $values); } } - Schema::table('subusers', function (Blueprint $table) { + Schema::table('subusers', function (Blueprint $table): void { $table->dropColumn('permissions'); }); } diff --git a/database/migrations/2020_03_22_164814_drop_permissions_table.php b/database/migrations/old/2020_03_22_164814_drop_permissions_table.php similarity index 95% rename from database/migrations/2020_03_22_164814_drop_permissions_table.php rename to database/migrations/old/2020_03_22_164814_drop_permissions_table.php index 030a8a6ba..ba5417721 100644 --- a/database/migrations/2020_03_22_164814_drop_permissions_table.php +++ b/database/migrations/old/2020_03_22_164814_drop_permissions_table.php @@ -1,8 +1,10 @@ increments('id'); $table->unsignedInteger('subuser_id'); $table->string('permission'); diff --git a/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php b/database/migrations/old/2020_04_03_203624_add_threads_column_to_servers_table.php similarity index 75% rename from database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php rename to database/migrations/old/2020_04_03_203624_add_threads_column_to_servers_table.php index d4c08c5e5..61be2def2 100644 --- a/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php +++ b/database/migrations/old/2020_04_03_203624_add_threads_column_to_servers_table.php @@ -1,8 +1,10 @@ string('threads')->nullable()->after('cpu'); }); } @@ -21,7 +23,7 @@ class AddThreadsColumnToServersTable extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('threads'); }); } diff --git a/database/migrations/2020_04_03_230614_create_backups_table.php b/database/migrations/old/2020_04_03_230614_create_backups_table.php similarity index 89% rename from database/migrations/2020_04_03_230614_create_backups_table.php rename to database/migrations/old/2020_04_03_230614_create_backups_table.php index a8c28d96d..a9b276c28 100644 --- a/database/migrations/2020_04_03_230614_create_backups_table.php +++ b/database/migrations/old/2020_04_03_230614_create_backups_table.php @@ -1,9 +1,11 @@ TABLE_NAME, $result->TABLE_NAME . '_plugin_bak'); + Schema::rename($result->TABLE_NAME, $result->TABLE_NAME.'_plugin_bak'); } - Schema::create('backups', function (Blueprint $table) { + Schema::create('backups', function (Blueprint $table): void { $table->bigIncrements('id'); $table->unsignedInteger('server_id'); $table->char('uuid', 36); diff --git a/database/migrations/2020_04_04_131016_add_table_server_transfers.php b/database/migrations/old/2020_04_04_131016_add_table_server_transfers.php similarity index 97% rename from database/migrations/2020_04_04_131016_add_table_server_transfers.php rename to database/migrations/old/2020_04_04_131016_add_table_server_transfers.php index c9f3e849a..c6de5b696 100644 --- a/database/migrations/2020_04_04_131016_add_table_server_transfers.php +++ b/database/migrations/old/2020_04_04_131016_add_table_server_transfers.php @@ -1,8 +1,10 @@ increments('id'); $table->integer('server_id')->unsigned(); $table->boolean('successful')->unsigned()->default(0); diff --git a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php b/database/migrations/old/2020_04_10_141024_store_node_tokens_as_encrypted_value.php similarity index 73% rename from database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php rename to database/migrations/old/2020_04_10_141024_store_node_tokens_as_encrypted_value.php index 2e750dfa2..fcb625866 100644 --- a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php +++ b/database/migrations/old/2020_04_10_141024_store_node_tokens_as_encrypted_value.php @@ -1,12 +1,14 @@ dropUnique(['daemonSecret']); }); - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->char('uuid', 36)->after('id'); $table->char('daemon_token_id', 16)->after('upload_size'); $table->renameColumn('`daemonSecret`', 'daemon_token'); }); - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->text('daemon_token')->change(); }); @@ -38,13 +40,13 @@ class StoreNodeTokensAsEncryptedValue extends Migration foreach (DB::select('SELECT id, daemon_token FROM nodes') as $datum) { DB::update('UPDATE nodes SET uuid = ?, daemon_token_id = ?, daemon_token = ? WHERE id = ?', [ Uuid::uuid4()->toString(), - substr($datum->daemon_token, 0, 16), - $encrypter->encrypt(substr($datum->daemon_token, 16)), + mb_substr($datum->daemon_token, 0, 16), + $encrypter->encrypt(mb_substr($datum->daemon_token, 16)), $datum->id, ]); } - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->unique(['uuid']); $table->unique(['daemon_token_id']); }); @@ -55,29 +57,29 @@ class StoreNodeTokensAsEncryptedValue extends Migration */ public function down(): void { - DB::transaction(function () { + DB::transaction(function (): void { /** @var Encrypter $encrypter */ $encrypter = Container::getInstance()->make(Encrypter::class); foreach (DB::select('SELECT id, daemon_token_id, daemon_token FROM nodes') as $datum) { DB::update('UPDATE nodes SET daemon_token = ? WHERE id = ?', [ - $datum->daemon_token_id . $encrypter->decrypt($datum->daemon_token), + $datum->daemon_token_id.$encrypter->decrypt($datum->daemon_token), $datum->id, ]); } }); - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropUnique(['uuid']); $table->dropUnique(['daemon_token_id']); }); - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->dropColumn(['uuid', 'daemon_token_id']); $table->renameColumn('daemon_token', 'daemonSecret'); }); - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->string('daemonSecret', 36)->change(); $table->unique(['daemonSecret']); }); diff --git a/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php b/database/migrations/old/2020_04_17_203438_allow_nullable_descriptions.php similarity index 63% rename from database/migrations/2020_04_17_203438_allow_nullable_descriptions.php rename to database/migrations/old/2020_04_17_203438_allow_nullable_descriptions.php index 8c2c149cf..056950f8c 100644 --- a/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php +++ b/database/migrations/old/2020_04_17_203438_allow_nullable_descriptions.php @@ -1,8 +1,10 @@ text('description')->nullable()->change(); }); - Schema::table('nests', function (Blueprint $table) { + Schema::table('nests', function (Blueprint $table): void { $table->text('description')->nullable()->change(); }); - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->text('description')->nullable()->change(); }); - Schema::table('locations', function (Blueprint $table) { + Schema::table('locations', function (Blueprint $table): void { $table->text('long')->nullable()->change(); }); } @@ -33,19 +35,19 @@ class AllowNullableDescriptions extends Migration */ public function down(): void { - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->text('description')->nullable(false)->change(); }); - Schema::table('nests', function (Blueprint $table) { + Schema::table('nests', function (Blueprint $table): void { $table->text('description')->nullable(false)->change(); }); - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->text('description')->nullable(false)->change(); }); - Schema::table('locations', function (Blueprint $table) { + Schema::table('locations', function (Blueprint $table): void { $table->text('long')->nullable(false)->change(); }); } diff --git a/database/migrations/2020_04_22_055500_add_max_connections_column.php b/database/migrations/old/2020_04_22_055500_add_max_connections_column.php similarity index 76% rename from database/migrations/2020_04_22_055500_add_max_connections_column.php rename to database/migrations/old/2020_04_22_055500_add_max_connections_column.php index 57604117c..f29ecc66a 100644 --- a/database/migrations/2020_04_22_055500_add_max_connections_column.php +++ b/database/migrations/old/2020_04_22_055500_add_max_connections_column.php @@ -1,8 +1,10 @@ integer('max_connections')->nullable()->default(0)->after('password'); }); } @@ -21,7 +23,7 @@ class AddMaxConnectionsColumn extends Migration */ public function down(): void { - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->dropColumn('max_connections'); }); } diff --git a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php b/database/migrations/old/2020_04_26_111208_add_backup_limit_to_servers.php similarity index 82% rename from database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php rename to database/migrations/old/2020_04_26_111208_add_backup_limit_to_servers.php index af1b72e64..2aec7d3d0 100644 --- a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php +++ b/database/migrations/old/2020_04_26_111208_add_backup_limit_to_servers.php @@ -1,9 +1,11 @@ unsignedInteger('backup_limit')->default(0)->change(); }); } else { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->unsignedInteger('backup_limit')->default(0)->after('database_limit'); }); } @@ -36,7 +38,7 @@ class AddBackupLimitToServers extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('backup_limit'); }); } diff --git a/database/migrations/2020_05_20_234655_add_mounts_table.php b/database/migrations/old/2020_05_20_234655_add_mounts_table.php similarity index 87% rename from database/migrations/2020_05_20_234655_add_mounts_table.php rename to database/migrations/old/2020_05_20_234655_add_mounts_table.php index db3b409d8..066a00265 100644 --- a/database/migrations/2020_05_20_234655_add_mounts_table.php +++ b/database/migrations/old/2020_05_20_234655_add_mounts_table.php @@ -1,8 +1,10 @@ increments('id')->unique(); $table->char('uuid', 36)->unique(); $table->string('name')->unique(); @@ -22,14 +24,14 @@ class AddMountsTable extends Migration $table->tinyInteger('user_mountable')->unsigned(); }); - Schema::create('egg_mount', function (Blueprint $table) { + Schema::create('egg_mount', function (Blueprint $table): void { $table->integer('egg_id'); $table->integer('mount_id'); $table->unique(['egg_id', 'mount_id']); }); - Schema::create('mount_node', function (Blueprint $table) { + Schema::create('mount_node', function (Blueprint $table): void { $table->integer('node_id'); $table->integer('mount_id'); diff --git a/database/migrations/2020_05_21_192756_add_mount_server_table.php b/database/migrations/old/2020_05_21_192756_add_mount_server_table.php similarity index 94% rename from database/migrations/2020_05_21_192756_add_mount_server_table.php rename to database/migrations/old/2020_05_21_192756_add_mount_server_table.php index 7d8e9438b..01693b98f 100644 --- a/database/migrations/2020_05_21_192756_add_mount_server_table.php +++ b/database/migrations/old/2020_05_21_192756_add_mount_server_table.php @@ -1,8 +1,10 @@ integer('server_id'); $table->integer('mount_id'); diff --git a/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php b/database/migrations/old/2020_07_02_213612_create_user_recovery_tokens_table.php similarity index 94% rename from database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php rename to database/migrations/old/2020_07_02_213612_create_user_recovery_tokens_table.php index 11a6f513c..4b3812763 100644 --- a/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php +++ b/database/migrations/old/2020_07_02_213612_create_user_recovery_tokens_table.php @@ -1,8 +1,10 @@ id(); $table->unsignedInteger('user_id'); $table->string('token'); diff --git a/database/migrations/2020_07_09_201845_add_notes_column_for_allocations.php b/database/migrations/old/2020_07_09_201845_add_notes_column_for_allocations.php similarity index 93% rename from database/migrations/2020_07_09_201845_add_notes_column_for_allocations.php rename to database/migrations/old/2020_07_09_201845_add_notes_column_for_allocations.php index a93b48053..d192c88e5 100644 --- a/database/migrations/2020_07_09_201845_add_notes_column_for_allocations.php +++ b/database/migrations/old/2020_07_09_201845_add_notes_column_for_allocations.php @@ -1,8 +1,10 @@ string('notes')->nullable()->after('server_id'); }); } @@ -21,7 +23,7 @@ class AddNotesColumnForAllocations extends Migration */ public function down(): void { - Schema::table('allocations', function (Blueprint $table) { + Schema::table('allocations', function (Blueprint $table): void { $table->dropColumn('notes'); }); } diff --git a/database/migrations/2020_08_20_205533_add_backup_state_column_to_backups.php b/database/migrations/old/2020_08_20_205533_add_backup_state_column_to_backups.php similarity index 76% rename from database/migrations/2020_08_20_205533_add_backup_state_column_to_backups.php rename to database/migrations/old/2020_08_20_205533_add_backup_state_column_to_backups.php index 4ac99fedd..d0180454b 100644 --- a/database/migrations/2020_08_20_205533_add_backup_state_column_to_backups.php +++ b/database/migrations/old/2020_08_20_205533_add_backup_state_column_to_backups.php @@ -1,8 +1,10 @@ boolean('is_successful')->after('uuid')->default(true); }); } @@ -21,7 +23,7 @@ class AddBackupStateColumnToBackups extends Migration */ public function down(): void { - Schema::table('backups', function (Blueprint $table) { + Schema::table('backups', function (Blueprint $table): void { $table->dropColumn('is_successful'); }); } diff --git a/database/migrations/2020_08_22_132500_update_bytes_to_unsigned_bigint.php b/database/migrations/old/2020_08_22_132500_update_bytes_to_unsigned_bigint.php similarity index 76% rename from database/migrations/2020_08_22_132500_update_bytes_to_unsigned_bigint.php rename to database/migrations/old/2020_08_22_132500_update_bytes_to_unsigned_bigint.php index 5c4adca1a..ca875b996 100644 --- a/database/migrations/2020_08_22_132500_update_bytes_to_unsigned_bigint.php +++ b/database/migrations/old/2020_08_22_132500_update_bytes_to_unsigned_bigint.php @@ -1,8 +1,10 @@ unsignedBigInteger('bytes')->default(0)->change(); }); } @@ -21,7 +23,7 @@ class UpdateBytesToUnsignedBigint extends Migration */ public function down(): void { - Schema::table('backups', function (Blueprint $table) { + Schema::table('backups', function (Blueprint $table): void { $table->integer('bytes')->default(0)->change(); }); } diff --git a/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php b/database/migrations/old/2020_08_23_175331_modify_checksums_column_for_backups.php similarity index 63% rename from database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php rename to database/migrations/old/2020_08_23_175331_modify_checksums_column_for_backups.php index 763b20457..71ff46d41 100644 --- a/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php +++ b/database/migrations/old/2020_08_23_175331_modify_checksums_column_for_backups.php @@ -1,9 +1,11 @@ renameColumn('sha256_hash', 'checksum'); }); - Schema::table('backups', function (Blueprint $table) { - DB::update('UPDATE backups SET checksum = CONCAT(\'sha256:\', checksum)'); + Schema::table('backups', function (Blueprint $table): void { + DB::update("UPDATE backups SET checksum = CONCAT('sha256:', checksum)"); }); } @@ -26,11 +28,11 @@ class ModifyChecksumsColumnForBackups extends Migration */ public function down(): void { - Schema::table('backups', function (Blueprint $table) { + Schema::table('backups', function (Blueprint $table): void { $table->renameColumn('checksum', 'sha256_hash'); }); - Schema::table('backups', function (Blueprint $table) { + Schema::table('backups', function (Blueprint $table): void { DB::update('UPDATE backups SET sha256_hash = SUBSTRING(sha256_hash, 8)'); }); } diff --git a/database/migrations/2020_09_13_110007_drop_packs_from_servers.php b/database/migrations/old/2020_09_13_110007_drop_packs_from_servers.php similarity index 79% rename from database/migrations/2020_09_13_110007_drop_packs_from_servers.php rename to database/migrations/old/2020_09_13_110007_drop_packs_from_servers.php index 53cba54f5..b69093d36 100644 --- a/database/migrations/2020_09_13_110007_drop_packs_from_servers.php +++ b/database/migrations/old/2020_09_13_110007_drop_packs_from_servers.php @@ -1,8 +1,10 @@ dropForeign(['pack_id']); $table->dropColumn('pack_id'); }); @@ -22,7 +24,7 @@ class DropPacksFromServers extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->unsignedInteger('pack_id')->after('egg_id')->nullable(); $table->foreign('pack_id')->references('id')->on('packs'); }); diff --git a/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php b/database/migrations/old/2020_09_13_110021_drop_packs_from_api_key_permissions.php similarity index 75% rename from database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php rename to database/migrations/old/2020_09_13_110021_drop_packs_from_api_key_permissions.php index 7c051db2c..21842fa7b 100644 --- a/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php +++ b/database/migrations/old/2020_09_13_110021_drop_packs_from_api_key_permissions.php @@ -1,8 +1,10 @@ dropColumn('r_packs'); }); } @@ -21,7 +23,7 @@ class DropPacksFromApiKeyPermissions extends Migration */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->unsignedTinyInteger('r_packs')->default(0); }); } diff --git a/database/migrations/2020_09_13_110047_drop_packs_table.php b/database/migrations/old/2020_09_13_110047_drop_packs_table.php similarity index 85% rename from database/migrations/2020_09_13_110047_drop_packs_table.php rename to database/migrations/old/2020_09_13_110047_drop_packs_table.php index 58194b8fa..2729e5b55 100644 --- a/database/migrations/2020_09_13_110047_drop_packs_table.php +++ b/database/migrations/old/2020_09_13_110047_drop_packs_table.php @@ -1,8 +1,10 @@ increments('id'); $table->unsignedInteger('egg_id'); $table->char('uuid', 36)->unique(); @@ -32,7 +34,7 @@ class DropPacksTable extends Migration $table->timestamps(); }); - Schema::table('packs', function (Blueprint $table) { + Schema::table('packs', function (Blueprint $table): void { $table->foreign('egg_id')->references('id')->on('eggs')->cascadeOnDelete(); }); } diff --git a/database/migrations/2020_09_13_113503_drop_daemon_key_table.php b/database/migrations/old/2020_09_13_113503_drop_daemon_key_table.php similarity index 95% rename from database/migrations/2020_09_13_113503_drop_daemon_key_table.php rename to database/migrations/old/2020_09_13_113503_drop_daemon_key_table.php index 274f9fd97..c70581d07 100644 --- a/database/migrations/2020_09_13_113503_drop_daemon_key_table.php +++ b/database/migrations/old/2020_09_13_113503_drop_daemon_key_table.php @@ -1,8 +1,10 @@ increments('id'); $table->unsignedInteger('server_id'); $table->unsignedInteger('user_id'); @@ -28,7 +30,7 @@ class DropDaemonKeyTable extends Migration $table->timestamps(); }); - Schema::table('daemon_keys', function (Blueprint $table) { + Schema::table('daemon_keys', function (Blueprint $table): void { $table->foreign('server_id')->references('id')->on('servers')->cascadeOnDelete(); $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); }); diff --git a/database/migrations/2020_10_10_165437_change_unique_database_name_to_account_for_server.php b/database/migrations/old/2020_10_10_165437_change_unique_database_name_to_account_for_server.php similarity index 69% rename from database/migrations/2020_10_10_165437_change_unique_database_name_to_account_for_server.php rename to database/migrations/old/2020_10_10_165437_change_unique_database_name_to_account_for_server.php index 6a277e449..6312744ee 100644 --- a/database/migrations/2020_10_10_165437_change_unique_database_name_to_account_for_server.php +++ b/database/migrations/old/2020_10_10_165437_change_unique_database_name_to_account_for_server.php @@ -1,8 +1,10 @@ dropUnique(['database_host_id', 'database']); }); - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->unique(['database_host_id', 'server_id', 'database']); }); } @@ -25,11 +27,11 @@ class ChangeUniqueDatabaseNameToAccountForServer extends Migration */ public function down(): void { - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->dropUnique(['database_host_id', 'server_id', 'database']); }); - Schema::table('databases', function (Blueprint $table) { + Schema::table('databases', function (Blueprint $table): void { $table->unique(['database_host_id', 'database']); }); } diff --git a/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php b/database/migrations/old/2020_10_26_194904_remove_nullable_from_schedule_name_field.php similarity index 79% rename from database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php rename to database/migrations/old/2020_10_26_194904_remove_nullable_from_schedule_name_field.php index d0b3118e5..b14ffb41a 100644 --- a/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php +++ b/database/migrations/old/2020_10_26_194904_remove_nullable_from_schedule_name_field.php @@ -1,9 +1,11 @@ string('name')->nullable(false)->change(); }); } @@ -24,7 +26,7 @@ class RemoveNullableFromScheduleNameField extends Migration */ public function down(): void { - Schema::table('schedules', function (Blueprint $table) { + Schema::table('schedules', function (Blueprint $table): void { $table->string('name')->nullable()->change(); }); } diff --git a/database/migrations/2020_11_02_201014_add_features_column_to_eggs.php b/database/migrations/old/2020_11_02_201014_add_features_column_to_eggs.php similarity index 76% rename from database/migrations/2020_11_02_201014_add_features_column_to_eggs.php rename to database/migrations/old/2020_11_02_201014_add_features_column_to_eggs.php index e134fe9a6..249f51a48 100644 --- a/database/migrations/2020_11_02_201014_add_features_column_to_eggs.php +++ b/database/migrations/old/2020_11_02_201014_add_features_column_to_eggs.php @@ -1,8 +1,10 @@ json('features')->after('description')->nullable(); }); } @@ -21,7 +23,7 @@ class AddFeaturesColumnToEggs extends Migration */ public function down(): void { - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->dropColumn('features'); }); } diff --git a/database/migrations/2020_12_12_102435_support_multiple_docker_images_and_updates.php b/database/migrations/old/2020_12_12_102435_support_multiple_docker_images_and_updates.php similarity index 85% rename from database/migrations/2020_12_12_102435_support_multiple_docker_images_and_updates.php rename to database/migrations/old/2020_12_12_102435_support_multiple_docker_images_and_updates.php index c7d2cff7f..6dcb5e818 100644 --- a/database/migrations/2020_12_12_102435_support_multiple_docker_images_and_updates.php +++ b/database/migrations/old/2020_12_12_102435_support_multiple_docker_images_and_updates.php @@ -1,9 +1,11 @@ json('docker_images')->after('docker_image')->nullable(); $table->text('update_url')->after('docker_images')->nullable(); }); @@ -26,7 +28,7 @@ class SupportMultipleDockerImagesAndUpdates extends Migration break; } - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->dropColumn('docker_image'); }); } @@ -36,7 +38,7 @@ class SupportMultipleDockerImagesAndUpdates extends Migration */ public function down(): void { - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->text('docker_image')->after('docker_images'); }); @@ -50,7 +52,7 @@ class SupportMultipleDockerImagesAndUpdates extends Migration break; } - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->dropColumn('docker_images'); $table->dropColumn('update_url'); }); diff --git a/database/migrations/2020_12_14_013707_make_successful_nullable_in_server_transfers.php b/database/migrations/old/2020_12_14_013707_make_successful_nullable_in_server_transfers.php similarity index 92% rename from database/migrations/2020_12_14_013707_make_successful_nullable_in_server_transfers.php rename to database/migrations/old/2020_12_14_013707_make_successful_nullable_in_server_transfers.php index 4c28b6c2b..40c10f7b2 100644 --- a/database/migrations/2020_12_14_013707_make_successful_nullable_in_server_transfers.php +++ b/database/migrations/old/2020_12_14_013707_make_successful_nullable_in_server_transfers.php @@ -1,8 +1,10 @@ boolean('successful')->nullable()->default(null)->change(); }); } @@ -21,7 +23,7 @@ class MakeSuccessfulNullableInServerTransfers extends Migration */ public function down(): void { - Schema::table('server_transfers', function (Blueprint $table) { + Schema::table('server_transfers', function (Blueprint $table): void { $table->boolean('successful')->default(0)->change(); }); } diff --git a/database/migrations/2020_12_17_014330_add_archived_field_to_server_transfers_table.php b/database/migrations/old/2020_12_17_014330_add_archived_field_to_server_transfers_table.php similarity index 94% rename from database/migrations/2020_12_17_014330_add_archived_field_to_server_transfers_table.php rename to database/migrations/old/2020_12_17_014330_add_archived_field_to_server_transfers_table.php index bc5d3356d..f7f7fdb5e 100644 --- a/database/migrations/2020_12_17_014330_add_archived_field_to_server_transfers_table.php +++ b/database/migrations/old/2020_12_17_014330_add_archived_field_to_server_transfers_table.php @@ -1,9 +1,11 @@ boolean('archived')->default(0)->after('new_additional_allocations'); }); @@ -25,7 +27,7 @@ class AddArchivedFieldToServerTransfersTable extends Migration */ public function down(): void { - Schema::table('server_transfers', function (Blueprint $table) { + Schema::table('server_transfers', function (Blueprint $table): void { $table->dropColumn('archived'); }); } diff --git a/database/migrations/2020_12_24_092449_make_allocation_fields_json.php b/database/migrations/old/2020_12_24_092449_make_allocation_fields_json.php similarity index 86% rename from database/migrations/2020_12_24_092449_make_allocation_fields_json.php rename to database/migrations/old/2020_12_24_092449_make_allocation_fields_json.php index bceec9de7..088dcd6a1 100644 --- a/database/migrations/2020_12_24_092449_make_allocation_fields_json.php +++ b/database/migrations/old/2020_12_24_092449_make_allocation_fields_json.php @@ -1,19 +1,19 @@ json('old_additional_allocations')->nullable()->change(); $table->json('new_additional_allocations')->nullable()->change(); }); @@ -21,12 +21,10 @@ class MakeAllocationFieldsJson extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { - Schema::table('server_transfers', function (Blueprint $table) { + Schema::table('server_transfers', function (Blueprint $table): void { $table->string('old_additional_allocations')->nullable()->change(); $table->string('new_additional_allocations')->nullable()->change(); }); diff --git a/database/migrations/2020_12_26_184914_add_upload_id_column_to_backups_table.php b/database/migrations/old/2020_12_26_184914_add_upload_id_column_to_backups_table.php similarity index 75% rename from database/migrations/2020_12_26_184914_add_upload_id_column_to_backups_table.php rename to database/migrations/old/2020_12_26_184914_add_upload_id_column_to_backups_table.php index 771e06ab1..0b51df3ac 100644 --- a/database/migrations/2020_12_26_184914_add_upload_id_column_to_backups_table.php +++ b/database/migrations/old/2020_12_26_184914_add_upload_id_column_to_backups_table.php @@ -1,8 +1,10 @@ text('upload_id')->nullable()->after('uuid'); }); } @@ -21,7 +23,7 @@ class AddUploadIdColumnToBackupsTable extends Migration */ public function down(): void { - Schema::table('backups', function (Blueprint $table) { + Schema::table('backups', function (Blueprint $table): void { $table->dropColumn('upload_id'); }); } diff --git a/database/migrations/2021_01_10_153937_add_file_denylist_to_egg_configs.php b/database/migrations/old/2021_01_10_153937_add_file_denylist_to_egg_configs.php similarity index 76% rename from database/migrations/2021_01_10_153937_add_file_denylist_to_egg_configs.php rename to database/migrations/old/2021_01_10_153937_add_file_denylist_to_egg_configs.php index 4a956625e..8c9c4fa9e 100644 --- a/database/migrations/2021_01_10_153937_add_file_denylist_to_egg_configs.php +++ b/database/migrations/old/2021_01_10_153937_add_file_denylist_to_egg_configs.php @@ -1,8 +1,10 @@ text('file_denylist')->after('docker_images'); }); } @@ -21,7 +23,7 @@ class AddFileDenylistToEggConfigs extends Migration */ public function down(): void { - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->dropColumn('file_denylist'); }); } diff --git a/database/migrations/2021_01_13_013420_add_cron_month.php b/database/migrations/old/2021_01_13_013420_add_cron_month.php similarity index 74% rename from database/migrations/2021_01_13_013420_add_cron_month.php rename to database/migrations/old/2021_01_13_013420_add_cron_month.php index da0bf8841..cffdf765d 100644 --- a/database/migrations/2021_01_13_013420_add_cron_month.php +++ b/database/migrations/old/2021_01_13_013420_add_cron_month.php @@ -1,8 +1,10 @@ string('cron_month')->after('cron_day_of_week'); }); } @@ -21,7 +23,7 @@ class AddCronMonth extends Migration */ public function down(): void { - Schema::table('schedules', function (Blueprint $table) { + Schema::table('schedules', function (Blueprint $table): void { $table->dropColumn('cron_month'); }); } diff --git a/database/migrations/2021_01_17_102401_create_audit_logs_table.php b/database/migrations/old/2021_01_17_102401_create_audit_logs_table.php similarity index 96% rename from database/migrations/2021_01_17_102401_create_audit_logs_table.php rename to database/migrations/old/2021_01_17_102401_create_audit_logs_table.php index d0fddf801..372ef53e5 100644 --- a/database/migrations/2021_01_17_102401_create_audit_logs_table.php +++ b/database/migrations/old/2021_01_17_102401_create_audit_logs_table.php @@ -1,8 +1,10 @@ id(); $table->char('uuid', 36); $table->boolean('is_system')->default(false); diff --git a/database/migrations/2021_01_17_152623_add_generic_server_status_column.php b/database/migrations/old/2021_01_17_152623_add_generic_server_status_column.php similarity index 81% rename from database/migrations/2021_01_17_152623_add_generic_server_status_column.php rename to database/migrations/old/2021_01_17_152623_add_generic_server_status_column.php index f8c9dec2c..77f9b008d 100644 --- a/database/migrations/2021_01_17_152623_add_generic_server_status_column.php +++ b/database/migrations/old/2021_01_17_152623_add_generic_server_status_column.php @@ -1,9 +1,11 @@ string('status')->nullable()->after('description'); }); @@ -20,7 +22,7 @@ class AddGenericServerStatusColumn extends Migration DB::table('servers')->where('installed', 1)->update(['status' => 'installing']); DB::table('servers')->where('installed', 1)->update(['status' => 'install_failed']); - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('suspended'); $table->dropColumn('installed'); }); @@ -31,7 +33,7 @@ class AddGenericServerStatusColumn extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->unsignedTinyInteger('suspended')->default(0); $table->unsignedTinyInteger('installed')->default(0); }); @@ -40,7 +42,7 @@ class AddGenericServerStatusColumn extends Migration DB::table('servers')->whereNull('status')->update(['installed' => 1]); DB::table('servers')->where('status', 'install_failed')->update(['installed' => 2]); - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('status'); }); } diff --git a/database/migrations/2021_01_26_210502_update_file_denylist_to_json.php b/database/migrations/old/2021_01_26_210502_update_file_denylist_to_json.php similarity index 69% rename from database/migrations/2021_01_26_210502_update_file_denylist_to_json.php rename to database/migrations/old/2021_01_26_210502_update_file_denylist_to_json.php index 7c2c5fa06..c2e5530c3 100644 --- a/database/migrations/2021_01_26_210502_update_file_denylist_to_json.php +++ b/database/migrations/old/2021_01_26_210502_update_file_denylist_to_json.php @@ -1,8 +1,10 @@ dropColumn('file_denylist'); }); - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->json('file_denylist')->nullable()->after('docker_images'); }); } @@ -25,11 +27,11 @@ class UpdateFileDenylistToJson extends Migration */ public function down(): void { - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->dropColumn('file_denylist'); }); - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->text('file_denylist')->after('docker_images'); }); } diff --git a/database/migrations/2021_02_23_205021_add_index_for_server_and_action.php b/database/migrations/old/2021_02_23_205021_add_index_for_server_and_action.php similarity index 84% rename from database/migrations/2021_02_23_205021_add_index_for_server_and_action.php rename to database/migrations/old/2021_02_23_205021_add_index_for_server_and_action.php index 1fd63559c..6a37453ba 100644 --- a/database/migrations/2021_02_23_205021_add_index_for_server_and_action.php +++ b/database/migrations/old/2021_02_23_205021_add_index_for_server_and_action.php @@ -1,8 +1,10 @@ dropIndex(['action', 'server_id']); }); } diff --git a/database/migrations/2021_02_23_212657_make_sftp_port_unsigned_int.php b/database/migrations/old/2021_02_23_212657_make_sftp_port_unsigned_int.php similarity index 77% rename from database/migrations/2021_02_23_212657_make_sftp_port_unsigned_int.php rename to database/migrations/old/2021_02_23_212657_make_sftp_port_unsigned_int.php index b9196a0ae..dd240f7f2 100644 --- a/database/migrations/2021_02_23_212657_make_sftp_port_unsigned_int.php +++ b/database/migrations/old/2021_02_23_212657_make_sftp_port_unsigned_int.php @@ -1,8 +1,10 @@ unsignedSmallInteger('daemonSFTP')->default(2022)->change(); }); } @@ -21,7 +23,7 @@ class MakeSftpPortUnsignedInt extends Migration */ public function down(): void { - Schema::table('nodes', function (Blueprint $table) { + Schema::table('nodes', function (Blueprint $table): void { $table->smallInteger('daemonSFTP')->default(2022)->change(); }); } diff --git a/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php b/database/migrations/old/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php similarity index 94% rename from database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php rename to database/migrations/old/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php index 61abdbd6c..ac979e6b9 100644 --- a/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php +++ b/database/migrations/old/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php @@ -1,7 +1,9 @@ unsignedTinyInteger('continue_on_failure')->after('is_queued')->default(0); }); } @@ -21,7 +23,7 @@ class AddContinueOnFailureOptionToTasks extends Migration */ public function down(): void { - Schema::table('tasks', function (Blueprint $table) { + Schema::table('tasks', function (Blueprint $table): void { $table->dropColumn('continue_on_failure'); }); } diff --git a/database/migrations/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php b/database/migrations/old/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php similarity index 77% rename from database/migrations/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php rename to database/migrations/old/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php index a0143fdd6..74ddcfb89 100644 --- a/database/migrations/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php +++ b/database/migrations/old/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php @@ -1,8 +1,10 @@ unsignedTinyInteger('only_when_online')->after('is_processing')->default(0); }); } @@ -21,7 +23,7 @@ class AddOnlyRunWhenServerOnlineOptionToSchedules extends Migration */ public function down(): void { - Schema::table('schedules', function (Blueprint $table) { + Schema::table('schedules', function (Blueprint $table): void { $table->dropColumn('only_when_online'); }); } diff --git a/database/migrations/2021_05_03_201016_add_support_for_locking_a_backup.php b/database/migrations/old/2021_05_03_201016_add_support_for_locking_a_backup.php similarity index 76% rename from database/migrations/2021_05_03_201016_add_support_for_locking_a_backup.php rename to database/migrations/old/2021_05_03_201016_add_support_for_locking_a_backup.php index 3296e3e8f..705261ba5 100644 --- a/database/migrations/2021_05_03_201016_add_support_for_locking_a_backup.php +++ b/database/migrations/old/2021_05_03_201016_add_support_for_locking_a_backup.php @@ -1,8 +1,10 @@ unsignedTinyInteger('is_locked')->after('is_successful')->default(0); }); } @@ -21,7 +23,7 @@ class AddSupportForLockingABackup extends Migration */ public function down(): void { - Schema::table('backups', function (Blueprint $table) { + Schema::table('backups', function (Blueprint $table): void { $table->dropColumn('is_locked'); }); } diff --git a/database/migrations/2021_07_12_013420_remove_userinteraction.php b/database/migrations/old/2021_07_12_013420_remove_userinteraction.php similarity index 92% rename from database/migrations/2021_07_12_013420_remove_userinteraction.php rename to database/migrations/old/2021_07_12_013420_remove_userinteraction.php index 33b4d5d3b..cf563726d 100644 --- a/database/migrations/2021_07_12_013420_remove_userinteraction.php +++ b/database/migrations/old/2021_07_12_013420_remove_userinteraction.php @@ -1,7 +1,9 @@ update([ - 'config_startup' => DB::raw('config_startup::jsonb - \'userInteraction\''), + 'config_startup' => DB::raw("config_startup::jsonb - 'userInteraction'"), ]); break; } diff --git a/database/migrations/2021_07_17_211512_create_user_ssh_keys_table.php b/database/migrations/old/2021_07_17_211512_create_user_ssh_keys_table.php similarity index 95% rename from database/migrations/2021_07_17_211512_create_user_ssh_keys_table.php rename to database/migrations/old/2021_07_17_211512_create_user_ssh_keys_table.php index a33bb4d31..8986a33f9 100644 --- a/database/migrations/2021_07_17_211512_create_user_ssh_keys_table.php +++ b/database/migrations/old/2021_07_17_211512_create_user_ssh_keys_table.php @@ -1,8 +1,10 @@ increments('id'); $table->unsignedInteger('user_id'); $table->string('name'); diff --git a/database/migrations/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php b/database/migrations/old/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php similarity index 84% rename from database/migrations/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php rename to database/migrations/old/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php index b9284eb0c..c6939e947 100644 --- a/database/migrations/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php +++ b/database/migrations/old/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php @@ -1,9 +1,11 @@ boolean('is_successful')->after('uuid')->default(false)->change(); }); @@ -27,7 +29,7 @@ class ChangeSuccessfulFieldToDefaultToFalseOnBackupsTable extends Migration */ public function down(): void { - Schema::table('backups', function (Blueprint $table) { + Schema::table('backups', function (Blueprint $table): void { $table->boolean('is_successful')->after('uuid')->default(true)->change(); }); } diff --git a/database/migrations/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php b/database/migrations/old/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php similarity index 86% rename from database/migrations/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php rename to database/migrations/old/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php index 5210f60d2..42b7cee61 100644 --- a/database/migrations/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php +++ b/database/migrations/old/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php @@ -1,9 +1,11 @@ unsignedInteger('node_id')->change(); $table->unsignedInteger('mount_id')->change(); }); @@ -29,7 +31,7 @@ class AddForeignKeysToMountNodeTable extends Migration ->orWhereNotIn('mount_id', $mounts) ->delete(); - Schema::table('mount_node', function (Blueprint $table) { + Schema::table('mount_node', function (Blueprint $table): void { $table->foreign('node_id') ->references('id') ->on('nodes') @@ -47,7 +49,7 @@ class AddForeignKeysToMountNodeTable extends Migration */ public function down(): void { - Schema::table('mount_node', function (Blueprint $table) { + Schema::table('mount_node', function (Blueprint $table): void { $table->dropForeign(['node_id']); $table->dropForeign(['mount_id']); }); diff --git a/database/migrations/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php b/database/migrations/old/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php similarity index 96% rename from database/migrations/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php rename to database/migrations/old/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php index f564ec491..da0abb3e1 100644 --- a/database/migrations/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php +++ b/database/migrations/old/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php @@ -1,8 +1,10 @@ unsignedInteger('server_id')->change(); $table->unsignedInteger('mount_id')->change(); }); @@ -28,7 +30,7 @@ class AddForeignKeysToMountServerTable extends Migration ->orWhereNotIn('mount_id', $mounts) ->delete(); - Schema::table('mount_server', function (Blueprint $table) { + Schema::table('mount_server', function (Blueprint $table): void { $table->foreign('server_id') ->references('id') ->on('servers') @@ -46,7 +48,7 @@ class AddForeignKeysToMountServerTable extends Migration */ public function down(): void { - Schema::table('mount_server', function (Blueprint $table) { + Schema::table('mount_server', function (Blueprint $table): void { $table->dropForeign(['server_id']); $table->dropForeign(['mount_id']); }); diff --git a/database/migrations/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php b/database/migrations/old/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php similarity index 86% rename from database/migrations/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php rename to database/migrations/old/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php index 11285a5c5..a9ec56b6e 100644 --- a/database/migrations/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php +++ b/database/migrations/old/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php @@ -1,8 +1,10 @@ unsignedInteger('egg_id')->change(); $table->unsignedInteger('mount_id')->change(); }); @@ -28,7 +30,7 @@ class AddForeignKeysToEggMountTable extends Migration ->orWhereNotIn('mount_id', $mounts) ->delete(); - Schema::table('egg_mount', function (Blueprint $table) { + Schema::table('egg_mount', function (Blueprint $table): void { $table->foreign('egg_id') ->references('id') ->on('eggs') @@ -46,7 +48,7 @@ class AddForeignKeysToEggMountTable extends Migration */ public function down(): void { - Schema::table('egg_mount', function (Blueprint $table) { + Schema::table('egg_mount', function (Blueprint $table): void { $table->dropForeign(['egg_id']); $table->dropForeign(['mount_id']); }); diff --git a/database/migrations/2022_01_25_030847_drop_google_analytics.php b/database/migrations/old/2022_01_25_030847_drop_google_analytics.php similarity index 95% rename from database/migrations/2022_01_25_030847_drop_google_analytics.php rename to database/migrations/old/2022_01_25_030847_drop_google_analytics.php index 0d65e5d4d..7c24733ee 100644 --- a/database/migrations/2022_01_25_030847_drop_google_analytics.php +++ b/database/migrations/old/2022_01_25_030847_drop_google_analytics.php @@ -1,7 +1,9 @@ select(['id', 'docker_images'])->cursor()->each(function ($egg) { + DB::table('eggs')->select(['id', 'docker_images'])->cursor()->each(function ($egg): void { $images = is_null($egg->docker_images) ? [] : json_decode($egg->docker_images, true, 512, JSON_THROW_ON_ERROR); $results = []; @@ -29,7 +31,7 @@ class MigrateEggImagesArrayToNewFormat extends Migration */ public function down(): void { - DB::table('eggs')->select(['id', 'docker_images'])->cursor()->each(function ($egg) { + DB::table('eggs')->select(['id', 'docker_images'])->cursor()->each(function ($egg): void { DB::table('eggs')->where('id', $egg->id)->update([ 'docker_images' => array_values(json_decode($egg->docker_images, true, 512, JSON_THROW_ON_ERROR)), ]); diff --git a/database/migrations/2022_05_28_135717_create_activity_logs_table.php b/database/migrations/old/2022_05_28_135717_create_activity_logs_table.php similarity index 95% rename from database/migrations/2022_05_28_135717_create_activity_logs_table.php rename to database/migrations/old/2022_05_28_135717_create_activity_logs_table.php index 4c4f05f1f..26e299bed 100644 --- a/database/migrations/2022_05_28_135717_create_activity_logs_table.php +++ b/database/migrations/old/2022_05_28_135717_create_activity_logs_table.php @@ -1,8 +1,10 @@ id(); $table->uuid('batch')->nullable(); $table->string('event')->index(); diff --git a/database/migrations/2022_05_29_140349_create_activity_log_actors_table.php b/database/migrations/old/2022_05_29_140349_create_activity_log_actors_table.php similarity index 93% rename from database/migrations/2022_05_29_140349_create_activity_log_actors_table.php rename to database/migrations/old/2022_05_29_140349_create_activity_log_actors_table.php index c9997ac41..185addbfd 100644 --- a/database/migrations/2022_05_29_140349_create_activity_log_actors_table.php +++ b/database/migrations/old/2022_05_29_140349_create_activity_log_actors_table.php @@ -1,8 +1,10 @@ id(); $table->foreignId('activity_log_id')->references('id')->on('activity_logs')->cascadeOnDelete(); $table->numericMorphs('subject'); diff --git a/database/migrations/2022_06_18_112822_track_api_key_usage_for_activity_events.php b/database/migrations/old/2022_06_18_112822_track_api_key_usage_for_activity_events.php similarity index 87% rename from database/migrations/2022_06_18_112822_track_api_key_usage_for_activity_events.php rename to database/migrations/old/2022_06_18_112822_track_api_key_usage_for_activity_events.php index f13878637..8dee5ea1a 100644 --- a/database/migrations/2022_06_18_112822_track_api_key_usage_for_activity_events.php +++ b/database/migrations/old/2022_06_18_112822_track_api_key_usage_for_activity_events.php @@ -1,16 +1,19 @@ unsignedInteger('api_key_id')->nullable()->after('actor_id'); }); } @@ -20,7 +23,7 @@ return new class () extends Migration { */ public function down(): void { - Schema::table('activity_logs', function (Blueprint $table) { + Schema::table('activity_logs', function (Blueprint $table): void { $table->dropColumn('api_key_id'); }); } diff --git a/database/migrations/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php b/database/migrations/old/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php similarity index 76% rename from database/migrations/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php rename to database/migrations/old/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php index c5b30a49a..0b2360484 100644 --- a/database/migrations/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php +++ b/database/migrations/old/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php @@ -1,8 +1,10 @@ boolean('force_outgoing_ip')->default(false); }); } @@ -21,7 +23,7 @@ class AddForceOutgoingIpColumnToEggsTable extends Migration */ public function down(): void { - Schema::table('eggs', function (Blueprint $table) { + Schema::table('eggs', function (Blueprint $table): void { $table->dropColumn('force_outgoing_ip'); }); } diff --git a/database/migrations/2022_08_16_230204_add_installed_at_column_to_servers_table.php b/database/migrations/old/2022_08_16_230204_add_installed_at_column_to_servers_table.php similarity index 75% rename from database/migrations/2022_08_16_230204_add_installed_at_column_to_servers_table.php rename to database/migrations/old/2022_08_16_230204_add_installed_at_column_to_servers_table.php index 541117a3a..a0a18ebce 100644 --- a/database/migrations/2022_08_16_230204_add_installed_at_column_to_servers_table.php +++ b/database/migrations/old/2022_08_16_230204_add_installed_at_column_to_servers_table.php @@ -1,8 +1,10 @@ timestamp('installed_at')->nullable(); }); } @@ -21,7 +23,7 @@ class AddInstalledAtColumnToServersTable extends Migration */ public function down(): void { - Schema::table('servers', function (Blueprint $table) { + Schema::table('servers', function (Blueprint $table): void { $table->dropColumn('installed_at'); }); } diff --git a/database/migrations/2022_12_12_213937_update_mail_settings_to_new_format.php b/database/migrations/old/2022_12_12_213937_update_mail_settings_to_new_format.php similarity index 82% rename from database/migrations/2022_12_12_213937_update_mail_settings_to_new_format.php rename to database/migrations/old/2022_12_12_213937_update_mail_settings_to_new_format.php index 97b651033..6d0c95024 100644 --- a/database/migrations/2022_12_12_213937_update_mail_settings_to_new_format.php +++ b/database/migrations/old/2022_12_12_213937_update_mail_settings_to_new_format.php @@ -1,10 +1,13 @@ keys, 0); - $oldSettings = $settings->filter(fn (Setting $setting) => in_array($setting->key, $oldKeys)); + $oldSettings = $settings->filter(fn (Setting $setting): bool => in_array($setting->key, $oldKeys)); // Gets the second column in our key table and gets all matching settings. $newKeys = array_column($this->keys, 1); - $newSettings = $settings->filter(fn (Setting $setting) => in_array($setting->key, $newKeys)); + $newSettings = $settings->filter(fn (Setting $setting): bool => in_array($setting->key, $newKeys)); // Map all the old settings to their new key. - $oldSettings->map(function (Setting $setting) use ($oldKeys) { + $oldSettings->map(function (Setting $setting) use ($oldKeys): Setting { $row = array_search($setting->key, $oldKeys, true); $setting->key = $this->keys[$row][1]; return $setting; // Check if any settings with the new key already exist. - })->filter(function (Setting $setting) use ($newSettings) { - if ($newSettings->contains('key', $setting->key)) { - return false; - } - - return true; + })->filter(function (Setting $setting) use ($newSettings): bool { + return ! $newSettings->contains('key', $setting->key); // Update the settings to use their new keys if they don't already exist. })->each(fn (Setting $setting) => $setting->save()); } @@ -50,22 +49,22 @@ return new class () extends Migration { */ public function down(): void { - DB::transaction(function () { + DB::transaction(function (): void { $settings = Setting::all(); // Gets the second column in our key table and gets all matching settings. $newKeys = array_column($this->keys, 0); - $newSettings = $settings->filter(fn (Setting $setting) => in_array($setting->key, $newKeys)); + $newSettings = $settings->filter(fn (Setting $setting): bool => in_array($setting->key, $newKeys)); // Delete all settings that already have the new key. $newSettings->each(fn (Setting $setting) => $setting->delete()); // Gets the first column in our key table and gets all matching settings. $oldKeys = array_column($this->keys, 1); - $oldSettings = $settings->filter(fn (Setting $setting) => in_array($setting->key, $oldKeys)); + $oldSettings = $settings->filter(fn (Setting $setting): bool => in_array($setting->key, $oldKeys)); // Map all the old settings to their new key. - $oldSettings->map(function (Setting $setting) use ($oldKeys) { + $oldSettings->map(function (Setting $setting) use ($oldKeys): Setting { $row = array_search($setting->key, $oldKeys, true); $setting->key = $this->keys[$row][0]; diff --git a/database/migrations/2023_01_24_210051_add_uuid_column_to_failed_jobs_table.php b/database/migrations/old/2023_01_24_210051_add_uuid_column_to_failed_jobs_table.php similarity index 79% rename from database/migrations/2023_01_24_210051_add_uuid_column_to_failed_jobs_table.php rename to database/migrations/old/2023_01_24_210051_add_uuid_column_to_failed_jobs_table.php index e3482e278..25bdbd9ff 100644 --- a/database/migrations/2023_01_24_210051_add_uuid_column_to_failed_jobs_table.php +++ b/database/migrations/old/2023_01_24_210051_add_uuid_column_to_failed_jobs_table.php @@ -1,24 +1,28 @@ string('uuid')->after('id')->nullable()->unique(); }); - DB::table('failed_jobs')->whereNull('uuid')->cursor()->each(function ($job) { + DB::table('failed_jobs')->whereNull('uuid')->cursor()->each(function ($job): void { DB::table('failed_jobs') ->where('id', $job->id) - ->update(['uuid' => (string) Illuminate\Support\Str::uuid()]); + ->update(['uuid' => (string) Str::uuid()]); }); } @@ -27,7 +31,7 @@ return new class () extends Migration { */ public function down(): void { - Schema::table('failed_jobs', function (Blueprint $table) { + Schema::table('failed_jobs', function (Blueprint $table): void { $table->dropColumn('uuid'); }); } diff --git a/database/migrations/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php b/database/migrations/old/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php similarity index 69% rename from database/migrations/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php rename to database/migrations/old/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php index 49e19bfed..7b98f7e0d 100644 --- a/database/migrations/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php +++ b/database/migrations/old/2023_02_23_191004_add_expires_at_column_to_api_keys_table.php @@ -1,16 +1,19 @@ timestamp('expires_at')->nullable()->after('last_used_at'); }); } @@ -20,7 +23,7 @@ return new class () extends Migration { */ public function down(): void { - Schema::table('api_keys', function (Blueprint $table) { + Schema::table('api_keys', function (Blueprint $table): void { $table->dropColumn('expires_at'); }); } diff --git a/database/migrations/2024_07_13_091852_clear_unused_allocation_notes.php b/database/migrations/old/2024_07_13_091852_clear_unused_allocation_notes.php similarity index 86% rename from database/migrations/2024_07_13_091852_clear_unused_allocation_notes.php rename to database/migrations/old/2024_07_13_091852_clear_unused_allocation_notes.php index 4e29fe37e..041350b20 100644 --- a/database/migrations/2024_07_13_091852_clear_unused_allocation_notes.php +++ b/database/migrations/old/2024_07_13_091852_clear_unused_allocation_notes.php @@ -1,9 +1,12 @@ /resources/scripts/__mocks__/file.ts', - '\\.(s?css|less)$': 'identity-obj-proxy', - ...pathsToModuleNameMapper(compilerOptions.paths, { - prefix: '/', - }), - }, - setupFilesAfterEnv: [ - '/resources/scripts/setup-tests.ts', - ], - transform: { - '.*\\.[t|j]sx$': 'babel-jest', - '.*\\.ts$': 'ts-jest', - }, - testPathIgnorePatterns: ['/node_modules/'], -}; diff --git a/openapi-ts.config.ts b/openapi-ts.config.ts new file mode 100644 index 000000000..ce70e608c --- /dev/null +++ b/openapi-ts.config.ts @@ -0,0 +1,34 @@ +import { defineConfig } from '@hey-api/openapi-ts'; + +export default defineConfig({ + input: 'storage/app/private/scribe/openapi.yaml', + output: { + path: 'resources/scripts/api/generated', + clean: true, + header: [ + '// Generated by @hey-api/openapi-ts.', + '// Do not edit this directory by hand; run npm run api:generate instead.', + ], + }, + plugins: [ + '@hey-api/typescript', + { + name: '@hey-api/client-axios', + baseUrl: false, + runtimeConfigPath: './resources/scripts/api/hey-api-runtime', + throwOnError: true, + }, + { + name: '@hey-api/sdk', + client: '@hey-api/client-axios', + paramsStructure: 'grouped', + }, + { + name: '@tanstack/react-query', + queryKeys: true, + queryOptions: true, + mutationKeys: true, + mutationOptions: true, + }, + ], +}); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..93963a591 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6265 @@ +{ + "name": "pterodactyl-panel", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pterodactyl-panel", + "dependencies": { + "@base-ui/react": "^1.6.0", + "@codemirror/autocomplete": "^6.20.3", + "@codemirror/commands": "^6.10.4", + "@codemirror/lang-cpp": "^6.0.3", + "@codemirror/lang-css": "^6.3.1", + "@codemirror/lang-go": "^6.0.1", + "@codemirror/lang-html": "^6.4.11", + "@codemirror/lang-java": "^6.0.2", + "@codemirror/lang-javascript": "^6.2.5", + "@codemirror/lang-json": "^6.0.2", + "@codemirror/lang-markdown": "^6.5.0", + "@codemirror/lang-php": "^6.0.2", + "@codemirror/lang-python": "^6.2.1", + "@codemirror/lang-rust": "^6.0.2", + "@codemirror/lang-sass": "^6.0.2", + "@codemirror/lang-sql": "^6.10.0", + "@codemirror/lang-vue": "^0.1.3", + "@codemirror/lang-xml": "^6.1.0", + "@codemirror/lang-yaml": "^6.1.3", + "@codemirror/language": "^6.12.4", + "@codemirror/legacy-modes": "^6.5.3", + "@codemirror/search": "^6.7.1", + "@codemirror/state": "^6.7.0", + "@codemirror/view": "^6.43.4", + "@floating-ui/react": "^0.27.19", + "@google-recaptcha/react": "^2.4.2", + "@lezer/highlight": "^1.2.3", + "@tailwindcss/forms": "^0.5.2", + "@tanstack/react-form": "^1.33.0", + "@tanstack/react-query": "^5", + "@tanstack/react-router": "^1.170.17", + "@tanstack/react-table": "^8.21.3", + "axios": "^1.18.1", + "boring-avatars": "^1.7.0", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "codemirror": "^6.0.2", + "dayjs": "^1.11.21", + "ghostty-web": "^0.4.0", + "i18next": "^25.8.0", + "i18next-http-backend": "^3.0.2", + "i18next-multiload-backend-adapter": "^2.3.0", + "lucide-react": "^1.17.0", + "pathe": "^2.0.3", + "qrcode.react": "^4.2.0", + "react": "^19", + "react-dom": "^19", + "react-fast-compare": "^3.2.0", + "react-i18next": "^16.5.4", + "recharts": "^3.8.1", + "sonner": "^2.0.7", + "tailwind-merge": "^3.6.0", + "tailwindcss": "^4.3.0", + "zustand": "^5.0.14" + }, + "devDependencies": { + "@hey-api/openapi-ts": "0.99.0", + "@oxlint/plugins": "^1.77.0", + "@tailwindcss/postcss": "^4", + "@testing-library/dom": "^10", + "@testing-library/jest-dom": "^6", + "@testing-library/react": "^16", + "@testing-library/user-event": "^14.2.1", + "@types/node": "^22.0.0", + "@types/react": "^19", + "@types/react-dom": "^19", + "@vitejs/plugin-react-swc": "^4", + "jsdom": "^26.1.0", + "oxfmt": "^0.58.0", + "oxlint": "^1.77.0", + "postcss": "^8.5.6", + "typescript": "^6", + "vite": "^8", + "vitest": "^4.1.9" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@adobe/css-tools": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.5.0.tgz", + "integrity": "sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@alloc/quick-lru": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", + "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@asamuzakjp/css-color": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-3.2.0.tgz", + "integrity": "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^2.1.3", + "@csstools/css-color-parser": "^3.0.9", + "@csstools/css-parser-algorithms": "^3.0.4", + "@csstools/css-tokenizer": "^3.0.3", + "lru-cache": "^10.4.3" + } + }, + "node_modules/@asamuzakjp/css-color/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@base-ui/react": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@base-ui/react/-/react-1.6.0.tgz", + "integrity": "sha512-/jzjTWJYXhRFO45Bev9lc3cHbmjzCMpUqbMZ2AgKy/z25mY9B6shGSNcXcjQar9n5doM0KYW1W8fcFv2jZBuMw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.2", + "@base-ui/utils": "0.3.1", + "@floating-ui/react-dom": "^2.1.8", + "@floating-ui/utils": "^0.2.11", + "use-sync-external-store": "^1.6.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@date-fns/tz": "^1.2.0", + "@types/react": "^17 || ^18 || ^19", + "date-fns": "^4.0.0", + "react": "^17 || ^18 || ^19", + "react-dom": "^17 || ^18 || ^19" + }, + "peerDependenciesMeta": { + "@date-fns/tz": { + "optional": true + }, + "@types/react": { + "optional": true + }, + "date-fns": { + "optional": true + } + } + }, + "node_modules/@base-ui/utils": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@base-ui/utils/-/utils-0.3.1.tgz", + "integrity": "sha512-gFFiltORVmW/N6IILTGxizP3PBpVpysqML1ALY5Vk0mH+7faVkCknOU31goYHN5Aoek2dkjxva1XOD2Ce9WuIg==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.2", + "@floating-ui/utils": "^0.2.11", + "reselect": "^5.2.0", + "use-sync-external-store": "^1.6.0" + }, + "peerDependencies": { + "@types/react": "^17 || ^18 || ^19", + "react": "^17 || ^18 || ^19", + "react-dom": "^17 || ^18 || ^19" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@codemirror/autocomplete": { + "version": "6.20.3", + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.3.tgz", + "integrity": "sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@codemirror/commands": { + "version": "6.10.4", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.10.4.tgz", + "integrity": "sha512-Ryk9y9T0FFVF0cUGhAknveAyUOl/A1qReTFi+qPKtOh2Z9F4AUBz3XOrYD4ZEgZirdugVzHvd/2/Wcwy5OliTg==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.7.0", + "@codemirror/view": "^6.27.0", + "@lezer/common": "^1.1.0" + } + }, + "node_modules/@codemirror/lang-cpp": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@codemirror/lang-cpp/-/lang-cpp-6.0.3.tgz", + "integrity": "sha512-URM26M3vunFFn9/sm6rzqrBzDgfWuDixp85uTY49wKudToc2jTHUrKIGGKs+QWND+YLofNNZpxcNGRynFJfvgA==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@lezer/cpp": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-css": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz", + "integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.2", + "@lezer/css": "^1.1.7" + } + }, + "node_modules/@codemirror/lang-go": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@codemirror/lang-go/-/lang-go-6.0.1.tgz", + "integrity": "sha512-7fNvbyNylvqCphW9HD6WFnRpcDjr+KXX/FgqXy5H5ZS0eC5edDljukm/yNgYkwTsgp2busdod50AOTIy6Jikfg==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.6.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.0", + "@lezer/go": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-html": { + "version": "6.4.11", + "resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.11.tgz", + "integrity": "sha512-9NsXp7Nwp891pQchI7gPdTwBuSuT3K65NGTHWHNJ55HjYcHLllr0rbIZNdOzas9ztc1EUVBlHou85FFZS4BNnw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/lang-css": "^6.0.0", + "@codemirror/lang-javascript": "^6.0.0", + "@codemirror/language": "^6.4.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0", + "@lezer/css": "^1.1.0", + "@lezer/html": "^1.3.12" + } + }, + "node_modules/@codemirror/lang-java": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-java/-/lang-java-6.0.2.tgz", + "integrity": "sha512-m5Nt1mQ/cznJY7tMfQTJchmrjdjQ71IDs+55d1GAa8DGaB8JXWsVCkVT284C3RTASaY43YknrK2X3hPO/J3MOQ==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@lezer/java": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-javascript": { + "version": "6.2.5", + "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.5.tgz", + "integrity": "sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.6.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.17.0", + "@lezer/common": "^1.0.0", + "@lezer/javascript": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-json": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.2.tgz", + "integrity": "sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@lezer/json": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-markdown": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.0.tgz", + "integrity": "sha512-0K40bZ35jpHya6FriukbgaleaqzBLZfOh7HuzqbMxBXkbYMJDxfF39c23xOgxFezR+3G+tR2/Mup+Xk865OMvw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.7.1", + "@codemirror/lang-html": "^6.0.0", + "@codemirror/language": "^6.3.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "@lezer/common": "^1.2.1", + "@lezer/markdown": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-php": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-php/-/lang-php-6.0.2.tgz", + "integrity": "sha512-ZKy2v1n8Fc8oEXj0Th0PUMXzQJ0AIR6TaZU+PbDHExFwdu+guzOA4jmCHS1Nz4vbFezwD7LyBdDnddSJeScMCA==", + "license": "MIT", + "dependencies": { + "@codemirror/lang-html": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.0", + "@lezer/php": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-python": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/@codemirror/lang-python/-/lang-python-6.2.1.tgz", + "integrity": "sha512-IRjC8RUBhn9mGR9ywecNhB51yePWCGgvHfY1lWN/Mrp3cKuHr0isDKia+9HnvhiWNnMpbGhWrkhuWOc09exRyw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.3.2", + "@codemirror/language": "^6.8.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.2.1", + "@lezer/python": "^1.1.4" + } + }, + "node_modules/@codemirror/lang-rust": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-rust/-/lang-rust-6.0.2.tgz", + "integrity": "sha512-EZaGjCUegtiU7kSMvOfEZpaCReowEf3yNidYu7+vfuGTm9ow4mthAparY5hisJqOHmJowVH3Upu+eJlUji6qqA==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0", + "@lezer/rust": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-sass": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@codemirror/lang-sass/-/lang-sass-6.0.2.tgz", + "integrity": "sha512-l/bdzIABvnTo1nzdY6U+kPAC51czYQcOErfzQ9zSm9D8GmNPD0WTW8st/CJwBTPLO8jlrbyvlSEcN20dc4iL0Q==", + "license": "MIT", + "dependencies": { + "@codemirror/lang-css": "^6.2.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.0.2", + "@lezer/sass": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-sql": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-6.10.0.tgz", + "integrity": "sha512-6ayPkEd/yRw0XKBx5uAiToSgGECo/GY2NoJIHXIIQh1EVwLuKoU8BP/qK0qH5NLXAbtJRLuT73hx7P9X34iO4w==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-vue": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@codemirror/lang-vue/-/lang-vue-0.1.3.tgz", + "integrity": "sha512-QSKdtYTDRhEHCfo5zOShzxCmqKJvgGrZwDQSdbvCRJ5pRLWBS7pD/8e/tH44aVQT6FKm0t6RVNoSUWHOI5vNug==", + "license": "MIT", + "dependencies": { + "@codemirror/lang-html": "^6.0.0", + "@codemirror/lang-javascript": "^6.1.2", + "@codemirror/language": "^6.0.0", + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.3.1" + } + }, + "node_modules/@codemirror/lang-xml": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-6.1.0.tgz", + "integrity": "sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.4.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0", + "@lezer/common": "^1.0.0", + "@lezer/xml": "^1.0.0" + } + }, + "node_modules/@codemirror/lang-yaml": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/@codemirror/lang-yaml/-/lang-yaml-6.1.3.tgz", + "integrity": "sha512-AZ8DJBuXGVHybpBQhmZtgew5//4hv3tdkXnr3vDmOUMJRuB6vn/uuwtmTOTlqEaQFg3hQSVeA90NmvIQyUV6FQ==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.2.0", + "@lezer/lr": "^1.0.0", + "@lezer/yaml": "^1.0.0" + } + }, + "node_modules/@codemirror/language": { + "version": "6.12.4", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.4.tgz", + "integrity": "sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.23.0", + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0", + "style-mod": "^4.0.0" + } + }, + "node_modules/@codemirror/legacy-modes": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/@codemirror/legacy-modes/-/legacy-modes-6.5.3.tgz", + "integrity": "sha512-xCsmIzH78MyWkib9jlPaaun57XNkfbMIhagfaZVd0iLTqlpw3jXaIcbZm72MTmmn64eTZpBVNjbyYh+QXnxRsg==", + "license": "MIT", + "dependencies": { + "@codemirror/language": "^6.0.0" + } + }, + "node_modules/@codemirror/lint": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz", + "integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.42.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/search": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.1.tgz", + "integrity": "sha512-uMe5UO6PamJtSHrXhhHOzSX3ReWtiJrva6GnPMwSOrZtiExb5X5eExhr2OUZQVvdxPsKpY3Ro2mFbQadpPWmHA==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.37.0", + "crelt": "^1.0.5" + } + }, + "node_modules/@codemirror/state": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.0.tgz", + "integrity": "sha512-Zbl9NyscLMZkfXPQnNAIIAFftidrA1UbcJEIMp24C0Bukc2I5T8wJS0wsXYsnDOqCFJUeJ1BITGNs5CqPDSmSg==", + "license": "MIT", + "dependencies": { + "@marijn/find-cluster-break": "^1.0.0" + } + }, + "node_modules/@codemirror/view": { + "version": "6.43.4", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.4.tgz", + "integrity": "sha512-YImu23iyKfncJzT7sRy+rEqEhSc8RhOHqDxwy4WzXRKJwYm6iwf/9OJk5ctCAdZ6yi2ZqaGEvmf55fSVqMDrgg==", + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.7.0", + "crelt": "^1.0.6", + "style-mod": "^4.1.0", + "w3c-keyname": "^2.2.4" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz", + "integrity": "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@csstools/css-calc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz", + "integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.1.0.tgz", + "integrity": "sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^5.1.0", + "@csstools/css-calc": "^2.1.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz", + "integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz", + "integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@emnapi/core": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", + "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.1", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz", + "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", + "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@floating-ui/core": { + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.5.tgz", + "integrity": "sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.11" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.6.tgz", + "integrity": "sha512-9gZSAI5XM36880PPMm//9dfiEngYoC6Am2izES1FF406YFsjvyBMmeJ2g4SAju3xWwtuynNRFL2s9hgxpLI5SQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.7.5", + "@floating-ui/utils": "^0.2.11" + } + }, + "node_modules/@floating-ui/react": { + "version": "0.27.19", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.27.19.tgz", + "integrity": "sha512-31B8h5mm8YxotlE7/AU/PhNAl8eWxAmjL/v2QOxroDNkTFLk3Uu82u63N3b6TXa4EGJeeZLVcd/9AlNlVqzeog==", + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "^2.1.8", + "@floating-ui/utils": "^0.2.11", + "tabbable": "^6.0.0" + }, + "peerDependencies": { + "react": ">=17.0.0", + "react-dom": ">=17.0.0" + } + }, + "node_modules/@floating-ui/react-dom": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.8.tgz", + "integrity": "sha512-cC52bHwM/n/CxS87FH0yWdngEZrjdtLW/qVruo68qg+prK7ZQ4YGdut2GyDVpoGeAYe/h899rVeOVm6Oi40k2A==", + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "^1.7.6" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.11.tgz", + "integrity": "sha512-RiB/yIh78pcIxl6lLMG0CgBXAZ2Y0eVHqMPYugu+9U0AeT6YBeiJpf7lbdJNIugFP5SIjwNRgo4DhR1Qxi26Gg==", + "license": "MIT" + }, + "node_modules/@google-recaptcha/core": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@google-recaptcha/core/-/core-1.1.3.tgz", + "integrity": "sha512-ArN5g4eoXp5YFjMBu5fKhmWZ2HuUyYTjg5RoAQRstpJYbkRgLooZveDQavLRqrClTuAHBDXTEXGRmyCIhj5GJg==", + "license": "MIT" + }, + "node_modules/@google-recaptcha/react": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/@google-recaptcha/react/-/react-2.4.2.tgz", + "integrity": "sha512-qscSi9PSikMA0xGUzDaqaI1SMZAc2nALRmqdLAbtxQPvaaDZglXBpynhLYWpL1ijyY/nfiFFTSKZ79xJVS3BnA==", + "license": "MIT", + "dependencies": { + "@google-recaptcha/core": "*" + }, + "peerDependencies": { + "@types/react": "^17 || ^18|| ^19", + "react": "^17 || ^18 || ^19" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@hey-api/codegen-core": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@hey-api/codegen-core/-/codegen-core-0.9.1.tgz", + "integrity": "sha512-s97jL1dgTMuiMHv2BZ1X4Tgd99Mf9GOvGdNqNcGwIMmnR+PgYNoraj4Zvp134MKsNCap/m7k0r0vKKnl56pj4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@hey-api/types": "0.1.4", + "ansi-colors": "4.1.3", + "c12": "3.3.4", + "color-support": "1.1.3" + }, + "engines": { + "node": ">=22.18.0" + }, + "funding": { + "url": "https://github.com/sponsors/hey-api" + } + }, + "node_modules/@hey-api/json-schema-ref-parser": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@hey-api/json-schema-ref-parser/-/json-schema-ref-parser-1.4.4.tgz", + "integrity": "sha512-otmd+zCxbYVBIp/mlMTnGkvlNYLkVKgs3VOIq0kSnenhB1+fRwLPQIeSwyWM6E51oXhUedkYjVsVpkVexeuJOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jsdevtools/ono": "7.1.3", + "@types/json-schema": "7.0.15", + "js-yaml": "4.2.0" + }, + "engines": { + "node": ">=22.18.0" + }, + "funding": { + "url": "https://github.com/sponsors/hey-api" + } + }, + "node_modules/@hey-api/openapi-ts": { + "version": "0.99.0", + "resolved": "https://registry.npmjs.org/@hey-api/openapi-ts/-/openapi-ts-0.99.0.tgz", + "integrity": "sha512-SePU/5oEWWkvUBYmvzdYRctseoLuskyhs4ET0RvLIcmzc8yLQoA2R+KtBIQ8bPsoSUB0m4E5SmBnl6aGSA0szQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@hey-api/codegen-core": "0.9.1", + "@hey-api/json-schema-ref-parser": "1.4.4", + "@hey-api/shared": "0.5.0", + "@hey-api/spec-types": "0.2.0", + "@hey-api/types": "0.1.4", + "@lukeed/ms": "2.0.2", + "ansi-colors": "4.1.3", + "color-support": "1.1.3", + "commander": "15.0.0", + "get-tsconfig": "4.14.0" + }, + "bin": { + "openapi-ts": "bin/run.js" + }, + "engines": { + "node": ">=22.18.0" + }, + "funding": { + "url": "https://github.com/sponsors/hey-api" + }, + "peerDependencies": { + "typescript": ">=5.5.3 || >=6.0.0 || 6.0.1-rc" + } + }, + "node_modules/@hey-api/shared": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@hey-api/shared/-/shared-0.5.0.tgz", + "integrity": "sha512-JN/j4Ebh4cJGYIQ5cwWuqe7GeSUyQoz7oC51WqyhKOcrejK6DKZMDkshc5d1eKTRuRL+rjozuRcoUaZZn2DGPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@hey-api/codegen-core": "0.9.1", + "@hey-api/json-schema-ref-parser": "1.4.4", + "@hey-api/spec-types": "0.2.0", + "@hey-api/types": "0.1.4", + "ansi-colors": "4.1.3", + "cross-spawn": "7.0.6", + "open": "11.0.0", + "semver": "7.8.4" + }, + "engines": { + "node": ">=22.18.0" + }, + "funding": { + "url": "https://github.com/sponsors/hey-api" + } + }, + "node_modules/@hey-api/shared/node_modules/semver": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz", + "integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@hey-api/spec-types": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@hey-api/spec-types/-/spec-types-0.2.0.tgz", + "integrity": "sha512-ibQ8Is7evMavzr8GNyJCcTg975d8DpaMUyLmOrQ85UBdy1l6t1KuRAwgChAbesJsIlNV6gjmlXruWyegDX18Fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@hey-api/types": "0.1.4" + }, + "funding": { + "url": "https://github.com/sponsors/hey-api" + } + }, + "node_modules/@hey-api/types": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@hey-api/types/-/types-0.1.4.tgz", + "integrity": "sha512-thWfawrDIP7wSI9ioT13I5soaaqB5vAPIiZmgD8PbeEVKNrkonc0N/Sjj97ezl7oQgusZmaNphGdMKipPO6IBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@lezer/common": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.2.tgz", + "integrity": "sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==", + "license": "MIT" + }, + "node_modules/@lezer/cpp": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@lezer/cpp/-/cpp-1.1.6.tgz", + "integrity": "sha512-vh9gWWJOXFVY8HBHK3Twzq8MgwG2iN4GSyzBP9sCGTe37P15x2R14VaBQk0VA0ezTRN1KHYBBsHhvpGZ2Xy/pA==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/css": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.4.tgz", + "integrity": "sha512-N+tn9tej2hPvyKgHEApMOQfHczDJCwxrRFS3SPn9QjYN+uwHvEDnCgKRrb3mxDYxRS8sKMM8fhC3+lc04Abz5Q==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.3.0" + } + }, + "node_modules/@lezer/go": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@lezer/go/-/go-1.0.1.tgz", + "integrity": "sha512-xToRsYxwsgJNHTgNdStpcvmbVuKxTapV0dM0wey1geMMRc9aggoVyKgzYp41D2/vVOx+Ii4hmE206kvxIXBVXQ==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.3.0" + } + }, + "node_modules/@lezer/highlight": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz", + "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.3.0" + } + }, + "node_modules/@lezer/html": { + "version": "1.3.13", + "resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz", + "integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/java": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@lezer/java/-/java-1.1.3.tgz", + "integrity": "sha512-yHquUfujwg6Yu4Fd1GNHCvidIvJwi/1Xu2DaKl/pfWIA2c1oXkVvawH3NyXhCaFx4OdlYBVX5wvz2f7Aoa/4Xw==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/javascript": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.4.tgz", + "integrity": "sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.1.3", + "@lezer/lr": "^1.3.0" + } + }, + "node_modules/@lezer/json": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.3.tgz", + "integrity": "sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/lr": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz", + "integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@lezer/markdown": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.6.4.tgz", + "integrity": "sha512-N0SxazMj4k65DBfaf1azqtMZd6u7MqluP84/NZnB/io8Td9aleFmAhz9hcbvSfsxT5tdYlJ5qgv5aMJGY4zEtA==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0" + } + }, + "node_modules/@lezer/php": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@lezer/php/-/php-1.0.5.tgz", + "integrity": "sha512-W7asp9DhM6q0W6DYNwIkLSKOvxlXRrif+UXBMxzsJUuqmhE7oVU+gS3THO4S/Puh7Xzgm858UNaFi6dxTP8dJA==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.1.0" + } + }, + "node_modules/@lezer/python": { + "version": "1.1.19", + "resolved": "https://registry.npmjs.org/@lezer/python/-/python-1.1.19.tgz", + "integrity": "sha512-MhQIURHRytsNzP/YXnqpYKW6la6voAH3kyplTOOiCdjyFY6cWWGFVmYVdHIPrElqSDf4iCDktQCockB9FxuhzQ==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/rust": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@lezer/rust/-/rust-1.0.2.tgz", + "integrity": "sha512-Lz5sIPBdF2FUXcWeCu1//ojFAZqzTQNRga0aYv6dYXqJqPfMdCAI0NzajWUd4Xijj1IKJLtjoXRPMvTKWBcqKg==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/sass": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@lezer/sass/-/sass-1.1.0.tgz", + "integrity": "sha512-3mMGdCTUZ/84ArHOuXWQr37pnf7f+Nw9ycPUeKX+wu19b7pSMcZGLbaXwvD2APMBDOGxPmpK/O6S1v1EvLoqgQ==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/xml": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@lezer/xml/-/xml-1.0.6.tgz", + "integrity": "sha512-CdDwirL0OEaStFue/66ZmFSeppuL6Dwjlk8qk153mSQwiSH/Dlri4GNymrNWnUmPl2Um7QfV1FO9KFUyX3Twww==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0" + } + }, + "node_modules/@lezer/yaml": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@lezer/yaml/-/yaml-1.0.4.tgz", + "integrity": "sha512-2lrrHqxalACEbxIbsjhqGpSW8kWpUKuY6RHgnSAFZa6qK62wvnPxA8hGOwOoDbwHcOFs5M4o27mjGu+P7TvBmw==", + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.2.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.4.0" + } + }, + "node_modules/@lukeed/ms": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@lukeed/ms/-/ms-2.0.2.tgz", + "integrity": "sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@marijn/find-cluster-break": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.3.tgz", + "integrity": "sha512-FY+MKLBoTsLNJF/eLWaOsXGdz6uh3Iu1axjPf6TUq92IYumcTcXWHoS747JARLkcdlJ/Waiaxc5wQfFO8jC6NA==", + "license": "MIT" + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz", + "integrity": "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.133.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.133.0.tgz", + "integrity": "sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@oxfmt/binding-android-arm-eabi": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm-eabi/-/binding-android-arm-eabi-0.58.0.tgz", + "integrity": "sha512-Uz62sHduGGPftXtILGyxdSW4PX82rUg+rfdNqhsgxe881g4rIoXlIqmZQ6HVKcF4f+F8qMhdD03Bx5u7gmeTdg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-android-arm64": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-android-arm64/-/binding-android-arm64-0.58.0.tgz", + "integrity": "sha512-rD0lRaJp1b+9vw6X4A2dJWKukd6X8yxiicN4JxXcXayolmUypRZxk+lKR+fVOu5q/iYc0fh5fR4bgmfOfVlbaA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-darwin-arm64": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-arm64/-/binding-darwin-arm64-0.58.0.tgz", + "integrity": "sha512-uzbPPk7O6M+w2K65vcQ1woga3wgP8zghjL1KOG5b6qJ8dvYHZJ1VShaslg2KOK6yQIwCQtcMCXqLBM6sqXUNTg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-darwin-x64": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-darwin-x64/-/binding-darwin-x64-0.58.0.tgz", + "integrity": "sha512-L0nKYDxU32oxeQqJj21W9SlIMnf81VZEhyah6iDvFhf5q0oynq498Fopth7blErUJVBpVtxQ98RMCfMPqpJX6w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-freebsd-x64": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-freebsd-x64/-/binding-freebsd-x64-0.58.0.tgz", + "integrity": "sha512-woNwfD58dC5PGS9LSLSD5JYfo/EFK5iG9vhDWkcCg3q78ag7KC8bpDqgvPHrMoXpx83OLXxoSOhu6z8FsVTHlg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm-gnueabihf": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.58.0.tgz", + "integrity": "sha512-Sqs8nMLxuQpY21NKJ1u4stPDmO5hskBCNNh2E3AdCfI1QqWtf4m+Qn4mGEIUO4KGmuq3SWc/SZ80uy5IiwTCDw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm-musleabihf": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.58.0.tgz", + "integrity": "sha512-Vd4exzBI5B5hB9m22JiTQzIL23WvHo/Pe+sNXPNeBLXSP9swCBPKCEBRwKpmpQzYhlgYaCgfPcGXPKAJBRIiZQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm64-gnu": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.58.0.tgz", + "integrity": "sha512-bUWi5mHV+4Vi56RLHE1h6q/HHfwAIT3XoB9vJAVeRzfu5NriXM8y6eeJu0vlKa0C9kq2rq1sOWRClhdLHPocrg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-arm64-musl": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.58.0.tgz", + "integrity": "sha512-2ZHxemzgHcjtktAuVUwSoyXmGo/t+aF5tS1ciPpPei4rhSyrz3JOqDosXXrmhN/yLUSzJjtuW7ToTWqfQpCj2w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-ppc64-gnu": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.58.0.tgz", + "integrity": "sha512-AwKkVwjVmFQ3bcO7j0McGYAqCKH2a326fswfofng/E8VewCT/raeeGQr4huVhY704deK8AWASSTlxzMj0eZc6Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-riscv64-gnu": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.58.0.tgz", + "integrity": "sha512-xsRpTxfUnJF8D3AUKko/qyWdjw4GZVHlCVFuGlzSCTeewLmykKINW8em1+wx+axsDVtJJcMtvsiaXggXxrlHgw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-riscv64-musl": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.58.0.tgz", + "integrity": "sha512-Z4AYOTcy7nYEIiXwD62PlerimyYRcfJOgUbQAEBjXz098kxKuERBlRntofGy69HHhe9E0TLVNMl1yspVNu+efw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-s390x-gnu": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.58.0.tgz", + "integrity": "sha512-A3nhhtZPC/TKVWOPj9q/H3p2znJDCcHWYlJBhWL8hGq/bFmBaNBHC8Np6E581yVq1w9Mi3rMDNzDalWvtUfJtQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-x64-gnu": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.58.0.tgz", + "integrity": "sha512-2g+tVkgwqphw8R4hgo+kF4oz8+P5RwVOtr9+irsC7uwEp0e9j7Crw8kDGKL20uYlLPD7g02DqA61mC/UNYx98A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-linux-x64-musl": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-linux-x64-musl/-/binding-linux-x64-musl-0.58.0.tgz", + "integrity": "sha512-rc15P6AbyyB7426aN8AakLd02Trb3a6ML/mmfAQeVHJEfVofWLcWIrBdy6zDEY+DIaL/s8E4GGPboVw+oP3+EA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-openharmony-arm64": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-openharmony-arm64/-/binding-openharmony-arm64-0.58.0.tgz", + "integrity": "sha512-ZWoTM27/HYPOh9iq86DAbhPu9nXb8qKvvGU/h8OfliyVUFAMMNTLDkGsWDKKnDqIkqvZ9+dXlgUOsH1LYO3O7g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-win32-arm64-msvc": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.58.0.tgz", + "integrity": "sha512-LHZnqFXe2dEfkRI4XdZS/57nEOT/I4UCRX5IyM9v4GYW9XwQCjGe1IUK59SuKw3POwvcgWQ4pme2cYXmNqTNPg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-win32-ia32-msvc": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.58.0.tgz", + "integrity": "sha512-mZKpg20TpheCJym1rarcZCUJeW1sSruw8zAAaCYWvuVfwIUDN1CXdrPU/JgCWReXTCTrEfCB8Wyo3hh9jSZ2EA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxfmt/binding-win32-x64-msvc": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/@oxfmt/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.58.0.tgz", + "integrity": "sha512-N/wUU4N5PZ2orBtI+Ko7MnMfYLfE7K91UrGMY/c/pYyHR3lA9kwst1XugkZx+92YcRh/Eo+iv2eTESSWXfiZPA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm-eabi": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.77.0.tgz", + "integrity": "sha512-E06sKWS6PiI6HRxS1wyQg22HvApt01hI7fV+T3wUk3OSbaaP4a3hYGY/MIQDmASqCiRjBdpRQYkgMkqH82cWmQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm64": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm64/-/binding-android-arm64-1.77.0.tgz", + "integrity": "sha512-NvsKz0KZxTp9cYWPLf+FXaSZwB3oO3peAjtukpOMBgse2vhQSoIIVqeO1yR0lEo/UcdZIDL18uq+kL0LzQ0ytA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-arm64": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.77.0.tgz", + "integrity": "sha512-bgjTn6nW4bQCFBvSvuHCpDD+sONvmpo4lGI4PxzMt1quBA+xYxhczk6RiCn3GZ9gY8uhaBbwhj9MdKGfu6T9DA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-x64": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.77.0.tgz", + "integrity": "sha512-aotaIttH1R6j1Rwhx0M0htgeZyGtVQqYNTVEYMN/UcgHPquGA6kmk9OyuDc3a2GKUQBC+3C3GVQCcrRPMYqAFA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-freebsd-x64": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.77.0.tgz", + "integrity": "sha512-nNx/wta7ksRAdYvq+l4AWjXkLxEXHALhENxjj2cYbQAIR4ybaA5L+hCbE63HOmft5czQ6ks+hb8vmEAnn7YGPg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-gnueabihf": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.77.0.tgz", + "integrity": "sha512-tMLLjM7xXtzXisVCzkOTXNCy9bZVId2wteNwjohlFDR/jY6WagpEDA1c1wu4xRc20Hojaxj+V6DSR7gbKxijWA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-musleabihf": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.77.0.tgz", + "integrity": "sha512-MiAFDFaqR0tmHTAyo0YDcZ5hyLREdYw/RQhc2R3cbT+8O3tB+zqPM2th9TTQ+Uo3jn/embS+DO+HyX9ztCPkOQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-gnu": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.77.0.tgz", + "integrity": "sha512-/xqQ3B16i1T4cyt/9Mn+4CpzhUXoBXp7kVpIwzOXNFLj5JmK1bIjsbSnX296Gg8A/o7oDtKWikFgBx0SLwztkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-musl": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.77.0.tgz", + "integrity": "sha512-LSbwuRKiNCenPDcbARqAZ5RfBy7gmj7vOvfJRLeCDU3gFtSxWbhv/+VTlaUqzUhNj1gFLHB8h7ALnxa/Az6z6g==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-ppc64-gnu": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.77.0.tgz", + "integrity": "sha512-QWdcH31mXEUe5Nq1s0CfCpceaKjIo9uZtwDjAuL681g1axf+5x8xrg/eXWaw//4NCxYZ4V4e5Hu5tvdR+pTBlg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-gnu": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.77.0.tgz", + "integrity": "sha512-GnOfYgJxbcElOiPZaDFDl406ONddwvOWk2jvAAAEjwAl4GofNoHF+/HHUIBYa6bFCArlcGPi0XjC4cU1pkgF/Q==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-musl": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.77.0.tgz", + "integrity": "sha512-AyEMTUCf0xY+hHF+IxqXFQIX0yQOIR8ykpY0lJNOw9xYqOzUX8dyZfRvlG0RfXwuQn2eonf/8NrMmDSZJjdqsA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-s390x-gnu": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.77.0.tgz", + "integrity": "sha512-sPLzEcNvxd/oyVQ5oZo92CiHkFkpBeRop13E/P3TPY+hZfXHKCOWKI70TE2RYwMKFJDc20EMjH16L7NZICtKTw==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-gnu": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.77.0.tgz", + "integrity": "sha512-1Oh2ssH2L7lwyvkdSqaMUfsGfwU2Wfvew+obBUYjRVqhpBcUpwnsPSEr1IzVi9XqkuY10geiLsNKecqaZC34Dw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-musl": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.77.0.tgz", + "integrity": "sha512-0j/2wRgNGO+Qj/M1uu/p57h/hFTTWWcfie0ufkbabeus2s5+/QqkCflnMOwLLN5m2GsNeWp4xdl4cPa4n7QCOQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-openharmony-arm64": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.77.0.tgz", + "integrity": "sha512-BJ/j54qS0usEnyDkLYURMj2iiD9h5Cyy+ppzeMSXBGRXaGRNWnj1Mw14NqWMR5E/PzdgB30OOCCzLzbRoduafw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-arm64-msvc": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.77.0.tgz", + "integrity": "sha512-Yh8w+g2Lpx7StrvtYkoz9JJvXjB9wxgFChFNb85nrXm/wj/XTwGWS1hve9+900HL7llrntYB3YP+y32E3tRqzA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-ia32-msvc": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.77.0.tgz", + "integrity": "sha512-zja5b7+6a7UsRFgAQSrnax5vrzliEyNPLCjfXONu/vTWswaIVZGFajJZptaeRvPE4LghtFdAzVFlexTm7MVTGA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-x64-msvc": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.77.0.tgz", + "integrity": "sha512-+teyvPDZ2RjUvo+SuCqS/UhaJl1QtdW5fWT5NJTV61V5MIuIS90Db9LixmtEGvXixyttiK62P96MSu3UlpviBw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/plugins": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/@oxlint/plugins/-/plugins-1.77.0.tgz", + "integrity": "sha512-6KtPXskPgpt+0Kyl2nNSxNnYXt7lbkxW1C7vi2L7xwtq/AisZlsmV+hnzOTEyM5tU1TxPv1GpTqpUBbZfPzBLg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@reduxjs/toolkit": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.12.0.tgz", + "integrity": "sha512-KiT+RzZbp6mQET+Mg+h2c97+9j1sNflUxQkIHI7Yuzf6Peu+OYpmkn6nbHWmLLWj+1ZODUJFwGZ7gx3L9R9EOw==", + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "@standard-schema/utils": "^0.3.0", + "immer": "^11.0.0", + "redux": "^5.0.1", + "redux-thunk": "^3.1.0", + "reselect": "^5.1.0" + }, + "peerDependencies": { + "react": "^16.9.0 || ^17.0.0 || ^18 || ^19", + "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-redux": { + "optional": true + } + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.3.tgz", + "integrity": "sha512-454rs7jHngixp/NMxd5srYD57OnzSlZ/eFTETjORQHLwJG1lRtmNOJcBerZlfu4GjKqeq8aCCIQrMdHyhI51Hw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.3.tgz", + "integrity": "sha512-PcAhP+ynjURNyy8SKGl5DQP94aGuB/7JrXJb/t7P+hanXvQVMWzUvRRhBAcg/lNRadBhoUPqSoP4xw5tR/KBEA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.3.tgz", + "integrity": "sha512-9YpfeUvSE2RS7wysJ81uOZkXJz7f7Q55H2Gvp3VEw/EsahqDtrphrZ0EwDLK5vvKOzaCrBsjF8JmnMLcUt78Gg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.3.tgz", + "integrity": "sha512-yB1IlAsSNHncV6SCTL27/MVGR5htvQsoGxIv5KMGXALp+Ll1wYsn+x98M9MW7qa+NdSbvrrY7ANI4wLJ0n1e6g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.3.tgz", + "integrity": "sha512-Yi30IVAAfLUCy2MseFjbB1jAMDl1VMCAas5StnYp8da9+CKvMd2H2cbEjWcw5NPaPqzvYkVIaF1nNUG+b7u/sw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.3.tgz", + "integrity": "sha512-jsO7R8To+AdlYgUmN5sHSCZbfhtMBkO0WUx8iORQnPcMMdgr7qM2DQmMwgabs3GhNztdmoKkMKQFHD6DTMCIQw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.3.tgz", + "integrity": "sha512-VWkUHwWriDciit80wleYwKILoR/KMvxh/IdwS/paX+ZgpuRpCrKLUdadJbc0NpBEiyhpYawsJ73j9aCvOH+f7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.3.tgz", + "integrity": "sha512-5f1laC0SlIR0yDbFCd8acUhvJIag6N3zC5P7oUPN6wX0aOma+uKJ0wBDH5aq7I1PVI2ttTlhJwzwRIBnLiSGEg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.3.tgz", + "integrity": "sha512-Iq4ko0r4XsgbrF/LunNgHtAGLRRVE2kXonAXQ/MV0mC6jQpMOhW1SvtZja2EhC/kd05++bP78dsqBeIQyYJ6Yg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.3.tgz", + "integrity": "sha512-B8m6tD5+/N5FeNQFbKlLA/2yVq9ycQP1SeedyEYYKWBNR3ZQbkvIUcNnDNM03lO1l5F2roiiFJGgvoLLyZXtSg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.3.tgz", + "integrity": "sha512-pSdpdUJHkuCxun9LE7jvgUB9qsRgaiyNNCX7m/AvHTcq67AiT/Yhoxvw5zPfhrM8k/BfP8ce/hMOpthKDpEUow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.3.tgz", + "integrity": "sha512-OXXS3RKJgX2uLwM+gYyuH5omcH8fL1LJs96pZGgtetVCahON57+d4SJHzTgZiOjxgGkSnpXpOsWuPDGAKAigEg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.3.tgz", + "integrity": "sha512-JTtb8BWFynicNSoPrehsCzBtOKjZ6jhMiPFEmOiuXg1Fl8dn2KHQob+GuPSGR0dryQa1PQJbzjF3dqO/whhjLg==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "1.10.0", + "@emnapi/runtime": "1.10.0", + "@napi-rs/wasm-runtime": "^1.1.4" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.3.tgz", + "integrity": "sha512-gEdFFEN70A/jxb2svrWsN3aDL7OUtmvlOy+6fa2jxG8K0wQ1ZbdeLGnidov6Yu5/733dI5ySfzFlQ/cb0bSz1g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.3.tgz", + "integrity": "sha512-eXB7CHuaQdqmJcc3koCNtNPmT/bj2gc999kUFgBxG8Ac0NdgXc4rkCHhqrgrhN3zddvvvrgzj1e90SuSfmyIXA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "license": "MIT" + }, + "node_modules/@standard-schema/utils": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@standard-schema/utils/-/utils-0.3.0.tgz", + "integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==", + "license": "MIT" + }, + "node_modules/@swc/core": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.40.tgz", + "integrity": "sha512-2kwzJikRvgtNAG7MwVZY2vEzZjTxKIq5jXOihuSV/8U+Hej8Va22t65aKnJZs3P+NwojZvR8Mf8kyM7O+V8sQg==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3", + "@swc/types": "^0.1.26" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.15.40", + "@swc/core-darwin-x64": "1.15.40", + "@swc/core-linux-arm-gnueabihf": "1.15.40", + "@swc/core-linux-arm64-gnu": "1.15.40", + "@swc/core-linux-arm64-musl": "1.15.40", + "@swc/core-linux-ppc64-gnu": "1.15.40", + "@swc/core-linux-s390x-gnu": "1.15.40", + "@swc/core-linux-x64-gnu": "1.15.40", + "@swc/core-linux-x64-musl": "1.15.40", + "@swc/core-win32-arm64-msvc": "1.15.40", + "@swc/core-win32-ia32-msvc": "1.15.40", + "@swc/core-win32-x64-msvc": "1.15.40" + }, + "peerDependencies": { + "@swc/helpers": ">=0.5.17" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.40.tgz", + "integrity": "sha512-PaYyclfmQ++77D8ityYvmmVzHv9aG8ROwt2GfG6/ccloy4Hgf80qtOnzb9VYvPsUT7Ty1uhuDRhv3XYpf62qhQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.40.tgz", + "integrity": "sha512-HbbPzvfLBUXjIB1Ezks+//lNUjmLjfyd63XSwprJgrZaXYdm70kohXPJUWdqKZozolFxbPaO+xtBaiUp6BoueA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.40.tgz", + "integrity": "sha512-SlRZsCjOCPR2LvFs0Ri/Xrx/5o5TCt8vl4gW6mX1hEZOG0a625RxzRHpHdAQNGykmAN/7IeaFAJG+QnNmxlHcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.40.tgz", + "integrity": "sha512-Q8byxJt2fh8CR3EUX6snBpy47AoBVm+In/+Z3rjDHMjC38ZvR9/gtUUNCT0tfrn4EdVsO8/QPi59nxrxvqxvBQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.40.tgz", + "integrity": "sha512-4z0MgHU+7M0pZDqBN1El7mFXDI1SBwinfcUkAyA4v8QrhOIUOZltySt2aStQLZGrdXVXM4Y4ylfiTC04ED+MoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-ppc64-gnu": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.40.tgz", + "integrity": "sha512-fLI4iUgeSZu0eRWUXwe6YzPFx9gHbFiPkl8Rp3mJfP8OpNR3nTQCGPvHdDh9xniW7mVvgMY4ni7A4VzqI1KrpA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-s390x-gnu": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.40.tgz", + "integrity": "sha512-YqeKMAb7d4nQSGMJQ454IlaCENpzcDqhvBE9+CPfdnYpnUXxd+BSrB6Xk0YjW8UyoEhUj4p6quATCxbsp6J3jg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.40.tgz", + "integrity": "sha512-7HOuS1iGcme/j/TuL1TfmmLGiMQrjv/GmjyZeydl00FKPtpGXEldwqfI56xgd1YzrzoB2svWjxbGGyQ0TEASxg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.40.tgz", + "integrity": "sha512-h4kZYHc7dpc9P9u4brRJaS8Pl7tPVHAeiLSzw7T5RfIJgAoSdaCMKzI/2Uay9gFhaw8uyCDl0L5q37r0EpAfIA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.40.tgz", + "integrity": "sha512-+mQgKZXSj6mV38Zh05QaxSjUDmGP/R2JWlXZTDLSPkDzHU6p3GxN9eeSf5dfyDVU86946fmCvSzyl/ucImx8+A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.40.tgz", + "integrity": "sha512-yvwdPLGd25mcj/mNatjNQ0lZujtQD6psH3v9PNmMb+fSzjbNG8KIDxjFWrcV+fsFVLOkyOmdJsFmX7NAFjVyPw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.15.40", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.40.tgz", + "integrity": "sha512-OXtKsLU1bVtInzzDEAY2sYiF/rl4tvAnLLLpuMp3HzAOQZ5A+i69AKDhA1YLQTaMAqO3vzyYNVAYVRMPtSYD4w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@swc/types": { + "version": "0.1.26", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.26.tgz", + "integrity": "sha512-lyMwd7WGgG79RS7EERZV3T8wMdmPq3xwyg+1nmAM64kIhx5yl+juO2PYIHb7vTiPgPCj8LYjsNV2T5wiQHUEaw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3" + } + }, + "node_modules/@tailwindcss/forms": { + "version": "0.5.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/forms/-/forms-0.5.11.tgz", + "integrity": "sha512-h9wegbZDPurxG22xZSoWtdzc41/OlNEUQERNqI/0fOwa2aVlWGu7C35E/x6LDyD3lgtztFSSjKZyuVM0hxhbgA==", + "license": "MIT", + "dependencies": { + "mini-svg-data-uri": "^1.2.3" + }, + "peerDependencies": { + "tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1 || >= 4.0.0-alpha.20 || >= 4.0.0-beta.1" + } + }, + "node_modules/@tailwindcss/node": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.0.tgz", + "integrity": "sha512-aFb4gUhFOgdh9AXo4IzBEOzBkkAxm9VigwDJnMIYv3lcfXCJVesNfbEaBl4BNgVRyid92AmdviqwBUBRKSeY3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "enhanced-resolve": "^5.21.0", + "jiti": "^2.6.1", + "lightningcss": "1.32.0", + "magic-string": "^0.30.21", + "source-map-js": "^1.2.1", + "tailwindcss": "4.3.0" + } + }, + "node_modules/@tailwindcss/oxide": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.0.tgz", + "integrity": "sha512-F7HZGBeN9I0/AuuJS5PwcD8xayx5ri5GhjYUDBEVYUkexyA/giwbDNjRVrxSezE3T250OU2K/wp/ltWx3UOefg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.3.0", + "@tailwindcss/oxide-darwin-arm64": "4.3.0", + "@tailwindcss/oxide-darwin-x64": "4.3.0", + "@tailwindcss/oxide-freebsd-x64": "4.3.0", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.0", + "@tailwindcss/oxide-linux-arm64-gnu": "4.3.0", + "@tailwindcss/oxide-linux-arm64-musl": "4.3.0", + "@tailwindcss/oxide-linux-x64-gnu": "4.3.0", + "@tailwindcss/oxide-linux-x64-musl": "4.3.0", + "@tailwindcss/oxide-wasm32-wasi": "4.3.0", + "@tailwindcss/oxide-win32-arm64-msvc": "4.3.0", + "@tailwindcss/oxide-win32-x64-msvc": "4.3.0" + } + }, + "node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.0.tgz", + "integrity": "sha512-TJPiq67tKlLuObP6RkwvVGDoxCMBVtDgKkLfa/uyj7/FyxvQwHS+UOnVrXXgbEsfUaMgiVvC4KbJnRr26ho4Ng==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.0.tgz", + "integrity": "sha512-oMN/WZRb+SO37BmUElEgeEWuU8E/HXRkiODxJxLe1UTHVXLrdVSgfaJV7pSlhRGMSOiXLuxTIjfsF3wYvz8cgQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.0.tgz", + "integrity": "sha512-N6CUmu4a6bKVADfw77p+iw6Yd9Q3OBhe0veaDX+QazfuVYlQsHfDgxBrsjQ/IW+zywL8mTrNd0SdJT/zgtvMdA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.0.tgz", + "integrity": "sha512-zDL5hBkQdH5C6MpqbK3gQAgP80tsMwSI26vjOzjJtNCMUo0lFgOItzHKBIupOZNQxt3ouPH7RPhvNhiTfCe5CQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.0.tgz", + "integrity": "sha512-R06HdNi7A7OEoMsf6d4tjZ71RCWnZQPHj2mnotSFURjNLdBC+cIgXQ7l81CqeoiQftjf6OOblxXMInMgN2VzMA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.0.tgz", + "integrity": "sha512-qTJHELX8jetjhRQHCLilkVLmybpzNQAtaI/gaoVoidn/ufbNDbAo8KlK2J+yPoc8wQxvDxCmh/5lr8nC1+lTbg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.0.tgz", + "integrity": "sha512-Z6sukiQsngnWO+l39X4pPbiWT81IC+PLKF+PHxIlyZbGNb9MODfYlXEVlFvej5BOZInWX01kVyzeLvHsXhfczQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.0.tgz", + "integrity": "sha512-DRNdQRpSGzRGfARVuVkxvM8Q12nh19l4BF/G7zGA1oe+9wcC6saFBHTISrpIcKzhiXtSrlSrluCfvMuledoCTQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.0.tgz", + "integrity": "sha512-Z0IADbDo8bh6I7h2IQMx601AdXBLfFpEdUotft86evd/8ZPflZe9COPO8Q1vw+pfLWIUo9zN/JGZvwuAJqduqg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.0.tgz", + "integrity": "sha512-HNZGOUxEmElksYR7S6sC5jTeNGpobAsy9u7Gu0AskJ8/20FR9GqebUyB+HBcU/ax6BHuiuJi+Oda4B+YX6H1yA==", + "bundleDependencies": [ + "@napi-rs/wasm-runtime", + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util", + "@emnapi/wasi-threads", + "tslib" + ], + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.10.0", + "@emnapi/runtime": "^1.10.0", + "@emnapi/wasi-threads": "^1.2.1", + "@napi-rs/wasm-runtime": "^1.1.4", + "@tybys/wasm-util": "^0.10.1", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.0.tgz", + "integrity": "sha512-Pe+RPVTi1T+qymuuRpcdvwSVZjnll/f7n8gBxMMh3xLTctMDKqpdfGimbMyioqtLhUYZxdJ9wGNhV7MKHvgZsQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.0.tgz", + "integrity": "sha512-Mvrf2kXW/yeW/OTezZlCGOirXRcUuLIBx/5Y12BaPM7wJoryG6dfS/NJL8aBPqtTEx/Vm4T4vKzFUcKDT+TKUA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/postcss": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/postcss/-/postcss-4.3.0.tgz", + "integrity": "sha512-Jm05Tjx+9yCLGv5qw1c+84Psds8MnyrEQYCB+FFk2lgGiUjlRqdxke4mVTuYrj2xnVZqKim2Apr5ySuQRYAw/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@alloc/quick-lru": "^5.2.0", + "@tailwindcss/node": "4.3.0", + "@tailwindcss/oxide": "4.3.0", + "postcss": "^8.5.10", + "tailwindcss": "4.3.0" + } + }, + "node_modules/@tanstack/devtools-event-client": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@tanstack/devtools-event-client/-/devtools-event-client-0.4.3.tgz", + "integrity": "sha512-OZI6QyULw0FI0wjgmeYzCIfbgPsOEzwJtCpa69XrfLMtNXLGnz3d/dIabk7frg0TmHo+Ah49w5I4KC7Tufwsvw==", + "license": "MIT", + "bin": { + "intent": "bin/intent.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/form-core": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/@tanstack/form-core/-/form-core-1.33.0.tgz", + "integrity": "sha512-AV4Pw9Dk4orFsuPBcDssfWMJFs+yMYBae7zZ4oTqrCf4ftNGQKxvrQRZeqKHG6A4TkiLeSvf2kzIjcVkrW7E6w==", + "license": "MIT", + "dependencies": { + "@tanstack/devtools-event-client": "^0.4.1", + "@tanstack/pacer-lite": "^0.1.1", + "@tanstack/store": "^0.11.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/history": { + "version": "1.162.0", + "resolved": "https://registry.npmjs.org/@tanstack/history/-/history-1.162.0.tgz", + "integrity": "sha512-79pf/RkhteYZTRgcR4F9kbk84P2N8rugQJswxfIqovlbRiT3yI7eBE+5QorIrZaOKktsgzRlXh1l/du/xpl4iA==", + "license": "MIT", + "engines": { + "node": ">=20.19" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/pacer-lite": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@tanstack/pacer-lite/-/pacer-lite-0.1.1.tgz", + "integrity": "sha512-y/xtNPNt/YeyoVxE/JCx+T7yjEzpezmbb+toK8DDD1P4m7Kzs5YR956+7OKexG3f8aXgC3rLZl7b1V+yNUSy5w==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/query-core": { + "version": "5.101.0", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.101.0.tgz", + "integrity": "sha512-cQetA74EB+seWySv1TTKr828TnP0u39m6LykwDXIo84SNortpDkp30TMEjkqtYCNP9c40uT/iwl6MLiufEt0Ow==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/react-form": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-form/-/react-form-1.33.0.tgz", + "integrity": "sha512-unaee+VS4MvKo+s1dmgGUXI4902VeAhuaUbKsQbhFe3MceOpB3JpAUGCDpyzjQPXVFkFY0COKfLrUNX2XZYW4g==", + "license": "MIT", + "dependencies": { + "@tanstack/form-core": "1.33.0", + "@tanstack/react-store": "^0.11.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@tanstack/react-start": { + "optional": true + } + } + }, + "node_modules/@tanstack/react-query": { + "version": "5.101.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.101.0.tgz", + "integrity": "sha512-rLlJXSpkqfizLWgkR5+eLeIk0MvTx/meEIR7LRjxic+qxiQP8zVjq7BqQkiCMNLQBlLfuOLqqr6KO5GtrDlmSg==", + "license": "MIT", + "dependencies": { + "@tanstack/query-core": "5.101.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^18 || ^19" + } + }, + "node_modules/@tanstack/react-router": { + "version": "1.170.17", + "resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.170.17.tgz", + "integrity": "sha512-ppLkjCfSMaeug9rmFRYzOd4TIqWV+yTE7tzIny7alJsSnM7w4lzEZm6eqCehG0SPetpZ0R3K+UnanSmBgOAVcQ==", + "license": "MIT", + "dependencies": { + "@tanstack/history": "1.162.0", + "@tanstack/react-store": "^0.9.3", + "@tanstack/router-core": "1.171.14", + "isbot": "^5.1.22" + }, + "engines": { + "node": ">=20.19" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": ">=18.0.0 || >=19.0.0", + "react-dom": ">=18.0.0 || >=19.0.0" + } + }, + "node_modules/@tanstack/react-router/node_modules/@tanstack/react-store": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@tanstack/react-store/-/react-store-0.9.3.tgz", + "integrity": "sha512-y2iHd/N9OkoQbFJLUX1T9vbc2O9tjH0pQRgTcx1/Nz4IlwLvkgpuglXUx+mXt0g5ZDFrEeDnONPqkbfxXJKwRg==", + "license": "MIT", + "dependencies": { + "@tanstack/store": "0.9.3", + "use-sync-external-store": "^1.6.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@tanstack/react-router/node_modules/@tanstack/store": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@tanstack/store/-/store-0.9.3.tgz", + "integrity": "sha512-8reSzl/qGWGGVKhBoxXPMWzATSbZLZFWhwBAFO9NAyp0TxzfBP0mIrGb8CP8KrQTmvzXlR/vFPPUrHTLBGyFyw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/react-store": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-store/-/react-store-0.11.0.tgz", + "integrity": "sha512-tX4YXh3PDkmpvGQWkWqKpzs/MSqbtuwY9dWdWhtV9Q50PmO+jOkUKIWIX4G85dwt7lxdHLXsiaEKPdKmC8F41w==", + "license": "MIT", + "dependencies": { + "@tanstack/store": "0.11.0", + "use-sync-external-store": "^1.6.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@tanstack/react-table": { + "version": "8.21.3", + "resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.21.3.tgz", + "integrity": "sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww==", + "license": "MIT", + "dependencies": { + "@tanstack/table-core": "8.21.3" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, + "node_modules/@tanstack/router-core": { + "version": "1.171.14", + "resolved": "https://registry.npmjs.org/@tanstack/router-core/-/router-core-1.171.14.tgz", + "integrity": "sha512-Mo3hwx0qB0cJsVYGDjG0+Ouf7VV74h/vsoDMGztdlyzDanp4gBA2s7IVvm6hFrmQM6GpD9F0Z7SqD7OldfLE7g==", + "license": "MIT", + "dependencies": { + "@tanstack/history": "1.162.0", + "cookie-es": "^3.0.0", + "seroval": "^1.5.4", + "seroval-plugins": "^1.5.4" + }, + "engines": { + "node": ">=20.19" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/store": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@tanstack/store/-/store-0.11.0.tgz", + "integrity": "sha512-WlzzCt3xi0G6pCAJu1U+2jiECwabETDpQDi3hfkFZvJii9AuZqEKbOiVarX1/bWhTNjU486yQtJCCasi/0q+Cw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/table-core": { + "version": "8.21.3", + "resolved": "https://registry.npmjs.org/@tanstack/table-core/-/table-core-8.21.3.tgz", + "integrity": "sha512-ldZXEhOBb8Is7xLs01fR3YEc3DERiz5silj8tnGkFZytt1abEvl/GhUmCE0PMLaMPTa3Jk4HbKmRlHmu+gCftg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@testing-library/dom": { + "version": "10.4.1", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", + "integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "picocolors": "1.1.1", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/jest-dom": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.9.1.tgz", + "integrity": "sha512-zIcONa+hVtVSSep9UT3jZ5rizo2BsxgyDYU7WFD5eICBE7no3881HGeb/QkGfsJs6JTkY1aQhT7rIPC7e+0nnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@adobe/css-tools": "^4.4.0", + "aria-query": "^5.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.6.3", + "picocolors": "^1.1.1", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=14", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz", + "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/react": { + "version": "16.3.2", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.2.tgz", + "integrity": "sha512-XU5/SytQM+ykqMnAnvB2umaJNIOsLF3PVv//1Ew4CTcpz0/BRyy/af40qqrt7SjKpDdT1saBMc42CUok5gaw+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@testing-library/dom": "^10.0.0", + "@types/react": "^18.0.0 || ^19.0.0", + "@types/react-dom": "^18.0.0 || ^19.0.0", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@testing-library/user-event": { + "version": "14.6.1", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.1.tgz", + "integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "peerDependencies": { + "@testing-library/dom": ">=7.21.4" + } + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.2.tgz", + "integrity": "sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/d3-array": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz", + "integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==", + "license": "MIT" + }, + "node_modules/@types/d3-color": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz", + "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==", + "license": "MIT" + }, + "node_modules/@types/d3-ease": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz", + "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==", + "license": "MIT" + }, + "node_modules/@types/d3-interpolate": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz", + "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==", + "license": "MIT", + "dependencies": { + "@types/d3-color": "*" + } + }, + "node_modules/@types/d3-path": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz", + "integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==", + "license": "MIT" + }, + "node_modules/@types/d3-scale": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz", + "integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==", + "license": "MIT", + "dependencies": { + "@types/d3-time": "*" + } + }, + "node_modules/@types/d3-shape": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.1.8.tgz", + "integrity": "sha512-lae0iWfcDeR7qt7rA88BNiqdvPS5pFVPpo5OfjElwNaT2yyekbM0C9vK+yqBqEmHr6lDkRnYNoTBYlAgJa7a4w==", + "license": "MIT", + "dependencies": { + "@types/d3-path": "*" + } + }, + "node_modules/@types/d3-time": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz", + "integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==", + "license": "MIT" + }, + "node_modules/@types/d3-timer": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz", + "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==", + "license": "MIT" + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.19.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.20.tgz", + "integrity": "sha512-6tELRwSDYWW9EdZhbeZmYGZ1/7Djkt+Ah3/ScEYT9cDord7UJzasR/4D3VONg9tQI5CDp+/CZC1AXj2pCFOvpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/react": { + "version": "19.2.17", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.17.tgz", + "integrity": "sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.2.3", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz", + "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.2.0" + } + }, + "node_modules/@types/use-sync-external-store": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz", + "integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==", + "license": "MIT" + }, + "node_modules/@vitejs/plugin-react-swc": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-4.3.1.tgz", + "integrity": "sha512-PaeokKjAGraNN+s5SIApgsktnJprIyt3zgEIu7awnEdfn29QiB2crTcCzyi2XGpX9rUnTc0cKU07Wm0N0g7H2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "^1.0.0", + "@swc/core": "^1.15.11" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "vite": "^4 || ^5 || ^6 || ^7 || ^8" + } + }, + "node_modules/@vitest/expect": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.9.tgz", + "integrity": "sha512-vl/rYsUKcBr3SnQn166+XR5ZQcgMx3DQhFWdfli/cWpLnLUmbxZvyrJZotLFUryib+LtArYMSTJ5RbQ57ZqrlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.1.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.1.9", + "@vitest/utils": "4.1.9", + "chai": "^6.2.2", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.9.tgz", + "integrity": "sha512-EVkXzBjrPGM+cK8/ANWgBrkUCfJfb38/EfTSO8h7pWvKkyPkpWxvR7BkD2MyItMF62C97zAEoqdpUixwR/e+Rw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.1.9", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.21" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.9.tgz", + "integrity": "sha512-s0iufns3iIFitdgm+YR7g1whCAaGtXz459VS9/PqyKDEEFgYIhsHOQmXgIgDuYCt7DeQmiZT0Qe2OA2p4ZPu5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.9.tgz", + "integrity": "sha512-KXLMDtc7oe70+3mJfGrPUWPesswH+3sTxAMAMl8DG7I8IUQT4XW718dY5ID3vPUcmlu27CcKfY4P3h3I29SLJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.1.9", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.9.tgz", + "integrity": "sha512-Jc7RKGNBo8Z28WYIm0Niej4xdSPByRf6mU58VpHQkd6Zh05rlnA+twjbK5HyeIGHxrzsc3mJgS43uM0CZKzaIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.9", + "@vitest/utils": "4.1.9", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.9.tgz", + "integrity": "sha512-fHpsS6mIi+PiEW+vcRVOMkX1oSaPKne3VOclSFICPcGOmfKgXPU5iAah+wcNcj2xPrCCmfq99IDGf+EojhhvhA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.9.tgz", + "integrity": "sha512-A51o8ymO5PpqlWNnBP9ZHPXDIpuMtTLlGSjN7la4US+LJzoUMyhwjA5QXlm39JexgwHKW4Xjs8Z2d3dLCXOeuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.9", + "convert-source-map": "^2.0.0", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.1.tgz", + "integrity": "sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.16.0", + "form-data": "^4.0.5", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" + } + }, + "node_modules/boring-avatars": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/boring-avatars/-/boring-avatars-1.11.2.tgz", + "integrity": "sha512-3+wkwPeObwS4R37FGXMYViqc4iTrIRj5yzfX9Qy4mnpZ26sX41dGMhsAgmKks1r/uufY1pl4vpgzMWHYfJRb2A==", + "license": "MIT" + }, + "node_modules/bundle-name": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", + "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "run-applescript": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/c12": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/c12/-/c12-3.3.4.tgz", + "integrity": "sha512-cM0ApFQSBXuourJejzwv/AuPRvAxordTyParRVcHjjtXirtkzM0uK2L9TTn9s0cXZbG7E55jCivRQzoxYmRAlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^5.0.0", + "confbox": "^0.2.4", + "defu": "^6.1.6", + "dotenv": "^17.3.1", + "exsolve": "^1.0.8", + "giget": "^3.2.0", + "jiti": "^2.6.1", + "ohash": "^2.0.11", + "pathe": "^2.0.3", + "perfect-debounce": "^2.1.0", + "pkg-types": "^2.3.0", + "rc9": "^3.0.1" + }, + "peerDependencies": { + "magicast": "*" + }, + "peerDependenciesMeta": { + "magicast": { + "optional": true + } + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/chai": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", + "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/chokidar": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", + "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^5.0.0" + }, + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/class-variance-authority": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz", + "integrity": "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==", + "license": "Apache-2.0", + "dependencies": { + "clsx": "^2.1.1" + }, + "funding": { + "url": "https://polar.sh/cva" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/codemirror": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz", + "integrity": "sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==", + "license": "MIT", + "dependencies": { + "@codemirror/autocomplete": "^6.0.0", + "@codemirror/commands": "^6.0.0", + "@codemirror/language": "^6.0.0", + "@codemirror/lint": "^6.0.0", + "@codemirror/search": "^6.0.0", + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.0.0" + } + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true, + "license": "ISC", + "bin": { + "color-support": "bin.js" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-15.0.0.tgz", + "integrity": "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/confbox": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.2.4.tgz", + "integrity": "sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cookie-es": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/cookie-es/-/cookie-es-3.1.1.tgz", + "integrity": "sha512-UaXxwISYJPTr9hwQxMFYZ7kNhSXboMXP+Z3TRX6f1/NyaGPfuNUZOWP1pUEb75B2HjfklIYLVRfWiFZJyC6Npg==", + "license": "MIT" + }, + "node_modules/crelt": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz", + "integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==", + "license": "MIT" + }, + "node_modules/cross-fetch": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.1.0.tgz", + "integrity": "sha512-uKm5PU+MHTootlWEY+mZ4vvXoCn4fLQxT9dSc1sXVMSFkINTJVN8cAQROpwcKm8bJ/c7rgZVIBWzH5T78sNZZw==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.7.0" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cssstyle": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.6.0.tgz", + "integrity": "sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^3.2.0", + "rrweb-cssom": "^0.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz", + "integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz", + "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-shape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", + "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==", + "license": "ISC", + "dependencies": { + "d3-path": "^3.1.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/data-urls": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", + "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/data-urls/node_modules/tr46": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/data-urls/node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/data-urls/node_modules/whatwg-url": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/dayjs": { + "version": "1.11.21", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.21.tgz", + "integrity": "sha512-98IT+HOahAisibz/yjKbzuOBwYcjJ7BCLPzARyHiyEBmRz4fatF+KPJszEHXsGYjUG234aH/cOjW1wwTbKUZlA==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, + "node_modules/decimal.js-light": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz", + "integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==", + "license": "MIT" + }, + "node_modules/default-browser": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.0.tgz", + "integrity": "sha512-H9LMLr5zwIbSxrmvikGuI/5KGhZ8E2zH3stkMgM5LpOWDutGM2JZaj460Udnf1a+946zc7YBgrqEWwbk7zHvGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz", + "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-lazy-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/defu": { + "version": "6.1.7", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.7.tgz", + "integrity": "sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/destr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.5.tgz", + "integrity": "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==", + "dev": true, + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, + "license": "MIT" + }, + "node_modules/dotenv": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", + "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/enhanced-resolve": { + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.23.0.tgz", + "integrity": "sha512-yJN/BOOLxcOW2aQgeif9mSnaUB8KtvmMMp56oA1kx1CRfBKbhZm2pJ+NBY+3eOboHxix8lfjWpHE0Ei5U8RbSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.3.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-module-lexer": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.1.0.tgz", + "integrity": "sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-toolkit": { + "version": "1.47.0", + "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.47.0.tgz", + "integrity": "sha512-n1GuoD0WEQZMBk5tttoZSqwgyLx01oqa5XsBmCHwPyNe1S9jPBEmtR2pSgp2kJuWE3ciFZ6yRHmY4pM4C3OOkw==", + "license": "MIT", + "workspaces": [ + "docs", + "benchmarks" + ] + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/eventemitter3": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz", + "integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==", + "license": "MIT" + }, + "node_modules/expect-type": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", + "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/exsolve": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/exsolve/-/exsolve-1.1.0.tgz", + "integrity": "sha512-D+42+T12DdIlJM3uepa55qGiL3sYdLBOxIl2ifQCzCHz4c7eiolaHsi3BIqEr7JxBzxv2pYZQX9kw16ziMcEmw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-tsconfig": { + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.14.0.tgz", + "integrity": "sha512-yTb+8DXzDREzgvYmh6s9vHsSVCHeC0G3PI5bEXNBHtmshPnO+S5O7qgLEOn0I5QvMy6kpZN8K1NKGyilLb93wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/ghostty-web": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/ghostty-web/-/ghostty-web-0.4.0.tgz", + "integrity": "sha512-0puDBik2qapbD/QQBW9o5ZHfXnZBqZWx/ctBiVtKZ6ZLds4NYb+wZuw1cRLXZk9zYovIQ908z3rvFhexAvc5Hg==", + "license": "MIT" + }, + "node_modules/giget": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/giget/-/giget-3.3.0.tgz", + "integrity": "sha512-gzi2D96p+AMfDcmJHGDj3KJ9NRiwvlFAU5yfa3ROwWZmFUjX4P43x3BcyRaOMMLto1vUo7C+86+MFhYTl6Ryiw==", + "dev": true, + "license": "MIT", + "bin": { + "giget": "dist/cli.mjs" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/html-encoding-sniffer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", + "integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-encoding": "^3.1.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/html-parse-stringify": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz", + "integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==", + "license": "MIT", + "dependencies": { + "void-elements": "3.1.0" + } + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/http-proxy-agent/node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/i18next": { + "version": "25.10.10", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-25.10.10.tgz", + "integrity": "sha512-cqUW2Z3EkRx7NqSyywjkgCLK7KLCL6IFVFcONG7nVYIJ3ekZ1/N5jUsihHV6Bq37NfhgtczxJcxduELtjTwkuQ==", + "funding": [ + { + "type": "individual", + "url": "https://www.locize.com/i18next" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + }, + { + "type": "individual", + "url": "https://www.locize.com" + } + ], + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.2" + }, + "peerDependencies": { + "typescript": "^5 || ^6" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/i18next-http-backend": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-3.0.6.tgz", + "integrity": "sha512-mBOqy8993jtqAoj6XaI1XeC/8/9v6EPS+681ziegrPvTB0DoaCY7PpTS0SpY56qLMoS4OI1TZEM2Zf59zNh05w==", + "license": "MIT", + "dependencies": { + "cross-fetch": "4.1.0" + } + }, + "node_modules/i18next-multiload-backend-adapter": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/i18next-multiload-backend-adapter/-/i18next-multiload-backend-adapter-2.3.0.tgz", + "integrity": "sha512-k52N4CImVEDeA+jJo16EJIDdlemSIsWmX6MuBPyR5V8Ig1vQSqVG1acXiQkKE+txLxD8LnR6WKYhkcxTcR86kw==", + "license": "MIT" + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/immer": { + "version": "11.1.8", + "resolved": "https://registry.npmjs.org/immer/-/immer-11.1.8.tgz", + "integrity": "sha512-/tbkHMW7y10Lx6i1crLjD4/OhNkRG+Fo7byZHtah0547nIeXYcpIXaUh0IAQY6gO5459qpGGYapcEOHtFXkIuA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-in-ssh": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-in-ssh/-/is-in-ssh-1.0.0.tgz", + "integrity": "sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-wsl": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz", + "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isbot": { + "version": "5.1.41", + "resolved": "https://registry.npmjs.org/isbot/-/isbot-5.1.41.tgz", + "integrity": "sha512-9WFV/Vhh0FEj6CQ7MoHweEL9/vLKPjeoD2I2htbAjX7kbW7VJs3OCpWOVyd+JraNTWVU6/DRx2MZy2KaUNXHcg==", + "license": "Unlicense", + "engines": { + "node": ">=18" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.2.0.tgz", + "integrity": "sha512-ePWsvanv0DWuDRsW8dnt+R4jQ31SCRCQ7hhNcPXZPsoBZiemuZNYGf7adZdqX2D86j6rvKp3RpCxVTSb8WQlOw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsdom": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-26.1.0.tgz", + "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssstyle": "^4.2.1", + "data-urls": "^5.0.0", + "decimal.js": "^10.5.0", + "html-encoding-sniffer": "^4.0.0", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.6", + "is-potential-custom-element-name": "^1.0.1", + "nwsapi": "^2.2.16", + "parse5": "^7.2.1", + "rrweb-cssom": "^0.8.0", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^5.1.1", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^7.0.0", + "whatwg-encoding": "^3.1.1", + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.1.1", + "ws": "^8.18.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "canvas": "^3.0.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jsdom/node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/jsdom/node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/jsdom/node_modules/tr46": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/jsdom/node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/jsdom/node_modules/whatwg-url": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lucide-react": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.17.0.tgz", + "integrity": "sha512-9FA9evdox/JQL5PT57fdA1x/yg8T7knJ98+zjTL3UfKza6pflQUUh3XtaQIHKvnsJw1lmsEyHVlt5jchYxOQ5w==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "license": "MIT", + "bin": { + "lz-string": "bin/bin.js" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/mini-svg-data-uri": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz", + "integrity": "sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==", + "license": "MIT", + "bin": { + "mini-svg-data-uri": "cli.js" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz", + "integrity": "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/nwsapi": { + "version": "2.2.24", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.24.tgz", + "integrity": "sha512-7YRhZ3jS45LwmSCT4b2sVFHt/WuovaktDU07QrtOBY2PXskss5a9jfmR9jptyumwXST+rFjrmppMY1KT/yn35A==", + "dev": true, + "license": "MIT" + }, + "node_modules/obug": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.2.tgz", + "integrity": "sha512-AWGB9WFcRXOQs48Z/udjI5ZcZMHXwX8XPByNpOydgcGsDLIzjGizhoMWJyKAWze7AVW/2W1i+/gPX4YtKe5cyg==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/ohash": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.11.tgz", + "integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/open": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/open/-/open-11.0.0.tgz", + "integrity": "sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "default-browser": "^5.4.0", + "define-lazy-prop": "^3.0.0", + "is-in-ssh": "^1.0.0", + "is-inside-container": "^1.0.0", + "powershell-utils": "^0.1.0", + "wsl-utils": "^0.3.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/oxfmt": { + "version": "0.58.0", + "resolved": "https://registry.npmjs.org/oxfmt/-/oxfmt-0.58.0.tgz", + "integrity": "sha512-8feG/7NVEHDVwc1OUpP6Pks+TnaDFUw2jLLFIMi5bcmmwxAX2wBQvjSzj62RRTYBf2Op1Wt8xbkmagmPTR5ETg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinypool": "2.1.0" + }, + "bin": { + "oxfmt": "bin/oxfmt" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxfmt/binding-android-arm-eabi": "0.58.0", + "@oxfmt/binding-android-arm64": "0.58.0", + "@oxfmt/binding-darwin-arm64": "0.58.0", + "@oxfmt/binding-darwin-x64": "0.58.0", + "@oxfmt/binding-freebsd-x64": "0.58.0", + "@oxfmt/binding-linux-arm-gnueabihf": "0.58.0", + "@oxfmt/binding-linux-arm-musleabihf": "0.58.0", + "@oxfmt/binding-linux-arm64-gnu": "0.58.0", + "@oxfmt/binding-linux-arm64-musl": "0.58.0", + "@oxfmt/binding-linux-ppc64-gnu": "0.58.0", + "@oxfmt/binding-linux-riscv64-gnu": "0.58.0", + "@oxfmt/binding-linux-riscv64-musl": "0.58.0", + "@oxfmt/binding-linux-s390x-gnu": "0.58.0", + "@oxfmt/binding-linux-x64-gnu": "0.58.0", + "@oxfmt/binding-linux-x64-musl": "0.58.0", + "@oxfmt/binding-openharmony-arm64": "0.58.0", + "@oxfmt/binding-win32-arm64-msvc": "0.58.0", + "@oxfmt/binding-win32-ia32-msvc": "0.58.0", + "@oxfmt/binding-win32-x64-msvc": "0.58.0" + }, + "peerDependencies": { + "svelte": "^5.0.0", + "vite-plus": "*" + }, + "peerDependenciesMeta": { + "svelte": { + "optional": true + }, + "vite-plus": { + "optional": true + } + } + }, + "node_modules/oxlint": { + "version": "1.77.0", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.77.0.tgz", + "integrity": "sha512-qnGh8XJHaQ0dprrDXNQZgS0FgjI6v+V3+X8DwmaV++5Aamy6jGKfDdQ1TUvhUxtmKFAbEf4/WeO5QZX+5WSngg==", + "dev": true, + "license": "MIT", + "bin": { + "oxlint": "bin/oxlint" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxlint/binding-android-arm-eabi": "1.77.0", + "@oxlint/binding-android-arm64": "1.77.0", + "@oxlint/binding-darwin-arm64": "1.77.0", + "@oxlint/binding-darwin-x64": "1.77.0", + "@oxlint/binding-freebsd-x64": "1.77.0", + "@oxlint/binding-linux-arm-gnueabihf": "1.77.0", + "@oxlint/binding-linux-arm-musleabihf": "1.77.0", + "@oxlint/binding-linux-arm64-gnu": "1.77.0", + "@oxlint/binding-linux-arm64-musl": "1.77.0", + "@oxlint/binding-linux-ppc64-gnu": "1.77.0", + "@oxlint/binding-linux-riscv64-gnu": "1.77.0", + "@oxlint/binding-linux-riscv64-musl": "1.77.0", + "@oxlint/binding-linux-s390x-gnu": "1.77.0", + "@oxlint/binding-linux-x64-gnu": "1.77.0", + "@oxlint/binding-linux-x64-musl": "1.77.0", + "@oxlint/binding-openharmony-arm64": "1.77.0", + "@oxlint/binding-win32-arm64-msvc": "1.77.0", + "@oxlint/binding-win32-ia32-msvc": "1.77.0", + "@oxlint/binding-win32-x64-msvc": "1.77.0" + }, + "peerDependencies": { + "oxlint-tsgolint": ">=7.0.2001", + "vite-plus": "*" + }, + "peerDependenciesMeta": { + "oxlint-tsgolint": { + "optional": true + }, + "vite-plus": { + "optional": true + } + } + }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "license": "MIT" + }, + "node_modules/perfect-debounce": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-2.1.0.tgz", + "integrity": "sha512-LjgdTytVFXeUgtHZr9WYViYSM/g8MkcTPYDlPa3cDqMirHjKiSZPYd6DoL7pK8AJQr+uWkQvCjHNdiMqsrJs+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkg-types": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.3.1.tgz", + "integrity": "sha512-y+ichcgc2LrADuhLNAx8DFjVfgz91pRxfZdI3UDhxHvcVEZsenLO+7XaU5vOp0u/7V/wZ+plyuQxtrDlZJ+yeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "confbox": "^0.2.4", + "exsolve": "^1.0.8", + "pathe": "^2.0.3" + } + }, + "node_modules/postcss": { + "version": "8.5.15", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz", + "integrity": "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.12", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/powershell-utils": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.1.0.tgz", + "integrity": "sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qrcode.react": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/qrcode.react/-/qrcode.react-4.2.0.tgz", + "integrity": "sha512-QpgqWi8rD9DsS9EP3z7BT+5lY5SFhsqGjpgW5DY/i3mK4M9DTBNz3ErMi8BWYEfI3L0d8GIbGmcdFAS1uIRGjA==", + "license": "ISC", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/rc9": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/rc9/-/rc9-3.0.1.tgz", + "integrity": "sha512-gMDyleLWVE+i6Sgtc0QbbY6pEKqYs97NGi6isHQPqYlLemPoO8dxQ3uGi0f4NiP98c+jMW6cG1Kx9dDwfvqARQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "defu": "^6.1.6", + "destr": "^2.0.5" + } + }, + "node_modules/react": { + "version": "19.2.7", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz", + "integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.2.7", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.7.tgz", + "integrity": "sha512-t0BRVXvbiE/o20Hfw669rLbMCDWtYZLvmJigy2f0MxsXF+71pxhR3xOkspmsO8h3ZlNzyibAmtCa3l4lYKk6gQ==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.7" + } + }, + "node_modules/react-fast-compare": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", + "integrity": "sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==", + "license": "MIT" + }, + "node_modules/react-i18next": { + "version": "16.6.6", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-16.6.6.tgz", + "integrity": "sha512-ZgL2HUoW34UKUkOV7uSQFE1CDnRPD+tCR3ywSuWH7u2iapnz86U8Bi3Vrs620qNDzCf1F47NxglCEkchCTDOHw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.29.2", + "html-parse-stringify": "^3.0.1", + "use-sync-external-store": "^1.6.0" + }, + "peerDependencies": { + "i18next": ">= 25.10.9", + "react": ">= 16.8.0", + "typescript": "^5 || ^6" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + }, + "react-native": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "license": "MIT" + }, + "node_modules/react-redux": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.3.0.tgz", + "integrity": "sha512-KQopgqFo/p/fgmAs5qz6p5RWaNAzq40WAu7fJIXnQpYxFPbJYtsJPWvGeF2rOBaY/kEuV77AVsX8TsQzKm+A/g==", + "license": "MIT", + "dependencies": { + "@types/use-sync-external-store": "^0.0.6", + "use-sync-external-store": "^1.4.0" + }, + "peerDependencies": { + "@types/react": "^18.2.25 || ^19", + "react": "^18.0 || ^19", + "redux": "^5.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "redux": { + "optional": true + } + } + }, + "node_modules/readdirp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz", + "integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/recharts": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/recharts/-/recharts-3.8.1.tgz", + "integrity": "sha512-mwzmO1s9sFL0TduUpwndxCUNoXsBw3u3E/0+A+cLcrSfQitSG62L32N69GhqUrrT5qKcAE3pCGVINC6pqkBBQg==", + "license": "MIT", + "workspaces": [ + "www" + ], + "dependencies": { + "@reduxjs/toolkit": "^1.9.0 || 2.x.x", + "clsx": "^2.1.1", + "decimal.js-light": "^2.5.1", + "es-toolkit": "^1.39.3", + "eventemitter3": "^5.0.1", + "immer": "^10.1.1", + "react-redux": "8.x.x || 9.x.x", + "reselect": "5.1.1", + "tiny-invariant": "^1.3.3", + "use-sync-external-store": "^1.2.2", + "victory-vendor": "^37.0.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/recharts/node_modules/immer": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.2.0.tgz", + "integrity": "sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, + "node_modules/recharts/node_modules/reselect": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz", + "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==", + "license": "MIT" + }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==", + "license": "MIT" + }, + "node_modules/redux-thunk": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "license": "MIT", + "peerDependencies": { + "redux": "^5.0.0" + } + }, + "node_modules/reselect": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.2.0.tgz", + "integrity": "sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw==", + "license": "MIT" + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/rolldown": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.3.tgz", + "integrity": "sha512-i00lAJ2ks1BYr7rjNjKC7BcqAS7nVfiT3QX1SI5aY+AFHblCmaUf9OE9dbdzDvW6dJxbi2ZCZiy9v3CcwOiX3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.133.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.0.3", + "@rolldown/binding-darwin-arm64": "1.0.3", + "@rolldown/binding-darwin-x64": "1.0.3", + "@rolldown/binding-freebsd-x64": "1.0.3", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.3", + "@rolldown/binding-linux-arm64-gnu": "1.0.3", + "@rolldown/binding-linux-arm64-musl": "1.0.3", + "@rolldown/binding-linux-ppc64-gnu": "1.0.3", + "@rolldown/binding-linux-s390x-gnu": "1.0.3", + "@rolldown/binding-linux-x64-gnu": "1.0.3", + "@rolldown/binding-linux-x64-musl": "1.0.3", + "@rolldown/binding-openharmony-arm64": "1.0.3", + "@rolldown/binding-wasm32-wasi": "1.0.3", + "@rolldown/binding-win32-arm64-msvc": "1.0.3", + "@rolldown/binding-win32-x64-msvc": "1.0.3" + } + }, + "node_modules/rrweb-cssom": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.8.0.tgz", + "integrity": "sha512-guoltQEx+9aMf2gDZ0s62EcV8lsXR+0w8915TC3ITdn2YueuNjdAYh/levpU9nFaoChh9RUS5ZdQMrKfVEN9tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/run-applescript": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", + "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, + "node_modules/scheduler": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", + "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", + "license": "MIT" + }, + "node_modules/seroval": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/seroval/-/seroval-1.5.4.tgz", + "integrity": "sha512-46uFvgrXTVxZcUorgSSRZ4y+ieqLLQRMlG4bnCZKW3qI6BZm7Rg4ntMW4p1mILEEBZWrFlcpp0AyIIlM6jD9iw==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/seroval-plugins": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/seroval-plugins/-/seroval-plugins-1.5.4.tgz", + "integrity": "sha512-S0xQPhUTefAhNvNWFg0c1J8qJArHt5KdtJ/cFAofo06KD1MVSeFWyl4iiu+ApDIuw0WhjpOfCdgConOfAnLgkw==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "seroval": "^1.0" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/sonner": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/sonner/-/sonner-2.0.7.tgz", + "integrity": "sha512-W6ZN4p58k8aDKA4XPcx2hpIQXBRAgyiWVkYhT7CvK6D3iAu7xjvVyhQHg2/iaKJZ1XVJ4r7XuwGL+WGEK37i9w==", + "license": "MIT", + "peerDependencies": { + "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", + "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.1.0.tgz", + "integrity": "sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/style-mod": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz", + "integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==", + "license": "MIT" + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tabbable": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.4.0.tgz", + "integrity": "sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg==", + "license": "MIT" + }, + "node_modules/tailwind-merge": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.6.0.tgz", + "integrity": "sha512-uxL7qAVQriqRQPAyK3pj66VqskWqoZ37PW94jwOTwNfq/z9oyu1V+eqrZqtR2+fCiXdYOZe/Modt8GtvqNzu+w==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, + "node_modules/tailwindcss": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.0.tgz", + "integrity": "sha512-y6nxMGB1nMW9R6k96e5gdIFzcfL/gTJRNaqGes1YvkLnPVXzWgbqFF2yLC0T8G774n24cx3Pe8XrKoniCOAH+Q==", + "license": "MIT" + }, + "node_modules/tapable": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/tiny-invariant": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", + "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==", + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.2.4.tgz", + "integrity": "sha512-SHf/r48b7vOrjve9PxJo3MN5v5yuyjHvdUcrQffT3WXMUfnGmHDVbC4k3sHJaJTgZCwpUplIaAo5ANtMyp3YHg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinypool": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-2.1.0.tgz", + "integrity": "sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.0.0 || >=22.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz", + "integrity": "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tldts": { + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz", + "integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^6.1.86" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz", + "integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz", + "integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^6.1.32" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/typescript": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", + "devOptional": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/use-sync-external-store": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz", + "integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/victory-vendor": { + "version": "37.3.6", + "resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-37.3.6.tgz", + "integrity": "sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ==", + "license": "MIT AND ISC", + "dependencies": { + "@types/d3-array": "^3.0.3", + "@types/d3-ease": "^3.0.0", + "@types/d3-interpolate": "^3.0.1", + "@types/d3-scale": "^4.0.2", + "@types/d3-shape": "^3.1.0", + "@types/d3-time": "^3.0.0", + "@types/d3-timer": "^3.0.0", + "d3-array": "^3.1.6", + "d3-ease": "^3.0.1", + "d3-interpolate": "^3.0.1", + "d3-scale": "^4.0.2", + "d3-shape": "^3.1.0", + "d3-time": "^3.0.0", + "d3-timer": "^3.0.1" + } + }, + "node_modules/vite": { + "version": "8.0.16", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.16.tgz", + "integrity": "sha512-h9bXPmJichP5fLmVQo3PyaGSDE2n3aPuomeAlVRm0JLmt4rY6zmPKd59HYI4LNW8oTK7tlTsuC7l/m7awx9Jcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.32.0", + "picomatch": "^4.0.4", + "postcss": "^8.5.15", + "rolldown": "1.0.3", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.1.18", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitest": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.9.tgz", + "integrity": "sha512-nE3/LEyc0z87uHYLZebqCUOaJr2hdtuPp7BQ4BosVFnfltxgAvMG08NyrSGlPpOUWvR27c5flSmYFTNr78L9GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.1.9", + "@vitest/mocker": "4.1.9", + "@vitest/pretty-format": "4.1.9", + "@vitest/runner": "4.1.9", + "@vitest/snapshot": "4.1.9", + "@vitest/spy": "4.1.9", + "@vitest/utils": "4.1.9", + "es-module-lexer": "^2.0.0", + "expect-type": "^1.3.0", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^4.0.0-rc.1", + "tinybench": "^2.9.0", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.1.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.1.9", + "@vitest/browser-preview": "4.1.9", + "@vitest/browser-webdriverio": "4.1.9", + "@vitest/coverage-istanbul": "4.1.9", + "@vitest/coverage-v8": "4.1.9", + "@vitest/ui": "4.1.9", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "node_modules/void-elements": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz", + "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "license": "MIT" + }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "deprecated": "Use @exodus/bytes instead for a more spec-conformant and faster implementation", + "dev": true, + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ws": { + "version": "8.21.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.1.tgz", + "integrity": "sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/wsl-utils": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.3.1.tgz", + "integrity": "sha512-g/eziiSUNBSsdDJtCLB8bdYEUMj4jR7AGeUo96p/3dTafgjHhpF4RiCFPiRILwjQoDXx5MqkBr4fwWtR3Ky4Wg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-wsl": "^3.1.0", + "powershell-utils": "^0.1.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, + "node_modules/zustand": { + "version": "5.0.14", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.14.tgz", + "integrity": "sha512-/8tAspM5LMPr28b3fwLYrtdj77ECpfZviaP75CMTnwO8ISyaE4GDIG/9rDDYq/cH9D2Xw2A2RXglLInmVBQB/g==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + }, + "use-sync-external-store": { + "optional": true + } + } + } + } +} diff --git a/package.json b/package.json index 732015ede..8910b7186 100644 --- a/package.json +++ b/package.json @@ -4,155 +4,109 @@ "node": ">=22" }, "dependencies": { - "@floating-ui/react-dom-interactions": "^0.6.6", - "@fortawesome/fontawesome-svg-core": "^1.2.32", - "@fortawesome/free-solid-svg-icons": "^5.15.1", - "@fortawesome/react-fontawesome": "^0.1.11", - "@headlessui/react": "^1.6.4", - "@heroicons/react": "^1.0.6", - "@hot-loader/react-dom": "^16.14.0", - "@preact/signals-react": "^1.2.1", + "@base-ui/react": "^1.6.0", + "@codemirror/autocomplete": "^6.20.3", + "@codemirror/commands": "^6.10.4", + "@codemirror/lang-cpp": "^6.0.3", + "@codemirror/lang-css": "^6.3.1", + "@codemirror/lang-go": "^6.0.1", + "@codemirror/lang-html": "^6.4.11", + "@codemirror/lang-java": "^6.0.2", + "@codemirror/lang-javascript": "^6.2.5", + "@codemirror/lang-json": "^6.0.2", + "@codemirror/lang-markdown": "^6.5.0", + "@codemirror/lang-php": "^6.0.2", + "@codemirror/lang-python": "^6.2.1", + "@codemirror/lang-rust": "^6.0.2", + "@codemirror/lang-sass": "^6.0.2", + "@codemirror/lang-sql": "^6.10.0", + "@codemirror/lang-vue": "^0.1.3", + "@codemirror/lang-xml": "^6.1.0", + "@codemirror/lang-yaml": "^6.1.3", + "@codemirror/language": "^6.12.4", + "@codemirror/legacy-modes": "^6.5.3", + "@codemirror/search": "^6.7.1", + "@codemirror/state": "^6.7.0", + "@codemirror/view": "^6.43.4", + "@floating-ui/react": "^0.27.19", + "@google-recaptcha/react": "^2.4.2", + "@lezer/highlight": "^1.2.3", "@tailwindcss/forms": "^0.5.2", - "@tailwindcss/line-clamp": "^0.4.0", - "axios": "^1.13.2", + "@tanstack/react-form": "^1.33.0", + "@tanstack/react-query": "^5", + "@tanstack/react-router": "^1.170.17", + "@tanstack/react-table": "^8.21.3", + "axios": "^1.18.1", "boring-avatars": "^1.7.0", - "chart.js": "^3.8.0", - "classnames": "^2.3.1", - "codemirror": "^5.57.0", - "copy-to-clipboard": "^3.3.1", - "date-fns": "^2.28.0", - "debounce": "^1.2.0", - "deepmerge-ts": "^4.2.1", - "easy-peasy": "^4.0.1", - "events": "^3.0.0", - "formik": "^2.2.6", - "framer-motion": "^6.3.10", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "codemirror": "^6.0.2", + "dayjs": "^1.11.21", + "ghostty-web": "^0.4.0", "i18next": "^25.8.0", "i18next-http-backend": "^3.0.2", "i18next-multiload-backend-adapter": "^2.3.0", + "lucide-react": "^1.17.0", "pathe": "^2.0.3", - "qrcode.react": "^1.0.1", - "react": "^16.14.0", - "react-chartjs-2": "^4.2.0", - "react-dom": "npm:@hot-loader/react-dom", + "qrcode.react": "^4.2.0", + "react": "^19", + "react-dom": "^19", "react-fast-compare": "^3.2.0", - "react-hot-loader": "^4.12.21", "react-i18next": "^16.5.4", - "react-router-dom": "^5.1.2", - "react-transition-group": "^4.4.1", - "reaptcha": "^1.7.2", - "sockette": "^2.0.6", - "styled-components": "^5.3.0", - "styled-components-breakpoint": "^3.0.0-preview.20", - "swr": "^0.2.3", - "tailwindcss": "^3.0.24", - "use-fit-text": "^2.4.0", - "uuid": "^13.0.0", - "xterm": "^4.19.0", - "xterm-addon-fit": "^0.5.0", - "xterm-addon-search": "^0.9.0", - "xterm-addon-search-bar": "^0.2.0", - "xterm-addon-unicode11": "^0.6.0", - "xterm-addon-web-links": "^0.6.0", - "yup": "^0.29.1" + "recharts": "^3.8.1", + "sonner": "^2.0.7", + "tailwind-merge": "^3.6.0", + "tailwindcss": "^4.3.0", + "zustand": "^5.0.14" }, "devDependencies": { - "@babel/core": "^7.12.1", - "@babel/plugin-proposal-class-properties": "^7.12.1", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1", - "@babel/plugin-proposal-object-rest-spread": "^7.12.1", - "@babel/plugin-proposal-optional-chaining": "^7.12.1", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-transform-modules-commonjs": "^7.18.2", - "@babel/plugin-transform-react-jsx": "^7.12.1", - "@babel/plugin-transform-runtime": "^7.12.1", - "@babel/preset-env": "^7.12.1", - "@babel/preset-react": "^7.12.1", - "@babel/preset-typescript": "^7.12.1", - "@babel/runtime": "^7.12.1", - "@fontsource-variable/ibm-plex-sans": "^5.2.8", - "@testing-library/dom": "^8.14.0", - "@testing-library/jest-dom": "^5.16.4", - "@testing-library/react": "12.1.5", + "@hey-api/openapi-ts": "0.99.0", + "@oxlint/plugins": "^1.77.0", + "@tailwindcss/postcss": "^4", + "@testing-library/dom": "^10", + "@testing-library/jest-dom": "^6", + "@testing-library/react": "^16", "@testing-library/user-event": "^14.2.1", - "@types/codemirror": "^0.0.98", - "@types/debounce": "^1.2.0", - "@types/events": "^3.0.0", - "@types/jest": "^28.1.3", "@types/node": "^22.0.0", - "@types/path-browserify": "^1.0.3", - "@types/qrcode.react": "^1.0.1", - "@types/react": "^16.14.0", - "@types/react-copy-to-clipboard": "^4.3.0", - "@types/react-dom": "^16.9.16", - "@types/react-redux": "^7.1.1", - "@types/react-router": "^5.1.3", - "@types/react-router-dom": "^5.1.3", - "@types/react-transition-group": "^4.4.0", - "@types/styled-components": "5.1.7", - "@types/uuid": "^3.4.5", - "@types/webpack-env": "^1.18.8", - "@types/yup": "^0.29.3", - "@typescript-eslint/eslint-plugin": "^5", - "@typescript-eslint/parser": "^5", - "autoprefixer": "^10.4.7", - "babel-jest": "^28.1.1", - "babel-loader": "^10.0.0", - "babel-plugin-styled-components": "^2.0.7", - "cross-env": "^7.0.2", - "css-loader": "^7.1.2", - "eslint": "^8", - "eslint-config-prettier": "^8", - "eslint-plugin-jest-dom": "^4.0.2", - "eslint-plugin-prettier": "^4", - "eslint-plugin-react": "^7", - "eslint-plugin-react-hooks": "^4", - "identity-obj-proxy": "^3.0.0", - "jest": "^28.1.1", + "@types/react": "^19", + "@types/react-dom": "^19", + "@vitejs/plugin-react-swc": "^4", + "jsdom": "^26.1.0", + "oxfmt": "^0.58.0", + "oxlint": "^1.77.0", "postcss": "^8.5.6", - "postcss-import": "^14.1.0", - "postcss-loader": "^8.2.0", - "postcss-nesting": "^13.0.2", - "postcss-preset-env": "^10.4.0", - "prettier": "^2.7.1", - "redux-devtools-extension": "^2.13.8", - "source-map-loader": "^5.0.0", - "style-loader": "^4.0.0", - "svg-url-loader": "^8.0.0", - "terser-webpack-plugin": "^5.3.14", - "ts-essentials": "^9.1.2", - "ts-jest": "^28.0.5", - "twin.macro": "^2.8.2", - "typescript": "~5.1.0", - "webpack": "^5.103.0", - "webpack-assets-manifest": "^6.4.0", - "webpack-cli": "^6.0.1", - "webpack-dev-server": "^5.2.2" + "typescript": "^6", + "vite": "^8", + "vitest": "^4.1.9" }, "scripts": { "clean": "cd public/assets && find . \\( -name \"*.js\" -o -name \"*.map\" \\) -type f -delete", - "test": "jest", - "tsc": "tsc --noEmit", - "lint": "eslint ./resources/scripts/**/*.{ts,tsx} --ext .ts,.tsx", - "watch": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --watch --progress", - "build": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --progress", - "build:production": "yarn run clean && cross-env NODE_ENV=production ./node_modules/.bin/webpack --mode production", - "serve": "yarn run clean && cross-env NODE_ENV=development USE_LOCAL_CERTS=true WEBPACK_PUBLIC_PATH=https://pterodactyl.test:5173/ webpack serve --progress --hot --server-type https" + "test": "vitest run", + "test:watch": "vitest", + "tsc": "tsc --noEmit && tsc --project tools/oxlint/rules && npm --prefix packages/hello-world run typecheck", + "lint": "oxfmt --check resources/scripts packages/hello-world tools/oxlint && oxlint resources/scripts packages/hello-world/src/client", + "api:generate": "openapi-ts", + "extension:api:generate": "node scripts/generate-extension-api.mjs", + "api:refresh": "PTERODACTYL_EXTENSIONS_ENABLED=false composer docs:openapi:verify && npm run api:generate", + "api:check": "npm run sdk:check && npm run tsc && npm run lint", + "dev": "vite", + "watch": "vite build --watch", + "prebuild": "npm run sdk:generate", + "build": "vite build", + "postbuild": "node scripts/check-extension-runtime.mjs", + "build:force": "npm run build --", + "build:production": "npm run build --", + "build:vite": "npm run build && npm --prefix packages/hello-world run build", + "serve": "vite", + "sdk:generate": "node scripts/generate-sdk-types.mjs && node scripts/generate-sdk-icons.mjs", + "sdk:check": "node scripts/generate-sdk-types.mjs --check && node scripts/generate-sdk-icons.mjs --check && npm run sdk:testing && vitest run packages/sdk/types-drift.spec.ts", + "sdk:testing": "node scripts/build-sdk-testing.mjs", + "pretest": "npm run sdk:testing" }, "browserslist": [ "> 0.5%", "last 2 versions", "firefox esr", "not dead" - ], - "babelMacros": { - "twin": { - "preset": "styled-components" - }, - "styledComponents": { - "pure": true, - "displayName": true, - "fileName": true - } - } + ] } diff --git a/packages/hello-world/.gitignore b/packages/hello-world/.gitignore new file mode 100644 index 000000000..1eae0cf67 --- /dev/null +++ b/packages/hello-world/.gitignore @@ -0,0 +1,2 @@ +dist/ +node_modules/ diff --git a/packages/hello-world/extension.json b/packages/hello-world/extension.json new file mode 100644 index 000000000..a013d5438 --- /dev/null +++ b/packages/hello-world/extension.json @@ -0,0 +1,26 @@ +{ + "id": "hello-world", + "name": "Hello World", + "version": "1.0.0", + "description": "A frontend example demonstrating slots, server pages, component replacements, React state, and SDK hooks.", + "ui": { + "entry": "dist/client.js", + "mode": "native", + "prefix": "hw", + "screens": [ + { + "id": "hello-world", + "area": "server", + "path": "hello-world", + "nav": { + "label": "Hello World", + "icon": "hand" + } + } + ], + "components": ["dashboard.serverCard", "server.files.details", "server.files.editor"] + }, + "requires": { + "sdk": ">=2.0.0-beta.4 <3.0" + } +} diff --git a/packages/hello-world/package.json b/packages/hello-world/package.json new file mode 100644 index 000000000..936bda874 --- /dev/null +++ b/packages/hello-world/package.json @@ -0,0 +1,11 @@ +{ + "name": "pterodactyl-hello-world", + "version": "1.0.0", + "private": true, + "type": "module", + "scripts": { + "build": "vite build", + "typecheck": "tsc --noEmit", + "test": "vitest run --config vitest.config.ts" + } +} diff --git a/packages/hello-world/postcss.config.mjs b/packages/hello-world/postcss.config.mjs new file mode 100644 index 000000000..d1840a7c4 --- /dev/null +++ b/packages/hello-world/postcss.config.mjs @@ -0,0 +1 @@ +export default { plugins: { '@tailwindcss/postcss': {} } }; diff --git a/packages/hello-world/src/client/FileDetails.tsx b/packages/hello-world/src/client/FileDetails.tsx new file mode 100644 index 000000000..d345627b0 --- /dev/null +++ b/packages/hello-world/src/client/FileDetails.tsx @@ -0,0 +1,8 @@ +import type { ComponentPartProps, ReplacementProps } from '@pterodactyl/sdk'; + +function FileName({ model }: ComponentPartProps<'server.files.details'>) { + return
{model.name}
; +} +export default function FileDetails({ Default }: ReplacementProps<'server.files.details'>) { + return ; +} diff --git a/packages/hello-world/src/client/FileEditor.tsx b/packages/hello-world/src/client/FileEditor.tsx new file mode 100755 index 000000000..10d413e70 --- /dev/null +++ b/packages/hello-world/src/client/FileEditor.tsx @@ -0,0 +1,15 @@ +import type { ReplacementProps } from '@pterodactyl/sdk'; + +// The panel owns the buffer, the save and the unsaved-changes guard; this adds a status line and keeps every native part. +export default function FileEditor({ Default, model }: ReplacementProps<'server.files.editor'>) { + return ( + <> + {model.dirty && ( +

+ {model.name || 'This new file'} has unsaved changes. +

+ )} + + + ); +} diff --git a/packages/hello-world/src/client/HelloWorldCard.tsx b/packages/hello-world/src/client/HelloWorldCard.tsx new file mode 100644 index 000000000..ae087b884 --- /dev/null +++ b/packages/hello-world/src/client/HelloWorldCard.tsx @@ -0,0 +1,58 @@ +import { useState } from 'react'; +import { + Button, + SocketEvent, + TitledGreyBox, + toast, + useCurrentUser, + useServerPermission, + useServerWebsocketEvent, +} from '@pterodactyl/sdk'; + +export default function HelloWorldCard({ serverName }: { serverName: string }) { + const user = useCurrentUser(); + const canEditFiles = useServerPermission('file.update'); + const [greetings, setGreetings] = useState(0); + const [lastStatus, setLastStatus] = useState(null); + + useServerWebsocketEvent(SocketEvent.STATUS, setLastStatus); + + const sayHello = () => { + setGreetings((count) => count + 1); + toast.success(`Hello, ${user.username}!`); + }; + + return ( + +
+

+ Hello, {user.username}! This extension is running on {serverName}. +

+
+
+
Your file access
+
{canEditFiles ? 'You can edit files.' : 'You cannot edit files.'}
+
+
+
Latest server status event
+
{lastStatus ?? 'Waiting for the next status event.'}
+
+
+
Greetings this visit
+
{greetings}
+
+
+
+ + setGreetings(0)}> + Reset counter + +
+

+ Try the buttons to update local React state. Server status changes arrive through the panel’s shared + websocket. +

+
+
+ ); +} diff --git a/packages/hello-world/src/client/HelloWorldScreen.tsx b/packages/hello-world/src/client/HelloWorldScreen.tsx new file mode 100644 index 000000000..87017db20 --- /dev/null +++ b/packages/hello-world/src/client/HelloWorldScreen.tsx @@ -0,0 +1,18 @@ +import { ServerContentBlock, useCurrentServerRequired } from '@pterodactyl/sdk'; +import HelloWorldCard from './HelloWorldCard'; + +export default function HelloWorldScreen() { + const server = useCurrentServerRequired(); + + return ( + +
+ +

+ For another example, open Users and create or edit a subuser. Permission shortcuts preselect the + form’s checkboxes without saving them. +

+
+
+ ); +} diff --git a/packages/hello-world/src/client/ServerCard.tsx b/packages/hello-world/src/client/ServerCard.tsx new file mode 100644 index 000000000..61907fc10 --- /dev/null +++ b/packages/hello-world/src/client/ServerCard.tsx @@ -0,0 +1,5 @@ +import type { ReplacementProps } from '@pterodactyl/sdk'; + +export default function ServerCard({ Default }: ReplacementProps<'dashboard.serverCard'>) { + return ; +} diff --git a/packages/hello-world/src/client/SubuserPresets.tsx b/packages/hello-world/src/client/SubuserPresets.tsx new file mode 100644 index 000000000..a22e8872e --- /dev/null +++ b/packages/hello-world/src/client/SubuserPresets.tsx @@ -0,0 +1,71 @@ +import { Button, Switch, TitledGreyBox, type SubuserPermissionsSlotData } from '@pterodactyl/sdk'; + +const presets = [ + { name: 'Viewer', permissions: ['websocket.connect', 'file.read', 'backup.read', 'activity.read'] }, + { + name: 'Operator', + permissions: [ + 'websocket.connect', + 'control.console', + 'control.start', + 'control.stop', + 'control.restart', + 'activity.read', + ], + }, + { + name: 'File manager', + permissions: [ + 'websocket.connect', + 'file.read', + 'file.read-content', + 'file.create', + 'file.update', + 'file.delete', + 'file.archive', + ], + }, +] as const; + +const reinstallPermission = 'settings.reinstall'; + +export default function SubuserPresets({ data }: { data: SubuserPermissionsSlotData }) { + const canChangeReinstall = !data.disabled && data.editablePermissions.includes(reinstallPermission); + + const setReinstall = (enabled: boolean) => { + const permissions = data.selectedPermissions.filter((permission) => permission !== reinstallPermission); + data.setPermissions(enabled ? [...permissions, reinstallPermission] : permissions); + }; + + return ( + +
+

+ Choose a starting point, then adjust the checkboxes below. Presets replace permissions you can edit. +

+
+ {presets.map((preset) => ( + + ))} +
+ +

+ This only selects the reinstall permission; it does not reinstall anything. Changes apply when you{' '} + {data.mode === 'create' ? 'invite the user' : 'save'}. +

+
+
+ ); +} diff --git a/packages/hello-world/src/client/examples.spec.tsx b/packages/hello-world/src/client/examples.spec.tsx new file mode 100644 index 000000000..45294ba9e --- /dev/null +++ b/packages/hello-world/src/client/examples.spec.tsx @@ -0,0 +1,198 @@ +import ServerCard from './ServerCard'; +import FileDetails from './FileDetails'; +import FileEditor from './FileEditor'; +import { + createComponentTestHost, + createTestServerCard, + createTestFileDetails, + createTestFileEditor, +} from '@pterodactyl/sdk/testing'; +import { useState, type ReactNode } from 'react'; +import { afterEach, beforeEach, expect, it, vi } from 'vitest'; +import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import type { ExtensionSetupContext, SubuserPermissionsSlotData } from '@pterodactyl/sdk'; +import HelloWorldCard from './HelloWorldCard'; +import SubuserPresets from './SubuserPresets'; +import extension from './index'; + +import { createExtensionTestHost, createTestServer, type ExtensionTestHost } from '@pterodactyl/sdk/testing'; +import { SocketEvent, toast, type SdkServer } from '@pterodactyl/sdk'; + +let host: ExtensionTestHost | undefined; +beforeEach(() => { + vi.spyOn(window, 'scrollTo').mockImplementation(() => {}); +}); +afterEach(() => { + cleanup(); + host?.dispose(); + host = undefined; + vi.restoreAllMocks(); +}); +function renderInHost(children: ReactNode, server?: SdkServer) { + host = createExtensionTestHost({ server }); + return render(children, { wrapper: host.Wrapper }); +} + +it('registers a console slot, a permissions form slot, and a lazy server page', () => { + const context: ExtensionSetupContext = { + meta: { id: 'hello-world' }, + config: {}, + slots: { register: vi.fn() }, + screens: { register: vi.fn() }, + columns: { register: vi.fn() }, + components: { replace: vi.fn() }, + }; + + extension.setup(context); + + expect(context.slots.register).toHaveBeenCalledWith('server.console.before', expect.any(Function)); + expect(context.slots.register).toHaveBeenCalledWith('server.users.permissions.before', SubuserPresets); + expect(context.screens.register).toHaveBeenCalledWith('hello-world', expect.any(Function), { + badge: expect.any(Function), + }); +}); + +it('shows the current user and updates local state and websocket feedback', async () => { + const feedback = vi.spyOn(toast, 'success'); + const server = createTestServer({ identifier: 'test', name: 'Example server' }); + renderInHost(, server); + await screen.findByText('Greetings this visit'); + + fireEvent.click(screen.getByRole('button', { name: 'Say hello' })); + fireEvent.click(screen.getByRole('button', { name: 'Say hello' })); + act(() => host!.emitWebsocket(SocketEvent.STATUS, 'running')); + + expect(screen.getByText('Greetings this visit').nextElementSibling?.textContent).toBe('2'); + expect(screen.getByText('Hello, Alex! This extension is running on Example server.')).toBeTruthy(); + expect(screen.getByText('running')).toBeTruthy(); + expect(feedback).toHaveBeenLastCalledWith('Hello, Alex!'); + fireEvent.click(screen.getByRole('button', { name: 'Reset counter' })); + expect(screen.getByText('Greetings this visit').nextElementSibling?.textContent).toBe('0'); +}); + +it('preselects role permissions without submitting the surrounding form', async () => { + const setPermissions = vi.fn(); + const submit = vi.fn((event) => event.preventDefault()); + const data: SubuserPermissionsSlotData = { + mode: 'create', + selectedPermissions: [], + editablePermissions: ['file.read'], + disabled: false, + setPermissions, + }; + renderInHost( +
+ + + ); + + fireEvent.click(await screen.findByRole('button', { name: 'Viewer' })); + + expect(setPermissions).toHaveBeenCalledExactlyOnceWith([ + 'websocket.connect', + 'file.read', + 'backup.read', + 'activity.read', + ]); + expect(submit).not.toHaveBeenCalled(); +}); + +it('changes only the reinstall selection when the switch is toggled', async () => { + function Draft() { + const [selectedPermissions, setPermissions] = useState(['file.read']); + return ( + <> + + {selectedPermissions.join(',')} + + ); + } + renderInHost(); + + fireEvent.click(await screen.findByRole('switch')); + expect(screen.getByRole('status').textContent).toBe('file.read,settings.reinstall'); + fireEvent.click(await screen.findByRole('switch')); + expect(screen.getByRole('status').textContent).toBe('file.read'); +}); + +it('disables the reinstall shortcut when it cannot be granted', async () => { + const setPermissions = vi.fn(); + renderInHost( + + ); + + await userEvent.click(await screen.findByRole('switch')); + + expect(screen.getByRole('switch').getAttribute('aria-disabled')).toBe('true'); + expect(setPermissions).not.toHaveBeenCalled(); +}); + +it('disables every shortcut while the host form is read-only or saving', async () => { + const setPermissions = vi.fn(); + renderInHost( + + ); + + await userEvent.click(await screen.findByRole('button', { name: 'Operator' })); + await userEvent.click(await screen.findByRole('switch')); + + expect(setPermissions).not.toHaveBeenCalled(); +}); + +it('composes the native server card using the real SDK fixture', () => { + const host = createComponentTestHost('dashboard.serverCard', { + model: createTestServerCard({ name: 'Survival' }), + prefix: 'hw', + }); + render(, { wrapper: host.Wrapper }); + expect(screen.getByText('Survival')).toBeTruthy(); + expect(screen.getByText('12.00 %')).toBeTruthy(); + // The prefixed utility replaces the native card's own gap instead of sitting beside it. + const card = screen.getByText('Survival').closest('.grid'); + expect(card?.classList.contains('hw:gap-3')).toBe(true); + expect(card?.classList.contains('gap-4')).toBe(false); +}); + +it('customizes only the file name while native size and timestamp remain available', () => { + const host = createComponentTestHost('server.files.details', { + model: createTestFileDetails({ name: 'server.properties' }), + }); + render(, { wrapper: host.Wrapper }); + expect(screen.getByText('server.properties').classList.contains('hw:font-medium')).toBe(true); + expect(screen.getByText('1 KiB')).toBeTruthy(); + expect(screen.getByTitle('2026-01-01T12:00:00Z')).toBeTruthy(); +}); + +it('reports unsaved changes above the native file editor', () => { + const host = createComponentTestHost('server.files.editor', { + model: createTestFileEditor({ name: 'server.properties', dirty: true }), + }); + render(, { wrapper: host.Wrapper }); + expect(screen.getByRole('status').textContent).toBe('server.properties has unsaved changes.'); + expect(screen.getByRole('button', { name: 'Save Content' })).toBeTruthy(); +}); diff --git a/packages/hello-world/src/client/index.tsx b/packages/hello-world/src/client/index.tsx new file mode 100644 index 000000000..f88e9c97b --- /dev/null +++ b/packages/hello-world/src/client/index.tsx @@ -0,0 +1,24 @@ +import './styles.css'; +import { definePterodactylExtension, type SdkServer } from '@pterodactyl/sdk'; +import HelloWorldCard from './HelloWorldCard'; +import SubuserPresets from './SubuserPresets'; + +function ConsoleGreeting({ data }: { data: SdkServer }) { + return ; +} + +export default definePterodactylExtension({ + setup({ slots, screens, components }) { + slots.register('server.console.before', ConsoleGreeting); + slots.register('server.users.permissions.before', SubuserPresets); + + components.replace('dashboard.serverCard', { load: () => import('./ServerCard') }); + components.replace('server.files.details', { load: () => import('./FileDetails') }); + components.replace('server.files.editor', { load: () => import('./FileEditor') }); + + screens.register('hello-world', () => import('./HelloWorldScreen'), { + // A live navigation badge. Returning undefined keeps the manifest's nav.badge (none here). + badge: ({ server }) => (server?.attributes.status === 'installing' ? 'Installing' : undefined), + }); + }, +}); diff --git a/packages/hello-world/src/client/styles.css b/packages/hello-world/src/client/styles.css new file mode 100644 index 000000000..b6e52e41d --- /dev/null +++ b/packages/hello-world/src/client/styles.css @@ -0,0 +1,10 @@ +/* + * Every extension builds Tailwind with its own prefix, declared as `ui.prefix` in + * extension.json (`hw:flex`, `hw:lg:hidden`), so its utilities and theme variables never + * collide with the panel build or with another extension's. A real extension imports + * `@pterodactyl/sdk/theme.css`; this example lives next to the SDK. + */ +@import 'tailwindcss/theme.css' layer(theme) prefix(hw); +@import 'tailwindcss/utilities.css' layer(utilities) prefix(hw); +@import '../../../sdk/theme.css'; +@source './**/*.{ts,tsx}'; diff --git a/packages/hello-world/tsconfig.json b/packages/hello-world/tsconfig.json new file mode 100644 index 000000000..df0cd84d7 --- /dev/null +++ b/packages/hello-world/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "jsx": "react-jsx", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "types": ["vite/client"], + "strict": true, + "noEmit": true, + "skipLibCheck": true, + "paths": { + "@pterodactyl/sdk": ["../sdk/types/index.d.ts"], + "@pterodactyl/sdk/testing": ["../sdk/types/testing.d.ts"], + "@pterodactyl/sdk/api": ["../sdk/types/api.d.ts"] + } + }, + "include": ["src/client/**/*"] +} diff --git a/packages/hello-world/vite.config.mjs b/packages/hello-world/vite.config.mjs new file mode 100644 index 000000000..6d0dbe17f --- /dev/null +++ b/packages/hello-world/vite.config.mjs @@ -0,0 +1,3 @@ +import { defineExtensionConfig } from '../sdk/vite.mjs'; + +export default defineExtensionConfig({ entry: 'src/client/index.tsx' }); diff --git a/packages/hello-world/vitest.config.ts b/packages/hello-world/vitest.config.ts new file mode 100644 index 000000000..fa1138a0c --- /dev/null +++ b/packages/hello-world/vitest.config.ts @@ -0,0 +1,18 @@ +import { defineConfig } from 'vitest/config'; +import { pterodactylTestAliases, pterodactylTestSetup } from '../sdk/vitest.mjs'; +import { fileURLToPath } from 'node:url'; + +export default defineConfig({ + root: fileURLToPath(new URL('.', import.meta.url)), + resolve: { + alias: pterodactylTestAliases(), + }, + test: { + name: 'hello-world', + environment: 'jsdom', + setupFiles: [pterodactylTestSetup], + include: ['src/**/*.spec.{ts,tsx}'], + clearMocks: true, + restoreMocks: true, + }, +}); diff --git a/packages/sdk/README.md b/packages/sdk/README.md new file mode 100644 index 000000000..a3015d989 --- /dev/null +++ b/packages/sdk/README.md @@ -0,0 +1,579 @@ +# @pterodactyl/sdk + +Build extensions for the Pterodactyl panel (v2+). This package provides: + +- **Types** for the runtime API — the actual implementation is provided *by the panel* + through its import map, so your built extension never bundles the SDK, React, or + TanStack Query: it shares the panel's own instances. +- **The Vite build preset** (`@pterodactyl/sdk/vite`) that keeps those modules external + and emits `dist/client.js` plus lazy screen chunks. + +## Quick start + +```tsx +// src/client/index.tsx +import { useState } from 'react'; +import { Button, definePterodactylExtension, toast } from '@pterodactyl/sdk'; + +export default definePterodactylExtension({ + setup({ slots, screens }) { + slots.register('server.console.before', () => { + const [count, setCount] = useState(0); + return ; + }); + + screens.register('votes', () => import('./VotesScreen')); + }, +}); +``` + +```js +// vite.config.mjs +import { defineExtensionConfig } from '@pterodactyl/sdk/vite'; + +export default defineExtensionConfig({ entry: 'src/client/index.tsx' }); +``` + +`vite build` → `dist/client.js`, referenced from your `extension.json`: + +```json +{ + "id": "myext", + "name": "My Extension", + "version": "1.0.0", + "ui": { + "entry": "dist/client.js", + "mode": "native", + "screens": [{ + "id": "votes", + "area": "server", + "path": "votes", + "nav": { "label": "Votes" }, + "permission": ["ext.myext.view"] + }] + } +} +``` + +The `ext.myext.view` permission above is the extension's own subuser permission. Register it from +the extension's PHP provider so subusers can be granted it in the server's user editor: + +```php +$this->registerPermissions('Manage server votes.', ['view' => 'View the votes page.']); +``` + +Each key becomes `ext..`. Check it on the backend with `$user->can('ext.myext.view', $server)`. + +Everything exported from `@pterodactyl/sdk` (and the shared `react` / `react-dom` / +`@tanstack/react-query` import-map entries) is semver-governed ABI: additions are +minor versions, removals are majors. + +## Loading and recovery + +Screen IDs, paths, navigation, and permissions live in `ui.screens` in the manifest. A screen's `permission` list names the subuser permissions needed to open it and is only accepted on `server` screens; account and admin screens are open to every signed-in user and every root admin respectively. Register each declared screen with `screens.register(id, importer)` during synchronous `setup`. Paths use a static first segment and may include named parameters such as `votes/$tab` (the panel reserves `$id`); duplicate paths, duplicate parameter patterns, and core route collisions reject the offending extension. Screen components receive a `data` prop (`ScreenComponentProps`) with the current `pathname`, `search`, and `params`, so `votes/$tab` reads its value from `data.params.tab`. + +The panel renders before optional bundles finish importing. Each extension commits atomically when ready; slot display order follows the configured extension order. Screens show local loading state while their bundle or chunk loads. Slots have individual Suspense and error boundaries, and SDK websocket callbacks are isolated and attributed to their mod. Native extensions still execute in the panel's JavaScript environment; boundaries are not a sandbox and cannot interrupt synchronous code. + +Recoverable render/query failures offer Retry. Failed screen chunks offer an explicit page reload because resetting an error boundary cannot evict a rejected browser module. Enabling, disabling, updating, or changing frontend configuration takes effect on the next full page load; reload after management changes. Already evaluated JavaScript is not unloaded dynamically. + +## Types and shared dependencies + +The panel currently supports the React 19.2 client API. Server-only caching APIs, development-only `captureOwnerStack`, and unstable cache-refresh APIs are not part of the shared React facade. React, React DOM, JSX runtime, Query, and SDK entry points stay external through the Vite preset. + +SDK declarations are generated from the runtime public surface with `npm run sdk:generate` at the panel root. `npm run sdk:check` checks reproducibility and compiles a packed-package consumer, including negative type cases. Component props, form fields, and `useCurrentServer(server => server.attributes.name)` preserve their actual types. SDK peer dependencies include the existing libraries referenced by those declarations; use SDK form hooks/components to share the panel's bound form contexts. + +Declare screen metadata in the manifest and register each implementation by ID with `screens.register`. Build extensions against the SDK version used by the panel. + +A `file:` dependency on `packages/sdk` is a link into the panel checkout. TypeScript follows links to their real location by default, so the SDK declarations would take React, TanStack Query and the other peers from the panel's `node_modules` while your code takes them from yours; when the versions differ, `useQuery(serverFileContentQueryOptions(...))` fails on two unrelated `QueryClient` types. Scaffolded extensions set `"preserveSymlinks": true` in `tsconfig.json`, which resolves the SDK's peers from the extension, the same way the Vitest preset does at runtime. Add that option to an extension scaffolded earlier and remove any `paths` entries for `react`, `@tanstack/react-query` or `lucide-react`. An SDK installed from a tarball or registry needs neither. + +## Resource hooks and native data + +Admin screens may declare `parent: "admin.node"`, `"admin.server"`, `"admin.egg"`, or `"admin.user"`. +Their paths become detail tabs and `useCurrentResource()` supplies the typed resource. +`nav` supports `order`, `group`, `badge`, and `icon`. Parameterized navigation +requires `nav.params`, for example `{ "tab": "overview" }` for `votes/$tab`. +`PanelLink`, `usePanelNavigate`, and `usePanelLocation` use the host router; navigation +by extension id and screen id also works for resource tabs. + +`serverQueryOptions`, `serverFilesQueryOptions`, `serverFileContentQueryOptions`, +`serverStartupQueryOptions`, and `serverBackupsQueryOptions` use core cache keys and +transport. Pass the server UUID for files, startup, and backups to share core entries. +`serverLogsQueryOptions(uuid, lines?)` reads the latest console output (at most 100 +lines, oldest first) and needs the `websocket.connect` permission. +Their hooks accept selectors, and `invalidateServerData(uuid, domains)` returns the +host invalidation promise. Curated mutation hooks reuse core updates and serialize +startup writes. Await `mutateAsync` from a handler wrapped with `useExtensionAction`. + +`serverResourcesQueryOptions(uuid)` and `useServerResources(uuid, select?)` read power +state and resource usage from the cache entry the dashboard's server cards poll, so a +screen that shows them adds no request of its own. The panel asks Wings at most every 20 +seconds; inside the server area, `useServerWebsocketEvent('stats' | 'status', ...)` +delivers live values. `invalidateServerData(uuid, ['resources'])` refetches the entry. +`useSendServerPower(uuid)` takes `{ signal: 'start' | 'stop' | 'restart' | 'kill' }` and +`useSendServerCommand(uuid)` takes `{ command }`. Both go through the client API, so they +work without a console socket, are checked against the user's `control.*` permissions by +the panel, and report failures with the panel's own notification before rejecting. + +`useNavigationBlocker(shouldBlock, options?)` asks before unsaved work is left behind: +router links and `usePanelNavigate`, the browser's back and forward buttons, and closing +or reloading the tab. Pass a boolean, or a function read at navigation time when the +answer lives in a ref. `message` sets the text of the default confirmation, +`beforeUnload: false` leaves tab close alone, and `confirm(transition)` replaces the +confirmation with your own decision (resolve `true` to leave); it receives the current +and next `pathname`, `params` and `search`, so navigation within your own screen can pass. + +```tsx +const [dirty, setDirty] = useState(false); +useNavigationBlocker(dirty, { message: 'Discard your changes to this file?' }); +``` + +File toolbar, row actions, and selection actions receive typed files, directory, +selection, and refresh callbacks. `server.startup.form` receives current configuration +and a guarded Docker image setter. `panel.users.detail.form` supplies the native +`form`, so contributed `form.AppField` controls share core validation, pending state, +submission, and persistence. Keep values in that form rather than copying a separate draft. `columns.register('admin.nodes', { id, label, +component })` adds a typed cell to the native table; servers and eggs are also supported. +Columns commit atomically and render inside local error boundaries. Table, Tooltip, +DropdownMenu, and Pagination complement the existing form and dialog primitives. `Empty` +(with `EmptyHeader`, `EmptyMedia`, `EmptyTitle`, `EmptyDescription`, `EmptyContent`) +matches the panel's empty states; pass it as a `Table`'s `emptyState`. + +`useExtensionTranslation('messages')` loads the provider's registered +`resources/lang//messages.php` group. Extension CSS is built with the extension's own +Tailwind prefix (see [Styling](#styling)). The Vite preset waits for entry CSS before setup. + +Themes override the panel's CSS tokens: colour roles, the `--terminal-*` +and `--editor-*` palettes, `--selection`, `--scrollbar-*`, `--color-scheme`, `--theme-color`, +and the layout tokens `--layout-content-width`, `--layout-auth-width`, +`--layout-sidebar-width` (`max-w-panel`, `max-w-auth`, `w-sidebar`) and `--spacing` (density). +Extension utilities read the same live tokens (`hw:bg-card`, `hw:w-sidebar`, `hw:p-4` for the prefix `hw`). +`document.documentElement.dataset.subNavigation = 'side'` moves the account and server +sub-navigation into a sidebar. The console and the `theme-color` meta re-read their tokens +when a stylesheet or an inline property on `` changes; `onThemeChange(listener)` gives +canvas or chart code the same signal, `readThemeToken('--name')` reads a value, and +`notifyThemeChange()` reports changes made through the CSSOM. Only the panel's own +`theme-color` tag follows the token; one registered with `registerHeadTags` is left as rendered. + +## Conditional screens, badges, and icons + +A screen's `when` states where it exists. A screen whose conditions fail is absent from +navigation and not routable: its URL shows the panel's not-found page. + +```json +{ + "id": "mods", + "area": "server", + "path": "mods", + "nav": { "label": "Mods", "icon": "blocks", "badge": "Beta" }, + "when": { + "eggTags": { "any": ["minecraft"] }, + "eggFeatures": { "any": ["eula"] }, + "match": "any" + } +} +``` + +`eggFeatures` and `eggTags` are for `server` screens. Each takes `all` (every value +present) and/or `any` (at least one), compared without regard to case against the +server's `egg_features` and `egg_tags`. With both declared they must both pass unless +`match` is `"any"`. These rules come from the manifest and the server payload, so they +apply before your bundle has loaded. Egg ids are deliberately not matchable: they differ +between installations, so decide those cases at runtime from your own configuration. + +For anything the manifest cannot express, declare `"when": { "runtime": true }` (any +area, alone or beside egg rules) and pass a predicate when registering the screen: + +```tsx +function useHasDomains({ server }: ScreenContext) { + return useSuspenseQuery(domainsQueryOptions(server!.attributes.uuid)).data.length > 0; +} + +// The third argument is a ScreenOptions object. +screens.register('subdomains', () => import('./SubdomainsScreen'), { + visible: useHasDomains, + badge: ({ config }) => (config.maintenance === true ? 'Paused' : undefined), +}); +``` + +`visible` and `badge` receive a `ScreenContext` (`user`, `config`, the `server` on server +screens, the `resource` on admin resource tabs) and are called while rendering their own +isolated mount, so they may use hooks and suspend; name them `use…` when they do. They +re-run whenever that data changes. A predicate that throws hides the screen, a badge that +throws leaves the manifest badge in place, and both are reported against your extension +without disturbing the rest of the navigation. + +A `runtime` screen stays hidden until its bundle has loaded and the predicate has +returned `true`, and its URL shows a spinner in the meantime; entries are never listed +first and withdrawn later. That is why the flag lives in the manifest: registering +`visible` for a screen without it, or omitting `visible` for a screen with it, fails the +extension at load. Egg rules are checked first, so a predicate only runs where they pass. + +`badge` needs no manifest flag. Return a string or number to show it (32 characters at +most), `null` or `''` for no badge, and `undefined` to keep `nav.badge`, which also shows +while the bundle loads or the badge suspends. + +`nav.icon` accepts any [lucide](https://lucide.dev/icons) icon name in kebab-case, such +as `life-buoy`. The names this panel ships are listed in `@pterodactyl/sdk/icons.json`; +a name outside that list renders the default icon and is reported by +`p:extension:doctor`. `` renders the same icons from the +panel's copy of lucide, so an icon chosen as data (a setting, an API field) does not +require bundling the icon set; `loadIconNames()` resolves the available names for a +picker. Common names render immediately; the rest of the set is one lazily fetched chunk +shared by every extension. Keep importing icons you reference in code from +`lucide-react` and pass them to ``. + +## Author tooling and configuration + +Use `p:extension:doctor `, `p:extension:dev --watch`, and +`p:extension:pack ` for preflight checks, successful-build publishing with browser reload in debug mode, and +runtime-only archives. Scaffolds include tests, CI, OpenAPI generation, and styling. +`@pterodactyl/sdk/testing` supplies `createExtensionTestHost` and `createTestServer`; +`@pterodactyl/sdk/vitest` supplies aliases and setup for the real runtime. Unmount the +wrapper and dispose the host after each test. The test host shares the real cache; +create one host at a time within a test environment. + +Declare `requires.panel`, `requires.sdk`, `requires.php`, and `requires.extensions` as Composer-style +version constraints in the manifest. Incompatible extensions and dependency cycles +fail independently. Activation validates the build and runs migrations before enabling +metadata. Upgrades retain old asset chunks for open sessions. Failed activation restores +the previous package and asset pointer; partially applied database migrations need manual +recovery. Successful lifecycle changes invalidate routes and signal queue worker restarts; +reload the page to replace already evaluated frontend code. + +Backend settings support `forUser($user)` and `forServer($server)`. Mark secrets with +`->secret()` to encrypt storage, mask admin output, and prohibit frontend exposure; +a password control alone does not enable encryption. Empty secret updates preserve the +stored value. `->frontend()->frontendType('boolean')` declares and verifies a public +value's type. `p:extension:types ` generates literal screen ids, registered permissions, and public config +keys. `defineConfiguredExtension` accepts a parser for runtime configuration and these +generated types. Undeclared value types remain bounded JSON. + +Frontend values reach signed-in users only. `->frontend()->public()` also delivers a +value to visitors who are not signed in (the login page), so use it only for values +anyone may read; `public()` requires `frontend()` and cannot be combined with +`secret()`. Generated types add `ExtensionPublicConfigKey` and `ExtensionPublicConfig` +for the keys a guest receives; every other key is absent until the user signs in and +the page reloads. + +Beyond `text`, `password`, `number`, `toggle`, and `select`, settings have five typed +fields, each validated server-side and rendered by the admin Extensions form: + +- `->color()`: a hex colour (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) or a numeric + `oklch(L C H [/ A])` colour, stored lower case. Nothing else is accepted, so the value + is safe to place in a style rule. Clearing it restores the default. +- `->textarea(maxLength: 5000)`: a multi-line string with normalized line endings. +- `->multiselect($options)`: a list of the declared string or integer option values, in + declaration order. +- `->list(itemRules: ['max:255'], maxItems: 50)`: an ordered list of strings; every item + must pass the item rules. +- `->file(mimes: ExtensionSettingFiles::IMAGES, maxKilobytes: 1024)`: an admin upload. + The type is decided from the content against the allow-list (PNG, JPEG, GIF, WebP and + AVIF by default; ICO, WOFF, WOFF2 and SVG only when listed, and SVG with active + content is refused), the file is stored under a random name on the + `extensions.files_disk` disk, and `get()` and `ctx.config` return its URL under + `/extension-files//` or the default (a URL or `null`). Replacing or clearing a file + deletes the old one; removing the extension deletes them all. Files are uploaded through + `POST`/`DELETE /api/admin/extensions//settings//file`, never through a + settings update. + +These fields imply their `frontendType` (`string` or `array`; a colour or file with a +`null` default stays JSON) and none of them can be `->secret()`. + +`->tab('Storage')` puts a field in a section of the admin form, chosen from a dropdown +above the form; sections appear in the order their first field is defined. Once any +field names a tab, fields without one are shown under "General", which comes first. A +form with no tabbed fields has no dropdown. Sections only group the form: every field is +saved together, and keys and validation are unchanged. + +The package exports `manifest.schema.json` for editor completion. Frontend scaffolds +reference it with `$schema`; the server validates every package before activation. + +Use `ExtensionJobProgress::begin($extensionId, $user, $server, $permission)` to create +a namespaced job snapshot, then `update($extensionId, $id, $percent, $message, $status)` +from workers. User jobs are private to their creator and root admins. Server jobs with +an extension permission are readable by users who still have that permission; otherwise +they remain creator-only. `useExtensionJobProgress(id, { serverUuid })` polls running +jobs, recovers on reconnect, and stops when the job finishes or access expires. Use a +shared cache store for workers and web requests. Snapshots expire after +`extensions.progress_retention_seconds` (one hour by default); they are progress UI, +not a durable job audit log. + +## Backend provider API + +Providers can use `listenToServerOperations` for immutable `provision`, `install`, +`reinstall`, `backup`, `delete`, `suspend`, `unsuspend`, and `transfer` results. Results +dispatch after commit and carry identifiers only (`serverUuid`, `operation`, `successful`, +`resourceUuid`): after `delete` the server row is gone, so key your own data by server +uuid. Provisioning fires only when Wings accepts creation, `delete` also fires when a +failed provisioning is cleaned up, suspension fires only for a change Wings accepted, and +`transfer` reports both outcomes. Listener failures are attributed to the extension. The +`backup completed` websocket event carries the backup's `uuid` in its payload. + +### Wrapping core actions + +`wrapAction($contract, $decorator)` runs extension code around any action contract under +`Pterodactyl\Contracts\` that the panel binds. The decorator receives the implementation that +would otherwise be used and returns an implementation of the same contract: + +```php +$this->wrapAction(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new PurgeDnsRecords($inner, $this->app->make(DnsRecords::class))); + +final class PurgeDnsRecords implements DeletesServers +{ + public function __construct(private readonly DeletesServers $inner, private readonly DnsRecords $dns) {} + + public function withForce(bool $bool = true): self + { + $this->inner->withForce($bool); + + return $this; + } + + public function delete(Server $server): void + { + $serverId = $server->id; + $this->inner->delete($server); + // The core action returned, so the server is gone. Use DB::afterCommit() for + // work that must also wait for a transaction opened by the caller. + DB::afterCommit(fn () => $this->dns->purge($serverId)); + } +} +``` + +The wrapper owns the call: it decides whether and when to invoke the inner action and +must forward fluent options such as `withForce()` itself, returning itself. Whatever it +throws reaches the caller unchanged, and exceptions of the inner action pass through +untouched. A reported exception raised from the extension's package is recorded against +the extension. The decorator is skipped while the extension is disabled or failed to boot; +one that throws or returns another type is recorded and skipped, so the core action always +resolves. Extensions wrap in load order, the last one outermost. + +Resolve the same contracts from the container to call core behaviour instead of +reimplementing it. Beside the mutating actions, these read or complete on your behalf: + +| Contract | Call | +| --- | --- | +| `Contracts\Files\ReadsFileContents` | `read($server, $path, ?int $maxBytes = null): string`, bounded by the panel's editable file size unless a limit is given. | +| `Contracts\Files\ListsDirectories` | `list($server, $directory = '/')`: the directory's `DaemonFileObject` entries. | +| `Contracts\Servers\ReadsServerLogs` | `read($server, $lines = 100)`: recent console lines, oldest first, at most `MAX_LINES`. | +| `Contracts\Servers\ReadsServerState` | `read($server): ServerState`, live state and usage from the cache the client API shares (up to 20 seconds old). | +| `Contracts\Servers\ChangesServerEgg` | `change($server, $egg, keepVariables: false)`: resets startup, image and variables to the new egg, optionally carrying over values whose names and rules still match. | +| `Contracts\Users\CompletesLogins` | `complete($user)` after you verified a first factor (it issues the two-factor checkpoint when the account needs one), `establish($user)` once every factor has passed, and `pendingCheckpoint()`. | + +These actions do not check permissions; authorize the caller first, as the core +controllers do. They can be wrapped like any other action. + +### Commands and scheduled tasks + +`registerCommands([CleanLogsCommand::class])` adds artisan commands and +`registerSchedule(fn (Schedule $schedule) => $schedule->command('logs:clean')->daily())` +defines tasks on the panel's scheduler. Both exist only while the extension is enabled and +booted successfully. Prefix command names with the extension id. A scheduled task that +fails, or a schedule callback that throws, is recorded against the extension; a callback +that throws schedules nothing. + +### Head tags + +`registerHeadTags` adds `` and `` elements to the panel's document head on +the server, for guests and signed-in users alike: + +```php +$this->registerHeadTags(fn (): array => [ + ['tag' => 'link', 'rel' => 'manifest', 'href' => '/extensions/pwa/manifest.webmanifest'], + ['tag' => 'meta', 'name' => 'theme-color', 'content' => $this->settings()->get('theme_color', '#0f172a')], +]); +``` + +Only `meta` (`name` or `property`, `content`, `media`) and `link` (`rel`, `href`, `sizes`, +`type`, `media`, `color`, `crossorigin`, `hreflang`, `title`) exist. `rel` is limited to +`manifest`, icon relations, `alternate`, `canonical`, `search`, `preconnect`, and +`dns-prefetch`; `href` must be an http(s) URL or a path on the panel. Scripts, stylesheets, +inline styles, event handlers, `http-equiv`, and the panel's own `csrf-token`, `viewport`, +`robots`, and `referrer` meta tags are rejected, and values are escaped. An element the +panel also ships (theme color, web app manifest, favicons) replaces the panel's. A static +array is validated when registered and an invalid one fails the extension's boot. A +closure runs when the layout renders and its result is cached for +`extensions.head_tags_cache_seconds` (60 by default); an invalid result is recorded and +contributes nothing. Up to 32 tags per extension. A registered `theme-color` is not +rewritten by the SPA; set the `--theme-color` token instead when the colour belongs to a theme. + +### Root paths + +Routes outside `/extensions/` need a top-level prefix claimed in the manifest: + +```json +{ "routes": { "root": ["go"] } } +``` + +`registerRootRoutes($this->extensionPath('routes', 'root.php'))` mounts the file under +every claimed prefix, or under one with a second argument; undeclared prefixes are +refused. Routes run in the `web` group, are throttled per client +(`extensions.root_routes_per_minute`, 120 by default), are public unless the file adds +auth middleware, and are named `extensions..root..`. A prefix is a +lowercase slug of at most 48 characters, up to eight per extension. Prefixes the panel +uses (its API, SPA and asset paths, the first segment of any core route, anything in the +public directory) are rejected when the manifest is read, and enabling fails while another +enabled extension claims the same prefix. Extension routes, under `/extensions/` or a +claimed prefix, are matched before the SPA's catch-all route. + +## Styling + +The panel and every extension compile their own Tailwind stylesheet, and all of them load +into the same `theme` and `utilities` cascade layers, each sorted on its own. Builds that +share a class name override each other: an extension's `.flex` beats the panel's +`.lg:hidden`, and one extension's `.grid-cols-2` beats another's `.sm:grid-cols-3`. Every +extension therefore builds Tailwind with a prefix of its own, declared in `extension.json`: + +```json +"ui": { "entry": "dist/client.js", "prefix": "hw" } +``` + +`ui.prefix` is 2 to 12 lowercase letters (`^[a-z]{2,12}$`, the only characters Tailwind +accepts). Tailwind variant names (`sm`, `dark`, `hover`, `group`, ...), theme namespaces +(`color`, `text`, ...), the first segment of the panel's custom properties (`terminal`, +`layout`, `tw`, ...) and `panel`, `core`, `ptero` are reserved; `manifest.schema.json` lists +them all. Two enabled extensions cannot share a prefix: install, enable and upgrade fail with +`Extension "b" cannot use Tailwind prefix "hw": enabled extension "a" also declares it.` +`p:extension:make` derives a prefix from the id (`hello-world` gives `hw`) or takes `--prefix`. + +`src/client/styles.css`, imported from the entry, uses the same prefix on both imports: + +```css +@import 'tailwindcss/theme.css' layer(theme) prefix(hw); +@import 'tailwindcss/utilities.css' layer(utilities) prefix(hw); +@import '@pterodactyl/sdk/theme.css'; +@source './**/*.{ts,tsx}'; +``` + +Do not import `tailwindcss` itself or its preflight (the panel already resets the page), and +keep the SDK theme last. It maps the panel's tokens, so utilities resolve to the live values +of the active panel theme: `hw:bg-card` is `var(--card)`, `hw:w-sidebar` is +`var(--layout-sidebar-width)`, `hw:p-4` is `calc(var(--spacing) * 4)`. Only the semantic +colours exist (`hw:bg-card`, `hw:text-muted-foreground`); Tailwind's palette +(`hw:bg-red-500`) is not available. + +The prefix is written once, first, as if it were a variant: + +| Write | Not | | +| --- | --- | --- | +| `hw:flex` | `flex` | An unprefixed class is not in your stylesheet; it only works while the panel happens to emit it. | +| `hw:lg:hover:bg-accent` | `lg:hw:hover:bg-accent` | The prefix comes before every variant. | +| `hw:mt-4!` | `!hw:mt-4` | The important modifier stays at the end. | +| `hw:-mt-2` | `-hw:mt-2` | The minus stays on the utility. | +| `hw:group` with `hw:group-hover:underline` | `group` | `group` and `peer` markers are prefixed too. | +| `@apply hw:flex hw:hover:bg-accent;` | `@apply flex;` | `@apply` takes the same prefixed names. | + +Hand-written classes are yours to name and belong outside the Tailwind layers. `@utility card` +defines `hw:card`, and a `@theme` variable `--color-brand` is emitted as `--hw-color-brand` +and used as `hw:bg-brand`. + +Classes passed to SDK components and to `Default` in a component replacement are merged with +the component's own for the prefix of every enabled extension: ` - - - - - -@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/databases/index.blade.php b/resources/views/admin/databases/index.blade.php deleted file mode 100644 index e4c69c513..000000000 --- a/resources/views/admin/databases/index.blade.php +++ /dev/null @@ -1,130 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Database Hosts -@endsection - -@section('content-header') -

Database HostsDatabase hosts that servers can have databases created on.

- -@endsection - -@section('content') -
-
-
-
-

Host List

-
- -
-
-
- - - - - - - - - - - - @foreach ($hosts as $host) - - - - - - - - - - @endforeach - -
IDNameHostPortUsernameDatabasesNode
{{ $host->id }}{{ $host->name }}{{ $host->host }}{{ $host->port }}{{ $host->username }}{{ $host->databases_count }} - @if(! is_null($host->node)) - {{ $host->node->name }} - @else - None - @endif -
-
-
-
-
- -@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/databases/view.blade.php b/resources/views/admin/databases/view.blade.php deleted file mode 100644 index e105751a0..000000000 --- a/resources/views/admin/databases/view.blade.php +++ /dev/null @@ -1,135 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Database Hosts → View → {{ $host->name }} -@endsection - -@section('content-header') -

{{ $host->name }}Viewing associated databases and details for this database host.

- -@endsection - -@section('content') -
-
-
-
-
-

Host Details

-
-
-
- - -
-
- - -

The IP address or FQDN that should be used when attempting to connect to this MySQL host from the panel to add new databases.

-
-
- - -

The port that MySQL is running on for this host.

-
-
- - -

This setting does nothing other than default to this database host when adding a database to a server on the selected node.

-
-
-
-
-
-
-
-

User Details

-
-
-
- - -

The username of an account that has enough permissions to create new users and databases on the system.

-
-
- - -

The password to the account defined. Leave blank to continue using the assigned password.

-
-
-

The account defined for this database host must have the WITH GRANT OPTION permission. If the defined account does not have this permission requests to create databases will fail. Do not use the same account details for MySQL that you have defined for this panel.

-
- -
-
-
-
-
-
-
-
-

Databases

-
-
- - - - - - - - - - @foreach($databases as $database) - - - - - - @if($database->max_connections != null) - - @else - - @endif - - - @endforeach -
ServerDatabase NameUsernameConnections FromMax Connections
{{ $database->getRelation('server')->name }}{{ $database->database }}{{ $database->username }}{{ $database->remote }}{{ $database->max_connections }}Unlimited - - - -
-
- @if($databases->hasPages()) - - @endif -
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/eggs/new.blade.php b/resources/views/admin/eggs/new.blade.php deleted file mode 100644 index b349751ff..000000000 --- a/resources/views/admin/eggs/new.blade.php +++ /dev/null @@ -1,178 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Nests → New Egg -@endsection - -@section('content-header') -

New EggCreate a new Egg to assign to servers.

- -@endsection - -@section('content') -
-
-
-
-
-

Configuration

-
-
-
-
-
- -
- -

Think of a Nest as a category. You can put multiple Eggs in a nest, but consider putting only Eggs that are related to each other in each Nest.

-
-
-
- - -

A simple, human-readable name to use as an identifier for this Egg. This is what users will see as their game server type.

-
-
- - -

A description of this Egg.

-
-
-
- - -

- Forces all outgoing network traffic to have its Source IP NATed to the IP of the server's primary allocation IP. - Required for certain games to work properly when the Node has multiple public IP addresses. -
- - Enabling this option will disable internal networking for any servers using this egg, - causing them to be unable to internally access other servers on the same node. - -

-
-
-
-
-
- - -

The docker images available to servers using this egg. Enter one per line. Users will be able to select from this list of images if more than one value is provided.

-
-
- - -

The default startup command that should be used for new servers created with this Egg. You can change this per-server as needed.

-
-
- -
- -

Additional features belonging to the egg. Useful for configuring additional panel modifications.

-
-
-
-
-
-
-
-
-
-
-

Process Management

-
-
-
-
-
-

All fields are required unless you select a separate option from the 'Copy Settings From' dropdown, in which case fields may be left blank to use the values from that option.

-
-
-
-
- - -

If you would like to default to settings from another Egg select it from the dropdown above.

-
-
- - -

The command that should be sent to server processes to stop them gracefully. If you need to send a SIGINT you should enter ^C here.

-
-
- - -

This should be a JSON representation of where log files are stored, and whether or not the daemon should be creating custom logs.

-
-
-
-
- - -

This should be a JSON representation of configuration files to modify and what parts should be changed.

-
-
- - -

This should be a JSON representation of what values the daemon should be looking for when booting a server to determine completion.

-
-
-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - {!! Theme::js('vendor/lodash/lodash.js') !!} - -@endsection diff --git a/resources/views/admin/eggs/scripts.blade.php b/resources/views/admin/eggs/scripts.blade.php deleted file mode 100644 index 5bbc9ee3a..000000000 --- a/resources/views/admin/eggs/scripts.blade.php +++ /dev/null @@ -1,118 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Nests → Egg: {{ $egg->name }} → Install Script -@endsection - -@section('content-header') -

{{ $egg->name }}Manage the install script for this Egg.

- -@endsection - -@section('content') - -
-
-
-
-
-

Install Script

-
- @if(! is_null($egg->copyFrom)) -
-
- This service option is copying installation scripts and container options from {{ $egg->copyFrom->name }}. Any changes you make to this script will not apply unless you select "None" from the dropdown box below. -
-
- @endif -
-
{{ $egg->script_install }}
-
-
-
-
- - -

If selected, script above will be ignored and script from selected option will be used in place.

-
-
- - -

Docker container to use when running this script for the server.

-
-
- - -

The entrypoint command to use for this script.

-
-
-
-
- The following service options rely on this script: - @if(count($relyOnScript) > 0) - @foreach($relyOnScript as $rely) - - {{ $rely->name }}@if(!$loop->last), @endif - - @endforeach - @else - none - @endif -
-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - {!! Theme::js('vendor/ace/ace.js') !!} - {!! Theme::js('vendor/ace/ext-modelist.js') !!} - - -@endsection diff --git a/resources/views/admin/eggs/variables.blade.php b/resources/views/admin/eggs/variables.blade.php deleted file mode 100644 index fbc14781e..000000000 --- a/resources/views/admin/eggs/variables.blade.php +++ /dev/null @@ -1,156 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Egg → {{ $egg->name }} → Variables -@endsection - -@section('content-header') -

{{ $egg->name }}Managing variables for this Egg.

- -@endsection - -@section('content') - -
-
- -
-
-
- @foreach($egg->variables as $variable) -
-
-
-

{{ $variable->name }}

-
-
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
-

This variable can be accessed in the startup command by using {{ $variable->env_variable }}.

-
-
-
- - -
-
- - -

These rules are defined using standard Laravel Framework validation rules.

-
-
- -
-
-
- @endforeach -
- -@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/eggs/view.blade.php b/resources/views/admin/eggs/view.blade.php deleted file mode 100644 index 0f1e6521f..000000000 --- a/resources/views/admin/eggs/view.blade.php +++ /dev/null @@ -1,222 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Nests → Egg: {{ $egg->name }} -@endsection - -@section('content-header') -

{{ $egg->name }}{{ str_limit($egg->description, 50) }}

- -@endsection - -@section('content') - -
-
-
-
-
-
-
-
- -
- -

If you would like to replace settings for this Egg by uploading a new JSON file, simply select it here and press "Update Egg". This will not change any existing startup strings or Docker images for existing servers.

-
-
-
-
- {!! csrf_field() !!} - -
-
-
-
-
-
-
-
-
-
-
-
-

Configuration

-
-
-
-
-
- - -

A simple, human-readable name to use as an identifier for this Egg.

-
-
- - -

This is the globally unique identifier for this Egg which the Daemon uses as an identifier.

-
-
- - -

The author of this version of the Egg. Uploading a new Egg configuration from a different author will change this.

-
-
- - -

- The docker images available to servers using this egg. Enter one per line. Users - will be able to select from this list of images if more than one value is provided. - Optionally, a display name may be provided by prefixing the image with the name - followed by a pipe character, and then the image URL. Example: Display Name|ghcr.io/my/egg -

-
-
-
- force_outgoing_ip) checked @endif /> - -

- Forces all outgoing network traffic to have its Source IP NATed to the IP of the server's primary allocation IP. - Required for certain games to work properly when the Node has multiple public IP addresses. -
- - Enabling this option will disable internal networking for any servers using this egg, - causing them to be unable to internally access other servers on the same node. - -

-
-
- -
-
-
- - -

A description of this Egg that will be displayed throughout the Panel as needed.

-
-
- - -

The default startup command that should be used for new servers using this Egg.

-
-
- -
- -

Additional features belonging to the egg. Useful for configuring additional panel modifications.

-
-
-
-
-
-
-
-
-
-
-

Process Management

-
-
-
-
-
-

The following configuration options should not be edited unless you understand how this system works. If wrongly modified it is possible for the daemon to break.

-

All fields are required unless you select a separate option from the 'Copy Settings From' dropdown, in which case fields may be left blank to use the values from that Egg.

-
-
-
-
- - -

If you would like to default to settings from another Egg select it from the menu above.

-
-
- - -

The command that should be sent to server processes to stop them gracefully. If you need to send a SIGINT you should enter ^C here.

-
-
- - -

This should be a JSON representation of where log files are stored, and whether or not the daemon should be creating custom logs.

-
-
-
-
- - -

This should be a JSON representation of configuration files to modify and what parts should be changed.

-
-
- - -

This should be a JSON representation of what values the daemon should be looking for when booting a server to determine completion.

-
-
-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/index.blade.php b/resources/views/admin/index.blade.php deleted file mode 100644 index 817766e09..000000000 --- a/resources/views/admin/index.blade.php +++ /dev/null @@ -1,53 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Administration -@endsection - -@section('content-header') -

Administrative OverviewA quick glance at your system.

- -@endsection - -@section('content') -
-
-
-
-

System Information

-
-
- @if ($version->isLatestPanel()) - You are running Pterodactyl Panel version {{ config('app.version') }}. Your panel is up-to-date! - @else - Your panel is not up-to-date! The latest version is {{ $version->getPanel() }} and you are currently running version {{ config('app.version') }}. - @endif -
-
-
-
- -@endsection diff --git a/resources/views/admin/locations/index.blade.php b/resources/views/admin/locations/index.blade.php deleted file mode 100644 index c54ffe0fa..000000000 --- a/resources/views/admin/locations/index.blade.php +++ /dev/null @@ -1,81 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Locations -@endsection - -@section('content-header') -

LocationsAll locations that nodes can be assigned to for easier categorization.

- -@endsection - -@section('content') -
-
-
-
-

Location List

-
- -
-
-
- - - - - - - - - - @foreach ($locations as $location) - - - - - - - - @endforeach - -
IDShort CodeDescriptionNodesServers
{{ $location->id }}{{ $location->short }}{{ $location->long }}{{ $location->nodes_count }}{{ $location->servers_count }}
-
-
-
-
- -@endsection diff --git a/resources/views/admin/locations/view.blade.php b/resources/views/admin/locations/view.blade.php deleted file mode 100644 index f34dcf3f5..000000000 --- a/resources/views/admin/locations/view.blade.php +++ /dev/null @@ -1,69 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Locations → View → {{ $location->short }} -@endsection - -@section('content-header') -

{{ $location->short }}{{ str_limit($location->long, 75) }}

- -@endsection - -@section('content') -
-
-
-
-

Location Details

-
-
-
-
- - -
-
- - -
-
- -
-
-
-
-
-
-

Nodes

-
-
- - - - - - - - @foreach($location->nodes as $node) - - - - - - - @endforeach -
IDNameFQDNServers
{{ $node->id }}{{ $node->name }}{{ $node->fqdn }}{{ $node->servers->count() }}
-
-
-
-
-@endsection diff --git a/resources/views/admin/mounts/index.blade.php b/resources/views/admin/mounts/index.blade.php deleted file mode 100644 index a3b989243..000000000 --- a/resources/views/admin/mounts/index.blade.php +++ /dev/null @@ -1,144 +0,0 @@ - -@extends('layouts.admin') - -@section('title') - Mounts -@endsection - -@section('content-header') -

MountsConfigure and manage additional mount points for servers.

- -@endsection - -@section('content') -
-
-
-
-

Mount List

- -
- -
-
- -
- - - - - - - - - - - - - @foreach ($mounts as $mount) - - - - - - - - - - @endforeach - -
IDNameSourceTargetEggsNodesServers
{{ $mount->id }}{{ $mount->name }}{{ $mount->source }}{{ $mount->target }}{{ $mount->eggs_count }}{{ $mount->nodes_count }}{{ $mount->servers_count }}
-
-
-
-
- - -@endsection diff --git a/resources/views/admin/mounts/view.blade.php b/resources/views/admin/mounts/view.blade.php deleted file mode 100644 index 96a156d24..000000000 --- a/resources/views/admin/mounts/view.blade.php +++ /dev/null @@ -1,314 +0,0 @@ - -@extends('layouts.admin') - -@section('title') - Mounts → View → {{ $mount->id }} -@endsection - -@section('content-header') -

{{ $mount->name }}{{ str_limit($mount->description, 75) }}

- -@endsection - -@section('content') -
-
-
-
-

Mount Details

-
- -
-
-
- - -
- -
- - -
- -
- - -
- -
-
- - -
- -
- - -
-
- -
-
- - -
-
- read_only) checked @endif> - -
- -
- read_only) checked @endif> - -
-
-
- -
- - -
-
- user_mountable) checked @endif> - -
- -
- user_mountable) checked @endif> - -
-
-
-
-
- - -
-
-
- -
-
-
-

Eggs

- -
- -
-
- -
- - - - - - - - @foreach ($mount->eggs as $egg) - - - - - - @endforeach -
IDName
{{ $egg->id }}{{ $egg->name }} - -
-
-
- -
-
-

Nodes

- -
- -
-
- -
- - - - - - - - - @foreach ($mount->nodes as $node) - - - - - - - @endforeach -
IDNameFQDN
{{ $node->id }}{{ $node->name }}{{ $node->fqdn }} - -
-
-
-
-
- - - - -@endsection - -@section('footer-scripts') - @parent - - -@endsection diff --git a/resources/views/admin/nests/index.blade.php b/resources/views/admin/nests/index.blade.php deleted file mode 100644 index 4bb6ae784..000000000 --- a/resources/views/admin/nests/index.blade.php +++ /dev/null @@ -1,102 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Nests -@endsection - -@section('content-header') -

NestsAll nests currently available on this system.

- -@endsection - -@section('content') -
-
-
- Eggs are a powerful feature of Pterodactyl Panel that allow for extreme flexibility and configuration. Please note that while powerful, modifying an egg wrongly can very easily brick your servers and cause more problems. Please avoid editing our default eggs — those provided by support@pterodactyl.io — unless you are absolutely sure of what you are doing. -
-
-
-
-
-
-
-

Configured Nests

- -
-
- - - - - - - - - @foreach($nests as $nest) - - - - - - - - @endforeach -
IDNameDescriptionEggsServers
{{ $nest->id }}{{ $nest->name }}{{ $nest->description }}{{ $nest->eggs_count }}{{ $nest->servers_count }}
-
-
-
-
- -@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/nests/new.blade.php b/resources/views/admin/nests/new.blade.php deleted file mode 100644 index 9a1cb0edc..000000000 --- a/resources/views/admin/nests/new.blade.php +++ /dev/null @@ -1,47 +0,0 @@ -@extends('layouts.admin') - -@section('title') - New Nest -@endsection - -@section('content-header') -

New NestConfigure a new nest to deploy to all nodes.

- -@endsection - -@section('content') -
-
-
-
-
-

New Nest

-
-
-
- -
- -

This should be a descriptive category name that encompasses all of the eggs within the nest.

-
-
-
- -
- -
-
-
- -
-
-
-
-@endsection diff --git a/resources/views/admin/nests/view.blade.php b/resources/views/admin/nests/view.blade.php deleted file mode 100644 index 9a6730746..000000000 --- a/resources/views/admin/nests/view.blade.php +++ /dev/null @@ -1,117 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Nests → {{ $nest->name }} -@endsection - -@section('content-header') -

{{ $nest->name }}{{ str_limit($nest->description, 50) }}

- -@endsection - -@section('content') -
-
-
-
-
-
- -
- -

This should be a descriptive category name that encompasses all of the options within the service.

-
-
-
- -
- -
-
-
- -
-
-
-
-
-
-
- -
- -

A unique ID used for identification of this nest internally and through the API.

-
-
-
- -
- -

The author of this service option. Please direct questions and issues to them unless this is an official option authored by support@pterodactyl.io.

-
-
-
- -
- -

A UUID that all servers using this option are assigned for identification purposes.

-
-
-
-
-
-
-
-
-
-
-

Nest Eggs

-
-
- - - - - - - - - @foreach($nest->eggs as $egg) - - - - - - - - @endforeach -
IDNameDescriptionServers
{{ $egg->id }}{{ $egg->name }}{{ $egg->description }}{{ $egg->servers->count() }} - -
-
- -
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/nodes/index.blade.php b/resources/views/admin/nodes/index.blade.php deleted file mode 100644 index 3b3a3fa48..000000000 --- a/resources/views/admin/nodes/index.blade.php +++ /dev/null @@ -1,107 +0,0 @@ -@extends('layouts.admin') - -@section('title') - List Nodes -@endsection - -@section('scripts') - @parent - {!! Theme::css('vendor/fontawesome/animation.min.css') !!} -@endsection - -@section('content-header') -

NodesAll nodes available on the system.

- -@endsection - -@section('content') -
-
-
-
-

Node List

-
-
-
- -
- - -
-
-
-
-
-
- - - - - - - - - - - - - @foreach ($nodes as $node) - - - - - - - - - - - @endforeach - -
NameLocationMemoryDiskServersSSLPublic
{!! $node->maintenance_mode ? ' ' : '' !!}{{ $node->name }}{{ $node->location->short }}{{ $node->memory }} MiB{{ $node->disk }} MiB{{ $node->servers_count }}
-
- @if($nodes->hasPages()) - - @endif -
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/nodes/new.blade.php b/resources/views/admin/nodes/new.blade.php deleted file mode 100644 index b10d08a76..000000000 --- a/resources/views/admin/nodes/new.blade.php +++ /dev/null @@ -1,175 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Nodes → New -@endsection - -@section('content-header') -

New NodeCreate a new local or remote node for servers to be installed to.

- -@endsection - -@section('content') -
-
-
-
-
-

Basic Details

-
-
-
- - -

Character limits: a-zA-Z0-9_.- and [Space] (min 1, max 100 characters).

-
-
- - -
-
- - -
-
- -
-
- - - -
-
- - -
-
-

By setting a node to private you will be denying the ability to auto-deploy to this node. -

-
- - -

Please enter domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may be used only if you are not using SSL for this node.

-
-
- -
-
- - -
-
- isSecure()) disabled @endif> - -
-
- @if(request()->isSecure()) -

Your Panel is currently configured to use a secure connection. In order for browsers to connect to your node it must use a SSL connection.

- @else -

In most cases you should select to use a SSL connection. If using an IP Address or you do not wish to use SSL at all, select a HTTP connection.

- @endif -
-
- -
-
- - -
-
- - -
-
-

If you are running the daemon behind a proxy such as Cloudflare, select this to have the daemon skip looking for certificates on boot.

-
-
-
-
-
-
-
-

Configuration

-
-
-
-
- - -

Enter the directory where server files should be stored. If you use OVH you should check your partition scheme. You may need to use /home/daemon-data to have enough space.

-
-
- -
- - MiB -
-
-
- -
- - % -
-
-
-

Enter the total amount of memory available for new servers. If you would like to allow overallocation of memory enter the percentage that you want to allow. To disable checking for overallocation enter -1 into the field. Entering 0 will prevent creating new servers if it would put the node over the limit.

-
-
-
-
- -
- - MiB -
-
-
- -
- - % -
-
-
-

Enter the total amount of disk space available for new servers. If you would like to allow overallocation of disk space enter the percentage that you want to allow. To disable checking for overallocation enter -1 into the field. Entering 0 will prevent creating new servers if it would put the node over the limit.

-
-
-
-
- - -
-
- - -
-
-

The daemon runs its own SFTP management container and does not use the SSHd process on the main physical server. Do not use the same port that you have assigned for your physical server's SSH process. If you will be running the daemon behind CloudFlare® you should set the daemon port to 8443 to allow websocket proxying over SSL.

-
-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/nodes/view/allocation.blade.php b/resources/views/admin/nodes/view/allocation.blade.php deleted file mode 100644 index 396428b61..000000000 --- a/resources/views/admin/nodes/view/allocation.blade.php +++ /dev/null @@ -1,356 +0,0 @@ -@extends('layouts.admin') - -@section('title') - {{ $node->name }}: Allocations -@endsection - -@section('content-header') -

{{ $node->name }}Control allocations available for servers on this node.

- -@endsection - -@section('content') -
- -
-
-
-
-
-

Existing Allocations

-
-
- - - - - - - - - - @foreach($node->allocations as $allocation) - - - - - - - - - @endforeach -
- - IP Address IP AliasPortAssigned To - -
- @if(is_null($allocation->server_id)) - - @else - - @endif - {{ $allocation->ip }} - - - {{ $allocation->port }} - @if(! is_null($allocation->server)) - {{ $allocation->server->name }} - @endif - - @if(is_null($allocation->server_id)) - - @endif -
-
- @if($node->allocations->hasPages()) - - @endif -
-
-
-
-
-
-

Assign New Allocations

-
-
-
- -
- -

Enter an IP address to assign ports to here.

-
-
-
- -
- -

If you would like to assign a default alias to these allocations enter it here.

-
-
-
- -
- -

Enter individual ports or port ranges here separated by commas or spaces.

-
-
-
- -
-
-
-
- -@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/nodes/view/configuration.blade.php b/resources/views/admin/nodes/view/configuration.blade.php deleted file mode 100644 index 1bbf15f33..000000000 --- a/resources/views/admin/nodes/view/configuration.blade.php +++ /dev/null @@ -1,88 +0,0 @@ -@extends('layouts.admin') - -@section('title') - {{ $node->name }}: Configuration -@endsection - -@section('content-header') -

{{ $node->name }}Your daemon configuration file.

- -@endsection - -@section('content') -
- -
-
-
-
-
-

Configuration File

-
-
-
{{ $node->getYamlConfiguration() }}
-
- -
-
-
-
-
-

Auto-Deploy

-
-
-

- Use the button below to generate a custom deployment command that can be used to configure - wings on the target server with a single command. -

-
- -
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/nodes/view/index.blade.php b/resources/views/admin/nodes/view/index.blade.php deleted file mode 100644 index defa0d366..000000000 --- a/resources/views/admin/nodes/view/index.blade.php +++ /dev/null @@ -1,170 +0,0 @@ -@extends('layouts.admin') - -@section('title') - {{ $node->name }} -@endsection - -@section('content-header') -

{{ $node->name }}A quick overview of your node.

- -@endsection - -@section('content') -
- -
-
-
-
-
-
-
-

Information

-
-
- - - - - - - - - - - - - -
Daemon Version (Latest: {{ $version->getDaemon() }})
System Information
Total CPU Threads
-
-
-
- @if ($node->description) -
-
-
- Description -
-
-
{{ $node->description }}
-
-
-
- @endif -
-
-
-

Delete Node

-
-
-

Deleting a node is a irreversible action and will immediately remove this node from the panel. There must be no servers associated with this node in order to continue.

-
- -
-
-
-
-
-
-
-

At-a-Glance

-
-
-
- @if($node->maintenance_mode) -
-
- -
- This node is under - Maintenance -
-
-
- @endif -
-
- -
- Disk Space Allocated - {{ $stats['disk']['value'] }} / {{ $stats['disk']['max'] }} MiB -
-
-
-
-
-
-
-
- -
- Memory Allocated - {{ $stats['memory']['value'] }} / {{ $stats['memory']['max'] }} MiB -
-
-
-
-
-
-
-
- -
- Total Servers - {{ $node->servers_count }} -
-
-
-
-
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/nodes/view/servers.blade.php b/resources/views/admin/nodes/view/servers.blade.php deleted file mode 100644 index f718f0acc..000000000 --- a/resources/views/admin/nodes/view/servers.blade.php +++ /dev/null @@ -1,63 +0,0 @@ -@extends('layouts.admin') - -@section('title') - {{ $node->name }}: Servers -@endsection - -@section('content-header') -

{{ $node->name }}All servers currently assigned to this node.

- -@endsection - -@section('content') -
- -
-
-
-
-
-

Server List

-
-
- - - - - - - - @foreach($servers as $server) - - - - - - - @endforeach -
IDServer NameOwnerService
{{ $server->uuidShort }}{{ $server->name }}{{ $server->user->username }}{{ $server->nest->name }} ({{ $server->egg->name }})
- @if($servers->hasPages()) - - @endif -
-
-
-
-@endsection diff --git a/resources/views/admin/nodes/view/settings.blade.php b/resources/views/admin/nodes/view/settings.blade.php deleted file mode 100644 index b5ca47688..000000000 --- a/resources/views/admin/nodes/view/settings.blade.php +++ /dev/null @@ -1,240 +0,0 @@ -@extends('layouts.admin') - -@section('title') - {{ $node->name }}: Settings -@endsection - -@section('content-header') -

{{ $node->name }}Configure your node settings.

- -@endsection - -@section('content') -
- -
-
-
-
-
-
-

Settings

-
-
-
- -
- -

Character limits: a-zA-Z0-9_.- and [Space] (min 1, max 100 characters).

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- public)) ? 'checked' : '' }} id="public_1" checked>
- public)) ? '' : 'checked' }} id="public_0"> -
-
-
- -
- -
-

Please enter domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node. - Why? -

-
-
- -
-
- scheme) === 'https') ? 'checked' : '' }}> - -
-
- scheme) !== 'https') ? 'checked' : '' }}> - -
-
-

In most cases you should select to use a SSL connection. If using an IP Address or you do not wish to use SSL at all, select a HTTP connection.

-
-
- -
-
- behind_proxy) == false) ? 'checked' : '' }}> - -
-
- behind_proxy) == true) ? 'checked' : '' }}> - -
-
-

If you are running the daemon behind a proxy such as Cloudflare, select this to have the daemon skip looking for certificates on boot.

-
-
- -
-
- maintenance_mode) == false) ? 'checked' : '' }}> - -
-
- maintenance_mode) == true) ? 'checked' : '' }}> - -
-
-

If the node is marked as 'Under Maintenance' users won't be able to access servers that are on this node.

-
-
-
-
-
-
-
-

Allocation Limits

-
-
-
-
-
- -
- - MiB -
-
-
- -
- - % -
-
-
-

Enter the total amount of memory available on this node for allocation to servers. You may also provide a percentage that can allow allocation of more than the defined memory.

-
-
-
-
- -
- - MiB -
-
-
- -
- - % -
-
-
-

Enter the total amount of disk space available on this node for server allocation. You may also provide a percentage that will determine the amount of disk space over the set limit to allow.

-
-
-
-
-
-
-
-

General Configuration

-
-
-
- -
- - MiB -
-

Enter the maximum size of files that can be uploaded through the web-based file manager.

-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
-
-

The daemon runs its own SFTP management container and does not use the SSHd process on the main physical server. Do not use the same port that you have assigned for your physical server's SSH process.

-
-
-
-
-
-
-
-
-
-

Save Settings

-
-
-
-
- -
-

Resetting the daemon master key will void any request coming from the old key. This key is used for all sensitive operations on the daemon including server creation and deletion. We suggest changing this key regularly for security.

-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/servers/index.blade.php b/resources/views/admin/servers/index.blade.php deleted file mode 100644 index 4d5ebcdcd..000000000 --- a/resources/views/admin/servers/index.blade.php +++ /dev/null @@ -1,89 +0,0 @@ -@extends('layouts.admin') - -@section('title') - List Servers -@endsection - -@section('content-header') -

ServersAll servers available on the system.

- -@endsection - -@section('content') -
-
-
-
-

Server List

-
-
-
- -
- - -
-
-
-
-
-
- - - - - - - - - - - - @foreach ($servers as $server) - - - - - - - - - - @endforeach - -
Server NameUUIDOwnerNodeConnection
{{ $server->name }}{{ $server->uuid }}{{ $server->user->username }}{{ $server->node->name }} - {{ $server->allocation->alias }}:{{ $server->allocation->port }} - - @if($server->isSuspended()) - Suspended - @elseif(! $server->isInstalled()) - Installing - @else - Active - @endif - - -
-
- @if($servers->hasPages()) - - @endif -
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/servers/new.blade.php b/resources/views/admin/servers/new.blade.php deleted file mode 100644 index 4198634f1..000000000 --- a/resources/views/admin/servers/new.blade.php +++ /dev/null @@ -1,395 +0,0 @@ -@extends('layouts.admin') - -@section('title') - New Server -@endsection - -@section('content-header') -

Create ServerAdd a new server to the panel.

- -@endsection - -@section('content') -
-
-
-
-
-

Core Details

-
- -
-
-
- - -

Character limits: a-z A-Z 0-9 _ - . and [Space].

-
- -
- - -

Email address of the Server Owner.

-
-
- -
-
- - -

A brief description of this server.

-
- -
-
- - -
-
-
-
-
-
-
- -
-
-
- -
-

Allocation Management

-
- -
-
- - - -

The node which this server will be deployed to.

-
- -
- - -

The main allocation that will be assigned to this server.

-
- -
- - -

Additional allocations to assign to this server on creation.

-
-
-
-
-
- -
-
-
- -
-

Application Feature Limits

-
- -
-
- -
- -
-

The total number of databases a user is allowed to create for this server.

-
-
- -
- -
-

The total number of allocations a user is allowed to create for this server.

-
-
- -
- -
-

The total number of backups that can be created for this server.

-
-
-
-
-
-
-
-
-
-

Resource Management

-
- -
-
- - -
- - % -
- -

If you do not want to limit CPU usage, set the value to 0. To determine a value, take the number of threads and multiply it by 100. For example, on a quad core system without hyperthreading (4 * 100 = 400) there is 400% available. To limit a server to using half of a single thread, you would set the value to 50. To allow a server to use up to two threads, set the value to 200.

-

- -
- - -
- -
- -

Advanced: Enter the specific CPU threads that this process can run on, or leave blank to allow all threads. This can be a single number, or a comma separated list. Example: 0, 0-1,3, or 0,1,3,4.

-
-
- -
-
- - -
- - MiB -
- -

The maximum amount of memory allowed for this container. Setting this to 0 will allow unlimited memory in a container.

-
- -
- - -
- - MiB -
- -

Setting this to 0 will disable swap space on this server. Setting to -1 will allow unlimited swap.

-
-
- -
-
- - -
- - MiB -
- -

This server will not be allowed to boot if it is using more than this amount of space. If a server goes over this limit while running it will be safely stopped and locked until enough space is available. Set to 0 to allow unlimited disk usage.

-
- -
- - -
- -
- -

Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10 and 1000. Please see this documentation for more information about it.

-
-
-
- - -
- -

Terminates the server if it breaches the memory limits. Enabling OOM killer may cause server processes to exit unexpectedly.

-
-
-
-
-
- -
-
-
-
-

Nest Configuration

-
- -
-
- - - - -

Select the Nest that this server will be grouped under.

-
- -
- - -

Select the Egg that will define how this server should operate.

-
-
-
- - -
- -

If the selected Egg has an install script attached to it, the script will run during the install. If you would like to skip this step, check this box.

-
-
-
-
- -
-
-
-

Docker Configuration

-
- -
-
- - - -

This is the default Docker image that will be used to run this server. Select an image from the dropdown above, or enter a custom image in the text field above.

-
-
-
-
-
- -
-
-
-
-

Startup Configuration

-
- -
-
- - -

The following data substitutes are available for the startup command: @{{SERVER_MEMORY}}, @{{SERVER_IP}}, and @{{SERVER_PORT}}. They will be replaced with the allocated memory, server IP, and server port respectively.

-
-
- -
-

Service Variables

-
- -
- - -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - {!! Theme::js('vendor/lodash/lodash.js') !!} - - - - {!! Theme::js('js/admin/new-server.js?v=20220530') !!} - - -@endsection diff --git a/resources/views/admin/servers/partials/navigation.blade.php b/resources/views/admin/servers/partials/navigation.blade.php deleted file mode 100644 index 964eac8e3..000000000 --- a/resources/views/admin/servers/partials/navigation.blade.php +++ /dev/null @@ -1,40 +0,0 @@ -@php - /** @var \Pterodactyl\Models\Server $server */ - $router = app('router'); -@endphp -
-
- -
-
diff --git a/resources/views/admin/servers/view/build.blade.php b/resources/views/admin/servers/view/build.blade.php deleted file mode 100644 index 655ea36af..000000000 --- a/resources/views/admin/servers/view/build.blade.php +++ /dev/null @@ -1,187 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }}: Build Details -@endsection - -@section('content-header') -

{{ $server->name }}Control allocations and system resources for this server.

- -@endsection - -@section('content') -@include('admin.servers.partials.navigation') -
-
-
-
-
-

Resource Management

-
-
-
- -
- - % -
-

Each virtual core (thread) on the system is considered to be 100%. Setting this value to 0 will allow a server to use CPU time without restrictions.

-
-
- -
- -
-

Advanced: Enter the specific CPU cores that this process can run on, or leave blank to allow all cores. This can be a single number, or a comma seperated list. Example: 0, 0-1,3, or 0,1,3,4.

-
-
- -
- - MiB -
-

The maximum amount of memory allowed for this container. Setting this to 0 will allow unlimited memory in a container.

-
-
- -
- - MiB -
-

Setting this to 0 will disable swap space on this server. Setting to -1 will allow unlimited swap.

-
-
- -
- - MiB -
-

This server will not be allowed to boot if it is using more than this amount of space. If a server goes over this limit while running it will be safely stopped and locked until enough space is available. Set to 0 to allow unlimited disk usage.

-
-
- -
- -
-

Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10 and 1000.

-
-
- -
-
- oom_disabled)checked @endif> - -
-
- oom_disabled)checked @endif> - -
-

- Enabling OOM killer may cause server processes to exit unexpectedly. -

-
-
-
-
-
-
-
-
-
-
-

Application Feature Limits

-
-
-
-
- -
- -
-

The total number of databases a user is allowed to create for this server.

-
-
- -
- -
-

The total number of allocations a user is allowed to create for this server.

-
-
- -
- -
-

The total number of backups that can be created for this server.

-
-
-
-
-
-
-
-
-

Allocation Management

-
-
-
- - -

The default connection address that will be used for this game server.

-
-
- -
- -
-

Please note that due to software limitations you cannot assign identical ports on different IPs to the same server.

-
-
- -
- -
-

Simply select which ports you would like to remove from the list above. If you want to assign a port on a different IP that is already in use you can select it from the left and delete it here.

-
-
- -
-
-
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/servers/view/database.blade.php b/resources/views/admin/servers/view/database.blade.php deleted file mode 100644 index 385ce0f3f..000000000 --- a/resources/views/admin/servers/view/database.blade.php +++ /dev/null @@ -1,169 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }}: Databases -@endsection - -@section('content-header') -

{{ $server->name }}Manage server databases.

- -@endsection - -@section('content') -@include('admin.servers.partials.navigation') -
-
-
- Database passwords can be viewed when visiting this server on the front-end. -
-
-
-

Active Databases

-
-
- - - - - - - - - - @foreach($server->databases as $database) - - - - - - @if($database->max_connections != null) - - @else - - @endif - - - @endforeach -
DatabaseUsernameConnections FromHostMax Connections
{{ $database->database }}{{ $database->username }}{{ $database->remote }}{{ $database->host->host }}:{{ $database->host->port }}{{ $database->max_connections }}Unlimited - - -
-
-
-
-
-
-
-

Create New Database

-
-
-
-
- - -

Select the host database server that this database should be created on.

-
-
- -
- s{{ $server->id }}_ - -
-
-
- - -

This should reflect the IP address that connections are allowed from. Uses standard MySQL notation. If unsure leave as %.

-
-
- - -

This should reflect the max number of concurrent connections from this user to the database. Leave empty for unlimited.

-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/servers/view/delete.blade.php b/resources/views/admin/servers/view/delete.blade.php deleted file mode 100644 index c23709632..000000000 --- a/resources/views/admin/servers/view/delete.blade.php +++ /dev/null @@ -1,91 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }}: Delete -@endsection - -@section('content-header') -

{{ $server->name }}Delete this server from the panel.

- -@endsection - -@section('content') -@include('admin.servers.partials.navigation') -
-
-
-
-

Safely Delete Server

-
-
-

This action will attempt to delete the server from both the panel and daemon. If either one reports an error the action will be cancelled.

-

Deleting a server is an irreversible action. All server data (including files and users) will be removed from the system.

-
- -
-
-
-
-
-

Force Delete Server

-
-
-

This action will attempt to delete the server from both the panel and daemon. If the daemon does not respond, or reports an error the deletion will continue.

-

Deleting a server is an irreversible action. All server data (including files and users) will be removed from the system. This method may leave dangling files on your daemon if it reports an error.

-
- -
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/servers/view/details.blade.php b/resources/views/admin/servers/view/details.blade.php deleted file mode 100644 index 9b4464b2c..000000000 --- a/resources/views/admin/servers/view/details.blade.php +++ /dev/null @@ -1,121 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }}: Details -@endsection - -@section('content-header') -

{{ $server->name }}Edit details for this server including owner and container.

- -@endsection - -@section('content') -@include('admin.servers.partials.navigation') -
-
-
-
-

Base Information

-
-
-
-
- - -

Character limits: a-zA-Z0-9_- and [Space].

-
-
- - -

Leave empty to not assign an external identifier for this server. The external ID should be unique to this server and not be in use by any other servers.

-
-
- - -

You can change the owner of this server by changing this field to an email matching another use on this system. If you do this a new daemon security token will be generated automatically.

-
-
- - -

A brief description of this server.

-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/servers/view/index.blade.php b/resources/views/admin/servers/view/index.blade.php deleted file mode 100644 index f94c6d42f..000000000 --- a/resources/views/admin/servers/view/index.blade.php +++ /dev/null @@ -1,178 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }} -@endsection - -@section('content-header') -

{{ $server->name }}{{ str_limit($server->description) }}

- -@endsection - -@section('content') -@include('admin.servers.partials.navigation') -
-
-
-
-
-
-

Information

-
-
- - - - - - - - @if(is_null($server->external_id)) - - @else - - @endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Internal Identifier{{ $server->id }}
External IdentifierNot Set{{ $server->external_id }}
UUID / Docker Container ID{{ $server->uuid }}
Current Egg - {{ $server->nest->name }} :: - {{ $server->egg->name }} -
Server Name{{ $server->name }}
CPU Limit - @if($server->cpu === 0) - Unlimited - @else - {{ $server->cpu }}% - @endif -
CPU Pinning - @if($server->threads != null) - {{ $server->threads }} - @else - Not Set - @endif -
Memory - @if($server->memory === 0) - Unlimited - @else - {{ $server->memory }}MiB - @endif - / - @if($server->swap === 0) - Not Set - @elseif($server->swap === -1) - Unlimited - @else - {{ $server->swap }}MiB - @endif -
Disk Space - @if($server->disk === 0) - Unlimited - @else - {{ $server->disk }}MiB - @endif -
Block IO Weight{{ $server->io }}
Default Connection{{ $server->allocation->ip }}:{{ $server->allocation->port }}
Connection Alias - @if($server->allocation->alias !== $server->allocation->ip) - {{ $server->allocation->alias }}:{{ $server->allocation->port }} - @else - No Alias Assigned - @endif -
-
-
-
-
-
-
-
-
-
- @if($server->isSuspended()) -
-
-
-

Suspended

-
-
-
- @endif - @if(!$server->isInstalled()) -
-
-
-

{{ (! $server->isInstalled()) ? 'Installing' : 'Install Failed' }}

-
-
-
- @endif -
-
-
-

{{ str_limit($server->user->username, 16) }}

-

Server Owner

-
-
- - More info - -
-
-
-
-
-

{{ str_limit($server->node->name, 16) }}

-

Server Node

-
-
- - More info - -
-
-
-
-
-
-
-@endsection diff --git a/resources/views/admin/servers/view/manage.blade.php b/resources/views/admin/servers/view/manage.blade.php deleted file mode 100644 index 5b3dec92e..000000000 --- a/resources/views/admin/servers/view/manage.blade.php +++ /dev/null @@ -1,202 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }}: Manage -@endsection - -@section('content-header') -

{{ $server->name }}Additional actions to control this server.

- -@endsection - -@section('content') - @include('admin.servers.partials.navigation') -
-
-
-
-

Reinstall Server

-
-
-

This will reinstall the server with the assigned service scripts. Danger! This could overwrite server data.

-
- -
-
-
-
-
-

Install Status

-
-
-

If you need to change the install status from uninstalled to installed, or vice versa, you may do so with the button below.

-
- -
-
- - @if(! $server->isSuspended()) -
-
-
-

Suspend Server

-
-
-

This will suspend the server, stop any running processes, and immediately block the user from being able to access their files or otherwise manage the server through the panel or API.

-
- -
-
- @else -
-
-
-

Unsuspend Server

-
-
-

This will unsuspend the server and restore normal user access.

-
- -
-
- @endif - - @if(is_null($server->transfer)) -
-
-
-

Transfer Server

-
-
-

- Transfer this server to another node connected to this panel. - Warning! This feature has not been fully tested and may have bugs. -

-
- - -
-
- @else -
-
-
-

Transfer Server

-
-
-

- This server is currently being transferred to another node. - Transfer was initiated at {{ $server->transfer->created_at }} -

-
- - -
-
- @endif -
- - -@endsection - -@section('footer-scripts') - @parent - {!! Theme::js('vendor/lodash/lodash.js') !!} - - @if($canTransfer) - {!! Theme::js('js/admin/server/transfer.js') !!} - @endif -@endsection diff --git a/resources/views/admin/servers/view/mounts.blade.php b/resources/views/admin/servers/view/mounts.blade.php deleted file mode 100644 index 36ca98ddc..000000000 --- a/resources/views/admin/servers/view/mounts.blade.php +++ /dev/null @@ -1,78 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }}: Mounts -@endsection - -@section('content-header') -

{{ $server->name }}Manage server mounts.

- -@endsection - -@section('content') - @include('admin.servers.partials.navigation') - -
-
-
-
-

Available Mounts

-
- -
- - - - - - - - - - - @foreach ($mounts as $mount) - - - - - - - @if (! in_array($mount->id, $server->mounts->pluck('id')->toArray())) - - - - @else - - - - @endif - - @endforeach -
IDNameSourceTargetStatus
{{ $mount->id }}{{ $mount->name }}{{ $mount->source }}{{ $mount->target }} - Unmounted - -
- {!! csrf_field() !!} - - -
-
- Mounted - -
- @method('DELETE') - {!! csrf_field() !!} - - -
-
-
-
-
-
-@endsection diff --git a/resources/views/admin/servers/view/startup.blade.php b/resources/views/admin/servers/view/startup.blade.php deleted file mode 100644 index f213b194a..000000000 --- a/resources/views/admin/servers/view/startup.blade.php +++ /dev/null @@ -1,192 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Server — {{ $server->name }}: Startup -@endsection - -@section('content-header') -

{{ $server->name }}Control startup command as well as variables.

- -@endsection - -@section('content') -@include('admin.servers.partials.navigation') -
-
-
-
-
-

Startup Command Modification

-
-
- - -

Edit your server's startup command here. The following variables are available by default: @{{SERVER_MEMORY}}, @{{SERVER_IP}}, and @{{SERVER_PORT}}.

-
-
- - -
- -
-
-
-
-
-
-
-

Service Configuration

-
-
-
-

- Changing any of the below values will result in the server processing a re-install command. The server will be stopped and will then proceed. - If you would like the service scripts to not run, ensure the box is checked at the bottom. -

-

- This is a destructive operation in many cases. This server will be stopped immediately in order for this action to proceed. -

-
-
- - -

Select the Nest that this server will be grouped into.

-
-
- - -

Select the Egg that will provide processing data for this server.

-
-
-
- skip_scripts) checked @endif /> - -
-

If the selected Egg has an install script attached to it, the script will run during install. If you would like to skip this step, check this box.

-
-
-
-
-
-

Docker Image Configuration

-
-
-
- - - -

This is the Docker image that will be used to run this server. Select an image from the dropdown or enter a custom image in the text field above.

-
-
-
-
-
-
-
-
-
-@endsection - -@section('footer-scripts') - @parent - {!! Theme::js('vendor/lodash/lodash.js') !!} - -@endsection diff --git a/resources/views/admin/settings/advanced.blade.php b/resources/views/admin/settings/advanced.blade.php deleted file mode 100644 index 0f2056ca4..000000000 --- a/resources/views/admin/settings/advanced.blade.php +++ /dev/null @@ -1,127 +0,0 @@ -@extends('layouts.admin') -@include('partials/admin.settings.nav', ['activeTab' => 'advanced']) - -@section('title') - Advanced Settings -@endsection - -@section('content-header') -

Advanced SettingsConfigure advanced settings for Pterodactyl.

- -@endsection - -@section('content') - @yield('settings::nav') -
-
-
-
-
-

reCAPTCHA

-
-
-
-
- -
- -

If enabled, login forms and password reset forms will do a silent captcha check and display a visible captcha if needed.

-
-
-
- -
- -
-
-
- -
- -

Used for communication between your site and Google. Be sure to keep it a secret.

-
-
-
- @if($showRecaptchaWarning) -
-
-
- You are currently using reCAPTCHA keys that were shipped with this Panel. For improved security it is recommended to generate new invisible reCAPTCHA keys that tied specifically to your website. -
-
-
- @endif -
-
-
-
-

HTTP Connections

-
-
-
-
- -
- -

The amount of time in seconds to wait for a connection to be opened before throwing an error.

-
-
-
- -
- -

The amount of time in seconds to wait for a request to be completed before throwing an error.

-
-
-
-
-
-
-
-

Automatic Allocation Creation

-
-
-
-
- -
- -

If enabled users will have the option to automatically create new allocations for their server via the frontend.

-
-
-
- -
- -

The starting port in the range that can be automatically allocated.

-
-
-
- -
- -

The ending port in the range that can be automatically allocated.

-
-
-
-
-
-
- -
-
-
-
-@endsection diff --git a/resources/views/admin/settings/index.blade.php b/resources/views/admin/settings/index.blade.php deleted file mode 100644 index 489646dc9..000000000 --- a/resources/views/admin/settings/index.blade.php +++ /dev/null @@ -1,75 +0,0 @@ -@extends('layouts.admin') -@include('partials/admin.settings.nav', ['activeTab' => 'basic']) - -@section('title') - Settings -@endsection - -@section('content-header') -

Panel SettingsConfigure Pterodactyl to your liking.

- -@endsection - -@section('content') - @yield('settings::nav') -
-
-
-
-

Panel Settings

-
-
-
-
-
- -
- -

This is the name that is used throughout the panel and in emails sent to clients.

-
-
-
- -
-
- @php - $level = old('pterodactyl:auth:2fa_required', config('pterodactyl.auth.2fa_required')); - @endphp - - - -
-

If enabled, any account falling into the selected grouping will be required to have 2-Factor authentication enabled to use the Panel.

-
-
-
- -
- -

The default language to use when rendering UI components.

-
-
-
-
- -
-
-
-
-@endsection diff --git a/resources/views/admin/settings/mail.blade.php b/resources/views/admin/settings/mail.blade.php deleted file mode 100644 index 9e99acd30..000000000 --- a/resources/views/admin/settings/mail.blade.php +++ /dev/null @@ -1,202 +0,0 @@ -@extends('layouts.admin') -@include('partials/admin.settings.nav', ['activeTab' => 'mail']) - -@section('title') - Mail Settings -@endsection - -@section('content-header') -

Mail SettingsConfigure how Pterodactyl should handle sending emails.

- -@endsection - -@section('content') - @yield('settings::nav') -
-
-
-
-

Email Settings

-
- @if($disabled) -
-
-
-
- This interface is limited to instances using SMTP as the mail driver. Please either use php artisan p:environment:mail command to update your email settings, or set MAIL_DRIVER=smtp in your environment file. -
-
-
-
- @else -
-
-
-
- -
- -

Enter the SMTP server address that mail should be sent through.

-
-
-
- -
- -

Enter the SMTP server port that mail should be sent through.

-
-
-
- -
- @php - $encryption = old('mail:mailers:smtp:encryption', config('mail.mailers.smtp.encryption')); - @endphp - -

Select the type of encryption to use when sending mail.

-
-
-
- -
- -

The username to use when connecting to the SMTP server.

-
-
-
- -
- -

The password to use in conjunction with the SMTP username. Leave blank to continue using the existing password. To set the password to an empty value enter !e into the field.

-
-
-
-
-
-
- -
- -

Enter an email address that all outgoing emails will originate from.

-
-
-
- -
- -

The name that emails should appear to come from.

-
-
-
-
- -
- @endif -
-
-
-@endsection - -@section('footer-scripts') - @parent - - -@endsection diff --git a/resources/views/admin/users/index.blade.php b/resources/views/admin/users/index.blade.php deleted file mode 100644 index 0c8e906c3..000000000 --- a/resources/views/admin/users/index.blade.php +++ /dev/null @@ -1,79 +0,0 @@ -@extends('layouts.admin') - -@section('title') - List Users -@endsection - -@section('content-header') -

UsersAll registered users on the system.

- -@endsection - -@section('content') -
-
-
-
-

User List

-
-
-
- -
- - -
-
-
-
-
-
- - - - - - - - - - - - - - - @foreach ($users as $user) - - - - - - - - - - - @endforeach - -
IDEmailClient NameUsername2FAServers OwnedCan Access
{{ $user->id }}{{ $user->email }} @if($user->root_admin)@endif{{ $user->name_last }}, {{ $user->name_first }}{{ $user->username }} - @if($user->use_totp) - - @else - - @endif - - {{ $user->servers_count }} - {{ $user->subuser_of_count }}
-
- @if($users->hasPages()) - - @endif -
-
-
-@endsection diff --git a/resources/views/admin/users/new.blade.php b/resources/views/admin/users/new.blade.php deleted file mode 100644 index 2ff50164d..000000000 --- a/resources/views/admin/users/new.blade.php +++ /dev/null @@ -1,128 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Create User -@endsection - -@section('content-header') -

Create UserAdd a new user to the system.

- -@endsection - -@section('content') -
-
-
-
-
-

Identity

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -

The default language to use when rendering the Panel for this user.

-
-
-
- -
-
-
-
-
-

Permissions

-
-
-
- -
- -

Setting this to 'Yes' gives a user full administrative access.

-
-
-
-
-
-
-
-
-

Password

-
-
-
-

Providing a user password is optional. New user emails prompt users to create a password the first time they login. If a password is provided here you will need to find a different method of providing it to the user.

-
- -
- -
- -
-
-
-
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/users/view.blade.php b/resources/views/admin/users/view.blade.php deleted file mode 100644 index f2a03329b..000000000 --- a/resources/views/admin/users/view.blade.php +++ /dev/null @@ -1,123 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Manage User: {{ $user->username }} -@endsection - -@section('content-header') -

{{ $user->name_first }} {{ $user->name_last}}{{ $user->username }}

- -@endsection - -@section('content') -
-
-
-
-
-

Identity

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -

The default language to use when rendering the Panel for this user.

-
-
-
- -
-
-
-
-
-

Password

-
-
- -
- -
- -

Leave blank to keep this user's password the same. User will not receive any notification if password is changed.

-
-
-
-
-
-
-
-
-

Permissions

-
-
-
- -
- -

Setting this to 'Yes' gives a user full administrative access.

-
-
-
-
-
-
-
-
-
-

Delete User

-
-
-

There must be no servers associated with this account in order for it to be deleted.

-
- -
-
-
-@endsection diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php deleted file mode 100644 index 20ca084d4..000000000 --- a/resources/views/layouts/admin.blade.php +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - {{ config('app.name', 'Pterodactyl') }} - @yield('title') - - - - - - - - - - - - - @include('layouts.scripts') - - @section('scripts') - {!! Theme::css('vendor/select2/select2.min.css?t={cache-version}') !!} - {!! Theme::css('vendor/bootstrap/bootstrap.min.css?t={cache-version}') !!} - {!! Theme::css('vendor/adminlte/admin.min.css?t={cache-version}') !!} - {!! Theme::css('vendor/adminlte/colors/skin-blue.min.css?t={cache-version}') !!} - {!! Theme::css('vendor/sweetalert/sweetalert.min.css?t={cache-version}') !!} - {!! Theme::css('vendor/animate/animate.min.css?t={cache-version}') !!} - {!! Theme::css('css/pterodactyl.css?t={cache-version}') !!} - - - - - @show - - -
-
- - -
- -
-
- @yield('content-header') -
-
-
-
- @if (count($errors) > 0) -
- There was an error validating the data provided.

-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - @foreach (Alert::getMessages() as $type => $messages) - @foreach ($messages as $message) - - @endforeach - @endforeach -
-
- @yield('content') -
-
-
-
- {{ $appVersion }}
- {{ round(microtime(true) - LARAVEL_START, 3) }}s -
- Copyright © 2015 - {{ date('Y') }} Pterodactyl Software. -
-
- @section('footer-scripts') - - - - {!! Theme::js('vendor/jquery/jquery.min.js?t={cache-version}') !!} - {!! Theme::js('vendor/sweetalert/sweetalert.min.js?t={cache-version}') !!} - {!! Theme::js('vendor/bootstrap/bootstrap.min.js?t={cache-version}') !!} - {!! Theme::js('vendor/slimscroll/jquery.slimscroll.min.js?t={cache-version}') !!} - {!! Theme::js('vendor/adminlte/app.min.js?t={cache-version}') !!} - {!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js?t={cache-version}') !!} - {!! Theme::js('vendor/select2/select2.full.min.js?t={cache-version}') !!} - {!! Theme::js('js/admin/functions.js?t={cache-version}') !!} - - - @if(Auth::user()->root_admin) - - @endif - - - @show - - diff --git a/resources/views/layouts/scripts.blade.php b/resources/views/layouts/scripts.blade.php deleted file mode 100644 index 3393bf5fe..000000000 --- a/resources/views/layouts/scripts.blade.php +++ /dev/null @@ -1 +0,0 @@ -{{-- Just here as a binder for dynamically rendered content. --}} diff --git a/resources/views/partials/admin/settings/nav.blade.php b/resources/views/partials/admin/settings/nav.blade.php deleted file mode 100644 index 9f1ace7f3..000000000 --- a/resources/views/partials/admin/settings/nav.blade.php +++ /dev/null @@ -1,16 +0,0 @@ -@include('partials/admin.settings.notice') - -@section('settings::nav') - @yield('settings::notice') -
-
- -
-
-@endsection diff --git a/resources/views/partials/admin/settings/notice.blade.php b/resources/views/partials/admin/settings/notice.blade.php deleted file mode 100644 index 2dc0bc112..000000000 --- a/resources/views/partials/admin/settings/notice.blade.php +++ /dev/null @@ -1,11 +0,0 @@ -@section('settings::notice') - @if(config('pterodactyl.load_environment_only', false)) -
-
-
- Your Panel is currently configured to read settings from the environment only. You will need to set APP_ENVIRONMENT_ONLY=false in your environment file in order to load settings dynamically. -
-
-
- @endif -@endsection diff --git a/resources/views/partials/schedules/task-template.blade.php b/resources/views/partials/schedules/task-template.blade.php deleted file mode 100644 index efcbbc47e..000000000 --- a/resources/views/partials/schedules/task-template.blade.php +++ /dev/null @@ -1,42 +0,0 @@ -@section('tasks::chain-template') - -@show diff --git a/resources/views/templates/auth/core.blade.php b/resources/views/templates/auth/core.blade.php index 775f3e43a..5ee9c124a 100644 --- a/resources/views/templates/auth/core.blade.php +++ b/resources/views/templates/auth/core.blade.php @@ -1,5 +1,5 @@ @extends('templates/wrapper', [ - 'css' => ['body' => 'bg-neutral-900'] + 'css' => ['body' => 'bg-background'] ]) @section('container') diff --git a/resources/views/templates/base/core.blade.php b/resources/views/templates/base/core.blade.php index 2db9da442..782242610 100644 --- a/resources/views/templates/base/core.blade.php +++ b/resources/views/templates/base/core.blade.php @@ -1,5 +1,5 @@ @extends('templates/wrapper', [ - 'css' => ['body' => 'bg-neutral-800'], + 'css' => ['body' => 'bg-background'], ]) @section('container') diff --git a/resources/views/templates/wrapper.blade.php b/resources/views/templates/wrapper.blade.php index a2d218a53..61782ddec 100644 --- a/resources/views/templates/wrapper.blade.php +++ b/resources/views/templates/wrapper.blade.php @@ -1,5 +1,6 @@ - +{{-- Dark is the shipping theme; the React SPA's semantic tokens key off this class (assets/tailwind.css). --}} + {{ config('app.name', 'Pterodactyl') }} @@ -9,14 +10,33 @@ - - - - - - - - + {{-- An extension that registers one of these elements (registerHeadTags) + replaces the panel's default instead of adding a second one. --}} + @unless ($extensionHead->replaces('link', 'apple-touch-icon')) + + @endunless + @unless ($extensionHead->replaces('link', 'icon')) + + + @endunless + @unless ($extensionHead->replaces('link', 'manifest')) + + @endunless + @unless ($extensionHead->replaces('link', 'mask-icon')) + + @endunless + @unless ($extensionHead->replaces('link', 'shortcut icon')) + + @endunless + @unless ($extensionHead->replaces('meta', 'msapplication-config')) + + @endunless + {{-- data-theme-token: the SPA keeps this tag equal to the --theme-color token. + A theme-color registered by an extension is left exactly as rendered. --}} + @unless ($extensionHead->replaces('meta', 'theme-color')) + + @endunless + {{ $extensionHead }} @show @section('user-data') @@ -33,17 +53,24 @@ @show @yield('assets') - - @include('layouts.scripts') + {!! $asset->cssImports('resources/scripts/index.tsx') !!} + {{-- Applied theme (p:theme:apply): token overrides linked after the app CSS so + the theme's :root/.dark declarations win the cascade at equal specificity. --}} + @if (file_exists(public_path('assets/theme.css'))) + + @endif - + @section('content') @yield('above-container') @yield('container') @yield('below-container') @show @section('scripts') - {!! $asset->js('main.js') !!} + {{-- The import map must precede any module script: it lets runtime-loaded + extension bundles share the panel's React/TanStack/SDK module instances. --}} + {!! $asset->importMap() !!} + {!! $asset->js('resources/scripts/index.tsx') !!} @show diff --git a/routes/admin.php b/routes/admin.php deleted file mode 100644 index a1e102eed..000000000 --- a/routes/admin.php +++ /dev/null @@ -1,228 +0,0 @@ -name('admin.index'); - -/* -|-------------------------------------------------------------------------- -| Location Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/api -| -*/ -Route::group(['prefix' => 'api'], function () { - Route::get('/', [Admin\ApiController::class, 'index'])->name('admin.api.index'); - Route::get('/new', [Admin\ApiController::class, 'create'])->name('admin.api.new'); - - Route::post('/new', [Admin\ApiController::class, 'store']); - - Route::delete('/revoke/{identifier}', [Admin\ApiController::class, 'delete'])->name('admin.api.delete'); -}); - -/* -|-------------------------------------------------------------------------- -| Location Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/locations -| -*/ -Route::group(['prefix' => 'locations'], function () { - Route::get('/', [Admin\LocationController::class, 'index'])->name('admin.locations'); - Route::get('/view/{location:id}', [Admin\LocationController::class, 'view'])->name('admin.locations.view'); - - Route::post('/', [Admin\LocationController::class, 'create']); - Route::patch('/view/{location:id}', [Admin\LocationController::class, 'update']); -}); - -/* -|-------------------------------------------------------------------------- -| Database Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/databases -| -*/ -Route::group(['prefix' => 'databases'], function () { - Route::get('/', [Admin\DatabaseController::class, 'index'])->name('admin.databases'); - Route::get('/view/{host:id}', [Admin\DatabaseController::class, 'view'])->name('admin.databases.view'); - - Route::post('/', [Admin\DatabaseController::class, 'create']); - Route::patch('/view/{host:id}', [Admin\DatabaseController::class, 'update']); - Route::delete('/view/{host:id}', [Admin\DatabaseController::class, 'delete']); -}); - -/* -|-------------------------------------------------------------------------- -| Settings Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/settings -| -*/ -Route::group(['prefix' => 'settings'], function () { - Route::get('/', [Admin\Settings\IndexController::class, 'index'])->name('admin.settings'); - Route::get('/mail', [Admin\Settings\MailController::class, 'index'])->name('admin.settings.mail'); - Route::get('/advanced', [Admin\Settings\AdvancedController::class, 'index'])->name('admin.settings.advanced'); - - Route::post('/mail/test', [Admin\Settings\MailController::class, 'test'])->name('admin.settings.mail.test'); - - Route::patch('/', [Admin\Settings\IndexController::class, 'update']); - Route::patch('/mail', [Admin\Settings\MailController::class, 'update']); - Route::patch('/advanced', [Admin\Settings\AdvancedController::class, 'update']); -}); - -/* -|-------------------------------------------------------------------------- -| User Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/users -| -*/ -Route::group(['prefix' => 'users'], function () { - Route::get('/', [Admin\UserController::class, 'index'])->name('admin.users'); - Route::get('/accounts.json', [Admin\UserController::class, 'json'])->name('admin.users.json'); - Route::get('/new', [Admin\UserController::class, 'create'])->name('admin.users.new'); - Route::get('/view/{user:id}', [Admin\UserController::class, 'view'])->name('admin.users.view'); - - Route::post('/new', [Admin\UserController::class, 'store']); - - Route::patch('/view/{user:id}', [Admin\UserController::class, 'update']); - Route::delete('/view/{user:id}', [Admin\UserController::class, 'delete'])->name('admin.users.delete'); -}); - -/* -|-------------------------------------------------------------------------- -| Server Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/servers -| -*/ -Route::group(['prefix' => 'servers'], function () { - Route::get('/', [Admin\Servers\ServerController::class, 'index'])->name('admin.servers'); - Route::get('/new', [Admin\Servers\CreateServerController::class, 'index'])->name('admin.servers.new'); - Route::get('/view/{server:id}', [Admin\Servers\ServerViewController::class, 'index'])->name('admin.servers.view'); - - Route::group(['middleware' => [ServerInstalled::class]], function () { - Route::get('/view/{server:id}/details', [Admin\Servers\ServerViewController::class, 'details'])->name('admin.servers.view.details'); - Route::get('/view/{server:id}/build', [Admin\Servers\ServerViewController::class, 'build'])->name('admin.servers.view.build'); - Route::get('/view/{server:id}/startup', [Admin\Servers\ServerViewController::class, 'startup'])->name('admin.servers.view.startup'); - Route::get('/view/{server:id}/database', [Admin\Servers\ServerViewController::class, 'database'])->name('admin.servers.view.database'); - Route::get('/view/{server:id}/mounts', [Admin\Servers\ServerViewController::class, 'mounts'])->name('admin.servers.view.mounts'); - }); - - Route::get('/view/{server:id}/manage', [Admin\Servers\ServerViewController::class, 'manage'])->name('admin.servers.view.manage'); - Route::get('/view/{server:id}/delete', [Admin\Servers\ServerViewController::class, 'delete'])->name('admin.servers.view.delete'); - - Route::post('/new', [Admin\Servers\CreateServerController::class, 'store']); - Route::post('/view/{server:id}/build', [Admin\ServersController::class, 'updateBuild']); - Route::post('/view/{server:id}/startup', [Admin\ServersController::class, 'saveStartup']); - Route::post('/view/{server:id}/database', [Admin\ServersController::class, 'newDatabase']); - Route::post('/view/{server:id}/mounts', [Admin\ServersController::class, 'addMount'])->name('admin.servers.view.mounts.store'); - Route::post('/view/{server:id}/manage/toggle', [Admin\ServersController::class, 'toggleInstall'])->name('admin.servers.view.manage.toggle'); - Route::post('/view/{server:id}/manage/suspension', [Admin\ServersController::class, 'manageSuspension'])->name('admin.servers.view.manage.suspension'); - Route::post('/view/{server:id}/manage/reinstall', [Admin\ServersController::class, 'reinstallServer'])->name('admin.servers.view.manage.reinstall'); - Route::post('/view/{server:id}/manage/transfer', [Admin\Servers\ServerTransferController::class, 'transfer'])->name('admin.servers.view.manage.transfer'); - Route::post('/view/{server:id}/delete', [Admin\ServersController::class, 'delete']); - - Route::patch('/view/{server:id}/details', [Admin\ServersController::class, 'setDetails']); - Route::patch('/view/{server:id}/database', [Admin\ServersController::class, 'resetDatabasePassword']); - - Route::delete('/view/{server:id}/database/{database:id}/delete', [Admin\ServersController::class, 'deleteDatabase'])->name('admin.servers.view.database.delete'); - Route::delete('/view/{server:id}/mounts/{mount:id}', [Admin\ServersController::class, 'deleteMount']) - ->name('admin.servers.view.mounts.delete'); -}); - -/* -|-------------------------------------------------------------------------- -| Node Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/nodes -| -*/ -Route::group(['prefix' => 'nodes'], function () { - Route::get('/', [Admin\Nodes\NodeController::class, 'index'])->name('admin.nodes'); - Route::get('/new', [Admin\NodesController::class, 'create'])->name('admin.nodes.new'); - Route::get('/view/{node:id}', [Admin\Nodes\NodeViewController::class, 'index'])->name('admin.nodes.view'); - Route::get('/view/{node:id}/settings', [Admin\Nodes\NodeViewController::class, 'settings'])->name('admin.nodes.view.settings'); - Route::get('/view/{node:id}/configuration', [Admin\Nodes\NodeViewController::class, 'configuration'])->name('admin.nodes.view.configuration'); - Route::get('/view/{node:id}/allocation', [Admin\Nodes\NodeViewController::class, 'allocations'])->name('admin.nodes.view.allocation'); - Route::get('/view/{node:id}/servers', [Admin\Nodes\NodeViewController::class, 'servers'])->name('admin.nodes.view.servers'); - Route::get('/view/{node:id}/system-information', Admin\Nodes\SystemInformationController::class); - - Route::post('/new', [Admin\NodesController::class, 'store']); - Route::post('/view/{node:id}/allocation', [Admin\NodesController::class, 'createAllocation']); - Route::post('/view/{node:id}/allocation/remove', [Admin\NodesController::class, 'allocationRemoveBlock'])->name('admin.nodes.view.allocation.removeBlock'); - Route::post('/view/{node:id}/allocation/alias', [Admin\NodesController::class, 'allocationSetAlias'])->name('admin.nodes.view.allocation.setAlias'); - Route::post('/view/{node:id}/settings/token', Admin\NodeAutoDeployController::class)->name('admin.nodes.view.configuration.token'); - - Route::patch('/view/{node:id}/settings', [Admin\NodesController::class, 'updateSettings']); - - Route::delete('/view/{node:id}/delete', [Admin\NodesController::class, 'delete'])->name('admin.nodes.view.delete'); - Route::delete('/view/{node:id}/allocation/remove/{allocation:id}', [Admin\NodesController::class, 'allocationRemoveSingle'])->name('admin.nodes.view.allocation.removeSingle'); - Route::delete('/view/{node:id}/allocations', [Admin\NodesController::class, 'allocationRemoveMultiple'])->name('admin.nodes.view.allocation.removeMultiple'); -}); - -/* -|-------------------------------------------------------------------------- -| Mount Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/mounts -| -*/ -Route::group(['prefix' => 'mounts'], function () { - Route::get('/', [Admin\MountController::class, 'index'])->name('admin.mounts'); - Route::get('/view/{mount:id}', [Admin\MountController::class, 'view'])->name('admin.mounts.view'); - - Route::post('/', [Admin\MountController::class, 'create']); - Route::post('/{mount:id}/eggs', [Admin\MountController::class, 'addEggs'])->name('admin.mounts.eggs'); - Route::post('/{mount:id}/nodes', [Admin\MountController::class, 'addNodes'])->name('admin.mounts.nodes'); - - Route::patch('/view/{mount:id}', [Admin\MountController::class, 'update']); - - Route::delete('/{mount:id}/eggs/{egg_id}', [Admin\MountController::class, 'deleteEgg']); - Route::delete('/{mount:id}/nodes/{node_id}', [Admin\MountController::class, 'deleteNode']); -}); - -/* -|-------------------------------------------------------------------------- -| Nest Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /admin/nests -| -*/ -Route::group(['prefix' => 'nests'], function () { - Route::get('/', [Admin\Nests\NestController::class, 'index'])->name('admin.nests'); - Route::get('/new', [Admin\Nests\NestController::class, 'create'])->name('admin.nests.new'); - Route::get('/view/{nest:id}', [Admin\Nests\NestController::class, 'view'])->name('admin.nests.view'); - Route::get('/egg/new', [Admin\Nests\EggController::class, 'create'])->name('admin.nests.egg.new'); - Route::get('/egg/{egg:id}', [Admin\Nests\EggController::class, 'view'])->name('admin.nests.egg.view'); - Route::get('/egg/{egg:id}/export', [Admin\Nests\EggShareController::class, 'export'])->name('admin.nests.egg.export'); - Route::get('/egg/{egg:id}/variables', [Admin\Nests\EggVariableController::class, 'view'])->name('admin.nests.egg.variables'); - Route::get('/egg/{egg:id}/scripts', [Admin\Nests\EggScriptController::class, 'index'])->name('admin.nests.egg.scripts'); - - Route::post('/new', [Admin\Nests\NestController::class, 'store']); - Route::post('/import', [Admin\Nests\EggShareController::class, 'import'])->name('admin.nests.egg.import'); - Route::post('/egg/new', [Admin\Nests\EggController::class, 'store']); - Route::post('/egg/{egg:id}/variables', [Admin\Nests\EggVariableController::class, 'store']); - - Route::put('/egg/{egg:id}', [Admin\Nests\EggShareController::class, 'update']); - - Route::patch('/view/{nest:id}', [Admin\Nests\NestController::class, 'update']); - Route::patch('/egg/{egg:id}', [Admin\Nests\EggController::class, 'update']); - Route::patch('/egg/{egg:id}/scripts', [Admin\Nests\EggScriptController::class, 'update']); - Route::patch('/egg/{egg:id}/variables/{variable:id}', [Admin\Nests\EggVariableController::class, 'update'])->name('admin.nests.egg.variables.edit'); - - Route::delete('/view/{nest:id}', [Admin\Nests\NestController::class, 'destroy']); - Route::delete('/egg/{egg:id}', [Admin\Nests\EggController::class, 'destroy']); - Route::delete('/egg/{egg:id}/variables/{variable:id}', [Admin\Nests\EggVariableController::class, 'destroy']); -}); diff --git a/routes/api-admin.php b/routes/api-admin.php new file mode 100644 index 000000000..3cab3ccb5 --- /dev/null +++ b/routes/api-admin.php @@ -0,0 +1,452 @@ +name('api.admin.languages'); + +Route::get('/activity', ActivityController::class)->name('api.admin.activity'); +Route::get('/activity/filters', ActivityFilterController::class)->name('api.admin.activity.filters'); + +/* +|-------------------------------------------------------------------------- +| Extension Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/extensions +| +*/ +Route::prefix('/extensions')->name('api.admin.extensions')->group(function (): void { + Route::get('/', [ExtensionController::class, 'index']); + Route::post('/', [ExtensionController::class, 'store'])->name('.install'); + Route::get('/{extension}/settings', [ExtensionController::class, 'settings'])->name('.settings'); + Route::patch('/{extension}/settings', [ExtensionController::class, 'updateSettings'])->name('.settings.update'); + Route::post('/{extension}/settings/{input}/file', [ExtensionController::class, 'uploadSettingFile'])->name('.settings.file'); + Route::delete('/{extension}/settings/{input}/file', [ExtensionController::class, 'clearSettingFile'])->name('.settings.file.clear'); + Route::post('/{extension}/enable', [ExtensionController::class, 'enable'])->name('.enable'); + Route::post('/{extension}/disable', [ExtensionController::class, 'disable'])->name('.disable'); + Route::delete('/{extension}', [ExtensionController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| User Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/users +| +*/ +Route::prefix('/users')->name('api.admin.users')->group(function (): void { + Route::get('/', [UserController::class, 'index']); + // `/external/{external_id}` before `/{user:id}` so the literal is not bound as an id. + Route::get('/external/{external_id}', UserExternalController::class)->name('.external'); + Route::get('/{user:id}', [UserController::class, 'show'])->name('.view'); + + Route::post('/', [UserController::class, 'store'])->name('.store'); + Route::post('/{user:id}/disable-2fa', DisableTwoFactorController::class)->name('.disable-2fa'); + Route::put('/{user:id}', [UserController::class, 'update'])->name('.update'); + + Route::delete('/{user:id}', [UserController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Node Action Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/nodes/{node} +| +*/ +Route::prefix('/nodes/{node:id}')->name('api.admin.nodes')->group(function (): void { + Route::get('/system-information', SystemInformationController::class)->name('.system-information'); + Route::post('/deploy-token', DeployTokenController::class)->name('.deploy-token'); + Route::get('/utilization', UtilizationController::class)->name('.utilization'); +}); + +/* +|-------------------------------------------------------------------------- +| Server Mount Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/servers/{server}/mounts +| +*/ +Route::prefix('/servers/{server:admin_identifier}/mounts')->name('api.admin.servers.mounts')->group(function (): void { + Route::get('/', [ServerMountController::class, 'index']); + Route::post('/', [ServerMountController::class, 'store'])->name('.store'); + Route::delete('/{mount:id}', [ServerMountController::class, 'destroy'])->name('.delete')->withoutScopedBindings(); +}); + +/* +|-------------------------------------------------------------------------- +| Server Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/servers +| +*/ +Route::prefix('/servers')->name('api.admin.servers')->group(function (): void { + Route::get('/', [ServerController::class, 'index']); + // `/external/{external_id}` before `/{server}` so the literal is not bound as a server. + Route::get('/external/{external_id}', ServerExternalController::class)->name('.external'); + Route::get('/{server:admin_identifier}', [ServerController::class, 'show'])->name('.view'); + + Route::post('/', [ServerController::class, 'store'])->name('.store'); + + Route::put('/{server:admin_identifier}/details', DetailsController::class)->name('.details'); + Route::put('/{server:admin_identifier}/build', BuildController::class)->name('.build'); + Route::put('/{server:admin_identifier}/startup', StartupController::class)->name('.startup'); + + Route::post('/{server:admin_identifier}/suspension', SuspensionController::class)->name('.suspension'); + Route::post('/{server:admin_identifier}/reinstall', ReinstallController::class)->name('.reinstall'); + Route::post('/{server:admin_identifier}/rebuild', RebuildController::class)->name('.rebuild'); + Route::get('/{server:admin_identifier}/transfer/progress', TransferProgressController::class)->name('.transfer-progress'); + Route::post('/{server:admin_identifier}/transfer', TransferController::class)->name('.transfer'); + Route::post('/{server:admin_identifier}/settings/toggle-install', ToggleInstallController::class)->name('.toggle-install'); + + Route::delete('/{server:admin_identifier}', [ServerController::class, 'destroy'])->name('.delete'); + Route::delete('/{server:admin_identifier}/force', [ServerController::class, 'forceDestroy'])->name('.delete.force'); +}); + +/* +|-------------------------------------------------------------------------- +| Server Database Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/servers/{server}/databases +| +*/ +Route::prefix('/servers/{server:admin_identifier}/databases')->name('api.admin.servers.databases')->group(function (): void { + Route::get('/', [DatabaseController::class, 'index']); + Route::get('/{database:id}', [DatabaseController::class, 'show'])->name('.view'); + + Route::post('/', [DatabaseController::class, 'store'])->name('.store'); + Route::post('/{database:id}/rotate-password', RotateDatabasePasswordController::class)->name('.rotate-password'); + + Route::delete('/{database:id}', [DatabaseController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Server Backup Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/servers/{server}/backups +| +*/ +Route::prefix('/servers/{server:admin_identifier}/backups')->name('api.admin.servers.backups')->group(function (): void { + Route::get('/', [ServerBackupController::class, 'index']); + Route::post('/{backup:id}/toggle', ToggleBackupController::class)->name('.toggle')->withoutScopedBindings(); +}); + +/* +|-------------------------------------------------------------------------- +| Node Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/nodes +| +*/ +Route::prefix('/nodes')->name('api.admin.nodes')->group(function (): void { + Route::get('/', [NodeController::class, 'index']); + Route::get('/{node:id}', [NodeController::class, 'show'])->name('.view'); + Route::get('/{node:id}/configuration', ConfigurationController::class)->name('.configuration'); + + Route::post('/', [NodeController::class, 'store'])->name('.store'); + Route::put('/{node:id}', [NodeController::class, 'update'])->name('.update'); + + Route::delete('/{node:id}', [NodeController::class, 'destroy'])->name('.delete'); + + // A node carries two independent tag sets - the games it accepts and the + // deploys it is reserved for - so each is replaced through its own endpoint. + Route::put('/{node:id}/tags', [TagController::class, 'syncNode'])->name('.tags.sync'); + Route::put('/{node:id}/deployment-tags', [TagController::class, 'syncNodeDeploymentTags'])->name('.deployment-tags.sync'); +}); + +/* +|-------------------------------------------------------------------------- +| Allocation Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/nodes/{node}/allocations +| +*/ +Route::prefix('/nodes/{node:id}/allocations')->name('api.admin.nodes.allocations')->group(function (): void { + Route::get('/', [AllocationController::class, 'index']); + // Literal segments (`/ips`, `/available`, `/block`) are declared before `/{allocation:id}`. + Route::get('/ips', UniqueIpsController::class)->name('.ips'); + Route::get('/available', AvailableAllocationsController::class)->name('.available'); + Route::post('/', [AllocationController::class, 'store'])->name('.store'); + + Route::delete('/block', DeleteAllocationBlockController::class)->name('.block'); + Route::delete('/', BulkDeleteAllocationsController::class)->name('.bulk-delete'); + + Route::put('/{allocation:id}', [AllocationController::class, 'update'])->name('.update'); + Route::delete('/{allocation:id}', [AllocationController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Location Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/locations +| +*/ +Route::prefix('/locations')->name('api.admin.locations')->group(function (): void { + Route::get('/', [LocationController::class, 'index']); + Route::get('/{location:id}', [LocationController::class, 'show'])->name('.view'); + Route::get('/{location:id}/eligible-nodes', EligibleNodesController::class)->name('.eligible-nodes'); + + Route::post('/', [LocationController::class, 'store'])->name('.store'); + Route::put('/{location:id}', [LocationController::class, 'update'])->name('.update'); + + Route::delete('/{location:id}', [LocationController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Mount Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/mounts +| +*/ +Route::prefix('/mounts')->name('api.admin.mounts')->group(function (): void { + Route::get('/', [MountController::class, 'index']); + Route::get('/{mount:id}', [MountController::class, 'show'])->name('.view'); + + Route::post('/', [MountController::class, 'store'])->name('.store'); + Route::put('/{mount:id}', [MountController::class, 'update'])->name('.update'); + + Route::delete('/{mount:id}', [MountController::class, 'destroy'])->name('.delete'); + + // Detach relies on global scoped binding resolving {egg}/{node} through the mount; keep it on. + Route::post('/{mount:id}/eggs', AttachEggsController::class)->name('.eggs'); + Route::delete('/{mount:id}/eggs/{egg:id}', DetachEggController::class)->name('.eggs.delete'); + + Route::post('/{mount:id}/nodes', AttachNodesController::class)->name('.nodes'); + Route::delete('/{mount:id}/nodes/{node:id}', DetachNodeController::class)->name('.nodes.delete'); +}); + +// Catalog routes must precede /eggs/{egg}/import to avoid binding "catalog" as an egg ID. +Route::prefix('/eggs/catalog')->name('api.admin.eggs.catalog')->group(function (): void { + Route::get('/', [EggCatalogController::class, 'index']); + Route::post('/refresh', [EggCatalogController::class, 'refresh'])->name('.refresh'); + Route::post('/import', ImportCatalogEggController::class)->name('.import'); +}); + +/* +|-------------------------------------------------------------------------- +| Egg Variable Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/eggs/{egg}/variables +| +*/ +Route::prefix('/eggs/{egg:id}/variables')->name('api.admin.eggs.variables')->group(function (): void { + Route::get('/', [EggVariableController::class, 'index']); + Route::post('/', [EggVariableController::class, 'store'])->name('.store'); + // `/reorder` before `/{variable:id}` so the literal is not bound as an id. + Route::put('/reorder', ReorderVariablesController::class)->name('.reorder'); + Route::put('/{variable:id}', [EggVariableController::class, 'update'])->name('.update'); + Route::delete('/{variable:id}', [EggVariableController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Egg Script Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/eggs/{egg}/scripts +| +*/ +Route::prefix('/eggs/{egg:id}/scripts')->name('api.admin.eggs.script')->group(function (): void { + Route::get('/', [EggScriptController::class, 'show']); + Route::put('/', [EggScriptController::class, 'update'])->name('.update'); +}); + +/* +|-------------------------------------------------------------------------- +| Egg Sharing and Tag Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/eggs/{egg} +| +*/ +Route::prefix('/eggs/{egg:id}')->name('api.admin.eggs')->group(function (): void { + Route::get('/export', ExportEggController::class)->name('.export'); + Route::post('/import', UpdateImportEggController::class)->name('.update-import'); + Route::put('/tags', [TagController::class, 'syncEgg'])->name('.tags.sync'); +}); + +/* +|-------------------------------------------------------------------------- +| Egg Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/eggs +| +| Eggs are addressed directly rather than through a nest: they are grouped by +| tags now, so there is no parent resource to route them under. +| +*/ +Route::prefix('/eggs')->name('api.admin.eggs')->group(function (): void { + // `/import` before `/{egg:id}` so the literal is not bound as an id. + Route::post('/import', ImportEggController::class)->name('.import'); + + Route::get('/', [EggController::class, 'index']); + Route::get('/{egg:id}', [EggController::class, 'show'])->name('.view'); + + Route::post('/', [EggController::class, 'store'])->name('.store'); + Route::put('/{egg:id}', [EggController::class, 'update'])->name('.update'); + + Route::delete('/{egg:id}', [EggController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Tag Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/tags +| +| Tags are generic labels attached to eggs and nodes. They take over the +| grouping role nests used to play, and sit alongside a node's location. +| +*/ +Route::prefix('/tags')->name('api.admin.tags')->group(function (): void { + Route::get('/', [TagController::class, 'index']); + Route::get('/{tag:id}', [TagController::class, 'show'])->name('.view'); + + Route::post('/', [TagController::class, 'store'])->name('.store'); + Route::put('/{tag:id}', [TagController::class, 'update'])->name('.update'); + + Route::delete('/{tag:id}', [TagController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Settings Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/settings +| +*/ +Route::prefix('/settings')->name('api.admin.settings')->group(function (): void { + Route::get('/', [SettingsController::class, 'index']); + Route::put('/general', GeneralController::class)->name('.general'); + Route::put('/mail', MailController::class)->name('.mail'); + Route::post('/mail/test', TestMailController::class)->name('.mail.test'); + Route::put('/advanced', AdvancedController::class)->name('.advanced'); +}); + +/* +|-------------------------------------------------------------------------- +| Database Host Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/database-hosts +| +*/ +Route::prefix('/database-hosts')->name('api.admin.database-hosts')->group(function (): void { + Route::get('/', [DatabaseHostController::class, 'index']); + Route::get('/{databaseHost:id}', [DatabaseHostController::class, 'show'])->name('.view'); + Route::get('/{databaseHost:id}/databases', [DatabaseHostController::class, 'databases'])->name('.databases'); + + Route::post('/', [DatabaseHostController::class, 'store'])->name('.store'); + Route::put('/{databaseHost:id}', [DatabaseHostController::class, 'update'])->name('.update'); + + Route::delete('/{databaseHost:id}', [DatabaseHostController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| API Key Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/api-keys +| +*/ +Route::prefix('/api-keys')->name('api.admin.api-keys')->group(function (): void { + Route::get('/', [ApiKeyController::class, 'index']); + Route::get('/{identifier}', [ApiKeyController::class, 'show'])->name('.view'); + + Route::post('/', [ApiKeyController::class, 'store'])->name('.store'); + Route::put('/{identifier}', [ApiKeyController::class, 'update'])->name('.update'); + + Route::delete('/{identifier}', [ApiKeyController::class, 'destroy'])->name('.delete'); +}); + +/* +|-------------------------------------------------------------------------- +| Version Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/admin/version +| +*/ +Route::prefix('/version')->name('api.admin.version')->group(function (): void { + Route::get('/', VersionController::class); +}); diff --git a/routes/api-application.php b/routes/api-application.php index f73096aa8..bf8718b9f 100644 --- a/routes/api-application.php +++ b/routes/api-application.php @@ -1,7 +1,23 @@ '/users'], function () { - Route::get('/', [Application\Users\UserController::class, 'index'])->name('api.application.users'); - Route::get('/{user:id}', [Application\Users\UserController::class, 'view'])->name('api.application.users.view'); - Route::get('/external/{external_id}', [Application\Users\ExternalUserController::class, 'index'])->name('api.application.users.external'); +Route::group(['prefix' => '/users'], function (): void { + Route::get('/', [UserController::class, 'index'])->name('api.application.users'); + Route::get('/{user:id}', [UserController::class, 'view'])->name('api.application.users.view'); + Route::get('/external/{external_id}', [ExternalUserController::class, 'index'])->name('api.application.users.external'); - Route::post('/', [Application\Users\UserController::class, 'store']); - Route::patch('/{user:id}', [Application\Users\UserController::class, 'update']); + Route::post('/', [UserController::class, 'store']); + Route::patch('/{user:id}', [UserController::class, 'update']); - Route::delete('/{user:id}', [Application\Users\UserController::class, 'delete']); + Route::delete('/{user:id}', [UserController::class, 'delete']); }); /* @@ -31,21 +47,21 @@ Route::group(['prefix' => '/users'], function () { | Endpoint: /api/application/nodes | */ -Route::group(['prefix' => '/nodes'], function () { - Route::get('/', [Application\Nodes\NodeController::class, 'index'])->name('api.application.nodes'); - Route::get('/deployable', Application\Nodes\NodeDeploymentController::class); - Route::get('/{node:id}', [Application\Nodes\NodeController::class, 'view'])->name('api.application.nodes.view'); - Route::get('/{node:id}/configuration', Application\Nodes\NodeConfigurationController::class); +Route::group(['prefix' => '/nodes'], function (): void { + Route::get('/', [NodeController::class, 'index'])->name('api.application.nodes'); + Route::get('/deployable', NodeDeploymentController::class); + Route::get('/{node:id}', [NodeController::class, 'view'])->name('api.application.nodes.view'); + Route::get('/{node:id}/configuration', NodeConfigurationController::class); - Route::post('/', [Application\Nodes\NodeController::class, 'store']); - Route::patch('/{node:id}', [Application\Nodes\NodeController::class, 'update'])->name('api.application.nodes.update'); + Route::post('/', [NodeController::class, 'store']); + Route::patch('/{node:id}', [NodeController::class, 'update'])->name('api.application.nodes.update'); - Route::delete('/{node:id}', [Application\Nodes\NodeController::class, 'delete']); + Route::delete('/{node:id}', [NodeController::class, 'delete']); - Route::group(['prefix' => '/{node:id}/allocations'], function () { - Route::get('/', [Application\Nodes\AllocationController::class, 'index'])->name('api.application.allocations'); - Route::post('/', [Application\Nodes\AllocationController::class, 'store']); - Route::delete('/{allocation:id}', [Application\Nodes\AllocationController::class, 'delete'])->name('api.application.allocations.view'); + Route::group(['prefix' => '/{node:id}/allocations'], function (): void { + Route::get('/', [AllocationController::class, 'index'])->name('api.application.allocations'); + Route::post('/', [AllocationController::class, 'store']); + Route::delete('/{allocation:id}', [AllocationController::class, 'delete'])->name('api.application.allocations.view'); }); }); @@ -57,14 +73,40 @@ Route::group(['prefix' => '/nodes'], function () { | Endpoint: /api/application/locations | */ -Route::group(['prefix' => '/locations'], function () { - Route::get('/', [Application\Locations\LocationController::class, 'index'])->name('api.applications.locations'); - Route::get('/{location:id}', [Application\Locations\LocationController::class, 'view'])->name('api.application.locations.view'); +Route::group(['prefix' => '/locations'], function (): void { + Route::get('/', [LocationController::class, 'index'])->name('api.applications.locations'); + Route::get('/{location:id}', [LocationController::class, 'view'])->name('api.application.locations.view'); - Route::post('/', [Application\Locations\LocationController::class, 'store']); - Route::patch('/{location:id}', [Application\Locations\LocationController::class, 'update']); + Route::post('/', [LocationController::class, 'store']); + Route::patch('/{location:id}', [LocationController::class, 'update']); - Route::delete('/{location:id}', [Application\Locations\LocationController::class, 'delete']); + Route::delete('/{location:id}', [LocationController::class, 'delete']); +}); + +/* +|-------------------------------------------------------------------------- +| Egg Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/application/eggs +| +*/ +Route::group(['prefix' => '/eggs'], function (): void { + Route::get('/', [EggController::class, 'index'])->name('api.application.eggs'); + Route::get('/{egg:id}', [EggController::class, 'view'])->name('api.application.eggs.view'); +}); + +/* +|-------------------------------------------------------------------------- +| Tag Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/application/tags +| +*/ +Route::group(['prefix' => '/tags'], function (): void { + Route::get('/', [TagController::class, 'index'])->name('api.application.tags'); + Route::get('/{tag:id}', [TagController::class, 'view'])->name('api.application.tags.view'); }); /* @@ -75,50 +117,31 @@ Route::group(['prefix' => '/locations'], function () { | Endpoint: /api/application/servers | */ -Route::group(['prefix' => '/servers'], function () { - Route::get('/', [Application\Servers\ServerController::class, 'index'])->name('api.application.servers'); - Route::get('/{server:id}', [Application\Servers\ServerController::class, 'view'])->name('api.application.servers.view'); - Route::get('/external/{external_id}', [Application\Servers\ExternalServerController::class, 'index'])->name('api.application.servers.external'); +Route::group(['prefix' => '/servers'], function (): void { + Route::get('/', [ServerController::class, 'index'])->name('api.application.servers'); + Route::get('/{server:id}', [ServerController::class, 'view'])->name('api.application.servers.view'); + Route::get('/external/{external_id}', [ExternalServerController::class, 'index'])->name('api.application.servers.external'); - Route::patch('/{server:id}/details', [Application\Servers\ServerDetailsController::class, 'details'])->name('api.application.servers.details'); - Route::patch('/{server:id}/build', [Application\Servers\ServerDetailsController::class, 'build'])->name('api.application.servers.build'); - Route::patch('/{server:id}/startup', [Application\Servers\StartupController::class, 'index'])->name('api.application.servers.startup'); + Route::patch('/{server:id}/details', [ServerDetailsController::class, 'details'])->name('api.application.servers.details'); + Route::patch('/{server:id}/build', [ServerDetailsController::class, 'build'])->name('api.application.servers.build'); + Route::patch('/{server:id}/startup', [StartupController::class, 'index'])->name('api.application.servers.startup'); - Route::post('/', [Application\Servers\ServerController::class, 'store']); - Route::post('/{server:id}/suspend', [Application\Servers\ServerManagementController::class, 'suspend'])->name('api.application.servers.suspend'); - Route::post('/{server:id}/unsuspend', [Application\Servers\ServerManagementController::class, 'unsuspend'])->name('api.application.servers.unsuspend'); - Route::post('/{server:id}/reinstall', [Application\Servers\ServerManagementController::class, 'reinstall'])->name('api.application.servers.reinstall'); + Route::post('/', [ServerController::class, 'store']); + Route::post('/{server:id}/suspend', [ServerManagementController::class, 'suspend'])->name('api.application.servers.suspend'); + Route::post('/{server:id}/unsuspend', [ServerManagementController::class, 'unsuspend'])->name('api.application.servers.unsuspend'); + Route::post('/{server:id}/reinstall', [ServerManagementController::class, 'reinstall'])->name('api.application.servers.reinstall'); - Route::delete('/{server:id}', [Application\Servers\ServerController::class, 'delete']); - Route::delete('/{server:id}/{force?}', [Application\Servers\ServerController::class, 'delete']); + Route::delete('/{server:id}', [ServerController::class, 'delete']); + Route::delete('/{server:id}/{force?}', [ServerController::class, 'delete']); // Database Management Endpoint - Route::group(['prefix' => '/{server:id}/databases'], function () { - Route::get('/', [Application\Servers\DatabaseController::class, 'index'])->name('api.application.servers.databases'); - Route::get('/{database:id}', [Application\Servers\DatabaseController::class, 'view'])->name('api.application.servers.databases.view'); + Route::group(['prefix' => '/{server:id}/databases'], function (): void { + Route::get('/', [DatabaseController::class, 'index'])->name('api.application.servers.databases'); + Route::get('/{database:id}', [DatabaseController::class, 'view'])->name('api.application.servers.databases.view'); - Route::post('/', [Application\Servers\DatabaseController::class, 'store']); - Route::post('/{database:id}/reset-password', [Application\Servers\DatabaseController::class, 'resetPassword']); + Route::post('/', [DatabaseController::class, 'store']); + Route::post('/{database:id}/reset-password', [DatabaseController::class, 'resetPassword']); - Route::delete('/{database:id}', [Application\Servers\DatabaseController::class, 'delete']); - }); -}); - -/* -|-------------------------------------------------------------------------- -| Nest Controller Routes -|-------------------------------------------------------------------------- -| -| Endpoint: /api/application/nests -| -*/ -Route::group(['prefix' => '/nests'], function () { - Route::get('/', [Application\Nests\NestController::class, 'index'])->name('api.application.nests'); - Route::get('/{nest:id}', [Application\Nests\NestController::class, 'view'])->name('api.application.nests.view'); - - // Egg Management Endpoint - Route::group(['prefix' => '/{nest:id}/eggs'], function () { - Route::get('/', [Application\Nests\EggController::class, 'index'])->name('api.application.nests.eggs'); - Route::get('/{egg:id}', [Application\Nests\EggController::class, 'view'])->name('api.application.nests.eggs.view'); + Route::delete('/{database:id}', [DatabaseController::class, 'delete']); }); }); diff --git a/routes/api-client.php b/routes/api-client.php index b5595ec01..1a7d6a662 100644 --- a/routes/api-client.php +++ b/routes/api-client.php @@ -1,13 +1,39 @@ name('api:client.index'); -Route::get('/permissions', [Client\ClientController::class, 'permissions']); +Route::get('/', [ClientController::class, 'index'])->name('api:client.index'); +Route::get('/permissions', [ClientController::class, 'permissions']); +Route::get('/extension-progress/{extension}/{job}', [ExtensionProgressController::class, 'user'])->where('extension', '[a-z][a-z0-9-]{0,47}')->whereUuid('job')->name('api:client.extension-progress'); -Route::prefix('/account')->middleware(AccountSubject::class)->group(function () { - Route::prefix('/')->withoutMiddleware(RequireTwoFactorAuthentication::class)->group(function () { - Route::get('/', [Client\AccountController::class, 'index'])->name('api:client.account'); - Route::get('/two-factor', [Client\TwoFactorController::class, 'index']); - Route::post('/two-factor', [Client\TwoFactorController::class, 'store']); - Route::post('/two-factor/disable', [Client\TwoFactorController::class, 'delete']); +Route::prefix('/account')->middleware(AccountSubject::class)->group(function (): void { + Route::prefix('/')->withoutMiddleware(RequireTwoFactorAuthentication::class)->group(function (): void { + Route::get('/', [AccountController::class, 'index'])->name('api:client.account'); + Route::get('/two-factor', [TwoFactorController::class, 'index']); + Route::post('/two-factor', [TwoFactorController::class, 'store']); + Route::post('/two-factor/disable', [TwoFactorController::class, 'delete']); }); - Route::put('/email', [Client\AccountController::class, 'updateEmail']) + Route::put('/email', [AccountController::class, 'updateEmail']) ->middleware('throttle') ->name('api:client.account.update-email'); - Route::put('/password', [Client\AccountController::class, 'updatePassword'])->name('api:client.account.update-password'); + Route::put('/password', [AccountController::class, 'updatePassword'])->name('api:client.account.update-password'); - Route::get('/activity', Client\ActivityLogController::class)->name('api:client.account.activity'); + Route::get('/activity', ActivityLogController::class)->name('api:client.account.activity'); + Route::get('/activity/filters', ActivityLogFilterController::class)->name('api:client.account.activity.filters'); - Route::get('/api-keys', [Client\ApiKeyController::class, 'index']); - Route::post('/api-keys', [Client\ApiKeyController::class, 'store']); - Route::delete('/api-keys/{identifier}', [Client\ApiKeyController::class, 'delete']); + Route::get('/api-keys', [ApiKeyController::class, 'index']); + Route::post('/api-keys', [ApiKeyController::class, 'store']); + Route::delete('/api-keys/{identifier}', [ApiKeyController::class, 'delete']); - Route::prefix('/ssh-keys')->group(function () { - Route::get('/', [Client\SSHKeyController::class, 'index']); - Route::post('/', [Client\SSHKeyController::class, 'store']); - Route::post('/remove', [Client\SSHKeyController::class, 'delete']); + Route::prefix('/ssh-keys')->group(function (): void { + Route::get('/', [SSHKeyController::class, 'index']); + Route::post('/', [SSHKeyController::class, 'store']); + Route::post('/remove', [SSHKeyController::class, 'delete']); }); }); @@ -61,93 +89,96 @@ Route::group([ AuthenticateServerAccess::class, ResourceBelongsToServer::class, ], -], function () { - Route::get('/', [Client\Servers\ServerController::class, 'index'])->name('api:client:server.view'); +], function (): void { + Route::get('/', [ServerController::class, 'index'])->name('api:client:server.view'); Route::middleware([ResourceLimit::Websocket->middleware()]) - ->get('/websocket', Client\Servers\WebsocketController::class) + ->get('/websocket', WebsocketController::class) ->name('api:client:server.ws'); - Route::get('/resources', Client\Servers\ResourceUtilizationController::class)->name('api:client:server.resources'); + Route::get('/resources', ResourceUtilizationController::class)->name('api:client:server.resources'); + Route::get('/logs', LogController::class)->name('api:client:server.logs'); + Route::get('/extension-progress/{extension}/{job}', [ExtensionProgressController::class, 'server'])->where('extension', '[a-z][a-z0-9-]{0,47}')->whereUuid('job')->name('api:client:server.extension-progress'); Route::get('/activity', Client\Servers\ActivityLogController::class)->name('api:client:server.activity'); + Route::get('/activity/filters', Client\Servers\ActivityLogFilterController::class)->name('api:client:server.activity.filters'); - Route::post('/command', [Client\Servers\CommandController::class, 'index']); - Route::post('/power', [Client\Servers\PowerController::class, 'index']); + Route::post('/command', [CommandController::class, 'index']); + Route::post('/power', [PowerController::class, 'index']); - Route::group(['prefix' => '/databases'], function () { - Route::get('/', [Client\Servers\DatabaseController::class, 'index']); + Route::group(['prefix' => '/databases'], function (): void { + Route::get('/', [DatabaseController::class, 'index']); Route::middleware([ResourceLimit::Database->middleware()]) - ->post('/', [Client\Servers\DatabaseController::class, 'store']); - Route::post('/{database}/rotate-password', [Client\Servers\DatabaseController::class, 'rotatePassword']); - Route::delete('/{database}', [Client\Servers\DatabaseController::class, 'delete']); + ->post('/', [DatabaseController::class, 'store']); + Route::post('/{database}/rotate-password', [DatabaseController::class, 'rotatePassword']); + Route::delete('/{database}', [DatabaseController::class, 'delete']); }); - Route::group(['prefix' => '/files'], function () { - Route::get('/list', [Client\Servers\FileController::class, 'directory']); - Route::get('/contents', [Client\Servers\FileController::class, 'contents']); - Route::get('/download', [Client\Servers\FileController::class, 'download']); - Route::put('/rename', [Client\Servers\FileController::class, 'rename']); - Route::post('/copy', [Client\Servers\FileController::class, 'copy']); - Route::post('/write', [Client\Servers\FileController::class, 'write']); - Route::post('/compress', [Client\Servers\FileController::class, 'compress']); - Route::post('/decompress', [Client\Servers\FileController::class, 'decompress']); - Route::post('/delete', [Client\Servers\FileController::class, 'delete']); - Route::post('/create-folder', [Client\Servers\FileController::class, 'create']); - Route::post('/chmod', [Client\Servers\FileController::class, 'chmod']); + Route::group(['prefix' => '/files'], function (): void { + Route::get('/list', [FileController::class, 'directory']); + Route::get('/contents', [FileController::class, 'contents']); + Route::get('/download', [FileController::class, 'download']); + Route::put('/rename', [FileController::class, 'rename']); + Route::post('/copy', [FileController::class, 'copy']); + Route::post('/write', [FileController::class, 'write']); + Route::post('/compress', [FileController::class, 'compress']); + Route::post('/decompress', [FileController::class, 'decompress']); + Route::post('/delete', [FileController::class, 'delete']); + Route::post('/create-folder', [FileController::class, 'create']); + Route::post('/chmod', [FileController::class, 'chmod']); Route::middleware([ResourceLimit::FilePull->middleware()]) - ->post('/pull', [Client\Servers\FileController::class, 'pull']); - Route::get('/upload', Client\Servers\FileUploadController::class); + ->post('/pull', [FileController::class, 'pull']); + Route::get('/upload', FileUploadController::class); }); - Route::group(['prefix' => '/schedules'], function () { - Route::get('/', [Client\Servers\ScheduleController::class, 'index']); + Route::group(['prefix' => '/schedules'], function (): void { + Route::get('/', [ScheduleController::class, 'index']); Route::middleware([ResourceLimit::Schedule->middleware()]) - ->post('/', [Client\Servers\ScheduleController::class, 'store']); - Route::get('/{schedule}', [Client\Servers\ScheduleController::class, 'view']); - Route::post('/{schedule}', [Client\Servers\ScheduleController::class, 'update']); - Route::post('/{schedule}/execute', [Client\Servers\ScheduleController::class, 'execute']); - Route::delete('/{schedule}', [Client\Servers\ScheduleController::class, 'delete']); + ->post('/', [ScheduleController::class, 'store']); + Route::get('/{schedule}', [ScheduleController::class, 'view']); + Route::post('/{schedule}', [ScheduleController::class, 'update']); + Route::post('/{schedule}/execute', [ScheduleController::class, 'execute']); + Route::delete('/{schedule}', [ScheduleController::class, 'delete']); - Route::post('/{schedule}/tasks', [Client\Servers\ScheduleTaskController::class, 'store']); - Route::post('/{schedule}/tasks/{task}', [Client\Servers\ScheduleTaskController::class, 'update']); - Route::delete('/{schedule}/tasks/{task}', [Client\Servers\ScheduleTaskController::class, 'delete']); + Route::post('/{schedule}/tasks', [ScheduleTaskController::class, 'store']); + Route::post('/{schedule}/tasks/{task}', [ScheduleTaskController::class, 'update']); + Route::delete('/{schedule}/tasks/{task}', [ScheduleTaskController::class, 'delete']); }); - Route::group(['prefix' => '/network'], function () { - Route::get('/allocations', [Client\Servers\NetworkAllocationController::class, 'index']); + Route::group(['prefix' => '/network'], function (): void { + Route::get('/allocations', [NetworkAllocationController::class, 'index']); Route::middleware([ResourceLimit::Allocation->middleware()]) - ->post('/allocations', [Client\Servers\NetworkAllocationController::class, 'store']); - Route::post('/allocations/{allocation}', [Client\Servers\NetworkAllocationController::class, 'update']); - Route::post('/allocations/{allocation}/primary', [Client\Servers\NetworkAllocationController::class, 'setPrimary']); - Route::delete('/allocations/{allocation}', [Client\Servers\NetworkAllocationController::class, 'delete']); + ->post('/allocations', [NetworkAllocationController::class, 'store']); + Route::post('/allocations/{allocation}', [NetworkAllocationController::class, 'update']); + Route::post('/allocations/{allocation}/primary', [NetworkAllocationController::class, 'setPrimary']); + Route::delete('/allocations/{allocation}', [NetworkAllocationController::class, 'delete']); }); - Route::group(['prefix' => '/users'], function () { - Route::get('/', [Client\Servers\SubuserController::class, 'index']); + Route::group(['prefix' => '/users'], function (): void { + Route::get('/', [SubuserController::class, 'index']); Route::middleware([ResourceLimit::Subuser->middleware()]) - ->post('/', [Client\Servers\SubuserController::class, 'store']); - Route::get('/{user}', [Client\Servers\SubuserController::class, 'view']); - Route::post('/{user}', [Client\Servers\SubuserController::class, 'update']); - Route::delete('/{user}', [Client\Servers\SubuserController::class, 'delete']); + ->post('/', [SubuserController::class, 'store']); + Route::get('/{user}', [SubuserController::class, 'view']); + Route::post('/{user}', [SubuserController::class, 'update']); + Route::delete('/{user}', [SubuserController::class, 'delete']); }); - Route::group(['prefix' => '/backups'], function () { - Route::get('/', [Client\Servers\BackupController::class, 'index']); - Route::post('/', [Client\Servers\BackupController::class, 'store']); - Route::get('/{backup}', [Client\Servers\BackupController::class, 'view']); - Route::get('/{backup}/download', [Client\Servers\BackupController::class, 'download']); - Route::post('/{backup}/lock', [Client\Servers\BackupController::class, 'toggleLock']); + Route::group(['prefix' => '/backups'], function (): void { + Route::get('/', [BackupController::class, 'index']); + Route::post('/', [BackupController::class, 'store']); + Route::get('/{backup}', [BackupController::class, 'view']); + Route::get('/{backup}/download', [BackupController::class, 'download']); + Route::post('/{backup}/lock', [BackupController::class, 'toggleLock']); Route::middleware([ResourceLimit::Backup->middleware()]) - ->post('/{backup}/restore', [Client\Servers\BackupController::class, 'restore']); - Route::delete('/{backup}', [Client\Servers\BackupController::class, 'delete']); + ->post('/{backup}/restore', [BackupController::class, 'restore']); + Route::delete('/{backup}', [BackupController::class, 'delete']); }); - Route::group(['prefix' => '/startup'], function () { - Route::get('/', [Client\Servers\StartupController::class, 'index']); - Route::put('/variable', [Client\Servers\StartupController::class, 'update']); + Route::group(['prefix' => '/startup'], function (): void { + Route::get('/', [StartupController::class, 'index']); + Route::put('/variable', [StartupController::class, 'update']); }); - Route::group(['prefix' => '/settings'], function () { - Route::post('/rename', [Client\Servers\SettingsController::class, 'rename']); - Route::post('/reinstall', [Client\Servers\SettingsController::class, 'reinstall']); - Route::put('/docker-image', [Client\Servers\SettingsController::class, 'dockerImage']); + Route::group(['prefix' => '/settings'], function (): void { + Route::post('/rename', [SettingsController::class, 'rename']); + Route::post('/reinstall', [SettingsController::class, 'reinstall']); + Route::put('/docker-image', [SettingsController::class, 'dockerImage']); }); }); diff --git a/routes/api-remote.php b/routes/api-remote.php index 7db442a54..02743c8de 100644 --- a/routes/api-remote.php +++ b/routes/api-remote.php @@ -1,25 +1,33 @@ '/servers/{uuid}'], function () { - Route::get('/', Remote\Servers\ServerDetailsController::class); - Route::get('/install', [Remote\Servers\ServerInstallController::class, 'index']); - Route::post('/install', [Remote\Servers\ServerInstallController::class, 'store']); - Route::post('/transfer/failure', [Remote\Servers\ServerTransferController::class, 'failure']); - Route::post('/transfer/success', [Remote\Servers\ServerTransferController::class, 'success']); +Route::group(['prefix' => '/servers/{uuid}'], function (): void { + Route::get('/', ServerDetailsController::class); + Route::get('/install', [ServerInstallController::class, 'index']); + Route::post('/install', [ServerInstallController::class, 'store']); + Route::post('/transfer/failure', [ServerTransferController::class, 'failure']); + Route::post('/transfer/success', [ServerTransferController::class, 'success']); }); -Route::group(['prefix' => '/backups'], function () { - Route::get('/{backup}', Remote\Backups\BackupRemoteUploadController::class); - Route::post('/{backup}', [Remote\Backups\BackupStatusController::class, 'index']); - Route::post('/{backup}/restore', [Remote\Backups\BackupStatusController::class, 'restore']); +Route::group(['prefix' => '/backups'], function (): void { + Route::get('/{backup}', BackupRemoteUploadController::class); + Route::post('/{backup}', [BackupStatusController::class, 'index']); + Route::post('/{backup}/restore', [BackupStatusController::class, 'restore']); }); diff --git a/routes/auth.php b/routes/auth.php index 36039f3a2..a7d3d4568 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -1,7 +1,12 @@ name('auth.login'); -Route::get('/password', [Auth\LoginController::class, 'index'])->name('auth.forgot-password'); -Route::get('/password/reset/{token}', [Auth\LoginController::class, 'index'])->name('auth.reset'); +Route::get('/login', [LoginController::class, 'index'])->name('auth.login'); +Route::get('/password', [LoginController::class, 'index'])->name('auth.forgot-password'); +Route::get('/password/reset/{token}', [LoginController::class, 'index'])->name('auth.reset'); // Apply a throttle to authentication action endpoints, in addition to the // recaptcha endpoints to slow down manual attack spammers even more. 🤷‍ // -// @see \Pterodactyl\Providers\RouteServiceProvider -Route::middleware(['throttle:authentication'])->group(function () { +// @see bootstrap/app.php (withRouting) +Route::middleware(['throttle:authentication'])->group(function (): void { // Login endpoints. - Route::post('/login', [Auth\LoginController::class, 'login'])->middleware('recaptcha'); - Route::post('/login/checkpoint', Auth\LoginCheckpointController::class)->name('auth.login-checkpoint'); + Route::post('/login', [LoginController::class, 'login'])->middleware('recaptcha'); + Route::post('/login/checkpoint', LoginCheckpointController::class)->name('auth.login-checkpoint'); // Forgot password route. A post to this endpoint will trigger an // email to be sent containing a reset token. - Route::post('/password', [Auth\ForgotPasswordController::class, 'sendResetLinkEmail']) + Route::post('/password', [ForgotPasswordController::class, 'sendResetLinkEmail']) ->name('auth.post.forgot-password') ->middleware('recaptcha'); }); @@ -37,14 +42,14 @@ Route::middleware(['throttle:authentication'])->group(function () { // Password reset routes. This endpoint is hit after going through // the forgot password routes to acquire a token (or after an account // is created). -Route::post('/password/reset', Auth\ResetPasswordController::class)->name('auth.reset-password'); +Route::post('/password/reset', ResetPasswordController::class)->name('auth.reset-password'); // Remove the guest middleware and apply the authenticated middleware to this endpoint, // so it cannot be used unless you're already logged in. -Route::post('/logout', [Auth\LoginController::class, 'logout']) +Route::post('/logout', [LoginController::class, 'logout']) ->withoutMiddleware('guest') ->middleware('auth') ->name('auth.logout'); // Catch any other combinations of routes and pass them off to the React component. -Route::fallback([Auth\LoginController::class, 'index']); +Route::fallback([LoginController::class, 'index']); diff --git a/routes/base.php b/routes/base.php index 93f45b577..b4c774d38 100644 --- a/routes/base.php +++ b/routes/base.php @@ -1,17 +1,33 @@ name('index')->fallback(); -Route::get('/account', [Base\IndexController::class, 'index']) +use Illuminate\Support\Facades\Route; +use Pterodactyl\Http\Controllers\Base\ExtensionFileController; +use Pterodactyl\Http\Controllers\Base\IndexController; +use Pterodactyl\Http\Controllers\Base\LocaleController; +use Pterodactyl\Http\Middleware\RequireTwoFactorAuthentication; +use Pterodactyl\Services\Extensions\ExtensionSettingFiles; + +Route::get('/', [IndexController::class, 'index'])->name('index')->fallback(); +Route::get('/account', [IndexController::class, 'index']) ->withoutMiddleware(RequireTwoFactorAuthentication::class) ->name('account'); -Route::get('/locales/locale.json', Base\LocaleController::class) +Route::get('/locales/locale.json', LocaleController::class) ->withoutMiddleware(['auth', RequireTwoFactorAuthentication::class]) ->where('namespace', '.*'); -Route::get('/{react}', [Base\IndexController::class, 'index']) - ->where('react', '^(?!(\/)?(api|auth|admin|daemon)).+'); +// Files uploaded through extension `file` settings. Public and stateless: no +// session, no cookies, so the immutable cache headers are safe behind a proxy. +Route::get('/'.ExtensionSettingFiles::ROUTE_PREFIX.'/{extension}/{file}', ExtensionFileController::class) + ->withoutMiddleware(['web', 'auth.session', RequireTwoFactorAuthentication::class]) + ->where('extension', '[a-z][a-z0-9-]{0,47}') + ->where('file', '[a-f0-9]{40}\.[a-z0-9]{2,5}') + ->name('extensions.files'); + +// The SPA catch-all is a fallback so that routes registered after it - an extension's +// /extensions/ and claimed root path routes - are matched first. +Route::get('/{react}', [IndexController::class, 'index']) + ->where('react', '^(?!(\/)?(api|auth|daemon)).+') + ->fallback(); diff --git a/scripts/build-sdk-testing.mjs b/scripts/build-sdk-testing.mjs new file mode 100644 index 000000000..ff643b2bd --- /dev/null +++ b/scripts/build-sdk-testing.mjs @@ -0,0 +1,22 @@ +import { build } from 'vite'; +import { esmExternalRequirePlugin } from 'rolldown/plugins'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { readFileSync } from 'node:fs'; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const sdk = JSON.parse(readFileSync(resolve(root, 'packages/sdk/package.json'), 'utf8')); +const peers = Object.keys(sdk.peerDependencies); +await build({ + configFile: false, + root, + resolve: {alias: {'@': resolve(root, 'resources/scripts'), '@feature': resolve(root, 'resources/scripts/components/server/features')}}, + build: { + target: 'esnext', minify: false, sourcemap: true, outDir: resolve(root, 'packages/sdk/testing-runtime'), emptyOutDir: true, + lib: {entry: {sdk: resolve(root, 'resources/scripts/sdk/index.ts'), api: resolve(root, 'resources/scripts/sdk/api.ts'), testing: resolve(root, 'resources/scripts/sdk/testing.tsx')}, formats: ['es']}, + rolldownOptions: { + plugins: [esmExternalRequirePlugin({external: peers.map(peer => new RegExp(`^${peer.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:/|$)`))})], + output: {entryFileNames: '[name].js', chunkFileNames: '[name]-[hash].js'}, + }, + }, +}); diff --git a/scripts/check-extension-runtime.mjs b/scripts/check-extension-runtime.mjs new file mode 100644 index 000000000..12205217b --- /dev/null +++ b/scripts/check-extension-runtime.mjs @@ -0,0 +1,84 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath, pathToFileURL } from 'node:url'; +import { createRequire } from 'node:module'; +import { JSDOM } from 'jsdom'; + +const require = createRequire(import.meta.url); +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const manifest = JSON.parse(readFileSync(resolve(root, 'public/assets/manifest.json'), 'utf8')); +const dom = new JSDOM('
', { + url: 'https://panel.test/', + pretendToBeVisual: true, +}); +for (const name of [ + 'window', + 'document', + 'navigator', + 'HTMLElement', + 'Element', + 'Node', + 'MutationObserver', + 'getComputedStyle', + 'requestAnimationFrame', + 'cancelAnimationFrame', + 'localStorage', +]) { + Object.defineProperty(globalThis, name, { configurable: true, value: dom.window[name] }); +} +const load = (source) => import(pathToFileURL(resolve(root, 'public/assets', manifest[source].file)).href); +const modules = [ + [ + 'react', + 'resources/scripts/ext-runtime/react.ts', + ['cache', 'cacheSignal', 'captureOwnerStack', 'unstable_useCacheRefresh'], + ], + ['react-dom', 'resources/scripts/ext-runtime/react-dom.ts', []], + ['react-dom/client', 'resources/scripts/ext-runtime/react-dom-client.ts', []], + ['react/jsx-runtime', 'resources/scripts/ext-runtime/react-jsx-runtime.ts', []], + ['@tanstack/react-query', 'resources/scripts/ext-runtime/tanstack-react-query.ts', []], +]; +try { + for (const [specifier, source, excluded] of modules) { + const built = await load(source); + const installed = require(specifier); + for (const name of Object.keys(installed).filter( + (name) => !name.startsWith('__') && !excluded.includes(name) + )) { + assert.ok(name in built, `${specifier} missing built export ${name}`); + } + if (built.default) { + for (const name of ['useState', 'createPortal', 'createRoot', 'jsx'].filter((name) => name in built)) { + assert.equal(built[name], built.default[name], `${specifier} named/default export identity differs`); + } + } + } + const React = await load('resources/scripts/ext-runtime/react.ts'); + const ReactDOM = await load('resources/scripts/ext-runtime/react-dom.ts'); + const client = await load('resources/scripts/ext-runtime/react-dom-client.ts'); + const query = await load('resources/scripts/ext-runtime/tanstack-react-query.ts'); + const sdk = await load('resources/scripts/sdk/index.ts'); + const api = await load('resources/scripts/sdk/api.ts'); + assert.equal(sdk.queryClient, api.queryClient, 'SDK entries must share the panel QueryClient'); + assert.ok(sdk.queryClient instanceof query.QueryClient, 'SDK and shared Query runtime differ'); + function Consumer() { + const [name] = React.useState('shared'); + React.useEffectEvent(() => name); + assert.equal(query.useQueryClient(), sdk.queryClient); + return React.createElement(React.Activity, { mode: 'visible' }, React.createElement(sdk.Button, null, name)); + } + const container = document.getElementById('extension-runtime-test'); + const mounted = client.createRoot(container); + ReactDOM.flushSync(() => + mounted.render( + React.createElement(query.QueryClientProvider, { client: sdk.queryClient }, React.createElement(Consumer)) + ) + ); + assert.equal(container.textContent, 'shared'); + ReactDOM.flushSync(() => mounted.unmount()); + sdk.queryClient.clear(); + console.log('Built extension runtime: exports, React hooks, UI and shared QueryClient verified.'); +} finally { + dom.window.close(); +} diff --git a/scripts/externalize-extension-api-runtime.mjs b/scripts/externalize-extension-api-runtime.mjs new file mode 100644 index 000000000..bbf72e526 --- /dev/null +++ b/scripts/externalize-extension-api-runtime.mjs @@ -0,0 +1,11 @@ +import { resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { externalizeExtensionApi } from '../packages/sdk/openapi.mjs'; + +const extension = process.argv[2]; +if (!extension || !/^[a-z][a-z0-9-]{0,47}$/.test(extension)) { + throw new Error('Usage: node scripts/externalize-extension-api-runtime.mjs [package-path]'); +} +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +await externalizeExtensionApi(resolve(process.argv[3] ?? resolve(root, 'extensions', extension), 'src/client/generated')); +console.log(`Externalized HeyAPI runtime for ${extension}.`); diff --git a/scripts/generate-extension-api.mjs b/scripts/generate-extension-api.mjs new file mode 100644 index 000000000..61d33d167 --- /dev/null +++ b/scripts/generate-extension-api.mjs @@ -0,0 +1,25 @@ +import { spawnSync } from 'node:child_process'; +import { existsSync, readFileSync } from 'node:fs'; +import { resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const target = process.argv[2]; +if (!target) throw new Error('Usage: npm run extension:api:generate -- '); +const directory = /^[a-z][a-z0-9-]{0,47}$/.test(target) ? resolve(root, 'extensions', target) : resolve(target); +const manifest = JSON.parse(readFileSync(resolve(directory, 'extension.json'), 'utf8')); +const extension = manifest.id; +if (!/^[a-z][a-z0-9-]{0,47}$/.test(extension)) throw new Error('Invalid extension id.'); +const openapiConfig = resolve(directory, 'openapi-ts.config.ts'); +if (!existsSync(openapiConfig)) throw new Error(`OpenAPI TS config not found: ${openapiConfig}`); + +const run = (command, args, cwd = root) => { + const result = spawnSync(command, args, { cwd, stdio: 'inherit', shell: process.platform === 'win32' }); + if (result.error) throw result.error; + if (result.status !== 0) process.exit(result.status ?? 1); +}; + +run('php', [resolve(root, 'scripts/generate-extension-openapi.php'), extension, + resolve(root, 'storage/app/private/scribe/openapi.yaml'), resolve(directory, 'openapi.yaml')]); +run(resolve(root, 'node_modules/.bin/openapi-ts' + (process.platform === 'win32' ? '.cmd' : '')), ['-f', openapiConfig], directory); +run('node', [resolve(root, 'scripts/externalize-extension-api-runtime.mjs'), extension, directory]); diff --git a/scripts/generate-extension-openapi.php b/scripts/generate-extension-openapi.php new file mode 100644 index 000000000..97c5ad77c --- /dev/null +++ b/scripts/generate-extension-openapi.php @@ -0,0 +1,147 @@ + [input] [output]\n"); + exit(1); +} + +$root = dirname(__DIR__); +$input = $argv[2] ?? $root.'/storage/app/private/scribe/openapi.yaml'; +$output = $argv[3] ?? $root.'/extensions/'.$extension.'/openapi.yaml'; + +if (! is_file($input)) { + fwrite(STDERR, "OpenAPI spec not found at {$input}. Run composer docs:openapi first.\n"); + exit(1); +} + +$inputIsJson = mb_strtolower(pathinfo($input, PATHINFO_EXTENSION)) === 'json'; +$outputIsJson = mb_strtolower(pathinfo($output, PATHINFO_EXTENSION)) === 'json'; +if (! $inputIsJson || ! $outputIsJson) { + $autoload = $root.'/vendor/autoload.php'; + if (! is_file($autoload)) { + fwrite(STDERR, "YAML input or output requires Composer dependencies. Run composer install or use JSON files.\n"); + exit(1); + } + + require $autoload; +} + +$document = $inputIsJson + ? json_decode(file_get_contents($input), false, 512, JSON_THROW_ON_ERROR) + : Yaml::parseFile($input); +$spec = $document instanceof stdClass ? get_object_vars($document) : $document; +if (is_array($spec) && ($spec['paths'] ?? null) instanceof stdClass) { + $spec['paths'] = get_object_vars($spec['paths']); +} + +if (! is_array($spec) || ! isset($spec['paths']) || ! is_array($spec['paths'])) { + fwrite(STDERR, "OpenAPI spec does not contain a paths object.\n"); + exit(1); +} + +$prefixes = [ + '/api/client/extensions/'.$extension, + '/api/admin/extensions/'.$extension, + '/api/application/extensions/'.$extension, + '/api/client/servers/{server}/extensions/'.$extension, +]; + +$paths = []; +foreach ($spec['paths'] as $path => $operations) { + if (! is_string($path)) { + continue; + } + + foreach ($prefixes as $prefix) { + if ($path === $prefix || str_starts_with($path, $prefix.'/')) { + $paths[$path] = $operations; + + break; + } + } +} + +if ($paths === []) { + fwrite(STDERR, "No extension OpenAPI paths found for {$extension}.\n"); + exit(1); +} + +$spec['paths'] = $paths; +$spec['info'] = (array) ($spec['info'] ?? []); +$spec['info']['title'] = mb_trim(($spec['info']['title'] ?? 'Pterodactyl API').' - '.$extension); +pruneUnusedSchemas($spec); + +$directory = dirname($output); +if (! is_dir($directory) && ! mkdir($directory, 0775, true) && ! is_dir($directory)) { + fwrite(STDERR, "Unable to create output directory {$directory}.\n"); + exit(1); +} + +$contents = $outputIsJson + ? json_encode($spec, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR)."\n" + : Yaml::dump($spec, 20, 2, Yaml::DUMP_OBJECT_AS_MAP | Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK); +if (file_put_contents($output, $contents) === false) { + fwrite(STDERR, "Unable to write OpenAPI spec to {$output}.\n"); + exit(1); +} + +printf("Extension OpenAPI written: %s (%d paths).\n", $output, count($paths)); + +/** @param array $spec */ +function pruneUnusedSchemas(array &$spec): void +{ + $components = $spec['components'] ?? null; + $components = $components instanceof stdClass ? get_object_vars($components) : $components; + if (! is_array($components) || ! isset($components['schemas'])) { + return; + } + + $schemas = $components['schemas']; + $schemas = $schemas instanceof stdClass ? get_object_vars($schemas) : $schemas; + if (! is_array($schemas)) { + return; + } + + $used = []; + collectSchemaRefs($spec['paths'], $used); + + $queue = array_keys($used); + while ($queue !== []) { + $name = array_pop($queue); + if (! is_string($name) || ! isset($schemas[$name])) { + continue; + } + + $before = array_keys($used); + collectSchemaRefs($schemas[$name], $used); + foreach (array_diff(array_keys($used), $before) as $next) { + $queue[] = $next; + } + } + + $components['schemas'] = (object) array_intersect_key($schemas, $used); + $spec['components'] = $components; +} + +/** @param array $used */ +function collectSchemaRefs(mixed $value, array &$used): void +{ + $value = $value instanceof stdClass ? get_object_vars($value) : $value; + if (! is_array($value)) { + return; + } + + $ref = $value['$ref'] ?? null; + if (is_string($ref) && str_starts_with($ref, '#/components/schemas/')) { + $used[mb_substr($ref, mb_strlen('#/components/schemas/'))] = true; + } + + foreach ($value as $child) { + collectSchemaRefs($child, $used); + } +} diff --git a/scripts/generate-sdk-icons.mjs b/scripts/generate-sdk-icons.mjs new file mode 100644 index 000000000..e193c2dc9 --- /dev/null +++ b/scripts/generate-sdk-icons.mjs @@ -0,0 +1,23 @@ +import { readFileSync, writeFileSync } from 'node:fs'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { icons } from 'lucide-react'; +import dynamicIconImports from 'lucide-react/dynamicIconImports.mjs'; + +// The icon names `nav.icon` and the SDK's resolve: lucide's canonical names +// (deprecated aliases are left out) in the release the panel is built with. PHP reads +// this list (p:extension:doctor) because it cannot inspect the frontend bundle, and +// extension tooling can read it from the SDK package. +const output = resolve(dirname(fileURLToPath(import.meta.url)), '../packages/sdk/icons.json'); +const exportName = (name) => name.replace(/(?:^|-)([a-z0-9])/g, (_match, letter) => letter.toUpperCase()); +const names = Object.keys(dynamicIconImports).filter((name) => exportName(name) in icons); +const expected = JSON.stringify(names.sort()) + '\n'; + +if (process.argv.includes('--check')) { + if (readFileSync(output, 'utf8') !== expected) { + console.error('packages/sdk/icons.json is out of date. Run npm run sdk:generate.'); + process.exit(1); + } +} else { + writeFileSync(output, expected); +} diff --git a/scripts/generate-sdk-types.mjs b/scripts/generate-sdk-types.mjs new file mode 100644 index 000000000..1671a2c60 --- /dev/null +++ b/scripts/generate-sdk-types.mjs @@ -0,0 +1,128 @@ +import ts from 'typescript'; +import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync } from 'node:fs'; +import { dirname, resolve, posix, sep } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +// TypeScript reports forward-slash paths on every platform; keep ours comparable. +const portable = (path) => path.split(sep).join('/'); +const sourceRoot = portable(resolve(root, 'resources/scripts')); +const outputRoot = portable(resolve(root, 'packages/sdk/types')); +const configuration = ts.readConfigFile(resolve(root, 'tsconfig.json'), ts.sys.readFile); +const parsed = ts.parseJsonConfigFileContent(configuration.config, ts.sys, root); +const options = { + ...parsed.options, + noEmit: false, + declaration: true, + emitDeclarationOnly: true, + noEmitOnError: true, + declarationMap: false, + sourceMap: false, + rootDir: sourceRoot, + outDir: outputRoot, + newLine: ts.NewLineKind.LineFeed, +}; +const program = ts.createProgram({ + rootNames: ['sdk/index.ts', 'sdk/api.ts', 'sdk/testing.tsx', 'vite-env.d.ts'].map((path) => resolve(sourceRoot, path)), + options, +}); +const emitted = new Map(); +const result = program.emit(undefined, (file, text) => emitted.set(posix.relative(outputRoot, portable(file)), text)); +const diagnostics = [...ts.getPreEmitDiagnostics(program), ...result.diagnostics]; +if (diagnostics.length) { + console.error( + ts.formatDiagnosticsWithColorAndContext(diagnostics, { + getCanonicalFileName: (file) => file, + getCurrentDirectory: () => root, + getNewLine: () => '\n', + }) + ); + process.exit(1); +} +for (const file of program.getSourceFiles()) { + if (file.isDeclarationFile && file.fileName.startsWith(sourceRoot + '/')) + emitted.set(posix.relative(sourceRoot, file.fileName), file.text); +} +const files = new Map(); +const external = new Set(); +function visit(path) { + if (files.has(path)) return; + const source = emitted.get(path); + if (!source) throw new Error(`Missing SDK declaration: ${path}`); + files.set(path, ''); + const ast = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true); + const replacements = []; + function collect(node) { + const literal = + ts.isImportDeclaration(node) || ts.isExportDeclaration(node) + ? node.moduleSpecifier + : ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument) + ? node.argument.literal + : undefined; + if (literal && ts.isStringLiteral(literal)) { + const specifier = literal.text; + if (specifier.startsWith('@/') || specifier.startsWith('@feature/') || specifier.startsWith('.')) { + const target = ( + specifier.startsWith('@/') + ? specifier.slice(2) + : specifier.startsWith('@feature/') + ? `components/server/features/${specifier.slice(9)}` + : posix.normalize(posix.join(posix.dirname(path), specifier)) + ).replace(/\.js$/, ''); + const declaration = [`${target}.d.ts`, `${target}/index.d.ts`, `${target}.ts`].find((candidate) => + emitted.has(candidate) + ); + if (!declaration) throw new Error(`Unresolved SDK type import ${specifier} in ${path}`); + visit(declaration); + let portable = posix.relative(posix.dirname(path), declaration.replace(/\.d\.ts$/, '.js')); + if (!portable.startsWith('.')) portable = `./${portable}`; + replacements.push({ start: literal.getStart(ast), end: literal.end, text: JSON.stringify(portable) }); + } else external.add(specifier); + } + ts.forEachChild(node, collect); + } + collect(ast); + let text = source; + for (const replacement of replacements.sort((a, b) => b.start - a.start)) + text = text.slice(0, replacement.start) + replacement.text + text.slice(replacement.end); + files.set(path, '// Generated by scripts/generate-sdk-types.mjs. Do not edit.\n' + text); +} +visit('sdk/index.d.ts'); +visit('sdk/api.d.ts'); +visit('sdk/testing.d.ts'); +files.set('testing.d.ts', "// Generated by scripts/generate-sdk-types.mjs. Do not edit.\nexport * from './sdk/testing.js';\n"); +files.set( + 'index.d.ts', + "// Generated by scripts/generate-sdk-types.mjs. Do not edit.\nexport * from './sdk/index.js';\n" +); +files.set('api.d.ts', "// Generated by scripts/generate-sdk-types.mjs. Do not edit.\nexport * from './sdk/api.js';\n"); +const metadata = JSON.parse(readFileSync(resolve(root, 'packages/sdk/package.json'), 'utf8')); +for (const specifier of external) { + const name = specifier.startsWith('@') ? specifier.split('/').slice(0, 2).join('/') : specifier.split('/')[0]; + if (!(name in metadata.peerDependencies) && !(name in (metadata.dependencies ?? {}))) + throw new Error(`SDK type dependency ${name} is not declared`); +} +const existing = readdirSync(outputRoot, { recursive: true }) + .map(portable) + .filter((path) => path.endsWith('.d.ts')); +if (process.argv.includes('--check')) { + const stale = existing.filter((path) => !files.has(path)); + for (const [path, text] of files) { + try { + if (readFileSync(resolve(outputRoot, path), 'utf8') !== text) stale.push(path); + } catch { + stale.push(path); + } + } + if (stale.length) { + console.error('SDK declarations are stale. Run npm run sdk:generate.\n' + stale.join('\n')); + process.exit(1); + } +} else { + for (const path of existing) if (!files.has(path)) rmSync(resolve(outputRoot, path)); + for (const [path, text] of files) { + mkdirSync(dirname(resolve(outputRoot, path)), { recursive: true }); + writeFileSync(resolve(outputRoot, path), text); + } +} +console.log(`SDK: ${files.size} declaration files; external types: ${[...external].sort().join(', ')}`); diff --git a/shell.nix b/shell.nix index 97e485d15..181c62c57 100644 --- a/shell.nix +++ b/shell.nix @@ -8,8 +8,7 @@ with pkgs; buildInputs = [ alejandra composer - nodejs_18 - nodePackages.yarn + nodejs_22 phpWithExtensions ]; diff --git a/tailwind.config.js b/tailwind.config.js deleted file mode 100644 index 7c814bd61..000000000 --- a/tailwind.config.js +++ /dev/null @@ -1,51 +0,0 @@ -const colors = require('tailwindcss/colors'); - -const gray = { - 50: 'hsl(216, 33%, 97%)', - 100: 'hsl(214, 15%, 91%)', - 200: 'hsl(210, 16%, 82%)', - 300: 'hsl(211, 13%, 65%)', - 400: 'hsl(211, 10%, 53%)', - 500: 'hsl(211, 12%, 43%)', - 600: 'hsl(209, 14%, 37%)', - 700: 'hsl(209, 18%, 30%)', - 800: 'hsl(209, 20%, 25%)', - 900: 'hsl(210, 24%, 16%)', -}; - -module.exports = { - content: [ - './resources/scripts/**/*.{js,ts,tsx}', - ], - theme: { - extend: { - fontFamily: { - header: ['"IBM Plex Sans"', '"Roboto"', 'system-ui', 'sans-serif'], - }, - colors: { - black: '#131a20', - // "primary" and "neutral" are deprecated, prefer the use of "blue" and "gray" - // in new code. - primary: colors.blue, - gray: gray, - neutral: gray, - cyan: colors.cyan, - }, - fontSize: { - '2xs': '0.625rem', - }, - transitionDuration: { - 250: '250ms', - }, - borderColor: theme => ({ - default: theme('colors.neutral.400', 'currentColor'), - }), - }, - }, - plugins: [ - require('@tailwindcss/line-clamp'), - require('@tailwindcss/forms')({ - strategy: 'class', - }), - ] -}; diff --git a/tests/Architecture/OpenApiContractTest.php b/tests/Architecture/OpenApiContractTest.php new file mode 100644 index 000000000..32c954f5b --- /dev/null +++ b/tests/Architecture/OpenApiContractTest.php @@ -0,0 +1,175 @@ + */ +function specification(): array +{ + static $spec = null; + + expect(OpenApiSpecValidator::specPath())->toBeFile('Generate the specification with composer docs:openapi first.'); + + return $spec ??= Yaml::parseFile(OpenApiSpecValidator::specPath()); +} + +/** @return Generator, parameters: array>}> */ +function operations(): Generator +{ + foreach (specification()['paths'] as $path => $pathItem) { + foreach (Arr::only($pathItem, ['get', 'post', 'put', 'patch', 'delete']) as $method => $operation) { + yield Str::upper($method).' '.$path => [ + 'method' => $method, + 'path' => $path, + 'operation' => $operation, + 'parameters' => [...($pathItem['parameters'] ?? []), ...($operation['parameters'] ?? [])], + ]; + } + } +} + +function operationKey(string $method, string $uri): string +{ + return Str::upper($method).' /'.preg_replace('/\{[^}]+\}/', '{}', mb_trim($uri, '/')); +} + +/** + * @param array $node + * @return list + */ +function schemaReferences(array $node): array +{ + return collect(Arr::dot($node)) + ->filter(fn (mixed $value, string $key): bool => ($key === '$ref' || Str::endsWith($key, '.$ref')) && is_string($value) && Str::startsWith($value, '#/components/schemas/')) + ->map(fn (string $ref): string => Str::after($ref, '#/components/schemas/')) + ->unique()->values()->all(); +} + +test('documents every registered API route and configured authentication route', function (): void { + $prefixes = config('scribe.routes.0.match.prefixes'); + $expected = collect(Route::getRoutes()->getRoutes()) + ->filter(fn (RegisteredRoute $route): bool => Str::is($prefixes, $route->uri())) + ->flatMap(fn (RegisteredRoute $route): array => array_map( + fn (string $method): string => operationKey($method, $route->uri()), + array_diff($route->methods(), ['HEAD', 'OPTIONS']), + )) + ->merge(array_map(function (string $route): string { + [$method, $uri] = explode(' ', $route, 2); + + return operationKey($method, $uri); + }, config('scribe.routes.0.include'))) + ->unique()->sort()->values()->all(); + $actual = collect(iterator_to_array(operations())) + ->map(fn (array $entry): string => operationKey($entry['method'], $entry['path'])) + ->sort()->values()->all(); + + expect($actual)->toBe($expected); +}); + +test('gives operations unique identifiers and useful documentation', function (): void { + $identifiers = []; + foreach (operations() as $label => $entry) { + $operation = $entry['operation']; + foreach (['operationId', 'summary', 'description'] as $field) { + expect(mb_trim($operation[$field] ?? ''))->not->toBeEmpty($label.' '.$field); + } + + $identifiers[] = $operation['operationId']; + } + + expect($identifiers)->not->toBeEmpty()->toBe(array_values(array_unique($identifiers))); +}); + +test('documents path parameters and publishes reusable parameter schemas', function (): void { + foreach (operations() as $label => $entry) { + $parameters = collect($entry['parameters']); + preg_match_all('/\{([^}?]+)\??\}/', $entry['path'], $matches); + foreach ($matches[1] as $name) { + $parameter = $parameters->last(fn (array $parameter): bool => ($parameter['in'] ?? null) === 'path' && ($parameter['name'] ?? null) === $name); + expect($parameter)->not->toBeNull($label.' '.$name); + expect(mb_trim($parameter['description'] ?? ''))->not->toBeEmpty($label.' '.$name); + } + + foreach ($parameters->whereIn('in', ['path', 'query']) as $parameter) { + expect($parameter['schema']['$ref'] ?? '')->toStartWith('#/components/schemas/', $label.' '.$parameter['name']); + } + } +}); + +test('publishes reusable request schemas and keeps GET inputs in parameters', function (): void { + foreach (operations() as $label => $entry) { + $operation = $entry['operation']; + if ($entry['method'] === 'get') { + expect($operation)->not->toHaveKey('requestBody', message: $label); + } + + if (! isset($operation['requestBody'])) { + continue; + } + + $content = $operation['requestBody']['content'] ?? []; + expect($content)->not->toBeEmpty($label); + foreach ($content as $media) { + expect($media['schema']['$ref'] ?? '')->toStartWith('#/components/schemas/', $label); + } + } +}); + +test('documents success responses and consistent reusable error envelopes', function (): void { + foreach (operations() as $label => $entry) { + $responses = $entry['operation']['responses'] ?? []; + expect($responses)->not->toBeEmpty($label); + expect(collect(array_keys($responses))->contains(fn (int|string $status): bool => Str::startsWith((string) $status, '2')))->toBeTrue($label.' success'); + expect(collect($responses)->contains(fn (array $response, int|string $status): bool => (string) $status === '204' || isset($response['content']['application/json']['schema'])))->toBeTrue($label.' schema'); + foreach ($responses as $status => $response) { + foreach ($response['content'] ?? [] as $media) { + $ref = $media['schema']['$ref'] ?? ''; + expect($ref)->toStartWith('#/components/schemas/', $label.' '.$status); + if ((int) $status >= 400 && (int) $status < 600) { + expect($ref)->toBe('#/components/schemas/'.((int) $status === 422 ? 'ValidationErrorEnvelope' : 'ErrorEnvelope'), $label.' '.$status); + } + } + } + } +}); + +test('publishes concrete reachable component schemas without dangling references', function (): void { + $spec = specification(); + $schemas = $spec['components']['schemas']; + expect($schemas)->toHaveKeys(['ErrorEnvelope', 'ValidationErrorEnvelope', 'PaginationMeta']); + foreach (Arr::dot($schemas) as $key => $value) { + if ($value !== 'object' || ! Str::endsWith($key, '.type')) { + continue; + } + + $schema = Arr::get($schemas, Str::beforeLast($key, '.type')); + expect(Arr::only($schema, ['properties', 'additionalProperties', 'oneOf', 'anyOf', 'allOf']))->not->toBeEmpty($key); + } + + $pending = schemaReferences($spec['paths']); + $reachable = []; + while ($pending !== []) { + $name = array_pop($pending); + if (isset($reachable[$name])) { + continue; + } + + expect($schemas)->toHaveKey($name); + $reachable[$name] = true; + array_push($pending, ...schemaReferences($schemas[$name])); + } + + expect(array_diff(array_keys($schemas), array_keys($reachable)))->toBe([]); +}); diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index 7bf990d5d..30dd42ac0 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -1,17 +1,19 @@ request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.'); + Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has '.$attribute.' attribute.'); } /** @@ -19,7 +21,7 @@ trait MiddlewareAttributeAssertionsTrait */ public function assertRequestMissingAttribute(string $attribute): void { - Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.'); + Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have '.$attribute.' attribute.'); } /** diff --git a/tests/Fixtures/assets/manifest.json b/tests/Fixtures/assets/manifest.json new file mode 100644 index 000000000..6363b63e9 --- /dev/null +++ b/tests/Fixtures/assets/manifest.json @@ -0,0 +1,62 @@ +{ + "resources/scripts/index.tsx": { + "file": "bundle.test.js", + "name": "main", + "src": "resources/scripts/index.tsx", + "isEntry": true, + "css": ["main.test.css"], + "integrity": "sha384-test-main", + "cssIntegrity": { + "main.test.css": "sha384-test-main-css" + } + }, + "resources/scripts/ext-runtime/react.ts": { + "file": "ext-runtime.react.test.js", + "name": "react", + "src": "resources/scripts/ext-runtime/react.ts", + "isEntry": true, + "integrity": "sha384-test-react" + }, + "resources/scripts/ext-runtime/react-jsx-runtime.ts": { + "file": "ext-runtime.react-jsx-runtime.test.js", + "name": "react-jsx-runtime", + "src": "resources/scripts/ext-runtime/react-jsx-runtime.ts", + "isEntry": true, + "integrity": "sha384-test-react-jsx-runtime" + }, + "resources/scripts/ext-runtime/react-dom.ts": { + "file": "ext-runtime.react-dom.test.js", + "name": "react-dom", + "src": "resources/scripts/ext-runtime/react-dom.ts", + "isEntry": true, + "integrity": "sha384-test-react-dom" + }, + "resources/scripts/ext-runtime/react-dom-client.ts": { + "file": "ext-runtime.react-dom-client.test.js", + "name": "react-dom-client", + "src": "resources/scripts/ext-runtime/react-dom-client.ts", + "isEntry": true, + "integrity": "sha384-test-react-dom-client" + }, + "resources/scripts/ext-runtime/tanstack-react-query.ts": { + "file": "ext-runtime.tanstack-react-query.test.js", + "name": "tanstack-react-query", + "src": "resources/scripts/ext-runtime/tanstack-react-query.ts", + "isEntry": true, + "integrity": "sha384-test-tanstack-react-query" + }, + "resources/scripts/sdk/index.ts": { + "file": "ext-runtime.sdk.test.js", + "name": "sdk", + "src": "resources/scripts/sdk/index.ts", + "isEntry": true, + "integrity": "sha384-test-sdk" + }, + "resources/scripts/sdk/api.ts": { + "file": "ext-runtime.sdk-api.test.js", + "name": "sdk-api", + "src": "resources/scripts/sdk/api.ts", + "isEntry": true, + "integrity": "sha384-test-sdk-api" + } +} diff --git a/tests/Fixtures/keys/x509-certificate.pem b/tests/Fixtures/keys/x509-certificate.pem new file mode 100644 index 000000000..e084db595 --- /dev/null +++ b/tests/Fixtures/keys/x509-certificate.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIIClzCCAX+gAwIBAgIBADANBgkqhkiG9w0BAQUFADAPMQ0wCwYDVQQDDAR0ZXN0 +MB4XDTI2MDYyODIxMzQzMFoXDTI2MDYyOTIxMzQzMFowDzENMAsGA1UEAwwEdGVz +dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALZNPzyWTEinfefSMYI8 +jPtiDpQ3n4xnqobumxAMDSQd7Wkbi9MyWfV3tr7PIVzblC4aH5iLIy5dOhUWqyBd +LwYbmdGfeghnP261CrYw4npoBO+k1CoAtfjxuv5Mkz9zs4/BtknyqKxteLxLglJI +VTTl/IdGVdacvBSkfystMkK3AjvIwNseWLe2fcwMSs1k0yN/p/6NUYsO4BBkybaM +JF7s3s29nKZDwPn8HxYD/5cnStSI0nhcltYF5O7/6DiH4x5lvT4Z9D+aHppDMTur +yxAkMTSTZqMkE5iOtk6XrnEaXDVOci1fYFYIO0yKExnbf2DkB//W9f1wMYbO40Zc +jMkCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAAbbdgyP9X3kAgMdMo2yMX6jJC9Kl +NTio30d+NPCXsziA6elS2wWK7LhAVx0WRCho3KNJC2j3sKGOSXwf7HlG8yX4QPng +oMf91+yM95yhJZxVGelKfBGg34Wu1e8l0FcuCchmseR8QtwwuwScDXnYQV7PyRiW +OJ5KEg6opQivmfI4gJWDNbe6ALwHxR0TZeRITQ+tU0r/JCFwbjMX2pFNAl2sjE9x +iiZwIndK2bAsME622kuPgfx/osJ/8zuQhBeRsiLfUT44j2RJNRj99gXRfKAA0vyG +LaKfKLpXnF7mm6UuShG/HRt07bxu6Ayan/SJnv3E5ZkinR5lX0upcmM/gQ== +-----END CERTIFICATE----- diff --git a/tests/Integration/Api/Admin/Activity/ActivityControllerTest.php b/tests/Integration/Api/Admin/Activity/ActivityControllerTest.php new file mode 100644 index 000000000..2f853f3a0 --- /dev/null +++ b/tests/Integration/Api/Admin/Activity/ActivityControllerTest.php @@ -0,0 +1,190 @@ +createServerModel(); + Activity::event('admin:server.build')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + Activity::event('admin:server.reinstall')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + + $response = $this->getJson(route('api.admin.activity'))->assertStatus(Response::HTTP_OK); + + $response->assertJsonPath('object', 'list'); + $response->assertJsonPath('data.0.object', 'activity_log'); + $response->assertJsonPath('data.0.attributes.event', 'admin:server.reinstall'); + $response->assertJsonPath('data.1.attributes.event', 'admin:server.build'); +}); +test('administrative activity spans every server rather than one', function () { + $first = $this->createServerModel(); + $second = $this->createServerModel(); + Activity::event('admin:server.build')->actor($this->getAdminUser())->subject($first)->property('name', $first->name)->log(); + Activity::event('admin:server.suspend')->actor($this->getAdminUser())->subject($second)->property('name', $second->name)->log(); + + $events = collect($this->getJson(route('api.admin.activity'))->assertOk()->json('data'))->pluck('attributes.event'); + + expect($events)->toContain('admin:server.build', 'admin:server.suspend'); +}); +test('customer activity is excluded from the administrative log', function () { + $server = $this->createServerModel(); + Activity::event('admin:server.build')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + Activity::event('server:power.start')->actor($this->getAdminUser())->subject($server)->log(); + Activity::event('server:file.write')->actor($this->getAdminUser())->subject($server)->property('file', '/a.txt')->log(); + Activity::event('user:account.password-changed')->actor($this->getAdminUser())->subject($this->getAdminUser())->log(); + Activity::event('auth:success')->actor($this->getAdminUser())->subject($this->getAdminUser())->log(); + + $events = collect($this->getJson(route('api.admin.activity'))->assertOk()->json('data'))->pluck('attributes.event'); + + expect($events)->toContain('admin:server.build'); + expect($events)->not->toContain('server:power.start'); + expect($events)->not->toContain('server:file.write'); + expect($events)->not->toContain('user:account.password-changed'); + expect($events)->not->toContain('auth:success'); +}); +test('activity can be filtered by event and includes the actor', function () { + $server = $this->createServerModel(); + Activity::event('admin:server.build')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + Activity::event('admin:server.suspend')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + + $response = $this->getJson(route('api.admin.activity', ['filter' => ['event' => 'suspend'], 'include' => 'actor']))->assertOk(); + + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.event', 'admin:server.suspend'); + $response->assertJsonPath('data.0.attributes.relationships.actor.attributes.email', $this->getAdminUser()->email); +}); +test('the originating address is exposed to administrators', function () { + $server = $this->createServerModel(); + Activity::event('admin:server.build')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->withRequestMetadata()->log(); + + $row = $this->getJson(route('api.admin.activity'))->assertOk()->json('data.0.attributes'); + + expect($row['ip'])->toBe('127.0.0.1'); + expect($row['properties']['ip'])->toBe('127.0.0.1'); +}); +test('disabled events are never listed', function () { + $server = $this->createServerModel(); + Activity::event(ActivityLog::DISABLED_EVENTS[0])->actor($this->getAdminUser())->subject($server)->log(); + + $events = collect($this->getJson(route('api.admin.activity'))->assertOk()->json('data'))->pluck('attributes.event'); + + expect($events)->not->toContain(ActivityLog::DISABLED_EVENTS[0]); +}); +test('the event filter cannot reach outside the administrative namespace', function () { + $server = $this->createServerModel(); + Activity::event('server:power.start')->actor($this->getAdminUser())->subject($server)->log(); + + $response = $this->getJson(route('api.admin.activity', ['filter' => ['event' => 'server:power.start']]))->assertOk(); + + $response->assertJsonCount(0, 'data'); +}); +test('endpoint requires an authenticated administrator', function () { + $this->app->get('auth')->forgetGuards(); + $this->getJson(route('api.admin.activity'))->assertUnauthorized(); + + $this->actingAs(User::factory()->create(['root_admin' => false])); + $this->getJson(route('api.admin.activity'))->assertForbidden(); +}); +test('activity can be filtered by the user that performed it', function () { + $server = $this->createServerModel(); + $other = User::factory()->create(['username' => 'someone-else', 'email' => 'else@example.com']); + Activity::event('admin:server.build')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + Activity::event('admin:server.suspend')->actor($other)->subject($server)->property('name', $server->name)->log(); + + $byUsername = collect($this->getJson(route('api.admin.activity', ['filter' => ['user' => 'someone-else']]))->assertOk()->json('data'))->pluck('attributes.event'); + expect($byUsername->all())->toBe(['admin:server.suspend']); + + $byEmail = collect($this->getJson(route('api.admin.activity', ['filter' => ['user' => 'else@example.com']]))->assertOk()->json('data'))->pluck('attributes.event'); + expect($byEmail->all())->toBe(['admin:server.suspend']); +}); +test('the user filter combines with the event filter', function () { + $server = $this->createServerModel(); + $other = User::factory()->create(['username' => 'someone-else']); + Activity::event('admin:server.build')->actor($other)->subject($server)->property('name', $server->name)->log(); + Activity::event('admin:server.suspend')->actor($other)->subject($server)->property('name', $server->name)->log(); + Activity::event('admin:server.suspend')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + + $response = $this->getJson(route('api.admin.activity', ['filter' => ['user' => 'someone-else', 'event' => 'suspend']]))->assertOk(); + + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.event', 'admin:server.suspend'); +}); +test('an entry without a user actor is excluded by the user filter', function () { + $server = $this->createServerModel(); + Activity::event('admin:server.build')->anonymous()->subject($server)->property('name', $server->name)->log(); + + $this->getJson(route('api.admin.activity', ['filter' => ['user' => 'anything']]))->assertOk()->assertJsonCount(0, 'data'); +}); +test('filtering by user id matches only that user', function () { + $server = $this->createServerModel(); + $dan = User::factory()->create(['username' => 'dan']); + $danny = User::factory()->create(['username' => 'danny']); + Activity::event('admin:server.build')->actor($dan)->subject($server)->property('name', $server->name)->log(); + Activity::event('admin:server.suspend')->actor($danny)->subject($server)->property('name', $server->name)->log(); + + $byText = $this->getJson(route('api.admin.activity', ['filter' => ['user' => 'dan']]))->assertOk(); + expect($byText->json('data'))->toHaveCount(2); + + $byId = $this->getJson(route('api.admin.activity', ['filter' => ['user_id' => $dan->id]]))->assertOk(); + expect($byId->json('data'))->toHaveCount(1); + $byId->assertJsonPath('data.0.attributes.event', 'admin:server.build'); +}); +test('filter options list the events and users present in the log', function () { + $server = $this->createServerModel(); + $other = User::factory()->create(['username' => 'zz-last']); + Activity::event('admin:server.build')->actor($this->getAdminUser())->subject($server)->property('name', $server->name)->log(); + Activity::event('admin:server.suspend')->actor($other)->subject($server)->property('name', $server->name)->log(); + Activity::event('server:power.start')->actor($other)->subject($server)->log(); + + $data = $this->getJson(route('api.admin.activity.filters'))->assertOk()->json('data'); + + expect($data['events'])->toBe(['admin:server.build', 'admin:server.suspend']); + expect(collect($data['users'])->pluck('username')->all())->toContain('zz-last'); + expect(collect($data['users'])->pluck('id')->all())->toContain($other->id); +}); +test('filter options never leak customer activity into the admin log', function () { + $server = $this->createServerModel(); + Activity::event('server:power.start')->actor($this->getAdminUser())->subject($server)->log(); + + $data = $this->getJson(route('api.admin.activity.filters'))->assertOk()->json('data'); + + expect($data['events'])->toBe([]); + expect($data['users'])->toBe([]); +}); +test('filter options require administrator access', function () { + $this->actingAs(User::factory()->create(['root_admin' => false])); + + $this->getJson(route('api.admin.activity.filters'))->assertForbidden(); +}); +test('the exact event filter does not match longer event names', function () { + $node = $this->createServerModel()->node; + Activity::event('admin:node-allocation.delete')->actor($this->getAdminUser())->subject($node)->property('address', '10.0.0.1')->property('port', 25565)->log(); + Activity::event('admin:node-allocation.delete-block')->actor($this->getAdminUser())->subject($node)->property('address', '10.0.0.1')->log(); + + expect($this->getJson(route('api.admin.activity', ['filter' => ['event' => 'admin:node-allocation.delete']]))->assertOk()->json('data'))->toHaveCount(2); + + $exact = $this->getJson(route('api.admin.activity', ['filter' => ['event_name' => 'admin:node-allocation.delete']]))->assertOk(); + expect($exact->json('data'))->toHaveCount(1); + $exact->assertJsonPath('data.0.attributes.event', 'admin:node-allocation.delete'); +}); + +test('malformed activity user filters return 422', function () { + $this->getJson(route('api.admin.activity', ['filter' => ['user' => ['nested' => 'value']]])) + ->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'filter.user'); +}); + +test('actor filters retain commas in email addresses', function () { + $actor = User::factory()->create(['email' => 'comma,actor@example.com']); + Activity::event('admin:user.create')->actor($actor)->subject($actor)->property('username', $actor->username)->log(); + + $this->getJson(route('api.admin.activity', ['filter' => ['user' => 'comma,actor@example.com']])) + ->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.event', 'admin:user.create'); +}); diff --git a/tests/Integration/Api/Admin/AdminApiIntegrationTestCase.php b/tests/Integration/Api/Admin/AdminApiIntegrationTestCase.php new file mode 100644 index 000000000..ff05a3a89 --- /dev/null +++ b/tests/Integration/Api/Admin/AdminApiIntegrationTestCase.php @@ -0,0 +1,56 @@ +user = $this->createAdminUser(); + + $this->actingAs($this->user); + } + + /** Return the root administrator the test is currently acting as. */ + public function getAdminUser(): User + { + return $this->user; + } + + /** Create a root administrator user. */ + protected function createAdminUser(): User + { + return User::factory()->create([ + 'root_admin' => true, + ]); + } + + /** Switch to a non-administrative account to assert the admin API rejects it. */ + protected function actingAsNonAdmin(): User + { + $user = User::factory()->create([ + 'root_admin' => false, + ]); + + $this->actingAs($user); + + return $user; + } +} diff --git a/tests/Integration/Api/Admin/ApiKeyAccessTest.php b/tests/Integration/Api/Admin/ApiKeyAccessTest.php new file mode 100644 index 000000000..f2ecef14e --- /dev/null +++ b/tests/Integration/Api/Admin/ApiKeyAccessTest.php @@ -0,0 +1,54 @@ +create(['root_admin' => true]); + $key = ApiKey::factory()->create(['user_id' => $admin->id, 'key_type' => ApiKey::TYPE_APPLICATION, ...$permissions]); + withKey($key); + + $denied = ['errors' => [['code' => 'AccessDeniedHttpException', 'status' => '403', 'detail' => 'You are attempting to use an application API key on an endpoint that does not accept them.']]]; + $this->getJson('/api/admin/users')->assertForbidden()->assertExactJson($denied); + $this->postJson('/api/admin/tags', ['name' => 'Escalated', 'slug' => 'escalated'])->assertForbidden()->assertExactJson($denied); + expect(Tag::query()->where('slug', 'escalated')->exists())->toBeFalse(); +})->with([ + 'node deployment key' => [['r_nodes' => 1]], + 'key with every permission' => [['r_servers' => 3, 'r_nodes' => 3, 'r_allocations' => 3, 'r_users' => 3, 'r_locations' => 3, 'r_eggs' => 3, 'r_database_hosts' => 3, 'r_server_databases' => 3]], +]); +test('a root administrator account key can use the admin API', function (): void { + $admin = User::factory()->create(['root_admin' => true]); + withKey(ApiKey::factory()->create(['user_id' => $admin->id, 'key_type' => ApiKey::TYPE_ACCOUNT])); + + $this->getJson('/api/admin/users')->assertOk(); +}); +test('an account key of a user who is not a root administrator cannot use the admin API', function (): void { + $user = User::factory()->create(['root_admin' => false]); + withKey(ApiKey::factory()->create(['user_id' => $user->id, 'key_type' => ApiKey::TYPE_ACCOUNT])); + + $this->assertAccessDeniedJson($this->getJson('/api/admin/users')); +}); +test('a root administrator session can use the admin API', function (): void { + $this->actingAs(User::factory()->create(['root_admin' => true])); + + $this->getJson('/api/admin/users')->assertOk(); +}); +/** + * Send the key as a bearer token on the following requests. + */ +function withKey(ApiKey $key): void +{ + pterodactylTestCase()->withHeader('Accept', 'application/vnd.pterodactyl.v1+json') + ->withHeader('Authorization', 'Bearer '.$key->identifier.decrypt($key->token)); +} diff --git a/tests/Integration/Api/Admin/ApiKeys/ApiKeyControllerTest.php b/tests/Integration/Api/Admin/ApiKeys/ApiKeyControllerTest.php new file mode 100644 index 000000000..fbaa421dc --- /dev/null +++ b/tests/Integration/Api/Admin/ApiKeys/ApiKeyControllerTest.php @@ -0,0 +1,108 @@ + [['getJson', 'api.admin.api-keys'], ['getJson', 'api.admin.api-keys.view'], ['postJson', 'api.admin.api-keys.store'], ['putJson', 'api.admin.api-keys.update'], ['delete', 'api.admin.api-keys.delete']]); +dataset('apiKeyListSortsDataProvider', fn (): array => [['memo'], ['-memo'], ['created_at'], ['-created_at']]); +test('get api keys', function (): void { + $keys = ApiKey::factory()->times(2)->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION]); + $response = $this->getJson(route('api.admin.api-keys', ['per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['identifier', 'memo', 'created_by' => ['id', 'username', 'email'], 'last_used_at', 'created_at', 'r_servers']], ['object', 'attributes' => ['identifier', 'memo', 'created_by' => ['id', 'username', 'email'], 'last_used_at', 'created_at', 'r_servers']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJsonPath('data.0.attributes.created_by.id', $this->getAdminUser()->id); + Assert::assertArraySubset(['object' => 'api_key', 'attributes' => ['identifier' => $keys[0]->identifier, 'memo' => $keys[0]->memo, 'created_by' => ['id' => $this->getAdminUser()->id, 'username' => $this->getAdminUser()->username, 'email' => $this->getAdminUser()->email], 'last_used_at' => null, 'created_at' => $keys[0]->created_at->toAtomString(), 'relationships' => [], 'r_servers' => 0, 'r_nodes' => 0, 'r_allocations' => 0, 'r_users' => 0, 'r_locations' => 0, 'r_eggs' => 0, 'r_database_hosts' => 0, 'r_server_databases' => 0]], collect($response->json('data'))->firstWhere('attributes.identifier', $keys[0]->identifier), true); + Assert::assertArraySubset(['object' => 'api_key', 'attributes' => ['identifier' => $keys[1]->identifier, 'memo' => $keys[1]->memo, 'created_by' => ['id' => $this->getAdminUser()->id, 'username' => $this->getAdminUser()->username, 'email' => $this->getAdminUser()->email], 'last_used_at' => null, 'created_at' => $keys[1]->created_at->toAtomString(), 'relationships' => [], 'r_servers' => 0, 'r_nodes' => 0, 'r_allocations' => 0, 'r_users' => 0, 'r_locations' => 0, 'r_eggs' => 0, 'r_database_hosts' => 0, 'r_server_databases' => 0]], collect($response->json('data'))->firstWhere('attributes.identifier', $keys[1]->identifier), true); +}); +test('get api keys accepts data table sorts', function (string $sort): void { + ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION, 'memo' => 'Data table sort A']); + ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION, 'memo' => 'Data table sort Z']); + $response = $this->getJson(route('api.admin.api-keys', ['filter' => ['memo' => 'Data table sort'], 'sort' => $sort, 'per_page' => 100])); + $response->assertOk(); + $response->assertJsonCount(2, 'data'); +})->with('apiKeyListSortsDataProvider'); +test('api key listing never exposes token', function (): void { + ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION]); + $response = $this->getJson(route('api.admin.api-keys')); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonMissingPath('data.0.attributes.token'); + $response->assertJsonMissingPath('data.0.attributes.secret_token'); +}); +test('create api key', function (): void { + $response = $this->postJson(route('api.admin.api-keys.store'), ['memo' => 'Test application key.', 'r_'.AdminAcl::RESOURCE_SERVERS => AdminAcl::READ, 'r_'.AdminAcl::RESOURCE_USERS => AdminAcl::READ | AdminAcl::WRITE]); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonStructure(['object', 'attributes' => ['identifier', 'memo', 'created_by' => ['id', 'username', 'email'], 'last_used_at', 'created_at', 'r_servers', 'r_users'], 'meta' => ['secret_token']]); + $response->assertJsonPath('attributes.created_by.id', $this->getAdminUser()->id); + $this->assertDatabaseHas('api_keys', ['memo' => 'Test application key.', 'key_type' => ApiKey::TYPE_APPLICATION, 'user_id' => $this->getAdminUser()->id, 'r_'.AdminAcl::RESOURCE_SERVERS => AdminAcl::READ, 'r_'.AdminAcl::RESOURCE_USERS => AdminAcl::READ | AdminAcl::WRITE]); + $key = ApiKey::query()->where('memo', 'Test application key.')->firstOrFail(); + // Secret is identifier + decrypted token, returned once on creation and never stored in plaintext. + $secret = $response->json('meta.secret_token'); + expect($secret)->toBe($key->identifier.decrypt($key->token)); + expect($secret)->toStartWith($key->identifier); + + $response->assertJsonMissingPath('attributes.token'); + $response->assertJson(['object' => 'api_key', 'attributes' => ['identifier' => $key->identifier, 'memo' => 'Test application key.', 'created_by' => ['id' => $this->getAdminUser()->id, 'username' => $this->getAdminUser()->username, 'email' => $this->getAdminUser()->email], 'last_used_at' => null, 'created_at' => $key->created_at->toAtomString(), 'relationships' => [], 'r_servers' => 1, 'r_nodes' => 0, 'r_allocations' => 0, 'r_users' => 3, 'r_locations' => 0, 'r_eggs' => 0, 'r_database_hosts' => 0, 'r_server_databases' => 0]]); +}); +test('view api key', function (): void { + $key = ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION]); + $response = $this->getJson(route('api.admin.api-keys.view', ['identifier' => $key->identifier])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonMissingPath('attributes.token'); + $response->assertJsonPath('attributes.created_by.id', $this->getAdminUser()->id); + $response->assertJson(['object' => 'api_key', 'attributes' => ['identifier' => $key->identifier, 'memo' => $key->memo, 'created_by' => ['id' => $this->getAdminUser()->id, 'username' => $this->getAdminUser()->username, 'email' => $this->getAdminUser()->email], 'last_used_at' => null, 'created_at' => $key->created_at->toAtomString(), 'relationships' => [], 'r_servers' => 0, 'r_nodes' => 0, 'r_allocations' => 0, 'r_users' => 0, 'r_locations' => 0, 'r_eggs' => 0, 'r_database_hosts' => 0, 'r_server_databases' => 0]]); +}); +test('view missing api key', function (): void { + $response = $this->getJson(route('api.admin.api-keys.view', ['identifier' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('update api key', function (): void { + $key = ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION, 'memo' => 'Original memo.', 'r_'.AdminAcl::RESOURCE_SERVERS => AdminAcl::READ]); + $identifier = $key->identifier; + $token = $key->token; + $response = $this->putJson(route('api.admin.api-keys.update', ['identifier' => $key->identifier]), ['memo' => 'Updated memo.', 'r_'.AdminAcl::RESOURCE_SERVERS => AdminAcl::READ | AdminAcl::WRITE, 'r_'.AdminAcl::RESOURCE_USERS => AdminAcl::READ]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('attributes.memo', 'Updated memo.'); + $response->assertJsonPath('attributes.created_by.id', $this->getAdminUser()->id); + $this->assertDatabaseHas('api_keys', ['id' => $key->id, 'identifier' => $key->identifier, 'memo' => 'Updated memo.', 'r_'.AdminAcl::RESOURCE_SERVERS => AdminAcl::READ | AdminAcl::WRITE, 'r_'.AdminAcl::RESOURCE_USERS => AdminAcl::READ]); + // The identifier and token are never regenerated by an update. + expect($key->refresh()->identifier)->toBe($identifier) + ->and($key->token)->toBe($token); +}); +test('delete api key', function (): void { + $key = ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION]); + $this->assertDatabaseHas('api_keys', ['id' => $key->id]); + $response = $this->delete(route('api.admin.api-keys.delete', ['identifier' => $key->identifier])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('api_keys', ['id' => $key->id]); +}); +test('delete missing api key', function (): void { + $response = $this->delete(route('api.admin.api-keys.delete', ['identifier' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $key = ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION]); + $response = $this->{$method}(route($routeName, ['identifier' => $key->identifier])); + $this->assertAccessDeniedJson($response); +})->with('apiKeyEndpointsDataProvider'); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.api-keys.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'memo'); + expect($error)->not->toBeNull('Expected a validation error for the [memo] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); diff --git a/tests/Integration/Api/Admin/DatabaseHosts/DatabaseHostControllerTest.php b/tests/Integration/Api/Admin/DatabaseHosts/DatabaseHostControllerTest.php new file mode 100644 index 000000000..01e77b46d --- /dev/null +++ b/tests/Integration/Api/Admin/DatabaseHosts/DatabaseHostControllerTest.php @@ -0,0 +1,169 @@ + [['getJson', 'api.admin.database-hosts'], ['getJson', 'api.admin.database-hosts.view'], ['getJson', 'api.admin.database-hosts.databases'], ['postJson', 'api.admin.database-hosts.store'], ['putJson', 'api.admin.database-hosts.update'], ['delete', 'api.admin.database-hosts.delete']]); +test('get database hosts', function (): void { + $hosts = DatabaseHost::factory()->times(2)->create(); + $response = $this->getJson(route('api.admin.database-hosts', ['per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'name', 'host', 'port', 'username', 'max_databases', 'node_id', 'created_at', 'updated_at']], ['object', 'attributes' => ['id', 'name', 'host', 'port', 'username', 'max_databases', 'node_id', 'created_at', 'updated_at']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[], []], 'meta' => ['pagination' => ['total' => 2, 'count' => 2, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]]); + Assert::assertArraySubset(['object' => 'database_host', 'attributes' => ['id' => $hosts[0]->id, 'name' => $hosts[0]->name, 'host' => $hosts[0]->host, 'port' => $hosts[0]->port, 'username' => $hosts[0]->username, 'max_databases' => $hosts[0]->max_databases, 'node_id' => $hosts[0]->node_id]], collect($response->json('data'))->firstWhere('attributes.id', $hosts[0]->id), true); + Assert::assertArraySubset(['object' => 'database_host', 'attributes' => ['id' => $hosts[1]->id, 'name' => $hosts[1]->name, 'host' => $hosts[1]->host, 'port' => $hosts[1]->port, 'username' => $hosts[1]->username, 'max_databases' => $hosts[1]->max_databases, 'node_id' => $hosts[1]->node_id]], collect($response->json('data'))->firstWhere('attributes.id', $hosts[1]->id), true); + $response->assertJsonMissing(['password' => $hosts[0]->password]); +}); +test('get database hosts filtered by name', function (): void { + $host = DatabaseHost::factory()->create(['name' => 'production-cluster']); + DatabaseHost::factory()->create(['name' => 'staging-cluster']); + $response = $this->getJson(route('api.admin.database-hosts', ['filter' => ['name' => 'production-cluster']])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + Assert::assertArraySubset(['object' => 'database_host', 'attributes' => ['id' => $host->id, 'name' => $host->name, 'host' => $host->host, 'port' => $host->port, 'username' => $host->username, 'max_databases' => $host->max_databases, 'node_id' => $host->node_id]], collect($response->json('data'))->firstWhere('attributes.id', $host->id), true); +}); +test('get database hosts sorted by name and creation date', function (): void { + $older = DatabaseHost::factory()->create(['name' => 'ZZ Sort Host Zebra', 'created_at' => now()->subMinute()]); + $newer = DatabaseHost::factory()->create(['name' => 'ZZ Sort Host Alpha', 'created_at' => now()]); + $byName = $this->getJson(route('api.admin.database-hosts', ['filter' => ['name' => 'ZZ Sort Host'], 'sort' => 'name'])); + $byName->assertOk()->assertJsonPath('data.0.attributes.id', $newer->id); + $byCreation = $this->getJson(route('api.admin.database-hosts', ['filter' => ['name' => 'ZZ Sort Host'], 'sort' => '-created_at'])); + $byCreation->assertOk()->assertJsonPath('data.0.attributes.id', $newer->id); + $this->assertNotSame($older->id, $newer->id); +}); +test('get single database host', function (): void { + $host = DatabaseHost::factory()->create(); + $server = $this->createServerModel(); + Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $response = $this->getJson(route('api.admin.database-hosts.view', ['databaseHost' => $host->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'name', 'host', 'port', 'username', 'max_databases', 'node_id', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'database_host', 'attributes' => ['id' => $host->id, 'name' => $host->name, 'host' => $host->host, 'port' => $host->port, 'username' => $host->username, 'max_databases' => $host->max_databases, 'node_id' => $host->node_id]]); + $response->assertJsonMissing(['password' => $host->password]); + $response->assertJsonMissing(['relationships' => ['databases']]); +}); +test('get database host databases', function (): void { + $host = DatabaseHost::factory()->create(); + $server = $this->createServerModel(); + Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $response = $this->getJson(route('api.admin.database-hosts.databases', ['databaseHost' => $host->id, 'per_page' => 1])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['server' => ['id', 'name'], 'name', 'username', 'connections_from', 'max_connections']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJsonPath('meta.pagination.total', 2); +}); +test('get missing database host', function (): void { + $response = $this->getJson(route('api.admin.database-hosts.view', ['databaseHost' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('create database host', function (): void { + mockDynamicConnection(); + $response = $this->postJson(route('api.admin.database-hosts.store'), ['name' => 'Test Host', 'host' => '127.0.0.1', 'port' => 3306, 'username' => 'someuser', 'password' => 'somepassword']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonCount(3); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'name', 'host', 'port', 'username', 'max_databases', 'node_id', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $this->assertDatabaseHas('database_hosts', ['name' => 'Test Host', 'host' => '127.0.0.1', 'username' => 'someuser']); + $host = DatabaseHost::query()->where('name', 'Test Host')->first(); + $response->assertJson(['object' => 'database_host', 'attributes' => ['id' => $host->id, 'name' => $host->name, 'host' => $host->host, 'port' => $host->port, 'username' => $host->username, 'max_databases' => $host->max_databases, 'node_id' => $host->node_id], 'meta' => ['resource' => route('api.admin.database-hosts.view', ['databaseHost' => $host->id])]], true); + // Plaintext password is never returned and is stored encrypted. + $response->assertJsonMissing(['password' => 'somepassword']); + + expect(Crypt::decrypt($host->password))->toBe('somepassword'); +}); +test('create database host connection failure', function (): void { + $fake = new FakeDynamicDatabaseConnection(); + $fake->throwOnSet = new PDOException('connection refused'); + + $this->app->instance(DynamicDatabaseConnection::class, $fake); + $response = $this->postJson(route('api.admin.database-hosts.store'), ['name' => 'Broken Host', 'host' => '127.0.0.1', 'port' => 3306, 'username' => 'someuser', 'password' => 'somepassword']); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'DisplayException'); + $response->assertJsonFragment(['detail' => 'There was an error while trying to connect to the host or while executing a query: "connection refused"']); +}); +test('create database host validation', function (): void { + $response = $this->postJson(route('api.admin.database-hosts.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + foreach (['name', 'host', 'port', 'username'] as $field) { + $error = $errors->firstWhere('meta.source_field', $field); + expect($error)->not->toBeNull("Expected a validation error for the [{$field}] field."); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); + } +}); +test('update database host', function (): void { + mockDynamicConnection(); + $host = DatabaseHost::factory()->create(); + $response = $this->putJson(route('api.admin.database-hosts.update', ['databaseHost' => $host->id]), ['name' => 'Updated Host', 'host' => '127.0.0.1', 'port' => 3306, 'username' => 'updateduser', 'password' => '']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'name', 'host', 'port', 'username', 'max_databases', 'node_id', 'created_at', 'updated_at']]); + $this->assertDatabaseHas('database_hosts', ['id' => $host->id, 'name' => 'Updated Host', 'username' => 'updateduser']); + $host = $host->fresh(); + $response->assertJson(['object' => 'database_host', 'attributes' => ['id' => $host->id, 'name' => $host->name, 'host' => $host->host, 'port' => $host->port, 'username' => $host->username, 'max_databases' => $host->max_databases, 'node_id' => $host->node_id]]); + $response->assertJsonMissing(['password' => $host->password]); +}); +test('update database host validation', function (): void { + $host = DatabaseHost::factory()->create(); + $response = $this->putJson(route('api.admin.database-hosts.update', ['databaseHost' => $host->id]), ['name' => '', 'host' => '127.0.0.1', 'port' => 'not-a-port', 'username' => 'updateduser']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $nameError = $errors->firstWhere('meta.source_field', 'name'); + expect($nameError)->not->toBeNull('Expected a validation error for the [name] field.'); + $portError = $errors->firstWhere('meta.source_field', 'port'); + expect($portError)->not->toBeNull('Expected a validation error for the [port] field.'); +}); +test('update database host encrypts password', function (): void { + mockDynamicConnection(); + $host = DatabaseHost::factory()->create(); + $response = $this->putJson(route('api.admin.database-hosts.update', ['databaseHost' => $host->id]), ['name' => $host->name, 'host' => '127.0.0.1', 'port' => 3306, 'username' => $host->username, 'password' => 'a-brand-new-password']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonMissing(['password' => 'a-brand-new-password']); + + expect(Crypt::decrypt($host->fresh()->password))->toBe('a-brand-new-password'); +}); +test('delete database host', function (): void { + $host = DatabaseHost::factory()->create(); + $this->assertDatabaseHas('database_hosts', ['id' => $host->id]); + $response = $this->delete(route('api.admin.database-hosts.delete', ['databaseHost' => $host->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('database_hosts', ['id' => $host->id]); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $host = DatabaseHost::factory()->create(); + $response = $this->{$method}(route($routeName, ['databaseHost' => $host->id])); + $this->assertAccessDeniedJson($response); +})->with('databaseHostEndpointsDataProvider'); +/** No-op DynamicDatabaseConnection and point "dynamic" at the test database so the live "SELECT 1" succeeds. */ +function mockDynamicConnection(): FakeDynamicDatabaseConnection +{ + return (function (): FakeDynamicDatabaseConnection { + config()->set('database.connections.dynamic', config('database.connections.mysql')); + $fake = new FakeDynamicDatabaseConnection(); + $this->app->instance(DynamicDatabaseConnection::class, $fake); + + return $fake; + })->call(pterodactylTestCase()); +} diff --git a/tests/Integration/Api/Admin/Eggs/EggCatalogControllerTest.php b/tests/Integration/Api/Admin/Eggs/EggCatalogControllerTest.php new file mode 100644 index 000000000..abef3bade --- /dev/null +++ b/tests/Integration/Api/Admin/Eggs/EggCatalogControllerTest.php @@ -0,0 +1,190 @@ + 'array']); + app(EggCatalogService::class)->refresh(); +}); + +/** @return array{id: string, name: string, description: string, category: string, downloadUrl: string} */ +function catalogEntry(string $url = 'https://raw.githubusercontent.com/pterodactyl/game-eggs/main/paper.json'): array +{ + return [ + 'id' => 'games-paper', + 'name' => 'Paper', + 'description' => 'A Minecraft server', + 'category' => 'games', + 'downloadUrl' => $url, + ]; +} + +test('lists the official catalog and caches it until refreshed', function (): void { + Http::fake([ + EggCatalogService::INDEX_URL => Http::sequence()->push([catalogEntry()])->push([]), + ]); + + $this->getJson(route('api.admin.eggs.catalog'))->assertOk()->assertExactJson([ + 'data' => [[ + 'id' => 'games-paper', + 'name' => 'Paper', + 'description' => 'A Minecraft server', + 'category' => 'games', + 'source_url' => 'https://eggs.pterodactyl.io/egg/games-paper', + ]], + ]); + $this->getJson(route('api.admin.eggs.catalog'))->assertOk()->assertJsonCount(1, 'data'); + $this->postJson(route('api.admin.eggs.catalog.refresh'))->assertNoContent(); + $this->getJson(route('api.admin.eggs.catalog'))->assertOk()->assertExactJson(['data' => []]); + + Http::assertSentCount(2); +}); + +test('imports a selected catalog egg with its variables and logs the import', function (): void { + $source = Egg::query()->where('name', 'Bungeecord')->firstOrFail(); + $payload = app(ExportsEggs::class)->export($source); + $before = Egg::query()->count(); + Http::fake([ + EggCatalogService::INDEX_URL => Http::response([catalogEntry()]), + catalogEntry()['downloadUrl'] => Http::response($payload), + ]); + + $response = $this->postJson(route('api.admin.eggs.catalog.import'), ['catalog_id' => 'games-paper']); + + $response->assertCreated()->assertJsonPath('attributes.name', $source->name); + $imported = Egg::query()->findOrFail($response->json('attributes.id')); + expect($imported->id)->not->toBe($source->id); + expect($imported->variables()->count())->toBe($source->variables()->count()); + expect($imported->startup)->toBe($source->startup); + expect(Egg::query()->count())->toBe($before + 1); + $this->assertDatabaseHas('activity_logs', ['event' => 'admin:egg.import']); + Http::assertSentCount(2); +}); + +test('rejects an unknown catalog id with 404 without fetching an arbitrary URL', function (): void { + $before = Egg::query()->count(); + Http::fake([EggCatalogService::INDEX_URL => Http::response([catalogEntry()])]); + + $this->postJson(route('api.admin.eggs.catalog.import'), [ + 'catalog_id' => 'https://example.com/egg.json', + 'url' => 'https://example.com/egg.json', + ])->assertNotFound(); + + expect(Egg::query()->count())->toBe($before); + Http::assertSentCount(1); +}); + +test('rejects non official catalog downloads with 502', function (string $url): void { + Http::fake([EggCatalogService::INDEX_URL => Http::response([catalogEntry($url)])]); + + $this->postJson(route('api.admin.eggs.catalog.import'), ['catalog_id' => 'games-paper']) + ->assertStatus(502) + ->assertJsonPath('errors.0.detail', 'The catalog egg does not have an official Pterodactyl download URL.'); + + Http::assertSentCount(1); +})->with([ + 'private host' => 'http://127.0.0.1/egg.json', + 'another catalog' => 'https://example.com/egg.json', + 'another GitHub owner' => 'https://raw.githubusercontent.com/other/eggs/main/egg.json', + 'credentials' => 'https://user:password@raw.githubusercontent.com/pterodactyl/game-eggs/main/egg.json', +]); + +test('encodes spaces in official download paths', function (): void { + $source = Egg::query()->where('name', 'Bungeecord')->firstOrFail(); + Http::fake([ + EggCatalogService::INDEX_URL => Http::response([catalogEntry('https://raw.githubusercontent.com/pterodactyl/game-eggs/main/My Game/egg.json')]), + 'https://raw.githubusercontent.com/pterodactyl/game-eggs/main/My%20Game/egg.json' => Http::response(app(ExportsEggs::class)->export($source)), + ]); + + $this->postJson(route('api.admin.eggs.catalog.import'), ['catalog_id' => 'games-paper'])->assertCreated(); + + Http::assertSentCount(2); +}); + +test('reports a catalog connection failure with 502 and permits retry', function (): void { + Http::fake([EggCatalogService::INDEX_URL => Http::sequence()->pushFailedConnection()->push([catalogEntry()])]); + + $this->getJson(route('api.admin.eggs.catalog'))->assertStatus(502) + ->assertJsonPath('errors.0.detail', 'Could not reach the Pterodactyl egg catalog. Please try again.'); + + $this->getJson(route('api.admin.eggs.catalog'))->assertOk()->assertJsonCount(1, 'data'); + Http::assertSentCount(2); +}); + +test('rejects malformed catalog responses with 502 without caching them', function (string $payload): void { + Http::fake([EggCatalogService::INDEX_URL => Http::sequence()->push($payload)->push([catalogEntry()])]); + + $this->getJson(route('api.admin.eggs.catalog'))->assertStatus(502); + $this->getJson(route('api.admin.eggs.catalog'))->assertOk()->assertJsonCount(1, 'data'); + + Http::assertSentCount(2); +})->with(['not JSON' => 'Error', 'scalar' => 'false', 'wrong shape' => '{"error":"oops"}', 'no valid entries' => '[{"invalid":true}]']); + +test('does not follow redirects from egg downloads', function (): void { + $before = Egg::query()->count(); + Http::fake([ + EggCatalogService::INDEX_URL => Http::response([catalogEntry()]), + catalogEntry()['downloadUrl'] => Http::response('', 302, ['Location' => 'http://127.0.0.1/egg.json']), + ]); + + $this->postJson(route('api.admin.eggs.catalog.import'), ['catalog_id' => 'games-paper'])->assertStatus(502); + + expect(Egg::query()->count())->toBe($before); + Http::assertSentCount(2); +}); + +test('does not create an egg from an invalid remote definition', function (): void { + $before = Egg::query()->count(); + Http::fake([ + EggCatalogService::INDEX_URL => Http::response([catalogEntry()]), + catalogEntry()['downloadUrl'] => Http::response(['meta' => ['version' => 'unsupported']]), + ]); + + $this->postJson(route('api.admin.eggs.catalog.import'), ['catalog_id' => 'games-paper'])->assertStatus(502) + ->assertJsonPath('errors.0.detail', 'The selected catalog egg contains an invalid definition.'); + + expect(Egg::query()->count())->toBe($before); + Http::assertSentCount(2); +}); + +test('validates catalog ids with 422 before contacting the catalog', function (mixed $id): void { + Http::fake([EggCatalogService::INDEX_URL => Http::response([])]); + + $this->postJson(route('api.admin.eggs.catalog.import'), ['catalog_id' => $id])->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'catalog_id'); + + Http::assertNothingSent(); +})->with(['missing' => null, 'array' => [['id']], 'too long' => str_repeat('x', 256)]); + +test('rejects non administrators with 403 before contacting the catalog', function (string $method, string $route): void { + $this->actingAsNonAdmin(); + Http::fake([EggCatalogService::INDEX_URL => Http::response([])]); + + $this->{$method}(route($route), ['catalog_id' => 'games-paper'])->assertForbidden(); + + Http::assertNothingSent(); +})->with([ + ['getJson', 'api.admin.eggs.catalog'], + ['postJson', 'api.admin.eggs.catalog.refresh'], + ['postJson', 'api.admin.eggs.catalog.import'], +]); + +test('requires authentication with 401', function (): void { + Auth::logout(); + Http::fake([EggCatalogService::INDEX_URL => Http::response([])]); + + $this->getJson(route('api.admin.eggs.catalog'))->assertUnauthorized(); + + Http::assertNothingSent(); +}); diff --git a/tests/Integration/Api/Admin/Eggs/EggControllerTest.php b/tests/Integration/Api/Admin/Eggs/EggControllerTest.php new file mode 100644 index 000000000..8fd536437 --- /dev/null +++ b/tests/Integration/Api/Admin/Eggs/EggControllerTest.php @@ -0,0 +1,40 @@ +getJson('/api/admin/nests')->assertNotFound(); + // The blade admin was removed entirely; stray /admin URLs now fall through to + // the React SPA shell, which handles them client side. + $this->get('/admin/nests')->assertOk()->assertViewIs('templates.base.core'); +}); +test('eggs can be filtered by name', function () { + /** @var Egg $egg */ + $egg = Egg::factory()->create(['name' => 'Filterable Egg']); + Egg::factory()->create(['name' => 'Other Egg']); + $this->getJson(route('api.admin.eggs', ['filter' => ['name' => 'Filterable Egg']]))->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.id', $egg->id); +}); +test('egg tags can be included', function () { + /** @var Egg $egg */ + $egg = Egg::factory()->create(); + /** @var Tag $tag */ + $tag = Tag::factory()->create(['name' => 'Minecraft', 'slug' => 'minecraft']); + $egg->tags()->attach($tag); + + $this->getJson(route('api.admin.eggs.view', ['egg' => $egg->id, 'include' => 'tags'])) + ->assertOk() + ->assertJsonPath('attributes.relationships.tags.data.0.attributes.id', $tag->id) + ->assertJsonPath('attributes.relationships.tags.data.0.attributes.slug', 'minecraft'); +}); +test('egg can be created', function () { + $response = $this->postJson(route('api.admin.eggs.store'), ['name' => 'Standalone Egg', 'description' => 'Grouped by tags.', 'docker_images' => 'Java 21|ghcr.io/pterodactyl/yolks:java_21', 'startup' => 'java -jar server.jar', 'config_stop' => 'stop', 'config_startup' => '{"done":["Done"]}', 'config_logs' => '{}', 'config_files' => '{}']); + $response->assertCreated()->assertJsonPath('attributes.name', 'Standalone Egg'); + $this->assertDatabaseHas('eggs', ['name' => 'Standalone Egg']); +}); diff --git a/tests/Integration/Api/Admin/Eggs/EggCrudControllerTest.php b/tests/Integration/Api/Admin/Eggs/EggCrudControllerTest.php new file mode 100644 index 000000000..ef47e57d0 --- /dev/null +++ b/tests/Integration/Api/Admin/Eggs/EggCrudControllerTest.php @@ -0,0 +1,125 @@ + [['getJson', 'api.admin.eggs'], ['getJson', 'api.admin.eggs.view'], ['postJson', 'api.admin.eggs.store'], ['putJson', 'api.admin.eggs.update'], ['delete', 'api.admin.eggs.delete']]); +test('get eggs', function (): void { + $eggs = Egg::factory()->times(2)->create(); + $eggs = $eggs->map(fn (Egg $egg) => $egg->refresh()); + + $response = $this->getJson(route('api.admin.eggs')); + $response->assertStatus(Response::HTTP_OK); + // Eggs are no longer scoped to a nest, so the listing covers the seeded eggs too. + $response->assertJsonCount(Egg::query()->count(), 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'uuid', 'name', 'docker_images', 'force_outgoing_ip', 'config', 'script', 'startup', 'created_at', 'updated_at']], ['object', 'attributes' => ['id', 'uuid', 'name', 'docker_images', 'force_outgoing_ip', 'config', 'script', 'startup', 'created_at', 'updated_at']]]]); + Assert::assertArraySubset(['object' => 'egg', 'attributes' => ['id' => $eggs[0]->id, 'uuid' => $eggs[0]->uuid, 'name' => $eggs[0]->name, 'author' => $eggs[0]->author, 'description' => $eggs[0]->description, 'docker_images' => $eggs[0]->docker_images, 'startup' => $eggs[0]->startup, 'force_outgoing_ip' => $eggs[0]->force_outgoing_ip]], collect($response->json('data'))->firstWhere('attributes.id', $eggs[0]->id), true); + Assert::assertArraySubset(['object' => 'egg', 'attributes' => ['id' => $eggs[1]->id, 'uuid' => $eggs[1]->uuid, 'name' => $eggs[1]->name, 'author' => $eggs[1]->author, 'description' => $eggs[1]->description, 'docker_images' => $eggs[1]->docker_images, 'startup' => $eggs[1]->startup, 'force_outgoing_ip' => $eggs[1]->force_outgoing_ip]], collect($response->json('data'))->firstWhere('attributes.id', $eggs[1]->id), true); +}); +test('get single egg', function (): void { + $egg = Egg::factory()->create(); + $response = $this->getJson(route('api.admin.eggs.view', ['egg' => $egg->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'docker_images', 'force_outgoing_ip', 'config', 'script', 'startup', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'egg', 'attributes' => ['id' => $egg->id, 'uuid' => $egg->uuid, 'name' => $egg->name, 'author' => $egg->author, 'description' => $egg->description, 'docker_images' => $egg->docker_images, 'startup' => $egg->startup, 'force_outgoing_ip' => $egg->force_outgoing_ip]]); +}); +test('get missing egg', function (): void { + $response = $this->getJson(route('api.admin.eggs.view', ['egg' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('create egg', function (): void { + $response = $this->postJson(route('api.admin.eggs.store'), validCreatePayload()); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'docker_images', 'force_outgoing_ip', 'config', 'script', 'startup', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $this->assertDatabaseHas('eggs', ['name' => 'Test Egg']); + $egg = Egg::query()->where('name', 'Test Egg')->firstOrFail(); + expect($egg->docker_images)->toBe(['Java 17' => 'ghcr.io/pterodactyl/yolks:java_17', 'Java 11' => 'ghcr.io/pterodactyl/yolks:java_11']); + $response->assertJson(['object' => 'egg', 'attributes' => ['id' => $egg->id, 'uuid' => $egg->uuid, 'name' => $egg->name, 'author' => $egg->author, 'description' => $egg->description, 'docker_images' => $egg->docker_images, 'startup' => $egg->startup, 'force_outgoing_ip' => $egg->force_outgoing_ip], 'meta' => ['resource' => route('api.admin.eggs.view', ['egg' => $egg->id])]]); +}); +test('update egg', function (): void { + $egg = Egg::factory()->create(); + $response = $this->putJson(route('api.admin.eggs.update', ['egg' => $egg->id]), array_merge(validCreatePayload(), ['name' => 'Updated Egg', 'startup' => 'java -jar updated.jar'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'egg'); + $response->assertJsonPath('attributes.name', 'Updated Egg'); + $response->assertJsonPath('attributes.startup', 'java -jar updated.jar'); + $this->assertDatabaseHas('eggs', ['id' => $egg->id, 'name' => 'Updated Egg']); +}); +test('delete egg', function (): void { + $egg = Egg::factory()->create(); + $this->assertDatabaseHas('eggs', ['id' => $egg->id]); + $response = $this->delete(route('api.admin.eggs.delete', ['egg' => $egg->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('eggs', ['id' => $egg->id]); +}); +test('delete egg with servers', function (): void { + $server = $this->createServerModel(); + $egg = Egg::query()->findOrFail($server->egg_id); + $response = $this->delete(route('api.admin.eggs.delete', ['egg' => $egg->id])); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + // Error handler rolls the transaction back on render, so only assert the rejected status. + $response->assertJsonPath('errors.0.code', 'HasActiveServersException'); +}); +test('delete egg with children', function (): void { + $parent = Egg::factory()->create(); + Egg::factory()->create(['config_from' => $parent->id]); + $response = $this->delete(route('api.admin.eggs.delete', ['egg' => $parent->id])); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + // Error handler rolls the transaction back on render, so only assert the rejected status. + $response->assertJsonPath('errors.0.code', 'HasChildrenException'); +}); +test('unknown include is ignored', function (): void { + $egg = Egg::factory()->create(); + $response = $this->getJson(route('api.admin.eggs.view', ['egg' => $egg->id, 'include' => 'variables,servers,nest'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'egg'); + $response->assertJsonPath('attributes.id', $egg->id); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $egg = Egg::factory()->create(); + $response = $this->{$method}(route($routeName, ['egg' => $egg->id])); + $this->assertAccessDeniedJson($response); +})->with('eggEndpointsDataProvider'); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.eggs.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'name'); + expect($error)->not->toBeNull('Expected a validation error for the [name] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); +/** Valid egg-creation payload; `docker_images` is a newline-delimited string the request normalizes into a `name => image` map. */ +function validCreatePayload(): array +{ + return ['name' => 'Test Egg', 'description' => 'A freshly created egg.', 'docker_images' => "Java 17|ghcr.io/pterodactyl/yolks:java_17\nJava 11|ghcr.io/pterodactyl/yolks:java_11", 'startup' => 'java -jar server.jar', 'config_stop' => 'stop', 'config_startup' => '{"done": ["Done"]}', 'config_logs' => '{}', 'config_files' => '{}', 'features' => ['eula', 'fastdl']]; +} + +test('config from must reference an existing egg', function (): void { + $response = $this->postJson(route('api.admin.eggs.store'), array_merge(validCreatePayload(), ['config_from' => 999999])); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'config_from'); + $response->assertJsonPath('errors.0.meta.rule', 'exists'); +}); +test('config from zero means no parent egg', function (): void { + $response = $this->postJson(route('api.admin.eggs.store'), array_merge(validCreatePayload(), ['config_from' => 0])); + $response->assertStatus(Response::HTTP_CREATED); + $this->assertDatabaseHas('eggs', ['name' => 'Test Egg', 'config_from' => null]); +}); +test('config from references the parent egg', function (): void { + $parent = Egg::factory()->create(); + $response = $this->postJson(route('api.admin.eggs.store'), array_merge(validCreatePayload(), ['config_from' => $parent->id])); + $response->assertStatus(Response::HTTP_CREATED); + $this->assertDatabaseHas('eggs', ['name' => 'Test Egg', 'config_from' => $parent->id]); +}); diff --git a/tests/Integration/Api/Admin/Eggs/EggScriptControllerTest.php b/tests/Integration/Api/Admin/Eggs/EggScriptControllerTest.php new file mode 100644 index 000000000..3f1d73c87 --- /dev/null +++ b/tests/Integration/Api/Admin/Eggs/EggScriptControllerTest.php @@ -0,0 +1,70 @@ +create(['script_install' => 'echo "original"', 'script_entry' => 'bash', 'script_container' => 'alpine:3.4', 'script_is_privileged' => true]); + $response = $this->getJson(route('api.admin.eggs.script', ['egg' => $egg->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'script' => ['privileged', 'install', 'entry', 'container', 'extends']]]); + $response->assertJsonPath('object', 'egg'); + $response->assertJsonPath('attributes.id', $egg->id); + $response->assertJsonPath('attributes.script.install', 'echo "original"'); + $response->assertJsonPath('attributes.script.entry', 'bash'); + $response->assertJsonPath('attributes.script.container', 'alpine:3.4'); + $response->assertJsonPath('attributes.script.privileged', true); +}); +test('update script', function () { + $egg = Egg::factory()->create(['script_install' => 'echo "original"', 'script_entry' => 'bash', 'script_container' => 'alpine:3.4']); + $response = $this->putJson(route('api.admin.eggs.script.update', ['egg' => $egg->id]), ['script_install' => 'echo "updated"', 'script_is_privileged' => true, 'script_entry' => 'ash', 'script_container' => 'alpine:3.20']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'egg'); + $response->assertJsonPath('attributes.id', $egg->id); + $response->assertJsonPath('attributes.script.install', 'echo "updated"'); + $response->assertJsonPath('attributes.script.entry', 'ash'); + $response->assertJsonPath('attributes.script.container', 'alpine:3.20'); + $this->assertDatabaseHas('eggs', ['id' => $egg->id, 'script_install' => 'echo "updated"', 'script_entry' => 'ash', 'script_container' => 'alpine:3.20']); + expect($egg->refresh()->script_install)->toBe('echo "updated"'); +}); +test('update script copies another egg script when the script is empty', function () { + $source = Egg::factory()->create(['script_install' => 'echo "source"']); + $egg = Egg::factory()->create(['script_install' => 'echo "original"']); + $response = $this->putJson(route('api.admin.eggs.script.update', ['egg' => $egg->id]), ['script_install' => '', 'script_is_privileged' => true, 'script_entry' => 'bash', 'script_container' => 'alpine:3.20', 'copy_script_from' => $source->id]); + $response->assertStatus(Response::HTTP_OK); + $egg->refresh(); + expect($egg->script_install)->toBeNull(); + expect($egg->copy_script_install)->toBe('echo "source"'); +}); +test('update script copy from must be numeric', function () { + $egg = Egg::factory()->create(); + $response = $this->putJson(route('api.admin.eggs.script.update', ['egg' => $egg->id]), ['copy_script_from' => 'not-a-number']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'copy_script_from'); + expect($error)->not->toBeNull('Expected a validation error for the [copy_script_from] field.'); + expect($error['meta']['rule'])->toBe('numeric'); +}); +test('update script copy from invalid', function () { + $egg = Egg::factory()->create(); + $response = $this->putJson(route('api.admin.eggs.script.update', ['egg' => $egg->id]), ['script_is_privileged' => true, 'script_entry' => 'bash', 'script_container' => 'alpine:3.4', 'copy_script_from' => 123456]); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'InvalidCopyFromException'); +}); +test('non admin forbidden', function (string $method, string $routeName) { + $this->actingAsNonAdmin(); + $egg = Egg::factory()->create(); + $response = $this->{$method}(route($routeName, ['egg' => $egg->id])); + $this->assertAccessDeniedJson($response); +})->with('scriptEndpointsDataProvider'); diff --git a/tests/Integration/Api/Admin/Eggs/EggShareControllerTest.php b/tests/Integration/Api/Admin/Eggs/EggShareControllerTest.php new file mode 100644 index 000000000..2ee657475 --- /dev/null +++ b/tests/Integration/Api/Admin/Eggs/EggShareControllerTest.php @@ -0,0 +1,85 @@ +get(route('api.admin.eggs.export', ['egg' => $egg->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertHeader('Content-Type', 'application/json'); + $decoded = json_decode($response->getContent(), true); + expect($decoded)->toBeArray(); + expect($decoded['meta']['version'] ?? null)->toBe(Egg::EXPORT_VERSION); + expect($decoded['name'] ?? null)->toBe($egg->name); +}); +test('import', function () { + $source = bungeecordEgg(); + $json = app(ExportsEggs::class)->export($source); + $before = Egg::query()->count(); + $response = $this->post(route('api.admin.eggs.import'), ['import_file' => uploadedJsonFile($json)]); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'docker_images', 'config', 'script', 'startup', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $response->assertJsonPath('object', 'egg'); + $response->assertJsonPath('attributes.name', $source->name); + expect(Egg::query()->count())->toBe($before + 1); + $this->assertDatabaseHas('eggs', ['name' => $source->name]); +}); +test('update import', function () { + $source = bungeecordEgg(); + $target = Egg::factory()->create(); + $json = app(ExportsEggs::class)->export($source); + $response = $this->post(route('api.admin.eggs.update-import', ['egg' => $target->id]), ['import_file' => uploadedJsonFile($json)]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'egg'); + $response->assertJsonPath('attributes.id', $target->id); + $response->assertJsonPath('attributes.name', $source->name); + $this->assertDatabaseHas('eggs', ['id' => $target->id, 'name' => $source->name]); +}); +test('import validation missing file', function () { + $response = $this->postJson(route('api.admin.eggs.import'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'import_file'); + $response->assertJsonPath('errors.0.meta.rule', 'required'); +}); +test('update import validation missing file', function () { + $egg = Egg::factory()->create(); + $response = $this->postJson(route('api.admin.eggs.update-import', ['egg' => $egg->id]), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'import_file'); + $response->assertJsonPath('errors.0.meta.rule', 'required'); +}); +test('non admin forbidden', function (string $method, string $routeName) { + $this->actingAsNonAdmin(); + $egg = Egg::factory()->create(); + $response = $this->{$method}(route($routeName, ['egg' => $egg->id])); + $this->assertAccessDeniedJson($response); +})->with('shareEndpointsDataProvider'); +/** Return the seeded Bungeecord egg, the canonical egg every other integration test relies upon. */ +function bungeecordEgg(): Egg +{ + /** @var Egg $egg */ + $egg = Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail(); + + return $egg; +} +/** Build an UploadedFile from a JSON string, flagged as a test upload so the parser's isFile()/getError() checks pass. */ +function uploadedJsonFile(string $json): UploadedFile +{ + $path = tempnam(sys_get_temp_dir(), 'egg').'.json'; + file_put_contents($path, $json); + + return new UploadedFile($path, 'egg.json', 'application/json', null, true); +} diff --git a/tests/Integration/Api/Admin/Eggs/EggVariableControllerTest.php b/tests/Integration/Api/Admin/Eggs/EggVariableControllerTest.php new file mode 100644 index 000000000..309d6fcae --- /dev/null +++ b/tests/Integration/Api/Admin/Eggs/EggVariableControllerTest.php @@ -0,0 +1,217 @@ + [['getJson', 'api.admin.eggs.variables'], ['postJson', 'api.admin.eggs.variables.store'], ['putJson', 'api.admin.eggs.variables.reorder'], ['putJson', 'api.admin.eggs.variables.update'], ['delete', 'api.admin.eggs.variables.delete']]); +/** @return iterable */ +dataset('invalidNormalizedValueProvider', function () { + yield 'non-string default value' => ['default_value', ['nested'], 'default_value']; + yield 'non-string option' => ['options', ['user_viewable', 42], 'options.1']; + yield 'non-list options' => ['options', ['viewable' => 'user_viewable'], 'options']; +}); +test('get variables', function (): void { + $egg = createEgg(); + $variables = EggVariable::factory()->times(2)->create(['egg_id' => $egg->id]); + $response = $this->getJson(url($egg)); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'egg_id', 'name', 'env_variable', 'default_value', 'user_viewable', 'user_editable', 'rules', 'created_at', 'updated_at']], ['object', 'attributes' => ['id', 'egg_id', 'name', 'env_variable', 'default_value', 'user_viewable', 'user_editable', 'rules', 'created_at', 'updated_at']]]]); + Assert::assertArraySubset(['object' => 'egg_variable', 'attributes' => ['id' => $variables[0]->id, 'egg_id' => $variables[0]->egg_id, 'name' => $variables[0]->name, 'description' => $variables[0]->description, 'env_variable' => $variables[0]->env_variable, 'default_value' => $variables[0]->default_value, 'user_viewable' => $variables[0]->user_viewable, 'user_editable' => $variables[0]->user_editable, 'rules' => $variables[0]->rules]], collect($response->json('data'))->firstWhere('attributes.id', $variables[0]->id), true); + Assert::assertArraySubset(['object' => 'egg_variable', 'attributes' => ['id' => $variables[1]->id, 'egg_id' => $variables[1]->egg_id, 'name' => $variables[1]->name, 'description' => $variables[1]->description, 'env_variable' => $variables[1]->env_variable, 'default_value' => $variables[1]->default_value, 'user_viewable' => $variables[1]->user_viewable, 'user_editable' => $variables[1]->user_editable, 'rules' => $variables[1]->rules]], collect($response->json('data'))->firstWhere('attributes.id', $variables[1]->id), true); +}); +test('unknown include is ignored', function (): void { + $egg = createEgg(); + EggVariable::factory()->create(['egg_id' => $egg->id]); + $response = $this->getJson(route('api.admin.eggs.variables', ['egg' => $egg->id, 'include' => 'egg,nonexistent'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); +}); +test('create variable', function (): void { + $egg = createEgg(); + $response = $this->postJson(url($egg), ['name' => 'Test Variable', 'description' => 'A brand new variable.', 'env_variable' => 'TEST_VARIABLE', 'options' => ['user_viewable', 'user_editable'], 'rules' => 'required|string', 'default_value' => 'default']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'egg_id', 'name', 'env_variable', 'default_value', 'user_viewable', 'user_editable', 'rules', 'created_at', 'updated_at']]); + $this->assertDatabaseHas('egg_variables', ['egg_id' => $egg->id, 'env_variable' => 'TEST_VARIABLE']); + $variable = EggVariable::query()->where('egg_id', $egg->id)->firstOrFail(); + expect($variable->user_viewable)->toBeTrue(); + expect($variable->user_editable)->toBeTrue(); + + $response->assertJson(['object' => 'egg_variable', 'attributes' => ['id' => $variable->id, 'egg_id' => $variable->egg_id, 'name' => $variable->name, 'description' => $variable->description, 'env_variable' => $variable->env_variable, 'default_value' => $variable->default_value, 'user_viewable' => $variable->user_viewable, 'user_editable' => $variable->user_editable, 'rules' => $variable->rules]]); +}); +test('update variable', function (): void { + $egg = createEgg(); + $variable = EggVariable::factory()->create(['egg_id' => $egg->id]); + $response = $this->putJson(url($egg, $variable), ['name' => 'Updated Variable', 'description' => 'An updated description.', 'env_variable' => 'UPDATED_VARIABLE', 'options' => ['user_viewable'], 'rules' => 'required|string', 'default_value' => 'updated']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'egg_variable'); + $response->assertJsonPath('attributes.name', 'Updated Variable'); + $response->assertJsonPath('attributes.env_variable', 'UPDATED_VARIABLE'); + $response->assertJsonPath('attributes.default_value', 'updated'); + $response->assertJsonPath('attributes.user_viewable', true); + $response->assertJsonPath('attributes.user_editable', false); + $this->assertDatabaseHas('egg_variables', ['id' => $variable->id, 'env_variable' => 'UPDATED_VARIABLE', 'name' => 'Updated Variable']); +}); +test('delete variable', function (): void { + $egg = createEgg(); + $variable = EggVariable::factory()->create(['egg_id' => $egg->id]); + $this->assertDatabaseHas('egg_variables', ['id' => $variable->id]); + $response = $this->delete(url($egg, $variable)); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('egg_variables', ['id' => $variable->id]); +}); +test('reorder variables', function (): void { + $egg = createEgg(); + $a = EggVariable::factory()->create(['egg_id' => $egg->id]); + $b = EggVariable::factory()->create(['egg_id' => $egg->id]); + $c = EggVariable::factory()->create(['egg_id' => $egg->id]); + $response = $this->putJson(route('api.admin.eggs.variables.reorder', ['egg' => $egg->id]), ['order' => [$c->id, $a->id, $b->id]]); + $response->assertStatus(Response::HTTP_OK); + $this->assertDatabaseHas('egg_variables', ['id' => $c->id, 'sort_order' => 0]); + $this->assertDatabaseHas('egg_variables', ['id' => $a->id, 'sort_order' => 1]); + $this->assertDatabaseHas('egg_variables', ['id' => $b->id, 'sort_order' => 2]); + $response->assertJsonPath('data.0.attributes.id', $c->id); + $response->assertJsonPath('data.1.attributes.id', $a->id); + $response->assertJsonPath('data.2.attributes.id', $b->id); +}); + +test('variable reordering accepts numeric string identifiers', function (): void { + $egg = createEgg(); + $first = EggVariable::factory()->for($egg)->create(); + $second = EggVariable::factory()->for($egg)->create(); + + $this->putJson(route('api.admin.eggs.variables.reorder', ['egg' => $egg->id]), ['order' => [(string) $second->id, (string) $first->id]]) + ->assertOk() + ->assertJsonPath('data.0.attributes.id', $second->id); + + $this->assertDatabaseHas('egg_variables', ['id' => $second->id, 'sort_order' => 0]); + $this->assertDatabaseHas('egg_variables', ['id' => $first->id, 'sort_order' => 1]); +}); + +test('variable reordering rejects non-list or duplicate identifiers with 422', function (bool $associative): void { + $egg = createEgg(); + $variable = EggVariable::factory()->for($egg)->create(['sort_order' => 5]); + $order = $associative ? ['first' => $variable->id] : [$variable->id, $variable->id]; + + $this->putJson(route('api.admin.eggs.variables.reorder', ['egg' => $egg->id]), ['order' => $order]) + ->assertUnprocessable(); + + $this->assertDatabaseHas('egg_variables', ['id' => $variable->id, 'sort_order' => 5]); +})->with(['associative' => true, 'duplicates' => false]); +test('variable reordering rejects malformed identifier values with 422', function (bool|float|string|null $value): void { + $egg = createEgg(); + $variable = EggVariable::factory()->for($egg)->create(['sort_order' => 5]); + + $this->putJson(route('api.admin.eggs.variables.reorder', ['egg' => $egg->id]), ['order' => [$value]], options: JSON_PRESERVE_ZERO_FRACTION) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'order.0'); + + $this->assertDatabaseHas('egg_variables', ['id' => $variable->id, 'sort_order' => 5]); +})->with(['boolean' => true, 'whole float' => 1.0, 'empty string' => '', 'null' => [null]]); +test('reserved name rejected', function (): void { + $egg = createEgg(); + $response = $this->postJson(url($egg), ['name' => 'Reserved', 'env_variable' => 'SERVER_PORT', 'rules' => 'required|string', 'default_value' => 'default']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'env_variable'); + $this->assertDatabaseMissing('egg_variables', ['env_variable' => 'SERVER_PORT']); +}); +test('update variable not on egg', function (): void { + $egg = createEgg(); + $other = createEgg(); + $variable = EggVariable::factory()->create(['egg_id' => $other->id]); + $response = $this->putJson(url($egg, $variable), ['name' => 'Updated Variable', 'env_variable' => 'UPDATED_VARIABLE', 'rules' => 'required|string', 'default_value' => 'updated']); + $this->assertNotFoundJson($response); +}); +test('delete variable not on egg', function (): void { + $egg = createEgg(); + $other = createEgg(); + $variable = EggVariable::factory()->create(['egg_id' => $other->id]); + $response = $this->delete(url($egg, $variable)); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $egg = createEgg(); + $variable = EggVariable::factory()->create(['egg_id' => $egg->id]); + $url = route($routeName, ['egg' => $egg->id, 'variable' => $variable->id]); + $response = $this->{$method}($url); + $this->assertAccessDeniedJson($response); +})->with('variableEndpointsDataProvider'); +test('invalid payloads return validation errors', function (): void { + $egg = createEgg(); + $response = $this->postJson(url($egg), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'name'); + expect($error)->not->toBeNull('Expected a validation error for the [name] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); +test('invalid normalized values are rejected', function (string $field, mixed $value, string $sourceField): void { + $egg = createEgg(); + $payload = ['name' => 'Test Variable', 'env_variable' => 'TEST_VARIABLE', 'options' => ['user_viewable'], 'rules' => 'required|string', 'default_value' => 'default']; + $payload[$field] = $value; + $response = $this->postJson(url($egg), $payload); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + + expect(collect($response->json('errors'))->firstWhere('meta.source_field', $sourceField))->not->toBeNull(sprintf('Expected a validation error for the [%s] field.', $sourceField)); +})->with('invalidNormalizedValueProvider'); +/** Create a standalone egg for the variables under test. */ +function createEgg(): Egg +{ + return Egg::factory()->create(); +} + +/** Build the variables route for a given egg, optionally targeting a single variable. */ +function url(Egg $egg, ?EggVariable $variable = null): string +{ + return $variable instanceof EggVariable ? route('api.admin.eggs.variables.update', ['egg' => $egg->id, 'variable' => $variable->id]) : route('api.admin.eggs.variables', ['egg' => $egg->id]); +} + +test('reserved name rejected regardless of case', function (): void { + $egg = createEgg(); + $response = $this->postJson(url($egg), ['name' => 'Reserved', 'env_variable' => 'server_port', 'rules' => 'required|string', 'default_value' => 'default']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'env_variable'); + $this->assertDatabaseMissing('egg_variables', ['env_variable' => 'server_port']); +}); +test('duplicate env variable on the same egg is rejected', function (): void { + $egg = createEgg(); + EggVariable::factory()->create(['egg_id' => $egg->id, 'env_variable' => 'TAKEN']); + $response = $this->postJson(url($egg), ['name' => 'Duplicate', 'env_variable' => 'TAKEN', 'rules' => 'required|string', 'default_value' => 'taken']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'env_variable'); + $response->assertJsonPath('errors.0.meta.rule', 'unique'); +}); +test('same env variable on another egg is allowed', function (): void { + $egg = createEgg(); + EggVariable::factory()->create(['egg_id' => createEgg()->id, 'env_variable' => 'SHARED']); + $response = $this->postJson(url($egg), ['name' => 'Shared', 'env_variable' => 'SHARED', 'rules' => 'required|string', 'default_value' => 'shared']); + $response->assertStatus(Response::HTTP_CREATED); + $this->assertDatabaseHas('egg_variables', ['egg_id' => $egg->id, 'env_variable' => 'SHARED']); +}); +test('update keeps its own env variable without a uniqueness clash', function (): void { + $egg = createEgg(); + $variable = EggVariable::factory()->create(['egg_id' => $egg->id, 'env_variable' => 'KEEP_ME']); + $response = $this->putJson(url($egg, $variable), ['name' => 'Renamed', 'env_variable' => 'KEEP_ME', 'rules' => 'required|string', 'default_value' => 'kept']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('attributes.name', 'Renamed'); +}); +test('unresolvable rule string is rejected', function (): void { + $egg = createEgg(); + $response = $this->postJson(url($egg), ['name' => 'Bad Rules', 'env_variable' => 'BAD_RULES', 'rules' => 'requird|string', 'default_value' => 'bad']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'rules'); + $response->assertJsonPath('errors.0.detail', 'The validation rule "requird" is not a valid rule for this application.'); +}); diff --git a/tests/Integration/Api/Admin/Extensions/ExtensionControllerTest.php b/tests/Integration/Api/Admin/Extensions/ExtensionControllerTest.php new file mode 100644 index 000000000..20f333efd --- /dev/null +++ b/tests/Integration/Api/Admin/Extensions/ExtensionControllerTest.php @@ -0,0 +1,322 @@ +baseDirectory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'ptero-admin-extensions-'.uniqid(); + $this->extensionsDirectory = $this->baseDirectory.DIRECTORY_SEPARATOR.'extensions'; + $this->assetsDirectory = $this->baseDirectory.DIRECTORY_SEPARATOR.'assets'; + File::ensureDirectoryExists($this->extensionsDirectory); + File::ensureDirectoryExists($this->assetsDirectory); + config(['extensions.enabled' => true, 'extensions.directory' => $this->extensionsDirectory, 'extensions.assets_directory' => $this->assetsDirectory]); + repository()->flushDiscovery(); +}); +afterEach(function (): void { + repository()->flushDiscovery(); + File::deleteDirectory($this->baseDirectory); +}); +dataset('extensionEndpointsDataProvider', fn (): array => [['getJson', 'api.admin.extensions'], ['postJson', 'api.admin.extensions.install'], ['getJson', 'api.admin.extensions.settings', ['extension' => 'admin-fixture']], ['patchJson', 'api.admin.extensions.settings.update', ['extension' => 'admin-fixture']], ['postJson', 'api.admin.extensions.settings.file', ['extension' => 'admin-fixture', 'input' => 'logo']], ['deleteJson', 'api.admin.extensions.settings.file.clear', ['extension' => 'admin-fixture', 'input' => 'logo']], ['postJson', 'api.admin.extensions.enable', ['extension' => 'admin-fixture']], ['postJson', 'api.admin.extensions.disable', ['extension' => 'admin-fixture']], ['delete', 'api.admin.extensions.delete', ['extension' => 'admin-fixture']]]); +test('list extensions returns discovered extensions and metadata', function (): void { + writeExtension('admin-fixture'); + Extension::query()->create(['identifier' => 'admin-fixture', 'version' => '1.0.0', 'enabled' => true]); + $response = $this->getJson(route('api.admin.extensions')); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('data.0.id', 'admin-fixture'); + $response->assertJsonPath('data.0.name', 'Admin Fixture'); + $response->assertJsonPath('data.0.enabled', true); + $response->assertJsonPath('data.0.state', 'enabled'); + $response->assertJsonPath('meta.enabled', true); + $response->assertJsonPath('meta.directory', $this->extensionsDirectory); +}); +test('enable disable and remove extension', function (): void { + writeExtension('admin-fixture'); + $enable = $this->postJson(route('api.admin.extensions.enable', ['extension' => 'admin-fixture'])); + $enable->assertStatus(Response::HTTP_OK); + $enable->assertJsonPath('data.id', 'admin-fixture'); + $enable->assertJsonPath('data.enabled', true); + $this->assertDatabaseHas('extensions', ['identifier' => 'admin-fixture', 'enabled' => true]); + $disable = $this->postJson(route('api.admin.extensions.disable', ['extension' => 'admin-fixture'])); + $disable->assertStatus(Response::HTTP_OK); + $disable->assertJsonPath('data.enabled', false); + $this->assertDatabaseHas('extensions', ['identifier' => 'admin-fixture', 'enabled' => false]); + $remove = $this->delete(route('api.admin.extensions.delete', ['extension' => 'admin-fixture'])); + $remove->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDirectoryDoesNotExist($this->extensionsDirectory.DIRECTORY_SEPARATOR.'admin-fixture'); + $this->assertDatabaseMissing('extensions', ['identifier' => 'admin-fixture']); +}); +test('settings for extension without a definition', function (): void { + writeExtension('admin-fixture'); + $response = $this->getJson(route('api.admin.extensions.settings', ['extension' => 'admin-fixture'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('data.registered', false); + $response->assertJsonPath('data.schema', []); + + $update = $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => ['anything' => 'value']]); + $update->assertStatus(Response::HTTP_NOT_FOUND); +}); +test('settings update keeps omitted required settings', function (): void { + $settings = registerSettings(); + $settings->update(['api_key' => 'stored-secret']); + + $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => ['limit' => 7]]) + ->assertOk() + ->assertJsonPath('data.registered', true); + + expect($settings->get('limit'))->toBe(7) + ->and($settings->get('api_key'))->toBe('stored-secret') + ->and($settings->get('public_note'))->toBe('note'); +}); +test('settings update still validates submitted required settings', function (): void { + $settings = registerSettings(); + + $response = $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => ['public_note' => '', 'limit' => 'many']]) + ->assertUnprocessable(); + + expect(collect($response->json('errors'))->pluck('meta.source_field')->sort()->values()->all())->toBe(['limit', 'public_note']) + ->and($settings->get('public_note'))->toBe('note') + ->and($settings->get('limit'))->toBe(10); +}); +test('settings update saves settings without validation rules', function (): void { + $settings = registerSettings(); + + $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => ['greeting' => 'changed greeting']]) + ->assertOk(); + + expect($settings->get('greeting'))->toBe('changed greeting'); +}); + +test('blank secret updates preserve credentials and save other settings', function (?string $value): void { + $settings = registerSettings(); + $settings->update(['api_key' => 'stored-secret']); + + $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => ['api_key' => $value, 'limit' => 7]]) + ->assertOk() + ->assertJsonPath('data.schema.2.value', '********'); + + expect($settings->get('api_key'))->toBe('stored-secret'); + expect($settings->get('limit'))->toBe(7); +})->with(['', null, ' ']); + +test('malformed settings return 422 with a field error', function (mixed $settings): void { + registerSettings(); + + $response = $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => $settings]) + ->assertUnprocessable(); + + expect($response->json('errors.0.meta.source_field'))->toBe('settings'); + $this->assertDatabaseMissing('extension_settings', ['extension' => 'admin-fixture']); +})->with(['scalar' => ['broken'], 'null' => [null], 'numeric keys' => [['value']], 'excessive depth' => [array_reduce(range(1, 11), fn (array $value): array => ['nested' => $value], ['value' => 'too deep'])]]); + +test('a settings update requires the settings envelope and accepts an empty partial update', function (): void { + $settings = registerSettings(); + $settings->update(['api_key' => 'stored-secret']); + + $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), []) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'settings'); + $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => []])->assertOk(); + + expect($settings->get('api_key'))->toBe('stored-secret'); +}); +test('settings for uninstalled extension returns not found', function (): void { + $response = $this->getJson(route('api.admin.extensions.settings', ['extension' => 'missing'])); + $response->assertStatus(Response::HTTP_NOT_FOUND); +}); +test('install requires extension package', function (): void { + $response = $this->postJson(route('api.admin.extensions.install'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $error = collect($response->json('errors'))->firstWhere('meta.source_field', 'package'); + expect($error)->not->toBeNull(); + expect($error['meta']['rule'])->toBe('required'); +}); +test('install rejects a package with an invalid manifest', function (): void { + $this->post(route('api.admin.extensions.install'), ['package' => extensionPackage(['id' => 'Bad_Probe', 'name' => 'Bad', 'version' => '1.0.0'])], ['Accept' => 'application/json']) + ->assertUnprocessable() + ->assertJsonPath('errors.0.code', 'InvalidExtensionException') + ->assertJsonPath('errors.0.detail', fn (string $detail): bool => str_contains($detail, 'Extension id "Bad_Probe" must match')); + + $this->assertDatabaseMissing('extensions', ['identifier' => 'Bad_Probe']); +}); +test('non admin forbidden', function (string $method, string $routeName, array $parameters = []): void { + writeExtension('admin-fixture'); + $this->actingAsNonAdmin(); + $response = $this->{$method}(route($routeName, $parameters)); + $this->assertAccessDeniedJson($response); +})->with('extensionEndpointsDataProvider'); +function repository(): ExtensionRepository +{ + return (fn () => $this->app->make(ExtensionRepository::class))->call(pterodactylTestCase()); +} + +function registerSettings(): ExtensionSettingsDefinition +{ + return (function (): ExtensionSettingsDefinition { + writeExtension('admin-fixture'); + $definition = new ExtensionSettingsDefinition(repository()->settings('admin-fixture'), [ + ExtensionSettingDefinition::make('limit', 'limit', 10, ['required', 'integer'])->field('number'), + ExtensionSettingDefinition::make('public_note', 'public_note', 'note', ['required', 'string']), + ExtensionSettingDefinition::make('api_key', 'api_key', '', ['required', 'string'])->secret(), + ExtensionSettingDefinition::make('greeting', 'greeting', 'default greeting'), + ExtensionSettingDefinition::make('accent', 'accent', '#3b82f6')->color(), + ExtensionSettingDefinition::make('links', 'links', [])->list(['max:20'], 2), + ExtensionSettingDefinition::make('tags', 'tags', [])->multiselect([['value' => 'survival', 'label' => 'Survival'], ['value' => 'creative', 'label' => 'Creative']]), + ExtensionSettingDefinition::make('logo', 'logo', null)->file(maxKilobytes: 8)->frontend()->public(), + ]); + $this->app->make(ExtensionSettingsRegistry::class)->register('admin-fixture', $definition); + + return $definition; + })->call(pterodactylTestCase()); +} + +/** + * @param array $manifest + */ +function extensionPackage(array $manifest): UploadedFile +{ + $path = tempnam(sys_get_temp_dir(), 'ptero-package-').'.zip'; + $zip = new ZipArchive; + $zip->open($path, ZipArchive::CREATE | ZipArchive::OVERWRITE); + $zip->addFromString('extension.json', json_encode($manifest, JSON_THROW_ON_ERROR)); + $zip->close(); + + return new UploadedFile($path, 'bad-probe.pteroext', 'application/zip', null, true); +} + +function writeExtension(string $identifier): void +{ + (function () use ($identifier): void { + $path = $this->extensionsDirectory.DIRECTORY_SEPARATOR.$identifier; + File::ensureDirectoryExists($path); + File::put($path.DIRECTORY_SEPARATOR.'extension.json', json_encode(['id' => $identifier, 'name' => 'Admin Fixture', 'version' => '1.0.0'], JSON_THROW_ON_ERROR)); + repository()->flushDiscovery(); + })->call(pterodactylTestCase()); +} + +test('secret settings are masked by the admin endpoint and encrypted on disk', function (): void { + $settings = registerSettings(); + $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => ['api_key' => 'private-token']]) + ->assertOk() + ->assertJsonPath('data.schema.2.value', '********'); + $this->getJson(route('api.admin.extensions.settings', ['extension' => 'admin-fixture'])) + ->assertOk() + ->assertJsonPath('data.schema.2.value', '********'); + expect($settings->get('api_key'))->toBe('private-token'); + expect(ExtensionSetting::query()->where('extension', 'admin-fixture')->where('key', 'api_key')->value('value'))->not->toContain('private-token'); +}); + +function settingFile(string $bytes, string $name = 'logo.png', string $mime = 'image/png'): UploadedFile +{ + $path = tempnam(sys_get_temp_dir(), 'ptero-setting-file-'); + file_put_contents($path, $bytes); + + return new UploadedFile($path, $name, $mime, null, true); +} + +function png(): string +{ + return (string) base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', true); +} + +test('typed settings are validated and normalized by the update endpoint', function (): void { + $settings = registerSettings(); + $route = route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']); + + $this->patchJson($route, ['settings' => ['accent' => 'red; background: url(//evil.example)']])->assertUnprocessable(); + $this->patchJson($route, ['settings' => ['links' => ['one', 'two', 'three']]])->assertUnprocessable(); + $this->patchJson($route, ['settings' => ['tags' => ['survival', 'hardcore']]])->assertUnprocessable(); + $this->patchJson($route, ['settings' => ['logo' => 'ffffffffffffffffffffffffffffffffffffffff.png']])->assertUnprocessable(); + + $this->patchJson($route, ['settings' => ['accent' => '#ABCDEF', 'links' => ['Docs | /docs'], 'tags' => ['creative', 'survival']]]) + ->assertOk() + ->assertJsonPath('data.schema.4.value', '#abcdef') + ->assertJsonPath('data.schema.5.value', ['Docs | /docs']) + ->assertJsonPath('data.schema.5.constraints.max_items', 2) + ->assertJsonPath('data.schema.6.value', ['survival', 'creative']) + ->assertJsonPath('data.schema.7.field', 'file') + ->assertJsonPath('data.schema.7.visibility', 'public') + ->assertJsonPath('data.schema.7.constraints.accept', ExtensionSettingFiles::IMAGES); + expect($settings->get('accent'))->toBe('#abcdef'); +}); +test('file settings are uploaded replaced served and cleared', function (): void { + Storage::fake('local'); + $settings = registerSettings(); + $route = route('api.admin.extensions.settings.file', ['extension' => 'admin-fixture', 'input' => 'logo']); + + $first = $this->post($route, ['file' => settingFile(png(), 'evil.php', 'application/x-php')], ['Accept' => 'application/json']) + ->assertOk() + ->json('data.schema.7.value'); + expect($first)->toStartWith('/extension-files/admin-fixture/')->toEndWith('.png'); + expect($settings->get('logo'))->toBe($first); + + // Served without a session: public, immutable, typed from the stored name and never sniffed. + $this->app['auth']->forgetGuards(); + $served = $this->get($first)->assertOk(); + expect($served->getContent())->toBe(png()); + expect($served->headers->get('Content-Type'))->toBe('image/png'); + expect($served->headers->get('X-Content-Type-Options'))->toBe('nosniff'); + expect($served->headers->get('Cache-Control'))->toContain('public')->toContain('immutable'); + expect($served->headers->get('Content-Security-Policy'))->toContain('sandbox'); + expect($served->headers->getCookies())->toBe([]); + $this->get('/extension-files/admin-fixture/'.str_repeat('0', 40).'.png')->assertNotFound(); + $this->get('/extension-files/other-extension/'.basename((string) $first))->assertNotFound(); + + $this->actingAs($this->getAdminUser()); + $second = $this->post($route, ['file' => settingFile(png())], ['Accept' => 'application/json'])->assertOk()->json('data.schema.7.value'); + expect($second)->not->toBe($first); + Storage::disk('local')->assertMissing(mb_ltrim((string) $first, '/')); + Storage::disk('local')->assertExists(mb_ltrim((string) $second, '/')); + + $this->deleteJson(route('api.admin.extensions.settings.file.clear', ['extension' => 'admin-fixture', 'input' => 'logo'])) + ->assertOk() + ->assertJsonPath('data.schema.7.value', null); + expect(Storage::disk('local')->allFiles())->toBe([]); + $this->assertDatabaseMissing('extension_settings', ['extension' => 'admin-fixture', 'key' => 'logo']); +}); +test('file uploads are rejected by content size and target', function (): void { + Storage::fake('local'); + registerSettings(); + $route = route('api.admin.extensions.settings.file', ['extension' => 'admin-fixture', 'input' => 'logo']); + $headers = ['Accept' => 'application/json']; + + $this->post($route, ['file' => settingFile('assertUnprocessable(); + $this->post($route, ['file' => settingFile('', 'logo.svg', 'image/svg+xml')], $headers)->assertUnprocessable(); + $this->post($route, ['file' => settingFile(png().str_repeat("\0", 9 * 1024))], $headers)->assertUnprocessable(); + $this->post($route, [], $headers)->assertUnprocessable(); + $this->post(route('api.admin.extensions.settings.file', ['extension' => 'admin-fixture', 'input' => 'greeting']), ['file' => settingFile(png())], $headers)->assertNotFound(); + $this->post(route('api.admin.extensions.settings.file', ['extension' => 'missing', 'input' => 'logo']), ['file' => settingFile(png())], $headers)->assertNotFound(); + expect(Storage::disk('local')->allFiles())->toBe([]); +}); +test('removing an extension deletes its uploaded files and their references', function (): void { + Storage::fake('local'); + registerSettings(); + Extension::query()->create(['identifier' => 'admin-fixture', 'version' => '1.0.0', 'enabled' => false]); + $this->post(route('api.admin.extensions.settings.file', ['extension' => 'admin-fixture', 'input' => 'logo']), ['file' => settingFile(png())], ['Accept' => 'application/json'])->assertOk(); + $this->patchJson(route('api.admin.extensions.settings.update', ['extension' => 'admin-fixture']), ['settings' => ['greeting' => 'kept']])->assertOk(); + expect(Storage::disk('local')->allFiles())->toHaveCount(1); + + $this->delete(route('api.admin.extensions.delete', ['extension' => 'admin-fixture']))->assertStatus(Response::HTTP_NO_CONTENT); + expect(Storage::disk('local')->allFiles())->toBe([]); + $this->assertDatabaseMissing('extension_settings', ['extension' => 'admin-fixture', 'key' => 'logo']); + $this->assertDatabaseHas('extension_settings', ['extension' => 'admin-fixture', 'key' => 'greeting']); +}); diff --git a/tests/Integration/Api/Admin/IncludesTest.php b/tests/Integration/Api/Admin/IncludesTest.php new file mode 100644 index 000000000..69e1dcd0f --- /dev/null +++ b/tests/Integration/Api/Admin/IncludesTest.php @@ -0,0 +1,147 @@ +getJson(route('api.admin.servers.view', ['server' => $server->id, 'include' => $includes])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['attributes' => ['relationships' => ['allocation' => ['object', 'attributes'], 'user' => ['object', 'attributes'], 'egg' => ['object', 'attributes'], 'location' => ['object', 'attributes'], 'node' => ['object', 'attributes'], 'allocations' => ['object', 'data'], 'subusers' => ['object', 'data'], 'variables' => ['object', 'data'], 'databases' => ['object', 'data']]]]); + $response->assertJsonPath('attributes.relationships.allocation.attributes.id', $server->allocation_id); + $response->assertJsonPath('attributes.relationships.user.attributes.id', $server->owner_id); + $response->assertJsonPath('attributes.relationships.node.attributes.id', $server->node_id); + $response->assertJsonPath('attributes.relationships.egg.attributes.id', $server->egg_id); + $response->assertJsonPath('attributes.relationships.subusers.object', 'list'); + $response->assertJsonPath('attributes.relationships.databases.object', 'list'); + expect(count($response->json('attributes.relationships.subusers.data')))->toBeGreaterThanOrEqual(1); + expect(count($response->json('attributes.relationships.databases.data')))->toBeGreaterThanOrEqual(1); + // The BungeeCord egg ships variables, so the server variables relation is non-empty. + expect(count($response->json('attributes.relationships.variables.data')))->toBeGreaterThanOrEqual(1); + $ignored = $this->getJson(route('api.admin.servers.view', ['server' => $server->id, 'include' => 'does-not-exist'])); + $ignored->assertStatus(Response::HTTP_OK); +}); +test('user includes', function () { + $server = $this->createServerModel(); + $response = $this->getJson(route('api.admin.users.view', ['user' => $server->owner_id, 'include' => 'servers'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['attributes' => ['relationships' => ['servers' => ['object', 'data']]]]); + $response->assertJsonPath('attributes.relationships.servers.object', 'list'); + expect(count($response->json('attributes.relationships.servers.data')))->toBeGreaterThanOrEqual(1); + $response->assertJsonPath('attributes.relationships.servers.data.0.attributes.id', $server->id); + $ignored = $this->getJson(route('api.admin.users.view', ['user' => $server->owner_id, 'include' => 'does-not-exist'])); + $ignored->assertStatus(Response::HTTP_OK); +}); +test('node includes', function () { + $server = $this->createServerModel(); + $response = $this->getJson(route('api.admin.nodes.view', ['node' => $server->node_id, 'include' => 'allocations,location,servers'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['attributes' => ['relationships' => ['allocations' => ['object', 'data'], 'location' => ['object', 'attributes'], 'servers' => ['object', 'data']]]]); + $response->assertJsonPath('attributes.relationships.location.attributes.id', $server->location->id); + expect(count($response->json('attributes.relationships.servers.data')))->toBeGreaterThanOrEqual(1); + $ignored = $this->getJson(route('api.admin.nodes.view', ['node' => $server->node_id, 'include' => 'does-not-exist'])); + $ignored->assertStatus(Response::HTTP_OK); +}); +test('egg includes', function () { + $server = $this->createServerModel(); + $url = route('api.admin.eggs.view', ['egg' => $server->egg_id, 'include' => 'variables,servers']); + $response = $this->getJson($url); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['attributes' => ['relationships' => ['variables' => ['object', 'data'], 'servers' => ['object', 'data']]]]); + expect(count($response->json('attributes.relationships.variables.data')))->toBeGreaterThanOrEqual(1); + expect(count($response->json('attributes.relationships.servers.data')))->toBeGreaterThanOrEqual(1); + $ignored = $this->getJson(route('api.admin.eggs.view', ['egg' => $server->egg_id, 'include' => 'does-not-exist'])); + $ignored->assertStatus(Response::HTTP_OK); +}); +test('location includes', function () { + $server = $this->createServerModel(); + $location = $server->location; + $response = $this->getJson(route('api.admin.locations.view', ['location' => $location->id, 'include' => 'nodes,servers'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['attributes' => ['relationships' => ['nodes' => ['object', 'data'], 'servers' => ['object', 'data']]]]); + expect(count($response->json('attributes.relationships.nodes.data')))->toBeGreaterThanOrEqual(1); + expect(count($response->json('attributes.relationships.servers.data')))->toBeGreaterThanOrEqual(1); + $ignored = $this->getJson(route('api.admin.locations.view', ['location' => $location->id, 'include' => 'does-not-exist'])); + $ignored->assertStatus(Response::HTTP_OK); +}); +test('allocation includes', function () { + $server = $this->createServerModel(); + $response = $this->getJson(route('api.admin.nodes.allocations', ['node' => $server->node_id, 'include' => 'node,server', 'per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['data' => [['attributes' => ['relationships' => ['node' => ['object', 'attributes'], 'server' => ['object']]]]]]); + $assigned = collect($response->json('data'))->firstWhere('attributes.assigned', true); + expect($assigned)->not->toBeNull('Expected the assigned allocation to be present in the collection.'); + expect($assigned['attributes']['relationships']['node']['attributes']['id'])->toBe($server->node_id); + expect($assigned['attributes']['relationships']['server']['attributes']['id'])->toBe($server->id); + $ignored = $this->getJson(route('api.admin.nodes.allocations', ['node' => $server->node_id, 'include' => 'does-not-exist'])); + $ignored->assertStatus(Response::HTTP_OK); +}); +/** Build a server with a subuser and database so collection includes resolve to non-empty data. */ +function createServerWithRelations(): Server +{ + return (function () { + $server = $this->createServerModel(); + Subuser::query()->create(['user_id' => User::factory()->create()->id, 'server_id' => $server->id, 'permissions' => ['control.console']]); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + + return $server->refresh(); + })->call(pterodactylTestCase()); +} + +function measuredReads(Closure $request): int +{ + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $request()->assertOk(); + + return count(array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select'))); + } finally { + DB::disableQueryLog(); + } +} + +test('admin collections batch nested relationships and aggregates', function (string $resource, string $includes) { + for ($i = 0; $i < 10; $i++) { + $server = $this->createServerModel(['name' => 'nplusone-'.$i, 'egg_id' => \Pterodactyl\Models\Egg::factory()->create(['name' => 'nplusone-'.$i])->id]); + $server->user->update(['username' => 'nplusone-'.$i]); + $server->node->update(['name' => 'nplusone-'.$i]); + $server->location->update(['short' => 'nplusone-'.$i]); + \Pterodactyl\Models\EggVariable::factory()->create(['egg_id' => $server->egg_id]); + Subuser::factory()->create(['server_id' => $server->id]); + Database::factory()->create(['server_id' => $server->id, 'database_host_id' => DatabaseHost::factory()->create(['node_id' => $server->node_id, 'name' => 'nplusone-'.$i])->id]); + } + $filter = match ($resource) { + 'users' => 'username', + 'locations' => 'short', + default => 'name', + }; + $request = fn (int $limit) => $this->getJson('/api/admin/'.$resource.'?filter['.$filter.']=nplusone-&per_page='.$limit.($includes === '' ? '' : '&include='.$includes)); + $request(1)->assertOk(); + $one = measuredReads(fn () => $request(1)); + expect(measuredReads(fn () => $request(10)))->toBe($one, $resource); + $request(10)->assertOk()->assertJsonCount(10, 'data'); +})->with([ + ['servers', ''], + ['servers', 'user,node,allocations,variables,databases,subusers'], + ['nodes', 'servers.user,location'], + ['users', 'servers.node'], + ['locations', 'nodes,servers'], + ['eggs', 'variables,tags,servers'], + ['database-hosts', 'databases'], +]); diff --git a/tests/Integration/Api/Admin/Locations/LocationControllerTest.php b/tests/Integration/Api/Admin/Locations/LocationControllerTest.php new file mode 100644 index 000000000..eb94e601a --- /dev/null +++ b/tests/Integration/Api/Admin/Locations/LocationControllerTest.php @@ -0,0 +1,120 @@ + [['getJson', 'api.admin.locations'], ['getJson', 'api.admin.locations.view'], ['getJson', 'api.admin.locations.eligible-nodes'], ['postJson', 'api.admin.locations.store'], ['putJson', 'api.admin.locations.update'], ['delete', 'api.admin.locations.delete']]); +dataset('locationListSortsDataProvider', fn (): array => [['short'], ['-short'], ['created_at'], ['-created_at']]); +test('get locations', function (): void { + $locations = Location::factory()->times(2)->create(); + $response = $this->getJson(route('api.admin.locations', ['per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']], ['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[], []], 'meta' => ['pagination' => ['total' => 2, 'count' => 2, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]]); + Assert::assertArraySubset(['object' => 'location', 'attributes' => ['id' => $locations[0]->id, 'short' => $locations[0]->short, 'long' => $locations[0]->long]], collect($response->json('data'))->firstWhere('attributes.id', $locations[0]->id), true); + Assert::assertArraySubset(['object' => 'location', 'attributes' => ['id' => $locations[1]->id, 'short' => $locations[1]->short, 'long' => $locations[1]->long]], collect($response->json('data'))->firstWhere('attributes.id', $locations[1]->id), true); +}); +test('get locations accepts data table sorts', function (string $sort): void { + Location::factory()->create(['short' => 'datatable-a', 'long' => 'Data table sort location']); + Location::factory()->create(['short' => 'datatable-z', 'long' => 'Data table sort location']); + $response = $this->getJson(route('api.admin.locations', ['filter' => ['long' => 'Data table sort location'], 'sort' => $sort, 'per_page' => 100])); + $response->assertOk(); + $response->assertJsonCount(2, 'data'); +})->with('locationListSortsDataProvider'); +test('get single location', function (): void { + $location = Location::factory()->create(); + $response = $this->getJson(route('api.admin.locations.view', ['location' => $location->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'location', 'attributes' => ['id' => $location->id, 'short' => $location->short, 'long' => $location->long]]); +}); +test('get missing location', function (): void { + $response = $this->getJson(route('api.admin.locations.view', ['location' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('create location', function (): void { + $response = $this->postJson(route('api.admin.locations.store'), ['short' => 'inerror', 'long' => 'This is a test long description.']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonCount(3); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $this->assertDatabaseHas('locations', ['short' => 'inerror', 'long' => 'This is a test long description.']); + $location = Location::query()->where('short', 'inerror')->first(); + $response->assertJson(['object' => 'location', 'attributes' => ['id' => $location->id, 'short' => $location->short, 'long' => $location->long], 'meta' => ['resource' => route('api.admin.locations.view', ['location' => $location->id])]], true); +}); +test('update location', function (): void { + $location = Location::factory()->create(); + $response = $this->putJson(route('api.admin.locations.update', ['location' => $location->id]), ['short' => 'newshort', 'long' => 'This is an updated description.']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']]); + $this->assertDatabaseHas('locations', ['short' => 'newshort', 'long' => 'This is an updated description.']); + $location = $location->fresh(); + $response->assertJson(['object' => 'location', 'attributes' => ['id' => $location->id, 'short' => $location->short, 'long' => $location->long]]); +}); +test('delete location', function (): void { + $location = Location::factory()->create(); + $this->assertDatabaseHas('locations', ['id' => $location->id]); + $response = $this->delete(route('api.admin.locations.delete', ['location' => $location->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('locations', ['id' => $location->id]); +}); +test('eligible nodes', function (): void { + $location = Location::factory()->create(); + $nodes = Node::factory()->times(2)->create(['location_id' => $location->id]); + // A node in a different location must not leak into the response. + Node::factory()->create(['location_id' => Location::factory()->create()->id]); + $response = $this->getJson(route('api.admin.locations.eligible-nodes', ['location' => $location->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonFragment(['id' => $nodes[0]->id]); + $response->assertJsonFragment(['id' => $nodes[1]->id]); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $location = Location::factory()->create(); + $response = $this->{$method}(route($routeName, ['location' => $location->id])); + $this->assertAccessDeniedJson($response); +})->with('locationEndpointsDataProvider'); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.locations.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'short'); + expect($error)->not->toBeNull('Expected a validation error for the [short] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); +test('duplicate short code is rejected', function (): void { + Location::factory()->create(['short' => 'taken']); + $response = $this->postJson(route('api.admin.locations.store'), ['short' => 'taken', 'long' => 'Duplicate short code.']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'short'); + $response->assertJsonPath('errors.0.meta.rule', 'unique'); +}); +test('update keeps its own short code without a uniqueness clash', function (): void { + $location = Location::factory()->create(['short' => 'keep-me']); + $response = $this->putJson(route('api.admin.locations.update', ['location' => $location->id]), ['short' => 'keep-me', 'long' => 'Renamed description.']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('attributes.long', 'Renamed description.'); +}); +test('delete location with nodes', function (): void { + $location = Location::factory()->create(); + Node::factory()->create(['location_id' => $location->id]); + $response = $this->delete(route('api.admin.locations.delete', ['location' => $location->id])); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'HasActiveNodesException'); + $this->assertDatabaseHas('locations', ['id' => $location->id]); +}); diff --git a/tests/Integration/Api/Admin/Mounts/MountAttachmentTest.php b/tests/Integration/Api/Admin/Mounts/MountAttachmentTest.php new file mode 100644 index 000000000..db7bc14e2 --- /dev/null +++ b/tests/Integration/Api/Admin/Mounts/MountAttachmentTest.php @@ -0,0 +1,208 @@ + [['postJson', 'api.admin.mounts.eggs'], ['deleteJson', 'api.admin.mounts.eggs.delete'], ['postJson', 'api.admin.mounts.nodes'], ['deleteJson', 'api.admin.mounts.nodes.delete']]); +test('eggs can be attached and detached', function (): void { + $mount = Mount::factory()->create(); + $egg = createEgg(); + $response = $this->postJson(route('api.admin.mounts.eggs', ['mount' => $mount->id]), ['eggs' => [$egg->id]]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJson(['object' => 'mount', 'attributes' => ['id' => $mount->id]]); + $this->assertDatabaseHas('egg_mount', ['mount_id' => $mount->id, 'egg_id' => $egg->id]); + // Attaching the same egg again must remain idempotent (no duplicate pivot rows). + $repeat = $this->postJson(route('api.admin.mounts.eggs', ['mount' => $mount->id]), ['eggs' => [$egg->id]]); + $repeat->assertStatus(Response::HTTP_OK); + $this->assertDatabaseCount('egg_mount', 1); + $detach = $this->delete(route('api.admin.mounts.eggs.delete', ['mount' => $mount->id, 'egg' => $egg->id])); + $detach->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('egg_mount', ['mount_id' => $mount->id, 'egg_id' => $egg->id]); +}); +test('nodes can be attached and detached', function (): void { + $mount = Mount::factory()->create(); + $node = createNode(); + $response = $this->postJson(route('api.admin.mounts.nodes', ['mount' => $mount->id]), ['nodes' => [$node->id]]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJson(['object' => 'mount', 'attributes' => ['id' => $mount->id]]); + $this->assertDatabaseHas('mount_node', ['mount_id' => $mount->id, 'node_id' => $node->id]); + // Attaching the same node again must remain idempotent (no duplicate pivot rows). + $repeat = $this->postJson(route('api.admin.mounts.nodes', ['mount' => $mount->id]), ['nodes' => [$node->id]]); + $repeat->assertStatus(Response::HTTP_OK); + $this->assertDatabaseCount('mount_node', 1); + $detach = $this->delete(route('api.admin.mounts.nodes.delete', ['mount' => $mount->id, 'node' => $node->id])); + $detach->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('mount_node', ['mount_id' => $mount->id, 'node_id' => $node->id]); +}); +test('includes can be loaded', function (): void { + $mount = Mount::factory()->create(); + $egg = createEgg(); + $node = createNode(); + $mount->eggs()->attach($egg->id); + $mount->nodes()->attach($node->id); + $response = $this->getJson(route('api.admin.mounts.view', ['mount' => $mount->id, 'include' => 'eggs,nodes,servers'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['relationships' => ['eggs' => ['object', 'data'], 'nodes' => ['object', 'data'], 'servers' => ['object', 'data']]]]); + $response->assertJsonPath('attributes.relationships.eggs.data.0.attributes.id', $egg->id); + $response->assertJsonPath('attributes.relationships.nodes.data.0.attributes.id', $node->id); + // The index endpoint must also accept the includes without raising a 500. + $index = $this->getJson(route('api.admin.mounts', ['include' => 'eggs,nodes,servers'])); + $index->assertStatus(Response::HTTP_OK); + $index->assertJsonStructure(['data' => [['attributes' => ['relationships' => ['eggs' => ['object', 'data'], 'nodes' => ['object', 'data'], 'servers' => ['object', 'data']]]]]]); +}); +test('attaching missing egg returns validation error', function (): void { + $mount = Mount::factory()->create(); + $response = $this->postJson(route('api.admin.mounts.eggs', ['mount' => $mount->id]), ['eggs' => [9999]]); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.code', 'ValidationException'); + $response->assertJsonPath('errors.0.meta.source_field', 'eggs.0'); + $response->assertJsonPath('errors.0.meta.rule', 'exists'); +}); +test('attaching missing node returns validation error', function (): void { + $mount = Mount::factory()->create(); + $response = $this->postJson(route('api.admin.mounts.nodes', ['mount' => $mount->id]), ['nodes' => [9999]]); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.code', 'ValidationException'); + $response->assertJsonPath('errors.0.meta.source_field', 'nodes.0'); + $response->assertJsonPath('errors.0.meta.rule', 'exists'); +}); +test('detaching missing egg returns not found', function (): void { + $mount = Mount::factory()->create(); + $response = $this->delete(route('api.admin.mounts.eggs.delete', ['mount' => $mount->id, 'egg' => 9999])); + $this->assertNotFoundJson($response); +}); +test('detaching missing node returns not found', function (): void { + $mount = Mount::factory()->create(); + $response = $this->delete(route('api.admin.mounts.nodes.delete', ['mount' => $mount->id, 'node' => 9999])); + $this->assertNotFoundJson($response); +}); +test('detaching unattached egg returns not found', function (): void { + $mount = Mount::factory()->create(); + $attached = createEgg(); + $unattached = createEgg(); + $mount->eggs()->attach($attached->id); + $response = $this->delete(route('api.admin.mounts.eggs.delete', ['mount' => $mount->id, 'egg' => $unattached->id])); + $this->assertNotFoundJson($response); + // Error handler rolls the transaction back on render, so only assert the rejected status. +}); +test('detaching unattached node returns not found', function (): void { + $mount = Mount::factory()->create(); + $attached = createNode(); + $unattached = createNode(); + $mount->nodes()->attach($attached->id); + $response = $this->delete(route('api.admin.mounts.nodes.delete', ['mount' => $mount->id, 'node' => $unattached->id])); + $this->assertNotFoundJson($response); + // Error handler rolls the transaction back on render, so only assert the rejected status. +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $mount = Mount::factory()->create(); + $egg = createEgg(); + $node = createNode(); + $mount->eggs()->attach($egg->id); + $mount->nodes()->attach($node->id); + $url = route($routeName, ['mount' => $mount->id, 'egg' => $egg->id, 'node' => $node->id]); + $response = $this->{$method}($url); + $this->assertAccessDeniedJson($response); +})->with('attachmentEndpointsDataProvider'); +/** Create a standalone egg so tests don't depend on seeded egg state. */ +function createEgg(): Egg +{ + return Egg::factory()->create(); +} + +/** Create a node backed by a freshly created location. */ +function createNode(): Node +{ + $location = Location::factory()->create(); + + return Node::factory()->create(['location_id' => $location->id]); +} + +test('mount attachment validates all ids with one lookup', function (string $resource): void { + $mount = Mount::factory()->create(); + $models = $resource === 'nodes' + ? Node::factory()->withLocation()->count(10)->create() + : Egg::factory()->count(10)->create(); + $counts = []; + foreach ([1, 10] as $limit) { + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $this->postJson(route('api.admin.mounts.'.$resource, ['mount' => $mount->id]), [$resource => $models->take($limit)->modelKeys()])->assertOk(); + $reads = array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select')); + $counts[] = count($reads); + } finally { + DB::disableQueryLog(); + } + } + + expect($counts[1])->toBe($counts[0]); + expect($mount->{$resource}()->count())->toBe(10); +})->with(['nodes', 'eggs']); + +test('mount attachment accepts numeric string identifiers', function (string $resource): void { + $mount = Mount::factory()->create(); + $model = $resource === 'nodes' ? createNode() : createEgg(); + + $this->postJson(route('api.admin.mounts.'.$resource, ['mount' => $mount->id]), [$resource => [(string) $model->id]]) + ->assertOk(); + + expect($mount->{$resource}()->whereKey($model->id)->exists())->toBeTrue(); +})->with(['nodes', 'eggs']); + +test('mount attachment rejects associative identifiers with 422', function (string $resource): void { + $mount = Mount::factory()->create(); + $model = $resource === 'nodes' ? createNode() : createEgg(); + + $this->postJson(route('api.admin.mounts.'.$resource, ['mount' => $mount->id]), [$resource => ['selected' => $model->id]]) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', $resource); + + expect($mount->{$resource}()->exists())->toBeFalse(); +})->with(['nodes', 'eggs']); + +test('mount attachment rejects malformed identifier values with 422', function (string $resource, bool|float|string|null $value): void { + $mount = Mount::factory()->create(); + + $this->postJson(route('api.admin.mounts.'.$resource, ['mount' => $mount->id]), [$resource => [$value]], options: JSON_PRESERVE_ZERO_FRACTION) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', $resource.'.0'); + + expect($mount->{$resource}()->exists())->toBeFalse(); +})->with(['nodes', 'eggs'])->with(['boolean' => true, 'whole float' => 1.0, 'empty string' => '', 'null' => [null]]); + +test('mount collection batches requested includes independently of page size', function (): void { + $mounts = Mount::factory()->count(10)->create(); + foreach ($mounts as $mount) { + $mount->eggs()->attach(createEgg()); + $mount->nodes()->attach(createNode()); + } + + $counts = []; + foreach ([1, 10] as $limit) { + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $this->getJson(route('api.admin.mounts', ['include' => 'eggs,nodes,servers', 'per_page' => $limit])) + ->assertOk() + ->assertJsonCount($limit, 'data'); + $counts[] = count(array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select'))); + } finally { + DB::disableQueryLog(); + } + } + + expect($counts[1])->toBe($counts[0]); +}); diff --git a/tests/Integration/Api/Admin/Mounts/MountControllerTest.php b/tests/Integration/Api/Admin/Mounts/MountControllerTest.php new file mode 100644 index 000000000..a5b3e1d7b --- /dev/null +++ b/tests/Integration/Api/Admin/Mounts/MountControllerTest.php @@ -0,0 +1,87 @@ + [['getJson', 'api.admin.mounts'], ['getJson', 'api.admin.mounts.view'], ['postJson', 'api.admin.mounts.store'], ['putJson', 'api.admin.mounts.update'], ['delete', 'api.admin.mounts.delete']]); +test('get mounts', function (): void { + $mount = Mount::factory()->create(); + $response = $this->getJson(route('api.admin.mounts', ['per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'uuid', 'name', 'description', 'source', 'target', 'read_only', 'user_mountable', 'eggs_count', 'nodes_count', 'servers_count']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[]], 'meta' => ['pagination' => ['total' => 1, 'count' => 1, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]]); + Assert::assertArraySubset(['object' => 'mount', 'attributes' => ['id' => $mount->id, 'uuid' => $mount->uuid, 'name' => $mount->name, 'description' => $mount->description, 'source' => $mount->source, 'target' => $mount->target, 'read_only' => $mount->read_only, 'user_mountable' => $mount->user_mountable, 'eggs_count' => 0, 'nodes_count' => 0, 'servers_count' => 0]], collect($response->json('data'))->firstWhere('attributes.id', $mount->id), true); +}); +test('get mounts sorted by name', function (): void { + $zebra = Mount::factory()->create(['name' => 'ZZ Sort Mount Zebra']); + $alpha = Mount::factory()->create(['name' => 'ZZ Sort Mount Alpha']); + $response = $this->getJson(route('api.admin.mounts', ['filter' => ['name' => 'ZZ Sort Mount'], 'sort' => 'name'])); + $response->assertOk()->assertJsonPath('data.0.attributes.id', $alpha->id); + $this->assertNotSame($zebra->id, $alpha->id); +}); +test('get single mount', function (): void { + $mount = Mount::factory()->create(); + $response = $this->getJson(route('api.admin.mounts.view', ['mount' => $mount->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'description', 'source', 'target', 'read_only', 'user_mountable', 'eggs_count', 'nodes_count', 'servers_count']]); + $response->assertJson(['object' => 'mount', 'attributes' => ['id' => $mount->id, 'uuid' => $mount->uuid, 'name' => $mount->name, 'description' => $mount->description, 'source' => $mount->source, 'target' => $mount->target, 'read_only' => $mount->read_only, 'user_mountable' => $mount->user_mountable, 'eggs_count' => 0, 'nodes_count' => 0, 'servers_count' => 0]]); +}); +test('get missing mount', function (): void { + $response = $this->getJson(route('api.admin.mounts.view', ['mount' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('create mount', function (): void { + $response = $this->postJson(route('api.admin.mounts.store'), ['name' => 'Example Mount', 'description' => 'An example mount.', 'source' => '/mnt/example-source', 'target' => '/mnt/example-target', 'read_only' => true, 'user_mountable' => false]); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonCount(3); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'description', 'source', 'target', 'read_only', 'user_mountable', 'eggs_count', 'nodes_count', 'servers_count'], 'meta' => ['resource']]); + $this->assertDatabaseHas('mounts', ['name' => 'Example Mount', 'source' => '/mnt/example-source']); + $mount = Mount::query()->where('name', 'Example Mount')->first(); + $response->assertJson(['object' => 'mount', 'attributes' => ['id' => $mount->id, 'uuid' => $mount->uuid, 'name' => $mount->name, 'description' => $mount->description, 'source' => $mount->source, 'target' => $mount->target, 'read_only' => $mount->read_only, 'user_mountable' => $mount->user_mountable, 'eggs_count' => 0, 'nodes_count' => 0, 'servers_count' => 0], 'meta' => ['resource' => route('api.admin.mounts.view', ['mount' => $mount->id])]], true); +}); +test('update mount', function (): void { + $mount = Mount::factory()->create(); + $response = $this->putJson(route('api.admin.mounts.update', ['mount' => $mount->id]), ['name' => 'Updated Mount', 'description' => 'An updated mount.', 'source' => '/mnt/updated-source', 'target' => '/mnt/updated-target', 'read_only' => true, 'user_mountable' => true]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'description', 'source', 'target', 'read_only', 'user_mountable', 'eggs_count', 'nodes_count', 'servers_count']]); + $this->assertDatabaseHas('mounts', ['id' => $mount->id, 'name' => 'Updated Mount', 'source' => '/mnt/updated-source']); + $mount = $mount->fresh(); + $response->assertJson(['object' => 'mount', 'attributes' => ['id' => $mount->id, 'uuid' => $mount->uuid, 'name' => $mount->name, 'description' => $mount->description, 'source' => $mount->source, 'target' => $mount->target, 'read_only' => $mount->read_only, 'user_mountable' => $mount->user_mountable, 'eggs_count' => 0, 'nodes_count' => 0, 'servers_count' => 0]]); +}); +test('delete mount', function (): void { + $mount = Mount::factory()->create(); + $this->assertDatabaseHas('mounts', ['id' => $mount->id]); + $response = $this->delete(route('api.admin.mounts.delete', ['mount' => $mount->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('mounts', ['id' => $mount->id]); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $mount = Mount::factory()->create(); + $response = $this->{$method}(route($routeName, ['mount' => $mount->id])); + $this->assertAccessDeniedJson($response); +})->with('mountEndpointsDataProvider'); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.mounts.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + foreach (['name', 'source', 'target'] as $field) { + $error = $errors->firstWhere('meta.source_field', $field); + expect($error)->not->toBeNull("Expected a validation error for the [{$field}] field."); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); + } +}); diff --git a/tests/Integration/Api/Admin/Nodes/AllocationControllerTest.php b/tests/Integration/Api/Admin/Nodes/AllocationControllerTest.php new file mode 100644 index 000000000..354c35a41 --- /dev/null +++ b/tests/Integration/Api/Admin/Nodes/AllocationControllerTest.php @@ -0,0 +1,213 @@ +create(); + $this->node = Node::factory()->create(['location_id' => $location->id]); +}); +/** Endpoints that should return a 403 when accessed by a user that is not a root administrator. */ +dataset('allocationEndpointsDataProvider', fn (): array => [['getJson', 'api.admin.nodes.allocations'], ['getJson', 'api.admin.nodes.allocations.ips'], ['getJson', 'api.admin.nodes.allocations.available'], ['postJson', 'api.admin.nodes.allocations.store'], ['putJson', 'api.admin.nodes.allocations.update'], ['delete', 'api.admin.nodes.allocations.delete'], ['deleteJson', 'api.admin.nodes.allocations.bulk-delete'], ['deleteJson', 'api.admin.nodes.allocations.block']]); +test('get allocations', function (): void { + $allocations = Allocation::factory()->times(2)->create(['node_id' => $this->node->id]); + // An allocation on a different node should not leak into the response. + $other = Node::factory()->create(['location_id' => $this->node->location_id]); + Allocation::factory()->create(['node_id' => $other->id]); + $response = $this->getJson(route('api.admin.nodes.allocations', ['node' => $this->node->id, 'per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'ip', 'alias', 'port', 'notes', 'server_id', 'server_name', 'assigned']], ['object', 'attributes' => ['id', 'ip', 'alias', 'port', 'notes', 'server_id', 'server_name', 'assigned']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'meta' => ['pagination' => ['total' => 2, 'count' => 2, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]]); + Assert::assertArraySubset(['object' => 'allocation', 'attributes' => ['id' => $allocations[0]->id, 'ip' => $allocations[0]->ip, 'port' => $allocations[0]->port, 'alias' => $allocations[0]->ip_alias, 'server_id' => $allocations[0]->server_id, 'assigned' => $allocations[0]->server_id !== null]], collect($response->json('data'))->firstWhere('attributes.id', $allocations[0]->id), true); + Assert::assertArraySubset(['object' => 'allocation', 'attributes' => ['id' => $allocations[1]->id, 'ip' => $allocations[1]->ip, 'port' => $allocations[1]->port, 'alias' => $allocations[1]->ip_alias, 'server_id' => $allocations[1]->server_id, 'assigned' => $allocations[1]->server_id !== null]], collect($response->json('data'))->firstWhere('attributes.id', $allocations[1]->id), true); +}); +test('assigned allocation returns server name', function (): void { + $server = $this->createServerModel(['node_id' => $this->node->id]); + $assigned = $server->allocation; + $unassigned = Allocation::factory()->create(['node_id' => $this->node->id]); + $response = $this->getJson(route('api.admin.nodes.allocations', ['node' => $this->node->id, 'per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonFragment(['id' => $assigned->id, 'server_id' => $server->id, 'server_name' => $server->name, 'assigned' => true]); + $response->assertJsonFragment(['id' => $unassigned->id, 'server_id' => null, 'server_name' => null, 'assigned' => false]); +}); +test('empty server id filter returns only unassigned allocations', function (): void { + $server = $this->createServerModel(['node_id' => $this->node->id]); + $assigned = $server->allocation; + $free = Allocation::factory()->create(['node_id' => $this->node->id]); + $response = $this->getJson(route('api.admin.nodes.allocations', ['node' => $this->node->id, 'filter' => ['server_id' => '']])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonFragment(['id' => $free->id, 'assigned' => false]); + $response->assertJsonMissing(['id' => $assigned->id]); +}); +test('server id filter returns only that server allocations', function (): void { + $server = $this->createServerModel(['node_id' => $this->node->id]); + $assigned = $server->allocation; + $free = Allocation::factory()->create(['node_id' => $this->node->id]); + $response = $this->getJson(route('api.admin.nodes.allocations', ['node' => $this->node->id, 'filter' => ['server_id' => $server->id]])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonFragment(['id' => $assigned->id, 'assigned' => true]); + $response->assertJsonMissing(['id' => $free->id]); +}); +test('unique ips', function (): void { + Allocation::factory()->times(2)->create(['node_id' => $this->node->id, 'ip' => '10.0.0.9']); + Allocation::factory()->create(['node_id' => $this->node->id, 'ip' => '10.0.0.8']); + $response = $this->getJson(route('api.admin.nodes.allocations.ips', ['node' => $this->node->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertExactJson(['data' => ['10.0.0.8', '10.0.0.9']]); +}); +test('available allocations', function (): void { + $server = $this->createServerModel(['node_id' => $this->node->id]); + $assigned = $server->allocation; + $free = Allocation::factory()->create(['node_id' => $this->node->id]); + $response = $this->getJson(route('api.admin.nodes.allocations.available', ['node' => $this->node->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonFragment(['id' => $free->id, 'assigned' => false]); + $response->assertJsonMissing(['id' => $assigned->id]); +}); +test('create allocations', function (): void { + $response = $this->postJson(route('api.admin.nodes.allocations.store', ['node' => $this->node->id]), ['ip' => ['192.168.1.1'], 'alias' => 'test-alias', 'ports' => ['25565', '25566']]); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('allocations', ['node_id' => $this->node->id, 'ip' => '192.168.1.1', 'port' => 25565, 'ip_alias' => 'test-alias']); + $this->assertDatabaseHas('allocations', ['node_id' => $this->node->id, 'ip' => '192.168.1.1', 'port' => 25566, 'ip_alias' => 'test-alias']); +}); +test('create allocations from range', function (): void { + $response = $this->postJson(route('api.admin.nodes.allocations.store', ['node' => $this->node->id]), ['ip' => ['192.168.1.2'], 'ports' => ['5000-5002']]); + $response->assertStatus(Response::HTTP_NO_CONTENT); + foreach ([5000, 5001, 5002] as $port) { + $this->assertDatabaseHas('allocations', ['node_id' => $this->node->id, 'ip' => '192.168.1.2', 'port' => $port]); + } +}); +test('update allocation alias', function (): void { + $allocation = Allocation::factory()->create(['node_id' => $this->node->id, 'ip_alias' => null]); + $response = $this->putJson(route('api.admin.nodes.allocations.update', ['node' => $this->node->id, 'allocation' => $allocation->id]), ['alias' => 'updated-alias']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'ip', 'alias', 'port', 'notes', 'server_id', 'server_name', 'assigned']]); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'ip_alias' => 'updated-alias']); + $response->assertJson(['object' => 'allocation', 'attributes' => ['id' => $allocation->id, 'ip' => $allocation->ip, 'port' => $allocation->port, 'alias' => 'updated-alias', 'server_id' => $allocation->server_id, 'assigned' => $allocation->server_id !== null]]); +}); +test('update allocation alias can be cleared', function (): void { + $allocation = Allocation::factory()->create(['node_id' => $this->node->id, 'ip_alias' => 'existing']); + $response = $this->putJson(route('api.admin.nodes.allocations.update', ['node' => $this->node->id, 'allocation' => $allocation->id]), ['alias' => '']); + $response->assertStatus(Response::HTTP_OK); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'ip_alias' => null]); +}); +test('delete allocation', function (): void { + $allocation = Allocation::factory()->create(['node_id' => $this->node->id]); + $response = $this->delete(route('api.admin.nodes.allocations.delete', ['node' => $this->node->id, 'allocation' => $allocation->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('allocations', ['id' => $allocation->id]); +}); +test('cannot delete assigned allocation', function (): void { + $server = $this->createServerModel(['node_id' => $this->node->id]); + $allocation = $server->allocation; + $response = $this->delete(route('api.admin.nodes.allocations.delete', ['node' => $this->node->id, 'allocation' => $allocation->id])); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + // Error handler rolls the transaction back on render, so only assert the rejected status. + $response->assertJsonPath('errors.0.code', 'ServerUsingAllocationException'); +}); +test('bulk delete allocations', function (): void { + $allocations = Allocation::factory()->times(3)->create(['node_id' => $this->node->id]); + $keep = Allocation::factory()->create(['node_id' => $this->node->id]); + $response = $this->deleteJson(route('api.admin.nodes.allocations.bulk-delete', ['node' => $this->node->id]), ['ids' => [$allocations[0]->id, $allocations[1]->id, $allocations[2]->id]]); + $response->assertStatus(Response::HTTP_NO_CONTENT); + foreach ($allocations as $allocation) { + $this->assertDatabaseMissing('allocations', ['id' => $allocation->id]); + } + + $this->assertDatabaseHas('allocations', ['id' => $keep->id]); +}); +test('ip block delete allocations', function (): void { + $block = Allocation::factory()->times(2)->create(['node_id' => $this->node->id, 'ip' => '10.0.0.5']); + $other = Allocation::factory()->create(['node_id' => $this->node->id, 'ip' => '10.0.0.6']); + $response = $this->deleteJson(route('api.admin.nodes.allocations.block', ['node' => $this->node->id]), ['ip' => '10.0.0.5']); + $response->assertStatus(Response::HTTP_NO_CONTENT); + foreach ($block as $allocation) { + $this->assertDatabaseMissing('allocations', ['id' => $allocation->id]); + } + + $this->assertDatabaseHas('allocations', ['id' => $other->id]); +}); +test('bulk delete requires ids', function (): void { + $response = $this->deleteJson(route('api.admin.nodes.allocations.bulk-delete', ['node' => $this->node->id]), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'ids'); +}); +test('ip block delete requires ip', function (): void { + $response = $this->deleteJson(route('api.admin.nodes.allocations.block', ['node' => $this->node->id]), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'ip'); +}); +test('allocation not on node returns404', function (): void { + $other = Node::factory()->create(['location_id' => $this->node->location_id]); + $allocation = Allocation::factory()->create(['node_id' => $other->id]); + $response = $this->delete(route('api.admin.nodes.allocations.delete', ['node' => $this->node->id, 'allocation' => $allocation->id])); + $this->assertNotFoundJson($response); +}); +test('missing node returns404', function (): void { + $response = $this->getJson(route('api.admin.nodes.allocations', ['node' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.nodes.allocations.store', ['node' => $this->node->id]), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'ip'); + expect($error)->not->toBeNull('Expected a validation error for the [ip] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); + + $error = $errors->firstWhere('meta.source_field', 'ports'); + expect($error)->not->toBeNull('Expected a validation error for the [ports] field.'); + expect($error['meta']['rule'])->toBe('required'); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $allocation = Allocation::factory()->create(['node_id' => $this->node->id]); + $response = $this->{$method}(route($routeName, ['node' => $this->node->id, 'allocation' => $allocation->id])); + $this->assertAccessDeniedJson($response); +})->with('allocationEndpointsDataProvider'); +test('creating allocations records the address under a non reserved property', function (): void { + $this->postJson(route('api.admin.nodes.allocations.store', ['node' => $this->node->id]), ['ip' => ['10.0.0.1'], 'ports' => ['25565']])->assertStatus(Response::HTTP_NO_CONTENT); + + $properties = ActivityLog::query()->where('event', 'admin:node-allocation.create')->latest('id')->firstOrFail()->propertyValues(); + + expect($properties)->toBe(['address' => ['10.0.0.1'], 'ports' => ['25565']]); +}); +test('allocation creation rejects associative address and port arrays', function (string $field): void { + $payload = ['ip' => ['10.0.0.1'], 'ports' => ['25565']]; + $payload[$field] = ['first' => $payload[$field][0]]; + + $this->postJson(route('api.admin.nodes.allocations.store', ['node' => $this->node->id]), $payload) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', $field); + + $this->assertDatabaseMissing('allocations', ['node_id' => $this->node->id]); +})->with(['ip', 'ports']); +test('deleting an ip block records a distinct event from deleting one allocation', function (): void { + $allocation = Allocation::factory()->create(['node_id' => $this->node->id, 'ip' => '10.0.0.5', 'port' => 25565]); + Allocation::factory()->create(['node_id' => $this->node->id, 'ip' => '10.0.0.6']); + + $this->delete(route('api.admin.nodes.allocations.delete', ['node' => $this->node->id, 'allocation' => $allocation->id]))->assertStatus(Response::HTTP_NO_CONTENT); + $this->deleteJson(route('api.admin.nodes.allocations.block', ['node' => $this->node->id]), ['ip' => '10.0.0.6'])->assertStatus(Response::HTTP_NO_CONTENT); + + $properties = fn (string $event): array => ActivityLog::query()->where('event', $event)->latest('id')->firstOrFail()->propertyValues(); + + expect($properties('admin:node-allocation.delete'))->toBe(['address' => '10.0.0.5', 'port' => 25565]); + expect($properties('admin:node-allocation.delete-block'))->toBe(['address' => '10.0.0.6']); +}); diff --git a/tests/Integration/Api/Admin/Nodes/NodeControllerTest.php b/tests/Integration/Api/Admin/Nodes/NodeControllerTest.php new file mode 100644 index 000000000..069ebac84 --- /dev/null +++ b/tests/Integration/Api/Admin/Nodes/NodeControllerTest.php @@ -0,0 +1,126 @@ + [['getJson', 'api.admin.nodes'], ['getJson', 'api.admin.nodes.view'], ['getJson', 'api.admin.nodes.configuration'], ['postJson', 'api.admin.nodes.store'], ['putJson', 'api.admin.nodes.update'], ['delete', 'api.admin.nodes.delete']]); +test('get nodes', function (): void { + $nodes = Node::factory()->times(2)->for(Location::factory())->create(); + $response = $this->getJson(route('api.admin.nodes', ['per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'uuid', 'name', 'fqdn', 'created_at', 'updated_at']], ['object', 'attributes' => ['id', 'uuid', 'name', 'fqdn', 'created_at', 'updated_at']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[], []], 'meta' => ['pagination' => ['total' => 2, 'count' => 2, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]]); + Assert::assertArraySubset(['object' => 'node', 'attributes' => ['id' => $nodes[0]->id, 'uuid' => $nodes[0]->uuid, 'name' => $nodes[0]->name, 'fqdn' => $nodes[0]->fqdn, 'location_id' => $nodes[0]->location_id, 'memory' => $nodes[0]->memory, 'disk' => $nodes[0]->disk]], collect($response->json('data'))->firstWhere('attributes.id', $nodes[0]->id), true); + Assert::assertArraySubset(['object' => 'node', 'attributes' => ['id' => $nodes[1]->id, 'uuid' => $nodes[1]->uuid, 'name' => $nodes[1]->name, 'fqdn' => $nodes[1]->fqdn, 'location_id' => $nodes[1]->location_id, 'memory' => $nodes[1]->memory, 'disk' => $nodes[1]->disk]], collect($response->json('data'))->firstWhere('attributes.id', $nodes[1]->id), true); +}); +test('get nodes sorted by name', function (): void { + $alpha = Node::factory()->for(Location::factory())->create(['name' => 'Alpha']); + $bravo = Node::factory()->for(Location::factory())->create(['name' => 'Bravo']); + $response = $this->getJson(route('api.admin.nodes', ['sort' => '-name', 'per_page' => 2])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('data.0.attributes.id', $bravo->id); + $response->assertJsonPath('data.1.attributes.id', $alpha->id); +}); +test('get single node', function (): void { + $node = Node::factory()->for(Location::factory())->create(); + $response = $this->getJson(route('api.admin.nodes.view', ['node' => $node->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'fqdn', 'memory', 'disk', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'node', 'attributes' => ['id' => $node->id, 'uuid' => $node->uuid, 'name' => $node->name, 'fqdn' => $node->fqdn, 'location_id' => $node->location_id, 'memory' => $node->memory, 'disk' => $node->disk]]); +}); +test('get missing node', function (): void { + $response = $this->getJson(route('api.admin.nodes.view', ['node' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('get node configuration', function (): void { + $node = Node::factory()->for(Location::factory())->create(); + $response = $this->getJson(route('api.admin.nodes.configuration', ['node' => $node->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['uuid', 'token_id', 'token', 'api' => ['host', 'port', 'ssl' => ['enabled', 'cert', 'key'], 'upload_limit'], 'system' => ['data', 'sftp' => ['bind_port']], 'remote']); + $response->assertJson(['uuid' => $node->uuid]); +}); +test('create node', function (): void { + $location = Location::factory()->create(); + $response = $this->postJson(route('api.admin.nodes.store'), ['name' => 'NewNode', 'description' => 'A brand new node.', 'location_id' => $location->id, 'public' => true, 'fqdn' => 'localhost', 'scheme' => 'https', 'behind_proxy' => false, 'maintenance_mode' => false, 'memory' => 2048, 'memory_overallocate' => 0, 'disk' => 20480, 'disk_overallocate' => 0, 'upload_size' => 100, 'daemon_listen' => 8080, 'daemon_sftp' => 2022, 'daemon_base' => '/var/lib/pterodactyl/volumes']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'name', 'fqdn', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $this->assertDatabaseHas('nodes', ['name' => 'NewNode', 'fqdn' => 'localhost']); + $node = Node::query()->where('name', 'NewNode')->first(); + $response->assertJson(['object' => 'node', 'attributes' => ['id' => $node->id, 'uuid' => $node->uuid, 'name' => $node->name, 'fqdn' => $node->fqdn, 'location_id' => $node->location_id, 'memory' => $node->memory, 'disk' => $node->disk], 'meta' => ['resource' => route('api.admin.nodes.view', ['node' => $node->id])]]); +}); +test('create node rejects ip address when using https', function (): void { + $location = Location::factory()->create(); + $response = $this->postJson(route('api.admin.nodes.store'), ['name' => 'IpNode', 'description' => 'A node with an invalid HTTPS address.', 'location_id' => $location->id, 'public' => true, 'fqdn' => '127.0.0.1', 'scheme' => 'https', 'behind_proxy' => false, 'maintenance_mode' => false, 'memory' => 2048, 'memory_overallocate' => 0, 'disk' => 20480, 'disk_overallocate' => 0, 'upload_size' => 100, 'daemon_listen' => 8080, 'daemon_sftp' => 2022, 'daemon_base' => '/var/lib/pterodactyl/volumes']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'fqdn'); +}); +test('create node rejects http when panel request is secure', function (): void { + $location = Location::factory()->create(); + // An explicitly https URL is required: the framework derives the HTTPS server + // variable from the request URL, so withServerVariables() would be overridden. + $response = $this->postJson('https://localhost'.route('api.admin.nodes.store', absolute: false), ['name' => 'HttpNode', 'description' => 'A node that would break secure browser websocket connections.', 'location_id' => $location->id, 'public' => true, 'fqdn' => 'localhost', 'scheme' => 'http', 'behind_proxy' => false, 'maintenance_mode' => false, 'memory' => 2048, 'memory_overallocate' => 0, 'disk' => 20480, 'disk_overallocate' => 0, 'upload_size' => 100, 'daemon_listen' => 8080, 'daemon_sftp' => 2022, 'daemon_base' => '/var/lib/pterodactyl/volumes']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'scheme'); +}); +test('update node', function (): void { + $node = Node::factory()->for(Location::factory())->create(); + $location = Location::factory()->create(); + $fake = new FakeDaemonConfiguration; + $response = $this->putJson(route('api.admin.nodes.update', ['node' => $node->id]), ['name' => 'UpdatedNode', 'description' => 'An updated description.', 'location_id' => $location->id, 'public' => true, 'fqdn' => 'localhost', 'scheme' => 'https', 'behind_proxy' => false, 'maintenance_mode' => false, 'memory' => 4096, 'memory_overallocate' => 10, 'disk' => 40960, 'disk_overallocate' => 20, 'upload_size' => 256, 'daemon_listen' => 1102, 'daemon_sftp' => 1101, 'daemon_base' => '/var/lib/pterodactyl/volumes']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'node'); + $response->assertJsonPath('attributes.name', 'UpdatedNode'); + $response->assertJsonPath('attributes.fqdn', 'localhost'); + $response->assertJsonPath('attributes.memory', 4096); + $response->assertJsonPath('attributes.daemon_listen', 1102); + $response->assertJsonPath('attributes.daemon_sftp', 1101); + $this->assertDatabaseHas('nodes', ['id' => $node->id, 'name' => 'UpdatedNode']); + expect($node->refresh()->location_id)->toEqual($location->id); + $fake->assertUpdated(); + Http::assertSent(fn (HttpRequest $request): bool => $request->hasHeader('Authorization', 'Bearer '.$node->getDecryptedKey())); +}); +test('delete node', function (): void { + $node = Node::factory()->for(Location::factory())->create(); + $this->assertDatabaseHas('nodes', ['id' => $node->id]); + $response = $this->delete(route('api.admin.nodes.delete', ['node' => $node->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('nodes', ['id' => $node->id]); +}); +test('delete node with servers', function (): void { + $server = $this->createServerModel(); + $node = Node::query()->findOrFail($server->node_id); + $response = $this->delete(route('api.admin.nodes.delete', ['node' => $node->id])); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + // Error handler rolls the transaction back on render, so only assert the rejected status. + $response->assertJsonPath('errors.0.code', 'HasActiveServersException'); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $node = Node::factory()->for(Location::factory())->create(); + $response = $this->{$method}(route($routeName, ['node' => $node->id])); + $this->assertAccessDeniedJson($response); +})->with('nodeEndpointsDataProvider'); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.nodes.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'name'); + expect($error)->not->toBeNull('Expected a validation error for the [name] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); diff --git a/tests/Integration/Api/Admin/Nodes/NodeIntrospectionControllerTest.php b/tests/Integration/Api/Admin/Nodes/NodeIntrospectionControllerTest.php new file mode 100644 index 000000000..29d51f0e2 --- /dev/null +++ b/tests/Integration/Api/Admin/Nodes/NodeIntrospectionControllerTest.php @@ -0,0 +1,96 @@ +for(Location::factory())->create(); + $information = ['version' => '1.11.0', 'os' => 'linux', 'architecture' => 'amd64', 'kernel_version' => '5.15.0-91-generic', 'cpu_count' => 8]; + $fake = new FakeDaemonConfiguration; + $fake->systemInformation = $information; + $response = $this->getJson(route('api.admin.nodes.system-information', ['node' => $node->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['version', 'os', 'architecture', 'kernel_version', 'cpu_count']); + $response->assertJson($information); + $fake->assertSystemInformationFetched(); + Http::assertSent(fn (HttpRequest $request): bool => $request->hasHeader('Authorization', 'Bearer '.$node->getDecryptedKey())); +}); +test('get system information for missing node', function () { + $response = $this->getJson(route('api.admin.nodes.system-information', ['node' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('deploy token creates key', function () { + $node = Node::factory()->for(Location::factory())->create(); + config()->set('app.url', 'https://panel.example.test'); + config()->set('app.debug', true); + $this->assertDatabaseMissing('api_keys', ['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION, 'r_nodes' => 3]); + $response = $this->postJson(route('api.admin.nodes.deploy-token', ['node' => $node->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['node', 'token', 'panel_url', 'allow_insecure']); + $response->assertJsonPath('node', $node->id); + $response->assertJsonPath('panel_url', 'https://panel.example.test'); + $response->assertJsonPath('allow_insecure', true); + $key = ApiKey::query()->where('user_id', $this->getAdminUser()->id)->where('key_type', ApiKey::TYPE_APPLICATION)->where('r_nodes', 3)->firstOrFail(); + foreach (AdminAcl::getResourceList() as $resource) { + expect($key->getAttribute(AdminAcl::COLUMN_IDENTIFIER.$resource))->toBe($resource === AdminAcl::RESOURCE_NODES ? AdminAcl::READ | AdminAcl::WRITE : AdminAcl::NONE); + } + // The returned token is the identifier concatenated with the decrypted secret. + expect($response->json('token'))->toStartWith($key->identifier); +}); +test('deploy token reuses existing key', function () { + $node = Node::factory()->for(Location::factory())->create(); + $first = $this->postJson(route('api.admin.nodes.deploy-token', ['node' => $node->id])); + $first->assertStatus(Response::HTTP_OK); + $second = $this->postJson(route('api.admin.nodes.deploy-token', ['node' => $node->id])); + $second->assertStatus(Response::HTTP_OK); + expect($second->json('token'))->toBe($first->json('token')); + $count = ApiKey::query()->where('user_id', $this->getAdminUser()->id)->where('key_type', ApiKey::TYPE_APPLICATION)->where('r_nodes', 3)->count(); + expect($count)->toBe(1); +}); +test('deploy token never reuses a key with wider permissions', function (): void { + $node = Node::factory()->for(Location::factory())->create(); + $broad = ApiKey::factory()->create(['user_id' => $this->getAdminUser()->id, 'key_type' => ApiKey::TYPE_APPLICATION, 'r_nodes' => 3, 'r_servers' => 3, 'r_users' => 3]); + $response = $this->postJson(route('api.admin.nodes.deploy-token', ['node' => $node->id]))->assertOk(); + expect($response->json('token'))->not->toStartWith($broad->identifier); +}); +test('deploy token for missing node', function () { + $response = $this->postJson(route('api.admin.nodes.deploy-token', ['node' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('get utilization', function () { + $server = $this->createServerModel(); + $node = Node::query()->findOrFail($server->node_id); + $response = $this->getJson(route('api.admin.nodes.utilization', ['node' => $node->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['memory' => ['value', 'max', 'percent', 'css'], 'disk' => ['value', 'max', 'percent', 'css']]); + $response->assertJsonPath('memory.max', number_format($node->memory)); + $response->assertJsonPath('disk.max', number_format($node->disk)); + $response->assertJsonPath('memory.value', number_format($server->memory)); + $response->assertJsonPath('disk.value', number_format($server->disk)); +}); +test('get utilization for missing node', function () { + $response = $this->getJson(route('api.admin.nodes.utilization', ['node' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (string $method, string $routeName) { + $this->actingAsNonAdmin(); + $node = Node::factory()->for(Location::factory())->create(); + $response = $this->{$method}(route($routeName, ['node' => $node->id])); + $this->assertAccessDeniedJson($response); +})->with('introspectionEndpointsDataProvider'); diff --git a/tests/Integration/Api/Admin/PaginationValidationTest.php b/tests/Integration/Api/Admin/PaginationValidationTest.php new file mode 100644 index 000000000..62de167c2 --- /dev/null +++ b/tests/Integration/Api/Admin/PaginationValidationTest.php @@ -0,0 +1,58 @@ +for(Location::factory())->create(); + $endpoint = str_replace('{node}', (string) $node->id, $endpoint); + } + + $this->getJson($endpoint.'?per_page=invalid') + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'per_page'); +})->with([ + 'users' => '/api/admin/users', + 'nodes' => '/api/admin/nodes', + 'locations' => '/api/admin/locations', + 'eggs' => '/api/admin/eggs', + 'servers' => '/api/admin/servers', + 'mounts' => '/api/admin/mounts', + 'tags' => '/api/admin/tags', + 'api keys' => '/api/admin/api-keys', + 'database hosts' => '/api/admin/database-hosts', + 'allocations' => '/api/admin/nodes/{node}/allocations', + 'activity' => '/api/admin/activity', +]); + +test('admin pagination rejects invalid bounds and shapes with 422', function (array $query, string $field): void { + $this->getJson(route('api.admin.users', $query)) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', $field); +})->with([ + 'zero size' => [['per_page' => 0], 'per_page'], + 'negative size' => [['per_page' => -1], 'per_page'], + 'oversized page' => [['per_page' => 101], 'per_page'], + 'array size' => [['per_page' => [10]], 'per_page'], + 'zero page' => [['page' => 0], 'page'], + 'negative page' => [['page' => -1], 'page'], + 'non-integer page' => [['page' => 'invalid'], 'page'], +]); + +test('admin pagination accepts integer query strings and preserves its default', function (): void { + $this->getJson(route('api.admin.users')) + ->assertOk() + ->assertJsonPath('meta.pagination.per_page', 50); + + $this->getJson(route('api.admin.users', ['per_page' => '100', 'page' => '1'])) + ->assertOk() + ->assertJsonPath('meta.pagination.per_page', 100); +}); diff --git a/tests/Integration/Api/Admin/Servers/DatabaseControllerTest.php b/tests/Integration/Api/Admin/Servers/DatabaseControllerTest.php new file mode 100644 index 000000000..06123d440 --- /dev/null +++ b/tests/Integration/Api/Admin/Servers/DatabaseControllerTest.php @@ -0,0 +1,152 @@ + [['getJson', 'api.admin.servers.databases'], ['getJson', 'api.admin.servers.databases.view'], ['postJson', 'api.admin.servers.databases.store'], ['postJson', 'api.admin.servers.databases.rotate-password'], ['delete', 'api.admin.servers.databases.delete']]); +test('get databases', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $databases = Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id, 'max_connections' => 0]); + $response = $this->getJson(route('api.admin.servers.databases', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'host' => ['address', 'port'], 'name', 'username', 'connections_from', 'max_connections']], ['object', 'attributes' => ['id', 'host' => ['address', 'port'], 'name', 'username', 'connections_from', 'max_connections']]]]); + Assert::assertArraySubset(['object' => 'server_database', 'attributes' => ['id' => hashid($databases[0]->id), 'host' => ['address' => $host->host, 'port' => $host->port], 'name' => $databases[0]->database, 'username' => $databases[0]->username, 'connections_from' => $databases[0]->remote, 'max_connections' => 0]], collect($response->json('data'))->firstWhere('attributes.id', hashid($databases[0]->id)), true); + Assert::assertArraySubset(['object' => 'server_database', 'attributes' => ['id' => hashid($databases[1]->id), 'host' => ['address' => $host->host, 'port' => $host->port], 'name' => $databases[1]->database, 'username' => $databases[1]->username, 'connections_from' => $databases[1]->remote, 'max_connections' => 0]], collect($response->json('data'))->firstWhere('attributes.id', hashid($databases[1]->id)), true); +}); +test('get databases by server short uuid', function (): void { + $server = $this->createServerModel(['uuidShort' => 'feedbabe']); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $response = $this->getJson(route('api.admin.servers.databases', ['server' => $server->uuidShort])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.name', $database->database); +}); +test('get single database', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id, 'max_connections' => 25]); + $response = $this->getJson(route('api.admin.servers.databases.view', ['server' => $server->id, 'database' => hashid($database->id)])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJson(['object' => 'server_database', 'attributes' => ['id' => hashid($database->id), 'host' => ['address' => $host->host, 'port' => $host->port], 'name' => $database->database, 'username' => $database->username, 'connections_from' => $database->remote, 'max_connections' => 25]], true); +}); +test('get single database with password include', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id, 'password' => encrypt('s3cr3t-password')]); + $response = $this->getJson(route('api.admin.servers.databases.view', ['server' => $server->id, 'database' => hashid($database->id), 'include' => 'password'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'name', 'relationships' => ['password' => ['object', 'attributes' => ['password']]]]]); + $response->assertJsonPath('object', 'server_database'); + $response->assertJsonPath('attributes.relationships.password.attributes.password', 's3cr3t-password'); +}); +test('get database not on server', function (): void { + $server = $this->createServerModel(); + $other = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $other->id, 'database_host_id' => $host->id]); + $response = $this->getJson(route('api.admin.servers.databases.view', ['server' => $server->id, 'database' => hashid($database->id)])); + $this->assertNotFoundJson($response); +}); +test('create database', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $response = $this->postJson(route('api.admin.servers.databases.store', ['server' => $server->id]), ['database' => 'admindb', 'remote' => '%', 'database_host_id' => $host->id, 'max_connections' => 25]); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'host' => ['address', 'port'], 'name', 'username', 'connections_from', 'max_connections', 'relationships' => ['password' => ['attributes' => ['password']]]], 'meta' => ['resource']]); + $response->assertJsonPath('object', 'server_database'); + $response->assertJsonPath('attributes.name', 's'.$server->id.'_admindb'); + + $database = Database::query()->where('server_id', $server->id)->firstOrFail(); + expect($database->remote)->toBe('%'); + expect($database->database_host_id)->toBe($host->id); + expect($database->max_connections)->toBe(25); + + $response->assertJsonPath('meta.resource', route('api.admin.servers.databases.view', ['server' => $server->id, 'database' => $database->id])); + $gateway->assertCreated('s'.$server->id.'_admindb'); + $gateway->assertAssigned('s'.$server->id.'_admindb', $database->username, '%'); + $gateway->assertFlushed(1); +}); +test('create database validation', function (): void { + $server = $this->createServerModel(); + $response = $this->postJson(route('api.admin.servers.databases.store', ['server' => $server->id]), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'database'); + expect($error)->not->toBeNull('Expected a validation error for the [database] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); +test('rotate password', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $response = $this->postJson(route('api.admin.servers.databases.rotate-password', ['server' => $server->id, 'database' => hashid($database->id)])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'name', 'relationships' => ['password' => ['attributes' => ['password']]]]]); + $response->assertJsonPath('object', 'server_database'); + + $gateway->assertFlushed(1); + expect($gateway->count('createUser'))->toBe(1); +}); +test('rotate password database not on server', function (): void { + $server = $this->createServerModel(); + $other = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $other->id, 'database_host_id' => $host->id]); + $response = $this->postJson(route('api.admin.servers.databases.rotate-password', ['server' => $server->id, 'database' => hashid($database->id)])); + $this->assertNotFoundJson($response); +}); +test('delete database', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $response = $this->delete(route('api.admin.servers.databases.delete', ['server' => $server->id, 'database' => hashid($database->id)])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('databases', ['id' => $database->id]); + $gateway->assertDroppedDatabase($database->database); + $gateway->assertDroppedUser($database->username, $database->remote); + $gateway->assertFlushed(1); +}); +test('delete database not on server', function (): void { + $server = $this->createServerModel(); + $other = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $other->id, 'database_host_id' => $host->id]); + $response = $this->delete(route('api.admin.servers.databases.delete', ['server' => $server->id, 'database' => hashid($database->id)])); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->actingAsNonAdmin(); + $response = $this->{$method}(route($routeName, ['server' => $server->id, 'database' => hashid($database->id)])); + $this->assertAccessDeniedJson($response); +})->with('databaseEndpointsDataProvider'); +/** Return the HashID encoded identifier for a database, as the route binding resolves it. */ +function hashid(int $id): string +{ + return (fn () => $this->app->make(HashidsInterface::class)->encode($id))->call(pterodactylTestCase()); +} diff --git a/tests/Integration/Api/Admin/Servers/ServerBackupControllerTest.php b/tests/Integration/Api/Admin/Servers/ServerBackupControllerTest.php new file mode 100644 index 000000000..ce6a01a78 --- /dev/null +++ b/tests/Integration/Api/Admin/Servers/ServerBackupControllerTest.php @@ -0,0 +1,58 @@ +createServerModel(); + $backups = Backup::factory()->times(2)->create(['server_id' => $server->id]); + $response = $this->getJson(route('api.admin.servers.backups', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['uuid', 'name', 'is_successful', 'is_locked', 'bytes', 'created_at', 'completed_at']]]]); + $response->assertJsonFragment(['uuid' => $backups[0]->uuid]); + $response->assertJsonFragment(['uuid' => $backups[1]->uuid]); +}); +test('list backups is scoped to server', function () { + $server = $this->createServerModel(); + Backup::factory()->create(['server_id' => $server->id]); + $other = $this->createServerModel(); + Backup::factory()->create(['server_id' => $other->id]); + $response = $this->getJson(route('api.admin.servers.backups', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); +}); +test('toggle backup lock', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id, 'is_locked' => false, 'ignored_files' => []]); + $response = $this->postJson(route('api.admin.servers.backups.toggle', ['server' => $server->id, 'backup' => $backup->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('attributes.is_locked', true); + $this->assertDatabaseHas('backups', ['id' => $backup->id, 'is_locked' => true]); + $this->postJson(route('api.admin.servers.backups.toggle', ['server' => $server->id, 'backup' => $backup->id])); + $this->assertDatabaseHas('backups', ['id' => $backup->id, 'is_locked' => false]); +}); +test('toggle backup not on server returns not found', function () { + $server = $this->createServerModel(); + $other = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $other->id]); + $response = $this->postJson(route('api.admin.servers.backups.toggle', ['server' => $server->id, 'backup' => $backup->id])); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (string $method, string $routeName) { + $this->actingAsNonAdmin(); + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id]); + $response = $this->{$method}(route($routeName, ['server' => $server->id, 'backup' => $backup->id])); + $this->assertAccessDeniedJson($response); +})->with('backupEndpointsDataProvider'); diff --git a/tests/Integration/Api/Admin/Servers/ServerControllerTest.php b/tests/Integration/Api/Admin/Servers/ServerControllerTest.php new file mode 100644 index 000000000..d2c42b9a6 --- /dev/null +++ b/tests/Integration/Api/Admin/Servers/ServerControllerTest.php @@ -0,0 +1,149 @@ + [['getJson', 'api.admin.servers'], ['getJson', 'api.admin.servers.view'], ['getJson', 'api.admin.servers.external'], ['postJson', 'api.admin.servers.store'], ['deleteJson', 'api.admin.servers.delete'], ['putJson', 'api.admin.servers.details'], ['putJson', 'api.admin.servers.build'], ['putJson', 'api.admin.servers.startup'], ['postJson', 'api.admin.servers.suspension'], ['postJson', 'api.admin.servers.reinstall'], ['postJson', 'api.admin.servers.rebuild'], ['getJson', 'api.admin.servers.transfer-progress']]); +test('get servers', function (): void { + $server = $this->createServerModel(); + $response = $this->getJson(route('api.admin.servers', ['per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'uuid', 'identifier', 'name', 'status', 'user', 'node', 'created_at', 'updated_at']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[]], 'meta' => ['pagination' => ['total' => 1, 'count' => 1, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]]); + Assert::assertArraySubset(['object' => 'server', 'attributes' => ['id' => $server->id, 'external_id' => $server->external_id, 'uuid' => $server->uuid, 'name' => $server->name, 'description' => $server->description, 'status' => $server->status, 'identifier' => $server->uuidShort, 'user' => $server->owner_id, 'node' => $server->node_id, 'allocation' => $server->allocation_id, 'egg' => $server->egg_id, 'limits' => ['memory' => $server->memory, 'disk' => $server->disk, 'cpu' => $server->cpu], 'feature_limits' => ['databases' => $server->database_limit, 'allocations' => $server->allocation_limit, 'backups' => $server->backup_limit], 'container' => ['startup_command' => $server->startup, 'image' => $server->image]]], collect($response->json('data'))->firstWhere('attributes.id', $server->id), true); +}); +test('get servers filtered by node', function (): void { + $server = $this->createServerModel(); + $this->createServerModel(); + $response = $this->getJson(route('api.admin.servers', ['filter' => ['node_id' => $server->node_id]])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.id', $server->id); +}); +test('get servers sorted by name', function (): void { + $alpha = $this->createServerModel(['name' => 'Alpha']); + $bravo = $this->createServerModel(['name' => 'Bravo']); + $response = $this->getJson(route('api.admin.servers', ['sort' => '-name', 'per_page' => 2])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('data.0.attributes.id', $bravo->id); + $response->assertJsonPath('data.1.attributes.id', $alpha->id); +}); +test('get servers filtered by broad search', function (): void { + /** @var User $owner */ + $owner = User::factory()->create(['username' => 'blade-owner', 'email' => 'blade-owner@example.com']); + $server = $this->createServerModel(['owner_id' => $owner->id, 'name' => 'Blade Parity', 'uuidShort' => 'b1ade123', 'external_id' => 'legacy-external']); + $this->createServerModel(['name' => 'Other Server']); + foreach (['blade', 'b1ade123', 'legacy-external', 'blade-owner', 'blade-owner@example.com'] as $term) { + $response = $this->getJson(route('api.admin.servers', ['filter' => ['*' => $term]])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.id', $server->id); + } +}); +test('get single server', function (): void { + $server = $this->createServerModel(); + $response = $this->getJson(route('api.admin.servers.view', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'identifier', 'name', 'status', 'limits', 'feature_limits', 'container', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'server', 'attributes' => ['id' => $server->id, 'external_id' => $server->external_id, 'uuid' => $server->uuid, 'name' => $server->name, 'description' => $server->description, 'status' => $server->status, 'identifier' => $server->uuidShort, 'user' => $server->owner_id, 'node' => $server->node_id, 'allocation' => $server->allocation_id, 'egg' => $server->egg_id, 'limits' => ['memory' => $server->memory, 'disk' => $server->disk, 'cpu' => $server->cpu], 'feature_limits' => ['databases' => $server->database_limit, 'allocations' => $server->allocation_limit, 'backups' => $server->backup_limit], 'container' => ['startup_command' => $server->startup, 'image' => $server->image]]]); +}); +test('get single server by short uuid', function (): void { + $server = $this->createServerModel(['uuidShort' => 'deadbeef']); + $response = $this->getJson(route('api.admin.servers.view', ['server' => $server->uuidShort])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJson(['object' => 'server', 'attributes' => ['id' => $server->id, 'external_id' => $server->external_id, 'uuid' => $server->uuid, 'name' => $server->name, 'description' => $server->description, 'status' => $server->status, 'identifier' => $server->uuidShort, 'user' => $server->owner_id, 'node' => $server->node_id, 'allocation' => $server->allocation_id, 'egg' => $server->egg_id, 'limits' => ['memory' => $server->memory, 'disk' => $server->disk, 'cpu' => $server->cpu], 'feature_limits' => ['databases' => $server->database_limit, 'allocations' => $server->allocation_limit, 'backups' => $server->backup_limit], 'container' => ['startup_command' => $server->startup, 'image' => $server->image]]]); +}); +test('includes can be loaded', function (): void { + $server = $this->createServerModel(); + $response = $this->getJson(route('api.admin.servers.view', ['server' => $server->id, 'include' => 'user,allocations,node,location'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['object', 'attributes' => ['relationships' => ['user' => ['object', 'attributes'], 'allocations' => ['object', 'data'], 'node' => ['object', 'attributes'], 'location' => ['object', 'attributes']]]]); + $response->assertJsonPath('attributes.relationships.user.attributes.id', $server->owner_id); + $response->assertJsonPath('attributes.relationships.node.attributes.id', $server->node_id); + // 'nest' is a retired include; unknown include names must still be ignored. + $ignored = $this->getJson(route('api.admin.servers.view', ['server' => $server->id, 'include' => 'nest'])); + $ignored->assertStatus(Response::HTTP_OK); +}); +test('get missing server', function (): void { + $response = $this->getJson(route('api.admin.servers.view', ['server' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('create server', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + /** @var Location $location */ + $location = Location::factory()->create(); + /** @var Node $node */ + $node = Node::factory()->create(['location_id' => $location->id]); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $node->id]); + /** @var Egg $egg */ + $egg = Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail(); + $fake = new FakeDaemonServer; + $response = $this->postJson(route('api.admin.servers.store'), ['name' => 'NewServer', 'description' => 'A brand new server.', 'owner_id' => $user->id, 'egg_id' => $egg->id, 'docker_image' => 'java:8', 'startup' => 'java -jar server.jar', 'environment' => ['BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server.jar'], 'memory' => 512, 'swap' => 0, 'disk' => 1024, 'io' => 500, 'cpu' => 0, 'threads' => null, 'database_limit' => 0, 'allocation_limit' => 0, 'backup_limit' => 0, 'primary_allocation_id' => $allocation->id]); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'uuid', 'identifier', 'name', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $this->assertDatabaseHas('servers', ['name' => 'NewServer', 'owner_id' => $user->id]); + $server = Server::query()->where('name', 'NewServer')->firstOrFail(); + $response->assertJson(['object' => 'server', 'meta' => ['resource' => route('api.admin.servers.view', ['server' => $server->id])]]); + $fake->assertCreated(); +}); +test('delete server', function (): void { + $server = $this->createServerModel(); + $this->assertDatabaseHas('servers', ['id' => $server->id]); + $fake = new FakeDaemonServer; + $response = $this->delete(route('api.admin.servers.delete', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); + $fake->assertDeleted(); +}); +test('force delete server via dedicated route', function (): void { + $server = $this->createServerModel(); + $fake = new FakeDaemonServer; + $this->delete(route('api.admin.servers.delete.force', ['server' => $server->id]))->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); + $fake->assertDeleted(); +}); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.servers.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'name'); + expect($error)->not->toBeNull('Expected a validation error for the [name] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); +test('get server by external id', function (): void { + $server = $this->createServerModel(['external_id' => 'srv-9000']); + $response = $this->getJson(route('api.admin.servers.external', ['external_id' => 'srv-9000'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJson(['object' => 'server', 'attributes' => ['id' => $server->id, 'external_id' => $server->external_id, 'uuid' => $server->uuid, 'name' => $server->name, 'description' => $server->description, 'status' => $server->status, 'identifier' => $server->uuidShort, 'user' => $server->owner_id, 'node' => $server->node_id, 'allocation' => $server->allocation_id, 'egg' => $server->egg_id, 'limits' => ['memory' => $server->memory, 'disk' => $server->disk, 'cpu' => $server->cpu], 'feature_limits' => ['databases' => $server->database_limit, 'allocations' => $server->allocation_limit, 'backups' => $server->backup_limit], 'container' => ['startup_command' => $server->startup, 'image' => $server->image]]]); +}); +test('get server by missing external id', function (): void { + $response = $this->getJson(route('api.admin.servers.external', ['external_id' => 'does-not-exist'])); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $server = $this->createServerModel(); + // Pass both id and external_id so external-lookup routes resolve too; the 403 fires before model binding. + $response = $this->{$method}(route($routeName, ['server' => $server->id, 'external_id' => 'forbidden'])); + $this->assertAccessDeniedJson($response); +})->with('serverEndpointsDataProvider'); diff --git a/tests/Integration/Api/Admin/Servers/ServerInstallControllerTest.php b/tests/Integration/Api/Admin/Servers/ServerInstallControllerTest.php new file mode 100644 index 000000000..2c3a38bf7 --- /dev/null +++ b/tests/Integration/Api/Admin/Servers/ServerInstallControllerTest.php @@ -0,0 +1,39 @@ +createServerModel(['status' => null]); + $response = $this->postJson(route('api.admin.servers.toggle-install', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + expect($server->refresh()->status)->toBe(Server::STATUS_INSTALLING); +}); +test('toggle installing server marks installed', function () { + $server = $this->createServerModel(['status' => Server::STATUS_INSTALLING]); + $response = $this->postJson(route('api.admin.servers.toggle-install', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + expect($server->refresh()->status)->toBeNull(); +}); +test('toggle rejected for failed install', function () { + $server = $this->createServerModel(['status' => Server::STATUS_INSTALL_FAILED]); + $response = $this->postJson(route('api.admin.servers.toggle-install', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'DisplayException'); +}); +test('toggle missing server', function () { + $response = $this->postJson(route('api.admin.servers.toggle-install', ['server' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function () { + $server = $this->createServerModel(); + $this->actingAsNonAdmin(); + $response = $this->postJson(route('api.admin.servers.toggle-install', ['server' => $server->id])); + $this->assertAccessDeniedJson($response); +}); diff --git a/tests/Integration/Api/Admin/Servers/ServerManagementTest.php b/tests/Integration/Api/Admin/Servers/ServerManagementTest.php new file mode 100644 index 000000000..4e7947cca --- /dev/null +++ b/tests/Integration/Api/Admin/Servers/ServerManagementTest.php @@ -0,0 +1,136 @@ +createServerModel(); + $fake = new FakeDaemonServer; + $response = $this->postJson(route('api.admin.servers.suspension', ['server' => $server->id]), ['suspended' => true]); + $response->assertStatus(Response::HTTP_NO_CONTENT); + + expect($server->refresh()->isSuspended())->toBeTrue(); + $fake->assertSynced(); +}); +test('unsuspend server', function (): void { + $server = $this->createServerModel(); + $server->update(['status' => Server::STATUS_SUSPENDED]); + + $fake = new FakeDaemonServer; + $response = $this->postJson(route('api.admin.servers.suspension', ['server' => $server->id]), ['suspended' => false]); + $response->assertStatus(Response::HTTP_NO_CONTENT); + + expect($server->refresh()->isSuspended())->toBeFalse(); + $fake->assertSynced(); +}); +test('reinstall server', function (): void { + $server = $this->createServerModel(); + $fake = new FakeDaemonServer; + $response = $this->postJson(route('api.admin.servers.reinstall', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_ACCEPTED); + + expect($server->refresh()->status)->toBe(Server::STATUS_INSTALLING); + $fake->assertReinstalled(); +}); +test('a server that skips its install script cannot be reinstalled', function (): void { + $server = $this->createServerModel(['skip_scripts' => true]); + $fake = new FakeDaemonServer; + + $this->postJson(route('api.admin.servers.reinstall', ['server' => $server->id])) + ->assertStatus(Response::HTTP_BAD_REQUEST) + ->assertJsonPath('errors.0.detail', trans('admin/server.exceptions.skipping_install_script')); + + expect($server->refresh()->status)->toBeNull() + ->and($fake->callsFor('reinstall'))->toBeEmpty(); +}); +test('rebuild server', function (): void { + $server = $this->createServerModel(); + $fake = new FakeDaemonServer; + $response = $this->postJson(route('api.admin.servers.rebuild', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + + $fake->assertSynced(); + Http::assertSent(fn (HttpRequest $request): bool => str_contains($request->url(), "/api/servers/{$server->uuid}/")); +}); +test('transfer progress when no transfer', function (): void { + $server = $this->createServerModel(); + $response = $this->getJson(route('api.admin.servers.transfer-progress', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); +}); +test('transfer progress in progress', function (): void { + $server = $this->createServerModel(); + $target = Node::factory()->create(['location_id' => $server->node->location_id]); + $transfer = new ServerTransfer(); + $transfer->server_id = $server->id; + $transfer->old_node = $server->node_id; + $transfer->new_node = $target->id; + $transfer->old_allocation = $server->allocation_id; + $transfer->new_allocation = $server->allocation_id; + $transfer->successful = null; + $transfer->save(); + + $response = $this->getJson(route('api.admin.servers.transfer-progress', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'server_transfer'); + $response->assertJsonPath('attributes.id', $transfer->id); + $response->assertJsonPath('attributes.new_node', $target->id); +}); +test('update server details', function (): void { + Bus::fake(); + $server = $this->createServerModel(); + /** @var User $owner */ + $owner = User::factory()->create(); + $response = $this->putJson(route('api.admin.servers.details', ['server' => $server->id]), ['name' => 'UpdatedServer', 'owner_id' => $owner->id, 'external_id' => 'external-123', 'description' => 'An updated description.']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'server'); + $response->assertJsonPath('attributes.name', 'UpdatedServer'); + $response->assertJsonPath('attributes.user', $owner->id); + $response->assertJsonPath('attributes.external_id', 'external-123'); + $this->assertDatabaseHas('servers', ['id' => $server->id, 'name' => 'UpdatedServer', 'owner_id' => $owner->id]); + Bus::assertDispatched(RevokeSftpAccessJob::class); +}); +test('update server build', function (): void { + $server = $this->createServerModel(); + new FakeDaemonServer; + $response = $this->putJson(route('api.admin.servers.build', ['server' => $server->id]), ['allocation_id' => $server->allocation_id, 'oom_disabled' => true, 'memory' => 1024, 'swap' => 0, 'io' => 500, 'cpu' => 100, 'threads' => null, 'disk' => 2048, 'database_limit' => 2, 'allocation_limit' => 1, 'backup_limit' => 3]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'server'); + $response->assertJsonPath('attributes.limits.memory', 1024); + $response->assertJsonPath('attributes.limits.disk', 2048); + $response->assertJsonPath('attributes.feature_limits.databases', 2); + $response->assertJsonPath('attributes.feature_limits.backups', 3); + $this->assertDatabaseHas('servers', ['id' => $server->id, 'memory' => 1024, 'disk' => 2048]); +}); +test('update server startup', function (): void { + $server = $this->createServerModel(['skip_scripts' => true]); + $response = $this->putJson(route('api.admin.servers.startup', ['server' => $server->id]), ['startup' => 'java -jar updated.jar', 'egg_id' => $server->egg_id, 'docker_image' => 'java:11', 'skip_scripts' => true, 'environment' => ['BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'updated.jar']]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('object', 'server'); + $response->assertJsonPath('attributes.container.startup_command', 'java -jar updated.jar'); + $response->assertJsonPath('attributes.container.image', 'java:11'); + $response->assertJsonPath('attributes.container.skip_scripts', true); + $this->assertDatabaseHas('servers', ['id' => $server->id, 'startup' => 'java -jar updated.jar', 'image' => 'java:11', 'skip_scripts' => true]); +}); +test('build rejects unassigned default allocation', function (): void { + $server = $this->createServerModel(); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id]); + $response = $this->putJson(route('api.admin.servers.build', ['server' => $server->id]), ['allocation_id' => $allocation->id, 'oom_disabled' => true, 'memory' => 256, 'swap' => 0, 'io' => 500, 'cpu' => 0, 'threads' => null, 'disk' => 512, 'database_limit' => 0, 'allocation_limit' => 0, 'backup_limit' => 0]); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'DisplayException'); +}); diff --git a/tests/Integration/Api/Admin/Servers/ServerMountControllerTest.php b/tests/Integration/Api/Admin/Servers/ServerMountControllerTest.php new file mode 100644 index 000000000..8fe200c80 --- /dev/null +++ b/tests/Integration/Api/Admin/Servers/ServerMountControllerTest.php @@ -0,0 +1,81 @@ +createServerModel(); + $mount = createEligibleMount($server); + $response = $this->getJson(route('api.admin.servers.mounts', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('object', 'list'); + $response->assertJsonPath('data.0.object', 'mount'); + $response->assertJsonPath('data.0.attributes.id', $mount->id); + $response->assertJsonPath('data.0.attributes.mounted', false); +}); +test('list reflects mounted state', function () { + $server = $this->createServerModel(); + $mount = createEligibleMount($server); + $this->postJson(route('api.admin.servers.mounts.store', ['server' => $server->id]), ['mount_id' => $mount->id])->assertStatus(Response::HTTP_NO_CONTENT); + $response = $this->getJson(route('api.admin.servers.mounts', ['server' => $server->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonPath('data.0.attributes.id', $mount->id); + $response->assertJsonPath('data.0.attributes.mounted', true); +}); +test('mount can be attached and detached', function () { + $server = $this->createServerModel(); + $mount = createEligibleMount($server); + $store = $this->postJson(route('api.admin.servers.mounts.store', ['server' => $server->id]), ['mount_id' => $mount->id]); + $store->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('mount_server', ['mount_id' => $mount->id, 'server_id' => $server->id]); + $delete = $this->deleteJson(route('api.admin.servers.mounts.delete', ['server' => $server->id, 'mount' => $mount->id])); + $delete->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('mount_server', ['mount_id' => $mount->id, 'server_id' => $server->id]); +}); +test('ineligible mount cannot be attached', function () { + $server = $this->createServerModel(); + /** @var Mount $mount */ + $mount = Mount::factory()->create(); + $response = $this->postJson(route('api.admin.servers.mounts.store', ['server' => $server->id]), ['mount_id' => $mount->id]); + $this->assertNotFoundJson($response); + $this->assertDatabaseMissing('mount_server', ['mount_id' => $mount->id, 'server_id' => $server->id]); +}); +test('store validation', function () { + $server = $this->createServerModel(); + $response = $this->postJson(route('api.admin.servers.mounts.store', ['server' => $server->id]), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'mount_id'); +}); +test('list missing server', function () { + $response = $this->getJson(route('api.admin.servers.mounts', ['server' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (string $method, string $routeName) { + $server = $this->createServerModel(); + $mount = createEligibleMount($server); + $this->actingAsNonAdmin(); + $response = $this->{$method}(route($routeName, ['server' => $server->id, 'mount' => $mount->id])); + $this->assertAccessDeniedJson($response); +})->with('mountEndpointsDataProvider'); +/** Create a mount eligible to attach to the server (assigned to its egg and node). */ +function createEligibleMount(Server $server): Mount +{ + /** @var Mount $mount */ + $mount = Mount::factory()->create(); + $mount->eggs()->attach($server->egg_id); + $mount->nodes()->attach($server->node_id); + + return $mount; +} diff --git a/tests/Integration/Api/Admin/Servers/ServerTransferControllerTest.php b/tests/Integration/Api/Admin/Servers/ServerTransferControllerTest.php new file mode 100644 index 000000000..2c1c30e25 --- /dev/null +++ b/tests/Integration/Api/Admin/Servers/ServerTransferControllerTest.php @@ -0,0 +1,133 @@ +createServerModel(); + /** @var Node $targetNode */ + $targetNode = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $targetNode->id, 'server_id' => null]); + $fake = new FakeDaemonTransfer; + $payload = ['node_id' => $targetNode->id, 'allocation_id' => $allocation->id]; + if ($nullAdditional) { + $payload['allocation_additional'] = null; + } + + $response = $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), $payload); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('server_transfers', ['server_id' => $server->id, 'old_node' => $server->node_id, 'new_node' => $targetNode->id, 'new_allocation' => $allocation->id]); + // The chosen allocation now belongs to the server so it cannot be claimed mid-transfer. + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => $server->id]); + $fake->assertNotified(); +})->with(['omitted additional allocations' => false, 'null additional allocations' => true]); +test('additional allocations are assigned', function (bool $stringIdentifiers): void { + $server = $this->createServerModel(); + /** @var Node $targetNode */ + $targetNode = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + /** @var Allocation $primary */ + $primary = Allocation::factory()->create(['node_id' => $targetNode->id, 'server_id' => null]); + /** @var Allocation $additional */ + $additional = Allocation::factory()->create(['node_id' => $targetNode->id, 'server_id' => null]); + $fake = new FakeDaemonTransfer; + $response = $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), ['node_id' => $targetNode->id, 'allocation_id' => $primary->id, 'allocation_additional' => [$stringIdentifiers ? (string) $additional->id : $additional->id]]); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('server_transfers', ['server_id' => $server->id, 'old_node' => $server->node_id, 'new_node' => $targetNode->id, 'new_allocation' => $primary->id]); + $this->assertDatabaseHas('allocations', ['id' => $primary->id, 'server_id' => $server->id]); + $this->assertDatabaseHas('allocations', ['id' => $additional->id, 'server_id' => $server->id]); + $fake->assertNotified(); +})->with(['integer identifiers' => false, 'numeric string identifiers' => true]); + +test('transfer rejects associative additional allocations with 422', function (): void { + $server = $this->createServerModel(); + $target = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + $primary = Allocation::factory()->for($target)->create(['server_id' => null]); + $additional = Allocation::factory()->for($target)->create(['server_id' => null]); + + $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), [ + 'node_id' => $target->id, + 'allocation_id' => $primary->id, + 'allocation_additional' => ['selected' => $additional->id], + ])->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'allocation_additional'); + + $this->assertDatabaseMissing('server_transfers', ['server_id' => $server->id]); + $this->assertDatabaseHas('allocations', ['id' => $additional->id, 'server_id' => null]); +}); + +test('transfer rejects malformed additional allocation identifiers with 422', function (bool|float|string|null $value): void { + $server = $this->createServerModel(); + $target = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + $primary = Allocation::factory()->for($target)->create(['server_id' => null]); + + $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), [ + 'node_id' => $target->id, + 'allocation_id' => $primary->id, + 'allocation_additional' => [$value], + ], options: JSON_PRESERVE_ZERO_FRACTION)->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'allocation_additional.0'); + + $this->assertDatabaseMissing('server_transfers', ['server_id' => $server->id]); +})->with(['boolean' => true, 'whole float' => 1.0, 'empty string' => '', 'null' => [null]]); + +test('null additional allocations do not bypass target node validation', function (): void { + $server = $this->createServerModel(); + $target = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + $wrongNodeAllocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => null]); + + $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), [ + 'node_id' => $target->id, + 'allocation_id' => $wrongNodeAllocation->id, + 'allocation_additional' => null, + ])->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'allocation_id'); + + $this->assertDatabaseMissing('server_transfers', ['server_id' => $server->id]); + $this->assertDatabaseHas('allocations', ['id' => $wrongNodeAllocation->id, 'server_id' => null]); +}); +test('server cannot be transferred to same node', function (): void { + $server = $this->createServerModel(); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => null]); + $response = $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), ['node_id' => $server->node_id, 'allocation_id' => $allocation->id]); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'node_id'); + $this->assertDatabaseMissing('server_transfers', ['server_id' => $server->id]); +}); +test('transfer rejects assigned allocation', function (): void { + $server = $this->createServerModel(); + /** @var Node $targetNode */ + $targetNode = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + /** @var Server $otherServer */ + $otherServer = $this->createServerModel(['node_id' => $targetNode->id]); + $response = $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), ['node_id' => $targetNode->id, 'allocation_id' => $otherServer->allocation_id]); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'allocation_id'); + $this->assertDatabaseMissing('server_transfers', ['server_id' => $server->id]); +}); +test('invalid payloads return validation errors', function (): void { + $server = $this->createServerModel(); + $response = $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + + $errors = collect($response->json('errors')); + expect($errors->firstWhere('meta.source_field', 'node_id'))->not->toBeNull(); + expect($errors->firstWhere('meta.source_field', 'allocation_id'))->not->toBeNull(); +}); +test('transfer missing server', function (): void { + $response = $this->postJson(route('api.admin.servers.transfer', ['server' => 'nil']), []); + $this->assertNotFoundJson($response); +}); +test('non admin forbidden', function (): void { + $server = $this->createServerModel(); + $this->actingAsNonAdmin(); + $response = $this->postJson(route('api.admin.servers.transfer', ['server' => $server->id]), []); + $this->assertAccessDeniedJson($response); +}); diff --git a/tests/Integration/Api/Admin/Settings/SettingsControllerTest.php b/tests/Integration/Api/Admin/Settings/SettingsControllerTest.php new file mode 100644 index 000000000..954ab617d --- /dev/null +++ b/tests/Integration/Api/Admin/Settings/SettingsControllerTest.php @@ -0,0 +1,95 @@ +getJson(route('api.admin.settings')); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['general' => ['app:name', 'pterodactyl:auth:2fa_required', 'app:locale'], 'mail' => ['mail:mailers:smtp:host', 'mail:mailers:smtp:port', 'mail:mailers:smtp:encryption', 'mail:mailers:smtp:username', 'mail:from:address', 'mail:from:name'], 'advanced' => ['recaptcha:enabled', 'recaptcha:secret_key', 'recaptcha:website_key', 'pterodactyl:guzzle:timeout', 'pterodactyl:guzzle:connect_timeout', 'pterodactyl:client_features:allocations:enabled'], 'meta' => ['load_environment_only', 'show_recaptcha_warning']]); + // The SMTP password must always be redacted to an empty string. + $response->assertJsonPath('mail.mail:mailers:smtp:password', ''); +}); +test('get languages', function () { + $response = $this->getJson(route('api.admin.languages')); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['en']); +}); +test('update general', function () { + $response = $this->putJson(route('api.admin.settings.general'), validGeneralPayload()); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('settings', ['key' => 'settings::app:name', 'value' => 'Test Panel']); + expect(Setting::fetch('settings::app:name'))->toBe('Test Panel'); + expect((string) Setting::fetch('settings::pterodactyl:auth:2fa_required'))->toBe('1'); + expect(Setting::fetch('settings::app:locale'))->toBe('en'); +}); +test('update mail', function () { + // Mail settings only update when SMTP is the selected driver, mirroring the legacy MailController guard. + config()->set('mail.default', 'smtp'); + $response = $this->putJson(route('api.admin.settings.mail'), validMailPayload()); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('settings', ['key' => 'settings::mail:mailers:smtp:host']); + $stored = Setting::fetch('settings::mail:mailers:smtp:password'); + expect($stored)->not->toBeNull(); + // The stored value must be encrypted, not the plaintext password. + $this->assertNotSame('super-secret', $stored); + expect($this->app->make(Encrypter::class)->decrypt($stored))->toBe('super-secret'); + // The plaintext password must not appear anywhere in the response body. + $this->assertStringNotContainsString('super-secret', $response->getContent()); +}); +test('mail test', function () { + Notification::fake(); + $response = $this->postJson(route('api.admin.settings.mail.test')); + $response->assertStatus(Response::HTTP_NO_CONTENT); + Notification::assertSentOnDemand(MailTested::class); +}); +test('update advanced', function () { + $response = $this->putJson(route('api.admin.settings.advanced'), validAdvancedPayload()); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('settings', ['key' => 'settings::recaptcha:secret_key', 'value' => 'secret-key']); + expect(Setting::fetch('settings::recaptcha:secret_key'))->toBe('secret-key'); + expect((string) Setting::fetch('settings::pterodactyl:client_features:allocations:range_start'))->toBe('5000'); +}); +test('invalid payloads return validation errors', function () { + $response = $this->putJson(route('api.admin.settings.general'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + $errors = collect($response->json('errors')); + $error = $errors->firstWhere('meta.source_field', 'branding.name'); + expect($error)->not->toBeNull('Expected a validation error for the [branding.name] field.'); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); +}); +test('non admin forbidden', function (string $method, string $routeName) { + $this->actingAsNonAdmin(); + $response = $this->{$method}(route($routeName)); + $this->assertAccessDeniedJson($response); +})->with('settingsEndpointsDataProvider'); +/** Return a valid payload for updating the general Panel settings. */ +function validGeneralPayload(): array +{ + return ['branding' => ['name' => 'Test Panel'], 'misc' => ['required_2fa' => 1], 'default_locale' => 'en']; +} +/** Return a valid payload for updating the SMTP mail settings (nested smtp shape). */ +function validMailPayload(): array +{ + return ['smtp' => ['host' => 'smtp.example.com', 'port' => 587, 'encryption' => 'tls', 'username' => 'smtp-user', 'password' => 'super-secret', 'from_address' => 'noreply@example.com', 'from_name' => 'Test Panel']]; +} +/** Return a valid payload for updating the advanced Panel settings. */ +function validAdvancedPayload(): array +{ + return ['recaptcha:enabled' => 'true', 'recaptcha:secret_key' => 'secret-key', 'recaptcha:website_key' => 'website-key', 'pterodactyl:guzzle:timeout' => 15, 'pterodactyl:guzzle:connect_timeout' => 5, 'pterodactyl:client_features:allocations:enabled' => 'true', 'pterodactyl:client_features:allocations:range_start' => 5000, 'pterodactyl:client_features:allocations:range_end' => 6000]; +} diff --git a/tests/Integration/Api/Admin/Tags/TagControllerTest.php b/tests/Integration/Api/Admin/Tags/TagControllerTest.php new file mode 100644 index 000000000..37ca7f1ea --- /dev/null +++ b/tests/Integration/Api/Admin/Tags/TagControllerTest.php @@ -0,0 +1,84 @@ +postJson(route('api.admin.tags.store'), ['name' => 'Premium', 'slug' => 'premium', 'color' => '#123456']); + $response->assertCreated()->assertJsonPath('attributes.slug', 'premium')->assertJsonPath('attributes.is_predefined', false); + $tag = Tag::query()->where('slug', 'premium')->firstOrFail(); + $this->putJson(route('api.admin.tags.update', ['tag' => $tag->id]), ['name' => 'Premium Capacity', 'slug' => 'premium-capacity', 'color' => '#654321'])->assertOk()->assertJsonPath('attributes.slug', 'premium-capacity'); + $this->getJson(route('api.admin.tags', ['filter' => ['slug' => 'premium-capacity']]))->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.id', $tag->id); + $this->delete(route('api.admin.tags.delete', ['tag' => $tag->id]))->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('tags', ['id' => $tag->id]); +}); +test('tag can be updated while keeping its own slug', function () { + $tag = Tag::factory()->create(['name' => 'Premium', 'slug' => 'premium', 'color' => '#123456']); + $this->putJson(route('api.admin.tags.update', ['tag' => $tag->id]), ['name' => 'Premium Capacity', 'slug' => 'premium', 'color' => '#654321'])->assertOk()->assertJsonPath('attributes.slug', 'premium')->assertJsonPath('attributes.name', 'Premium Capacity'); + $this->assertDatabaseHas('tags', ['id' => $tag->id, 'slug' => 'premium', 'name' => 'Premium Capacity']); +}); +test('tag cannot take another tags slug', function () { + Tag::factory()->create(['slug' => 'taken']); + $tag = Tag::factory()->create(['slug' => 'mine']); + $response = $this->putJson(route('api.admin.tags.update', ['tag' => $tag->id]), ['name' => 'Mine', 'slug' => 'taken']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'slug'); + $response->assertJsonPath('errors.0.meta.rule', 'unique'); + $this->assertDatabaseHas('tags', ['id' => $tag->id, 'slug' => 'mine']); +}); +test('single tag can be viewed', function () { + $tag = Tag::query()->create(['name' => 'Viewable', 'slug' => 'viewable', 'color' => '#abcdef']); + $this->getJson(route('api.admin.tags.view', ['tag' => $tag->id]))->assertOk()->assertJsonPath('object', 'tag')->assertJsonPath('attributes.id', $tag->id)->assertJsonPath('attributes.slug', 'viewable'); + $this->getJson(route('api.admin.tags.view', ['tag' => 999999]))->assertNotFound(); +}); +test('built in tags cannot be updated', function () { + /** @var Tag $tag */ + $tag = Tag::factory()->create(['name' => 'Minecraft', 'slug' => 'minecraft']); + $this->putJson(route('api.admin.tags.update', ['tag' => $tag->id]), ['name' => 'Changed', 'slug' => 'changed'])->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.code', 'DisplayException'); +}); +test('built in tags cannot be deleted', function () { + /** @var Tag $tag */ + $tag = Tag::factory()->create(['name' => 'Minecraft', 'slug' => 'minecraft']); + $this->delete(route('api.admin.tags.delete', ['tag' => $tag->id]))->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.code', 'DisplayException'); +}); +test('tags sync independently to eggs and node kinds', function () { + /** @var Tag $game */ + $game = Tag::factory()->create(['slug' => 'game-tag']); + /** @var Tag $reservation */ + $reservation = Tag::factory()->create(['slug' => 'reservation-tag']); + /** @var Egg $egg */ + $egg = Egg::factory()->create(); + /** @var Node $node */ + $node = Node::factory()->withLocation()->create(); + $this->putJson(route('api.admin.eggs.tags.sync', ['egg' => $egg->id]), ['tags' => [(string) $game->id]])->assertOk()->assertJsonPath('data.0.attributes.id', $game->id); + $this->putJson(route('api.admin.nodes.tags.sync', ['node' => $node->id]), ['tags' => [(string) $game->id]])->assertOk(); + $this->putJson(route('api.admin.nodes.deployment-tags.sync', ['node' => $node->id]), ['tags' => [(string) $reservation->id]])->assertOk(); + expect($egg->tags()->pluck('tags.id')->all())->toBe([$game->id]); + expect($node->eggTags()->pluck('tags.id')->all())->toBe([$game->id]); + expect($node->deploymentTags()->pluck('tags.id')->all())->toBe([$reservation->id]); +}); + +test('syncing existing tags resolves ids and slugs in a single read', function () { + $node = Node::factory()->withLocation()->create(); + $tags = Tag::factory()->count(10)->create(); + $values = $tags->map(fn (Tag $tag, int $index): string => $index % 2 === 0 ? (string) $tag->id : $tag->slug)->all(); + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $this->putJson(route('api.admin.nodes.tags.sync', ['node' => $node->id]), ['tags' => [...$values, $values[0]]])->assertOk(); + $reads = array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select') && str_contains($query['query'], 'from `tags`') && ! str_contains($query['query'], 'join')); + expect($reads)->toHaveCount(1); + } finally { + DB::disableQueryLog(); + } + expect($node->eggTags()->pluck('tags.id')->sort()->values()->all())->toBe($tags->pluck('id')->sort()->values()->all()); +}); diff --git a/tests/Integration/Api/Admin/Users/UserControllerTest.php b/tests/Integration/Api/Admin/Users/UserControllerTest.php new file mode 100644 index 000000000..fe57308ea --- /dev/null +++ b/tests/Integration/Api/Admin/Users/UserControllerTest.php @@ -0,0 +1,161 @@ + [['username'], ['email'], ['uuid']]); +dataset('userListSortsDataProvider', fn (): array => [['email'], ['-email'], ['username'], ['-username'], ['created_at'], ['-created_at']]); +/** Endpoints that should return a 403 error when accessed by a non-root-admin user. */ +dataset('userEndpointsDataProvider', fn (): array => [['getJson', 'api.admin.users'], ['getJson', 'api.admin.users.view'], ['getJson', 'api.admin.users.external'], ['postJson', 'api.admin.users.store'], ['postJson', 'api.admin.users.disable-2fa'], ['putJson', 'api.admin.users.update'], ['delete', 'api.admin.users.delete']]); +test('returns paginated users with relationship counts', function (): void { + $admin = $this->getAdminUser(); + $admin->forceFill(['username' => 'admin-list-contract-admin', 'email' => 'admin-list-contract-admin@example.test'])->save(); + $user = User::factory()->create(['username' => 'admin-list-contract-user', 'email' => 'admin-list-contract-user@example.test']); + $server = $this->createServerModel(['owner_id' => $user->id]); + Subuser::factory()->create(['user_id' => $user->id, 'server_id' => $server->id]); + $user = $user->fresh()->loadCount('servers'); + $user->setAttribute('subuser_of_count', 1); + + $response = $this->getJson(route('api.admin.users', ['filter' => ['search' => 'admin-list-contract'], 'per_page' => 60])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ADMIN_USER_ATTRIBUTES], ['object', 'attributes' => ADMIN_USER_ATTRIBUTES]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[], []], 'meta' => ['pagination' => ['total' => 2, 'count' => 2, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]]); + Assert::assertArraySubset(['object' => 'user', 'attributes' => ['id' => $admin->id, 'external_id' => $admin->external_id, 'uuid' => $admin->uuid, 'username' => $admin->username, 'email' => $admin->email, 'language' => $admin->language, 'first_name' => $admin->name_first, 'last_name' => $admin->name_last, 'root_admin' => (bool) $admin->root_admin, '2fa' => (bool) $admin->use_totp]], collect($response->json('data'))->firstWhere('attributes.id', $admin->id), true); + Assert::assertArraySubset(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'language' => $user->language, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp]], collect($response->json('data'))->firstWhere('attributes.id', $user->id), true); + $attributes = collect($response->json('data'))->firstWhere('attributes.id', $user->id)['attributes']; + expect($attributes['servers_count'])->toBe(1) + ->and($attributes['subuser_of_count'])->toBe(1); +}); +test('get users defaults to root admins first', function (): void { + $regularUser = User::factory()->create(['root_admin' => false]); + $rootAdmin = User::factory()->create(['root_admin' => true]); + $response = $this->getJson(route('api.admin.users', ['per_page' => 100])); + $response->assertStatus(Response::HTTP_OK); + + $emails = collect($response->json('data'))->pluck('attributes.email'); + expect($emails->search($rootAdmin->email))->toBeLessThan($emails->search($regularUser->email)); +}); +test('get users accepts data table sorts', function (string $sort): void { + User::factory()->create(['username' => 'datatable-sort-a', 'email' => 'datatable-sort-a@example.test']); + User::factory()->create(['username' => 'datatable-sort-z', 'email' => 'datatable-sort-z@example.test']); + $response = $this->getJson(route('api.admin.users', ['filter' => ['search' => 'datatable-sort'], 'sort' => $sort, 'per_page' => 100])); + $response->assertOk(); + $response->assertJsonCount(2, 'data'); +})->with('userListSortsDataProvider'); +test('get users searches identity fields', function (string $field): void { + $user = User::factory()->create(['username' => 'parity-search-user', 'email' => 'parity-search@example.com']); + User::factory()->create(['username' => 'unmatched-user', 'email' => 'unmatched@example.com']); + $term = match ($field) { + 'username' => 'parity-search-user', + 'email' => 'parity-search@example.com', + 'uuid' => mb_substr($user->uuid, 0, 8), + }; + $response = $this->getJson(route('api.admin.users', ['filter' => ['search' => $term], 'per_page' => 100])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.id', $user->id); +})->with('userSearchDataProvider'); +test('get single user', function (): void { + $user = User::factory()->create(); + $response = $this->getJson(route('api.admin.users.view', ['user' => $user->id])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ADMIN_USER_ATTRIBUTES]); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'language' => $user->language, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp]]); +}); +test('get missing user', function (): void { + $response = $this->getJson(route('api.admin.users.view', ['user' => 'nil'])); + $this->assertNotFoundJson($response); +}); +test('create user', function (): void { + $response = $this->postJson(route('api.admin.users.store'), ['username' => 'testuser', 'email' => 'test@example.com', 'name_first' => 'Test', 'name_last' => 'User']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonCount(3); + $response->assertJsonStructure(['object', 'attributes' => ADMIN_USER_ATTRIBUTES, 'meta' => ['resource']]); + $this->assertDatabaseHas('users', ['username' => 'testuser', 'email' => 'test@example.com']); + $user = User::query()->where('username', 'testuser')->first(); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'language' => $user->language, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp], 'meta' => ['resource' => route('api.admin.users.view', ['user' => $user->id])]], true); +}); +test('update user', function (): void { + $user = User::factory()->create(); + $response = $this->putJson(route('api.admin.users.update', ['user' => $user->id]), ['username' => 'new.test.name', 'email' => 'new@emailtest.com', 'name_first' => $user->name_first, 'name_last' => $user->name_last]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ADMIN_USER_ATTRIBUTES]); + $this->assertDatabaseHas('users', ['username' => 'new.test.name', 'email' => 'new@emailtest.com']); + $user = $user->fresh(); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'language' => $user->language, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp]]); +}); +test('get user by external id', function (): void { + $user = User::factory()->create(['external_id' => 'remote-123']); + $response = $this->getJson(route('api.admin.users.external', ['external_id' => 'remote-123'])); + $response->assertStatus(Response::HTTP_OK); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'language' => $user->language, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp]]); +}); +test('get user by missing external id', function (): void { + $response = $this->getJson(route('api.admin.users.external', ['external_id' => 'does-not-exist'])); + $this->assertNotFoundJson($response); +}); +test('disable two factor', function (): void { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => 'encrypted-secret']); + $response = $this->postJson(route('api.admin.users.disable-2fa', ['user' => $user->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('users', ['id' => $user->id, 'use_totp' => false, 'totp_secret' => null]); +}); +test('delete user', function (): void { + $user = User::factory()->create(); + $this->assertDatabaseHas('users', ['id' => $user->id]); + $response = $this->delete(route('api.admin.users.delete', ['user' => $user->id])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('users', ['id' => $user->id]); +}); +test('cannot delete self', function (): void { + $user = $this->getAdminUser(); + $response = $this->delete(route('api.admin.users.delete', ['user' => $user->id])); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'DisplayException'); + $this->assertDatabaseHas('users', ['id' => $user->id]); +}); +test('non admin forbidden', function (string $method, string $routeName): void { + $this->actingAsNonAdmin(); + $user = User::factory()->create(); + // Pass both id and external_id so external-lookup routes resolve too; the 403 fires before model binding. + $response = $this->{$method}(route($routeName, ['user' => $user->id, 'external_id' => 'forbidden'])); + $this->assertAccessDeniedJson($response); +})->with('userEndpointsDataProvider'); +test('passwords shorter than eight characters are rejected', function (string $method, string $route): void { + $user = User::factory()->create(); + $response = $this->{$method}(route($route, $route === 'api.admin.users.update' ? ['user' => $user->id] : []), ['username' => 'weakuser', 'email' => 'weak@example.com', 'name_first' => 'Weak', 'name_last' => 'Password', 'password' => 'abc']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.source_field', 'password')->assertJsonPath('errors.0.meta.rule', 'min'); + $this->assertDatabaseMissing('users', ['username' => 'weakuser']); +})->with([['postJson', 'api.admin.users.store'], ['putJson', 'api.admin.users.update']]); +test('a blank password leaves the password unchanged', function (): void { + $user = User::factory()->create(); + $hash = $user->password; + $this->putJson(route('api.admin.users.update', ['user' => $user->id]), ['username' => $user->username, 'email' => $user->email, 'name_first' => $user->name_first, 'name_last' => $user->name_last, 'password' => ''])->assertOk(); + expect($user->fresh()->password)->toBe($hash); +}); +test('invalid payloads return validation errors', function (): void { + $response = $this->postJson(route('api.admin.users.store'), []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonStructure(['errors' => [['code', 'detail', 'meta' => ['source_field', 'rule']]]]); + + $errors = collect($response->json('errors')); + foreach (['email', 'username', 'name_first', 'name_last'] as $field) { + $error = $errors->firstWhere('meta.source_field', $field); + expect($error)->not->toBeNull("Expected a validation error for the [{$field}] field."); + expect($error['meta']['rule'])->toBe('required'); + expect($error['detail'])->not->toBeEmpty(); + } +}); diff --git a/tests/Integration/Api/Admin/VersionControllerTest.php b/tests/Integration/Api/Admin/VersionControllerTest.php new file mode 100644 index 000000000..0b350e27a --- /dev/null +++ b/tests/Integration/Api/Admin/VersionControllerTest.php @@ -0,0 +1,34 @@ +app->instance(SoftwareVersionService::class, new FakeSoftwareVersionService( + panel: '1.0.0', + daemon: '1.0.0', + discord: 'https://pterodactyl.io/discord', + donations: 'https://github.com/sponsors/matthewpi', + isLatestPanel: true, + )); + $response = $this->getJson(route('api.admin.version')); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonStructure(['current', 'latest', 'is_latest', 'daemon', 'discord', 'donations']); + $response->assertJsonPath('current', config('app.version')); + $response->assertJsonPath('latest', '1.0.0'); + $response->assertJsonPath('is_latest', true); + $response->assertJsonPath('daemon', '1.0.0'); + $response->assertJsonPath('discord', 'https://pterodactyl.io/discord'); + $response->assertJsonPath('donations', 'https://github.com/sponsors/matthewpi'); +}); +test('non admin forbidden', function () { + $this->actingAsNonAdmin(); + $response = $this->getJson(route('api.admin.version')); + $this->assertAccessDeniedJson($response); +}); diff --git a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php index 73a4f8f51..5d77a91fa 100644 --- a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php +++ b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php @@ -1,18 +1,16 @@ withHeader('Accept', 'application/vnd.pterodactyl.v1+json') - ->withHeader('Authorization', 'Bearer ' . $this->key->identifier . decrypt($this->key->token)); + ->withHeader('Authorization', 'Bearer '.$this->key->identifier.decrypt($this->key->token)); } public function getApiUser(): User @@ -57,7 +55,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase { $this->key = $this->createApiKey($user, $permissions); - $this->withHeader('Authorization', 'Bearer ' . $this->key->identifier . decrypt($this->key->token)); + $this->withHeader('Authorization', 'Bearer '.$this->key->identifier.decrypt($this->key->token)); return $this->key; } @@ -85,28 +83,9 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase 'r_allocations' => AdminAcl::READ | AdminAcl::WRITE, 'r_users' => AdminAcl::READ | AdminAcl::WRITE, 'r_locations' => AdminAcl::READ | AdminAcl::WRITE, - 'r_nests' => AdminAcl::READ | AdminAcl::WRITE, 'r_eggs' => AdminAcl::READ | AdminAcl::WRITE, 'r_database_hosts' => AdminAcl::READ | AdminAcl::WRITE, 'r_server_databases' => AdminAcl::READ | AdminAcl::WRITE, ], $permissions)); } - - /** - * Return a transformer that can be used for testing purposes. - */ - protected function getTransformer(string $abstract): BaseTransformer - { - $request = Request::createFromGlobals(); - $request->setUserResolver(function () { - return $this->getApiKey()->user; - }); - - $transformer = $abstract::fromRequest($request); - - Assert::assertInstanceOf(BaseTransformer::class, $transformer); - Assert::assertNotInstanceOf(BaseClientTransformer::class, $transformer); - - return $transformer; - } } diff --git a/tests/Integration/Api/Application/Eggs/EggControllerTest.php b/tests/Integration/Api/Application/Eggs/EggControllerTest.php new file mode 100644 index 000000000..48d533c94 --- /dev/null +++ b/tests/Integration/Api/Application/Eggs/EggControllerTest.php @@ -0,0 +1,93 @@ +get(); + $response = $this->getJson('/api/application/eggs'); + $response->assertOk(); + $response->assertJsonCount($eggs->count(), 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'uuid', 'author', 'description', 'docker_image', 'startup', 'created_at', 'updated_at', 'script' => ['privileged', 'install', 'entry', 'container', 'extends'], 'config' => ['files', 'startup', 'stop', 'logs', 'extends']]]], 'meta' => ['pagination']]); + foreach ($eggs as $egg) { + $attributes = collect($response->json('data'))->firstWhere('attributes.id', $egg->id)['attributes']; + expect($attributes)->toMatchArray([ + 'id' => $egg->id, + 'uuid' => $egg->uuid, + 'name' => $egg->name, + 'author' => $egg->author, + 'description' => $egg->description, + 'docker_image' => array_values($egg->docker_images)[0], + 'docker_images' => $egg->docker_images, + 'startup' => $egg->startup, + 'created_at' => $egg->created_at->toAtomString(), + 'updated_at' => $egg->updated_at->toAtomString(), + ]); + expect($attributes['script'])->toBe([ + 'privileged' => $egg->script_is_privileged, + 'install' => $egg->script_install, + 'entry' => $egg->script_entry, + 'container' => $egg->script_container, + 'extends' => $egg->copy_script_from, + ]); + expect($attributes['config'])->toBe([ + 'files' => json_decode($egg->config_files ?? 'null', true) ?: [], + 'startup' => json_decode($egg->config_startup ?? 'null', true), + 'stop' => $egg->config_stop, + 'logs' => json_decode($egg->config_logs ?? 'null', true), + 'file_denylist' => $egg->file_denylist, + 'extends' => $egg->config_from, + ]); + } +}); +test('return single egg', function (): void { + $egg = Egg::query()->findOrFail(1); + $this->getJson('/api/application/eggs/'.$egg->id)->assertOk()->assertJson(['object' => 'egg', 'attributes' => ['id' => $egg->id, 'uuid' => $egg->uuid, 'name' => $egg->name, 'author' => $egg->author, 'description' => $egg->description, 'docker_images' => $egg->docker_images, 'startup' => $egg->startup]], true); +}); +test('return single egg with relationships', function (): void { + $egg = Egg::query()->findOrFail(1); + $server = $this->createServerModel(['egg_id' => $egg->id]); + $variable = EggVariable::factory()->create(['egg_id' => $egg->id]); + $response = $this->getJson('/api/application/eggs/'.$egg->id.'?include=servers,variables')->assertOk(); + expect($response->json('attributes.relationships.servers.data.*.attributes.id'))->toContain($server->id); + expect($response->json('attributes.relationships.variables.data.*.attributes.id'))->toContain($variable->id); +}); +test('return single egg with its tags', function (): void { + $egg = Egg::factory()->create(); + $tag = Tag::factory()->create(); + $egg->tags()->attach($tag); + $response = $this->getJson('/api/application/eggs/'.$egg->id.'?include=tags')->assertOk(); + expect($response->json('attributes.relationships.tags.data.*.attributes.slug'))->toBe([$tag->slug]); +}); +test('filter eggs by tag slug', function (): void { + [$first, $second] = Tag::factory()->count(2)->create(); + $firstEgg = Egg::factory()->create(); + $firstEgg->tags()->attach($first); + $secondEgg = Egg::factory()->create(); + $secondEgg->tags()->attach($second); + expect($this->getJson('/api/application/eggs?filter[tag]='.$first->slug)->assertOk()->json('data.*.attributes.id'))->toBe([$firstEgg->id]); + expect($this->getJson('/api/application/eggs?filter[tag]='.$first->slug.','.$second->slug.'&sort=id')->assertOk()->json('data.*.attributes.id'))->toBe([$firstEgg->id, $secondEgg->id]); + expect($this->getJson('/api/application/eggs?filter[tag]=no-such-tag')->assertOk()->json('data'))->toBe([]); +}); +test('retired nest include is ignored', function (): void { + $egg = Egg::factory()->create(); + $this->getJson('/api/application/eggs/'.$egg->id.'?include=nest')->assertOk()->assertJsonMissingPath('attributes.nest')->assertJsonMissingPath('attributes.relationships.nest'); +}); +test('missing egg returns not found', function (): void { + $this->assertNotFoundJson($this->getJson('/api/application/eggs/nil')); +}); +test('read permission is required', function (): void { + $this->createNewDefaultApiKey($this->getApiUser(), ['r_eggs' => 0]); + $this->assertAccessDeniedJson($this->getJson('/api/application/eggs')); +}); +test('nest endpoints do not exist', function (): void { + $this->getJson('/api/application/nests')->assertStatus(Response::HTTP_NOT_FOUND); +}); diff --git a/tests/Integration/Api/Application/Location/LocationControllerTest.php b/tests/Integration/Api/Application/Location/LocationControllerTest.php index ed75413ac..35bf8f956 100644 --- a/tests/Integration/Api/Application/Location/LocationControllerTest.php +++ b/tests/Integration/Api/Application/Location/LocationControllerTest.php @@ -1,268 +1,85 @@ times(2)->create(); - - $response = $this->getJson('/api/application/locations?per_page=60'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2, 'data'); - $response->assertJsonStructure([ - 'object', - 'data' => [ - ['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']], - ['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']], - ], - 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']], - ]); - - $response - ->assertJson([ - 'object' => 'list', - 'data' => [[], []], - 'meta' => [ - 'pagination' => [ - 'total' => 2, - 'count' => 2, - 'per_page' => 60, - 'current_page' => 1, - 'total_pages' => 1, - ], - ], - ]) - ->assertJsonFragment([ - 'object' => 'location', - 'attributes' => [ - 'id' => $locations[0]->id, - 'short' => $locations[0]->short, - 'long' => $locations[0]->long, - 'created_at' => $this->formatTimestamp($locations[0]->created_at), - 'updated_at' => $this->formatTimestamp($locations[0]->updated_at), - ], - ])->assertJsonFragment([ - 'object' => 'location', - 'attributes' => [ - 'id' => $locations[1]->id, - 'short' => $locations[1]->short, - 'long' => $locations[1]->long, - 'created_at' => $this->formatTimestamp($locations[1]->created_at), - 'updated_at' => $this->formatTimestamp($locations[1]->updated_at), - ], - ]); - } - - /** - * Test getting a single location on the API. - */ - public function testGetSingleLocation() - { - $location = Location::factory()->create(); - - $response = $this->getJson('/api/application/locations/' . $location->id); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2); - $response->assertJsonStructure(['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']]); - $response->assertJson([ - 'object' => 'location', - 'attributes' => [ - 'id' => $location->id, - 'short' => $location->short, - 'long' => $location->long, - 'created_at' => $this->formatTimestamp($location->created_at), - 'updated_at' => $this->formatTimestamp($location->updated_at), - ], - ], true); - } - - /** - * Test that a location can be created. - */ - public function testCreateLocation() - { - $response = $this->postJson('/api/application/locations', [ - 'short' => 'inhouse', - 'long' => 'This is my inhouse location', - ]); - - $response->assertStatus(Response::HTTP_CREATED); - $response->assertJsonCount(3); - $response->assertJsonStructure([ - 'object', - 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at'], - 'meta' => ['resource'], - ]); - - $this->assertDatabaseHas('locations', ['short' => 'inhouse', 'long' => 'This is my inhouse location']); - - $location = Location::where('short', 'inhouse')->first(); - $response->assertJson([ - 'object' => 'location', - 'attributes' => $this->getTransformer(LocationTransformer::class)->transform($location), - 'meta' => [ - 'resource' => route('api.application.locations.view', $location->id), - ], - ], true); - } - - /** - * Test that a location can be updated. - */ - public function testUpdateLocation() - { - $location = Location::factory()->create(); - - $response = $this->patchJson('/api/application/locations/' . $location->id, [ - 'short' => 'new inhouse', - 'long' => 'This is my new inhouse location', - ]); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2); - $response->assertJsonStructure([ - 'object', - 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at'], - ]); - - $this->assertDatabaseHas('locations', ['short' => 'new inhouse', 'long' => 'This is my new inhouse location']); - $location = $location->fresh(); - - $response->assertJson([ - 'object' => 'location', - 'attributes' => $this->getTransformer(LocationTransformer::class)->transform($location), - ]); - } - - /** - * Test that a location can be deleted from the database. - */ - public function testDeleteLocation() - { - $location = Location::factory()->create(); - $this->assertDatabaseHas('locations', ['id' => $location->id]); - - $response = $this->delete('/api/application/locations/' . $location->id); - $response->assertStatus(Response::HTTP_NO_CONTENT); - - $this->assertDatabaseMissing('locations', ['id' => $location->id]); - } - - /** - * Test that all the defined relationships for a location can be loaded successfully. - */ - public function testRelationshipsCanBeLoaded() - { - $location = Location::factory()->create(); - $server = $this->createServerModel(['user_id' => $this->getApiUser()->id, 'location_id' => $location->id]); - - $response = $this->getJson('/api/application/locations/' . $location->id . '?include=servers,nodes'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2)->assertJsonCount(2, 'attributes.relationships'); - $response->assertJsonStructure([ - 'attributes' => [ - 'relationships' => [ - 'nodes' => ['object', 'data' => [['attributes' => ['id']]]], - 'servers' => ['object', 'data' => [['attributes' => ['id']]]], - ], - ], - ]); - - // Just assert that we see the expected relationship IDs in the response. - $response->assertJson([ - 'attributes' => [ - 'relationships' => [ - 'nodes' => [ - 'object' => 'list', - 'data' => [ - [ - 'object' => 'node', - 'attributes' => $this->getTransformer(NodeTransformer::class)->transform($server->getRelation('node')), - ], - ], - ], - 'servers' => [ - 'object' => 'list', - 'data' => [ - [ - 'object' => 'server', - 'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server), - ], - ], - ], - ], - ], - ]); - } - - /** - * Test that a relationship that an API key does not have permission to access - * cannot be loaded onto the model. - */ - public function testKeyWithoutPermissionCannotLoadRelationship() - { - $this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]); - - $location = Location::factory()->create(); - Node::factory()->create(['location_id' => $location->id]); - - $response = $this->getJson('/api/application/locations/' . $location->id . '?include=nodes'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); - $response->assertJsonStructure([ - 'attributes' => [ - 'relationships' => [ - 'nodes' => ['object', 'attributes'], - ], - ], - ]); - - // Just assert that we see the expected relationship IDs in the response. - $response->assertJson([ - 'attributes' => [ - 'relationships' => [ - 'nodes' => [ - 'object' => 'null_resource', - 'attributes' => null, - ], - ], - ], - ]); - } - - /** - * Test that a missing location returns a 404 error. - * - * GET /api/application/locations/:id - */ - public function testGetMissingLocation() - { - $response = $this->getJson('/api/application/locations/nil'); - $this->assertNotFoundJson($response); - } - - /** - * Test that an authentication error occurs if a key does not have permission - * to access a resource. - */ - public function testErrorReturnedIfNoPermission() - { - $location = Location::factory()->create(); - $this->createNewDefaultApiKey($this->getApiUser(), ['r_locations' => 0]); - - $response = $this->getJson('/api/application/locations/' . $location->id); - $this->assertAccessDeniedJson($response); - } -} +uses(ApplicationApiIntegrationTestCase::class); +test('get locations', function (): void { + $locations = Location::factory()->times(2)->create(); + $response = $this->getJson('/api/application/locations?per_page=60'); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']], ['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[], []], 'meta' => ['pagination' => ['total' => 2, 'count' => 2, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]])->assertJsonFragment(['object' => 'location', 'attributes' => ['id' => $locations[0]->id, 'short' => $locations[0]->short, 'long' => $locations[0]->long, 'relationships' => [], 'created_at' => $this->formatTimestamp($locations[0]->created_at), 'updated_at' => $this->formatTimestamp($locations[0]->updated_at)]])->assertJsonFragment(['object' => 'location', 'attributes' => ['id' => $locations[1]->id, 'short' => $locations[1]->short, 'long' => $locations[1]->long, 'relationships' => [], 'created_at' => $this->formatTimestamp($locations[1]->created_at), 'updated_at' => $this->formatTimestamp($locations[1]->updated_at)]]); +}); +test('get single location', function (): void { + $location = Location::factory()->create(); + $response = $this->getJson('/api/application/locations/'.$location->id); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'location', 'attributes' => ['id' => $location->id, 'short' => $location->short, 'long' => $location->long, 'created_at' => $this->formatTimestamp($location->created_at), 'updated_at' => $this->formatTimestamp($location->updated_at)]], true); +}); +test('create location', function (): void { + $response = $this->postJson('/api/application/locations', ['short' => 'inhouse', 'long' => 'This is my inhouse location']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonCount(3); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $this->assertDatabaseHas('locations', ['short' => 'inhouse', 'long' => 'This is my inhouse location']); + $location = Location::query()->where('short', 'inhouse')->first(); + $response->assertJson(['object' => 'location', 'attributes' => ['id' => $location->id, 'short' => $location->short, 'long' => $location->long], 'meta' => ['resource' => route('api.application.locations.view', $location->id)]], true); +}); +test('update location', function (): void { + $location = Location::factory()->create(); + $response = $this->patchJson('/api/application/locations/'.$location->id, ['short' => 'new inhouse', 'long' => 'This is my new inhouse location']); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'short', 'long', 'created_at', 'updated_at']]); + $this->assertDatabaseHas('locations', ['short' => 'new inhouse', 'long' => 'This is my new inhouse location']); + $location = $location->fresh(); + $response->assertJson(['object' => 'location', 'attributes' => ['id' => $location->id, 'short' => $location->short, 'long' => $location->long]]); +}); +test('delete location', function (): void { + $location = Location::factory()->create(); + $this->assertDatabaseHas('locations', ['id' => $location->id]); + $response = $this->delete('/api/application/locations/'.$location->id); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('locations', ['id' => $location->id]); +}); +test('relationships can be loaded', function (): void { + $location = Location::factory()->create(); + $server = $this->createServerModel(['user_id' => $this->getApiUser()->id, 'location_id' => $location->id]); + $response = $this->getJson('/api/application/locations/'.$location->id.'?include=servers,nodes'); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2)->assertJsonCount(2, 'attributes.relationships'); + $response->assertJsonStructure(['attributes' => ['relationships' => ['nodes' => ['object', 'data' => [['attributes' => ['id']]]], 'servers' => ['object', 'data' => [['attributes' => ['id']]]]]]]); + // Just assert that we see the expected relationship IDs in the response. + $response->assertJson(['attributes' => ['relationships' => ['nodes' => ['object' => 'list', 'data' => [['object' => 'node', 'attributes' => ['id' => $server->node_id, 'location_id' => $location->id]]]], 'servers' => ['object' => 'list', 'data' => [['object' => 'server', 'attributes' => ['id' => $server->id, 'uuid' => $server->uuid, 'identifier' => $server->uuidShort, 'name' => $server->name, 'user' => $server->owner_id, 'node' => $server->node_id]]]]]]]); +}); +test('key without permission cannot load relationship', function (): void { + $this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]); + $location = Location::factory()->create(); + Node::factory()->create(['location_id' => $location->id]); + $response = $this->getJson('/api/application/locations/'.$location->id.'?include=nodes'); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); + $response->assertJsonStructure(['attributes' => ['relationships' => ['nodes' => ['object', 'attributes']]]]); + // Just assert that we see the expected relationship IDs in the response. + $response->assertJson(['attributes' => ['relationships' => ['nodes' => ['object' => 'null_resource', 'attributes' => null]]]]); +}); +test('get missing location', function (): void { + $response = $this->getJson('/api/application/locations/nil'); + $this->assertNotFoundJson($response); +}); +test('error returned if no permission', function (): void { + $location = Location::factory()->create(); + $this->createNewDefaultApiKey($this->getApiUser(), ['r_locations' => 0]); + $response = $this->getJson('/api/application/locations/'.$location->id); + $this->assertAccessDeniedJson($response); +}); diff --git a/tests/Integration/Api/Application/Nests/EggControllerTest.php b/tests/Integration/Api/Application/Nests/EggControllerTest.php deleted file mode 100644 index 07a527e0f..000000000 --- a/tests/Integration/Api/Application/Nests/EggControllerTest.php +++ /dev/null @@ -1,123 +0,0 @@ -where('nest_id', 1)->get(); - - $response = $this->getJson('/api/application/nests/' . $eggs->first()->nest_id . '/eggs'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(count($eggs), 'data'); - $response->assertJsonStructure([ - 'object', - 'data' => [ - [ - 'object', - 'attributes' => [ - 'id', 'uuid', 'nest', 'author', 'description', 'docker_image', 'startup', 'created_at', 'updated_at', - 'script' => ['privileged', 'install', 'entry', 'container', 'extends'], - 'config' => [ - 'files' => [], - 'startup' => ['done'], - 'stop', - 'logs' => [], - 'extends', - ], - ], - ], - ], - ]); - - foreach (array_get($response->json(), 'data') as $datum) { - $egg = $eggs->where('id', '=', $datum['attributes']['id'])->first(); - - $expected = json_encode(Arr::sortRecursive($datum['attributes'])); - $actual = json_encode(Arr::sortRecursive($this->getTransformer(EggTransformer::class)->transform($egg))); - - $this->assertSame( - $expected, - $actual, - 'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[$expected]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[$actual]." - ); - } - } - - /** - * Test that a single egg can be returned. - */ - public function testReturnSingleEgg() - { - $egg = Egg::query()->findOrFail(1); - - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/' . $egg->id); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonStructure([ - 'object', - 'attributes' => [ - 'id', 'uuid', 'nest', 'author', 'description', 'docker_image', 'startup', 'script' => [], 'config' => [], 'created_at', 'updated_at', - ], - ]); - - $response->assertJson([ - 'object' => 'egg', - 'attributes' => $this->getTransformer(EggTransformer::class)->transform($egg), - ], true); - } - - /** - * Test that a single egg and all the defined relationships can be returned. - */ - public function testReturnSingleEggWithRelationships() - { - $egg = Egg::query()->findOrFail(1); - - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/' . $egg->id . '?include=servers,variables,nest'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonStructure([ - 'object', - 'attributes' => [ - 'relationships' => [ - 'nest' => ['object', 'attributes'], - 'servers' => ['object', 'data' => []], - 'variables' => ['object', 'data' => []], - ], - ], - ]); - } - - /** - * Test that a missing egg returns a 404 error. - */ - public function testGetMissingEgg() - { - $egg = Egg::query()->findOrFail(1); - - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/nil'); - $this->assertNotFoundJson($response); - } - - /** - * Test that an authentication error occurs if a key does not have permission - * to access a resource. - */ - public function testErrorReturnedIfNoPermission() - { - $egg = Egg::query()->findOrFail(1); - $this->createNewDefaultApiKey($this->getApiUser(), ['r_eggs' => 0]); - - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs'); - $this->assertAccessDeniedJson($response); - } -} diff --git a/tests/Integration/Api/Application/Nests/NestControllerTest.php b/tests/Integration/Api/Application/Nests/NestControllerTest.php deleted file mode 100644 index 799fc18ac..000000000 --- a/tests/Integration/Api/Application/Nests/NestControllerTest.php +++ /dev/null @@ -1,127 +0,0 @@ -repository = $this->app->make(NestRepositoryInterface::class); - } - - /** - * Test that the expected nests are returned by the request. - */ - public function testNestResponse() - { - /** @var \Pterodactyl\Models\Nest[] $nests */ - $nests = $this->repository->all(); - - $response = $this->getJson('/api/application/nests'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(count($nests), 'data'); - $response->assertJsonStructure([ - 'object', - 'data' => [['object', 'attributes' => ['id', 'uuid', 'author', 'name', 'description', 'created_at', 'updated_at']]], - 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']], - ]); - - $response->assertJson([ - 'object' => 'list', - 'data' => [], - 'meta' => [ - 'pagination' => [ - 'total' => 4, - 'count' => 4, - 'per_page' => 50, - 'current_page' => 1, - 'total_pages' => 1, - ], - ], - ]); - - foreach ($nests as $nest) { - $response->assertJsonFragment([ - 'object' => 'nest', - 'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest), - ]); - } - } - - /** - * Test that getting a single nest returns the expected result. - */ - public function testSingleNestResponse() - { - $nest = $this->repository->find(1); - - $response = $this->getJson('/api/application/nests/' . $nest->id); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonStructure([ - 'object', - 'attributes' => ['id', 'uuid', 'author', 'name', 'description', 'created_at', 'updated_at'], - ]); - - $response->assertJson([ - 'object' => 'nest', - 'attributes' => $this->getTransformer(NestTransformer::class)->transform($nest), - ]); - } - - /** - * Test that including eggs in the response works as expected. - */ - public function testSingleNestWithEggsIncluded() - { - $nest = $this->repository->find(1); - $nest->loadMissing('eggs'); - - $response = $this->getJson('/api/application/nests/' . $nest->id . '?include=servers,eggs'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonStructure([ - 'object', - 'attributes' => [ - 'relationships' => [ - 'eggs' => ['object', 'data' => []], - 'servers' => ['object', 'data' => []], - ], - ], - ]); - - $response->assertJsonCount(count($nest->getRelation('eggs')), 'attributes.relationships.eggs.data'); - } - - /** - * Test that a missing nest returns a 404 error. - */ - public function testGetMissingNest() - { - $response = $this->getJson('/api/application/nests/nil'); - $this->assertNotFoundJson($response); - } - - /** - * Test that an authentication error occurs if a key does not have permission - * to access a resource. - */ - public function testErrorReturnedIfNoPermission() - { - $nest = $this->repository->find(1); - $this->createNewDefaultApiKey($this->getApiUser(), ['r_nests' => 0]); - - $response = $this->getJson('/api/application/nests/' . $nest->id); - $this->assertAccessDeniedJson($response); - } -} diff --git a/tests/Integration/Api/Application/Nodes/NodeController/UpdateNodeTest.php b/tests/Integration/Api/Application/Nodes/NodeController/UpdateNodeTest.php index 3d6c01ebe..5c23110bd 100644 --- a/tests/Integration/Api/Application/Nodes/NodeController/UpdateNodeTest.php +++ b/tests/Integration/Api/Application/Nodes/NodeController/UpdateNodeTest.php @@ -1,54 +1,23 @@ for(Location::factory())->create(); - $location = Location::factory()->create(); - - $this->mock(DaemonConfigurationRepository::class, function (MockInterface $mock) use ($node) { - $mock->expects('setNode')->with(\Mockery::on(fn ($value) => $value->is($node)))->andReturnSelf(); - $mock->expects('update')->withAnyArgs()->andReturn( - new Response() - ); - }); - - $this->patchJson(route('api.application.nodes.update', ['node' => $node]), [ - 'name' => 'New Name', - 'description' => 'New Description', - 'location_id' => $location->id, - 'fqdn' => 'new.example.com', - 'scheme' => 'https', - 'memory' => 100, - 'memory_overallocate' => 10, - 'disk' => 200, - 'disk_overallocate' => 20, - 'daemon_sftp' => 1101, - 'daemon_listen' => 1102, - ]) - ->assertOk() - ->assertJsonPath('object', 'node') - ->assertJsonPath('attributes.name', 'New Name') - ->assertJsonPath('attributes.description', 'New Description') - ->assertJsonPath('attributes.fqdn', 'new.example.com') - ->assertJsonPath('attributes.scheme', 'https') - ->assertJsonPath('attributes.memory', 100) - ->assertJsonPath('attributes.memory_overallocate', 10) - ->assertJsonPath('attributes.disk', 200) - ->assertJsonPath('attributes.disk_overallocate', 20) - ->assertJsonPath('attributes.daemon_sftp', 1101) - ->assertJsonPath('attributes.daemon_listen', 1102); - - $this->assertEquals($location->id, $node->refresh()->location_id); - } -} +uses(ApplicationApiIntegrationTestCase::class); +test('can update node properties', function () { + $node = Node::factory()->for(Location::factory())->create(); + $location = Location::factory()->create(); + $fake = new FakeDaemonConfiguration; + $this->patchJson(route('api.application.nodes.update', ['node' => $node]), ['name' => 'New Name', 'description' => 'New Description', 'location_id' => $location->id, 'fqdn' => 'new.example.com', 'scheme' => 'https', 'memory' => 100, 'memory_overallocate' => 10, 'disk' => 200, 'disk_overallocate' => 20, 'daemon_sftp' => 1101, 'daemon_listen' => 1102])->assertOk()->assertJsonPath('object', 'node')->assertJsonPath('attributes.name', 'New Name')->assertJsonPath('attributes.description', 'New Description')->assertJsonPath('attributes.fqdn', 'new.example.com')->assertJsonPath('attributes.scheme', 'https')->assertJsonPath('attributes.memory', 100)->assertJsonPath('attributes.memory_overallocate', 10)->assertJsonPath('attributes.disk', 200)->assertJsonPath('attributes.disk_overallocate', 20)->assertJsonPath('attributes.daemon_sftp', 1101)->assertJsonPath('attributes.daemon_listen', 1102); + expect($node->refresh()->location_id)->toEqual($location->id); + $fake->assertUpdated(); + Http::assertSent(fn (HttpRequest $request): bool => $request->hasHeader('Authorization', 'Bearer '.$node->getDecryptedKey())); +}); diff --git a/tests/Integration/Api/Application/Nodes/NodeControllerTest.php b/tests/Integration/Api/Application/Nodes/NodeControllerTest.php new file mode 100644 index 000000000..bffa17810 --- /dev/null +++ b/tests/Integration/Api/Application/Nodes/NodeControllerTest.php @@ -0,0 +1,33 @@ +for(Location::factory())->create(); + $server = $this->createServerModel(['node_id' => $node->id]); + $this->getJson('/api/application/nodes?filter[uuid]='.$node->uuid)->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.allocated_resources.memory', $server->memory)->assertJsonPath('data.0.attributes.allocated_resources.disk', $server->disk); +}); +test('node list query count does not scale with results', function () { + Node::factory()->for(Location::factory())->create(); + $this->getJson('/api/application/nodes')->assertOk(); + DB::flushQueryLog(); + DB::enableQueryLog(); + $this->getJson('/api/application/nodes')->assertOk(); + $oneNodeQueryCount = count(DB::getQueryLog()); + DB::disableQueryLog(); + Node::factory()->for(Location::factory())->create(); + DB::flushQueryLog(); + DB::enableQueryLog(); + $this->getJson('/api/application/nodes')->assertOk(); + $twoNodeQueryCount = count(DB::getQueryLog()); + DB::disableQueryLog(); + expect($twoNodeQueryCount)->toBe($oneNodeQueryCount); +}); diff --git a/tests/Integration/Api/Application/Nodes/NodeCrudTest.php b/tests/Integration/Api/Application/Nodes/NodeCrudTest.php new file mode 100644 index 000000000..8a37fbc79 --- /dev/null +++ b/tests/Integration/Api/Application/Nodes/NodeCrudTest.php @@ -0,0 +1,85 @@ + 'https://panel.example.com/']); + $node = Node::factory()->withLocation()->create(); + + $this->withServerVariables(['HTTP_HOST' => 'localhost:8123']) + ->getJson("/api/application/nodes/{$node->id}/configuration") + ->assertOk() + ->assertJsonPath('remote', 'https://panel.example.com'); +}); +test('node can be created', function () { + $location = Location::factory()->create(); + $response = $this->postJson('/api/application/nodes', ['name' => 'ApplicationNode', 'description' => 'Created through the application API.', 'location_id' => $location->id, 'public' => true, 'fqdn' => 'localhost', 'scheme' => 'https', 'behind_proxy' => false, 'maintenance_mode' => false, 'memory' => 2048, 'memory_overallocate' => 0, 'disk' => 20480, 'disk_overallocate' => 0, 'upload_size' => 100, 'daemon_listen' => 8080, 'daemon_sftp' => 2022, 'daemon_base' => '/var/lib/pterodactyl/volumes']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonPath('object', 'node'); + $response->assertJsonPath('attributes.name', 'ApplicationNode'); + $this->assertDatabaseHas('nodes', ['name' => 'ApplicationNode', 'fqdn' => 'localhost']); +}); +test('single node can be viewed', function () { + $node = Node::factory()->for(Location::factory())->create(); + $this->getJson("/api/application/nodes/{$node->id}")->assertOk()->assertJsonPath('object', 'node')->assertJsonPath('attributes.id', $node->id)->assertJsonPath('attributes.uuid', $node->uuid)->assertJsonPath('attributes.fqdn', $node->fqdn); +}); +test('node configuration is returned', function () { + $node = Node::factory()->for(Location::factory())->create(); + $this->getJson("/api/application/nodes/{$node->id}/configuration")->assertOk()->assertJsonPath('uuid', $node->uuid)->assertJsonStructure(['debug', 'uuid', 'token_id', 'token', 'api' => ['host', 'port', 'ssl' => ['enabled', 'cert', 'key'], 'upload_limit'], 'system' => ['data', 'sftp' => ['bind_port']], 'remote']); +}); +test('a key that can only read nodes cannot read node configuration', function (): void { + $this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => AdminAcl::READ]); + $node = Node::factory()->for(Location::factory())->create(); + $this->assertAccessDeniedJson($this->getJson("/api/application/nodes/{$node->id}/configuration")); + $this->getJson("/api/application/nodes/{$node->id}")->assertOk(); +}); +test('node without servers can be deleted', function () { + $node = Node::factory()->for(Location::factory())->create(); + $this->deleteJson("/api/application/nodes/{$node->id}")->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('nodes', ['id' => $node->id]); +}); +test('node with servers cannot be deleted', function () { + $server = $this->createServerModel(); + $this->deleteJson("/api/application/nodes/{$server->node_id}")->assertBadRequest(); + $this->assertDatabaseHas('nodes', ['id' => $server->node_id]); +}); +test('empty server id filter returns only unassigned allocations', function () { + $server = $this->createServerModel(); + $assigned = $server->allocation; + $free = Allocation::factory()->create(['node_id' => $server->node_id]); + $response = $this->getJson("/api/application/nodes/{$server->node_id}/allocations?filter[server_id]="); + $response->assertOk(); + $response->assertJsonCount(1, 'data'); + $response->assertJsonFragment(['id' => $free->id, 'assigned' => false]); + $response->assertJsonMissing(['id' => $assigned->id]); +}); +test('allocations can be created for a node', function () { + $node = Node::factory()->for(Location::factory())->create(); + $this->postJson("/api/application/nodes/{$node->id}/allocations", ['ip' => '10.0.0.10', 'ports' => ['25565', '25570-25572']])->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('allocations', ['node_id' => $node->id, 'ip' => '10.0.0.10', 'port' => 25565]); + foreach ([25570, 25571, 25572] as $port) { + $this->assertDatabaseHas('allocations', ['node_id' => $node->id, 'ip' => '10.0.0.10', 'port' => $port]); + } +}); +test('unassigned allocation can be deleted', function () { + $node = Node::factory()->for(Location::factory())->create(); + $allocation = Allocation::factory()->create(['node_id' => $node->id]); + $this->deleteJson("/api/application/nodes/{$node->id}/allocations/{$allocation->id}")->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('allocations', ['id' => $allocation->id]); +}); +test('assigned allocation cannot be deleted', function () { + $server = $this->createServerModel(); + $allocation = $server->allocation; + $this->deleteJson("/api/application/nodes/{$server->node_id}/allocations/{$allocation->id}")->assertBadRequest(); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id]); +}); diff --git a/tests/Integration/Api/Application/Nodes/NodeDeploymentControllerTest.php b/tests/Integration/Api/Application/Nodes/NodeDeploymentControllerTest.php new file mode 100644 index 000000000..bd500e52f --- /dev/null +++ b/tests/Integration/Api/Application/Nodes/NodeDeploymentControllerTest.php @@ -0,0 +1,20 @@ +for(Location::factory())->create(['public' => true, 'memory' => 1024, 'disk' => 10240]); + $this->getJson('/api/application/nodes/deployable?memory=0&disk=0&page=1')->assertOk()->assertJsonFragment(['id' => $node->id, 'allocated_resources' => ['memory' => 0, 'disk' => 0]]); +}); +test('allocated resources reflect assigned servers', function () { + $server = $this->createServerModel(); + $node = Node::query()->findOrFail($server->node_id); + $this->getJson("/api/application/nodes/deployable?memory=0&disk=0&page=1&location_ids[]={$node->location_id}")->assertOk()->assertJsonFragment(['id' => $node->id, 'allocated_resources' => ['memory' => $server->memory, 'disk' => $server->disk]]); +}); diff --git a/tests/Integration/Api/Application/PaginationValidationTest.php b/tests/Integration/Api/Application/PaginationValidationTest.php new file mode 100644 index 000000000..ae77083b8 --- /dev/null +++ b/tests/Integration/Api/Application/PaginationValidationTest.php @@ -0,0 +1,23 @@ + ['/api/application/users?per_page=invalid'], 'nodes' => ['/api/application/nodes?per_page=invalid'], 'locations' => ['/api/application/locations?per_page=invalid'], 'eggs' => ['/api/application/eggs?per_page=invalid'], 'servers' => ['/api/application/servers?per_page=invalid'], 'allocations' => ['/api/application/nodes/{node}/allocations?per_page=invalid'], 'deployable nodes' => ['/api/application/nodes/deployable?memory=0&disk=0&page=1&per_page=invalid']]; +}); +test('invalid page sizes return validation errors for every list endpoint', function (string $endpoint) { + if (str_contains($endpoint, '{node}')) { + $node = Node::factory()->for(Location::factory())->create(); + $endpoint = str_replace('{node}', (string) $node->id, $endpoint); + } + $this->getJson($endpoint)->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'per_page'); +})->with('listEndpointProvider'); +test('page size is capped', function () { + $this->getJson('/api/application/users?per_page=101')->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'per_page'); +}); diff --git a/tests/Integration/Api/Application/Servers/ServerControllerTest.php b/tests/Integration/Api/Application/Servers/ServerControllerTest.php new file mode 100644 index 000000000..b5f992a24 --- /dev/null +++ b/tests/Integration/Api/Application/Servers/ServerControllerTest.php @@ -0,0 +1,174 @@ +actingAs($this->getApiUser()); + $node = Node::factory()->for(Location::factory())->create(); + $allocation = Allocation::factory()->for($node)->create(); + $egg = Egg::query()->where('name', 'Bungeecord')->firstOrFail(); + $daemon = new FakeDaemonServer; + $payload = deploymentPayload($surface, $this->getApiUser()->id, $egg->id, [ + 'locations' => [(string) $node->location_id], + 'dedicated_ip' => $dedicatedIp, + 'port_range' => [], + ]); + + $response = $this->postJson('/api/'.$surface.'/servers', $payload)->assertCreated(); + + $this->assertDatabaseHas('servers', ['id' => $response->json('attributes.id'), 'node_id' => $node->id, 'allocation_id' => $allocation->id]); + $daemon->assertCreated(); +})->with(['admin', 'application'])->with([ + 'false' => false, + 'true' => true, + 'zero' => 0, + 'one' => 1, + 'string zero' => '0', + 'string one' => '1', +]); + +test('automatic deployments reject malformed constraints before creating a server', function (string $surface, string $field, mixed $value): void { + $this->actingAs($this->getApiUser()); + $egg = Egg::query()->where('name', 'Bungeecord')->firstOrFail(); + $deploy = ['locations' => [], 'dedicated_ip' => false, 'port_range' => []]; + $deploy[$field] = $value; + + $this->postJson('/api/'.$surface.'/servers', deploymentPayload($surface, $this->getApiUser()->id, $egg->id, $deploy)) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'deploy.'.$field); + + $this->assertDatabaseMissing('servers', ['name' => 'Deployed Server']); +})->with(['admin', 'application'])->with([ + 'invalid boolean' => ['dedicated_ip', 'not-a-boolean'], + 'associative locations' => ['locations', ['first' => 1]], + 'associative port ranges' => ['port_range', ['first' => '25565']], +]); + +test('automatic deployments reject malformed location identifiers with 422', function (string $surface, bool|float|string|null $value): void { + $this->actingAs($this->getApiUser()); + $egg = Egg::query()->where('name', 'Bungeecord')->firstOrFail(); + + $this->postJson('/api/'.$surface.'/servers', deploymentPayload($surface, $this->getApiUser()->id, $egg->id, ['locations' => [$value], 'dedicated_ip' => false, 'port_range' => []]), options: JSON_PRESERVE_ZERO_FRACTION) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'deploy.locations.0'); + + $this->assertDatabaseMissing('servers', ['name' => 'Deployed Server']); +})->with(['admin', 'application'])->with(['boolean' => true, 'whole float' => 1.0, 'empty string' => '', 'null' => [null]]); + +function deploymentPayload(string $surface, int $userId, int $eggId, array $deploy): array +{ + $limits = ['memory' => 512, 'swap' => 0, 'disk' => 1024, 'io' => 500, 'cpu' => 0, 'threads' => null]; + $payload = [ + 'name' => 'Deployed Server', + 'docker_image' => 'java:8', + 'startup' => 'java -jar server.jar', + 'environment' => ['BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server.jar'], + 'deploy' => $deploy, + ]; + + if ($surface === 'application') { + return [...$payload, 'user' => $userId, 'egg' => $eggId, 'limits' => $limits, 'feature_limits' => ['databases' => 0, 'allocations' => 0, 'backups' => 0]]; + } + + return [...$payload, ...$limits, 'owner_id' => $userId, 'egg_id' => $eggId, 'database_limit' => 0, 'allocation_limit' => 0, 'backup_limit' => 0]; +} + +test('search filters servers', function (): void { + $matching = $this->createServerModel(['name' => 'Audit Search Needle']); + $this->createServerModel(['name' => 'Audit Search Haystack']); + $this->getJson('/api/application/servers?search=Needle')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.id', $matching->id); +}); +test('transfer relationship can be included', function (): void { + $server = $this->createServerModel(); + $targetNode = Node::factory()->for(Location::factory())->create(); + $targetAllocation = Allocation::factory()->for($targetNode)->create(); + $transfer = ServerTransfer::factory()->create(['server_id' => $server->id, 'old_node' => $server->node_id, 'new_node' => $targetNode->id, 'old_allocation' => $server->allocation_id, 'new_allocation' => $targetAllocation->id]); + $this->getJson('/api/application/servers/'.$server->id.'?include=transfer')->assertOk()->assertJsonPath('attributes.relationships.transfer.object', 'server_transfer')->assertJsonPath('attributes.relationships.transfer.attributes.id', $transfer->id); +}); +test('missing transfer relationship is null', function (): void { + $server = $this->createServerModel(); + $this->getJson('/api/application/servers/'.$server->id.'?include=transfer')->assertOk()->assertJsonPath('attributes.relationships.transfer.object', 'null_resource')->assertJsonPath('attributes.relationships.transfer.attributes', null); +}); +test('retired nest include is ignored', function (): void { + $egg = Egg::factory()->create(); + $server = $this->createServerModel(['egg_id' => $egg->id]); + $this->getJson('/api/application/servers/'.$server->id.'?include=nest')->assertOk()->assertJsonMissingPath('attributes.nest')->assertJsonMissingPath('attributes.relationships.nest'); +}); +test('server list query count does not scale with results', function (): void { + $this->createServerModel(['name' => 'First Server']); + $this->getJson('/api/application/servers')->assertOk(); + DB::flushQueryLog(); + DB::enableQueryLog(); + $this->getJson('/api/application/servers')->assertOk(); + $oneServerQueryCount = count(DB::getQueryLog()); + DB::disableQueryLog(); + $this->createServerModel(['name' => 'Second Server']); + DB::flushQueryLog(); + DB::enableQueryLog(); + $this->getJson('/api/application/servers')->assertOk(); + $twoServerQueryCount = count(DB::getQueryLog()); + DB::disableQueryLog(); + expect($twoServerQueryCount)->toBe($oneServerQueryCount); +}); +test('server list uses per server environment overrides', function (): void { + $server = $this->createServerModel(); + $variable = $server->egg->variables()->firstOrFail(); + ServerVariable::query()->create(['server_id' => $server->id, 'variable_id' => $variable->id, 'variable_value' => 'application-api-override']); + $this->getJson('/api/application/servers?filter[uuid]='.$server->uuid)->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.container.environment.'.$variable->env_variable, 'application-api-override'); +}); + +test('server includes are batched across the collection', function (): void { + for ($i = 0; $i < 10; $i++) { + $this->createServerModel(); + } + + $request = fn (int $limit) => $this->getJson('/api/application/servers?include=user,node.location,allocations&per_page='.$limit); + $request(1)->assertOk(); + $counts = []; + foreach ([1, 10] as $limit) { + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $request($limit)->assertOk()->assertJsonCount($limit, 'data'); + $counts[] = count(array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select'))); + } finally { + DB::disableQueryLog(); + } + } + + expect($counts[1])->toBe($counts[0]); +}); + +test('batch loading keeps unauthorized includes hidden and raw relationships out of node attributes', function (): void { + $server = $this->createServerModel(); + $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0, 'r_server_databases' => 0]); + $response = $this->getJson('/api/application/servers?include=user,databases,node.servers')->assertOk(); + $response->assertJsonPath('data.0.attributes.relationships.user.object', 'null_resource'); + $response->assertJsonPath('data.0.attributes.relationships.databases.object', 'null_resource'); + $response->assertJsonMissingPath('data.0.attributes.relationships.node.attributes.servers'); + $response->assertJsonPath('data.0.attributes.relationships.node.attributes.relationships.servers.data.0.attributes.id', $server->id); +}); + +test('variable parent include preserves egg metadata without querying each variable', function (): void { + $server = $this->createServerModel(); + $variable = $server->egg->variables()->firstOrFail(); + ServerVariable::query()->create(['server_id' => $server->id, 'variable_id' => $variable->id, 'variable_value' => 'override']); + $response = $this->getJson('/api/application/servers/'.$server->id.'?include=variables.parent')->assertOk(); + $row = collect($response->json('attributes.relationships.variables.data'))->firstWhere('attributes.id', $variable->id); + expect($row['attributes']['server_value'])->toBe('override'); + expect($row['attributes']['relationships']['parent']['attributes']['env_variable'])->toBe($variable->env_variable); +}); diff --git a/tests/Integration/Api/Application/Servers/ServerManagementTest.php b/tests/Integration/Api/Application/Servers/ServerManagementTest.php new file mode 100644 index 000000000..a4f492cc3 --- /dev/null +++ b/tests/Integration/Api/Application/Servers/ServerManagementTest.php @@ -0,0 +1,152 @@ +createServerModel(['external_id' => 'ext-abc-123']); + $this->getJson('/api/application/servers/external/ext-abc-123')->assertOk()->assertJsonPath('object', 'server')->assertJsonPath('attributes.uuid', $server->uuid); + $this->getJson('/api/application/servers/external/does-not-exist')->assertNotFound(); +}); +test('server can be created', function (): void { + mockDaemon(); + // Reuse the fixture server's node/egg, then create a fresh unassigned + // allocation on that node for the new server to claim. + $fixture = $this->createServerModel(); + $allocation = Allocation::factory()->create(['node_id' => $fixture->node_id]); + $owner = User::factory()->create(); + $environment = $fixture->egg->variables->mapWithKeys(fn ($variable): array => [$variable->env_variable => $variable->default_value])->toArray(); + $response = $this->postJson('/api/application/servers', ['name' => 'Created Via API', 'user' => $owner->id, 'egg' => $fixture->egg_id, 'docker_image' => 'ghcr.io/pterodactyl/yolks:java_17', 'startup' => 'java -jar server.jar', 'environment' => $environment, 'skip_scripts' => true, 'limits' => ['memory' => 512, 'swap' => 0, 'disk' => 1024, 'io' => 500, 'cpu' => 100], 'feature_limits' => ['databases' => 0, 'allocations' => 1, 'backups' => 0], 'allocation' => ['default' => $allocation->id]]); + $response->assertStatus(Response::HTTP_CREATED)->assertJsonPath('object', 'server')->assertJsonPath('attributes.name', 'Created Via API')->assertJsonPath('attributes.user', $owner->id); + $this->assertDatabaseHas('servers', ['name' => 'Created Via API', 'owner_id' => $owner->id]); + expect($allocation->refresh()->server_id)->toBe($response->json('attributes.id')); +}); +test('server details can be updated', function (): void { + $revocation = new FakeDaemonRevocation; + $server = $this->createServerModel(); + $previousOwner = $server->user; + $owner = User::factory()->create(); + $this->patchJson("/api/application/servers/{$server->id}/details", ['name' => 'Renamed Via API', 'user' => $owner->id, 'external_id' => 'ext-renamed', 'description' => 'Updated description.'])->assertOk()->assertJsonPath('attributes.name', 'Renamed Via API')->assertJsonPath('attributes.user', $owner->id)->assertJsonPath('attributes.external_id', 'ext-renamed'); + $server->refresh(); + expect($server->name)->toBe('Renamed Via API'); + expect($server->owner_id)->toBe($owner->id); + $revocation->assertDeauthorized($previousOwner->uuid, [$server->uuid]); +}); +test('server build can be updated', function (): void { + mockDaemon(); + $server = $this->createServerModel(); + $this->patchJson("/api/application/servers/{$server->id}/build", ['allocation' => $server->allocation_id, 'limits' => ['memory' => 1024, 'swap' => 0, 'io' => 500, 'cpu' => 200, 'disk' => 5120], 'feature_limits' => ['databases' => 5, 'backups' => 2, 'allocations' => 1]])->assertOk()->assertJsonPath('attributes.limits.memory', 1024)->assertJsonPath('attributes.limits.cpu', 200)->assertJsonPath('attributes.feature_limits.databases', 5); + $server->refresh(); + expect($server->memory)->toBe(1024); + expect($server->database_limit)->toBe(5); +}); +test('server startup can be updated', function (): void { + mockDaemon(); + $server = $this->createServerModel(); + $environment = $server->egg->variables->mapWithKeys(fn ($variable): array => [$variable->env_variable => $variable->default_value])->toArray(); + $this->patchJson("/api/application/servers/{$server->id}/startup", ['startup' => 'java -jar updated.jar', 'environment' => $environment, 'egg' => $server->egg_id, 'image' => 'ghcr.io/pterodactyl/yolks:java_17', 'skip_scripts' => false])->assertOk()->assertJsonPath('attributes.container.startup_command', 'java -jar updated.jar')->assertJsonPath('attributes.container.image', 'ghcr.io/pterodactyl/yolks:java_17'); + expect($server->refresh()->startup)->toBe('java -jar updated.jar'); +}); +test('server can be suspended and unsuspended', function (): void { + mockDaemon(); + $server = $this->createServerModel(); + $this->postJson("/api/application/servers/{$server->id}/suspend")->assertStatus(Response::HTTP_NO_CONTENT); + expect($server->refresh()->isSuspended())->toBeTrue(); + $this->postJson("/api/application/servers/{$server->id}/unsuspend")->assertStatus(Response::HTTP_NO_CONTENT); + expect($server->refresh()->isSuspended())->toBeFalse(); +}); +test('server can be reinstalled', function (): void { + mockDaemon(); + $server = $this->createServerModel(); + $this->postJson("/api/application/servers/{$server->id}/reinstall")->assertStatus(Response::HTTP_NO_CONTENT); + expect($server->refresh()->status)->toBe(Server::STATUS_INSTALLING); +}); +test('a server that skips its install script cannot be reinstalled', function (): void { + $fake = new FakeDaemonServer; + $server = $this->createServerModel(['skip_scripts' => true]); + + $this->getJson("/api/application/servers/{$server->id}")->assertOk()->assertJsonPath('attributes.container.skip_scripts', true); + $this->postJson("/api/application/servers/{$server->id}/reinstall") + ->assertStatus(Response::HTTP_BAD_REQUEST) + ->assertJsonPath('errors.0.detail', trans('admin/server.exceptions.skipping_install_script')); + + expect($server->refresh()->status)->toBeNull() + ->and($fake->callsFor('reinstall'))->toBeEmpty(); +}); +test('a server that skips its install script can be reinstalled from an unfinished install', function (string $status): void { + $fake = new FakeDaemonServer; + $server = $this->createServerModel(['skip_scripts' => true, 'status' => $status]); + + $this->postJson("/api/application/servers/{$server->id}/reinstall")->assertStatus(Response::HTTP_NO_CONTENT); + + expect($server->refresh()->status)->toBe(Server::STATUS_INSTALLING); + $fake->assertReinstalled(); +})->with([Server::STATUS_INSTALLING, Server::STATUS_INSTALL_FAILED, Server::STATUS_REINSTALL_FAILED]); +test('server can be deleted', function (): void { + mockDaemon(); + $server = $this->createServerModel(); + $this->deleteJson("/api/application/servers/{$server->id}")->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); +}); +test('server can be force deleted', function (): void { + mockDaemon(); + $server = $this->createServerModel(); + $this->deleteJson("/api/application/servers/{$server->id}/force")->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); +}); +test('server databases can be listed and viewed', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->getJson("/api/application/servers/{$server->id}/databases")->assertOk()->assertJsonPath('object', 'list')->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.id', $database->id); + $this->getJson("/api/application/servers/{$server->id}/databases/{$database->id}")->assertOk()->assertJsonPath('object', 'server_database')->assertJsonPath('attributes.id', $database->id); +}); +test('server database can be created', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $this->postJson("/api/application/servers/{$server->id}/databases", ['database' => 'apidb', 'remote' => '%', 'host' => $host->id])->assertStatus(Response::HTTP_CREATED)->assertJsonPath('object', 'server_database')->assertJsonPath('attributes.database', "s{$server->id}_apidb"); + $database = Database::query()->where('server_id', $server->id)->firstOrFail(); + expect($database->database_host_id)->toBe($host->id); + $gateway->assertCreated("s{$server->id}_apidb"); + $gateway->assertFlushed(1); +}); +test('server database password can be reset', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $this->postJson("/api/application/servers/{$server->id}/databases/{$database->id}/reset-password")->assertStatus(Response::HTTP_NO_CONTENT); + $gateway->assertFlushed(1); + expect($gateway->count('createUser'))->toBe(1); +}); +test('server database can be deleted', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $this->deleteJson("/api/application/servers/{$server->id}/databases/{$database->id}")->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('databases', ['id' => $database->id]); + $gateway->assertDroppedDatabase($database->database); + $gateway->assertDroppedUser($database->username, $database->remote); + $gateway->assertFlushed(1); +}); +/** Fake the Wings server endpoints exercised by state-changing requests. */ +function mockDaemon(): void +{ + new FakeDaemonServer; +} diff --git a/tests/Integration/Api/Application/Tags/TagControllerTest.php b/tests/Integration/Api/Application/Tags/TagControllerTest.php new file mode 100644 index 000000000..dd544bd91 --- /dev/null +++ b/tests/Integration/Api/Application/Tags/TagControllerTest.php @@ -0,0 +1,75 @@ +count(2)->create(['legacy_nest_id' => null]); + $tags = Tag::query()->get(); + $response = $this->getJson('/api/application/tags')->assertOk(); + $response->assertJsonCount($tags->count(), 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'name', 'slug', 'color', 'is_predefined', 'legacy_nest_id', 'created_at', 'updated_at']]], 'meta' => ['pagination']]); + foreach ($customTags as $tag) { + $attributes = collect($response->json('data'))->firstWhere('attributes.id', $tag->id)['attributes']; + expect($attributes)->toBe([ + 'id' => $tag->id, + 'name' => $tag->name, + 'slug' => $tag->slug, + 'color' => $tag->color, + 'is_predefined' => false, + 'legacy_nest_id' => null, + 'relationships' => [], + 'created_at' => $tag->created_at->toAtomString(), + 'updated_at' => $tag->updated_at->toAtomString(), + ]); + } +}); +test('filter tags by slug', function (): void { + $tag = Tag::factory()->create(['slug' => 'filter-me']); + Tag::factory()->create(); + $response = $this->getJson('/api/application/tags?filter[slug]=filter-me')->assertOk(); + expect($response->json('data.*.attributes.id'))->toBe([$tag->id]); +}); +test('return single tag', function (): void { + $tag = Tag::factory()->create(['legacy_nest_id' => 42]); + $this->getJson('/api/application/tags/'.$tag->id)->assertOk()->assertJson(['object' => 'tag', 'attributes' => ['id' => $tag->id, 'name' => $tag->name, 'slug' => $tag->slug, 'color' => $tag->color, 'is_predefined' => false, 'legacy_nest_id' => 42, 'relationships' => [], 'created_at' => $tag->created_at->toAtomString(), 'updated_at' => $tag->updated_at->toAtomString()]], true); +}); +test('built in tag reports its built in name and color', function (): void { + $tag = Tag::factory()->predefined('minecraft')->create(['name' => 'Something Else']); + $this->getJson('/api/application/tags/'.$tag->id)->assertOk() + ->assertJsonPath('attributes.name', 'Minecraft') + ->assertJsonPath('attributes.is_predefined', true) + ->assertJsonPath('attributes.color', '#5B8731'); +}); +test('return single tag with relationships', function (): void { + $tag = Tag::factory()->create(); + $egg = Egg::factory()->create(); + $egg->tags()->attach($tag); + $node = Node::factory()->withLocation()->create(); + $node->eggTags()->attach($tag); + $response = $this->getJson('/api/application/tags/'.$tag->id.'?include=eggs,nodes')->assertOk(); + expect($response->json('attributes.relationships.eggs.data.*.attributes.id'))->toBe([$egg->id]); + expect($response->json('attributes.relationships.nodes.data.*.attributes.id'))->toBe([$node->id]); +}); +test('key without node permission cannot load nodes', function (): void { + $this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]); + $tag = Tag::factory()->create(); + Node::factory()->withLocation()->create()->eggTags()->attach($tag); + $this->getJson('/api/application/tags/'.$tag->id.'?include=nodes')->assertOk() + ->assertJson(['attributes' => ['relationships' => ['nodes' => ['object' => 'null_resource', 'attributes' => null]]]]); +}); +test('missing tag returns not found', function (): void { + $this->assertNotFoundJson($this->getJson('/api/application/tags/nil')); +}); +test('egg read permission is required', function (string $url): void { + $tag = Tag::factory()->create(); + $this->createNewDefaultApiKey($this->getApiUser(), ['r_eggs' => 0]); + $this->assertAccessDeniedJson($this->getJson(str_replace('{tag}', (string) $tag->id, $url))); +})->with(['/api/application/tags', '/api/application/tags/{tag}']); diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index fc37b7232..3dc8738bb 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -1,70 +1,30 @@ create(['external_id' => Str::random()]); - - $response = $this->getJson('/api/application/users/external/' . $user->external_id); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2); - $response->assertJsonStructure([ - 'object', - 'attributes' => [ - 'id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', - 'language', 'root_admin', '2fa', 'created_at', 'updated_at', - ], - ]); - - $response->assertJson([ - 'object' => 'user', - 'attributes' => [ - 'id' => $user->id, - 'external_id' => $user->external_id, - 'uuid' => $user->uuid, - 'username' => $user->username, - 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, - 'language' => $user->language, - 'root_admin' => (bool) $user->root_admin, - '2fa' => (bool) $user->totp_enabled, - 'created_at' => $this->formatTimestamp($user->created_at), - 'updated_at' => $this->formatTimestamp($user->updated_at), - ], - ], true); - } - - /** - * Test that an invalid external ID returns a 404 error. - */ - public function testGetMissingUser() - { - $response = $this->getJson('/api/application/users/external/nil'); - $this->assertNotFoundJson($response); - } - - /** - * Test that an authentication error occurs if a key does not have permission - * to access a resource. - */ - public function testErrorReturnedIfNoPermission() - { - $user = User::factory()->create(['external_id' => Str::random()]); - $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - - $response = $this->getJson('/api/application/users/external/' . $user->external_id); - $this->assertAccessDeniedJson($response); - } -} +uses(ApplicationApiIntegrationTestCase::class); +test('get remote user', function () { + $user = User::factory()->create(['external_id' => Str::random()]); + $response = $this->getJson('/api/application/users/external/'.$user->external_id); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, 'created_at' => $this->formatTimestamp($user->created_at), 'updated_at' => $this->formatTimestamp($user->updated_at)]], true); +}); +test('get missing user', function () { + $response = $this->getJson('/api/application/users/external/nil'); + $this->assertNotFoundJson($response); +}); +test('error returned if no permission', function () { + $user = User::factory()->create(['external_id' => Str::random()]); + $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); + $response = $this->getJson('/api/application/users/external/'.$user->external_id); + $this->assertAccessDeniedJson($response); +}); diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index a2512094b..4c8eb7fa3 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -1,309 +1,124 @@ [['postJson', '/api/application/users'], ['patchJson', '/api/application/users/{id}'], ['delete', '/api/application/users/{id}']]); +test('get users', function (): void { + $user = User::factory()->create(); + $response = $this->getJson('/api/application/users?per_page=60'); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2, 'data'); + $response->assertJsonStructure(['object', 'data' => [['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']], ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']]], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']]]); + $response->assertJson(['object' => 'list', 'data' => [[], []], 'meta' => ['pagination' => ['total' => 2, 'count' => 2, 'per_page' => 60, 'current_page' => 1, 'total_pages' => 1]]])->assertJsonFragment(['object' => 'user', 'attributes' => ['id' => $this->getApiUser()->id, 'external_id' => $this->getApiUser()->external_id, 'uuid' => $this->getApiUser()->uuid, 'username' => $this->getApiUser()->username, 'email' => $this->getApiUser()->email, 'first_name' => $this->getApiUser()->name_first, 'last_name' => $this->getApiUser()->name_last, 'language' => $this->getApiUser()->language, 'root_admin' => $this->getApiUser()->root_admin, '2fa' => (bool) $this->getApiUser()->totp_enabled, 'relationships' => [], 'created_at' => $this->formatTimestamp($this->getApiUser()->created_at), 'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at)]])->assertJsonFragment(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, 'relationships' => [], 'created_at' => $this->formatTimestamp($user->created_at), 'updated_at' => $this->formatTimestamp($user->updated_at)]]); +}); +test('get single user', function (): void { + $user = User::factory()->create(); + $response = $this->getJson('/api/application/users/'.$user->id); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']]); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'external_id' => $user->external_id, 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, 'created_at' => $this->formatTimestamp($user->created_at), 'updated_at' => $this->formatTimestamp($user->updated_at)]]); +}); +test('relationships can be loaded', function (): void { + $user = User::factory()->create(); + $server = $this->createServerModel(['user_id' => $user->id]); + $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at', 'relationships' => ['servers' => ['object', 'data' => [['object', 'attributes' => []]]]]]]); + $response->assertJsonCount(1, 'attributes.relationships.servers.data'); + $response->assertJson(['attributes' => ['relationships' => ['servers' => ['object' => 'list', 'data' => [['object' => 'server', 'attributes' => ['id' => $server->id, 'uuid' => $server->uuid, 'identifier' => $server->uuidShort, 'name' => $server->name, 'user' => $user->id, 'node' => $server->node_id]]]]]]]); +}); +test('key without permission cannot load relationship', function (): void { + $this->createNewDefaultApiKey($this->getApiUser(), ['r_servers' => 0]); + $user = User::factory()->create(); + $this->createServerModel(['user_id' => $user->id]); + $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); + $response->assertJsonStructure(['attributes' => ['relationships' => ['servers' => ['object', 'attributes']]]]); + // Just assert that we see the expected relationship IDs in the response. + $response->assertJson(['attributes' => ['relationships' => ['servers' => ['object' => 'null_resource', 'attributes' => null]]]]); +}); +test('get missing user', function (): void { + $response = $this->getJson('/api/application/users/nil'); + $this->assertNotFoundJson($response); +}); +test('error returned if no permission', function (): void { + $user = User::factory()->create(); + $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); + $response = $this->getJson('/api/application/users/'.$user->id); + $this->assertAccessDeniedJson($response); +}); +test('create user', function (): void { + $response = $this->postJson('/api/application/users', ['username' => 'testuser', 'email' => 'test@example.com', 'first_name' => 'Test', 'last_name' => 'User']); + $response->assertStatus(Response::HTTP_CREATED); + $response->assertJsonCount(3); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], 'meta' => ['resource']]); + $this->assertDatabaseHas('users', ['username' => 'testuser', 'email' => 'test@example.com']); + $user = User::query()->where('username', 'testuser')->first(); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'uuid' => $user->uuid, 'external_id' => $user->external_id, 'username' => $user->username, 'email' => $user->email, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp], 'meta' => ['resource' => route('api.application.users.view', $user->id)]], true); + + $log = $user->activity()->where('event', 'user:user.create')->sole(); + expect($log->actor_id)->toBe($this->getApiUser()->id) + ->and($log->properties->only(['email', 'username', 'admin'])->all())->toBe(['email' => 'test@example.com', 'username' => 'testuser', 'admin' => false]); +}); +test('update user', function (): void { + $user = User::factory()->create(); + $response = $this->patchJson('/api/application/users/'.$user->id, ['username' => 'new.test.name', 'email' => 'new@emailtest.com', 'first_name' => $user->name_first, 'last_name' => $user->name_last]); + $response->assertStatus(Response::HTTP_OK); + $response->assertJsonCount(2); + $response->assertJsonStructure(['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']]); + $this->assertDatabaseHas('users', ['username' => 'new.test.name', 'email' => 'new@emailtest.com']); + $user = $user->fresh(); + $response->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'uuid' => $user->uuid, 'external_id' => $user->external_id, 'username' => $user->username, 'email' => $user->email, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->use_totp]]); +}); +test('passwords shorter than eight characters are rejected', function (string $method, string $suffix): void { + $user = User::factory()->create(); + $url = '/api/application/users'.str_replace('{user}', (string) $user->id, $suffix); + $response = $this->{$method}($url, ['username' => 'weakuser', 'email' => 'weak@example.com', 'first_name' => 'Weak', 'last_name' => 'Password', 'password' => 'abc']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.source_field', 'password')->assertJsonPath('errors.0.meta.rule', 'min'); + $this->assertDatabaseMissing('users', ['username' => 'weakuser']); +})->with([['postJson', ''], ['patchJson', '/{user}']]); +test('a user can be created with an eight character password', function (): void { + $this->postJson('/api/application/users', ['username' => 'okuser', 'email' => 'ok@example.com', 'first_name' => 'Ok', 'last_name' => 'Password', 'password' => 'abcdefgh'])->assertCreated(); + expect(Hash::check('abcdefgh', User::query()->where('username', 'okuser')->firstOrFail()->password))->toBeTrue(); +}); +test('a user email must not start with a dash', function (string $method, string $suffix): void { + $user = User::factory()->create(); + $this->{$method}('/api/application/users'.str_replace('{user}', (string) $user->id, $suffix), ['username' => 'dashuser', 'email' => '-x@example.com', 'first_name' => 'Dash', 'last_name' => 'User']) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'email') + ->assertJsonPath('errors.0.meta.rule', 'p_user_email'); + $this->assertDatabaseMissing('users', ['email' => '-x@example.com']); +})->with([['postJson', ''], ['patchJson', '/{user}']]); +test('delete user', function (): void { + $user = User::factory()->create(); + $this->assertDatabaseHas('users', ['id' => $user->id]); + $response = $this->delete('/api/application/users/'.$user->id); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('users', ['id' => $user->id]); +}); +test('api key without write permissions', function (string $method, string $url): void { + $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]); + if (str_contains($url, '{id}')) { $user = User::factory()->create(); - - $response = $this->getJson('/api/application/users?per_page=60'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2, 'data'); - $response->assertJsonStructure([ - 'object', - 'data' => [ - ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']], - ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']], - ], - 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']], - ]); - - $response - ->assertJson([ - 'object' => 'list', - 'data' => [[], []], - 'meta' => [ - 'pagination' => [ - 'total' => 2, - 'count' => 2, - 'per_page' => 60, - 'current_page' => 1, - 'total_pages' => 1, - ], - ], - ]) - ->assertJsonFragment([ - 'object' => 'user', - 'attributes' => [ - 'id' => $this->getApiUser()->id, - 'external_id' => $this->getApiUser()->external_id, - 'uuid' => $this->getApiUser()->uuid, - 'username' => $this->getApiUser()->username, - 'email' => $this->getApiUser()->email, - 'first_name' => $this->getApiUser()->name_first, - 'last_name' => $this->getApiUser()->name_last, - 'language' => $this->getApiUser()->language, - 'root_admin' => $this->getApiUser()->root_admin, - '2fa' => (bool) $this->getApiUser()->totp_enabled, - 'created_at' => $this->formatTimestamp($this->getApiUser()->created_at), - 'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at), - ], - ]) - ->assertJsonFragment([ - 'object' => 'user', - 'attributes' => [ - 'id' => $user->id, - 'external_id' => $user->external_id, - 'uuid' => $user->uuid, - 'username' => $user->username, - 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, - 'language' => $user->language, - 'root_admin' => (bool) $user->root_admin, - '2fa' => (bool) $user->totp_enabled, - 'created_at' => $this->formatTimestamp($user->created_at), - 'updated_at' => $this->formatTimestamp($user->updated_at), - ], - ]); + $url = str_replace('{id}', (string) $user->id, $url); } - /** - * Test getting a single user. - */ - public function testGetSingleUser() - { - $user = User::factory()->create(); - - $response = $this->getJson('/api/application/users/' . $user->id); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2); - $response->assertJsonStructure([ - 'object', - 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], - ]); - - $response->assertJson([ - 'object' => 'user', - 'attributes' => [ - 'id' => $user->id, - 'external_id' => $user->external_id, - 'uuid' => $user->uuid, - 'username' => $user->username, - 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, - 'language' => $user->language, - 'root_admin' => (bool) $user->root_admin, - '2fa' => (bool) $user->totp_enabled, - 'created_at' => $this->formatTimestamp($user->created_at), - 'updated_at' => $this->formatTimestamp($user->updated_at), - ], - ]); - } - - /** - * Test that the correct relationships can be loaded. - */ - public function testRelationshipsCanBeLoaded() - { - $user = User::factory()->create(); - $server = $this->createServerModel(['user_id' => $user->id]); - - $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2); - $response->assertJsonStructure([ - 'object', - 'attributes' => [ - 'id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at', - 'relationships' => ['servers' => ['object', 'data' => [['object', 'attributes' => []]]]], - ], - ]); - - $response->assertJsonFragment([ - 'object' => 'list', - 'data' => [ - [ - 'object' => 'server', - 'attributes' => $this->getTransformer(ServerTransformer::class)->transform($server), - ], - ], - ]); - } - - /** - * Test that attempting to load a relationship that the key does not have permission - * for returns a null object. - */ - public function testKeyWithoutPermissionCannotLoadRelationship() - { - $this->createNewDefaultApiKey($this->getApiUser(), ['r_servers' => 0]); - - $user = User::factory()->create(); - $this->createServerModel(['user_id' => $user->id]); - - $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); - $response->assertJsonStructure([ - 'attributes' => [ - 'relationships' => [ - 'servers' => ['object', 'attributes'], - ], - ], - ]); - - // Just assert that we see the expected relationship IDs in the response. - $response->assertJson([ - 'attributes' => [ - 'relationships' => [ - 'servers' => [ - 'object' => 'null_resource', - 'attributes' => null, - ], - ], - ], - ]); - } - - /** - * Test that an invalid external ID returns a 404 error. - */ - public function testGetMissingUser() - { - $response = $this->getJson('/api/application/users/nil'); - $this->assertNotFoundJson($response); - } - - /** - * Test that an authentication error occurs if a key does not have permission - * to access a resource. - */ - public function testErrorReturnedIfNoPermission() - { - $user = User::factory()->create(); - $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - - $response = $this->getJson('/api/application/users/' . $user->id); - $this->assertAccessDeniedJson($response); - } - - /** - * Test that a user can be created. - */ - public function testCreateUser() - { - $response = $this->postJson('/api/application/users', [ - 'username' => 'testuser', - 'email' => 'test@example.com', - 'first_name' => 'Test', - 'last_name' => 'User', - ]); - - $response->assertStatus(Response::HTTP_CREATED); - $response->assertJsonCount(3); - $response->assertJsonStructure([ - 'object', - 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], - 'meta' => ['resource'], - ]); - - $this->assertDatabaseHas('users', ['username' => 'testuser', 'email' => 'test@example.com']); - - $user = User::where('username', 'testuser')->first(); - $response->assertJson([ - 'object' => 'user', - 'attributes' => $this->getTransformer(UserTransformer::class)->transform($user), - 'meta' => [ - 'resource' => route('api.application.users.view', $user->id), - ], - ], true); - } - - /** - * Test that a user can be updated. - */ - public function testUpdateUser() - { - $user = User::factory()->create(); - - $response = $this->patchJson('/api/application/users/' . $user->id, [ - 'username' => 'new.test.name', - 'email' => 'new@emailtest.com', - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, - ]); - $response->assertStatus(Response::HTTP_OK); - $response->assertJsonCount(2); - $response->assertJsonStructure([ - 'object', - 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], - ]); - - $this->assertDatabaseHas('users', ['username' => 'new.test.name', 'email' => 'new@emailtest.com']); - $user = $user->fresh(); - - $response->assertJson([ - 'object' => 'user', - 'attributes' => $this->getTransformer(UserTransformer::class)->transform($user), - ]); - } - - /** - * Test that a user can be deleted from the database. - */ - public function testDeleteUser() - { - $user = User::factory()->create(); - $this->assertDatabaseHas('users', ['id' => $user->id]); - - $response = $this->delete('/api/application/users/' . $user->id); - $response->assertStatus(Response::HTTP_NO_CONTENT); - - $this->assertDatabaseMissing('users', ['id' => $user->id]); - } - - /** - * Test that an API key without write permissions cannot create, update, or - * delete a user model. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('userWriteEndpointsDataProvider')] - public function testApiKeyWithoutWritePermissions(string $method, string $url) - { - $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]); - - if (str_contains($url, '{id}')) { - $user = User::factory()->create(); - $url = str_replace('{id}', $user->id, $url); - } - - $response = $this->$method($url); - $this->assertAccessDeniedJson($response); - } - - /** - * Endpoints that should return a 403 error when the key does not have write - * permissions for user management. - */ - public static function userWriteEndpointsDataProvider(): array - { - return [ - ['postJson', '/api/application/users'], - ['patchJson', '/api/application/users/{id}'], - ['delete', '/api/application/users/{id}'], - ]; - } -} + $response = $this->{$method}($url); + $this->assertAccessDeniedJson($response); +})->with('userWriteEndpointsDataProvider'); diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index a4a2d5207..09ccef526 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -1,228 +1,135 @@ create(); - - $response = $this->actingAs($user)->get('/api/client/account'); - - $response->assertOk()->assertJson([ - 'object' => 'user', - 'attributes' => [ - 'id' => $user->id, - 'admin' => false, - 'username' => $user->username, - 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, - 'language' => $user->language, - ], - ]); +uses(ClientApiIntegrationTestCase::class); +test('account details are returned', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + $response = $this->actingAs($user)->get('/api/client/account'); + $response->assertOk()->assertJson(['object' => 'user', 'attributes' => ['id' => $user->id, 'admin' => false, 'username' => $user->username, 'email' => $user->email, 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language]]); +}); +test('email is updated', function (): void { + $user = User::factory()->create(); + $this->actingAs($user)->putJson('/api/client/account/email', ['email' => $email = Str::random().'@example.com', 'password' => 'password'])->assertNoContent(); + $this->assertActivityFor('user:account.email-changed', $user, $user); + $this->assertDatabaseHas('users', ['id' => $user->id, 'email' => $email]); +}); +test('email change is throttled', function (): void { + $users = User::factory()->count(2)->create(); + $endpoint = route('api:client.account.update-email'); + for ($i = 0; $i < 3; $i++) { + $this->actingAs($users[0])->putJson($endpoint, ['email' => "foo+{$i}@example.com", 'password' => 'password'])->assertNoContent(); } - /** - * Test that the user's email address can be updated via the API. - */ - public function testEmailIsUpdated() - { - $user = User::factory()->create(); + $this->putJson($endpoint, ['email' => 'bar@example.com', 'password' => 'password'])->assertTooManyRequests(); + // The other user should still be able to update their email because the throttle + // is tied to the account, not to the IP address. + $this->actingAs($users[1])->putJson($endpoint, ['email' => 'bar+1@example.com', 'password' => 'password'])->assertNoContent(); +}); +test('email is not updated when password is invalid', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + $response = $this->actingAs($user)->putJson('/api/client/account/email', ['email' => 'hodor@example.com', 'password' => 'invalid']); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'InvalidPasswordProvidedException'); + $response->assertJsonPath('errors.0.detail', 'The password provided was invalid for this account.'); +}); +test('email is not updated when not valid', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + $response = $this->actingAs($user)->putJson('/api/client/account/email', ['email' => '', 'password' => 'password']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.rule', 'required'); + $response->assertJsonPath('errors.0.detail', 'The email field is required.'); + $response = $this->actingAs($user)->putJson('/api/client/account/email', ['email' => 'invalid', 'password' => 'password']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.rule', 'email'); + $response->assertJsonPath('errors.0.detail', 'The email must be a valid email address.'); +}); +test('email must be a strict address that does not start with a dash', function (string $email): void { + $user = User::factory()->create(); + $this->actingAs($user)->putJson('/api/client/account/email', ['email' => $email, 'password' => 'password']) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'email'); + $this->assertDatabaseMissing('users', ['id' => $user->id, 'email' => $email]); +})->with([ + 'dash prefix' => ['-x@example.com'], + 'local part over 64 characters' => [str_repeat('a', 65).'@example.com'], + 'domain label over 63 characters' => ['user@'.str_repeat('a', 64).'.com'], +]); +test('password is updated', function (): void { + $user = User::factory()->create(); + // Assign the user to two servers, one as the owner the other as a subuser, both + // on different nodes to ensure our logic fires off correctly and the user has their + // credentials revoked on both nodes. + $server = $this->createServerModel(['owner_id' => $user->id]); + $server2 = $this->createServerModel(); + Subuser::factory()->for($server2)->for($user)->create(); + $initialHash = $user->password; + Bus::fake([RevokeSftpAccessJob::class]); + $this->actingAs($user)->putJson('/api/client/account/password', ['current_password' => 'password', 'password' => 'New_Password1', 'password_confirmation' => 'New_Password1'])->assertNoContent(); + $user = $user->refresh(); + $this->assertNotEquals($user->password, $initialHash); + expect(Hash::check('New_Password1', $user->password))->toBeTrue(); + expect(Hash::check('password', $user->password))->toBeFalse(); + $this->assertActivityFor('user:account.password-changed', $user, $user); + $this->assertNotEquals($server->node_id, $server2->node_id); + Bus::assertDispatchedTimes(RevokeSftpAccessJob::class, 2); + Bus::assertDispatched(fn (RevokeSftpAccessJob $job): bool => $job->user === $user->uuid && $job->target->is($server->node)); + Bus::assertDispatched(fn (RevokeSftpAccessJob $job): bool => $job->user === $user->uuid && $job->target->is($server2->node)); +}); +test('password is not updated if current password is invalid', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + $response = $this->actingAs($user)->putJson('/api/client/account/password', ['current_password' => 'invalid', 'password' => 'New_Password1', 'password_confirmation' => 'New_Password1']); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'InvalidPasswordProvidedException'); + $response->assertJsonPath('errors.0.detail', 'The password provided was invalid for this account.'); +}); +test('error is returned for invalid request data', function (): void { + $user = User::factory()->create(); + $this->actingAs($user)->putJson('/api/client/account/password', ['current_password' => 'password'])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.rule', 'required'); + $this->actingAs($user)->putJson('/api/client/account/password', ['current_password' => 'password', 'password' => 'pass', 'password_confirmation' => 'pass'])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.rule', 'min'); +}); +test('error is returned if password is not confirmed', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + $response = $this->actingAs($user)->putJson('/api/client/account/password', ['current_password' => 'password', 'password' => 'New_Password1', 'password_confirmation' => 'Invalid_New_Password']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.rule', 'confirmed'); + $response->assertJsonPath('errors.0.detail', 'The password confirmation does not match.'); +}); - $this->actingAs($user) - ->putJson('/api/client/account/email', [ - 'email' => $email = Str::random() . '@example.com', - 'password' => 'password', - ]) - ->assertNoContent(); +test('malformed account credentials return 422 without changing the account', function (string $endpoint, string $field, array $credential): void { + $user = User::factory()->create(); + $originalPassword = $user->password; + $payload = $endpoint === 'email' + ? ['email' => 'changed@example.com'] + : ['password' => 'New_Password1', 'password_confirmation' => 'New_Password1']; - $this->assertActivityFor('user:account.email-changed', $user, $user); - $this->assertDatabaseHas('users', ['id' => $user->id, 'email' => $email]); - } + $this->actingAs($user)->putJson('/api/client/account/'.$endpoint, array_merge($payload, $credential)) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', $field); - public function testEmailChangeIsThrottled(): void - { - $users = User::factory()->count(2)->create(); - $endpoint = route('api:client.account.update-email'); - - for ($i = 0; $i < 3; ++$i) { - $this->actingAs($users[0]) - ->putJson($endpoint, ['email' => "foo+{$i}@example.com", 'password' => 'password']) - ->assertNoContent(); - } - - $this - ->putJson($endpoint, ['email' => 'bar@example.com', 'password' => 'password']) - ->assertTooManyRequests(); - - // The other user should still be able to update their email because the throttle - // is tied to the account, not to the IP address. - $this->actingAs($users[1]) - ->putJson($endpoint, ['email' => 'bar+1@example.com', 'password' => 'password']) - ->assertNoContent(); - } - - /** - * Tests that an email is not updated if the password provided in the request is not - * valid for the account. - */ - public function testEmailIsNotUpdatedWhenPasswordIsInvalid() - { - /** @var User $user */ - $user = User::factory()->create(); - - $response = $this->actingAs($user)->putJson('/api/client/account/email', [ - 'email' => 'hodor@example.com', - 'password' => 'invalid', - ]); - - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'InvalidPasswordProvidedException'); - $response->assertJsonPath('errors.0.detail', 'The password provided was invalid for this account.'); - } - - /** - * Tests that an email is not updated if an invalid email address is passed through - * in the request. - */ - public function testEmailIsNotUpdatedWhenNotValid() - { - /** @var User $user */ - $user = User::factory()->create(); - - $response = $this->actingAs($user)->putJson('/api/client/account/email', [ - 'email' => '', - 'password' => 'password', - ]); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.meta.rule', 'required'); - $response->assertJsonPath('errors.0.detail', 'The email field is required.'); - - $response = $this->actingAs($user)->putJson('/api/client/account/email', [ - 'email' => 'invalid', - 'password' => 'password', - ]); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.meta.rule', 'email'); - $response->assertJsonPath('errors.0.detail', 'The email must be a valid email address.'); - } - - /** - * Test that the password for an account can be successfully updated. - */ - public function testPasswordIsUpdated() - { - $user = User::factory()->create(); - - // Assign the user to two servers, one as the owner the other as a subuser, both - // on different nodes to ensure our logic fires off correctly and the user has their - // credentials revoked on both nodes. - $server = $this->createServerModel(['owner_id' => $user->id]); - $server2 = $this->createServerModel(); - Subuser::factory()->for($server2)->for($user)->create(); - - $initialHash = $user->password; - - Bus::fake([RevokeSftpAccessJob::class]); - - $this->actingAs($user) - ->putJson('/api/client/account/password', [ - 'current_password' => 'password', - 'password' => 'New_Password1', - 'password_confirmation' => 'New_Password1', - ]) - ->assertNoContent(); - - $user = $user->refresh(); - - $this->assertNotEquals($user->password, $initialHash); - $this->assertTrue(Hash::check('New_Password1', $user->password)); - $this->assertFalse(Hash::check('password', $user->password)); - - $this->assertActivityFor('user:account.password-changed', $user, $user); - $this->assertNotEquals($server->node_id, $server2->node_id); - - Bus::assertDispatchedTimes(RevokeSftpAccessJob::class, 2); - Bus::assertDispatched(fn (RevokeSftpAccessJob $job) => $job->user === $user->uuid && $job->target->is($server->node)); - Bus::assertDispatched(fn (RevokeSftpAccessJob $job) => $job->user === $user->uuid && $job->target->is($server2->node)); - } - - /** - * Test that the password for an account is not updated if the current password is not - * provided correctly. - */ - public function testPasswordIsNotUpdatedIfCurrentPasswordIsInvalid() - { - /** @var User $user */ - $user = User::factory()->create(); - - $response = $this->actingAs($user)->putJson('/api/client/account/password', [ - 'current_password' => 'invalid', - 'password' => 'New_Password1', - 'password_confirmation' => 'New_Password1', - ]); - - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'InvalidPasswordProvidedException'); - $response->assertJsonPath('errors.0.detail', 'The password provided was invalid for this account.'); - } - - /** - * Test that a validation error is returned to the user if no password is provided or if - * the password is below the minimum password length. - */ - public function testErrorIsReturnedForInvalidRequestData() - { - $user = User::factory()->create(); - - $this->actingAs($user)->putJson('/api/client/account/password', [ - 'current_password' => 'password', - ]) - ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.meta.rule', 'required'); - - $this->actingAs($user)->putJson('/api/client/account/password', [ - 'current_password' => 'password', - 'password' => 'pass', - 'password_confirmation' => 'pass', - ]) - ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.meta.rule', 'min'); - } - - /** - * Test that a validation error is returned if the password passed in the request - * does not have a confirmation, or the confirmation is not the same as the password. - */ - public function testErrorIsReturnedIfPasswordIsNotConfirmed() - { - /** @var User $user */ - $user = User::factory()->create(); - - $response = $this->actingAs($user)->putJson('/api/client/account/password', [ - 'current_password' => 'password', - 'password' => 'New_Password1', - 'password_confirmation' => 'Invalid_New_Password', - ]); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.meta.rule', 'confirmed'); - $response->assertJsonPath('errors.0.detail', 'The password confirmation does not match.'); - } -} + expect($user->fresh()->email)->toBe($user->email); + expect($user->fresh()->password)->toBe($originalPassword); +})->with([ + 'missing email credential' => ['email', 'password', []], + 'null email credential' => ['email', 'password', ['password' => null]], + 'array email credential' => ['email', 'password', ['password' => []]], + 'missing password credential' => ['password', 'current_password', []], + 'null password credential' => ['password', 'current_password', ['current_password' => null]], + 'array password credential' => ['password', 'current_password', ['current_password' => []]], +]); diff --git a/tests/Integration/Api/Client/ActivityLogControllerTest.php b/tests/Integration/Api/Client/ActivityLogControllerTest.php new file mode 100644 index 000000000..74d48f0f3 --- /dev/null +++ b/tests/Integration/Api/Client/ActivityLogControllerTest.php @@ -0,0 +1,208 @@ +create(); + Activity::event('user:account.email-changed')->actor($user)->subject($user)->log(); + // Activity for someone else must never be visible on this account. + Activity::event('user:account.email-changed')->actor($other = User::factory()->create())->subject($other)->log(); + $this->actingAs($user)->getJson('/api/client/account/activity')->assertOk()->assertJsonPath('object', 'list')->assertJsonCount(1, 'data')->assertJsonPath('data.0.object', 'activity_log')->assertJsonPath('data.0.attributes.event', 'user:account.email-changed'); +}); +test('account activity includes the logged properties', function () { + /** @var User $user */ + $user = User::factory()->create(); + Activity::event('user:account.email-changed')->actor($user)->subject($user) + ->property('old', 'old@example.com') + ->property(['new' => 'new@example.com']) + ->log(); + + $this->actingAs($user)->getJson('/api/client/account/activity')->assertOk() + ->assertJsonPath('data.0.attributes.properties.old', 'old@example.com') + ->assertJsonPath('data.0.attributes.properties.new', 'new@example.com'); +}); +test('account activity can be filtered by event', function () { + /** @var User $user */ + $user = User::factory()->create(); + Activity::event('user:account.email-changed')->actor($user)->subject($user)->log(); + Activity::event('user:account.password-changed')->actor($user)->subject($user)->log(); + $this->actingAs($user)->getJson('/api/client/account/activity?filter[event]=password-changed')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.event', 'user:account.password-changed'); +}); +test('account activity requires authentication', function () { + $this->getJson('/api/client/account/activity')->assertUnauthorized(); +}); +test('server activity is returned', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + Activity::event('server:power.start')->actor($user)->subject($server)->log(); + // Activity on another server must not leak into this listing. + Activity::event('server:power.start')->actor($user)->subject($this->createServerModel())->log(); + $this->actingAs($user)->getJson($this->link($server, '/activity'))->assertOk()->assertJsonPath('object', 'list')->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.event', 'server:power.start'); +}); +test('server activity requires permission', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $this->getJson($this->link($server, '/activity'))->assertUnauthorized(); + $this->actingAs($user)->getJson($this->link($server, '/activity'))->assertForbidden(); +}); +test('the reserved ip property is hidden from other viewers while other addresses are not', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $other = User::factory()->create(); + Activity::event('server:power.start') + ->actor($other) + ->subject($server) + ->property(['ip' => '198.51.100.7', 'address' => '10.0.0.1']) + ->log(); + + $properties = $this->actingAs($user)->getJson($this->link($server, '/activity'))->assertOk()->json('data.0.attributes.properties'); + + expect($properties['ip'])->toBe('[hidden]'); + expect($properties['address'])->toBe('10.0.0.1'); +}); +test('a failed log in reveals the attempt address to the account it targeted', function () { + $user = User::factory()->create(['root_admin' => false]); + Activity::event('auth:fail')->anonymous()->subject($user)->withRequestMetadata()->log(); + + $row = $this->actingAs($user)->getJson('/api/client/account/activity')->assertOk()->json('data.0.attributes'); + + expect($row['event'])->toBe('auth:fail'); + expect($row['ip'])->toBe('127.0.0.1'); + expect($row['properties']['ip'])->toBe('127.0.0.1'); +}); +test('an entry with an actor never reveals that actor address to its subject', function () { + $owner = User::factory()->create(['root_admin' => false]); + $subuser = User::factory()->create(['root_admin' => false]); + Activity::event('server:subuser.create')->actor($owner)->subject($subuser)->withRequestMetadata()->log(); + + $row = $this->actingAs($subuser)->getJson('/api/client/account/activity')->assertOk()->json('data.0.attributes'); + + expect($row['event'])->toBe('server:subuser.create'); + expect($row['ip'])->toBeNull(); + expect($row['properties']['ip'])->toBe('[hidden]'); +}); +test('an administrator sees the same address in both fields', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $user->update(['root_admin' => true]); + Activity::event('server:power.start')->actor(User::factory()->create())->subject($server)->withRequestMetadata()->log(); + + $row = $this->actingAs($user)->getJson($this->link($server, '/activity'))->assertOk()->json('data.0.attributes'); + + expect($row['ip'])->toBe('127.0.0.1'); + expect($row['properties']['ip'])->toBe('127.0.0.1'); +}); +test('entries are identified by the log id rather than the subject pivot id', function () { + $user = User::factory()->create(['root_admin' => false]); + $log = Activity::event('user:account.password-changed')->actor($user)->subject($user)->log(); + + $row = $this->actingAs($user)->getJson('/api/client/account/activity')->assertOk()->json('data.0.attributes'); + + expect($row['id'])->toBe(sha1((string) $log->id)); + expect(ActivityLog::query()->whereKey($log->id)->exists())->toBeTrue(); +}); +test('account activity can be filtered by the user that performed it', function () { + /** @var User $user */ + $user = User::factory()->create(); + $admin = User::factory()->create(['username' => 'an-admin']); + Activity::event('user:account.password-changed')->actor($user)->subject($user)->log(); + Activity::event('user:account.email-changed')->actor($admin)->subject($user)->log(); + + $events = collect($this->actingAs($user)->getJson('/api/client/account/activity?filter[user]=an-admin')->assertOk()->json('data'))->pluck('attributes.event'); + + expect($events->all())->toBe(['user:account.email-changed']); +}); +test('server activity can be filtered by the user that performed it', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $other = User::factory()->create(['username' => 'other-actor']); + Activity::event('server:power.start')->actor($user)->subject($server)->log(); + Activity::event('server:power.stop')->actor($other)->subject($server)->log(); + + $events = collect($this->actingAs($user)->getJson($this->link($server, '/activity?filter[user]=other-actor'))->assertOk()->json('data'))->pluck('attributes.event'); + + expect($events->all())->toBe(['server:power.stop']); +}); +test('account filter options are scoped to that account', function () { + /** @var User $user */ + $user = User::factory()->create(); + $admin = User::factory()->create(['username' => 'an-admin']); + $stranger = User::factory()->create(['username' => 'stranger']); + Activity::event('user:account.password-changed')->actor($user)->subject($user)->log(); + Activity::event('user:account.email-changed')->actor($admin)->subject($user)->log(); + Activity::event('user:api-key.create')->actor($stranger)->subject($stranger)->log(); + + $data = $this->actingAs($user)->getJson('/api/client/account/activity/filters')->assertOk()->json('data'); + + expect($data['events'])->toBe(['user:account.email-changed', 'user:account.password-changed']); + expect(collect($data['users'])->pluck('username')->all())->toContain('an-admin'); + expect(collect($data['users'])->pluck('username')->all())->not->toContain('stranger'); +}); +test('server filter options are scoped to that server and need permission', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $other = User::factory()->create(['username' => 'other-actor']); + Activity::event('server:power.start')->actor($user)->subject($server)->log(); + Activity::event('server:power.stop')->actor($other)->subject($server)->log(); + Activity::event('server:power.kill')->actor($other)->subject($this->createServerModel())->log(); + + $data = $this->actingAs($user)->getJson($this->link($server, '/activity/filters'))->assertOk()->json('data'); + + expect($data['events'])->toBe(['server:power.start', 'server:power.stop']); + expect(collect($data['users'])->pluck('username')->all())->toContain('other-actor'); + + [$denied, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $this->actingAs($denied)->getJson($this->link($server, '/activity/filters'))->assertForbidden(); +}); +test('filtering by user id is exact on the client feeds', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $other = User::factory()->create(['username' => 'other-actor']); + Activity::event('server:power.start')->actor($user)->subject($server)->log(); + Activity::event('server:power.stop')->actor($other)->subject($server)->log(); + + $events = collect($this->actingAs($user)->getJson($this->link($server, '/activity?filter[user_id]='.$other->id))->assertOk()->json('data'))->pluck('attributes.event'); + + expect($events->all())->toBe(['server:power.stop']); +}); +test('an entry is only flagged as api when it points at a real key', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $log = Activity::event('server:power.start')->actor($user)->subject($server)->log(); + $log->forceFill(['api_key_id' => 0])->save(); + + $row = $this->actingAs($user)->getJson($this->link($server, '/activity'))->assertOk()->json('data.0.attributes'); + + expect($row['is_api'])->toBeFalse(); +}); + +test('malformed activity user filters return 422 on the client feeds', function (string $feed) { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $endpoint = $feed === 'account' ? '/api/client/account/activity' : $this->link($server, '/activity'); + + $this->actingAs($user)->getJson($endpoint.'?'.http_build_query(['filter' => ['user' => ['nested' => 'value']]])) + ->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'filter.user'); +})->with(['account', 'server']); + +test('server filter options respect hidden administrator activity', function () { + config()->set('activity.hide_admin_activity', true); + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + $admin = User::factory()->create(['root_admin' => true]); + Activity::event('server:power.start')->actor($user)->subject($server)->log(); + Activity::event('server:power.kill')->actor($admin)->subject($server)->log(); + + $response = $this->actingAs($user)->getJson($this->link($server, '/activity/filters'))->assertOk(); + + $response->assertJsonPath('data.events', ['server:power.start']); + $response->assertJsonCount(1, 'data.users'); + $response->assertJsonPath('data.users.0.id', $user->id); +}); + +test('disabled events and their actors are excluded from server filter options', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ActivityRead->value]); + Activity::event(ActivityLog::DISABLED_EVENTS[0])->actor($user)->subject($server)->log(); + + $this->actingAs($user)->getJson($this->link($server, '/activity/filters'))->assertOk() + ->assertJsonPath('data.events', [])->assertJsonPath('data.users', []); +}); diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 6017a72b2..b761b3349 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -1,254 +1,131 @@ forceDelete(); - - parent::tearDown(); +uses(ClientApiIntegrationTestCase::class); +/** + * Cleanup after tests. + */ +afterEach(function (): void { + ApiKey::query()->forceDelete(); +}); +/** + * Provides some different IP address combinations that can be used when + * testing that we accept the expected IP values. + */ +dataset('validIPAddressDataProvider', fn (): array => [[[]], [['127.0.0.1']], [['127.0.0.1', '::1']], [['::ffff:7f00:1']], [['127.0.0.1', '192.168.1.100', '192.168.10.10/28']], [['127.0.0.1/32', '192.168.100.100/27', '::1', '::1/128']]]); +test('api keys are returned', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + /** @var ApiKey $key */ + $key = ApiKey::factory()->for($user)->create(['key_type' => ApiKey::TYPE_ACCOUNT]); + $response = $this->actingAs($user)->get('/api/client/account/api-keys')->assertOk()->assertJsonPath('object', 'list')->assertJsonPath('data.0.object', ApiKey::RESOURCE_NAME); + expect($response->json('data.0.attributes'))->toBe([ + 'identifier' => $key->identifier, + 'description' => $key->memo, + 'allowed_ips' => null, + 'last_used_at' => null, + 'created_at' => $key->created_at->toAtomString(), + ]); + $response->assertJsonMissingPath('data.0.attributes.token'); + $response->assertJsonMissingPath('data.0.attributes.secret_token'); +}); +test('api key can be created for account', function (array $data): void { + /** @var User $user */ + $user = User::factory()->create(); + // Small subtest to ensure we're always comparing the number of keys to the + // specific logged in account, and not just the total number of keys stored in + // the database. + ApiKey::factory()->times(10)->create(['user_id' => User::factory()->create()->id, 'key_type' => ApiKey::TYPE_ACCOUNT]); + $response = $this->actingAs($user)->postJson('/api/client/account/api-keys', ['description' => 'Test Description', 'allowed_ips' => $data])->assertOk()->assertJsonPath('object', ApiKey::RESOURCE_NAME); + /** @var ApiKey $key */ + $key = ApiKey::query()->where('identifier', $response->json('attributes.identifier'))->firstOrFail(); + expect($response->json('attributes'))->toBe([ + 'identifier' => $key->identifier, + 'description' => 'Test Description', + 'allowed_ips' => $data, + 'last_used_at' => null, + 'created_at' => $key->created_at->toAtomString(), + ]); + $response->assertJsonMissingPath('attributes.token'); + $this->assertDatabaseHas('api_keys', ['id' => $key->id, 'memo' => 'Test Description', 'user_id' => $user->id]); + $response->assertJsonPath('meta.secret_token', decrypt($key->token)); + $this->assertActivityFor('user:api-key.create', $user, [$key, $user]); +})->with('validIPAddressDataProvider'); +test('api key cannot specify more than fifty ips', function (): void { + $ips = []; + for ($i = 0; $i < 100; $i++) { + $ips[] = '127.0.0.'.$i; } - /** - * Test that the client's API key can be returned successfully. - */ - public function testApiKeysAreReturned() - { - /** @var User $user */ - $user = User::factory()->create(); - /** @var ApiKey $key */ - $key = ApiKey::factory()->for($user)->create([ - 'key_type' => ApiKey::TYPE_ACCOUNT, - ]); + $this->actingAs(User::factory()->create())->postJson('/api/client/account/api-keys', ['description' => 'Test Data', 'allowed_ips' => $ips])->assertUnprocessable()->assertJsonPath('errors.0.detail', 'The allowed ips may not have more than 50 items.'); +}); +test('api key allowed ips must be a list', function (): void { + $user = User::factory()->create(); - $response = $this->actingAs($user)->get('/api/client/account/api-keys') - ->assertOk() - ->assertJsonPath('object', 'list') - ->assertJsonPath('data.0.object', ApiKey::RESOURCE_NAME); + $this->actingAs($user)->postJson('/api/client/account/api-keys', ['description' => 'Associative IPs', 'allowed_ips' => ['primary' => '127.0.0.1']]) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'allowed_ips'); - $this->assertJsonTransformedWith($response->json('data.0.attributes'), $key); - } - - /** - * Test that an API key can be created for the client account. This also checks that the - * API key secret is returned as metadata in the response since it will not be returned - * after that point. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('validIPAddressDataProvider')] - public function testApiKeyCanBeCreatedForAccount(array $data) - { - /** @var User $user */ - $user = User::factory()->create(); - - // Small subtest to ensure we're always comparing the number of keys to the - // specific logged in account, and not just the total number of keys stored in - // the database. - ApiKey::factory()->times(10)->create([ - 'user_id' => User::factory()->create()->id, - 'key_type' => ApiKey::TYPE_ACCOUNT, - ]); - - $response = $this->actingAs($user)->postJson('/api/client/account/api-keys', [ - 'description' => 'Test Description', - 'allowed_ips' => $data, - ]) - ->assertOk() - ->assertJsonPath('object', ApiKey::RESOURCE_NAME); - - /** @var ApiKey $key */ - $key = ApiKey::query()->where('identifier', $response->json('attributes.identifier'))->firstOrFail(); - - $this->assertJsonTransformedWith($response->json('attributes'), $key); - $response->assertJsonPath('meta.secret_token', decrypt($key->token)); - - $this->assertActivityFor('user:api-key.create', $user, [$key, $user]); - } - - /** - * Block requests to create an API key specifying more than 50 IP addresses. - */ - public function testApiKeyCannotSpecifyMoreThanFiftyIps() - { - $ips = []; - for ($i = 0; $i < 100; ++$i) { - $ips[] = '127.0.0.' . $i; - } - - $this->actingAs(User::factory()->create()) - ->postJson('/api/client/account/api-keys', [ - 'description' => 'Test Data', - 'allowed_ips' => $ips, - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.detail', 'The allowed ips may not have more than 50 items.'); - } - - /** - * Test that no more than 25 API keys can exist at any one time for an account. This prevents - * a DoS attack vector against the panel. - * - * @see https://github.com/pterodactyl/panel/security/advisories/GHSA-pjmh-7xfm-r4x9 - * @see https://github.com/pterodactyl/panel/issues/4394 - */ - public function testApiKeyLimitIsApplied() - { - /** @var User $user */ - $user = User::factory()->create(); - ApiKey::factory()->times(25)->for($user)->create([ - 'key_type' => ApiKey::TYPE_ACCOUNT, - ]); - - $this->actingAs($user)->postJson('/api/client/account/api-keys', [ - 'description' => 'Test Description', - 'allowed_ips' => ['127.0.0.1'], - ]) - ->assertStatus(Response::HTTP_BAD_REQUEST) - ->assertJsonPath('errors.0.code', 'DisplayException') - ->assertJsonPath('errors.0.detail', 'You have reached the account limit for number of API keys.'); - } - - /** - * Test that a bad request results in a validation error being returned by the API. - * - * @see https://github.com/pterodactyl/panel/issues/2457 - */ - public function testValidationErrorIsReturnedForBadRequests() - { - $this->actingAs(User::factory()->create()); - - $this->postJson('/api/client/account/api-keys', [ - 'description' => '', - 'allowed_ips' => ['127.0.0.1'], - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta.rule', 'required') - ->assertJsonPath('errors.0.detail', 'The description field is required.'); - - $this->postJson('/api/client/account/api-keys', [ - 'description' => str_repeat('a', 501), - 'allowed_ips' => ['127.0.0.1'], - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta.rule', 'max') - ->assertJsonPath('errors.0.detail', 'The description may not be greater than 500 characters.'); - - $this->postJson('/api/client/account/api-keys', [ - 'description' => 'Foobar', - 'allowed_ips' => ['hodor', '127.0.0.1', 'hodor/24'], - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.detail', '"hodor" is not a valid IP address or CIDR range.') - ->assertJsonPath('errors.0.meta.source_field', 'allowed_ips.0') - ->assertJsonPath('errors.1.detail', '"hodor/24" is not a valid IP address or CIDR range.') - ->assertJsonPath('errors.1.meta.source_field', 'allowed_ips.2'); - } - - /** - * Tests that an API key can be deleted from the account. - */ - public function testApiKeyCanBeDeleted() - { - /** @var User $user */ - $user = User::factory()->create(); - /** @var ApiKey $key */ - $key = ApiKey::factory()->for($user)->create([ - 'key_type' => ApiKey::TYPE_ACCOUNT, - ]); - - $response = $this->actingAs($user)->delete('/api/client/account/api-keys/' . $key->identifier); - $response->assertStatus(Response::HTTP_NO_CONTENT); - - $this->assertDatabaseMissing('api_keys', ['id' => $key->id]); - $this->assertActivityFor('user:api-key.delete', $user, $user); - } - - /** - * Test that trying to delete an API key that does not exist results in a 404. - */ - public function testNonExistentApiKeyDeletionReturns404Error() - { - /** @var User $user */ - $user = User::factory()->create(); - /** @var ApiKey $key */ - $key = ApiKey::factory()->create([ - 'user_id' => $user->id, - 'key_type' => ApiKey::TYPE_ACCOUNT, - ]); - - $response = $this->actingAs($user)->delete('/api/client/account/api-keys/1234'); - $response->assertNotFound(); - - $this->assertDatabaseHas('api_keys', ['id' => $key->id]); - Event::assertNotDispatched(ActivityLogged::class); - } - - /** - * Test that an API key that exists on the system cannot be deleted if the user - * who created it is not the authenticated user. - */ - public function testApiKeyBelongingToAnotherUserCannotBeDeleted() - { - /** @var User $user */ - $user = User::factory()->create(); - /** @var User $user2 */ - $user2 = User::factory()->create(); - /** @var ApiKey $key */ - $key = ApiKey::factory()->for($user2)->create([ - 'key_type' => ApiKey::TYPE_ACCOUNT, - ]); - - $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/' . $key->identifier) - ->assertNotFound(); - - $this->assertDatabaseHas('api_keys', ['id' => $key->id]); - Event::assertNotDispatched(ActivityLogged::class); - } - - /** - * Tests that an application API key also belonging to the logged-in user cannot be - * deleted through this endpoint if it exists. - */ - public function testApplicationApiKeyCannotBeDeleted() - { - /** @var User $user */ - $user = User::factory()->create(); - /** @var ApiKey $key */ - $key = ApiKey::factory()->for($user)->create([ - 'key_type' => ApiKey::TYPE_APPLICATION, - ]); - - $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/' . $key->identifier) - ->assertNotFound(); - - $this->assertDatabaseHas('api_keys', ['id' => $key->id]); - } - - /** - * Provides some different IP address combinations that can be used when - * testing that we accept the expected IP values. - */ - public static function validIPAddressDataProvider(): array - { - return [ - [[]], - [['127.0.0.1']], - [['127.0.0.1', '::1']], - [['::ffff:7f00:1']], - [['127.0.0.1', '192.168.1.100', '192.168.10.10/28']], - [['127.0.0.1/32', '192.168.100.100/27', '::1', '::1/128']], - ]; - } -} + $this->assertDatabaseMissing('api_keys', ['user_id' => $user->id]); +}); +test('api key limit is applied', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + ApiKey::factory()->times(25)->for($user)->create(['key_type' => ApiKey::TYPE_ACCOUNT]); + $this->actingAs($user)->postJson('/api/client/account/api-keys', ['description' => 'Test Description', 'allowed_ips' => ['127.0.0.1']])->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.code', 'DisplayException')->assertJsonPath('errors.0.detail', 'You have reached the account limit for number of API keys.'); +}); +test('validation error is returned for bad requests', function (): void { + $this->actingAs(User::factory()->create()); + $this->postJson('/api/client/account/api-keys', ['description' => '', 'allowed_ips' => ['127.0.0.1']])->assertUnprocessable()->assertJsonPath('errors.0.meta.rule', 'required')->assertJsonPath('errors.0.detail', 'The description field is required.'); + $this->postJson('/api/client/account/api-keys', ['description' => str_repeat('a', 501), 'allowed_ips' => ['127.0.0.1']])->assertUnprocessable()->assertJsonPath('errors.0.meta.rule', 'max')->assertJsonPath('errors.0.detail', 'The description may not be greater than 500 characters.'); + $this->postJson('/api/client/account/api-keys', ['description' => 'Foobar', 'allowed_ips' => ['hodor', '127.0.0.1', 'hodor/24']])->assertUnprocessable()->assertJsonPath('errors.0.detail', '"hodor" is not a valid IP address or CIDR range.')->assertJsonPath('errors.0.meta.source_field', 'allowed_ips.0')->assertJsonPath('errors.1.detail', '"hodor/24" is not a valid IP address or CIDR range.')->assertJsonPath('errors.1.meta.source_field', 'allowed_ips.2'); +}); +test('api key can be deleted', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + /** @var ApiKey $key */ + $key = ApiKey::factory()->for($user)->create(['key_type' => ApiKey::TYPE_ACCOUNT]); + $response = $this->actingAs($user)->delete('/api/client/account/api-keys/'.$key->identifier); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('api_keys', ['id' => $key->id]); + $this->assertActivityFor('user:api-key.delete', $user, $user); +}); +test('non existent api key deletion returns404 error', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + /** @var ApiKey $key */ + $key = ApiKey::factory()->create(['user_id' => $user->id, 'key_type' => ApiKey::TYPE_ACCOUNT]); + $response = $this->actingAs($user)->delete('/api/client/account/api-keys/1234'); + $response->assertNotFound(); + $this->assertDatabaseHas('api_keys', ['id' => $key->id]); + Event::assertNotDispatched(ActivityLogged::class); +}); +test('api key belonging to another user cannot be deleted', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + /** @var User $user2 */ + $user2 = User::factory()->create(); + /** @var ApiKey $key */ + $key = ApiKey::factory()->for($user2)->create(['key_type' => ApiKey::TYPE_ACCOUNT]); + $this->actingAs($user)->deleteJson('/api/client/account/api-keys/'.$key->identifier)->assertNotFound(); + $this->assertDatabaseHas('api_keys', ['id' => $key->id]); + Event::assertNotDispatched(ActivityLogged::class); +}); +test('application api key cannot be deleted', function (): void { + /** @var User $user */ + $user = User::factory()->create(); + /** @var ApiKey $key */ + $key = ApiKey::factory()->for($user)->create(['key_type' => ApiKey::TYPE_APPLICATION]); + $this->actingAs($user)->deleteJson('/api/client/account/api-keys/'.$key->identifier)->assertNotFound(); + $this->assertDatabaseHas('api_keys', ['id' => $key->id]); +}); diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index d7ceb34a2..684331e99 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -1,23 +1,24 @@ uuid"; break; @@ -74,27 +74,9 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase $link = "/api/client/servers/{$model->server->uuid}/backups/$model->uuid"; break; default: - throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model))); + throw new InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model))); } - return $link . ($append ? '/' . ltrim($append, '/') : ''); - } - - /** - * Asserts that the data passed through matches the output of the data from the transformer. This - * will remove the "relationships" key when performing the comparison. - */ - protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model) - { - $reflect = new \ReflectionClass($model); - $transformer = sprintf('\\Pterodactyl\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName()); - - $transformer = new $transformer(); - $this->assertInstanceOf(BaseClientTransformer::class, $transformer); - - $this->assertSame( - $transformer->transform($model), - Collection::make($data)->except(['relationships'])->toArray() - ); + return $link.($append ? '/'.mb_ltrim($append, '/') : ''); } } diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index 44084450a..619358904 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -1,336 +1,217 @@ times(3)->create(); + /** @var Server[] $servers */ + $servers = [$this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), $this->createServerModel(['user_id' => $users[2]->id])]; + $response = $this->actingAs($users[0])->getJson('/api/client'); + $response->assertOk(); + $response->assertJsonPath('object', 'list'); + $response->assertJsonPath('data.0.object', Server::RESOURCE_NAME); + $response->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort); + $response->assertJsonPath('data.0.attributes.server_owner', true); + $response->assertJsonPath('meta.pagination.total', 1); + $response->assertJsonPath('meta.pagination.per_page', 50); +}); +test('servers are filtered using name and uuid information', function () { + /** @var User[] $users */ + $users = User::factory()->times(2)->create(); + $users[0]->update(['root_admin' => true]); + /** @var Server[] $servers */ + $servers = [$this->createServerModel(['user_id' => $users[0]->id, 'name' => 'Julia']), $this->createServerModel(['user_id' => $users[1]->id, 'uuidShort' => '12121212', 'name' => 'Janice']), $this->createServerModel(['user_id' => $users[1]->id, 'uuid' => Uuid::uuid4()->toString(), 'external_id' => 'ext123', 'name' => 'Julia']), $this->createServerModel(['user_id' => $users[1]->id, 'uuid' => Uuid::uuid4()->toString(), 'name' => 'Jennifer'])]; + $this->actingAs($users[1])->getJson('/api/client?filter[*]=Julia')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); + $this->actingAs($users[1])->getJson('/api/client?filter[*]=ext123')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); + $this->actingAs($users[1])->getJson('/api/client?filter[*]=12121212')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.identifier', $servers[1]->uuidShort); + $this->actingAs($users[1])->getJson("/api/client?filter[*]={$servers[2]->uuidShort}")->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); + $this->actingAs($users[1])->getJson('/api/client?filter[*]=88788878-abcd')->assertOk()->assertJsonCount(0, 'data'); + $this->actingAs($users[0])->getJson('/api/client?filter[*]=Julia&type=admin-all')->assertOk()->assertJsonCount(2, 'data')->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort)->assertJsonPath('data.1.attributes.identifier', $servers[2]->uuidShort); +}); +test('servers are filtered using allocation information', function () { + /** @var User $user */ + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + $server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]); + $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]); + $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]); + $server->update(['allocation_id' => $allocation->id]); + $server2->update(['allocation_id' => $allocation2->id]); + $server->refresh(); + $server2->refresh(); + $this->actingAs($user)->getJson('/api/client?filter[*]=192.168.1.1')->assertOk()->assertJsonCount(2, 'data')->assertJsonPath('data.0.attributes.identifier', $server->uuidShort)->assertJsonPath('data.1.attributes.identifier', $server2->uuidShort); + $this->actingAs($user)->getJson('/api/client?filter[*]=192.168.1.1:25565')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.identifier', $server->uuidShort); + $this->actingAs($user)->getJson('/api/client?filter[*]=:25570')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.attributes.identifier', $server2->uuidShort); + $this->actingAs($user)->getJson('/api/client?filter[*]=:255')->assertOk()->assertJsonCount(2, 'data')->assertJsonPath('data.0.attributes.identifier', $server->uuidShort)->assertJsonPath('data.1.attributes.identifier', $server2->uuidShort); +}); +test('servers user is a subuser of are returned', function () { + /** @var User[] $users */ + $users = User::factory()->times(3)->create(); + $servers = [$this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), $this->createServerModel(['user_id' => $users[2]->id])]; + // Set user 0 as a subuser of server 1. Thus, we should get two servers + // back in the response when making the API call as user 0. + Subuser::query()->create(['user_id' => $users[0]->id, 'server_id' => $servers[1]->id, 'permissions' => [Permissions::WebsocketConnect->value]]); + $response = $this->actingAs($users[0])->getJson('/api/client'); + $response->assertOk(); + $response->assertJsonCount(2, 'data'); + $response->assertJsonPath('data.0.attributes.server_owner', true); + $response->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort); + $response->assertJsonPath('data.1.attributes.server_owner', false); + $response->assertJsonPath('data.1.attributes.identifier', $servers[1]->uuidShort); +}); +test('filter only owner servers', function () { + /** @var User[] $users */ + $users = User::factory()->times(3)->create(); + $servers = [$this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), $this->createServerModel(['user_id' => $users[2]->id])]; + // Set user 0 as a subuser of server 1. Thus, we should get two servers + // back in the response when making the API call as user 0. + Subuser::query()->create(['user_id' => $users[0]->id, 'server_id' => $servers[1]->id, 'permissions' => [Permissions::WebsocketConnect->value]]); + $response = $this->actingAs($users[0])->getJson('/api/client?type=owner'); + $response->assertOk(); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.server_owner', true); + $response->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort); +}); +test('permissions are returned', function () { + /** @var User $user */ + $user = User::factory()->create(); + $this->actingAs($user)->getJson('/api/client/permissions')->assertOk()->assertJson(['object' => 'system_permissions', 'attributes' => ['permissions' => Permission::permissions()->toArray()]]); +}); +test('only admin level servers are returned', function () { + /** @var User[] $users */ + $users = User::factory()->times(4)->create(); + $users[0]->update(['root_admin' => true]); + $servers = [$this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), $this->createServerModel(['user_id' => $users[2]->id]), $this->createServerModel(['user_id' => $users[3]->id])]; + Subuser::query()->create(['user_id' => $users[0]->id, 'server_id' => $servers[1]->id, 'permissions' => [Permissions::WebsocketConnect->value]]); + // Only servers 2 & 3 (0 indexed) should be returned by the API at this point. The user making + // the request is the owner of server 0, and a subuser of server 1, so they should be excluded. + $response = $this->actingAs($users[0])->getJson('/api/client?type=admin'); + $response->assertOk(); + $response->assertJsonCount(2, 'data'); + $response->assertJsonPath('data.0.attributes.server_owner', false); + $response->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); + $response->assertJsonPath('data.1.attributes.server_owner', false); + $response->assertJsonPath('data.1.attributes.identifier', $servers[3]->uuidShort); +}); +test('all servers are returned to admin', function () { + /** @var User[] $users */ + $users = User::factory()->times(4)->create(); + $users[0]->update(['root_admin' => true]); + $servers = [$this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), $this->createServerModel(['user_id' => $users[2]->id]), $this->createServerModel(['user_id' => $users[3]->id])]; + Subuser::query()->create(['user_id' => $users[0]->id, 'server_id' => $servers[1]->id, 'permissions' => [Permissions::WebsocketConnect->value]]); + // All servers should be returned. + $response = $this->actingAs($users[0])->getJson('/api/client?type=admin-all'); + $response->assertOk(); + $response->assertJsonCount(4, 'data'); +}); +test('no servers are returned if admin filter is passed by regular user', function (string $type) { + /** @var User[] $users */ + $users = User::factory()->times(3)->create(); + $this->createServerModel(['user_id' => $users[0]->id]); + $this->createServerModel(['user_id' => $users[1]->id]); + $this->createServerModel(['user_id' => $users[2]->id]); + $response = $this->actingAs($users[0])->getJson('/api/client?type='.$type); + $response->assertOk(); + $response->assertJsonCount(0, 'data'); +})->with('filterTypeDataProvider'); +test('only primary allocation is returned to subuser', function () { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $server->allocation->notes = 'Test notes'; + $server->allocation->save(); + Allocation::factory()->times(2)->create(['node_id' => $server->node_id, 'server_id' => $server->id]); + $server->refresh(); + $response = $this->actingAs($user)->getJson('/api/client'); + $response->assertOk(); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.attributes.server_owner', false); + $response->assertJsonPath('data.0.attributes.uuid', $server->uuid); + $response->assertJsonCount(1, 'data.0.attributes.relationships.allocations.data'); + $response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.id', $server->allocation->id); + $response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.notes', null); +}); + +function measuredReads(Closure $request): int { - /** - * Test that only the servers a logged-in user is assigned to are returned by the - * API endpoint. Obviously there are cases such as being an administrator or being - * a subuser, but for this test we just want to test a basic scenario and pretend - * subusers do not exist at all. - */ - public function testOnlyLoggedInUsersServersAreReturned() - { - /** @var \Pterodactyl\Models\User[] $users */ - $users = User::factory()->times(3)->create(); + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $request()->assertOk(); - /** @var \Pterodactyl\Models\Server[] $servers */ - $servers = [ - $this->createServerModel(['user_id' => $users[0]->id]), - $this->createServerModel(['user_id' => $users[1]->id]), - $this->createServerModel(['user_id' => $users[2]->id]), - ]; - - $response = $this->actingAs($users[0])->getJson('/api/client'); - - $response->assertOk(); - $response->assertJsonPath('object', 'list'); - $response->assertJsonPath('data.0.object', Server::RESOURCE_NAME); - $response->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort); - $response->assertJsonPath('data.0.attributes.server_owner', true); - $response->assertJsonPath('meta.pagination.total', 1); - $response->assertJsonPath('meta.pagination.per_page', 50); - } - - /** - * Test that using ?filter[*]=name|uuid returns any server matching that name or UUID - * with the search filters. - */ - public function testServersAreFilteredUsingNameAndUuidInformation() - { - /** @var \Pterodactyl\Models\User[] $users */ - $users = User::factory()->times(2)->create(); - $users[0]->update(['root_admin' => true]); - - /** @var \Pterodactyl\Models\Server[] $servers */ - $servers = [ - $this->createServerModel(['user_id' => $users[0]->id, 'name' => 'Julia']), - $this->createServerModel(['user_id' => $users[1]->id, 'uuidShort' => '12121212', 'name' => 'Janice']), - $this->createServerModel(['user_id' => $users[1]->id, 'uuid' => Uuid::uuid4()->toString(), 'external_id' => 'ext123', 'name' => 'Julia']), - $this->createServerModel(['user_id' => $users[1]->id, 'uuid' => Uuid::uuid4()->toString(), 'name' => 'Jennifer']), - ]; - - $this->actingAs($users[1])->getJson('/api/client?filter[*]=Julia') - ->assertOk() - ->assertJsonCount(1, 'data') - ->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); - - $this->actingAs($users[1])->getJson('/api/client?filter[*]=ext123') - ->assertOk() - ->assertJsonCount(1, 'data') - ->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); - - $this->actingAs($users[1])->getJson('/api/client?filter[*]=ext123') - ->assertOk() - ->assertJsonCount(1, 'data') - ->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); - - $this->actingAs($users[1])->getJson('/api/client?filter[*]=12121212') - ->assertOk() - ->assertJsonCount(1, 'data') - ->assertJsonPath('data.0.attributes.identifier', $servers[1]->uuidShort); - - $this->actingAs($users[1])->getJson("/api/client?filter[*]={$servers[2]->uuidShort}") - ->assertOk() - ->assertJsonCount(1, 'data') - ->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); - - $this->actingAs($users[1])->getJson('/api/client?filter[*]=88788878-abcd') - ->assertOk() - ->assertJsonCount(0, 'data'); - - $this->actingAs($users[0])->getJson('/api/client?filter[*]=Julia&type=admin-all') - ->assertOk() - ->assertJsonCount(2, 'data') - ->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort) - ->assertJsonPath('data.1.attributes.identifier', $servers[2]->uuidShort); - } - - /** - * Test that using ?filter[*]=:25565 or ?filter[*]=192.168.1.1:25565 returns only those servers - * with the same allocation for the given user. - */ - public function testServersAreFilteredUsingAllocationInformation() - { - /** @var User $user */ - /** @var Server $server */ - [$user, $server] = $this->generateTestAccount(); - $server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]); - - $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]); - $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]); - - $server->update(['allocation_id' => $allocation->id]); - $server2->update(['allocation_id' => $allocation2->id]); - - $server->refresh(); - $server2->refresh(); - - $this->actingAs($user)->getJson('/api/client?filter[*]=192.168.1.1') - ->assertOk() - ->assertJsonCount(2, 'data') - ->assertJsonPath('data.0.attributes.identifier', $server->uuidShort) - ->assertJsonPath('data.1.attributes.identifier', $server2->uuidShort); - - $this->actingAs($user)->getJson('/api/client?filter[*]=192.168.1.1:25565') - ->assertOk() - ->assertJsonCount(1, 'data') - ->assertJsonPath('data.0.attributes.identifier', $server->uuidShort); - - $this->actingAs($user)->getJson('/api/client?filter[*]=:25570') - ->assertOk() - ->assertJsonCount(1, 'data') - ->assertJsonPath('data.0.attributes.identifier', $server2->uuidShort); - - $this->actingAs($user)->getJson('/api/client?filter[*]=:255') - ->assertOk() - ->assertJsonCount(2, 'data') - ->assertJsonPath('data.0.attributes.identifier', $server->uuidShort) - ->assertJsonPath('data.1.attributes.identifier', $server2->uuidShort); - } - - /** - * Test that servers where the user is a subuser are returned by default in the API call. - */ - public function testServersUserIsASubuserOfAreReturned() - { - /** @var \Pterodactyl\Models\User[] $users */ - $users = User::factory()->times(3)->create(); - $servers = [ - $this->createServerModel(['user_id' => $users[0]->id]), - $this->createServerModel(['user_id' => $users[1]->id]), - $this->createServerModel(['user_id' => $users[2]->id]), - ]; - - // Set user 0 as a subuser of server 1. Thus, we should get two servers - // back in the response when making the API call as user 0. - Subuser::query()->create([ - 'user_id' => $users[0]->id, - 'server_id' => $servers[1]->id, - 'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT], - ]); - - $response = $this->actingAs($users[0])->getJson('/api/client'); - - $response->assertOk(); - $response->assertJsonCount(2, 'data'); - $response->assertJsonPath('data.0.attributes.server_owner', true); - $response->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort); - $response->assertJsonPath('data.1.attributes.server_owner', false); - $response->assertJsonPath('data.1.attributes.identifier', $servers[1]->uuidShort); - } - - /** - * Returns only servers that the user owns, not servers they are a subuser of. - */ - public function testFilterOnlyOwnerServers() - { - /** @var \Pterodactyl\Models\User[] $users */ - $users = User::factory()->times(3)->create(); - $servers = [ - $this->createServerModel(['user_id' => $users[0]->id]), - $this->createServerModel(['user_id' => $users[1]->id]), - $this->createServerModel(['user_id' => $users[2]->id]), - ]; - - // Set user 0 as a subuser of server 1. Thus, we should get two servers - // back in the response when making the API call as user 0. - Subuser::query()->create([ - 'user_id' => $users[0]->id, - 'server_id' => $servers[1]->id, - 'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT], - ]); - - $response = $this->actingAs($users[0])->getJson('/api/client?type=owner'); - - $response->assertOk(); - $response->assertJsonCount(1, 'data'); - $response->assertJsonPath('data.0.attributes.server_owner', true); - $response->assertJsonPath('data.0.attributes.identifier', $servers[0]->uuidShort); - } - - /** - * Tests that the permissions from the Panel are returned correctly. - */ - public function testPermissionsAreReturned() - { - /** @var User $user */ - $user = User::factory()->create(); - - $this->actingAs($user) - ->getJson('/api/client/permissions') - ->assertOk() - ->assertJson([ - 'object' => 'system_permissions', - 'attributes' => [ - 'permissions' => Permission::permissions()->toArray(), - ], - ]); - } - - /** - * Test that only servers a user can access because they are an administrator are returned. This - * will always exclude any servers they can see because they're the owner or a subuser of the server. - */ - public function testOnlyAdminLevelServersAreReturned() - { - /** @var \Pterodactyl\Models\User[] $users */ - $users = User::factory()->times(4)->create(); - $users[0]->update(['root_admin' => true]); - - $servers = [ - $this->createServerModel(['user_id' => $users[0]->id]), - $this->createServerModel(['user_id' => $users[1]->id]), - $this->createServerModel(['user_id' => $users[2]->id]), - $this->createServerModel(['user_id' => $users[3]->id]), - ]; - - Subuser::query()->create([ - 'user_id' => $users[0]->id, - 'server_id' => $servers[1]->id, - 'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT], - ]); - - // Only servers 2 & 3 (0 indexed) should be returned by the API at this point. The user making - // the request is the owner of server 0, and a subuser of server 1, so they should be excluded. - $response = $this->actingAs($users[0])->getJson('/api/client?type=admin'); - - $response->assertOk(); - $response->assertJsonCount(2, 'data'); - - $response->assertJsonPath('data.0.attributes.server_owner', false); - $response->assertJsonPath('data.0.attributes.identifier', $servers[2]->uuidShort); - $response->assertJsonPath('data.1.attributes.server_owner', false); - $response->assertJsonPath('data.1.attributes.identifier', $servers[3]->uuidShort); - } - - /** - * Test that all servers a user can access as an admin are returned if using ?filter=admin-all. - */ - public function testAllServersAreReturnedToAdmin() - { - /** @var \Pterodactyl\Models\User[] $users */ - $users = User::factory()->times(4)->create(); - $users[0]->update(['root_admin' => true]); - - $servers = [ - $this->createServerModel(['user_id' => $users[0]->id]), - $this->createServerModel(['user_id' => $users[1]->id]), - $this->createServerModel(['user_id' => $users[2]->id]), - $this->createServerModel(['user_id' => $users[3]->id]), - ]; - - Subuser::query()->create([ - 'user_id' => $users[0]->id, - 'server_id' => $servers[1]->id, - 'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT], - ]); - - // All servers should be returned. - $response = $this->actingAs($users[0])->getJson('/api/client?type=admin-all'); - - $response->assertOk(); - $response->assertJsonCount(4, 'data'); - } - - /** - * Test that no servers get returned if the user requests all admin level servers by using - * ?type=admin or ?type=admin-all in the request. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('filterTypeDataProvider')] - public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(string $type) - { - /** @var \Pterodactyl\Models\User[] $users */ - $users = User::factory()->times(3)->create(); - - $this->createServerModel(['user_id' => $users[0]->id]); - $this->createServerModel(['user_id' => $users[1]->id]); - $this->createServerModel(['user_id' => $users[2]->id]); - - $response = $this->actingAs($users[0])->getJson('/api/client?type=' . $type); - - $response->assertOk(); - $response->assertJsonCount(0, 'data'); - } - - /** - * Test that a subuser without the allocation.read permission is only able to see the primary - * allocation for the server. - */ - public function testOnlyPrimaryAllocationIsReturnedToSubuser() - { - /** @var Server $server */ - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $server->allocation->notes = 'Test notes'; - $server->allocation->save(); - - Allocation::factory()->times(2)->create([ - 'node_id' => $server->node_id, - 'server_id' => $server->id, - ]); - - $server->refresh(); - $response = $this->actingAs($user)->getJson('/api/client'); - - $response->assertOk(); - $response->assertJsonCount(1, 'data'); - $response->assertJsonPath('data.0.attributes.server_owner', false); - $response->assertJsonPath('data.0.attributes.uuid', $server->uuid); - $response->assertJsonCount(1, 'data.0.attributes.relationships.allocations.data'); - $response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.id', $server->allocation->id); - $response->assertJsonPath('data.0.attributes.relationships.allocations.data.0.attributes.notes', null); - } - - public static function filterTypeDataProvider(): array - { - return [['admin'], ['admin-all']]; + return count(array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select'))); + } finally { + DB::disableQueryLog(); } } + +test('client list batches dependencies and preserves each server override', function (bool $subuser) { + $viewer = User::factory()->create(); + $servers = []; + for ($i = 0; $i < 10; $i++) { + $server = $this->createServerModel($subuser ? [] : ['owner_id' => $viewer->id]); + if ($subuser) { + Subuser::factory()->create(['server_id' => $server->id, 'user_id' => $viewer->id, 'permissions' => [Permissions::StartupRead->value, Permissions::AllocationRead->value, Permissions::UserRead->value]]); + } + $variable = $server->egg->variables()->firstOrFail(); + $variable->update(['user_viewable' => true]); + ServerVariable::query()->create(['server_id' => $server->id, 'variable_id' => $variable->id, 'variable_value' => 'override-'.$i]); + $server->update(['startup' => '{{'.$variable->env_variable.'}}']); + $servers[] = $server; + } + $this->actingAs($viewer); + $request = fn (int $limit) => $this->getJson('/api/client?include=subusers&per_page='.$limit); + $request(1)->assertOk(); + $one = measuredReads(fn () => $request(1)); + $ten = measuredReads(fn () => $request(10)); + expect($ten)->toBe($one); + $response = $request(10)->assertOk()->assertJsonCount(10, 'data'); + foreach ($servers as $i => $server) { + $row = collect($response->json('data'))->firstWhere('attributes.uuid', $server->uuid); + expect($row['attributes']['invocation'])->toBe('override-'.$i); + expect(collect($row['attributes']['relationships']['variables']['data'])->pluck('attributes.server_value'))->toContain('override-'.$i); + } +})->with([false, true]); + +test('client child lists have bounded reads', function (string $resource) { + [$user, $server] = $this->generateTestAccount(); + $host = DatabaseHost::factory()->create(); + $add = function () use ($resource, $server, $host): void { + match ($resource) { + 'network/allocations' => Allocation::factory()->create(['server_id' => $server->id, 'node_id' => $server->node_id]), + 'users' => Subuser::factory()->create(['server_id' => $server->id]), + default => Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]), + }; + }; + if ($resource !== 'network/allocations') { + $add(); + } + $this->actingAs($user); + $request = fn () => $this->getJson('/api/client/servers/'.$server->uuid.'/'.$resource); + $request()->assertOk(); + $one = measuredReads($request); + for ($i = 0; $i < 9; $i++) { + $add(); + } + expect(measuredReads($request))->toBe($one); + $request()->assertOk()->assertJsonCount(10, 'data'); +})->with(['network/allocations', 'users', 'databases', 'databases?include=password']); diff --git a/tests/Integration/Api/Client/ExtensionProgressControllerTest.php b/tests/Integration/Api/Client/ExtensionProgressControllerTest.php new file mode 100644 index 000000000..4a82fc099 --- /dev/null +++ b/tests/Integration/Api/Client/ExtensionProgressControllerTest.php @@ -0,0 +1,58 @@ +directory = sys_get_temp_dir().'/ptero-progress-'.uniqid(); + File::ensureDirectoryExists($this->directory.'/source'); + File::put($this->directory.'/source/extension.json', json_encode(['id' => 'probe', 'name' => 'Probe', 'version' => '1.0.0'], JSON_THROW_ON_ERROR)); + config(['extensions.enabled' => true, 'extensions.directory' => $this->directory.'/installed']); + $this->app->make(ExtensionRepository::class)->flushDiscovery(); + $this->app->make(InstallsExtensions::class)->install($this->directory.'/source', enable: true); + $this->progress = $this->app->make(ExtensionJobProgress::class); +}); +afterEach(function (): void { + \Pterodactyl\Models\Extension::query()->where('identifier', 'probe')->delete(); + File::deleteDirectory($this->directory); +}); + +test('user progress requires authentication and the matching owner namespace and scope', function (): void { + $user = User::factory()->create(); + $job = $this->progress->begin('probe', $user); + $url = route('api:client.extension-progress', ['extension' => 'probe', 'job' => $job->id]); + $this->getJson($url)->assertUnauthorized(); + $this->actingAs($user)->getJson($url)->assertOk()->assertJsonPath('data.sequence', 1)->assertJsonMissingPath('data.userUuid'); + $updated = $this->progress->update('probe', $job->id, 75, 'Almost done'); + $this->getJson($url)->assertOk()->assertJsonPath('data.percent', 75)->assertJsonPath('data.sequence', $updated->sequence); + $this->actingAs(User::factory()->create())->getJson($url)->assertNotFound(); + $this->actingAs($user)->getJson(route('api:client.extension-progress', ['extension' => 'other', 'job' => $job->id]))->assertNotFound(); + $this->getJson(route('api:client.extension-progress', ['extension' => 'probe', 'job' => 'invalid']))->assertNotFound(); +}); + +test('server progress enforces server access operation permissions disabled extensions and expiry', function (): void { + [$user, $server] = $this->generateTestAccount(['ext.probe.view']); + $job = $this->progress->begin('probe', $user, $server, 'ext.probe.view'); + $url = route('api:client:server.extension-progress', ['server' => $server->uuid, 'extension' => 'probe', 'job' => $job->id]); + $this->actingAs($user)->getJson($url)->assertOk()->assertJsonPath('data.id', $job->id); + $this->getJson(route('api:client.extension-progress', ['extension' => 'probe', 'job' => $job->id]))->assertNotFound(); + $otherServer = $this->createServerModel(['user_id' => $user->id]); + $this->getJson(route('api:client:server.extension-progress', ['server' => $otherServer->uuid, 'extension' => 'probe', 'job' => $job->id]))->assertNotFound(); + $server->subusers()->where('user_id', $user->id)->update(['permissions' => ['backup.read']]); + $this->getJson($url)->assertNotFound(); + $this->actingAs($server->user)->getJson($url)->assertOk(); + config(['extensions.enabled' => false]); + $this->getJson($url)->assertNotFound(); + config(['extensions.enabled' => true]); + $this->travel(61)->minutes(); + $this->getJson($url)->assertNotFound(); +}); diff --git a/tests/Integration/Api/Client/SSHKeyControllerTest.php b/tests/Integration/Api/Client/SSHKeyControllerTest.php index 03d40f709..ba158acd7 100644 --- a/tests/Integration/Api/Client/SSHKeyControllerTest.php +++ b/tests/Integration/Api/Client/SSHKeyControllerTest.php @@ -1,144 +1,84 @@ create(); - $user2 = User::factory()->create(); - - $key = UserSSHKey::factory()->for($user)->create(); - UserSSHKey::factory()->for($user2)->rsa()->create(); - - $this->actingAs($user); - $response = $this->getJson('/api/client/account/ssh-keys') - ->assertOk() - ->assertJsonPath('object', 'list') - ->assertJsonPath('data.0.object', UserSSHKey::RESOURCE_NAME); - - $this->assertJsonTransformedWith($response->json('data.0.attributes'), $key); - } - - /** - * Test that a user's SSH key can be deleted, and that passing the fingerprint - * of another user's SSH key won't delete that key. - */ - public function testSSHKeyCanBeDeleted() - { - $user = User::factory()->create(); - $user2 = User::factory()->create(); - - $key = UserSSHKey::factory()->for($user)->create(); - $key2 = UserSSHKey::factory()->for($user2)->create(); - - $endpoint = '/api/client/account/ssh-keys/remove'; - - $this->actingAs($user); - $this->postJson($endpoint) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta', ['source_field' => 'fingerprint', 'rule' => 'required']); - - $this->postJson($endpoint, ['fingerprint' => $key->fingerprint])->assertNoContent(); - - $this->assertSoftDeleted($key); - $this->assertNotSoftDeleted($key2); - - $this->postJson($endpoint, ['fingerprint' => $key->fingerprint])->assertNoContent(); - $this->postJson($endpoint, ['fingerprint' => $key2->fingerprint])->assertNoContent(); - - $this->assertNotSoftDeleted($key2); - } - - public function testDSAKeyIsRejected() - { - $user = User::factory()->create(); - $key = UserSSHKey::factory()->dsa()->make(); - - $this->actingAs($user)->postJson('/api/client/account/ssh-keys', [ - 'name' => 'Name', - 'public_key' => $key->public_key, - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.detail', 'DSA keys are not supported.'); - - $this->assertEquals(0, $user->sshKeys()->count()); - } - - public function testWeakRSAKeyIsRejected() - { - $user = User::factory()->create(); - $key = UserSSHKey::factory()->rsa(true)->make(); - - $this->actingAs($user)->postJson('/api/client/account/ssh-keys', [ - 'name' => 'Name', - 'public_key' => $key->public_key, - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.detail', 'RSA keys must be at least 2048 bytes in length.'); - - $this->assertEquals(0, $user->sshKeys()->count()); - } - - public function testInvalidOrPrivateKeyIsRejected() - { - $user = User::factory()->create(); - - $this->actingAs($user)->postJson('/api/client/account/ssh-keys', [ - 'name' => 'Name', - 'public_key' => 'invalid', - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.detail', 'The public key provided is not valid.'); - - $this->assertEquals(0, $user->sshKeys()->count()); - - $key = EC::createKey('Ed25519'); - $this->actingAs($user)->postJson('/api/client/account/ssh-keys', [ - 'name' => 'Name', - 'public_key' => $key->toString('PKCS8'), - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.detail', 'The public key provided is not valid.'); - } - - public function testPublicKeyCanBeStored() - { - $user = User::factory()->create(); - $key = UserSSHKey::factory()->make(); - - $this->actingAs($user)->postJson('/api/client/account/ssh-keys', [ - 'name' => 'Name', - 'public_key' => $key->public_key, - ]) - ->assertOk() - ->assertJsonPath('object', UserSSHKey::RESOURCE_NAME) - ->assertJsonPath('attributes.public_key', $key->public_key); - - $this->assertCount(1, $user->sshKeys); - $this->assertEquals($key->public_key, $user->sshKeys[0]->public_key); - } - - public function testPublicKeyThatAlreadyExistsCannotBeAddedASecondTime() - { - $user = User::factory()->create(); - $key = UserSSHKey::factory()->for($user)->create(); - - $this->actingAs($user)->postJson('/api/client/account/ssh-keys', [ - 'name' => 'Name', - 'public_key' => $key->public_key, - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.detail', 'The public key provided already exists on your account.'); - - $this->assertEquals(1, $user->sshKeys()->count()); - } -} +uses(ClientApiIntegrationTestCase::class); +test('ssh keys are returned', function (): void { + $user = User::factory()->create(); + $user2 = User::factory()->create(); + $key = UserSSHKey::factory()->for($user)->create(); + UserSSHKey::factory()->for($user2)->rsa()->create(); + $this->actingAs($user); + $response = $this->getJson('/api/client/account/ssh-keys')->assertOk()->assertJsonPath('object', 'list')->assertJsonPath('data.0.object', UserSSHKey::RESOURCE_NAME); + expect($response->json('data.0.attributes'))->toBe([ + 'name' => $key->name, + 'fingerprint' => $key->fingerprint, + 'public_key' => $key->public_key, + 'created_at' => $key->created_at->toAtomString(), + ]); +}); +test('ssh key can be deleted', function (): void { + $user = User::factory()->create(); + $user2 = User::factory()->create(); + $key = UserSSHKey::factory()->for($user)->create(); + $key2 = UserSSHKey::factory()->for($user2)->create(); + $endpoint = '/api/client/account/ssh-keys/remove'; + $this->actingAs($user); + $this->postJson($endpoint)->assertUnprocessable()->assertJsonPath('errors.0.meta', ['source_field' => 'fingerprint', 'rule' => 'required']); + $this->postJson($endpoint, ['fingerprint' => $key->fingerprint])->assertNoContent(); + $this->assertSoftDeleted($key); + $this->assertNotSoftDeleted($key2); + $this->postJson($endpoint, ['fingerprint' => $key->fingerprint])->assertNoContent(); + $this->postJson($endpoint, ['fingerprint' => $key2->fingerprint])->assertNoContent(); + $this->assertNotSoftDeleted($key2); +}); +test('dsa key is rejected', function (): void { + $user = User::factory()->create(); + $key = UserSSHKey::factory()->dsa()->make(); + $this->actingAs($user)->postJson('/api/client/account/ssh-keys', ['name' => 'Name', 'public_key' => $key->public_key])->assertUnprocessable()->assertJsonPath('errors.0.detail', 'DSA keys are not supported.'); + expect($user->sshKeys()->count())->toEqual(0); +}); +test('weak rsa key is rejected', function (): void { + $user = User::factory()->create(); + $key = UserSSHKey::factory()->rsa(true)->make(); + $this->actingAs($user)->postJson('/api/client/account/ssh-keys', ['name' => 'Name', 'public_key' => $key->public_key])->assertUnprocessable()->assertJsonPath('errors.0.detail', 'RSA keys must be at least 2048 bytes in length.'); + expect($user->sshKeys()->count())->toEqual(0); +}); +test('invalid or private key is rejected', function (): void { + $user = User::factory()->create(); + $this->actingAs($user)->postJson('/api/client/account/ssh-keys', ['name' => 'Name', 'public_key' => 'invalid'])->assertUnprocessable()->assertJsonPath('errors.0.detail', 'The public key provided is not valid.'); + expect($user->sshKeys()->count())->toEqual(0); + $key = EC::createKey('Ed25519'); + $this->actingAs($user)->postJson('/api/client/account/ssh-keys', ['name' => 'Name', 'public_key' => $key->toString('PKCS8')])->assertUnprocessable()->assertJsonPath('errors.0.detail', 'The public key provided is not valid.'); +}); +test('only supported public key material can be stored', function (string $publicKey): void { + $user = User::factory()->create(); + $this->actingAs($user)->postJson('/api/client/account/ssh-keys', ['name' => 'Name', 'public_key' => $publicKey]) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'public_key'); + expect($user->sshKeys()->count())->toBe(0); +})->with([ + 'x509 certificate' => fn (): string => file_get_contents(base_path('tests/Fixtures/keys/x509-certificate.pem')), + 'key with a NUL byte' => fn (): string => substr_replace(EC::createKey('Ed25519')->getPublicKey()->toString('OpenSSH'), "\0", 20, 0), + 'key over 16 KB' => fn (): string => 'ssh-ed25519 '.str_repeat('A', 16400), +]); +test('public key can be stored', function (): void { + $user = User::factory()->create(); + $key = UserSSHKey::factory()->make(); + $this->actingAs($user)->postJson('/api/client/account/ssh-keys', ['name' => 'Name', 'public_key' => $key->public_key])->assertOk()->assertJsonPath('object', UserSSHKey::RESOURCE_NAME)->assertJsonPath('attributes.public_key', $key->public_key); + expect($user->sshKeys)->toHaveCount(1); + expect($user->sshKeys[0]->public_key)->toEqual($key->public_key); +}); +test('public key that already exists cannot be added a second time', function (): void { + $user = User::factory()->create(); + $key = UserSSHKey::factory()->for($user)->create(); + $this->actingAs($user)->postJson('/api/client/account/ssh-keys', ['name' => 'Name', 'public_key' => $key->public_key])->assertUnprocessable()->assertJsonPath('errors.0.detail', 'The public key provided already exists on your account.'); + expect($user->sshKeys()->count())->toEqual(1); +}); diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php index c5d6ac127..a0763b336 100644 --- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -1,55 +1,44 @@ generateTestAccount(); - // Will be a subuser of $server2. - $server2 = $this->createServerModel(); - // And as no access to $server3. - $server3 = $this->createServerModel(); - - // Set the API $user as a subuser of server 2, but with no permissions - // to do anything with the allocations for that server. - Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); - - $allocation1 = Allocation::factory()->create(['server_id' => $server1->id, 'node_id' => $server1->node_id]); - $allocation2 = Allocation::factory()->create(['server_id' => $server2->id, 'node_id' => $server2->node_id]); - $allocation3 = Allocation::factory()->create(['server_id' => $server3->id, 'node_id' => $server3->node_id]); - - // This is the only valid call for this test, accessing the allocation for the same - // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation1->id . $endpoint)); - $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); - - // This request fails because the allocation is valid for that server but the user - // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation2->id . $endpoint))->assertForbidden(); - - // Both of these should report a 404 error due to the allocations being linked to - // servers that are not the same as the server in the request, or are assigned - // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); - } - - public static function methodDataProvider(): array - { - return [ - ['POST', ''], - ['DELETE', ''], - ['POST', '/primary'], - ]; - } -} +uses(ClientApiIntegrationTestCase::class); +dataset('methodDataProvider', function () { + return [['POST', ''], ['DELETE', ''], ['POST', '/primary']]; +}); +test('access to a servers allocations is restricted properly', function (string $method, string $endpoint) { + // The API $user is the owner of $server1. + [$user, $server1] = $this->generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the allocations for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + $allocation1 = Allocation::factory()->create(['server_id' => $server1->id, 'node_id' => $server1->node_id]); + $allocation2 = Allocation::factory()->create(['server_id' => $server2->id, 'node_id' => $server2->node_id]); + $allocation3 = Allocation::factory()->create(['server_id' => $server3->id, 'node_id' => $server3->node_id]); + $server1->update(['allocation_limit' => 5]); + // This is the only valid call for this test, accessing the allocation for the same + // server that the API user is the owner of. + $body = $method === 'POST' && $endpoint === '' ? ['notes' => null] : []; + $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation1->id.$endpoint), $body); + $response->assertStatus($method === 'DELETE' ? 204 : 200); + // This request fails because the allocation is valid for that server but the user + // making the request is not authorized to perform that action. + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation2->id.$endpoint))->assertForbidden(); + // Both of these should report a 404 error due to the allocations being linked to + // servers that are not the same as the server in the request, or are assigned + // to a server for which the user making the request has no access to. + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); +})->with('methodDataProvider'); diff --git a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php index 61d93a62a..b296a92cc 100644 --- a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php @@ -1,92 +1,59 @@ set('pterodactyl.client_features.allocations.enabled', true); + config()->set('pterodactyl.client_features.allocations.range_start', 5000); + config()->set('pterodactyl.client_features.allocations.range_end', 5050); +}); +dataset('permissionDataProvider', fn (): array => [[[Permissions::AllocationCreate->value]], [[]]]); +test('new allocation can be assigned to server', function (array $permission): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permission); + $server->update(['allocation_limit' => 2]); + $response = $this->actingAs($user)->postJson($this->link($server, '/network/allocations')); + $response->assertJsonPath('object', Allocation::RESOURCE_NAME); - config()->set('pterodactyl.client_features.allocations.enabled', true); - config()->set('pterodactyl.client_features.allocations.range_start', 5000); - config()->set('pterodactyl.client_features.allocations.range_end', 5050); - } - - /** - * Tests that a new allocation can be properly assigned to a server. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('permissionDataProvider')] - public function testNewAllocationCanBeAssignedToServer(array $permission) - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount($permission); - $server->update(['allocation_limit' => 2]); - - $response = $this->actingAs($user)->postJson($this->link($server, '/network/allocations')); - $response->assertJsonPath('object', Allocation::RESOURCE_NAME); - - $matched = Allocation::query()->findOrFail($response->json('attributes.id')); - - $this->assertSame($server->id, $matched->server_id); - $this->assertJsonTransformedWith($response->json('attributes'), $matched); - } - - /** - * Test that a user without the required permissions cannot create an allocation for - * the server instance. - */ - public function testAllocationCannotBeCreatedIfUserDoesNotHavePermission() - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_UPDATE]); - $server->update(['allocation_limit' => 2]); - - $this->actingAs($user)->postJson($this->link($server, '/network/allocations'))->assertForbidden(); - } - - /** - * Test that an error is returned to the user if this feature is not enabled on the system. - */ - public function testAllocationCannotBeCreatedIfNotEnabled() - { - config()->set('pterodactyl.client_features.allocations.enabled', false); - - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount(); - $server->update(['allocation_limit' => 2]); - - $this->actingAs($user)->postJson($this->link($server, '/network/allocations')) - ->assertStatus(Response::HTTP_BAD_REQUEST) - ->assertJsonPath('errors.0.code', 'AutoAllocationNotEnabledException') - ->assertJsonPath('errors.0.detail', 'Server auto-allocation is not enabled for this instance.'); - } - - /** - * Test that an allocation cannot be created if the server has reached its allocation limit. - */ - public function testAllocationCannotBeCreatedIfServerIsAtLimit() - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount(); - $server->update(['allocation_limit' => 1]); - - $this->actingAs($user)->postJson($this->link($server, '/network/allocations')) - ->assertStatus(Response::HTTP_BAD_REQUEST) - ->assertJsonPath('errors.0.code', 'DisplayException') - ->assertJsonPath('errors.0.detail', 'Cannot assign additional allocations to this server: limit has been reached.'); - } - - public static function permissionDataProvider(): array - { - return [[[Permission::ACTION_ALLOCATION_CREATE]], [[]]]; - } -} + $matched = Allocation::query()->findOrFail($response->json('attributes.id')); + expect($matched->server_id)->toBe($server->id); + expect($response->json('attributes'))->toBe([ + 'id' => $matched->id, + 'ip' => $matched->ip, + 'ip_alias' => $matched->ip_alias, + 'port' => $matched->port, + 'notes' => null, + 'is_default' => false, + ]); +})->with('permissionDataProvider'); +test('allocation cannot be created if user does not have permission', function (): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount([Permissions::AllocationUpdate->value]); + $server->update(['allocation_limit' => 2]); + $this->actingAs($user)->postJson($this->link($server, '/network/allocations'))->assertForbidden(); +}); +test('allocation cannot be created if not enabled', function (): void { + config()->set('pterodactyl.client_features.allocations.enabled', false); + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + $server->update(['allocation_limit' => 2]); + $this->actingAs($user)->postJson($this->link($server, '/network/allocations'))->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.code', 'AutoAllocationNotEnabledException')->assertJsonPath('errors.0.detail', 'Server auto-allocation is not enabled for this instance.'); +}); +test('allocation cannot be created if server is at limit', function (): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + $server->update(['allocation_limit' => 1]); + $this->actingAs($user)->postJson($this->link($server, '/network/allocations'))->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.code', 'DisplayException')->assertJsonPath('errors.0.detail', 'Cannot assign additional allocations to this server: limit has been reached.'); +}); diff --git a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php index f6bd466e6..03b020b62 100644 --- a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php @@ -1,104 +1,55 @@ generateTestAccount($permission); - $server->update(['allocation_limit' => 2]); - - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->create([ - 'server_id' => $server->id, - 'node_id' => $server->node_id, - 'notes' => 'hodor', - ]); - - $this->actingAs($user)->deleteJson($this->link($allocation))->assertStatus(Response::HTTP_NO_CONTENT); - - $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null, 'notes' => null]); - } - - /** - * Test that an error is returned if the user does not have permissiont to delete an allocation. - */ - public function testErrorIsReturnedIfUserDoesNotHavePermission() - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]); - - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->create([ - 'server_id' => $server->id, - 'node_id' => $server->node_id, - 'notes' => 'hodor', - ]); - - $this->actingAs($user)->deleteJson($this->link($allocation))->assertForbidden(); - - $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => $server->id]); - } - - /** - * Test that an allocation is not deleted if it is currently marked as the primary allocation - * for the server. - */ - public function testErrorIsReturnedIfAllocationIsPrimary() - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount(); - $server->update(['allocation_limit' => 2]); - - $this->actingAs($user)->deleteJson($this->link($server->allocation)) - ->assertStatus(Response::HTTP_BAD_REQUEST) - ->assertJsonPath('errors.0.code', 'DisplayException') - ->assertJsonPath('errors.0.detail', 'You cannot delete the primary allocation for this server.'); - } - - public function testAllocationCannotBeDeletedIfServerLimitIsNotDefined() - { - [$user, $server] = $this->generateTestAccount(); - - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->forServer($server)->create(['notes' => 'Test notes']); - - $this->actingAs($user)->deleteJson($this->link($allocation)) - ->assertStatus(400) - ->assertJsonPath('errors.0.detail', 'You cannot delete allocations for this server: no allocation limit is set.'); - - $allocation->refresh(); - $this->assertNotNull($allocation->notes); - $this->assertEquals($server->id, $allocation->server_id); - } - - /** - * Test that an allocation cannot be deleted if it does not belong to the server instance. - */ - public function testErrorIsReturnedIfAllocationDoesNotBelongToServer() - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount(); - [, $server2] = $this->generateTestAccount(); - - $this->actingAs($user)->deleteJson($this->link($server2->allocation))->assertNotFound(); - $this->actingAs($user)->deleteJson($this->link($server, "/network/allocations/{$server2->allocation_id}"))->assertNotFound(); - } - - public static function permissionDataProvider(): array - { - return [[[Permission::ACTION_ALLOCATION_DELETE]], [[]]]; - } -} +uses(ClientApiIntegrationTestCase::class); +dataset('permissionDataProvider', function () { + return [[[Permissions::AllocationDelete->value]], [[]]]; +}); +test('allocation can be deleted from server', function (array $permission) { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permission); + $server->update(['allocation_limit' => 2]); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['server_id' => $server->id, 'node_id' => $server->node_id, 'notes' => 'hodor']); + $this->actingAs($user)->deleteJson($this->link($allocation))->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null, 'notes' => null]); +})->with('permissionDataProvider'); +test('error is returned if user does not have permission', function () { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount([Permissions::AllocationCreate->value]); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['server_id' => $server->id, 'node_id' => $server->node_id, 'notes' => 'hodor']); + $this->actingAs($user)->deleteJson($this->link($allocation))->assertForbidden(); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => $server->id]); +}); +test('error is returned if allocation is primary', function () { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + $server->update(['allocation_limit' => 2]); + $this->actingAs($user)->deleteJson($this->link($server->allocation))->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.code', 'DisplayException')->assertJsonPath('errors.0.detail', 'You cannot delete the primary allocation for this server.'); +}); +test('allocation cannot be deleted if server limit is not defined', function () { + [$user, $server] = $this->generateTestAccount(); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->forServer($server)->create(['notes' => 'Test notes']); + $this->actingAs($user)->deleteJson($this->link($allocation))->assertStatus(400)->assertJsonPath('errors.0.detail', 'You cannot delete allocations for this server: no allocation limit is set.'); + $allocation->refresh(); + expect($allocation->notes)->not->toBeNull(); + expect($allocation->server_id)->toEqual($server->id); +}); +test('error is returned if allocation does not belong to server', function () { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + [, $server2] = $this->generateTestAccount(); + $this->actingAs($user)->deleteJson($this->link($server2->allocation))->assertNotFound(); + $this->actingAs($user)->deleteJson($this->link($server, "/network/allocations/{$server2->allocation_id}"))->assertNotFound(); +}); diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php index 33fde157c..363bd7065 100644 --- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -1,63 +1,47 @@ generateTestAccount(); - // Will be a subuser of $server2. - $server2 = $this->createServerModel(); - // And as no access to $server3. - $server3 = $this->createServerModel(); - - // Set the API $user as a subuser of server 2, but with no permissions - // to do anything with the backups for that server. - Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); - - $backup1 = Backup::factory()->create(['server_id' => $server1->id, 'completed_at' => CarbonImmutable::now()]); - $backup2 = Backup::factory()->create(['server_id' => $server2->id, 'completed_at' => CarbonImmutable::now()]); - $backup3 = Backup::factory()->create(['server_id' => $server3->id, 'completed_at' => CarbonImmutable::now()]); - - $this->instance(DeleteBackupService::class, $mock = \Mockery::mock(DeleteBackupService::class)); - - if ($method === 'DELETE') { - $mock->expects('handle')->andReturnUndefined(); - } - - // This is the only valid call for this test, accessing the backup for the same - // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup1->uuid . $endpoint)) - ->assertStatus($method === 'DELETE' ? 204 : 200); - - // This request fails because the backup is valid for that server but the user - // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup2->uuid . $endpoint))->assertForbidden(); - - // Both of these should report a 404 error due to the backup being linked to - // servers that are not the same as the server in the request, or are assigned - // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup2->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); +uses(ClientApiIntegrationTestCase::class); +dataset('methodDataProvider', function () { + return [['GET', ''], ['GET', '/download'], ['DELETE', '']]; +}); +test('access to a servers backup is restricted properly', function (string $method, string $endpoint) { + // The API $user is the owner of $server1. + [$user, $server1] = $this->generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the backups for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + $backup1 = Backup::factory()->create(['server_id' => $server1->id, 'completed_at' => CarbonImmutable::now()]); + $backup2 = Backup::factory()->create(['server_id' => $server2->id, 'completed_at' => CarbonImmutable::now()]); + $backup3 = Backup::factory()->create(['server_id' => $server3->id, 'completed_at' => CarbonImmutable::now()]); + $fake = new FakeDaemonBackup; + // This is the only valid call for this test, accessing the backup for the same + // server that the API user is the owner of. + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup1->uuid.$endpoint))->assertStatus($method === 'DELETE' ? 204 : 200); + if ($method === 'DELETE') { + $fake->assertDeleted($backup1->uuid); } - - public static function methodDataProvider(): array - { - return [ - ['GET', ''], - ['GET', '/download'], - ['DELETE', ''], - ]; - } -} + // This request fails because the backup is valid for that server but the user + // making the request is not authorized to perform that action. + $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup2->uuid.$endpoint))->assertForbidden(); + // Both of these should report a 404 error due to the backup being linked to + // servers that are not the same as the server in the request, or are assigned + // to a server for which the user making the request has no access to. + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup2->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); +})->with('methodDataProvider'); diff --git a/tests/Integration/Api/Client/Server/Backup/BackupControllerTest.php b/tests/Integration/Api/Client/Server/Backup/BackupControllerTest.php new file mode 100644 index 000000000..f71110416 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Backup/BackupControllerTest.php @@ -0,0 +1,102 @@ +generateTestAccount([Permissions::BackupRead->value]); + $backups = Backup::factory()->times(2)->create(['server_id' => $server->id]); + // A backup on another server must never show up in this listing. + Backup::factory()->create(['server_id' => $this->createServerModel()->id]); + $response = $this->actingAs($user)->getJson($this->link($server, '/backups'))->assertOk()->assertJsonPath('object', 'list')->assertJsonCount(2, 'data')->assertJsonPath('meta.backup_count', 2)->assertJsonPath('meta.pagination.total', 2); + $uuids = collect($response->json('data'))->pluck('attributes.uuid'); + expect($uuids->toArray())->toEqualCanonicalizing($backups->pluck('uuid')->toArray()); +}); +test('backup listing requires read permission', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $this->getJson($this->link($server, '/backups'))->assertUnauthorized(); + $this->actingAs($user)->getJson($this->link($server, '/backups'))->assertForbidden(); +}); +test('backup can be created', function () { + $user = User::factory()->create(); + $server = $this->createServerModel(['owner_id' => $user->id, 'backup_limit' => 3]); + $fake = new FakeDaemonBackup; + $this->actingAs($user)->postJson($this->link($server, '/backups'), ['name' => 'Test Backup'])->assertOk()->assertJsonPath('object', 'backup')->assertJsonPath('attributes.name', 'Test Backup')->assertJsonPath('attributes.is_locked', false); + $this->assertDatabaseHas('backups', ['server_id' => $server->id, 'name' => 'Test Backup']); + $backup = Backup::query()->where('server_id', $server->id)->where('name', 'Test Backup')->firstOrFail(); + $fake->assertBackedUp($backup->uuid); +}); +test('backup cannot be created past the server limit', function () { + $user = User::factory()->create(); + $server = $this->createServerModel(['owner_id' => $user->id, 'backup_limit' => 1]); + Backup::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($server, '/backups'), ['name' => 'One Too Many'])->assertBadRequest(); + $this->assertDatabaseMissing('backups', ['server_id' => $server->id, 'name' => 'One Too Many']); +}); +test('backup lock can be toggled', function () { + [$user, $server] = $this->generateTestAccount([Permissions::BackupDelete->value]); + $backup = Backup::factory()->create(['server_id' => $server->id, 'is_locked' => false]); + $this->actingAs($user)->postJson($this->link($backup, '/lock'))->assertOk()->assertJsonPath('attributes.is_locked', true); + expect($backup->refresh()->is_locked)->toBeTrue(); + $this->postJson($this->link($backup, '/lock'))->assertOk()->assertJsonPath('attributes.is_locked', false); + expect($backup->refresh()->is_locked)->toBeFalse(); +}); +test('lock toggle requires delete permission', function () { + [$user, $server] = $this->generateTestAccount([Permissions::BackupCreate->value]); + $backup = Backup::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($backup, '/lock'))->assertForbidden(); +}); +test('backup can be restored', function () { + [$user, $server] = $this->generateTestAccount([Permissions::BackupRestore->value]); + $backup = Backup::factory()->create(['server_id' => $server->id, 'completed_at' => now(), 'is_successful' => true]); + $fake = new FakeDaemonBackup; + $this->actingAs($user)->postJson($this->link($backup, '/restore'), ['truncate' => false])->assertNoContent(); + // The server is placed into a restoring state while Wings works. + expect($server->refresh()->status)->toBe('restoring_backup'); + $fake->assertRestored($backup->uuid); +}); +test('a restore interrupted by a wings restart is logged as failed', function () { + [$user, $server] = $this->generateTestAccount([Permissions::BackupRestore->value]); + $backup = Backup::factory()->create(['server_id' => $server->id, 'completed_at' => now(), 'is_successful' => true]); + new FakeDaemonBackup; + $this->actingAs($user)->postJson($this->link($backup, '/restore'), ['truncate' => false])->assertNoContent(); + + $this->app->make(ResetsServerStates::class)->reset($server->node); + + expect($server->refresh()->status)->toBeNull(); + expect($server->activity()->where('event', 'server:backup.restore-failed')->exists())->toBeTrue(); +}); +test('backup cannot be restored while server is busy', function () { + [$user, $server] = $this->generateTestAccount([Permissions::BackupRestore->value]); + $server->update(['status' => 'installing']); + $backup = Backup::factory()->create(['server_id' => $server->id, 'completed_at' => now(), 'is_successful' => true]); + // The server-state middleware rejects requests against a server that is + // still installing before the controller's own status check runs. + $this->actingAs($user)->postJson($this->link($backup, '/restore'), ['truncate' => false])->assertConflict(); +}); +test('a backup can only be restored once it completed successfully', function (bool $isSuccessful, bool $isCompleted): void { + [$user, $server] = $this->generateTestAccount([Permissions::BackupRestore->value]); + $backup = Backup::factory()->create(['server_id' => $server->id, 'completed_at' => $isCompleted ? now() : null, 'is_successful' => $isSuccessful]); + $fake = new FakeDaemonBackup; + $this->actingAs($user)->postJson($this->link($backup, '/restore'), ['truncate' => true])->assertBadRequest(); + expect($server->refresh()->status)->toBeNull(); + expect(collect($fake->calls)->where('method', 'restore'))->toBeEmpty(); +})->with([ + 'failed but completed' => [false, true], + 'failed and incomplete' => [false, false], + 'successful but incomplete' => [true, false], +]); +test('restore requires truncate flag', function () { + [$user, $server] = $this->generateTestAccount([Permissions::BackupRestore->value]); + $backup = Backup::factory()->create(['server_id' => $server->id, 'completed_at' => now(), 'is_successful' => true]); + $this->actingAs($user)->postJson($this->link($backup, '/restore'))->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'truncate'); +}); diff --git a/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php b/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php index d6aea997d..823969915 100644 --- a/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php +++ b/tests/Integration/Api/Client/Server/Backup/DeleteBackupTest.php @@ -1,64 +1,35 @@ repository = $this->mock(DaemonBackupRepository::class); - } - - public function testUserWithoutPermissionCannotDeleteBackup() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_BACKUP_CREATE]); - - $backup = Backup::factory()->create(['server_id' => $server->id]); - - $this->actingAs($user)->deleteJson($this->link($backup)) - ->assertStatus(Response::HTTP_FORBIDDEN); - } - - /** - * Tests that a backup can be deleted for a server and that it is properly updated - * in the database. Once deleted there should also be a corresponding record in the - * activity logs table for this API call. - */ - public function testBackupCanBeDeleted() - { - Event::fake([ActivityLogged::class]); - - [$user, $server] = $this->generateTestAccount([Permission::ACTION_BACKUP_DELETE]); - - /** @var Backup $backup */ - $backup = Backup::factory()->create(['server_id' => $server->id]); - - $this->repository->expects('setServer->delete')->with( - \Mockery::on(function ($value) use ($backup) { - return $value instanceof Backup && $value->uuid === $backup->uuid; - }) - )->andReturn(new Response()); - - $this->actingAs($user)->deleteJson($this->link($backup))->assertStatus(Response::HTTP_NO_CONTENT); - - $backup->refresh(); - $this->assertSoftDeleted($backup); - - $this->assertActivityFor('server:backup.delete', $user, [$backup, $backup->server]); - - $this->actingAs($user)->deleteJson($this->link($backup))->assertStatus(Response::HTTP_NOT_FOUND); - } -} +uses(ClientApiIntegrationTestCase::class); +beforeEach(function () { + $this->repository = new FakeDaemonBackup; +}); +test('user without permission cannot delete backup', function () { + [$user, $server] = $this->generateTestAccount([Permissions::BackupCreate->value]); + $backup = Backup::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->deleteJson($this->link($backup))->assertStatus(Response::HTTP_FORBIDDEN); +}); +test('backup can be deleted', function () { + Event::fake([ActivityLogged::class]); + [$user, $server] = $this->generateTestAccount([Permissions::BackupDelete->value]); + /** @var Backup $backup */ + $backup = Backup::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->deleteJson($this->link($backup))->assertStatus(Response::HTTP_NO_CONTENT); + $backup->refresh(); + $this->assertSoftDeleted($backup); + $this->repository->assertDeleted($backup->uuid); + $this->assertActivityFor('server:backup.delete', $user, [$backup, $backup->server]); + $this->actingAs($user)->deleteJson($this->link($backup))->assertStatus(Response::HTTP_NOT_FOUND); +}); diff --git a/tests/Integration/Api/Client/Server/CommandControllerTest.php b/tests/Integration/Api/Client/Server/CommandControllerTest.php index 14d6da3f2..22b50fd4b 100644 --- a/tests/Integration/Api/Client/Server/CommandControllerTest.php +++ b/tests/Integration/Api/Client/Server/CommandControllerTest.php @@ -1,92 +1,44 @@ generateTestAccount(); - - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [ - 'command' => '', - ]); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.meta.rule', 'required'); - } - - /** - * Test that a subuser without the required permission receives an error when trying to - * execute the command. - */ - public function testSubuserWithoutPermissionReceivesError() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [ - 'command' => 'say Test', - ]); - - $response->assertStatus(Response::HTTP_FORBIDDEN); - } - - /** - * Test that a command can be sent to the server. - */ - public function testCommandCanSendToServer() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_CONTROL_CONSOLE]); - - $mock = $this->mock(DaemonCommandRepository::class); - $mock->expects('setServer') - ->with(\Mockery::on(fn (Server $value) => $value->is($server))) - ->andReturnSelf(); - - $mock->expects('send')->with('say Test')->andReturn(new GuzzleResponse()); - - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [ - 'command' => 'say Test', - ]); - - $response->assertStatus(Response::HTTP_NO_CONTENT); - } - - /** - * Test that an error is returned when the server is offline that is more specific than the - * regular daemon connection error. - */ - public function testErrorIsReturnedWhenServerIsOffline() - { - [$user, $server] = $this->generateTestAccount(); - - $mock = $this->mock(DaemonCommandRepository::class); - $mock->expects('setServer->send')->andThrows( - new DaemonConnectionException( - new BadResponseException('', new Request('GET', 'test'), new GuzzleResponse(Response::HTTP_BAD_GATEWAY)) - ) - ); - - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/command", [ - 'command' => 'say Test', - ]); - - $response->assertStatus(Response::HTTP_BAD_GATEWAY); - $response->assertJsonPath('errors.0.code', 'HttpException'); - $response->assertJsonPath('errors.0.detail', 'Server must be online in order to send commands.'); - } -} +uses(ClientApiIntegrationTestCase::class); +test('validation error is returned if no command is present', function () { + [$user, $server] = $this->generateTestAccount(); + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/command", ['command' => '']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.rule', 'required'); +}); +test('subuser without permission receives error', function () { + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/command", ['command' => 'say Test']); + $response->assertStatus(Response::HTTP_FORBIDDEN); +}); +test('command can send to server', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $fake = new FakeDaemonCommand; + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/command", ['command' => 'say Test']); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $fake->assertSent('say Test'); + Http::assertSent(fn (HttpRequest $request): bool => str_contains($request->url(), "/api/servers/{$server->uuid}/")); +}); +test('error is returned when server is offline', function () { + [$user, $server] = $this->generateTestAccount(); + $fake = new FakeDaemonCommand; + $fake->throwable = new DaemonConnectionException(Http::failedRequest([], Response::HTTP_BAD_GATEWAY)); + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/command", ['command' => 'say Test']); + $response->assertStatus(Response::HTTP_BAD_GATEWAY); + $response->assertJsonPath('errors.0.code', 'HttpException'); + $response->assertJsonPath('errors.0.detail', 'Server must be online in order to send commands.'); + $fake->assertSent('say Test'); +}); diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php index c31aed6e2..aa52d923e 100644 --- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -1,66 +1,56 @@ generateTestAccount(); - // Will be a subuser of $server2. - $server2 = $this->createServerModel(); - // And as no access to $server3. - $server3 = $this->createServerModel(); - - $host = DatabaseHost::factory()->create([]); - - // Set the API $user as a subuser of server 2, but with no permissions - // to do anything with the databases for that server. - Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); - - $database1 = Database::factory()->create(['server_id' => $server1->id, 'database_host_id' => $host->id]); - $database2 = Database::factory()->create(['server_id' => $server2->id, 'database_host_id' => $host->id]); - $database3 = Database::factory()->create(['server_id' => $server3->id, 'database_host_id' => $host->id]); - - $this - ->mock($method === 'POST' ? DatabasePasswordService::class : DatabaseManagementService::class) - ->expects($method === 'POST' ? 'handle' : 'delete') - ->andReturn($method === 'POST' ? 'foo' : null); - - $hashids = $this->app->make(HashidsInterface::class); - // This is the only valid call for this test, accessing the database for the same - // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $hashids->encode($database1->id) . $endpoint)) - ->assertStatus($method === 'DELETE' ? 204 : 200); - - // This request fails because the database is valid for that server but the user - // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $hashids->encode($database2->id) . $endpoint))->assertForbidden(); - - // Both of these should report a 404 error due to the database being linked to - // servers that are not the same as the server in the request, or are assigned - // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $hashids->encode($database2->id) . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound(); +uses(ClientApiIntegrationTestCase::class); +dataset('methodDataProvider', function () { + return [['POST', '/rotate-password'], ['DELETE', '']]; +}); +test('access to a servers databases is restricted properly', function (string $method, string $endpoint) { + // The API $user is the owner of $server1. + [$user, $server1] = $this->generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + $host = DatabaseHost::factory()->create([]); + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the databases for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + $database1 = Database::factory()->create(['server_id' => $server1->id, 'database_host_id' => $host->id]); + $database2 = Database::factory()->create(['server_id' => $server2->id, 'database_host_id' => $host->id]); + $database3 = Database::factory()->create(['server_id' => $server3->id, 'database_host_id' => $host->id]); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $hashids = $this->app->make(HashidsInterface::class); + // This is the only valid call for this test, accessing the database for the same + // server that the API user is the owner of. + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$hashids->encode($database1->id).$endpoint))->assertStatus($method === 'DELETE' ? 204 : 200); + // This request fails because the database is valid for that server but the user + // making the request is not authorized to perform that action. + $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$hashids->encode($database2->id).$endpoint))->assertForbidden(); + // Both of these should report a 404 error due to the database being linked to + // servers that are not the same as the server in the request, or are assigned + // to a server for which the user making the request has no access to. + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$hashids->encode($database2->id).$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$hashids->encode($database3->id).$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$hashids->encode($database3->id).$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/databases/'.$hashids->encode($database3->id).$endpoint))->assertNotFound(); + if ($method === 'POST') { + $gateway->assertFlushed(1); + expect($gateway->count('createUser'))->toBe(1); + } else { + $gateway->assertDroppedDatabase($database1->database); + $gateway->assertDroppedUser($database1->username, $database1->remote); + $gateway->assertFlushed(1); } - - public static function methodDataProvider(): array - { - return [ - ['POST', '/rotate-password'], - ['DELETE', ''], - ]; - } -} +})->with('methodDataProvider'); diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseControllerTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseControllerTest.php new file mode 100644 index 000000000..0f49b0da9 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Database/DatabaseControllerTest.php @@ -0,0 +1,50 @@ +generateTestAccount([Permissions::DatabaseRead->value]); + $host = DatabaseHost::factory()->create(); + $databases = Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + // A database on a different server must not be included. + Database::factory()->create(['server_id' => $this->createServerModel()->id, 'database_host_id' => $host->id]); + $response = $this->actingAs($user)->getJson($this->link($server, '/databases'))->assertOk()->assertJsonPath('object', 'list')->assertJsonCount(2, 'data')->assertJsonPath('data.0.object', 'server_database'); + $names = collect($response->json('data'))->pluck('attributes.name'); + expect($names->toArray())->toEqualCanonicalizing($databases->pluck('database')->toArray()); +}); +test('database can be created', function () { + $user = User::factory()->create(); + $server = $this->createServerModel(['owner_id' => $user->id, 'database_limit' => 2]); + $host = DatabaseHost::factory()->create(); + $this->app->instance(DatabaseHostGateway::class, $gateway = new FakeDatabaseHostGateway()); + $this->actingAs($user)->postJson($this->link($server, '/databases'), ['database' => 'testdb2', 'remote' => '%'])->assertOk()->assertJsonPath('object', 'server_database')->assertJsonPath('attributes.name', "s{$server->id}_testdb2"); + $database = Database::query()->where('server_id', $server->id)->firstOrFail(); + expect($database->database)->toBe("s{$server->id}_testdb2"); + $gateway->assertCreated("s{$server->id}_testdb2"); + $gateway->assertFlushed(1); +}); +test('database cannot be created past the server limit', function () { + $user = User::factory()->create(); + $server = $this->createServerModel(['owner_id' => $user->id, 'database_limit' => 1]); + $host = DatabaseHost::factory()->create(); + Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->actingAs($user)->postJson($this->link($server, '/databases'), ['database' => 'overlimit', 'remote' => '%'])->assertBadRequest(); +}); +test('endpoints require permissions', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $this->getJson($this->link($server, '/databases'))->assertUnauthorized(); + $this->actingAs($user); + $this->getJson($this->link($server, '/databases'))->assertForbidden(); + $this->postJson($this->link($server, '/databases'), ['database' => 'testdb', 'remote' => '%'])->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/Files/CompressFilesTest.php b/tests/Integration/Api/Client/Server/Files/CompressFilesTest.php index ccddc3773..abf78ef20 100644 --- a/tests/Integration/Api/Client/Server/Files/CompressFilesTest.php +++ b/tests/Integration/Api/Client/Server/Files/CompressFilesTest.php @@ -1,45 +1,43 @@ generateTestAccount([Permission::ACTION_CONTROL_CONSOLE]); +uses(ClientApiIntegrationTestCase::class); +test('endpoint requires authorization', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $this->postJson($this->link($server, '/files/compress'))->assertUnauthorized(); + $this->actingAs($user)->postJson($this->link($server, '/files/compress'))->assertForbidden(); +}); +test('endpoint triggers wings call', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileArchive->value]); + $fake = new FakeDaemonFile; + $fake->compressed = ['name' => 'test.tar.gz', 'mime' => 'application/gzip']; + $this->actingAs($user)->postJson($endpoint = $this->link($server, '/files/compress'), [])->assertUnprocessable()->assertJsonPath('errors.0.meta', ['source_field' => 'files', 'rule' => 'required']); + $this->postJson($endpoint, ['root' => '/', 'files' => ['test.txt']])->assertOk()->assertJsonPath('object', 'file_object')->assertJsonPath('attributes.name', 'test.tar.gz')->assertJsonPath('attributes.mimetype', 'application/gzip'); + $fake->assertCompressedFiles('/', ['test.txt']); +}); +test('compress description only interpolates properties the event records', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileArchive->value]); + $fake = new FakeDaemonFile; + $fake->compressed = ['name' => 'test.tar.gz', 'mime' => 'application/gzip']; + $this->actingAs($user)->postJson($this->link($server, '/files/compress'), ['root' => '/logs', 'files' => ['latest.log']])->assertOk(); - $this->postJson($this->link($server, '/files/compress'))->assertUnauthorized(); + $log = ActivityLog::query()->where('event', 'server:file.compress')->latest('id')->firstOrFail(); + $properties = (array) app(ActivityLogTransformer::class)->transform($log)['properties']; - $this->actingAs($user) - ->postJson($this->link($server, '/files/compress')) - ->assertForbidden(); + // A single file resolves the "_one" plural, whose placeholders must all be present + // in the transformed properties or the front-end renders a raw "{{name}}" token. + expect($properties['count'])->toBe(1); + preg_match_all('/:([\\w.-]+\\w)/', trans('activity.server.file.compress_one'), $matches); + foreach ($matches[1] as $placeholder) { + expect($properties)->toHaveKey(explode('.', $placeholder)[0]); } - - public function testEndpointTriggersWingsCall(): void - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_FILE_ARCHIVE]); - - $this->mock(DaemonFileRepository::class, function (MockInterface $mock) { - $mock->expects('setServer->compressFiles')->with('/', ['test.txt'])->andReturn([ - 'name' => 'test.tar.gz', - 'mime' => 'application/gzip', - ]); - }); - - $this->actingAs($user) - ->postJson($endpoint = $this->link($server, '/files/compress'), []) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta', ['source_field' => 'files', 'rule' => 'required']); - - $this->postJson($endpoint, ['root' => '/', 'files' => ['test.txt']]) - ->assertOk() - ->assertJsonPath('object', 'file_object') - ->assertJsonPath('attributes.name', 'test.tar.gz') - ->assertJsonPath('attributes.mimetype', 'application/gzip'); - } -} +}); diff --git a/tests/Integration/Api/Client/Server/Files/FileControllerTest.php b/tests/Integration/Api/Client/Server/Files/FileControllerTest.php new file mode 100644 index 000000000..1cab59af2 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Files/FileControllerTest.php @@ -0,0 +1,125 @@ + 'test.txt', 'mode' => '-rw-r--r--', 'mode_bits' => '0644', 'size' => 100, 'file' => true, 'symlink' => false, 'mime' => 'text/plain', 'created' => '2024-01-01T00:00:00Z', 'modified' => '2024-01-01T00:00:00Z']; +dataset('endpointsDataProvider', function () { + return ['list' => ['getJson', '/files/list'], 'contents' => ['getJson', '/files/contents?file=/test.txt'], 'download' => ['getJson', '/files/download?file=/test.txt'], 'upload' => ['getJson', '/files/upload'], 'write' => ['postJson', '/files/write?file=/test.txt'], 'create-folder' => ['postJson', '/files/create-folder'], 'rename' => ['putJson', '/files/rename'], 'copy' => ['postJson', '/files/copy'], 'decompress' => ['postJson', '/files/decompress'], 'delete' => ['postJson', '/files/delete'], 'chmod' => ['postJson', '/files/chmod'], 'pull' => ['postJson', '/files/pull']]; +}); +test('endpoints require authentication and permission', function (string $method, string $path) { + [, $server] = $this->generateTestAccount(); + $this->{$method}($this->link($server, $path))->assertUnauthorized(); + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $this->actingAs($user)->{$method}($this->link($server, $path))->assertForbidden(); +})->with('endpointsDataProvider'); +test('directory listing is returned', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileRead->value]); + $fake = new FakeDaemonFile; + $fake->directory = [FILE_CONTROLLER_FILE_OBJECT]; + $this->actingAs($user)->getJson($this->link($server, '/files/list'))->assertOk()->assertJsonPath('object', 'list')->assertJsonPath('data.0.object', 'file_object')->assertJsonPath('data.0.attributes.name', 'test.txt')->assertJsonPath('data.0.attributes.is_file', true)->assertJsonPath('data.0.attributes.mimetype', 'text/plain'); + $fake->assertDirectoryListed('/'); +}); +test('directory query parameter is passed to wings', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileRead->value]); + $fake = new FakeDaemonFile; + $fake->directory = []; + $this->actingAs($user)->getJson($this->link($server, '/files/list?directory=%2Fnested%2Fpath'))->assertOk()->assertJsonPath('data', []); + $fake->assertDirectoryListed('/nested/path'); +}); +test('file contents are returned as text', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileReadContent->value]); + $fake = new FakeDaemonFile; + $fake->content = 'file contents here'; + $response = $this->actingAs($user)->get($this->link($server, '/files/contents?file=%2Ftest.txt')); + $response->assertOk(); + $response->assertHeader('Content-Type', 'text/plain; charset=utf-8'); + expect($response->getContent())->toBe('file contents here'); + $fake->assertContentFetched('/test.txt'); +}); +test('reading file contents records the file path in the activity log', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileReadContent->value]); + $fake = new FakeDaemonFile; + $fake->content = 'file contents here'; + $this->actingAs($user)->get($this->link($server, '/files/contents?file=%2Fconfig%2Fserver.properties'))->assertOk(); + $fake->assertContentFetched('/config/server.properties'); + Event::assertDispatched(ActivityLogged::class, fn (ActivityLogged $event): bool => $event->is('server:file.read') && $event->model->propertyValues() === ['file' => '/config/server.properties']); +}); +test('file contents requires file parameter', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileReadContent->value]); + $this->actingAs($user)->getJson($this->link($server, '/files/contents'))->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'file'); +}); +test('download url is signed for the server node', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileReadContent->value]); + $response = $this->actingAs($user)->getJson($this->link($server, '/files/download?file=%2Ftest.txt'))->assertOk()->assertJsonPath('object', 'signed_url'); + $url = $response->json('attributes.url'); + expect($url)->toStartWith($server->node->getConnectionAddress().'/download/file?token='); +}); +test('upload url is signed for the server node', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileCreate->value]); + $response = $this->actingAs($user)->getJson($this->link($server, '/files/upload'))->assertOk()->assertJsonPath('object', 'signed_url'); + $url = $response->json('attributes.url'); + expect($url)->toStartWith($server->node->getConnectionAddress().'/upload/file?token='); +}); +test('file contents can be written', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileCreate->value]); + $fake = new FakeDaemonFile; + $this->actingAs($user)->call('POST', $this->link($server, '/files/write?file=%2Ftest.txt'), [], [], [], $this->transformHeadersToServerVars(['Accept' => 'application/json']), 'new file contents')->assertNoContent(); + $fake->assertContentPut('/test.txt', 'new file contents'); +}); +test('folder can be created', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileCreate->value]); + $fake = new FakeDaemonFile; + $this->actingAs($user)->postJson($this->link($server, '/files/create-folder'), ['root' => '/', 'name' => 'new-folder'])->assertNoContent(); + $fake->assertDirectoryCreated('new-folder', '/'); +}); +test('files can be renamed', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileUpdate->value]); + $files = [['from' => 'old.txt', 'to' => 'new.txt']]; + $fake = new FakeDaemonFile; + $this->actingAs($user)->putJson($this->link($server, '/files/rename'), ['root' => '/', 'files' => $files])->assertNoContent(); + $fake->assertFilesRenamed('/', $files); +}); +test('file can be copied', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileCreate->value]); + $fake = new FakeDaemonFile; + $this->actingAs($user)->postJson($this->link($server, '/files/copy'), ['location' => '/test.txt'])->assertNoContent(); + $fake->assertFileCopied('/test.txt'); +}); +test('file can be decompressed', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileCreate->value]); + $fake = new FakeDaemonFile; + $this->actingAs($user)->postJson($this->link($server, '/files/decompress'), ['root' => '/', 'file' => 'archive.tar.gz'])->assertNoContent(); + $fake->assertFileDecompressed('/', 'archive.tar.gz'); +}); +test('files can be deleted', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileDelete->value]); + $fake = new FakeDaemonFile; + $this->actingAs($user)->postJson($this->link($server, '/files/delete'), ['root' => '/', 'files' => ['test.txt']])->assertNoContent(); + $fake->assertFilesDeleted('/', ['test.txt']); +}); +test('file permissions can be updated', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileUpdate->value]); + $files = [['file' => 'test.txt', 'mode' => '0644']]; + $fake = new FakeDaemonFile; + $this->actingAs($user)->postJson($this->link($server, '/files/chmod'), ['root' => '/', 'files' => $files])->assertNoContent(); + $fake->assertFilesChmoded('/', $files); +}); +test('remote file can be pulled', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileCreate->value]); + $fake = new FakeDaemonFile; + $this->actingAs($user)->postJson($this->link($server, '/files/pull'), ['url' => 'https://cdn.example.com/file.zip', 'directory' => '/'])->assertNoContent(); + $fake->assertPulled('https://cdn.example.com/file.zip'); +}); +test('pull requires a valid url', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileCreate->value]); + $this->actingAs($user)->postJson($this->link($server, '/files/pull'), ['url' => 'not-a-url'])->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'url'); +}); diff --git a/tests/Integration/Api/Client/Server/GetServerTest.php b/tests/Integration/Api/Client/Server/GetServerTest.php new file mode 100644 index 000000000..6681cc0d2 --- /dev/null +++ b/tests/Integration/Api/Client/Server/GetServerTest.php @@ -0,0 +1,33 @@ +generateTestAccount(); + $this->actingAs($user)->getJson($this->link($server))->assertOk()->assertJsonPath('object', 'server')->assertJsonPath('attributes.uuid', $server->uuid)->assertJsonPath('attributes.name', $server->name)->assertJsonPath('meta.is_server_owner', true)->assertJsonPath('meta.user_permissions.0', '*'); +}); +test('server details expose the tags of its egg', function () { + [$user, $server] = $this->generateTestAccount(); + $this->actingAs($user)->getJson($this->link($server))->assertOk()->assertJsonPath('attributes.egg_tags', []); + + $server->egg->tags()->attach(Tag::factory()->create(['name' => 'Minecraft', 'slug' => 'minecraft'])); + $this->actingAs($user)->getJson($this->link($server))->assertOk()->assertJsonPath('attributes.egg_tags', ['minecraft']); +}); +test('subuser permissions are returned in meta', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value, Permissions::WebsocketConnect->value]); + $response = $this->actingAs($user)->getJson($this->link($server))->assertOk()->assertJsonPath('meta.is_server_owner', false); + expect($response->json('meta.user_permissions'))->toEqualCanonicalizing([Permissions::ControlConsole->value, Permissions::WebsocketConnect->value]); +}); +test('unrelated user cannot view the server', function () { + [, $server] = $this->generateTestAccount(); + [$other] = $this->generateTestAccount(); + $this->getJson($this->link($server))->assertUnauthorized(); + $this->actingAs($other)->getJson($this->link($server))->assertNotFound(); +}); diff --git a/tests/Integration/Api/Client/Server/LogControllerTest.php b/tests/Integration/Api/Client/Server/LogControllerTest.php new file mode 100644 index 000000000..8f61b0494 --- /dev/null +++ b/tests/Integration/Api/Client/Server/LogControllerTest.php @@ -0,0 +1,81 @@ +generateTestAccount(); + $fake = new FakeDaemonServer; + $this->getJson($this->link($server, '/logs'))->assertUnauthorized(); + $fake->assertNothingHappened(); +}); +test('subuser without the websocket permission cannot read logs', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $fake = new FakeDaemonServer; + $this->actingAs($user)->getJson($this->link($server, '/logs'))->assertForbidden(); + $fake->assertNothingHappened(); +}); +test('user cannot read logs of a server they cannot access', function () { + [$user] = $this->generateTestAccount(); + [, $server] = $this->generateTestAccount(); + $fake = new FakeDaemonServer; + $this->actingAs($user)->getJson($this->link($server, '/logs'))->assertNotFound(); + $fake->assertNothingHappened(); +}); +test('server logs are returned', function (array $permissions) { + [$user, $server] = $this->generateTestAccount($permissions); + $fake = new FakeDaemonServer; + $fake->logs = ['[12:00:00] Starting server', '[12:00:04] Done']; + $response = $this->actingAs($user)->getJson($this->link($server, '/logs')); + $response->assertOk(); + $response->assertExactJson(['object' => 'server_logs', 'attributes' => ['lines' => ['[12:00:00] Starting server', '[12:00:04] Done']]]); + $fake->assertLogsRead(ReadsServerLogs::MAX_LINES); + expect($fake->callsFor('getLogs')[0]['server_uuid'])->toBe($server->uuid); +})->with([ + 'server owner' => [[]], + 'subuser with the websocket permission' => [[Permissions::WebsocketConnect->value]], +]); +test('requested line count is passed to wings', function () { + [$user, $server] = $this->generateTestAccount(); + $fake = new FakeDaemonServer; + $this->actingAs($user)->getJson($this->link($server, '/logs?lines=25'))->assertOk()->assertJsonPath('attributes.lines', []); + $fake->assertLogsRead(25); +}); +test('line count is validated', function (string $lines, string $rule) { + [$user, $server] = $this->generateTestAccount(); + $fake = new FakeDaemonServer; + $response = $this->actingAs($user)->getJson($this->link($server, '/logs?lines='.$lines)); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.source_field', 'lines'); + $response->assertJsonPath('errors.0.meta.rule', $rule); + $fake->assertNothingHappened(); +})->with([ + 'zero' => ['0', 'min'], + 'negative' => ['-5', 'min'], + 'above the maximum' => ['101', 'max'], + 'not a number' => ['all', 'integer'], +]); +test('a server without console output returns no lines', function () { + [$user, $server] = $this->generateTestAccount(); + $fake = new FakeDaemonServer; + $fake->logs = null; + $this->actingAs($user)->getJson($this->link($server, '/logs'))->assertOk()->assertJsonPath('attributes.lines', []); +}); +test('error is returned when wings cannot be reached', function () { + [$user, $server] = $this->generateTestAccount(); + $fake = new FakeDaemonServer; + $fake->throwable = new DaemonConnectionException(Http::failedRequest([], Response::HTTP_BAD_GATEWAY)); + $response = $this->actingAs($user)->getJson($this->link($server, '/logs')); + $response->assertStatus(Response::HTTP_BAD_GATEWAY); + $response->assertJsonPath('errors.0.code', 'DaemonConnectionException'); +}); diff --git a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php index 0fc9a865b..0934a4a2f 100644 --- a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php +++ b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php @@ -1,137 +1,80 @@ generateTestAccount(); +uses(ClientApiIntegrationTestCase::class); +dataset('updatePermissionsDataProvider', fn (): array => [[[]], [[Permissions::AllocationUpdate->value]]]); +test('server allocations are returned', function (): void { + [$user, $server] = $this->generateTestAccount(); + $response = $this->actingAs($user)->getJson($this->link($server, '/network/allocations')); + $response->assertOk(); + $response->assertJsonPath('object', 'list'); + $response->assertJsonCount(1, 'data'); - $response = $this->actingAs($user)->getJson($this->link($server, '/network/allocations')); - - $response->assertOk(); - $response->assertJsonPath('object', 'list'); - $response->assertJsonCount(1, 'data'); - - $this->assertJsonTransformedWith($response->json('data.0.attributes'), $server->allocation); - } - - /** - * Test that allocations cannot be returned without the required user permissions. - */ - public function testServerAllocationsAreNotReturnedWithoutPermission() - { - [$user, $server] = $this->generateTestAccount(); - $user2 = User::factory()->create(); - - $server->owner_id = $user2->id; - $server->save(); - - $this->actingAs($user)->getJson($this->link($server, '/network/allocations')) - ->assertNotFound(); - - [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]); - - $this->actingAs($user)->getJson($this->link($server, '/network/allocations')) - ->assertForbidden(); - } - - /** - * Tests that notes on an allocation can be set correctly. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('updatePermissionsDataProvider')] - public function testAllocationNotesCanBeUpdated(array $permissions) - { - [$user, $server] = $this->generateTestAccount($permissions); - $allocation = $server->allocation; - - $this->assertNull($allocation->notes); - - $this->actingAs($user)->postJson($this->link($allocation), []) - ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.meta.rule', 'present'); - - $this->actingAs($user)->postJson($this->link($allocation), ['notes' => 'Test notes']) - ->assertOk() - ->assertJsonPath('object', Allocation::RESOURCE_NAME) - ->assertJsonPath('attributes.notes', 'Test notes'); - - $allocation = $allocation->refresh(); - - $this->assertSame('Test notes', $allocation->notes); - - $this->actingAs($user)->postJson($this->link($allocation), ['notes' => null]) - ->assertOk() - ->assertJsonPath('object', Allocation::RESOURCE_NAME) - ->assertJsonPath('attributes.notes', null); - - $allocation = $allocation->refresh(); - - $this->assertNull($allocation->notes); - } - - public function testAllocationNotesCannotBeUpdatedByInvalidUsers() - { - [$user, $server] = $this->generateTestAccount(); - $user2 = User::factory()->create(); - - $server->owner_id = $user2->id; - $server->save(); - - $this->actingAs($user)->postJson($this->link($server->allocation))->assertNotFound(); - - [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]); - - $this->actingAs($user)->postJson($this->link($server->allocation))->assertForbidden(); - } - - #[\PHPUnit\Framework\Attributes\DataProvider('updatePermissionsDataProvider')] - public function testPrimaryAllocationCanBeModified(array $permissions) - { - [$user, $server] = $this->generateTestAccount($permissions); - $allocation = $server->allocation; - $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); - - $server->allocation_id = $allocation->id; - $server->save(); - - $this->actingAs($user)->postJson($this->link($allocation2, '/primary')) - ->assertOk(); - - $server = $server->refresh(); - - $this->assertSame($allocation2->id, $server->allocation_id); - } - - public function testPrimaryAllocationCannotBeModifiedByInvalidUser() - { - [$user, $server] = $this->generateTestAccount(); - $user2 = User::factory()->create(); - - $server->owner_id = $user2->id; - $server->save(); - - $this->actingAs($user)->postJson($this->link($server->allocation, '/primary')) - ->assertNotFound(); - - [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]); - - $this->actingAs($user)->postJson($this->link($server->allocation, '/primary')) - ->assertForbidden(); - } - - public static function updatePermissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_ALLOCATION_UPDATE]]]; - } -} + $allocation = $server->allocation; + expect($response->json('data.0.attributes'))->toBe([ + 'id' => $allocation->id, + 'ip' => $allocation->ip, + 'ip_alias' => $allocation->ip_alias, + 'port' => $allocation->port, + 'notes' => null, + 'is_default' => true, + ]); +}); +test('server allocations are not returned without permission', function (): void { + [$user, $server] = $this->generateTestAccount(); + $user2 = User::factory()->create(); + $server->owner_id = $user2->id; + $server->save(); + $this->actingAs($user)->getJson($this->link($server, '/network/allocations'))->assertNotFound(); + [$user, $server] = $this->generateTestAccount([Permissions::AllocationCreate->value]); + $this->actingAs($user)->getJson($this->link($server, '/network/allocations'))->assertForbidden(); +}); +test('allocation notes can be updated', function (array $permissions): void { + [$user, $server] = $this->generateTestAccount($permissions); + $allocation = $server->allocation; + expect($allocation->notes)->toBeNull(); + $this->actingAs($user)->postJson($this->link($allocation), [])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.rule', 'present'); + $this->actingAs($user)->postJson($this->link($allocation), ['notes' => 'Test notes'])->assertOk()->assertJsonPath('object', Allocation::RESOURCE_NAME)->assertJsonPath('attributes.notes', 'Test notes'); + $allocation = $allocation->refresh(); + expect($allocation->notes)->toBe('Test notes'); + $this->actingAs($user)->postJson($this->link($allocation), ['notes' => null])->assertOk()->assertJsonPath('object', Allocation::RESOURCE_NAME)->assertJsonPath('attributes.notes', null); + $allocation = $allocation->refresh(); + expect($allocation->notes)->toBeNull(); +})->with('updatePermissionsDataProvider'); +test('allocation notes cannot be updated by invalid users', function (): void { + [$user, $server] = $this->generateTestAccount(); + $user2 = User::factory()->create(); + $server->owner_id = $user2->id; + $server->save(); + $this->actingAs($user)->postJson($this->link($server->allocation))->assertNotFound(); + [$user, $server] = $this->generateTestAccount([Permissions::AllocationCreate->value]); + $this->actingAs($user)->postJson($this->link($server->allocation))->assertForbidden(); +}); +test('primary allocation can be modified', function (array $permissions): void { + [$user, $server] = $this->generateTestAccount($permissions); + $allocation = $server->allocation; + $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); + $server->allocation_id = $allocation->id; + $server->save(); + $this->actingAs($user)->postJson($this->link($allocation2, '/primary'))->assertOk(); + $server = $server->refresh(); + expect($server->allocation_id)->toBe($allocation2->id); +})->with('updatePermissionsDataProvider'); +test('primary allocation cannot be modified by invalid user', function (): void { + [$user, $server] = $this->generateTestAccount(); + $user2 = User::factory()->create(); + $server->owner_id = $user2->id; + $server->save(); + $this->actingAs($user)->postJson($this->link($server->allocation, '/primary'))->assertNotFound(); + [$user, $server] = $this->generateTestAccount([Permissions::AllocationCreate->value]); + $this->actingAs($user)->postJson($this->link($server->allocation, '/primary'))->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index 54daa0e60..5917e3e55 100644 --- a/tests/Integration/Api/Client/Server/PowerControllerTest.php +++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php @@ -1,97 +1,48 @@ generateTestAccount($permissions); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/power", ['signal' => $action]) - ->assertStatus(Response::HTTP_FORBIDDEN); - } - - /** - * Test that sending an invalid power signal returns an error. - */ - public function testInvalidPowerSignalResultsInError() - { - [$user, $server] = $this->generateTestAccount(); - - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/power", [ - 'signal' => 'invalid', - ]); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.meta.rule', 'in'); - $response->assertJsonPath('errors.0.detail', 'The selected signal is invalid.'); - } - - /** - * Test that sending a valid power actions works. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('validPowerActionDataProvider')] - public function testActionCanBeSentToServer(string $action, string $permission) - { - $service = \Mockery::mock(DaemonPowerRepository::class); - $this->app->instance(DaemonPowerRepository::class, $service); - - [$user, $server] = $this->generateTestAccount([$permission]); - - $service->expects('setServer') - ->with(\Mockery::on(function ($value) use ($server) { - return $server->uuid === $value->uuid; - })) - ->andReturnSelf() - ->getMock() - ->expects('send') - ->with(trim($action)); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/power", ['signal' => $action]) - ->assertStatus(Response::HTTP_NO_CONTENT); - } - - /** - * Returns invalid permission combinations for a given power action. - */ - public static function invalidPermissionDataProvider(): array - { - return [ - ['start', [Permission::ACTION_CONTROL_STOP, Permission::ACTION_CONTROL_RESTART]], - ['stop', [Permission::ACTION_CONTROL_START]], - ['kill', [Permission::ACTION_CONTROL_START, Permission::ACTION_CONTROL_RESTART]], - ['restart', [Permission::ACTION_CONTROL_STOP, Permission::ACTION_CONTROL_START]], - ['random', [Permission::ACTION_CONTROL_START]], - ]; - } - - public static function validPowerActionDataProvider(): array - { - return [ - ['start', Permission::ACTION_CONTROL_START], - ['stop', Permission::ACTION_CONTROL_STOP], - ['restart', Permission::ACTION_CONTROL_RESTART], - ['kill', Permission::ACTION_CONTROL_STOP], - // Yes, these spaces are intentional. You should be able to send values with or without - // a space on the start/end since we should be trimming the values. - [' restart', Permission::ACTION_CONTROL_RESTART], - ['kill ', Permission::ACTION_CONTROL_STOP], - ]; - } -} +uses(ClientApiIntegrationTestCase::class); +/** + * Returns invalid permission combinations for a given power action. + */ +dataset('invalidPermissionDataProvider', function () { + return [['start', [Permissions::ControlStop->value, Permissions::ControlRestart->value]], ['stop', [Permissions::ControlStart->value]], ['kill', [Permissions::ControlStart->value, Permissions::ControlRestart->value]], ['restart', [Permissions::ControlStop->value, Permissions::ControlStart->value]], ['random', [Permissions::ControlStart->value]]]; +}); +dataset('validPowerActionDataProvider', function () { + return [ + ['start', Permissions::ControlStart->value], + ['stop', Permissions::ControlStop->value], + ['restart', Permissions::ControlRestart->value], + ['kill', Permissions::ControlStop->value], + // Yes, these spaces are intentional. You should be able to send values with or without + // a space on the start/end since we should be trimming the values. + [' restart', Permissions::ControlRestart->value], + ['kill ', Permissions::ControlStop->value], + ]; +}); +test('subuser without permissions receives error', function (string $action, array $permissions) { + [$user, $server] = $this->generateTestAccount($permissions); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/power", ['signal' => $action])->assertStatus(Response::HTTP_FORBIDDEN); +})->with('invalidPermissionDataProvider'); +test('invalid power signal results in error', function () { + [$user, $server] = $this->generateTestAccount(); + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/power", ['signal' => 'invalid']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.rule', 'in'); + $response->assertJsonPath('errors.0.detail', 'The selected signal is invalid.'); +}); +test('action can be sent to server', function (string $action, string $permission) { + $fake = new FakeDaemonPower; + [$user, $server] = $this->generateTestAccount([$permission]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/power", ['signal' => $action])->assertStatus(Response::HTTP_NO_CONTENT); + $fake->assertSentTo(mb_trim($action), $server->uuid); +})->with('validPowerActionDataProvider'); diff --git a/tests/Integration/Api/Client/Server/ResourceUtilizationControllerTest.php b/tests/Integration/Api/Client/Server/ResourceUtilizationControllerTest.php index 82c1a442f..7711a4bdd 100644 --- a/tests/Integration/Api/Client/Server/ResourceUtilizationControllerTest.php +++ b/tests/Integration/Api/Client/Server/ResourceUtilizationControllerTest.php @@ -1,43 +1,53 @@ app->instance(DaemonServerRepository::class, $service); - - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - - $service->expects('setServer')->with(\Mockery::on(function ($value) use ($server) { - return $server->uuid === $value->uuid; - }))->andReturnSelf()->getMock()->expects('getDetails')->andReturns([]); - - $response = $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/resources"); - - $response->assertOk(); - $response->assertJson([ - 'object' => 'stats', - 'attributes' => [ - 'current_state' => 'stopped', - 'is_suspended' => false, - 'resources' => [ - 'memory_bytes' => 0, - 'cpu_absolute' => 0, - 'disk_bytes' => 0, - 'network_rx_bytes' => 0, - 'network_tx_bytes' => 0, - ], - ], - ]); - } -} +uses(ClientApiIntegrationTestCase::class); +test('server resource utilization is returned', function () { + $fake = new FakeDaemonServer; + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $fake->details = []; + $response = $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/resources"); + $response->assertOk(); + $response->assertJson(['object' => 'stats', 'attributes' => ['current_state' => 'stopped', 'is_suspended' => false, 'resources' => ['memory_bytes' => 0, 'cpu_absolute' => 0, 'disk_bytes' => 0, 'network_rx_bytes' => 0, 'network_tx_bytes' => 0]]]); + $fake->assertDetailsFetched(); +}); +test('non-empty daemon payload passes through', function () { + $fake = new FakeDaemonServer; + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $fake->details = ['state' => 'running', 'utilization' => ['memory_bytes' => 1048576, 'cpu_absolute' => 12.5, 'disk_bytes' => 5242880, 'network' => ['rx_bytes' => 100, 'tx_bytes' => 200], 'uptime' => 3600]]; + $response = $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/resources"); + $response->assertOk(); + $response->assertJsonPath('attributes.current_state', 'running'); + $response->assertJsonPath('attributes.resources.memory_bytes', 1048576); + $response->assertJsonPath('attributes.resources.cpu_absolute', 12.5); + $response->assertJsonPath('attributes.resources.network_rx_bytes', 100); + $response->assertJsonPath('attributes.resources.network_tx_bytes', 200); + $fake->assertDetailsFetched(); +}); +test('resource utilization is cached between requests', function () { + $fake = new FakeDaemonServer; + [$user, $server] = $this->generateTestAccount(); + $fake->details = ['state' => 'running']; + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/resources")->assertOk()->assertJsonPath('attributes.current_state', 'running'); + $fake->details = ['state' => 'offline']; + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/resources")->assertOk()->assertJsonPath('attributes.current_state', 'running'); + expect($fake->callsFor('getDetails'))->toHaveCount(1); + $this->travel(21)->seconds(); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/resources")->assertOk()->assertJsonPath('attributes.current_state', 'offline'); +}); +test('error is returned when wings cannot report resource utilization', function () { + $fake = new FakeDaemonServer; + [$user, $server] = $this->generateTestAccount(); + $fake->throwable = new DaemonConnectionException(Http::failedRequest([], Response::HTTP_BAD_GATEWAY)); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/resources")->assertStatus(Response::HTTP_BAD_GATEWAY)->assertJsonPath('errors.0.code', 'DaemonConnectionException'); +}); diff --git a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php index 26ab866e0..a46b8657d 100644 --- a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php @@ -1,95 +1,65 @@ generateTestAccount($permissions); +uses(ClientApiIntegrationTestCase::class); +dataset('permissionsDataProvider', fn (): array => [[[]], [[Permissions::ScheduleCreate->value]]]); +test('schedule can be created for server', function (array $permissions): void { + [$user, $server] = $this->generateTestAccount($permissions); + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", ['name' => 'Test Schedule', 'is_active' => false, 'minute' => '0', 'hour' => '*/2', 'day_of_week' => '2', 'month' => '1', 'day_of_month' => '*']); + $response->assertOk(); - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/schedules", [ - 'name' => 'Test Schedule', - 'is_active' => false, - 'minute' => '0', - 'hour' => '*/2', - 'day_of_week' => '2', - 'month' => '1', - 'day_of_month' => '*', - ]); - - $response->assertOk(); - - $this->assertNotNull($id = $response->json('attributes.id')); - - /** @var Schedule $schedule */ - $schedule = Schedule::query()->findOrFail($id); - $this->assertFalse($schedule->is_active); - $this->assertFalse($schedule->is_processing); - $this->assertSame('0', $schedule->cron_minute); - $this->assertSame('*/2', $schedule->cron_hour); - $this->assertSame('2', $schedule->cron_day_of_week); - $this->assertSame('1', $schedule->cron_month); - $this->assertSame('*', $schedule->cron_day_of_month); - $this->assertSame('Test Schedule', $schedule->name); - - $this->assertJsonTransformedWith($response->json('attributes'), $schedule); - $response->assertJsonCount(0, 'attributes.relationships.tasks.data'); + expect($id = $response->json('attributes.id'))->not->toBeNull(); + /** @var Schedule $schedule */ + $schedule = Schedule::query()->findOrFail($id); + expect($schedule->is_active)->toBeFalse(); + expect($schedule->is_processing)->toBeFalse(); + expect($schedule->cron_minute)->toBe('0'); + expect($schedule->cron_hour)->toBe('*/2'); + expect($schedule->cron_day_of_week)->toBe('2'); + expect($schedule->cron_month)->toBe('1'); + expect($schedule->cron_day_of_month)->toBe('*'); + expect($schedule->name)->toBe('Test Schedule'); + expect(collect($response->json('attributes'))->except('relationships')->all())->toBe([ + 'id' => $schedule->id, + 'name' => $schedule->name, + 'cron' => [ + 'day_of_week' => $schedule->cron_day_of_week, + 'day_of_month' => $schedule->cron_day_of_month, + 'month' => $schedule->cron_month, + 'hour' => $schedule->cron_hour, + 'minute' => $schedule->cron_minute, + ], + 'is_active' => $schedule->is_active, + 'is_processing' => $schedule->is_processing, + 'only_when_online' => $schedule->only_when_online, + 'last_run_at' => $schedule->last_run_at?->toAtomString(), + 'next_run_at' => $schedule->next_run_at?->toAtomString(), + 'created_at' => $schedule->created_at->toAtomString(), + 'updated_at' => $schedule->updated_at->toAtomString(), + ]); + $response->assertJsonCount(0, 'attributes.relationships.tasks.data'); +})->with('permissionsDataProvider'); +test('schedule validation rules', function (): void { + [$user, $server] = $this->generateTestAccount(); + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", []); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + foreach (['name', 'minute', 'hour', 'day_of_month', 'month', 'day_of_week'] as $i => $field) { + $response->assertJsonPath("errors.{$i}.code", 'ValidationException'); + $response->assertJsonPath("errors.{$i}.meta.rule", 'required'); + $response->assertJsonPath("errors.{$i}.meta.source_field", $field); } - /** - * Test that the validation rules for scheduling work as expected. - */ - public function testScheduleValidationRules() - { - [$user, $server] = $this->generateTestAccount(); - - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/schedules", []); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - foreach (['name', 'minute', 'hour', 'day_of_month', 'day_of_week'] as $i => $field) { - $response->assertJsonPath("errors.$i.code", 'ValidationException'); - $response->assertJsonPath("errors.$i.meta.rule", 'required'); - $response->assertJsonPath("errors.$i.meta.source_field", $field); - } - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/schedules", [ - 'name' => 'Testing', - 'is_active' => 'no', - 'minute' => '*', - 'hour' => '*', - 'day_of_month' => '*', - 'month' => '*', - 'day_of_week' => '*', - ]) - ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.meta.rule', 'boolean'); - } - - /** - * Test that a subuser without required permissions cannot create a schedule. - */ - public function testSubuserCannotCreateScheduleWithoutPermissions() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/schedules", []) - ->assertForbidden(); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_SCHEDULE_CREATE]]]; - } -} + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", ['name' => 'Testing', 'is_active' => 'no', 'minute' => '*', 'hour' => '*', 'day_of_month' => '*', 'month' => '*', 'day_of_week' => '*'])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.rule', 'boolean'); +}); +test('subuser cannot create schedule without permissions', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", [])->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php index c204ff4f5..b79431036 100644 --- a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php @@ -1,83 +1,41 @@ generateTestAccount($permissions); - - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - $task = Task::factory()->create(['schedule_id' => $schedule->id]); - - $this->actingAs($user) - ->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id") - ->assertStatus(Response::HTTP_NO_CONTENT); - - $this->assertDatabaseMissing('schedules', ['id' => $schedule->id]); - $this->assertDatabaseMissing('tasks', ['id' => $task->id]); - } - - /** - * Test that no error is returned if the schedule does not exist on the system at all. - */ - public function testNotFoundErrorIsReturnedIfScheduleDoesNotExistAtAll() - { - [$user, $server] = $this->generateTestAccount(); - - $this->actingAs($user) - ->deleteJson("/api/client/servers/$server->uuid/schedules/123456789") - ->assertStatus(Response::HTTP_NOT_FOUND); - } - - /** - * Ensure that a schedule belonging to another server cannot be deleted and its presence is not - * revealed to the user. - */ - public function testNotFoundErrorIsReturnedIfScheduleDoesNotBelongToServer() - { - [$user, $server] = $this->generateTestAccount(); - $server2 = $this->createServerModel(['owner_id' => $user->id]); - - $schedule = Schedule::factory()->create(['server_id' => $server2->id]); - - $this->actingAs($user) - ->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id") - ->assertStatus(Response::HTTP_NOT_FOUND); - - $this->assertDatabaseHas('schedules', ['id' => $schedule->id]); - } - - /** - * Test that an error is returned if the subuser does not have the required permissions to - * delete the schedule from the server. - */ - public function testErrorIsReturnedIfSubuserDoesNotHaveRequiredPermissions() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]); - - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $this->actingAs($user) - ->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id") - ->assertStatus(Response::HTTP_FORBIDDEN); - - $this->assertDatabaseHas('schedules', ['id' => $schedule->id]); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_SCHEDULE_DELETE]]]; - } -} +uses(ClientApiIntegrationTestCase::class); +dataset('permissionsDataProvider', function () { + return [[[]], [[Permissions::ScheduleDelete->value]]]; +}); +test('schedule can be deleted', function (array $permissions) { + [$user, $server] = $this->generateTestAccount($permissions); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); + $this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseMissing('schedules', ['id' => $schedule->id]); + $this->assertDatabaseMissing('tasks', ['id' => $task->id]); +})->with('permissionsDataProvider'); +test('not found error is returned if schedule does not exist at all', function () { + [$user, $server] = $this->generateTestAccount(); + $this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/123456789")->assertStatus(Response::HTTP_NOT_FOUND); +}); +test('not found error is returned if schedule does not belong to server', function () { + [$user, $server] = $this->generateTestAccount(); + $server2 = $this->createServerModel(['owner_id' => $user->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); + $this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")->assertStatus(Response::HTTP_NOT_FOUND); + $this->assertDatabaseHas('schedules', ['id' => $schedule->id]); +}); +test('error is returned if subuser does not have required permissions', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")->assertStatus(Response::HTTP_FORBIDDEN); + $this->assertDatabaseHas('schedules', ['id' => $schedule->id]); +}); diff --git a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php index eafcf3c05..57c52f8d9 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php @@ -1,70 +1,44 @@ generateTestAccount($permissions); +uses(ClientApiIntegrationTestCase::class); +dataset('permissionsDataProvider', function () { + return [[[]], [[Permissions::ScheduleUpdate->value]]]; +}); +test('schedule is executed right away', function (array $permissions) { + [$user, $server] = $this->generateTestAccount($permissions); + Bus::fake(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $response = $this->actingAs($user)->postJson($this->link($schedule, '/execute')); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'DisplayException'); + $response->assertJsonPath('errors.0.detail', 'Cannot process schedule for task execution: no tasks are registered.'); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 2]); + $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertStatus(Response::HTTP_ACCEPTED); + Bus::assertDispatched(function (RunTaskJob $job) use ($task) { + // A task executed right now should not have any job delay associated with it. + expect($job->delay)->toBeNull(); + expect($job->task->id)->toBe($task->id); - Bus::fake(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create([ - 'server_id' => $server->id, - ]); - - $response = $this->actingAs($user)->postJson($this->link($schedule, '/execute')); - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'DisplayException'); - $response->assertJsonPath('errors.0.detail', 'Cannot process schedule for task execution: no tasks are registered.'); - - /** @var Task $task */ - $task = Task::factory()->create([ - 'schedule_id' => $schedule->id, - 'sequence_id' => 1, - 'time_offset' => 2, - ]); - - $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertStatus(Response::HTTP_ACCEPTED); - - Bus::assertDispatched(function (RunTaskJob $job) use ($task) { - // A task executed right now should not have any job delay associated with it. - $this->assertNull($job->delay); - $this->assertSame($task->id, $job->task->id); - - return true; - }); - } - - /** - * Test that a user without the schedule update permission cannot execute it. - */ - public function testUserWithoutScheduleUpdatePermissionCannotExecute() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden(); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; - } -} + return true; + }); +})->with('permissionsDataProvider'); +test('user without schedule update permission cannot execute', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleCreate->value]); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index cc5db4139..5fd16662d 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -1,100 +1,78 @@ forceDelete(); - Schedule::query()->forceDelete(); - - parent::tearDown(); +uses(ClientApiIntegrationTestCase::class); +/** + * Cleanup after tests run. + */ +afterEach(function (): void { + Task::query()->forceDelete(); + Schedule::query()->forceDelete(); +}); +dataset('permissionsDataProvider', fn (): array => [[[], false], [[], true], [[Permissions::ScheduleRead->value], false], [[Permissions::ScheduleRead->value], true]]); +test('server schedules are returned', function (array $permissions, bool $individual): void { + [$user, $server] = $this->generateTestAccount($permissions); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]); + $response = $this->actingAs($user)->getJson($individual ? "/api/client/servers/{$server->uuid}/schedules/{$schedule->id}" : "/api/client/servers/{$server->uuid}/schedules")->assertOk(); + $prefix = $individual ? '' : 'data.0.'; + if (! $individual) { + $response->assertJsonCount(1, 'data'); } - /** - * Test that schedules for a server are returned. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] - public function testServerSchedulesAreReturned(array $permissions, bool $individual) - { - [$user, $server] = $this->generateTestAccount($permissions); + $response->assertJsonCount(1, $prefix.'attributes.relationships.tasks.data'); + $response->assertJsonPath($prefix.'object', Schedule::RESOURCE_NAME); + $response->assertJsonPath($prefix.'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - /** @var Task $task */ - $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]); - - $response = $this->actingAs($user) - ->getJson( - $individual - ? "/api/client/servers/$server->uuid/schedules/$schedule->id" - : "/api/client/servers/$server->uuid/schedules" - ) - ->assertOk(); - - $prefix = $individual ? '' : 'data.0.'; - if (!$individual) { - $response->assertJsonCount(1, 'data'); - } - - $response->assertJsonCount(1, $prefix . 'attributes.relationships.tasks.data'); - - $response->assertJsonPath($prefix . 'object', Schedule::RESOURCE_NAME); - $response->assertJsonPath($prefix . 'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); - - $this->assertJsonTransformedWith($response->json($prefix . 'attributes'), $schedule); - $this->assertJsonTransformedWith($response->json($prefix . 'attributes.relationships.tasks.data.0.attributes'), $task); - } - - /** - * Test that a schedule belonging to another server cannot be viewed. - */ - public function testScheduleBelongingToAnotherServerCannotBeViewed() - { - [$user, $server] = $this->generateTestAccount(); - $server2 = $this->createServerModel(['owner_id' => $user->id]); - - $schedule = Schedule::factory()->create(['server_id' => $server2->id]); - - $this->actingAs($user) - ->getJson("/api/client/servers/$server->uuid/schedules/$schedule->id") - ->assertNotFound(); - } - - /** - * Test that a subuser without the required permissions is unable to access the schedules endpoint. - */ - public function testUserWithoutPermissionCannotViewSchedules() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - - $this->actingAs($user) - ->getJson("/api/client/servers/$server->uuid/schedules") - ->assertForbidden(); - - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $this->actingAs($user) - ->getJson("/api/client/servers/$server->uuid/schedules/$schedule->id") - ->assertForbidden(); - } - - public static function permissionsDataProvider(): array - { - return [ - [[], false], - [[], true], - [[Permission::ACTION_SCHEDULE_READ], false], - [[Permission::ACTION_SCHEDULE_READ], true], - ]; - } -} + expect(collect($response->json($prefix.'attributes'))->except('relationships')->all())->toBe([ + 'id' => $schedule->id, + 'name' => $schedule->name, + 'cron' => [ + 'day_of_week' => $schedule->cron_day_of_week, + 'day_of_month' => $schedule->cron_day_of_month, + 'month' => $schedule->cron_month, + 'hour' => $schedule->cron_hour, + 'minute' => $schedule->cron_minute, + ], + 'is_active' => $schedule->is_active, + 'is_processing' => $schedule->is_processing, + 'only_when_online' => $schedule->only_when_online, + 'last_run_at' => $schedule->last_run_at?->toAtomString(), + 'next_run_at' => $schedule->next_run_at?->toAtomString(), + 'created_at' => $schedule->created_at->toAtomString(), + 'updated_at' => $schedule->updated_at->toAtomString(), + ]); + expect($response->json($prefix.'attributes.relationships.tasks.data.0.attributes'))->toBe([ + 'id' => $task->id, + 'sequence_id' => $task->sequence_id, + 'action' => $task->action, + 'payload' => $task->payload, + 'time_offset' => $task->time_offset, + 'is_queued' => $task->is_queued, + 'continue_on_failure' => $task->continue_on_failure, + 'created_at' => $task->created_at->toAtomString(), + 'updated_at' => $task->updated_at->toAtomString(), + ]); +})->with('permissionsDataProvider'); +test('schedule belonging to another server cannot be viewed', function (): void { + [$user, $server] = $this->generateTestAccount(); + $server2 = $this->createServerModel(['owner_id' => $user->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")->assertNotFound(); +}); +test('user without permission cannot view schedules', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/schedules")->assertForbidden(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php index 26a83de4c..9b5054db0 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -1,66 +1,53 @@ generateTestAccount(); - // Will be a subuser of $server2. - $server2 = $this->createServerModel(); - // And as no access to $server3. - $server3 = $this->createServerModel(); - - // Set the API $user as a subuser of server 2, but with no permissions - // to do anything with the schedules for that server. - Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); - - $schedule1 = Schedule::factory()->create(['server_id' => $server1->id]); - $schedule2 = Schedule::factory()->create(['server_id' => $server2->id]); - $schedule3 = Schedule::factory()->create(['server_id' => $server3->id]); - - // This is the only valid call for this test, accessing the schedule for the same - // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule1->id . $endpoint)); - $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); - - // This request fails because the schedule is valid for that server but the user - // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule2->id . $endpoint))->assertForbidden(); - - // Both of these should report a 404 error due to the schedules being linked to - // servers that are not the same as the server in the request, or are assigned - // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); - } - - public static function methodDataProvider(): array - { - return [ - ['GET', ''], - ['POST', ''], - ['DELETE', ''], - ['POST', '/execute'], - ['POST', '/tasks'], - ]; - } -} +uses(ClientApiIntegrationTestCase::class); +dataset('methodDataProvider', function () { + return [['GET', ''], ['POST', ''], ['DELETE', ''], ['POST', '/execute'], ['POST', '/tasks']]; +}); +test('access to a servers schedules is restricted properly', function (string $method, string $endpoint) { + // The API $user is the owner of $server1. + [$user, $server1] = $this->generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the schedules for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + $schedule1 = Schedule::factory()->create(['server_id' => $server1->id]); + $schedule2 = Schedule::factory()->create(['server_id' => $server2->id]); + $schedule3 = Schedule::factory()->create(['server_id' => $server3->id]); + // This is the only valid call for this test, accessing the schedule for the same + // server that the API user is the owner of. Each variant sends a valid body so + // the expected status proves authorization passed, not just validation. + $body = match (true) { + $method === 'POST' && $endpoint === '' => ['name' => 'Test', 'minute' => '*', 'hour' => '*', 'day_of_month' => '*', 'month' => '*', 'day_of_week' => '*'], + $method === 'POST' && $endpoint === '/tasks' => ['action' => 'command', 'payload' => 'test', 'time_offset' => 0], + default => [], + }; + $expected = match (true) { + $method === 'DELETE' => 204, + // Empty schedule: passes auth, service rejects with "no tasks are registered". + $method === 'POST' && $endpoint === '/execute' => 400, + default => 200, + }; + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule1->id.$endpoint), $body)->assertStatus($expected); + // This request fails because the schedule is valid for that server but the user + // making the request is not authorized to perform that action. + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule2->id.$endpoint))->assertForbidden(); + // Both of these should report a 404 error due to the schedules being linked to + // servers that are not the same as the server in the request, or are assigned + // to a server for which the user making the request has no access to. + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); +})->with('methodDataProvider'); diff --git a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php index 6b6ad1091..4c75ca2c9 100644 --- a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php @@ -1,115 +1,70 @@ 'Updated Schedule Name', - 'minute' => '5', - 'hour' => '*', - 'day_of_week' => '*', - 'month' => '*', - 'day_of_month' => '*', - 'is_active' => false, - ]; +uses(ClientApiIntegrationTestCase::class); +beforeEach(function (): void { + $this->updateData = ['name' => 'Updated Schedule Name', 'minute' => '5', 'hour' => '*', 'day_of_week' => '*', 'month' => '*', 'day_of_month' => '*', 'is_active' => false]; +}); +dataset('permissionsDataProvider', fn (): array => [[[]], [[Permissions::ScheduleUpdate->value]]]); +test('schedule can be updated', function (array $permissions): void { + [$user, $server] = $this->generateTestAccount($permissions); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*', '*'); + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", $this->updateData); + $schedule = $schedule->refresh(); + $response->assertOk(); + expect($schedule->name)->toBe('Updated Schedule Name'); + expect($schedule->is_active)->toBeFalse(); + expect(collect($response->json('attributes'))->except('relationships')->all())->toBe([ + 'id' => $schedule->id, + 'name' => $schedule->name, + 'cron' => [ + 'day_of_week' => $schedule->cron_day_of_week, + 'day_of_month' => $schedule->cron_day_of_month, + 'month' => $schedule->cron_month, + 'hour' => $schedule->cron_hour, + 'minute' => $schedule->cron_minute, + ], + 'is_active' => $schedule->is_active, + 'is_processing' => $schedule->is_processing, + 'only_when_online' => $schedule->only_when_online, + 'last_run_at' => $schedule->last_run_at?->toAtomString(), + 'next_run_at' => $schedule->next_run_at?->toAtomString(), + 'created_at' => $schedule->created_at->toAtomString(), + 'updated_at' => $schedule->updated_at->toAtomString(), + ]); + expect($schedule->next_run_at->toAtomString())->toBe($expected->toAtomString()); +})->with('permissionsDataProvider'); +test('error is returned if schedule does not belong to server', function (): void { + [$user, $server] = $this->generateTestAccount(); + $server2 = $this->createServerModel(['owner_id' => $user->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")->assertNotFound(); +}); +test('error is returned if subuser does not have permission to modify schedule', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleCreate->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")->assertForbidden(); +}); +test('schedule is processing is set to false when active state changes', function (): void { + [$user, $server] = $this->generateTestAccount(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id, 'is_active' => true, 'is_processing' => true]); + expect($schedule->is_active)->toBeTrue(); + expect($schedule->is_processing)->toBeTrue(); - /** - * Test that a schedule can be updated. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] - public function testScheduleCanBeUpdated(array $permissions) - { - [$user, $server] = $this->generateTestAccount($permissions); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - $expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*', '*'); - - $response = $this->actingAs($user) - ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", $this->updateData); - - $schedule = $schedule->refresh(); - - $response->assertOk(); - $this->assertSame('Updated Schedule Name', $schedule->name); - $this->assertFalse($schedule->is_active); - $this->assertJsonTransformedWith($response->json('attributes'), $schedule); - - $this->assertSame($expected->toAtomString(), $schedule->next_run_at->toAtomString()); - } - - /** - * Test that an error is returned if the schedule exists but does not belong to this - * specific server instance. - */ - public function testErrorIsReturnedIfScheduleDoesNotBelongToServer() - { - [$user, $server] = $this->generateTestAccount(); - $server2 = $this->createServerModel(['owner_id' => $user->id]); - - $schedule = Schedule::factory()->create(['server_id' => $server2->id]); - - $this->actingAs($user) - ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") - ->assertNotFound(); - } - - /** - * Test that an error is returned if the subuser does not have permission to modify a - * server schedule. - */ - public function testErrorIsReturnedIfSubuserDoesNotHavePermissionToModifySchedule() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); - - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $this->actingAs($user) - ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") - ->assertForbidden(); - } - - /** - * Test that the "is_processing" field gets reset to false when the schedule is enabled - * or disabled so that an invalid state can be more easily fixed. - * - * @see https://github.com/pterodactyl/panel/issues/2425 - */ - public function testScheduleIsProcessingIsSetToFalseWhenActiveStateChanges() - { - [$user, $server] = $this->generateTestAccount(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create([ - 'server_id' => $server->id, - 'is_active' => true, - 'is_processing' => true, - ]); - - $this->assertTrue($schedule->is_active); - $this->assertTrue($schedule->is_processing); - - $response = $this->actingAs($user) - ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", $this->updateData); - - $schedule = $schedule->refresh(); - - $response->assertOk(); - $this->assertFalse($schedule->is_active); - $this->assertFalse($schedule->is_processing); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; - } -} + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", $this->updateData); + $schedule = $schedule->refresh(); + $response->assertOk(); + expect($schedule->is_active)->toBeFalse(); + expect($schedule->is_processing)->toBeFalse(); +}); diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php index c2d047a2b..343a48539 100644 --- a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php +++ b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php @@ -1,176 +1,111 @@ generateTestAccount($permissions); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - $this->assertEmpty($schedule->tasks); - - $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ - 'action' => 'command', - 'payload' => 'say Test', - 'time_offset' => 10, - 'sequence_id' => 1, - ]); - - $response->assertOk(); - /** @var Task $task */ - $task = Task::query()->findOrFail($response->json('attributes.id')); - - $this->assertSame($schedule->id, $task->schedule_id); - $this->assertSame(1, $task->sequence_id); - $this->assertSame('command', $task->action); - $this->assertSame('say Test', $task->payload); - $this->assertSame(10, $task->time_offset); - $this->assertJsonTransformedWith($response->json('attributes'), $task); +uses(ClientApiIntegrationTestCase::class); +dataset('permissionsDataProvider', fn (): array => [[[]], [[Permissions::ScheduleUpdate->value, Permissions::ControlConsole->value]]]); +dataset('taskActionPermissions', [ + 'command' => ['command', 'say Test', Permissions::ControlConsole], + 'power start' => ['power', 'start', Permissions::ControlStart], + 'power stop' => ['power', 'stop', Permissions::ControlStop], + 'power restart' => ['power', 'restart', Permissions::ControlRestart], + 'power kill' => ['power', 'kill', Permissions::ControlStop], + 'backup' => ['backup', null, Permissions::BackupCreate], +]); +test('task can be created', function (array $permissions): void { + [$user, $server] = $this->generateTestAccount($permissions); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'command', 'payload' => 'say Test', 'time_offset' => 10, 'sequence_id' => 1]); + $response->assertOk(); + /** @var Task $task */ + $task = Task::query()->findOrFail($response->json('attributes.id')); + expect($task->schedule_id)->toBe($schedule->id); + expect($task->sequence_id)->toBe(1); + expect($task->action)->toBe('command'); + expect($task->payload)->toBe('say Test'); + expect($task->time_offset)->toBe(10); + expect($response->json('attributes'))->toBe([ + 'id' => $task->id, + 'sequence_id' => $task->sequence_id, + 'action' => $task->action, + 'payload' => $task->payload, + 'time_offset' => $task->time_offset, + 'is_queued' => $task->is_queued, + 'continue_on_failure' => $task->continue_on_failure, + 'created_at' => $task->created_at->toAtomString(), + 'updated_at' => $task->updated_at->toAtomString(), + ]); +})->with('permissionsDataProvider'); +test('validation errors are returned', function (): void { + [$user, $server] = $this->generateTestAccount(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + foreach (['action', 'payload', 'time_offset'] as $i => $field) { + $response->assertJsonPath("errors.{$i}.meta.rule", $field === 'payload' ? 'required_unless' : 'required'); + $response->assertJsonPath("errors.{$i}.meta.source_field", $field); } - /** - * Test that validation errors are returned correctly if bad data is passed into the API. - */ - public function testValidationErrorsAreReturned() - { - [$user, $server] = $this->generateTestAccount(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - - foreach (['action', 'payload', 'time_offset'] as $i => $field) { - $response->assertJsonPath("errors.$i.meta.rule", $field === 'payload' ? 'required_unless' : 'required'); - $response->assertJsonPath("errors.$i.meta.source_field", $field); - } - - $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ - 'action' => 'hodor', - 'payload' => 'say Test', - 'time_offset' => 0, - ]) - ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.meta.rule', 'in') - ->assertJsonPath('errors.0.meta.source_field', 'action'); - - $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ - 'action' => 'command', - 'time_offset' => 0, - ]) - ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.meta.rule', 'required_unless') - ->assertJsonPath('errors.0.meta.source_field', 'payload'); - - $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ - 'action' => 'command', - 'payload' => 'say Test', - 'time_offset' => 0, - 'sequence_id' => 'hodor', - ]) - ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) - ->assertJsonPath('errors.0.meta.rule', 'numeric') - ->assertJsonPath('errors.0.meta.source_field', 'sequence_id'); - } - - /** - * Test that backups can not be tasked when the backup limit is 0. - */ - public function testBackupsCanNotBeTaskedIfLimit0() - { - [$user, $server] = $this->generateTestAccount(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ - 'action' => 'backup', - 'time_offset' => 0, - ]) - ->assertStatus(Response::HTTP_FORBIDDEN) - ->assertJsonPath('errors.0.detail', 'A backup task cannot be created when the server\'s backup limit is set to 0.'); - - $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ - 'action' => 'backup', - 'payload' => "file.txt\nfile2.log", - 'time_offset' => 0, - ]) - ->assertStatus(Response::HTTP_FORBIDDEN) - ->assertJsonPath('errors.0.detail', 'A backup task cannot be created when the server\'s backup limit is set to 0.'); - } - - /** - * Test that an error is returned if the user attempts to create an additional task that - * would put the schedule over the task limit. - */ - public function testErrorIsReturnedIfTooManyTasksExistForSchedule() - { - config()->set('pterodactyl.client_features.schedules.per_schedule_task_limit', 2); - - [$user, $server] = $this->generateTestAccount(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - Task::factory()->times(2)->create(['schedule_id' => $schedule->id]); - - $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ - 'action' => 'command', - 'payload' => 'say test', - 'time_offset' => 0, - ]) - ->assertStatus(Response::HTTP_BAD_REQUEST) - ->assertJsonPath('errors.0.code', 'ServiceLimitExceededException') - ->assertJsonPath('errors.0.detail', 'Schedules may not have more than 2 tasks associated with them. Creating this task would put this schedule over the limit.'); - } - - /** - * Test that an error is returned if the targeted schedule does not belong to the server - * in the request. - */ - public function testErrorIsReturnedIfScheduleDoesNotBelongToServer() - { - [$user, $server] = $this->generateTestAccount(); - $server2 = $this->createServerModel(['owner_id' => $user->id]); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server2->id]); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/schedules/$schedule->id/tasks") - ->assertNotFound(); - } - - /** - * Test that an error is returned if the subuser making the request does not have permission - * to update a schedule. - */ - public function testErrorIsReturnedIfSubuserDoesNotHaveScheduleUpdatePermissions() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $this->actingAs($user) - ->postJson($this->link($schedule, '/tasks')) - ->assertForbidden(); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; - } -} + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'hodor', 'payload' => 'say Test', 'time_offset' => 0])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.rule', 'in')->assertJsonPath('errors.0.meta.source_field', 'action'); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'command', 'time_offset' => 0])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.rule', 'required_unless')->assertJsonPath('errors.0.meta.source_field', 'payload'); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'command', 'payload' => 'say Test', 'time_offset' => 0, 'sequence_id' => 'hodor'])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.rule', 'numeric')->assertJsonPath('errors.0.meta.source_field', 'sequence_id'); +}); +test('backups can not be tasked if limit0', function (): void { + [$user, $server] = $this->generateTestAccount(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'backup', 'time_offset' => 0])->assertStatus(Response::HTTP_FORBIDDEN)->assertJsonPath('errors.0.detail', "A backup task cannot be created when the server's backup limit is set to 0."); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'backup', 'payload' => "file.txt\nfile2.log", 'time_offset' => 0])->assertStatus(Response::HTTP_FORBIDDEN)->assertJsonPath('errors.0.detail', "A backup task cannot be created when the server's backup limit is set to 0."); +}); +test('a task cannot be created without the permission its action needs', function (string $action, ?string $payload): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value]); + $server->forceFill(['backup_limit' => 1])->save(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => $action, 'payload' => $payload, 'time_offset' => 0])->assertForbidden(); + expect($schedule->tasks()->count())->toBe(0); +})->with('taskActionPermissions'); +test('a task can be created with the permission its action needs', function (string $action, ?string $payload, Permissions $permission): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value, $permission->value]); + $server->forceFill(['backup_limit' => 1])->save(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => $action, 'payload' => $payload, 'time_offset' => 0])->assertOk(); + $this->assertDatabaseHas('tasks', ['schedule_id' => $schedule->id, 'action' => $action, 'payload' => $payload ?? '']); +})->with('taskActionPermissions'); +test('a power task only accepts known signals', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value, Permissions::ControlStart->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'power', 'payload' => 'invalid', 'time_offset' => 0]) + ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) + ->assertJsonPath('errors.0.meta.rule', 'in') + ->assertJsonPath('errors.0.meta.source_field', 'payload'); +}); +test('error is returned if too many tasks exist for schedule', function (): void { + config()->set('pterodactyl.client_features.schedules.per_schedule_task_limit', 2); + [$user, $server] = $this->generateTestAccount(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + Task::factory()->times(2)->create(['schedule_id' => $schedule->id]); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), ['action' => 'command', 'payload' => 'say test', 'time_offset' => 0])->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.code', 'ServiceLimitExceededException')->assertJsonPath('errors.0.detail', 'Schedules may not have more than 2 tasks associated with them. Creating this task would put this schedule over the limit.'); +}); +test('error is returned if schedule does not belong to server', function (): void { + [$user, $server] = $this->generateTestAccount(); + $server2 = $this->createServerModel(['owner_id' => $user->id]); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}/tasks")->assertNotFound(); +}); +test('error is returned if subuser does not have schedule update permissions', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleCreate->value]); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php index b610dd379..70ce05921 100644 --- a/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php +++ b/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php @@ -1,84 +1,47 @@ createServerModel(); - [$user] = $this->generateTestAccount(); - - $schedule = Schedule::factory()->create(['server_id' => $server2->id]); - $task = Task::factory()->create(['schedule_id' => $schedule->id]); - - $this->actingAs($user)->deleteJson($this->link($task))->assertNotFound(); - } - - /** - * Test that an error is returned if the task and schedule in the URL do not line up - * with each other. - */ - public function testTaskBelongingToDifferentScheduleReturnsError() - { - [$user, $server] = $this->generateTestAccount(); - - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - $schedule2 = Schedule::factory()->create(['server_id' => $server->id]); - $task = Task::factory()->create(['schedule_id' => $schedule->id]); - - $this->actingAs($user)->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule2->id/tasks/$task->id")->assertNotFound(); - } - - /** - * Test that a user without the required permissions returns an error. - */ - public function testUserWithoutPermissionReturnsError() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); - - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - $task = Task::factory()->create(['schedule_id' => $schedule->id]); - - $this->actingAs($user)->deleteJson($this->link($task))->assertForbidden(); - - $user2 = User::factory()->create(); - - $this->actingAs($user2)->deleteJson($this->link($task))->assertNotFound(); - } - - /** - * Test that a schedule task is deleted and items with a higher sequence ID are decremented - * properly in the database. - */ - public function testScheduleTaskIsDeletedAndSubsequentTasksAreUpdated() - { - [$user, $server] = $this->generateTestAccount(); - - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - $tasks = [ - Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]), - Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]), - Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]), - Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]), - ]; - - $response = $this->actingAs($user)->deleteJson($this->link($tasks[1])); - $response->assertStatus(Response::HTTP_NO_CONTENT); - - $this->assertDatabaseHas('tasks', ['id' => $tasks[0]->id, 'sequence_id' => 1]); - $this->assertDatabaseHas('tasks', ['id' => $tasks[2]->id, 'sequence_id' => 2]); - $this->assertDatabaseHas('tasks', ['id' => $tasks[3]->id, 'sequence_id' => 3]); - $this->assertDatabaseMissing('tasks', ['id' => $tasks[1]->id]); - } -} +uses(ClientApiIntegrationTestCase::class); +test('schedule not belonging to server returns error', function () { + $server2 = $this->createServerModel(); + [$user] = $this->generateTestAccount(); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); + $this->actingAs($user)->deleteJson($this->link($task))->assertNotFound(); +}); +test('task belonging to different schedule returns error', function () { + [$user, $server] = $this->generateTestAccount(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $schedule2 = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); + $this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule2->id}/tasks/{$task->id}")->assertNotFound(); +}); +test('user without permission returns error', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleCreate->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); + $this->actingAs($user)->deleteJson($this->link($task))->assertForbidden(); + $user2 = User::factory()->create(); + $this->actingAs($user2)->deleteJson($this->link($task))->assertNotFound(); +}); +test('schedule task is deleted and subsequent tasks are updated', function () { + [$user, $server] = $this->generateTestAccount(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $tasks = [Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]), Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]), Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]), Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4])]; + $response = $this->actingAs($user)->deleteJson($this->link($tasks[1])); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $this->assertDatabaseHas('tasks', ['id' => $tasks[0]->id, 'sequence_id' => 1]); + $this->assertDatabaseHas('tasks', ['id' => $tasks[2]->id, 'sequence_id' => 2]); + $this->assertDatabaseHas('tasks', ['id' => $tasks[3]->id, 'sequence_id' => 3]); + $this->assertDatabaseMissing('tasks', ['id' => $tasks[1]->id]); +}); diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/UpdateScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/UpdateScheduleTaskTest.php new file mode 100644 index 000000000..20a4aead7 --- /dev/null +++ b/tests/Integration/Api/Client/Server/ScheduleTask/UpdateScheduleTaskTest.php @@ -0,0 +1,78 @@ +generateTestAccount(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'action' => 'command', 'payload' => 'say Old', 'time_offset' => 0]); + $this->actingAs($user)->postJson($this->link($task), ['action' => 'command', 'payload' => 'say Updated', 'time_offset' => 30])->assertOk()->assertJsonPath('attributes.payload', 'say Updated')->assertJsonPath('attributes.time_offset', 30); + $task->refresh(); + expect($task->payload)->toBe('say Updated'); + expect($task->time_offset)->toBe(30); +}); +test('updating sequence reorders other tasks', function () { + [$user, $server] = $this->generateTestAccount(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $tasks = collect([1, 2, 3])->map(fn (int $i) => Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => $i, 'action' => 'command', 'payload' => "say {$i}", 'time_offset' => 0])); + // Move the last task to the front; the other two shift up by one. + $this->actingAs($user)->postJson($this->link($tasks[2]), ['action' => 'command', 'payload' => 'say 3', 'time_offset' => 0, 'sequence_id' => 1])->assertOk()->assertJsonPath('attributes.sequence_id', 1); + expect($tasks[0]->refresh()->sequence_id)->toBe(2); + expect($tasks[1]->refresh()->sequence_id)->toBe(3); + expect($tasks[2]->refresh()->sequence_id)->toBe(1); +}); +test('backup task cannot be set when backups are disabled', function () { + [$user, $server] = $this->generateTestAccount(); + $server->update(['backup_limit' => 0]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'action' => 'command', 'payload' => 'say Test', 'time_offset' => 0]); + $this->actingAs($user)->postJson($this->link($task), ['action' => 'backup', 'time_offset' => 0])->assertForbidden(); +}); +test('task belonging to another schedule is not found', function () { + [$user, $server] = $this->generateTestAccount(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $otherSchedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $otherSchedule->id, 'sequence_id' => 1, 'action' => 'command', 'payload' => 'say Test', 'time_offset' => 0]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}/tasks/{$task->id}", ['action' => 'command', 'payload' => 'say Test', 'time_offset' => 0])->assertNotFound(); +}); +test('a subuser with the action permission can change a task', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value, Permissions::ControlConsole->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'action' => 'power', 'payload' => 'start', 'time_offset' => 0]); + $this->actingAs($user)->postJson($this->link($task), ['action' => 'command', 'payload' => 'say Test', 'time_offset' => 10])->assertOk(); + $task->refresh(); + expect($task->action)->toBe('command'); + expect($task->payload)->toBe('say Test'); +}); +test('a task cannot be changed to an action the subuser lacks permission for', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'action' => 'power', 'payload' => 'start', 'time_offset' => 0]); + $this->actingAs($user)->postJson($this->link($task), ['action' => 'command', 'payload' => 'say Test', 'time_offset' => 10])->assertForbidden(); + $task->refresh(); + expect($task->action)->toBe('power'); + expect($task->payload)->toBe('start'); +}); +test('an updated power task only accepts known signals', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleUpdate->value, Permissions::ControlStart->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'action' => 'power', 'payload' => 'start', 'time_offset' => 0]); + $this->actingAs($user)->postJson($this->link($task), ['action' => 'power', 'payload' => 'invalid', 'time_offset' => 0]) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.rule', 'in') + ->assertJsonPath('errors.0.meta.source_field', 'payload'); +}); +test('subuser requires schedule update permission', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ScheduleRead->value]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'action' => 'command', 'payload' => 'say Test', 'time_offset' => 0]); + $this->actingAs($user)->postJson($this->link($task), ['action' => 'command', 'payload' => 'say Test', 'time_offset' => 0])->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/SettingsControllerTest.php b/tests/Integration/Api/Client/Server/SettingsControllerTest.php index 1497927cd..16ca00c50 100644 --- a/tests/Integration/Api/Client/Server/SettingsControllerTest.php +++ b/tests/Integration/Api/Client/Server/SettingsControllerTest.php @@ -1,122 +1,91 @@ generateTestAccount($permissions); - $originalName = $server->name; - $originalDescription = $server->description; +uses(ClientApiIntegrationTestCase::class); +dataset('renamePermissionsDataProvider', fn (): array => [[[]], [[Permissions::SettingsRename->value]]]); +dataset('reinstallPermissionsDataProvider', fn (): array => [[[]], [[Permissions::SettingsReinstall->value]]]); +test('server name can be changed', function (array $permissions): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permissions); + $originalName = $server->name; + $originalDescription = $server->description; + $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/rename", ['name' => '', 'description' => '']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.meta.rule', 'required'); - $response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/settings/rename", [ - 'name' => '', - 'description' => '', - ]); + $server = $server->refresh(); + expect($server->name)->toBe($originalName); + expect($server->description)->toBe($originalDescription); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/rename", ['name' => 'Test Server Name', 'description' => 'This is a test server.'])->assertStatus(Response::HTTP_NO_CONTENT); + $server = $server->refresh(); + expect($server->name)->toBe('Test Server Name'); + expect($server->description)->toBe('This is a test server.'); +})->with('renamePermissionsDataProvider'); +test('subuser cannot change server name without permission', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $originalName = $server->name; + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/rename", ['name' => 'Test Server Name'])->assertStatus(Response::HTTP_FORBIDDEN); + $server = $server->refresh(); + expect($server->name)->toBe($originalName); +}); +test('server can be reinstalled', function (array $permissions): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permissions); + expect($server->isInstalled())->toBeTrue(); + $fake = new FakeDaemonServer; + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/reinstall")->assertStatus(Response::HTTP_ACCEPTED); + $fake->assertReinstalled(); + $server = $server->refresh(); + expect($server->status)->toBe(Server::STATUS_INSTALLING); +})->with('reinstallPermissionsDataProvider'); +test('a server that skips its install script cannot be reinstalled', function (array $permissions): void { + [$user, $server] = $this->generateTestAccount($permissions); + $server->update(['skip_scripts' => true]); + $fake = new FakeDaemonServer; - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.meta.rule', 'required'); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}")->assertOk()->assertJsonPath('attributes.skip_scripts', true); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/reinstall") + ->assertStatus(Response::HTTP_BAD_REQUEST) + ->assertJsonPath('errors.0.detail', trans('admin/server.exceptions.skipping_install_script')); - $server = $server->refresh(); - $this->assertSame($originalName, $server->name); - $this->assertSame($originalDescription, $server->description); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/settings/rename", [ - 'name' => 'Test Server Name', - 'description' => 'This is a test server.', - ]) - ->assertStatus(Response::HTTP_NO_CONTENT); - - $server = $server->refresh(); - $this->assertSame('Test Server Name', $server->name); - $this->assertSame('This is a test server.', $server->description); - } - - /** - * Test that a subuser receives a permissions error if they do not have the required permission - * and attempt to change the name. - */ - public function testSubuserCannotChangeServerNameWithoutPermission() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $originalName = $server->name; - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/settings/rename", [ - 'name' => 'Test Server Name', - ]) - ->assertStatus(Response::HTTP_FORBIDDEN); - - $server = $server->refresh(); - $this->assertSame($originalName, $server->name); - } - - /** - * Test that a server can be reinstalled. Honestly this test doesn't do much of anything other - * than make sure the endpoint works since. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('reinstallPermissionsDataProvider')] - public function testServerCanBeReinstalled(array $permissions) - { - /** @var Server $server */ - [$user, $server] = $this->generateTestAccount($permissions); - $this->assertTrue($server->isInstalled()); - - $service = \Mockery::mock(DaemonServerRepository::class); - $this->app->instance(DaemonServerRepository::class, $service); - - $service->expects('setServer') - ->with(\Mockery::on(function ($value) use ($server) { - return $value->uuid === $server->uuid; - })) - ->andReturnSelf() - ->getMock() - ->expects('reinstall') - ->andReturnUndefined(); - - $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/settings/reinstall") - ->assertStatus(Response::HTTP_ACCEPTED); - - $server = $server->refresh(); - $this->assertSame(Server::STATUS_INSTALLING, $server->status); - } - - /** - * Test that a subuser receives a permissions error if they do not have the required permission - * and attempt to reinstall a server. - */ - public function testSubuserCannotReinstallServerWithoutPermission() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/settings/reinstall") - ->assertStatus(Response::HTTP_FORBIDDEN); - - $server = $server->refresh(); - $this->assertTrue($server->isInstalled()); - } - - public static function renamePermissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_SETTINGS_RENAME]]]; - } - - public static function reinstallPermissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_SETTINGS_REINSTALL]]]; - } -} + expect($server->refresh()->status)->toBeNull() + ->and($fake->callsFor('reinstall'))->toBeEmpty(); +})->with('reinstallPermissionsDataProvider'); +test('subuser cannot reinstall server without permission', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/settings/reinstall")->assertStatus(Response::HTTP_FORBIDDEN); + $server = $server->refresh(); + expect($server->isInstalled())->toBeTrue(); +}); +test('docker image can be changed', function (): void { + [$user, $server] = $this->generateTestAccount(); + $images = array_values($server->egg->docker_images); + $server->forceFill(['image' => $images[0]])->saveOrFail(); + $target = end($images); + $this->actingAs($user)->putJson("/api/client/servers/{$server->uuid}/settings/docker-image", ['docker_image' => $target])->assertStatus(Response::HTTP_NO_CONTENT); + expect($server->refresh()->image)->toBe($target); +}); +test('docker image cannot be changed when admin set', function (): void { + [$user, $server] = $this->generateTestAccount(); + // The server factory image is intentionally not part of any egg. + expect(array_values($server->egg->docker_images))->not->toContain($server->image); + $this->actingAs($user)->putJson("/api/client/servers/{$server->uuid}/settings/docker-image", ['docker_image' => array_values($server->egg->docker_images)[0]])->assertStatus(Response::HTTP_BAD_REQUEST); +}); +test('docker image must be defined on the egg', function (): void { + [$user, $server] = $this->generateTestAccount(); + $server->forceFill(['image' => array_values($server->egg->docker_images)[0]])->saveOrFail(); + $this->actingAs($user)->putJson("/api/client/servers/{$server->uuid}/settings/docker-image", ['docker_image' => 'malicious/image:latest'])->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)->assertJsonPath('errors.0.meta.source_field', 'docker_image'); +}); +test('subuser cannot change docker image without permission', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $this->actingAs($user)->putJson("/api/client/servers/{$server->uuid}/settings/docker-image", ['docker_image' => array_values($server->egg->docker_images)[0]])->assertStatus(Response::HTTP_FORBIDDEN); +}); diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index 493cc6a0a..5ee539db2 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -1,64 +1,48 @@ generateTestAccount($permissions); +uses(ClientApiIntegrationTestCase::class); +dataset('permissionsDataProvider', fn (): array => [[[]], [[Permissions::StartupRead->value]]]); +test('startup variables are returned for server', function (array $permissions): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permissions); + $egg = $this->cloneEggAndVariables($server->egg); + // BUNGEE_VERSION should never be returned to the user in this API call, either in + // the array of variables, or revealed in the startup command. + $egg->variables()->first()->update(['user_viewable' => false]); + $server->fill(['egg_id' => $egg->id, 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}'])->save(); + $server = $server->refresh(); + $response = $this->actingAs($user)->getJson($this->link($server).'/startup'); + $response->assertOk(); + $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version [hidden]'); + $response->assertJsonPath('meta.raw_startup_command', $server->startup); + $response->assertJsonPath('object', 'list'); + $response->assertJsonCount(1, 'data'); + $response->assertJsonPath('data.0.object', EggVariable::RESOURCE_NAME); - $egg = $this->cloneEggAndVariables($server->egg); - // BUNGEE_VERSION should never be returned to the user in this API call, either in - // the array of variables, or revealed in the startup command. - $egg->variables()->first()->update([ - 'user_viewable' => false, - ]); - - $server->fill([ - 'egg_id' => $egg->id, - 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}', - ])->save(); - $server = $server->refresh(); - - $response = $this->actingAs($user)->getJson($this->link($server) . '/startup'); - - $response->assertOk(); - $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version [hidden]'); - $response->assertJsonPath('meta.raw_startup_command', $server->startup); - - $response->assertJsonPath('object', 'list'); - $response->assertJsonCount(1, 'data'); - $response->assertJsonPath('data.0.object', EggVariable::RESOURCE_NAME); - $this->assertJsonTransformedWith($response->json('data.0.attributes'), $egg->variables[1]); - } - - /** - * Test that a user without the required permission, or who does not have any permission to - * access the server cannot get the startup information for it. - */ - public function testStartupDataIsNotReturnedWithoutPermission() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->getJson($this->link($server) . '/startup')->assertForbidden(); - - $user2 = User::factory()->create(); - $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_STARTUP_READ]]]; - } -} + $variable = $egg->variables[1]; + expect($response->json('data.0.attributes'))->toBe([ + 'name' => $variable->name, + 'description' => $variable->description, + 'env_variable' => 'SERVER_JARFILE', + 'default_value' => 'bungeecord.jar', + 'server_value' => null, + 'is_editable' => true, + 'rules' => $variable->rules, + ]); +})->with('permissionsDataProvider'); +test('startup data is not returned without permission', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $this->actingAs($user)->getJson($this->link($server).'/startup')->assertForbidden(); + $user2 = User::factory()->create(); + $this->actingAs($user2)->getJson($this->link($server).'/startup')->assertNotFound(); +}); diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index cb67cb095..825ba972d 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -1,154 +1,87 @@ generateTestAccount($permissions); - $server->fill([ - 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}', - ])->save(); +uses(ClientApiIntegrationTestCase::class); +dataset('permissionsDataProvider', fn (): array => [[[]], [[Permissions::StartupUpdate->value]]]); +test('startup variable can be updated', function (array $permissions): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permissions); + $server->fill(['startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}'])->save(); + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', ['key' => 'BUNGEE_VERSION', 'value' => '1.2.3']); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.code', 'ValidationException'); + $response->assertJsonPath('errors.0.detail', 'The value may only contain letters and numbers.'); + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', ['key' => 'BUNGEE_VERSION', 'value' => '123']); + $response->assertOk(); + $response->assertJsonPath('object', EggVariable::RESOURCE_NAME); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ - 'key' => 'BUNGEE_VERSION', - 'value' => '1.2.3', - ]); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.code', 'ValidationException'); - $response->assertJsonPath('errors.0.detail', 'The value may only contain letters and numbers.'); - - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ - 'key' => 'BUNGEE_VERSION', - 'value' => '123', - ]); - - $response->assertOk(); - $response->assertJsonPath('object', EggVariable::RESOURCE_NAME); - $this->assertJsonTransformedWith($response->json('attributes'), $server->variables[0]); - $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version 123'); - $response->assertJsonPath('meta.raw_startup_command', $server->startup); - } - - /** - * Test that variables that are either not user_viewable, or not user_editable, cannot be - * updated via this endpoint. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] - public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(array $permissions) - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount($permissions); - - $egg = $this->cloneEggAndVariables($server->egg); - $egg->variables()->where('env_variable', 'BUNGEE_VERSION')->update(['user_viewable' => false]); - $egg->variables()->where('env_variable', 'SERVER_JARFILE')->update(['user_editable' => false]); - - $server->fill(['egg_id' => $egg->id])->save(); - $server->refresh(); - - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ - 'key' => 'BUNGEE_VERSION', - 'value' => '123', - ]); - - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); - $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit does not exist.'); - - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ - 'key' => 'SERVER_JARFILE', - 'value' => 'server2.jar', - ]); - - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); - $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit is read-only.'); - } - - /** - * Test that a hidden variable is not included in the startup_command output for the server if - * a different variable is updated. - */ - public function testHiddenVariablesAreNotReturnedInStartupCommandWhenUpdatingVariable() - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount(); - - $egg = $this->cloneEggAndVariables($server->egg); - $egg->variables()->first()->update(['user_viewable' => false]); - - $server->fill([ - 'egg_id' => $egg->id, - 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}', - ])->save(); - - $server->refresh(); - - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ - 'key' => 'SERVER_JARFILE', - 'value' => 'server2.jar', - ]); - - $response->assertOk(); - $response->assertJsonPath('meta.startup_command', 'java server2.jar --version [hidden]'); - $response->assertJsonPath('meta.raw_startup_command', $server->startup); - } - - /** - * Test that an egg variable with a validation rule of 'nullable|string' works if no value - * is passed through in the request. - * - * @see https://github.com/pterodactyl/panel/issues/2433 - */ - public function testEggVariableWithNullableStringIsNotRequired() - { - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount(); - - $egg = $this->cloneEggAndVariables($server->egg); - $egg->variables()->first()->update(['rules' => 'nullable|string']); - - $server->fill(['egg_id' => $egg->id])->save(); - $server->refresh(); - - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ - 'key' => 'BUNGEE_VERSION', - 'value' => '', - ]); - - $response->assertOk(); - $response->assertJsonPath('attributes.server_value', null); - } - - /** - * Test that a variable cannot be updated if the user does not have permission to perform - * that action, or they aren't assigned at all to the server. - */ - public function testStartupVariableCannotBeUpdatedIfNotUserViewable() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->putJson($this->link($server) . '/startup/variable')->assertForbidden(); - - $user2 = User::factory()->create(); - $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_STARTUP_UPDATE]]]; - } -} + $variable = $server->variables[0]; + expect($response->json('attributes'))->toBe([ + 'name' => $variable->name, + 'description' => $variable->description, + 'env_variable' => 'BUNGEE_VERSION', + 'default_value' => $variable->default_value, + 'server_value' => '123', + 'is_editable' => true, + 'rules' => $variable->rules, + ]); + $this->assertDatabaseHas('server_variables', ['server_id' => $server->id, 'variable_id' => $variable->id, 'variable_value' => '123']); + $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version 123'); + $response->assertJsonPath('meta.raw_startup_command', $server->startup); +})->with('permissionsDataProvider'); +test('startup variable cannot be updated if not user viewable or editable', function (array $permissions): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permissions); + $egg = $this->cloneEggAndVariables($server->egg); + $egg->variables()->where('env_variable', 'BUNGEE_VERSION')->update(['user_viewable' => false]); + $egg->variables()->where('env_variable', 'SERVER_JARFILE')->update(['user_editable' => false]); + $server->fill(['egg_id' => $egg->id])->save(); + $server->refresh(); + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', ['key' => 'BUNGEE_VERSION', 'value' => '123']); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); + $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit does not exist.'); + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', ['key' => 'SERVER_JARFILE', 'value' => 'server2.jar']); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); + $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit is read-only.'); +})->with('permissionsDataProvider'); +test('hidden variables are not returned in startup command when updating variable', function (): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + $egg = $this->cloneEggAndVariables($server->egg); + $egg->variables()->first()->update(['user_viewable' => false]); + $server->fill(['egg_id' => $egg->id, 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}'])->save(); + $server->refresh(); + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', ['key' => 'SERVER_JARFILE', 'value' => 'server2.jar']); + $response->assertOk(); + $response->assertJsonPath('meta.startup_command', 'java server2.jar --version [hidden]'); + $response->assertJsonPath('meta.raw_startup_command', $server->startup); +}); +test('egg variable with nullable string is not required', function (): void { + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + $egg = $this->cloneEggAndVariables($server->egg); + $egg->variables()->first()->update(['rules' => 'nullable|string']); + $server->fill(['egg_id' => $egg->id])->save(); + $server->refresh(); + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', ['key' => 'BUNGEE_VERSION', 'value' => '']); + $response->assertOk(); + $response->assertJsonPath('attributes.server_value', null); +}); +test('startup variable cannot be updated if not user viewable', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $this->actingAs($user)->putJson($this->link($server).'/startup/variable')->assertForbidden(); + $user2 = User::factory()->create(); + $this->actingAs($user2)->putJson($this->link($server).'/startup/variable')->assertNotFound(); +}); diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index 12aef45e8..1a47a6118 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -1,161 +1,105 @@ [[[]], [[Permissions::UserCreate->value]]]); +test('subuser can be created', function (array $permissions): void { + [$user, $server] = $this->generateTestAccount($permissions); + $response = $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $email = $this->faker->email, 'permissions' => [Permissions::UserCreate->value]]); + $response->assertOk(); + /** @var User $subuser */ + $subuser = User::query()->where('email', $email)->firstOrFail(); + $response->assertJsonPath('object', Subuser::RESOURCE_NAME); + $response->assertJsonPath('attributes.uuid', $subuser->uuid); + $response->assertJsonPath('attributes.permissions', [Permissions::UserCreate->value, Permissions::WebsocketConnect->value]); - /** - * Test that a subuser can be created for a server. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('permissionsDataProvider')] - public function testSubuserCanBeCreated(array $permissions) - { - [$user, $server] = $this->generateTestAccount($permissions); + expect($response->json('attributes'))->toBe([ + 'uuid' => $subuser->uuid, + 'identifier' => $subuser->identifier, + 'username' => $subuser->username, + 'email' => $email, + 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($email)), + '2fa_enabled' => false, + 'created_at' => $subuser->created_at->toAtomString(), + 'permissions' => [Permissions::UserCreate->value, Permissions::WebsocketConnect->value], + ]); +})->with('permissionsDataProvider'); +test('inviting a new email address logs the user it creates', function (): void { + [$user, $server] = $this->generateTestAccount(); + $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $email = $this->faker->email, 'permissions' => [Permissions::UserCreate->value]])->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $email = $this->faker->email, - 'permissions' => [ - Permission::ACTION_USER_CREATE, - ], - ]); + $created = User::query()->where('email', $email)->firstOrFail(); + $log = $created->activity()->where('event', 'user:user.create')->sole(); + expect($log->actor_id)->toBe($user->id) + ->and($log->properties->get('email'))->toBe($email); +}); +test('inviting an existing user does not log a user creation', function (): void { + [$user, $server] = $this->generateTestAccount(); + $existing = User::factory()->create(); + $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $existing->email, 'permissions' => [Permissions::UserCreate->value]])->assertOk(); - $response->assertOk(); - - /** @var User $subuser */ - $subuser = User::query()->where('email', $email)->firstOrFail(); - - $response->assertJsonPath('object', Subuser::RESOURCE_NAME); - $response->assertJsonPath('attributes.uuid', $subuser->uuid); - $response->assertJsonPath('attributes.permissions', [ - Permission::ACTION_USER_CREATE, - Permission::ACTION_WEBSOCKET_CONNECT, - ]); - - $expected = $response->json('attributes'); - unset($expected['permissions']); - - $this->assertJsonTransformedWith($expected, $subuser); - } - - /** - * Tests that an error is returned if a subuser attempts to create a new subuser and assign - * permissions that their account does not also possess. - */ - public function testErrorIsReturnedIfAssigningPermissionsNotAssignedToSelf() - { - [$user, $server] = $this->generateTestAccount([ - Permission::ACTION_USER_CREATE, - Permission::ACTION_USER_READ, - Permission::ACTION_CONTROL_CONSOLE, - ]); - - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $this->faker->email, - 'permissions' => [ - Permission::ACTION_USER_CREATE, - Permission::ACTION_USER_UPDATE, // This permission is not assigned to the subuser. - ], - ]); - - $response->assertForbidden(); - $response->assertJsonPath('errors.0.code', 'HttpForbiddenException'); - $response->assertJsonPath('errors.0.detail', 'Cannot assign permissions to a subuser that your account does not actively possess.'); - } - - /** - * Throws some bad data at the API and ensures that a subuser cannot be created. - */ - public function testSubuserWithExcessivelyLongEmailCannotBeCreated() - { - [$user, $server] = $this->generateTestAccount(); - - $email = str_repeat(Str::random(20), 9) . '1@gmail.com'; // 191 is the hard limit for the column in MySQL. - - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $email, - 'permissions' => [ - Permission::ACTION_USER_CREATE, - ], - ]); - - $response->assertOk(); - - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $email . '.au', - 'permissions' => [ - Permission::ACTION_USER_CREATE, - ], - ]); - - $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); - $response->assertJsonPath('errors.0.detail', 'The email must be between 1 and 191 characters.'); - $response->assertJsonPath('errors.0.meta.source_field', 'email'); - } - - /** - * Test that creating a subuser when there is already an account with that email runs - * as expected and does not create a new account. - */ - public function testCreatingSubuserWithSameEmailAsExistingUserWorks() - { - [$user, $server] = $this->generateTestAccount(); - - /** @var User $existing */ - $existing = User::factory()->create(['email' => $this->faker->email]); - - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $existing->email, - 'permissions' => [ - Permission::ACTION_USER_CREATE, - ], - ]); - - $response->assertOk(); - $response->assertJsonPath('object', Subuser::RESOURCE_NAME); - $response->assertJsonPath('attributes.uuid', $existing->uuid); - } - - /** - * Test that an error is returned if the account associated with an email address is already - * associated with the server instance. - */ - public function testAddingSubuserThatAlreadyIsAssignedReturnsError() - { - [$user, $server] = $this->generateTestAccount(); - - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $email = $this->faker->email, - 'permissions' => [ - Permission::ACTION_USER_CREATE, - ], - ]); - - $response->assertOk(); - - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $email, - 'permissions' => [ - Permission::ACTION_USER_CREATE, - ], - ]); - - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'ServerSubuserExistsException'); - $response->assertJsonPath('errors.0.detail', 'A user with that email address is already assigned as a subuser for this server.'); - } - - public static function permissionsDataProvider(): array - { - return [[[]], [[Permission::ACTION_USER_CREATE]]]; - } -} + expect($existing->activity()->where('event', 'user:user.create')->exists())->toBeFalse() + ->and($existing->activity()->where('event', 'server:subuser.create')->exists())->toBeTrue(); +}); +test('error is returned if assigning permissions not assigned to self', function (): void { + [$user, $server] = $this->generateTestAccount([Permissions::UserCreate->value, Permissions::UserRead->value, Permissions::ControlConsole->value]); + $response = $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $this->faker->email, 'permissions' => [Permissions::UserCreate->value, Permissions::UserUpdate->value]]); + $response->assertForbidden(); + $response->assertJsonPath('errors.0.code', 'HttpForbiddenException'); + $response->assertJsonPath('errors.0.detail', 'Cannot assign permissions to a subuser that your account does not actively possess.'); +}); +test('subuser with excessively long email cannot be created', function (): void { + [$user, $server] = $this->generateTestAccount(); + // RFCs limit the local part to 64 characters and each domain label to 63, so this + // address is as long as the 191-character column allows while staying valid. + $local = str_repeat(Str::random(10), 6).'1234'; + $label = str_repeat(Str::random(10), 6).'1'; + $email = "{$local}@{$label}.{$label}.au"; + expect(mb_strlen($email))->toBe(191); + $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $email, 'permissions' => [Permissions::UserCreate->value]])->assertOk(); + $response = $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => "{$local}@{$label}.{$label}.com", 'permissions' => [Permissions::UserCreate->value]]); + $response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); + $response->assertJsonPath('errors.0.detail', 'The email must be between 1 and 191 characters.'); + $response->assertJsonPath('errors.0.meta.source_field', 'email'); +}); +test('subuser email must be a strict address that does not start with a dash', function (string $email): void { + [$user, $server] = $this->generateTestAccount(); + $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $email, 'permissions' => [Permissions::UserCreate->value]]) + ->assertUnprocessable() + ->assertJsonPath('errors.0.meta.source_field', 'email'); + $this->assertDatabaseMissing('users', ['email' => $email]); +})->with([ + 'dash prefix' => ['-x@example.com'], + 'quoted dash prefix' => ['"-x"@example.com'], + 'local part over 64 characters' => [str_repeat('a', 65).'@example.com'], +]); +test('creating subuser with same email as existing user works', function (): void { + [$user, $server] = $this->generateTestAccount(); + /** @var User $existing */ + $existing = User::factory()->create(['email' => $this->faker->email]); + $response = $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $existing->email, 'permissions' => [Permissions::UserCreate->value]]); + $response->assertOk(); + $response->assertJsonPath('object', Subuser::RESOURCE_NAME); + $response->assertJsonPath('attributes.uuid', $existing->uuid); +}); +test('adding subuser that already is assigned returns error', function (): void { + [$user, $server] = $this->generateTestAccount(); + $response = $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $email = $this->faker->email, 'permissions' => [Permissions::UserCreate->value]]); + $response->assertOk(); + $response = $this->actingAs($user)->postJson($this->link($server).'/users', ['email' => $email, 'permissions' => [Permissions::UserCreate->value]]); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'ServerSubuserExistsException'); + $response->assertJsonPath('errors.0.detail', 'A user with that email address is already assigned as a subuser for this server.'); +}); diff --git a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php index c9b7f8ed7..400065e98 100644 --- a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php @@ -1,59 +1,34 @@ generateTestAccount(); - - /** @var User $differentUser */ - $differentUser = User::factory()->create(); - - $real = Uuid::uuid4()->toString(); - // Generate a UUID that lines up with a user in the database if it were to be cast to an int. - $uuid = ($prefix ?: $differentUser->id) . substr($real, strlen($prefix ?: (string) $differentUser->id)); - - /** @var User $subuser */ - $subuser = User::factory()->create(['uuid' => $uuid]); - - Subuser::query()->forceCreate([ - 'user_id' => $subuser->id, - 'server_id' => $server->id, - 'permissions' => [Permission::ACTION_WEBSOCKET_CONNECT], - ]); - - $this->withoutExceptionHandling() - ->actingAs($user) - ->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); - - Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($subuser, $server) { - return $job->user === $subuser->uuid && $job->target->is($server); - }); - } -} +uses(ClientApiIntegrationTestCase::class); +test('correct subuser is deleted from server', function (?string $prefix) { + Bus::fake([RevokeSftpAccessJob::class]); + [$user, $server] = $this->generateTestAccount(); + /** @var User $differentUser */ + $differentUser = User::factory()->create(); + $real = Uuid::uuid4()->toString(); + // Generate a UUID that lines up with a user in the database if it were to be cast to an int. + $uuid = ($prefix ?: $differentUser->id).mb_substr($real, mb_strlen($prefix ?: (string) $differentUser->id)); + /** @var User $subuser */ + $subuser = User::factory()->create(['uuid' => $uuid]); + Subuser::query()->forceCreate(['user_id' => $subuser->id, 'server_id' => $server->id, 'permissions' => [Permissions::WebsocketConnect->value]]); + $this->withoutExceptionHandling()->actingAs($user)->deleteJson($this->link($server)."/users/{$subuser->uuid}")->assertNoContent(); + Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($subuser, $server) { + return $job->user === $subuser->uuid && $job->target->is($server); + }); +})->with([ + 'without a numeric prefix' => [null], + 'with a numeric prefix' => ['18180000'], +]); diff --git a/tests/Integration/Api/Client/Server/Subuser/ExtensionSubuserPermissionsTest.php b/tests/Integration/Api/Client/Server/Subuser/ExtensionSubuserPermissionsTest.php new file mode 100644 index 000000000..207a46354 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Subuser/ExtensionSubuserPermissionsTest.php @@ -0,0 +1,35 @@ +app->make(ExtensionPermissionRegistry::class)->register('issue-probe', 'Control the probe.', ['view' => 'View the probe.']); +}); +test('the permission list includes extension permission groups', function (): void { + [$user] = $this->generateTestAccount(); + + $permissions = $this->actingAs($user)->getJson('/api/client/permissions')->assertOk()->json('attributes.permissions'); + + expect($permissions['ext.issue-probe'])->toBe(['description' => 'Control the probe.', 'keys' => ['view' => 'View the probe.']]) + ->and($permissions)->toHaveKey('control'); +}); +test('a subuser can be granted a registered extension permission', function (): void { + [$user, $server] = $this->generateTestAccount(); + + $this->actingAs($user)->postJson($this->link($server).'/users', [ + 'email' => $email = 'probe-subuser@example.com', + 'permissions' => [Permissions::ControlConsole->value, 'ext.issue-probe.view', 'ext.unregistered.view'], + ])->assertOk()->assertJsonPath('attributes.permissions', [Permissions::ControlConsole->value, 'ext.issue-probe.view', Permissions::WebsocketConnect->value]); + + $subuser = User::query()->where('email', $email)->firstOrFail(); + expect($subuser->can('ext.issue-probe.view', $server))->toBeTrue() + ->and($subuser->can('ext.unregistered.view', $server))->toBeFalse(); +}); diff --git a/tests/Integration/Api/Client/Server/Subuser/GetSubusersTest.php b/tests/Integration/Api/Client/Server/Subuser/GetSubusersTest.php new file mode 100644 index 000000000..a65d2af63 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Subuser/GetSubusersTest.php @@ -0,0 +1,27 @@ +generateTestAccount(); + $subusers = User::factory()->times(2)->create()->map(function (User $subuser) use ($server) { + return Subuser::query()->create(['user_id' => $subuser->id, 'server_id' => $server->id, 'permissions' => [Permissions::ControlConsole->value]]); + }); + $response = $this->actingAs($user)->getJson($this->link($server, '/users'))->assertOk()->assertJsonPath('object', 'list')->assertJsonCount(2, 'data')->assertJsonPath('data.0.object', 'server_subuser'); + $uuids = collect($response->json('data'))->pluck('attributes.uuid'); + expect($uuids->toArray())->toEqualCanonicalizing($subusers->map(fn ($s) => $s->user->uuid)->toArray()); + expect($response->json('data.0.attributes.permissions'))->toContain(Permissions::ControlConsole->value); +}); +test('listing requires user read permission', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlConsole->value]); + $this->getJson($this->link($server, '/users'))->assertUnauthorized(); + $this->actingAs($user)->getJson($this->link($server, '/users'))->assertForbidden(); +}); diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php index 18d47f295..fe5ad8fe0 100644 --- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -1,61 +1,47 @@ create(); - - // The API $user is the owner of $server1. - [$user, $server1] = $this->generateTestAccount(); - // Will be a subuser of $server2. - $server2 = $this->createServerModel(); - // And as no access to $server3. - $server3 = $this->createServerModel(); - - // Set the API $user as a subuser of server 2, but with no permissions - // to do anything with the subusers for that server. - Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); - - Subuser::factory()->create(['server_id' => $server1->id, 'user_id' => $internal->id]); - Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $internal->id]); - Subuser::factory()->create(['server_id' => $server3->id, 'user_id' => $internal->id]); - - // This route is acceptable since they're accessing a subuser on their own server. - $this->actingAs($user)->json($method, $this->link($server1, '/users/' . $internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); - - // This route can be revealed since the subuser belongs to the correct server, but - // errors out with a 403 since $user does not have the right permissions for this. - $this->actingAs($user)->json($method, $this->link($server2, '/users/' . $internal->uuid))->assertForbidden(); - $this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound(); - - if ($method === 'DELETE') { - Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($server1, $internal) { - return $job->user === $internal->uuid && $job->target->is($server1); - }); - } else { - Bus::assertNotDispatched(RevokeSftpAccessJob::class); - } +uses(ClientApiIntegrationTestCase::class); +dataset('methodDataProvider', function () { + return [['GET'], ['POST'], ['DELETE']]; +}); +test('user cannot access resource belonging to other servers', function (string $method) { + Bus::fake([RevokeSftpAccessJob::class]); + // Generic subuser, the specific resource we're trying to access. + /** @var User $internal */ + $internal = User::factory()->create(); + // The API $user is the owner of $server1. + [$user, $server1] = $this->generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the subusers for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + Subuser::factory()->create(['server_id' => $server1->id, 'user_id' => $internal->id]); + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $internal->id]); + Subuser::factory()->create(['server_id' => $server3->id, 'user_id' => $internal->id]); + // This route is acceptable since they're accessing a subuser on their own server. + $this->actingAs($user)->json($method, $this->link($server1, '/users/'.$internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); + // This route can be revealed since the subuser belongs to the correct server, but + // errors out with a 403 since $user does not have the right permissions for this. + $this->actingAs($user)->json($method, $this->link($server2, '/users/'.$internal->uuid))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server3, '/users/'.$internal->uuid))->assertNotFound(); + if ($method === 'DELETE') { + Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($server1, $internal) { + return $job->user === $internal->uuid && $job->target->is($server1); + }); + } else { + Bus::assertNotDispatched(RevokeSftpAccessJob::class); } - - public static function methodDataProvider(): array - { - return [['GET'], ['POST'], ['DELETE']]; - } -} +})->with('methodDataProvider'); diff --git a/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php index 661022c85..e3b6896e7 100644 --- a/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/UpdateSubuserTest.php @@ -1,151 +1,56 @@ generateTestAccount(['user.read']); - - $subuser = Subuser::factory() - ->for(User::factory()->create()) - ->for($server) - ->create([ - 'permissions' => ['control.start'], - ]); - - $this->postJson( - $endpoint = "/api/client/servers/$server->uuid/users/{$subuser->user->uuid}", - $data = [ - 'permissions' => [ - 'control.start', - 'control.stop', - ], - ] - ) - ->assertUnauthorized(); - - $this->actingAs($subuser->user)->postJson($endpoint, $data)->assertForbidden(); - $this->actingAs($user)->postJson($endpoint, $data)->assertForbidden(); - - $server->subusers()->where('user_id', $user->id)->update([ - 'permissions' => [ - Permission::ACTION_USER_UPDATE, - Permission::ACTION_CONTROL_START, - Permission::ACTION_CONTROL_STOP, - ], - ]); - - $this->postJson($endpoint, $data)->assertOk(); - - Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($server, $subuser) { - return $job->user === $subuser->user->uuid && $job->target->is($server); - }); - } - - /** - * Tests that permissions for the account are updated and any extraneous values - * we don't know about are removed. - */ - public function testPermissionsAreSavedToAccount() - { - Bus::fake([RevokeSftpAccessJob::class]); - - [$user, $server] = $this->generateTestAccount(); - - /** @var Subuser $subuser */ - $subuser = Subuser::factory() - ->for(User::factory()->create()) - ->for($server) - ->create([ - 'permissions' => ['control.restart', 'websocket.connect', 'foo.bar'], - ]); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/users/{$subuser->user->uuid}", [ - 'permissions' => [ - 'control.start', - 'control.stop', - 'control.stop', - 'foo.bar', - 'power.fake', - ], - ]) - ->assertOk(); - - $subuser->refresh(); - $this->assertEqualsCanonicalizing( - ['control.start', 'control.stop', 'websocket.connect'], - $subuser->permissions - ); - - Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($server, $subuser) { - return $job->user === $subuser->user->uuid && $job->target->is($server); - }); - } - - /** - * Ensure a subuser cannot assign permissions to an account that they do not have - * themselves. - */ - public function testUserCannotAssignPermissionsTheyDoNotHave() - { - Bus::fake([RevokeSftpAccessJob::class]); - - [$user, $server] = $this->generateTestAccount([Permission::ACTION_USER_READ, Permission::ACTION_USER_UPDATE]); - - $subuser = Subuser::factory() - ->for(User::factory()->create()) - ->for($server) - ->create(['permissions' => ['foo.bar']]); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/users/{$subuser->user->uuid}", [ - 'permissions' => [Permission::ACTION_USER_READ, Permission::ACTION_CONTROL_CONSOLE], - ]) - ->assertForbidden(); - - $this->assertEqualsCanonicalizing(['foo.bar'], $subuser->refresh()->permissions); - - Bus::assertNothingDispatched(); - } - - /** - * Test that a user cannot update thyself. - */ - public function testUserCannotUpdateSelf() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_USER_READ, Permission::ACTION_USER_UPDATE]); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/users/$user->uuid", []) - ->assertForbidden(); - } - - /** - * Test that an error is returned if you attempt to update a subuser on a different account. - */ - public function testCannotUpdateSubuserForDifferentServer() - { - [$user, $server] = $this->generateTestAccount(); - [$user2] = $this->generateTestAccount(['foo.bar']); - - $this->actingAs($user) - ->postJson("/api/client/servers/$server->uuid/users/$user2->uuid", []) - ->assertNotFound(); - } -} +uses(ClientApiIntegrationTestCase::class); +test('correct permissions are required for updating', function () { + Bus::fake([RevokeSftpAccessJob::class]); + [$user, $server] = $this->generateTestAccount(['user.read']); + $subuser = Subuser::factory()->for(User::factory()->create())->for($server)->create(['permissions' => ['control.start']]); + $this->postJson($endpoint = "/api/client/servers/{$server->uuid}/users/{$subuser->user->uuid}", $data = ['permissions' => ['control.start', 'control.stop']])->assertUnauthorized(); + $this->actingAs($subuser->user)->postJson($endpoint, $data)->assertForbidden(); + $this->actingAs($user)->postJson($endpoint, $data)->assertForbidden(); + $server->subusers()->where('user_id', $user->id)->update(['permissions' => [Permissions::UserUpdate->value, Permissions::ControlStart->value, Permissions::ControlStop->value]]); + $this->postJson($endpoint, $data)->assertOk(); + Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($server, $subuser) { + return $job->user === $subuser->user->uuid && $job->target->is($server); + }); +}); +test('permissions are saved to account', function () { + Bus::fake([RevokeSftpAccessJob::class]); + [$user, $server] = $this->generateTestAccount(); + /** @var Subuser $subuser */ + $subuser = Subuser::factory()->for(User::factory()->create())->for($server)->create(['permissions' => ['control.restart', 'websocket.connect', 'foo.bar']]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/users/{$subuser->user->uuid}", ['permissions' => ['control.start', 'control.stop', 'control.stop', 'foo.bar', 'power.fake']])->assertOk(); + $subuser->refresh(); + expect($subuser->permissions)->toEqualCanonicalizing(['control.start', 'control.stop', 'websocket.connect']); + Bus::assertDispatchedTimes(function (RevokeSftpAccessJob $job) use ($server, $subuser) { + return $job->user === $subuser->user->uuid && $job->target->is($server); + }); +}); +test('user cannot assign permissions they do not have', function () { + Bus::fake([RevokeSftpAccessJob::class]); + [$user, $server] = $this->generateTestAccount([Permissions::UserRead->value, Permissions::UserUpdate->value]); + $subuser = Subuser::factory()->for(User::factory()->create())->for($server)->create(['permissions' => ['foo.bar']]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/users/{$subuser->user->uuid}", ['permissions' => [Permissions::UserRead->value, Permissions::ControlConsole->value]])->assertForbidden(); + expect($subuser->refresh()->permissions)->toEqualCanonicalizing(['foo.bar']); + Bus::assertNothingDispatched(); +}); +test('user cannot update self', function () { + [$user, $server] = $this->generateTestAccount([Permissions::UserRead->value, Permissions::UserUpdate->value]); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/users/{$user->uuid}", [])->assertForbidden(); +}); +test('cannot update subuser for different server', function () { + [$user, $server] = $this->generateTestAccount(); + [$user2] = $this->generateTestAccount(['foo.bar']); + $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/users/{$user2->uuid}", [])->assertNotFound(); +}); diff --git a/tests/Integration/Api/Client/Server/WebsocketControllerTest.php b/tests/Integration/Api/Client/Server/WebsocketControllerTest.php index 76eee97bb..f8d918dff 100644 --- a/tests/Integration/Api/Client/Server/WebsocketControllerTest.php +++ b/tests/Integration/Api/Client/Server/WebsocketControllerTest.php @@ -1,130 +1,78 @@ generateTestAccount([Permission::ACTION_CONTROL_RESTART]); - - $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/websocket") - ->assertStatus(Response::HTTP_FORBIDDEN) - ->assertJsonPath('errors.0.code', 'HttpForbiddenException') - ->assertJsonPath('errors.0.detail', 'You do not have permission to connect to this server\'s websocket.'); - } - - /** - * Confirm users cannot access the websocket for another user's server. - */ - public function testUserWithoutPermissionForServerReceivesError() - { - [, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - [$user] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - - $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/websocket") - ->assertStatus(Response::HTTP_NOT_FOUND); - } - - /** - * Test that the expected permissions are returned for the server owner and that the JWT is - * configured correctly. - */ - public function testJwtAndWebsocketUrlAreReturnedForServerOwner() - { - /** @var \Pterodactyl\Models\User $user */ - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount(); - - // Force the node to HTTPS since we want to confirm it gets transformed to wss:// in the URL. - $server->node->scheme = 'https'; - $server->node->save(); - - $response = $this->actingAs($user) - ->withoutExceptionHandling() - ->getJson("/api/client/servers/$server->uuid/websocket") - ->assertOk() - ->assertJsonStructure(['data' => ['token', 'socket']]); - - $connection = $response->json('data.socket'); - $this->assertStringStartsWith('wss://', $connection, 'Failed asserting that websocket connection address has expected "wss://" prefix.'); - $this->assertStringEndsWith("/api/servers/$server->uuid/ws", $connection, 'Failed asserting that websocket connection address uses expected Wings endpoint.'); - - $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); - $config = $config->withValidationConstraints(new SignedWith(new Sha256(), $key)); - - /** @var \Lcobucci\JWT\Token\Plain $token */ - $token = $config->parser()->parse($response->json('data.token')); - - $this->assertTrue( - $config->validator()->validate($token, ...$config->validationConstraints()), - 'Failed to validate that the JWT data returned was signed using the Node\'s secret key.' - ); - - // The way we generate times for the JWT will truncate the microseconds from the - // time, but CarbonImmutable::now() will include them, thus causing test failures. - // - // This little chunk of logic just strips those out by generating a new CarbonImmutable - // instance from the current timestamp, which is how the JWT works. We also need to - // switch to UTC here for consistency. - $expect = CarbonImmutable::createFromTimestamp(CarbonImmutable::now()->getTimestamp())->timezone('UTC'); - - // Check that the claims are generated correctly. - $this->assertTrue($token->hasBeenIssuedBy(config('app.url'))); - $this->assertTrue($token->isPermittedFor($server->node->getConnectionAddress())); - $this->assertEquals($expect, $token->claims()->get('iat')); - $this->assertEquals($expect->subMinutes(5), $token->claims()->get('nbf')); - $this->assertEquals($expect->addMinutes(10), $token->claims()->get('exp')); - $this->assertSame($user->uuid, $token->claims()->get('user_uuid')); - $this->assertSame($server->uuid, $token->claims()->get('server_uuid')); - $this->assertSame(['*'], $token->claims()->get('permissions')); - $this->assertEquals(JwtScope::Websocket->value, $token->claims()->get('scope')); - } - - /** - * Test that the subuser's permissions are passed along correctly in the generated JWT. - */ - public function testJwtIsConfiguredCorrectlyForServerSubuser() - { - $permissions = [Permission::ACTION_WEBSOCKET_CONNECT, Permission::ACTION_CONTROL_CONSOLE]; - - /** @var \Pterodactyl\Models\User $user */ - /** @var \Pterodactyl\Models\Server $server */ - [$user, $server] = $this->generateTestAccount($permissions); - - $response = $this->actingAs($user) - ->withoutExceptionHandling() - ->getJson("/api/client/servers/$server->uuid/websocket") - ->assertOk() - ->assertJsonStructure(['data' => ['token', 'socket']]); - - $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); - $config = $config->withValidationConstraints(new SignedWith(new Sha256(), $key)); - - /** @var \Lcobucci\JWT\Token\Plain $token */ - $token = $config->parser()->parse($response->json('data.token')); - - $this->assertTrue( - $config->validator()->validate($token, ...$config->validationConstraints()), - 'Failed to validate that the JWT data returned was signed using the Node\'s secret key.' - ); - - // Check that the claims are generated correctly. - $this->assertSame($permissions, $token->claims()->get('permissions')); - $this->assertEquals(JwtScope::Websocket->value, $token->claims()->get('scope')); - } -} +uses(ClientApiIntegrationTestCase::class); +test('subuser without websocket permission receives error', function () { + [$user, $server] = $this->generateTestAccount([Permissions::ControlRestart->value]); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket")->assertStatus(Response::HTTP_FORBIDDEN)->assertJsonPath('errors.0.code', 'HttpForbiddenException')->assertJsonPath('errors.0.detail', 'You do not have permission to connect to this server\'s websocket.'); +}); +test('user without permission for server receives error', function () { + [, $server] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + [$user] = $this->generateTestAccount([Permissions::WebsocketConnect->value]); + $this->actingAs($user)->getJson("/api/client/servers/{$server->uuid}/websocket")->assertStatus(Response::HTTP_NOT_FOUND); +}); +test('jwt and websocket url are returned for server owner', function () { + /** @var User $user */ + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount(); + // Force the node to HTTPS since we want to confirm it gets transformed to wss:// in the URL. + $server->node->scheme = 'https'; + $server->node->save(); + $response = $this->actingAs($user)->withoutExceptionHandling()->getJson("/api/client/servers/{$server->uuid}/websocket")->assertOk()->assertJsonStructure(['data' => ['token', 'socket']]); + $connection = $response->json('data.socket'); + expect($connection)->toStartWith('wss://', 'Failed asserting that websocket connection address has expected "wss://" prefix.'); + expect($connection)->toEndWith("/api/servers/{$server->uuid}/ws", 'Failed asserting that websocket connection address uses expected Wings endpoint.'); + $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); + $config = $config->withValidationConstraints(new SignedWith(new Sha256(), $key)); + /** @var Plain $token */ + $token = $config->parser()->parse($response->json('data.token')); + expect($config->validator()->validate($token, ...$config->validationConstraints()))->toBeTrue('Failed to validate that the JWT data returned was signed using the Node\'s secret key.'); + // The way we generate times for the JWT will truncate the microseconds from the + // time, but CarbonImmutable::now() will include them, thus causing test failures. + // + // This little chunk of logic just strips those out by generating a new CarbonImmutable + // instance from the current timestamp, which is how the JWT works. We also need to + // switch to UTC here for consistency. + $expect = CarbonImmutable::createFromTimestamp(CarbonImmutable::now()->getTimestamp())->timezone('UTC'); + // Check that the claims are generated correctly. + expect($token->hasBeenIssuedBy(config('app.url')))->toBeTrue(); + expect($token->isPermittedFor($server->node->getConnectionAddress()))->toBeTrue(); + expect($token->claims()->get('iat'))->toEqual($expect); + expect($token->claims()->get('nbf'))->toEqual($expect->subMinutes(5)); + expect($token->claims()->get('exp'))->toEqual($expect->addMinutes(10)); + expect($token->claims()->get('user_uuid'))->toBe($user->uuid); + expect($token->claims()->get('server_uuid'))->toBe($server->uuid); + expect($token->claims()->get('permissions'))->toBe(['*']); + expect($token->claims()->get('scope'))->toEqual(JwtScope::Websocket->value); +}); +test('jwt is configured correctly for server subuser', function () { + $permissions = [Permissions::WebsocketConnect->value, Permissions::ControlConsole->value]; + /** @var User $user */ + /** @var Server $server */ + [$user, $server] = $this->generateTestAccount($permissions); + $response = $this->actingAs($user)->withoutExceptionHandling()->getJson("/api/client/servers/{$server->uuid}/websocket")->assertOk()->assertJsonStructure(['data' => ['token', 'socket']]); + $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); + $config = $config->withValidationConstraints(new SignedWith(new Sha256(), $key)); + /** @var Plain $token */ + $token = $config->parser()->parse($response->json('data.token')); + expect($config->validator()->validate($token, ...$config->validationConstraints()))->toBeTrue('Failed to validate that the JWT data returned was signed using the Node\'s secret key.'); + // Check that the claims are generated correctly. + expect($token->claims()->get('permissions'))->toBe($permissions); + expect($token->claims()->get('scope'))->toEqual(JwtScope::Websocket->value); +}); diff --git a/tests/Integration/Api/Client/TwoFactorControllerTest.php b/tests/Integration/Api/Client/TwoFactorControllerTest.php index 5c3d80388..4ed2a60d6 100644 --- a/tests/Integration/Api/Client/TwoFactorControllerTest.php +++ b/tests/Integration/Api/Client/TwoFactorControllerTest.php @@ -1,207 +1,107 @@ create(['use_totp' => false]); - - $this->assertFalse($user->use_totp); - $this->assertEmpty($user->totp_secret); - $this->assertEmpty($user->totp_authenticated_at); - - $response = $this->actingAs($user)->getJson('/api/client/account/two-factor'); - - $response->assertOk(); - $response->assertJsonStructure(['data' => ['image_url_data']]); - - $user = $user->refresh(); - - $this->assertFalse($user->use_totp); - $this->assertNotEmpty($user->totp_secret); - $this->assertEmpty($user->totp_authenticated_at); - } - - /** - * Test that an error is returned if the user's account already has 2FA enabled on it. - */ - public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled() - { - /** @var User $user */ - $user = User::factory()->create(['use_totp' => true]); - - $response = $this->actingAs($user)->getJson('/api/client/account/two-factor'); - - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); - $response->assertJsonPath('errors.0.detail', 'Two-factor authentication is already enabled on this account.'); - } - - /** - * Test that a validation error is thrown if invalid data is passed to the 2FA endpoint. - */ - public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA() - { - /** @var User $user */ - $user = User::factory()->create(['use_totp' => false]); - - $this->actingAs($user) - ->postJson('/api/client/account/two-factor', ['code' => '']) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta.rule', 'required') - ->assertJsonPath('errors.0.meta.source_field', 'code') - ->assertJsonPath('errors.1.meta.rule', 'required') - ->assertJsonPath('errors.1.meta.source_field', 'password'); - } - - /** - * Tests that 2FA can be enabled on an account for the user. - */ - public function testTwoFactorCanBeEnabledOnAccount() - { - /** @var User $user */ - $user = User::factory()->create(['use_totp' => false]); - - // Make the initial call to get the account setup for 2FA. - $this->actingAs($user)->getJson('/api/client/account/two-factor')->assertOk(); - - $user = $user->refresh(); - $this->assertNotNull($user->totp_secret); - - /** @var Google2FA $service */ - $service = $this->app->make(Google2FA::class); - - $secret = decrypt($user->totp_secret); - $token = $service->getCurrentOtp($secret); - - $response = $this->actingAs($user)->postJson('/api/client/account/two-factor', [ - 'code' => $token, - 'password' => 'password', - ]); - - $response->assertOk(); - $response->assertJsonPath('object', 'recovery_tokens'); - - $user = $user->refresh(); - $this->assertTrue($user->use_totp); - - $tokens = RecoveryToken::query()->where('user_id', $user->id)->get(); - $this->assertCount(10, $tokens); - $this->assertStringStartsWith('$2y$10$', $tokens[0]->token); - // Ensure the recovery tokens that were created include a "created_at" timestamp - // value on them. - // - // @see https://github.com/pterodactyl/panel/issues/3163 - $this->assertNotNull($tokens[0]->created_at); - - $tokens = $tokens->pluck('token')->toArray(); - - foreach ($response->json('attributes.tokens') as $raw) { - foreach ($tokens as $hashed) { - if (password_verify($raw, $hashed)) { - continue 2; - } +uses(\Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase::class); +test('two factor image data is returned', function () { + /** @var User $user */ + $user = User::factory()->create(['use_totp' => false]); + expect($user->use_totp)->toBeFalse(); + expect($user->totp_secret)->toBeEmpty(); + expect($user->totp_authenticated_at)->toBeEmpty(); + $response = $this->actingAs($user)->getJson('/api/client/account/two-factor'); + $response->assertOk(); + $response->assertJsonStructure(['data' => ['image_url_data']]); + $user = $user->refresh(); + expect($user->use_totp)->toBeFalse(); + expect($user->totp_secret)->not->toBeEmpty(); + expect($user->totp_authenticated_at)->toBeEmpty(); +}); +test('error is returned when two factor is already enabled', function () { + /** @var User $user */ + $user = User::factory()->create(['use_totp' => true]); + $response = $this->actingAs($user)->getJson('/api/client/account/two-factor'); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); + $response->assertJsonPath('errors.0.detail', 'Two-factor authentication is already enabled on this account.'); +}); +test('validation error is returned if invalid data is passed to enabled2 fa', function () { + /** @var User $user */ + $user = User::factory()->create(['use_totp' => false]); + $this->actingAs($user)->postJson('/api/client/account/two-factor', ['code' => ''])->assertUnprocessable()->assertJsonPath('errors.0.meta.rule', 'required')->assertJsonPath('errors.0.meta.source_field', 'code')->assertJsonPath('errors.1.meta.rule', 'required')->assertJsonPath('errors.1.meta.source_field', 'password'); +}); +test('two factor can be enabled on account', function () { + /** @var User $user */ + $user = User::factory()->create(['use_totp' => false]); + // Make the initial call to get the account setup for 2FA. + $this->actingAs($user)->getJson('/api/client/account/two-factor')->assertOk(); + $user = $user->refresh(); + expect($user->totp_secret)->not->toBeNull(); + /** @var Google2FA $service */ + $service = $this->app->make(Google2FA::class); + $secret = decrypt($user->totp_secret); + $token = $service->getCurrentOtp($secret); + $response = $this->actingAs($user)->postJson('/api/client/account/two-factor', ['code' => $token, 'password' => 'password']); + $response->assertOk(); + $response->assertJsonPath('object', 'recovery_tokens'); + $user = $user->refresh(); + expect($user->use_totp)->toBeTrue(); + $tokens = RecoveryToken::query()->where('user_id', $user->id)->get(); + expect($tokens)->toHaveCount(10); + expect($tokens[0]->token)->toStartWith('$2y$10$'); + // Ensure the recovery tokens that were created include a "created_at" timestamp + // value on them. + // + // @see https://github.com/pterodactyl/panel/issues/3163 + expect($tokens[0]->created_at)->not->toBeNull(); + $tokens = $tokens->pluck('token')->toArray(); + foreach ($response->json('attributes.tokens') as $raw) { + foreach ($tokens as $hashed) { + if (password_verify($raw, $hashed)) { + continue 2; } - - throw new ExpectationFailedException(sprintf('Failed asserting that token [%s] exists as a hashed value in recovery_tokens table.', $raw)); } + throw new ExpectationFailedException(sprintf('Failed asserting that token [%s] exists as a hashed value in recovery_tokens table.', $raw)); } - - /** - * Test that two-factor authentication can be disabled on an account as long as the password - * provided is valid for the account. - */ - public function testTwoFactorCanBeDisabledOnAccount() - { - Carbon::setTestNow(Carbon::now()); - - /** @var User $user */ - $user = User::factory()->create(['use_totp' => true]); - - $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [ - 'password' => 'invalid', - ]); - - $response->assertStatus(Response::HTTP_BAD_REQUEST); - $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); - $response->assertJsonPath('errors.0.detail', 'The password provided was not valid.'); - - $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [ - 'password' => 'password', - ]); - - $response->assertStatus(Response::HTTP_NO_CONTENT); - - $user = $user->refresh(); - $this->assertFalse($user->use_totp); - $this->assertNotNull($user->totp_authenticated_at); - $this->assertSame(Carbon::now()->toAtomString(), $user->totp_authenticated_at->toAtomString()); - } - - /** - * Test that no error is returned when trying to disabled two factor on an account where it - * was not enabled in the first place. - */ - public function testNoErrorIsReturnedIfTwoFactorIsNotEnabled() - { - Carbon::setTestNow(Carbon::now()); - - /** @var User $user */ - $user = User::factory()->create(['use_totp' => false]); - - $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [ - 'password' => 'password', - ]); - - $response->assertStatus(Response::HTTP_NO_CONTENT); - } - - /** - * Test that a valid account password is required when enabling two-factor. - */ - public function testEnablingTwoFactorRequiresValidPassword() - { - $user = User::factory()->create(['use_totp' => false]); - - $this->actingAs($user) - ->postJson('/api/client/account/two-factor', [ - 'code' => '123456', - 'password' => 'foo', - ]) - ->assertStatus(Response::HTTP_BAD_REQUEST) - ->assertJsonPath('errors.0.detail', 'The password provided was not valid.'); - - $this->assertFalse($user->refresh()->use_totp); - } - - /** - * Test that a valid account password is required when disabling two-factor. - */ - public function testDisablingTwoFactorRequiresValidPassword() - { - $user = User::factory()->create(['use_totp' => true]); - - $this->actingAs($user) - ->postJson('/api/client/account/two-factor/disable', [ - 'password' => 'foo', - ]) - ->assertStatus(Response::HTTP_BAD_REQUEST) - ->assertJsonPath('errors.0.detail', 'The password provided was not valid.'); - - $this->assertTrue($user->refresh()->use_totp); - } -} +}); +test('two factor can be disabled on account', function () { + Carbon::setTestNow(Carbon::now()); + /** @var User $user */ + $user = User::factory()->create(['use_totp' => true]); + $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', ['password' => 'invalid']); + $response->assertStatus(Response::HTTP_BAD_REQUEST); + $response->assertJsonPath('errors.0.code', 'InvalidPasswordProvidedException'); + $response->assertJsonPath('errors.0.detail', 'The password provided was invalid for this account.'); + $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', ['password' => 'password']); + $response->assertStatus(Response::HTTP_NO_CONTENT); + $user = $user->refresh(); + expect($user->use_totp)->toBeFalse(); + expect($user->totp_authenticated_at)->not->toBeNull(); + expect($user->totp_authenticated_at->toAtomString())->toBe(Carbon::now()->toAtomString()); +}); +test('no error is returned if two factor is not enabled', function () { + Carbon::setTestNow(Carbon::now()); + /** @var User $user */ + $user = User::factory()->create(['use_totp' => false]); + $response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', ['password' => 'password']); + $response->assertStatus(Response::HTTP_NO_CONTENT); +}); +test('enabling two factor requires valid password', function () { + $user = User::factory()->create(['use_totp' => false]); + $this->actingAs($user)->postJson('/api/client/account/two-factor', ['code' => '123456', 'password' => 'foo'])->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.detail', 'The password provided was invalid for this account.'); + expect($user->refresh()->use_totp)->toBeFalse(); +}); +test('disabling two factor requires valid password', function () { + $user = User::factory()->create(['use_totp' => true]); + $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', ['password' => 'foo'])->assertStatus(Response::HTTP_BAD_REQUEST)->assertJsonPath('errors.0.detail', 'The password provided was invalid for this account.'); + expect($user->refresh()->use_totp)->toBeTrue(); +}); diff --git a/tests/Integration/Api/Remote/ActivityProcessingControllerTest.php b/tests/Integration/Api/Remote/ActivityProcessingControllerTest.php new file mode 100644 index 000000000..c11079619 --- /dev/null +++ b/tests/Integration/Api/Remote/ActivityProcessingControllerTest.php @@ -0,0 +1,73 @@ +generateTestAccount(); + $this->user = $user; + $this->server = $server; + setAuthorization($server->node); +}); +test('events are recorded against the server and actor', function () { + $timestamp = CarbonImmutable::now()->subMinute(); + $this->postJson('/api/remote/activity', ['data' => [['user' => $this->user->uuid, 'server' => $this->server->uuid, 'event' => 'server:console.command', 'metadata' => ['command' => 'say hello'], 'ip' => '192.168.1.1', 'timestamp' => $timestamp->toRfc3339String()]]])->assertSuccessful(); + $log = logsFor($this->server)->where('event', 'server:console.command')->sole(); + expect($log->ip)->toBe('192.168.1.1'); + expect($log->actor_id)->toBe($this->user->id); + expect($log->actor_type)->toBe($this->user->getMorphClass()); + expect($log->properties->all())->toBe(['command' => 'say hello']); + expect($log->timestamp->utc()->toDateTimeString())->toBe($timestamp->toDateTimeString()); + $subject = $log->subjects->sole(); + expect($subject->subject_id)->toBe($this->server->id); + expect($subject->subject_type)->toBe($this->server->getMorphClass()); +}); +test('events without a user are recorded with no actor', function () { + $this->postJson('/api/remote/activity', ['data' => [['server' => $this->server->uuid, 'event' => 'server:crashed', 'metadata' => null, 'timestamp' => CarbonImmutable::now()->toRfc3339String()]]])->assertSuccessful(); + $log = logsFor($this->server)->where('event', 'server:crashed')->sole(); + expect($log->actor_id)->toBeNull(); + expect($log->actor_type)->toBeNull(); + expect($log->ip)->toBe('127.0.0.1'); +}); +test('events for other nodes and foreign namespaces are discarded', function () { + $other = $this->createServerModel(); + $this->assertNotSame($this->server->node_id, $other->node_id); + $this->postJson('/api/remote/activity', ['data' => [['user' => $this->user->uuid, 'server' => $other->uuid, 'event' => 'server:console.command', 'metadata' => [], 'timestamp' => CarbonImmutable::now()->toRfc3339String()], ['user' => $this->user->uuid, 'server' => $this->server->uuid, 'event' => 'user:api-key.create', 'metadata' => [], 'timestamp' => CarbonImmutable::now()->toRfc3339String()]]])->assertSuccessful(); + expect(logsFor($this->server)->count())->toBe(0); + expect(logsFor($other)->count())->toBe(0); +}); +test('unparsable timestamps do not fail the request', function () { + $this->postJson('/api/remote/activity', ['data' => [['user' => $this->user->uuid, 'server' => $this->server->uuid, 'event' => 'server:console.command', 'metadata' => [], 'timestamp' => 'not a timestamp']]])->assertSuccessful(); + $log = logsFor($this->server)->where('event', 'server:console.command')->sole(); + expect($log->properties->get('original_timestamp'))->toBe('not a timestamp'); +}); +/** + * Activity logged against a specific server. The suite shares one database + * across test classes, so assertions have to be scoped to this test's own + * server rather than counting every row in the table. + * + * @return Builder + */ +function logsFor(Server $server): Builder +{ + return ActivityLog::query()->whereHas('subjects', fn (Builder $query) => $query->where('subject_id', $server->id)->where('subject_type', $server->getMorphClass())); +} +function setAuthorization(Node $node): void +{ + (function () use ($node) { + $this->withHeader('Authorization', 'Bearer '.$node->daemon_token_id.'.'.decrypt($node->daemon_token)); + })->call(pterodactylTestCase()); +} diff --git a/tests/Integration/Api/Remote/RemoteServersApiTest.php b/tests/Integration/Api/Remote/RemoteServersApiTest.php new file mode 100644 index 000000000..7b5e2cfb3 --- /dev/null +++ b/tests/Integration/Api/Remote/RemoteServersApiTest.php @@ -0,0 +1,179 @@ +getJson('/api/remote/servers')->assertUnauthorized(); +}); +test('node can list its own servers', function () { + $server = $this->createServerModel(); + // A server on a different node must never be included. + $other = $this->createServerModel(); + $response = actingAsNode($server->node)->getJson('/api/remote/servers')->assertOk()->assertJsonCount(1, 'data')->assertJsonPath('data.0.uuid', $server->uuid); + $this->assertNotSame($other->node_id, $server->node_id); +}); +test('node can fetch a single server configuration', function () { + $server = $this->createServerModel(); + actingAsNode($server->node)->getJson("/api/remote/servers/{$server->uuid}")->assertOk()->assertJsonStructure(['settings', 'process_configuration'])->assertJsonPath('settings.uuid', $server->uuid); +}); +test('node cannot fetch a server it does not own', function () { + $server = $this->createServerModel(); + $otherNode = Node::factory()->for(Location::factory())->create(); + actingAsNode($otherNode)->getJson("/api/remote/servers/{$server->uuid}")->assertForbidden(); +}); +test('node can fetch install script details', function () { + $server = $this->createServerModel(); + actingAsNode($server->node)->getJson("/api/remote/servers/{$server->uuid}/install")->assertOk()->assertJsonStructure(['container_image', 'entrypoint', 'script']); +}); +test('node can report a completed install', function () { + $server = $this->createServerModel(['status' => Server::STATUS_INSTALLING, 'installed_at' => null]); + actingAsNode($server->node)->postJson("/api/remote/servers/{$server->uuid}/install", ['successful' => true, 'reinstall' => false])->assertNoContent(); + $server->refresh(); + expect($server->status)->toBeNull(); + expect($server->installed_at)->not->toBeNull(); +}); +test('node can report a failed install', function () { + $server = $this->createServerModel(['status' => Server::STATUS_INSTALLING, 'installed_at' => null]); + actingAsNode($server->node)->postJson("/api/remote/servers/{$server->uuid}/install", ['successful' => false, 'reinstall' => false])->assertNoContent(); + expect($server->refresh()->status)->toBe(Server::STATUS_INSTALL_FAILED); +}); +test('node can reset restoring servers', function () { + $server = $this->createServerModel(); + $server->update(['status' => Server::STATUS_RESTORING_BACKUP]); + actingAsNode($server->node)->postJson('/api/remote/servers/reset')->assertNoContent(); + expect($server->refresh()->status)->toBeNull(); +}); +test('node can push activity events', function () { + $server = $this->createServerModel(); + $user = User::factory()->create(); + actingAsNode($server->node)->postJson('/api/remote/activity', ['data' => [['server' => $server->uuid, 'user' => $user->uuid, 'event' => 'server:power.start', 'metadata' => null, 'ip' => '10.0.0.5', 'timestamp' => now()->toRfc3339String()]]])->assertOk(); + $this->assertDatabaseHas('activity_logs', ['event' => 'server:power.start', 'actor_id' => $user->id]); +}); +test('node can mark a backup as completed', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id, 'is_successful' => false, 'completed_at' => null]); + actingAsNode($server->node)->postJson("/api/remote/backups/{$backup->uuid}", ['successful' => true, 'checksum' => 'abc123', 'checksum_type' => 'sha1', 'size' => 1024])->assertNoContent(); + $backup->refresh(); + expect($backup->is_successful)->toBeTrue(); + expect($backup->checksum)->toBe('sha1:abc123'); + expect($backup->bytes)->toBe(1024); + expect($backup->completed_at)->not->toBeNull(); +}); +test('completed backup cannot be reported again', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id, 'is_successful' => true]); + actingAsNode($server->node)->postJson("/api/remote/backups/{$backup->uuid}", ['successful' => true, 'checksum' => 'x', 'checksum_type' => 'sha1', 'size' => 1])->assertBadRequest(); +}); +test('node can mark a backup restore as complete', function () { + $server = $this->createServerModel(); + $server->update(['status' => Server::STATUS_RESTORING_BACKUP]); + $backup = Backup::factory()->create(['server_id' => $server->id]); + actingAsNode($server->node)->postJson("/api/remote/backups/{$backup->uuid}/restore", ['successful' => true])->assertNoContent(); + expect($server->refresh()->status)->toBeNull(); + expect($server->activity()->where('event', 'server:backup.restore-complete')->exists())->toBeTrue(); +}); +test('node can mark a backup restore as failed', function () { + $server = $this->createServerModel(); + $server->update(['status' => Server::STATUS_RESTORING_BACKUP]); + $backup = Backup::factory()->create(['server_id' => $server->id]); + actingAsNode($server->node)->postJson("/api/remote/backups/{$backup->uuid}/restore", ['successful' => false])->assertNoContent(); + expect($server->refresh()->status)->toBeNull(); + expect($server->activity()->where('event', 'server:backup.restore-failed')->exists())->toBeTrue(); +}); +test('backup upload url requires size and s3 adapter', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id, 'is_successful' => false, 'completed_at' => null]); + actingAsNode($server->node)->getJson("/api/remote/backups/{$backup->uuid}")->assertBadRequest(); + // The default backup adapter is wings, which does not support generating + // multipart upload URLs. + actingAsNode($server->node)->getJson("/api/remote/backups/{$backup->uuid}?size=1024")->assertBadRequest(); +}); +function actingAsNode(Node $node): IntegrationTestCase +{ + return (function () use ($node) { + return $this->withHeader('Authorization', "Bearer {$node->daemon_token_id}.".$node->getDecryptedKey()); + })->call(pterodactylTestCase()); +} + +test('reporting a failed backup restore records a namespaced server event', function () { + $server = $this->createServerModel(['status' => Server::STATUS_RESTORING_BACKUP]); + $backup = Backup::factory()->create(['server_id' => $server->id]); + + actingAsNode($server->node)->postJson("/api/remote/backups/{$backup->uuid}/restore", ['successful' => false])->assertNoContent(); + + expect($server->activity()->where('event', 'server:backup.restore-failed')->exists())->toBeTrue(); +}); + +test('wings configurations batch variables and keep per server overrides', function () { + $first = $this->createServerModel(); + $servers = [$first]; + for ($i = 1; $i < 10; $i++) { + $servers[] = $this->createServerModel(['node_id' => $first->node_id, 'egg_id' => $first->egg_id]); + } + $variable = $first->egg->variables()->firstOrFail(); + foreach ($servers as $i => $server) { + ServerVariable::query()->create(['server_id' => $server->id, 'variable_id' => $variable->id, 'variable_value' => 'wings-'.$i]); + } + $request = fn (int $limit) => actingAsNode($first->node)->getJson('/api/remote/servers?per_page='.$limit); + $request(1)->assertOk(); + $counts = []; + foreach ([1, 10] as $limit) { + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $request($limit)->assertOk()->assertJsonCount($limit, 'data'); + $counts[] = count(array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select'))); + } finally { + DB::disableQueryLog(); + } + } + expect($counts[1])->toBe($counts[0]); + $response = $request(10)->assertOk(); + foreach ($servers as $i => $server) { + $row = collect($response->json('data'))->firstWhere('uuid', $server->uuid); + expect($row['settings']['environment'][$variable->env_variable])->toBe('wings-'.$i); + } +}); + +test('resetting restoring servers loads backup subjects together', function () { + $first = $this->createServerModel(); + $servers = [$first]; + for ($i = 1; $i < 10; $i++) { + $servers[] = $this->createServerModel(['node_id' => $first->node_id]); + } + foreach ($servers as $server) { + $server->update(['status' => Server::STATUS_RESTORING_BACKUP]); + $backup = Backup::factory()->create(['server_id' => $server->id]); + Activity::event('server:backup.restore')->subject($server, $backup)->log(); + } + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + actingAsNode($first->node)->postJson('/api/remote/servers/reset')->assertNoContent(); + $reads = array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select') && str_contains($query['query'], 'from `backups`')); + expect($reads)->toHaveCount(1); + } finally { + DB::disableQueryLog(); + } + foreach ($servers as $server) { + expect($server->fresh()->status)->toBeNull(); + expect($server->activity()->where('event', 'server:backup.restore-failed')->exists())->toBeTrue(); + } +}); diff --git a/tests/Integration/Api/Remote/ServerTransferControllerTest.php b/tests/Integration/Api/Remote/ServerTransferControllerTest.php index 8b119a651..16bf54f11 100644 --- a/tests/Integration/Api/Remote/ServerTransferControllerTest.php +++ b/tests/Integration/Api/Remote/ServerTransferControllerTest.php @@ -1,111 +1,81 @@ createServerModel(); + $new = Node::factory()->for(Location::factory())->has(Allocation::factory())->create(); + $this->transfer = ServerTransfer::factory()->for($server)->create(['old_allocation' => $server->allocation_id, 'new_allocation' => $new->allocations->first()->id, 'new_node' => $new->id, 'old_node' => $server->node_id]); +}); +test('success status update can be sent from new node', function () { + $server = $this->transfer->server; + $source = $this->transfer->oldNode; + $url = $source->getConnectionAddress()."/api/servers/{$server->uuid}"; + Http::fake([$url => Http::response()]); + $newNode = $this->transfer->newNode; + $this->withHeader('Authorization', "Bearer {$newNode->daemon_token_id}.".$newNode->getDecryptedKey())->postJson("/api/remote/servers/{$server->uuid}/transfer/success")->assertNoContent(); + expect($this->transfer->refresh()->successful)->toBeTrue(); + Http::assertSent(fn (Request $request): bool => $request->method() === 'DELETE' + && $request->url() === $url + && $request->hasHeader('Authorization', 'Bearer '.$source->getDecryptedKey())); + Http::assertSentCount(1); +}); +test('failure status update can be sent from old node', function () { + $server = $this->transfer->server; + $oldNode = $this->transfer->oldNode; + $this->withHeader('Authorization', "Bearer {$oldNode->daemon_token_id}.".$oldNode->getDecryptedKey())->postJson("/api/remote/servers/{$server->uuid}/transfer/failure")->assertNoContent(); + expect($this->transfer->refresh()->successful)->toBeFalse(); +}); +test('failure status update can be sent from new node', function () { + $server = $this->transfer->server; + $newNode = $this->transfer->newNode; + $this->withHeader('Authorization', "Bearer {$newNode->daemon_token_id}.".$newNode->getDecryptedKey())->postJson("/api/remote/servers/{$server->uuid}/transfer/failure")->assertNoContent(); + expect($this->transfer->refresh()->successful)->toBeFalse(); +}); +test('success status update cannot be sent from old node', function () { + $server = $this->transfer->server; + $oldNode = $this->transfer->oldNode; + $this->withHeader('Authorization', "Bearer {$oldNode->daemon_token_id}.".$oldNode->getDecryptedKey())->postJson("/api/remote/servers/{$server->uuid}/transfer/success")->assertForbidden()->assertJsonPath('errors.0.code', 'HttpForbiddenException')->assertJsonPath('errors.0.detail', 'Requesting node does not have permission to access this server.'); + expect($this->transfer->refresh()->successful)->toBeNull(); +}); +test('success status update cannot be sent from unauthorized node', function () { + $server = $this->transfer->server; + $node = Node::factory()->for(Location::factory())->create(); + $this->withHeader('Authorization', "Bearer {$node->daemon_token_id}.".$node->getDecryptedKey())->postJson("/api/remote/servers/{$server->uuid}/transfer/success")->assertForbidden()->assertJsonPath('errors.0.code', 'HttpForbiddenException')->assertJsonPath('errors.0.detail', 'Requesting node does not have permission to access this server.'); + expect($this->transfer->refresh()->successful)->toBeNull(); +}); +test('failure status update cannot be sent from unauthorized node', function () { + $server = $this->transfer->server; + $node = Node::factory()->for(Location::factory())->create(); + $this->withHeader('Authorization', "Bearer {$node->daemon_token_id}.".$node->getDecryptedKey())->postJson("/api/remote/servers/{$server->uuid}/transfer/failure")->assertForbidden()->assertJsonPath('errors.0.code', 'HttpForbiddenException')->assertJsonPath('errors.0.detail', 'Requesting node does not have permission to access this server.'); + expect($this->transfer->refresh()->successful)->toBeNull(); +}); - public function setup(): void - { - parent::setUp(); +test('transfer results are reported to operation listeners', function (string $result, bool $successful) { + Event::fake([OperationCompleted::class]); + $server = $this->transfer->server; + Http::fake([$this->transfer->oldNode->getConnectionAddress()."/api/servers/{$server->uuid}" => Http::response()]); + $newNode = $this->transfer->newNode; - $server = $this->createServerModel(); + $this->withHeader('Authorization', "Bearer {$newNode->daemon_token_id}.".$newNode->getDecryptedKey())->postJson("/api/remote/servers/{$server->uuid}/transfer/{$result}")->assertNoContent(); - $new = Node::factory() - ->for(Location::factory()) - ->has(Allocation::factory()) - ->create(); - - $this->transfer = ServerTransfer::factory()->for($server)->create([ - 'old_allocation' => $server->allocation_id, - 'new_allocation' => $new->allocations->first()->id, - 'new_node' => $new->id, - 'old_node' => $server->node_id, - ]); - } - - public function testSuccessStatusUpdateCanBeSentFromNewNode(): void - { - $server = $this->transfer->server; - $newNode = $this->transfer->newNode; - - $this - ->withHeader('Authorization', "Bearer $newNode->daemon_token_id." . $newNode->getDecryptedKey()) - ->postJson("/api/remote/servers/{$server->uuid}/transfer/success") - ->assertNoContent(); - - $this->assertTrue($this->transfer->refresh()->successful); - } - - public function testFailureStatusUpdateCanBeSentFromOldNode(): void - { - $server = $this->transfer->server; - $oldNode = $this->transfer->oldNode; - - $this->withHeader('Authorization', "Bearer $oldNode->daemon_token_id." . $oldNode->getDecryptedKey()) - ->postJson("/api/remote/servers/{$server->uuid}/transfer/failure") - ->assertNoContent(); - - $this->assertFalse($this->transfer->refresh()->successful); - } - - public function testFailureStatusUpdateCanBeSentFromNewNode(): void - { - $server = $this->transfer->server; - $newNode = $this->transfer->newNode; - - $this->withHeader('Authorization', "Bearer $newNode->daemon_token_id." . $newNode->getDecryptedKey()) - ->postJson("/api/remote/servers/{$server->uuid}/transfer/failure") - ->assertNoContent(); - - $this->assertFalse($this->transfer->refresh()->successful); - } - - public function testSuccessStatusUpdateCannotBeSentFromOldNode(): void - { - $server = $this->transfer->server; - $oldNode = $this->transfer->oldNode; - - $this->withHeader('Authorization', "Bearer $oldNode->daemon_token_id." . $oldNode->getDecryptedKey()) - ->postJson("/api/remote/servers/{$server->uuid}/transfer/success") - ->assertForbidden() - ->assertJsonPath('errors.0.code', 'HttpForbiddenException') - ->assertJsonPath('errors.0.detail', 'Requesting node does not have permission to access this server.'); - - $this->assertNull($this->transfer->refresh()->successful); - } - - public function testSuccessStatusUpdateCannotBeSentFromUnauthorizedNode(): void - { - $server = $this->transfer->server; - $node = Node::factory()->for(Location::factory())->create(); - - $this->withHeader('Authorization', "Bearer $node->daemon_token_id." . $node->getDecryptedKey()) - ->postJson("/api/remote/servers/$server->uuid/transfer/success") - ->assertForbidden() - ->assertJsonPath('errors.0.code', 'HttpForbiddenException') - ->assertJsonPath('errors.0.detail', 'Requesting node does not have permission to access this server.'); - - $this->assertNull($this->transfer->refresh()->successful); - } - - public function testFailureStatusUpdateCannotBeSentFromUnauthorizedNode(): void - { - $server = $this->transfer->server; - $node = Node::factory()->for(Location::factory())->create(); - - $this->withHeader('Authorization', "Bearer $node->daemon_token_id." . $node->getDecryptedKey()) - ->postJson("/api/remote/servers/$server->uuid/transfer/failure")->assertForbidden() - ->assertJsonPath('errors.0.code', 'HttpForbiddenException') - ->assertJsonPath('errors.0.detail', 'Requesting node does not have permission to access this server.'); - - $this->assertNull($this->transfer->refresh()->successful); - } -} + Event::assertDispatchedTimes(OperationCompleted::class, 1); + Event::assertDispatched(OperationCompleted::class, fn (OperationCompleted $event): bool => $event->operation === 'transfer' + && $event->successful === $successful + && $event->serverUuid === $server->uuid + && $event->resourceUuid === $server->uuid); +})->with([['success', true], ['failure', false]]); diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index c793435d6..f73e0bf81 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -1,246 +1,117 @@ generateTestAccount(); + $user->update(['password' => 'foobar']); + $this->user = $user; + $this->server = $server; + setAuthorization(); +}); +dataset('authorizationTypeDataProvider', function () { + return ['password auth' => ['password'], 'public key auth' => ['public_key']]; +}); +dataset('serverStateDataProvider', function () { + return ['installing' => [Server::STATUS_INSTALLING], 'suspended' => [Server::STATUS_SUSPENDED], 'restoring a backup' => [Server::STATUS_RESTORING_BACKUP]]; +}); +test('public key is validated correctly', function () { + $key = UserSSHKey::factory()->for($this->user)->create(); + $this->postJson('/api/remote/sftp/auth', [])->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'username')->assertJsonPath('errors.0.meta.rule', 'required')->assertJsonPath('errors.1.meta.source_field', 'password')->assertJsonPath('errors.1.meta.rule', 'required'); + $data = ['type' => 'public_key', 'username' => getUsername(), 'password' => $key->public_key]; + $this->postJson('/api/remote/sftp/auth', $data)->assertOk()->assertJsonPath('server', $this->server->uuid)->assertJsonPath('permissions', ['*']); + $key->delete(); + $this->postJson('/api/remote/sftp/auth', $data)->assertForbidden(); + $this->postJson('/api/remote/sftp/auth', array_merge($data, ['type' => null]))->assertForbidden(); +}); +test('password is validated correctly', function () { + $this->postJson('/api/remote/sftp/auth', ['username' => getUsername(), 'password' => ''])->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'password')->assertJsonPath('errors.0.meta.rule', 'required'); + $this->postJson('/api/remote/sftp/auth', ['username' => getUsername(), 'password' => 'wrong password'])->assertForbidden(); + $this->user->update(['password' => 'foobar']); + $this->postJson('/api/remote/sftp/auth', ['username' => getUsername(), 'password' => 'foobar'])->assertOk(); +}); +test('user is throttled if invalid credentials are provided', function () { + // Requests alternate between two usernames, so each throttle key is hit + // every other request and the lockout fires once the first key has + // recorded the configured number of attempts. + $limit = (int) config('auth.lockout.attempts') * 2; + for ($i = 0; $i <= $limit; $i++) { + $this->postJson('/api/remote/sftp/auth', ['type' => 'public_key', 'username' => $i % 2 === 0 ? $this->user->username : getUsername(), 'password' => 'invalid key'])->assertStatus($i === $limit ? 429 : 403); + } +}); +test('user is not throttled if no public key matches', function () { + for ($i = 0; $i <= 10; $i++) { + $this->postJson('/api/remote/sftp/auth', ['type' => 'public_key', 'username' => getUsername(), 'password' => EC::createKey('Ed25519')->getPublicKey()->toString('OpenSSH')])->assertForbidden(); + } +}); +test('an x509 certificate offered as a public key is rejected and throttled', function (): void { + $certificate = file_get_contents(base_path('tests/Fixtures/keys/x509-certificate.pem')); + $limit = (int) config('auth.lockout.attempts'); + for ($i = 0; $i <= $limit; $i++) { + $this->postJson('/api/remote/sftp/auth', ['type' => 'public_key', 'username' => getUsername(), 'password' => $certificate])->assertStatus($i === $limit ? 429 : 403); + } +}); +test('request is rejected if server belongs to different node', function (string $type) { + $node2 = $this->createServerModel()->node; + setAuthorization($node2); + $password = $type === 'public_key' ? UserSSHKey::factory()->for($this->user)->create()->public_key : 'foobar'; + $this->postJson('/api/remote/sftp/auth', ['type' => $type, 'username' => getUsername(), 'password' => $password])->assertForbidden(); +})->with('authorizationTypeDataProvider'); +test('request is denied if user lacks sftp permission', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileRead->value]); + $user->update(['password' => 'foobar']); + setAuthorization($server->node); + $this->postJson('/api/remote/sftp/auth', ['username' => $user->username.'.'.$server->uuidShort, 'password' => 'foobar'])->assertForbidden()->assertJsonPath('errors.0.detail', 'You do not have permission to access SFTP for this server.'); +}); +test('invalid server state returns conflict error', function (string $status) { + $this->server->update(['status' => $status]); + $this->postJson('/api/remote/sftp/auth', ['username' => getUsername(), 'password' => 'foobar'])->assertStatus(409); +})->with('serverStateDataProvider'); +test('user permissions are returned correctly', function () { + [$user, $server] = $this->generateTestAccount([Permissions::FileRead->value, Permissions::FileSftp->value]); + $user->update(['password' => 'foobar']); + setAuthorization($server->node); + $data = ['username' => $user->username.'.'.$server->uuidShort, 'password' => 'foobar']; + $this->postJson('/api/remote/sftp/auth', $data)->assertOk()->assertJsonPath('permissions', [Permissions::FileRead->value, Permissions::FileSftp->value]); + $user->update(['root_admin' => true]); + $this->postJson('/api/remote/sftp/auth', $data)->assertOk()->assertJsonPath('permissions.0', '*'); + setAuthorization(); + $data['username'] = $user->username.'.'.$this->server->uuidShort; + $this->post('/api/remote/sftp/auth', $data)->assertOk()->assertJsonPath('permissions.0', '*'); + $user->update(['root_admin' => false]); + $this->post('/api/remote/sftp/auth', $data)->assertForbidden(); +}); +/** + * Returns the username for connecting to SFTP. + */ +function getUsername(bool $long = false): string { - protected User $user; - - protected Server $server; - - /** - * Sets up the tests. - */ - public function setUp(): void - { - parent::setUp(); - - [$user, $server] = $this->generateTestAccount(); - - $user->update(['password' => password_hash('foobar', PASSWORD_DEFAULT)]); - - $this->user = $user; - $this->server = $server; - - $this->setAuthorization(); - } - - /** - * Test that a public key is validated correctly. - */ - public function testPublicKeyIsValidatedCorrectly() - { - $key = UserSSHKey::factory()->for($this->user)->create(); - - $this->postJson('/api/remote/sftp/auth', []) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta.source_field', 'username') - ->assertJsonPath('errors.0.meta.rule', 'required') - ->assertJsonPath('errors.1.meta.source_field', 'password') - ->assertJsonPath('errors.1.meta.rule', 'required'); - - $data = [ - 'type' => 'public_key', - 'username' => $this->getUsername(), - 'password' => $key->public_key, - ]; - - $this->postJson('/api/remote/sftp/auth', $data) - ->assertOk() - ->assertJsonPath('server', $this->server->uuid) - ->assertJsonPath('permissions', ['*']); - - $key->delete(); - $this->postJson('/api/remote/sftp/auth', $data)->assertForbidden(); - $this->postJson('/api/remote/sftp/auth', array_merge($data, ['type' => null]))->assertForbidden(); - } - - /** - * Test that an account password is validated correctly. - */ - public function testPasswordIsValidatedCorrectly() - { - $this->postJson('/api/remote/sftp/auth', [ - 'username' => $this->getUsername(), - 'password' => '', - ]) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta.source_field', 'password') - ->assertJsonPath('errors.0.meta.rule', 'required'); - - $this->postJson('/api/remote/sftp/auth', [ - 'username' => $this->getUsername(), - 'password' => 'wrong password', - ]) - ->assertForbidden(); - - $this->user->update(['password' => password_hash('foobar', PASSWORD_DEFAULT)]); - - $this->postJson('/api/remote/sftp/auth', [ - 'username' => $this->getUsername(), - 'password' => 'foobar', - ]) - ->assertOk(); - } - - /** - * Test that providing an invalid key and/or invalid username triggers the throttle on - * the endpoint. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('authorizationTypeDataProvider')] - public function testUserIsThrottledIfInvalidCredentialsAreProvided() - { - for ($i = 0; $i <= 10; ++$i) { - $this->postJson('/api/remote/sftp/auth', [ - 'type' => 'public_key', - 'username' => $i % 2 === 0 ? $this->user->username : $this->getUsername(), - 'password' => 'invalid key', - ]) - ->assertStatus($i === 10 ? 429 : 403); - } - } - - /** - * Test that the user is not throttled so long as a valid public key is provided, even - * if it doesn't actually exist in the database for the user. - */ - public function testUserIsNotThrottledIfNoPublicKeyMatches() - { - for ($i = 0; $i <= 10; ++$i) { - $this->postJson('/api/remote/sftp/auth', [ - 'type' => 'public_key', - 'username' => $this->getUsername(), - 'password' => EC::createKey('Ed25519')->getPublicKey()->toString('OpenSSH'), - ]) - ->assertForbidden(); - } - } - - /** - * Test that a request is rejected if the credentials are valid but the username indicates - * a server on a different node. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('authorizationTypeDataProvider')] - public function testRequestIsRejectedIfServerBelongsToDifferentNode(string $type) - { - $node2 = $this->createServerModel()->node; - - $this->setAuthorization($node2); - - $password = $type === 'public_key' - ? UserSSHKey::factory()->for($this->user)->create()->public_key - : 'foobar'; - - $this->postJson('/api/remote/sftp/auth', [ - 'type' => 'public_key', - 'username' => $this->getUsername(), - 'password' => $password, - ]) - ->assertForbidden(); - } - - public function testRequestIsDeniedIfUserLacksSftpPermission() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_FILE_READ]); - - $user->update(['password' => password_hash('foobar', PASSWORD_DEFAULT)]); - - $this->setAuthorization($server->node); - - $this->postJson('/api/remote/sftp/auth', [ - 'username' => $user->username . '.' . $server->uuidShort, - 'password' => 'foobar', - ]) - ->assertForbidden() - ->assertJsonPath('errors.0.detail', 'You do not have permission to access SFTP for this server.'); - } - - #[\PHPUnit\Framework\Attributes\DataProvider('serverStateDataProvider')] - public function testInvalidServerStateReturnsConflictError(string $status) - { - $this->server->update(['status' => $status]); - - $this->postJson('/api/remote/sftp/auth', ['username' => $this->getUsername(), 'password' => 'foobar']) - ->assertStatus(409); - } - - /** - * Test that permissions are returned for the user account correctly. - */ - public function testUserPermissionsAreReturnedCorrectly() - { - [$user, $server] = $this->generateTestAccount([Permission::ACTION_FILE_READ, Permission::ACTION_FILE_SFTP]); - - $user->update(['password' => password_hash('foobar', PASSWORD_DEFAULT)]); - - $this->setAuthorization($server->node); - - $data = [ - 'username' => $user->username . '.' . $server->uuidShort, - 'password' => 'foobar', - ]; - - $this->postJson('/api/remote/sftp/auth', $data) - ->assertOk() - ->assertJsonPath('permissions', [Permission::ACTION_FILE_READ, Permission::ACTION_FILE_SFTP]); - - $user->update(['root_admin' => true]); - - $this->postJson('/api/remote/sftp/auth', $data) - ->assertOk() - ->assertJsonPath('permissions.0', '*'); - - $this->setAuthorization(); - $data['username'] = $user->username . '.' . $this->server->uuidShort; - - $this->post('/api/remote/sftp/auth', $data) - ->assertOk() - ->assertJsonPath('permissions.0', '*'); - - $user->update(['root_admin' => false]); - $this->post('/api/remote/sftp/auth', $data)->assertForbidden(); - } - - public static function authorizationTypeDataProvider(): array - { - return [ - 'password auth' => ['password'], - 'public key auth' => ['public_key'], - ]; - } - - public static function serverStateDataProvider(): array - { - return [ - 'installing' => [Server::STATUS_INSTALLING], - 'suspended' => [Server::STATUS_SUSPENDED], - 'restoring a backup' => [Server::STATUS_RESTORING_BACKUP], - ]; - } - - /** - * Returns the username for connecting to SFTP. - */ - protected function getUsername(bool $long = false): string - { - return $this->user->username . '.' . ($long ? $this->server->uuid : $this->server->uuidShort); - } - - /** - * Sets the authorization header for the rest of the test. - */ - protected function setAuthorization(?Node $node = null): void - { - $node = $node ?? $this->server->node; - - $this->withHeader('Authorization', 'Bearer ' . $node->daemon_token_id . '.' . decrypt($node->daemon_token)); - } + return (function () use ($long) { + return $this->user->username.'.'.($long ? $this->server->uuid : $this->server->uuidShort); + })->call(pterodactylTestCase()); +} +/** + * Sets the authorization header for the rest of the test. + */ +function setAuthorization(?Node $node = null): void +{ + (function () use ($node) { + $node = $node ?? $this->server->node; + $this->withHeader('Authorization', 'Bearer '.$node->daemon_token_id.'.'.decrypt($node->daemon_token)); + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Console/Commands/Location/LocationCommandsTest.php b/tests/Integration/Console/Commands/Location/LocationCommandsTest.php new file mode 100644 index 000000000..86234a6da --- /dev/null +++ b/tests/Integration/Console/Commands/Location/LocationCommandsTest.php @@ -0,0 +1,32 @@ +artisan('p:location:make', ['--short' => 'cli-made', '--long' => 'Made from the CLI'])->assertExitCode(0); + $this->assertDatabaseHas('locations', ['short' => 'cli-made', 'long' => 'Made from the CLI']); +}); +test('make rejects a duplicate short code', function () { + Location::factory()->create(['short' => 'cli-dupe']); + $this->artisan('p:location:make', ['--short' => 'cli-dupe', '--long' => 'Duplicate'])->assertExitCode(1); + expect(Location::query()->where('short', 'cli-dupe')->count())->toBe(1); +}); +test('delete removes an empty location', function () { + $location = Location::factory()->create(['short' => 'cli-gone']); + $this->artisan('p:location:delete', ['--short' => 'cli-gone'])->assertExitCode(0); + $this->assertDatabaseMissing('locations', ['id' => $location->id]); +}); +test('delete refuses a location with nodes', function () { + $location = Location::factory()->create(['short' => 'cli-busy']); + Node::factory()->create(['location_id' => $location->id]); + expect(fn () => $this->artisan('p:location:delete', ['--short' => 'cli-busy'])) + ->toThrow(\Pterodactyl\Exceptions\Service\Location\HasActiveNodesException::class); + $this->assertDatabaseHas('locations', ['id' => $location->id]); +}); diff --git a/tests/Integration/Console/Commands/Server/BulkPowerActionCommandTest.php b/tests/Integration/Console/Commands/Server/BulkPowerActionCommandTest.php new file mode 100644 index 000000000..6fa7fe771 --- /dev/null +++ b/tests/Integration/Console/Commands/Server/BulkPowerActionCommandTest.php @@ -0,0 +1,32 @@ +createServerModel(); + $nodeServer = $this->createServerModel(); + $this->createServerModel(['node_id' => $nodeServer->node_id, 'status' => Server::STATUS_SUSPENDED]); + $this->createServerModel(['node_id' => $nodeServer->node_id, 'status' => Server::STATUS_INSTALLING]); + $this->createServerModel(); + $power = new FakeDaemonPower; + + $this->artisan('p:server:bulk-power', [ + 'action' => 'start', + '--servers' => (string) $selectedServer->id, + '--nodes' => (string) $nodeServer->node_id, + '--no-interaction' => true, + ])->assertSuccessful(); + + $power->assertSentTimes('start', 2); + $power->assertSentTo('start', $selectedServer->uuid); + $power->assertSentTo('start', $nodeServer->uuid); +}); diff --git a/tests/Integration/Console/Commands/Themes/ThemeCommandsTest.php b/tests/Integration/Console/Commands/Themes/ThemeCommandsTest.php new file mode 100644 index 000000000..def0deee7 --- /dev/null +++ b/tests/Integration/Console/Commands/Themes/ThemeCommandsTest.php @@ -0,0 +1,102 @@ +app->publicPath(); + $this->app->usePublicPath($directory.'/public'); + config()->set('extensions.themes_directory', $directory.'/themes'); + File::ensureDirectoryExists($directory.'/themes/example/assets'); + File::put($directory.'/themes/example/theme.json', '{"id":"example","name":"Example","version":"1.0.0"}'); + File::put($directory.'/themes/example/tokens.css', ':root { --accent: red; }'); + File::put($directory.'/themes/example/assets/logo.txt', 'theme asset'); + + try { + $this->artisan('p:theme:apply', ['id' => 'example'])->assertExitCode(0); + + expect(File::get(public_path('assets/theme.css')))->toBe(':root { --accent: red; }'); + expect(File::get(public_path('assets/theme/logo.txt')))->toBe('theme asset'); + + $this->artisan('p:theme:apply', ['id' => 'missing'])->assertExitCode(1); + expect(File::get(public_path('assets/theme.css')))->toBe(':root { --accent: red; }'); + + $this->artisan('p:theme:reset')->assertExitCode(0); + expect(File::exists(public_path('assets/theme.css')))->toBeFalse(); + expect(File::isDirectory(public_path('assets/theme')))->toBeFalse(); + } finally { + $this->app->usePublicPath($originalPublicPath); + File::deleteDirectory($directory); + } +}); + +test('a theme asset staging failure leaves the active stylesheet and assets intact', function (): void { + $directory = sys_get_temp_dir().'/panel-theme-'.Str::random(12); + $originalPublicPath = $this->app->publicPath(); + $this->app->usePublicPath($directory.'/public'); + config()->set('extensions.themes_directory', $directory.'/themes'); + File::ensureDirectoryExists($directory.'/themes/example/assets'); + File::ensureDirectoryExists(public_path('assets/theme')); + File::put($directory.'/themes/example/theme.json', '{"id":"example"}'); + File::put($directory.'/themes/example/tokens.css', 'new tokens'); + File::put(public_path('assets/theme.css'), 'original tokens'); + File::put(public_path('assets/theme/logo.txt'), 'original asset'); + File::partialMock()->shouldReceive('copyDirectory')->once()->andReturn(false); + + try { + expect(fn () => $this->app->make(AppliesThemes::class)->apply('example')) + ->toThrow(InvalidExtensionException::class, 'Unable to stage theme assets'); + expect(File::get(public_path('assets/theme.css')))->toBe('original tokens'); + expect(File::get(public_path('assets/theme/logo.txt')))->toBe('original asset'); + expect(glob(public_path('assets/.staging-*')))->toBeEmpty(); + } finally { + $this->app->usePublicPath($originalPublicPath); + File::deleteDirectory($directory); + } +}); + +test('a theme activation failure restores both original paths', function (): void { + $directory = sys_get_temp_dir().'/panel-theme-'.Str::random(12); + $originalPublicPath = $this->app->publicPath(); + $this->app->usePublicPath($directory.'/public'); + config()->set('extensions.themes_directory', $directory.'/themes'); + File::ensureDirectoryExists($directory.'/themes/example/assets'); + File::ensureDirectoryExists(public_path('assets/theme')); + File::put($directory.'/themes/example/theme.json', '{"id":"example"}'); + File::put($directory.'/themes/example/tokens.css', 'new tokens'); + File::put($directory.'/themes/example/assets/logo.txt', 'new asset'); + File::put(public_path('assets/theme.css'), 'original tokens'); + File::put(public_path('assets/theme/logo.txt'), 'original asset'); + $filesystem = File::getFacadeRoot(); + $publishedAssets = public_path('assets/theme'); + File::partialMock()->shouldReceive('move')->andReturnUsing(static function (string $from, string $to) use ($filesystem, $publishedAssets): bool { + if ($to === $publishedAssets && str_contains($from, '.staging-')) { + return false; + } + + return $filesystem->move($from, $to); + }); + + try { + expect(fn () => $this->app->make(AppliesThemes::class)->apply('example')) + ->toThrow(RuntimeException::class, 'Unable to move'); + expect(File::get(public_path('assets/theme.css')))->toBe('original tokens'); + expect(File::get(public_path('assets/theme/logo.txt')))->toBe('original asset'); + expect(glob(public_path('assets/.previous-*')))->toBeEmpty(); + expect(glob(public_path('assets/.staging-*')))->toBeEmpty(); + } finally { + $this->app->usePublicPath($originalPublicPath); + File::deleteDirectory($directory); + } +}); diff --git a/tests/Integration/Console/Commands/UpgradeCommandTest.php b/tests/Integration/Console/Commands/UpgradeCommandTest.php new file mode 100644 index 000000000..225cd7a3b --- /dev/null +++ b/tests/Integration/Console/Commands/UpgradeCommandTest.php @@ -0,0 +1,51 @@ +command; + if ($command[0] === 'curl') { + $archive = $command[4]; + $permissions = fileperms(dirname($archive)) & 0777; + } + + $step = $command[0] === PHP_BINARY ? $command[2] : $command[0]; + + return Process::result(errorOutput: 'Deployment failed', exitCode: $step === $failed ? 1 : 0); + }); + + expect(fn () => Artisan::call('p:upgrade', ['--user' => 'tester', '--group' => 'tester', '--no-interaction' => true])) + ->toThrow(ProcessFailedException::class); + + Process::assertRan(fn (PendingProcess $process): bool => $process->command === [PHP_BINARY, 'artisan', 'down', '--no-interaction']); + Process::assertNotRan(fn (PendingProcess $process): bool => $process->command === [PHP_BINARY, 'artisan', 'up', '--no-interaction']); + expect(Artisan::output())->not->toContain('Panel has been successfully upgraded.'); + if ($archive !== null) { + expect($permissions)->toBe(0700); + $this->assertDirectoryDoesNotExist(dirname($archive)); + } +})->with(['curl', 'tar', 'chmod', 'composer', 'view:clear', 'config:clear', 'migrate', 'chown', 'queue:restart']); + +test('upgrade leaves maintenance only after every deployment step succeeds', function (): void { + Process::fake(); + + expect(Artisan::call('p:upgrade', ['--skip-download' => true, '--user' => 'tester', '--group' => 'tester', '--no-interaction' => true]))->toBe(0); + + Process::assertRan(fn (PendingProcess $process): bool => $process->command === [PHP_BINARY, 'artisan', 'migrate', '--no-interaction', '--force', '--seed']); + Process::assertRan(fn (PendingProcess $process): bool => $process->command === [PHP_BINARY, 'artisan', 'up', '--no-interaction']); + Process::assertRanTimes(fn (PendingProcess $process): bool => true, 9); + expect(Artisan::output())->toContain('Panel has been successfully upgraded.'); +}); diff --git a/tests/Integration/Console/Commands/User/MakeUserCommandTest.php b/tests/Integration/Console/Commands/User/MakeUserCommandTest.php new file mode 100644 index 000000000..2f82968bf --- /dev/null +++ b/tests/Integration/Console/Commands/User/MakeUserCommandTest.php @@ -0,0 +1,56 @@ +artisan('p:user:make', userOptions('abc')) + ->expectsOutputToContain('The password must be at least 8 characters.') + ->assertExitCode(1); + + $this->assertDatabaseMissing('users', ['username' => 'cli-user']); +}); +test('creates a user with an eight character password', function (): void { + $this->artisan('p:user:make', userOptions('abcdefgh'))->assertExitCode(0); + + $user = User::query()->where('username', 'cli-user')->firstOrFail(); + expect(Hash::check('abcdefgh', $user->password))->toBeTrue(); + + $log = $user->activity()->where('event', 'user:user.create')->sole(); + expect($log->actor_id)->toBeNull() + ->and($log->properties->get('email'))->toBe('cli-user@example.com'); +}); +test('creates a user without a password when asked to', function (): void { + $options = userOptions(''); + unset($options['--password']); + + $this->artisan('p:user:make', [...$options, '--no-password' => true])->assertExitCode(0); + + $this->assertDatabaseHas('users', ['username' => 'cli-user']); +}); +/** + * @return array + */ +function userOptions(string $password): array +{ + return [ + '--email' => 'cli-user@example.com', + '--username' => 'cli-user', + '--name-first' => 'Cli', + '--name-last' => 'User', + '--password' => $password, + '--admin' => '0', + '--no-interaction' => true, + ]; +} diff --git a/tests/Integration/Console/SchedulerTest.php b/tests/Integration/Console/SchedulerTest.php new file mode 100644 index 000000000..8bb9b0c86 --- /dev/null +++ b/tests/Integration/Console/SchedulerTest.php @@ -0,0 +1,53 @@ +set('pterodactyl.telemetry.enabled', $enabled); + $uuid = '00000000-0000-4000-8000-000000000001'; + Setting::put('app:telemetry:uuid', $uuid); + $node = Node::factory()->for(Location::factory())->create(); + $daemon = new FakeDaemonConfiguration; + Http::fake(['https://telemetry.pterodactyl.io' => Http::response([], 200)]); + + $schedule = new Schedule; + $this->app->make(Scheduler::class)($schedule); + $events = array_values(array_filter( + $schedule->events(), + fn ($event): bool => $event->description === 'Collect Telemetry', + )); + + expect($events)->toHaveCount($enabled ? 1 : 0); + + if (! $enabled) { + Http::assertNothingSent(); + $daemon->assertNothingHappened(); + + return; + } + + expect($events[0]->expression)->toBe('1 0 * * *'); + expect($events[0]->withoutOverlapping)->toBeTrue(); + $events[0]->run($this->app); + + Http::assertSent(fn (Request $request): bool => $request->url() === 'https://telemetry.pterodactyl.io' + && $request['id'] === $uuid + && in_array($node->uuid, array_column($request['nodes'], 'id'), true)); + Http::assertSentCount(2); + $daemon->assertSystemInformationFetched(); +})->with([true, false]); diff --git a/tests/Integration/Database/LegacyMigrationHistoryGuardTest.php b/tests/Integration/Database/LegacyMigrationHistoryGuardTest.php new file mode 100644 index 000000000..e45c78db6 --- /dev/null +++ b/tests/Integration/Database/LegacyMigrationHistoryGuardTest.php @@ -0,0 +1,32 @@ + historyGuard()->up())->not->toThrow(RuntimeException::class); +}); + +test('refuses a database from an older 1.x release', function (): void { + DB::table('migrations')->where('migration', '2024_07_13_091852_clear_unused_allocation_notes')->delete(); + + expect(fn () => historyGuard()->up())->toThrow( + RuntimeException::class, + 'missing 1 Pterodactyl Panel 1.x migration(s), starting with 2024_07_13_091852_clear_unused_allocation_notes' + ); +}); diff --git a/tests/Integration/Database/LegacyNestSchemaTest.php b/tests/Integration/Database/LegacyNestSchemaTest.php new file mode 100644 index 000000000..c53c1d794 --- /dev/null +++ b/tests/Integration/Database/LegacyNestSchemaTest.php @@ -0,0 +1,29 @@ + + */ +dataset('legacyNestColumnsDataProvider', function () { + return ['servers.nest_id' => ['servers', 'nest_id'], 'eggs.nest_id' => ['eggs', 'nest_id'], 'api_keys.r_nests' => ['api_keys', 'r_nests'], 'tags.legacy_nest_id' => ['tags', 'legacy_nest_id']]; +}); +test('nest tables survive migration', function () { + expect(Schema::hasTable('nests'))->toBeTrue('The legacy nests table must not be dropped.'); +}); +test('legacy nest columns survive migration', function (string $table, string $column) { + expect(Schema::hasColumn($table, $column))->toBeTrue("The legacy {$table}.{$column} column must not be dropped — nest data is retained on purpose."); +})->with('legacyNestColumnsDataProvider'); +test('unwritten nest columns are nullable', function () { + foreach ([['servers', 'nest_id'], ['eggs', 'nest_id']] as [$table, $column]) { + $definition = collect(Schema::getColumns($table))->firstWhere('name', $column); + expect($definition)->not->toBeNull("Expected {$table}.{$column} to exist."); + expect($definition['nullable'])->toBeTrue("{$table}.{$column} must be nullable; nothing writes it any more."); + } +}); diff --git a/tests/Integration/Database/SubuserGrantUniquenessMigrationTest.php b/tests/Integration/Database/SubuserGrantUniquenessMigrationTest.php new file mode 100644 index 000000000..17f2bfbe2 --- /dev/null +++ b/tests/Integration/Database/SubuserGrantUniquenessMigrationTest.php @@ -0,0 +1,68 @@ +set('database.connections.subuser-migration-tests', ['driver' => 'sqlite', 'database' => ':memory:']); + DB::setDefaultConnection('subuser-migration-tests'); + Schema::create('subusers', function (Blueprint $table): void { + $table->increments('id'); + $table->unsignedInteger('server_id'); + $table->unsignedInteger('user_id'); + $table->json('permissions')->nullable(); + }); + App::make(Migrator::class)->getRepository()->createRepository(); +}); + +afterEach(function (): void { + DB::setDefaultConnection('mysql'); + DB::purge('subuser-migration-tests'); +}); + +function migrationPath(): string +{ + return database_path('migrations/2026_10_04_090113_add_unique_server_user_to_subusers_table.php'); +} + +test('existing duplicate grants prevent the unique index without changing permissions', function (): void { + DB::table('subusers')->insert([ + ['server_id' => 11, 'user_id' => 22, 'permissions' => '["control.start"]'], + ['server_id' => 11, 'user_id' => 22, 'permissions' => '["control.stop"]'], + ]); + + expect(fn () => App::make(Migrator::class)->run([migrationPath()]))->toThrow(QueryException::class); + expect(DB::table('subusers')->orderBy('id')->pluck('permissions')->all())->toBe(['["control.start"]', '["control.stop"]']); + expect(Schema::hasIndex('subusers', 'subusers_server_id_user_id_unique'))->toBeFalse(); +}); + +test('the database rejects duplicate grants while allowing a user on another server', function (): void { + App::make(Migrator::class)->run([migrationPath()]); + DB::table('subusers')->insert([ + ['server_id' => 11, 'user_id' => 22, 'permissions' => '[]'], + ['server_id' => 12, 'user_id' => 22, 'permissions' => '[]'], + ]); + expect(fn () => DB::table('subusers')->insert(['server_id' => 11, 'user_id' => 22, 'permissions' => '[]'])) + ->toThrow(QueryException::class); + expect(DB::table('subusers')->count())->toBe(2); +}); + +test('rolling back the unique invariant preserves the existing grant', function (): void { + $migrator = App::make(Migrator::class); + $migrator->run([migrationPath()]); + DB::table('subusers')->insert(['server_id' => 11, 'user_id' => 22, 'permissions' => '["control.start"]']); + $migrator->rollback([migrationPath()]); + expect(DB::table('subusers')->sole()->permissions)->toBe('["control.start"]'); + expect(Schema::hasIndex('subusers', 'subusers_server_id_user_id_unique'))->toBeFalse(); +}); diff --git a/tests/Integration/Http/Controllers/Admin/UserController/DeleteUserTest.php b/tests/Integration/Http/Controllers/Admin/UserController/DeleteUserTest.php deleted file mode 100644 index 5768ae1a7..000000000 --- a/tests/Integration/Http/Controllers/Admin/UserController/DeleteUserTest.php +++ /dev/null @@ -1,37 +0,0 @@ -actingAs(User::factory()->create()) - ->delete(route('admin.users.delete', ['user' => User::factory()->create()])) - ->assertForbidden(); - } - - public function testCannotDeleteSelf(): void - { - $this->actingAs($user = User::factory()->admin()->create()) - ->delete(route('admin.users.delete', ['user' => $user])) - ->assertBadRequest() - ->assertJsonPath('errors.0.detail', __('admin/user.exceptions.delete_self')); - - $this->assertModelExists($user); - } - - public function testUserIsDeleted(): void - { - $user = User::factory()->create(); - - $this->actingAs(User::factory()->admin()->create()) - ->delete(route('admin.users.delete', ['user' => $user])) - ->assertRedirectToRoute('admin.users'); - - $this->assertModelMissing($user); - } -} diff --git a/tests/Integration/Http/Controllers/Auth/LoginCheckpointControllerTest.php b/tests/Integration/Http/Controllers/Auth/LoginCheckpointControllerTest.php index a5aafcd4e..5a34d26d6 100644 --- a/tests/Integration/Http/Controllers/Auth/LoginCheckpointControllerTest.php +++ b/tests/Integration/Http/Controllers/Auth/LoginCheckpointControllerTest.php @@ -1,207 +1,96 @@ create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16)), 'totp_authenticated_at' => is_null($ts) ? null : Carbon::now()->addSeconds($ts)]); + Session::put('auth_confirmation_token', new LoginCheckpoint($user->id, 'token', now()->addMinutes(5))); + $totp = $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)); + $this->withoutExceptionHandling()->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => $totp]))->assertOk()->assertSessionMissing('auth_confirmation_token')->assertJsonPath('data.complete', true)->assertJsonPath('data.intended', '/')->assertJsonPath('data.user.uuid', $user->uuid); + expect($user->refresh()->totp_authenticated_at)->toEqual(now()); + $this->assertAuthenticatedAs($user); + Event::assertDispatched(fn (DirectLogin $event) => $event->user->is($user) && $event->remember); + Event::assertDispatched(fn (ProvidedAuthenticationToken $event) => $event->user->is($user)); +})->with([ + 'without a prior authentication time' => [null], + 'with a prior authentication time 31 seconds ago' => [-31], + 'with a prior authentication time 60 seconds ago' => [-60], +]); +test('totp token cannot be reused', function (int $seconds) { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16)), 'totp_authenticated_at' => now()->addSeconds($seconds)]); + Session::put('auth_confirmation_token', new LoginCheckpoint($user->id, 'token', now()->addMinutes(5))); + $totp = $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => $totp]))->assertBadRequest()->assertJsonPath('errors.0.detail', 'The two-factor authentication token was invalid.'); + $this->assertGuest(); + expect($user->refresh()->totp_authenticated_at)->toEqual(now()->addSeconds($seconds)); + Event::assertDispatched(fn (Failed $event) => $event->guard === 'auth' && $event->user->is($user)); +})->with([ + 'after 1 second' => [1], + 'after 30 seconds' => [30], + 'after 80 seconds' => [80], +]); +test('endpoint returns error if session missing', function () { + $this->postJson(route('auth.login-checkpoint'))->assertUnprocessable()->assertJsonPath('errors.0.meta.source_field', 'confirmation_token')->assertJsonPath('errors.1.meta.source_field', 'authentication_code')->assertJsonPath('errors.2.meta.source_field', 'recovery_token'); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => '123456']))->assertBadRequest()->assertJsonPath('errors.0.detail', 'The authentication token provided has expired, please refresh the page and try again.'); + $this->assertGuest(); + Event::assertDispatched(fn (Failed $event) => $event->guard === 'auth'); +}); +test('endpoint applies throttling', function () { + for ($i = 0; $i < config('auth.lockout.attempts'); $i++) { + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => '123456']))->assertBadRequest(); } - - /** - * Basic test that a user can be signed in using their TOTP token and that - * the `totp_authenticated_at` field in the database is updated to the login - * verification time. - */ - #[TestWith([null])] - #[TestWith([-31])] - #[TestWith([-60])] - public function testUserCanSignInUsingTotpToken(?int $ts): void - { - $user = User::factory()->create([ - 'use_totp' => true, - 'totp_secret' => encrypt(str_repeat('a', 16)), - 'totp_authenticated_at' => is_null($ts) ? null : Carbon::now()->addSeconds($ts), - ]); - - Session::put('auth_confirmation_token', [ - 'user_id' => $user->id, - 'token_value' => 'token', - 'expires_at' => now()->addMinutes(5), - ]); - - $totp = $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)); - - $this->withoutExceptionHandling()->postJson(route('auth.login-checkpoint', [ - 'confirmation_token' => 'token', - 'authentication_code' => $totp, - ])) - ->assertOk() - ->assertSessionMissing('auth_confirmation_token') - ->assertJsonPath('data.complete', true) - ->assertJsonPath('data.intended', '/') - ->assertJsonPath('data.user.uuid', $user->uuid); - - $this->assertEquals(now(), $user->refresh()->totp_authenticated_at); - - $this->assertAuthenticatedAs($user); - - Event::assertDispatched(fn (DirectLogin $event) => $event->user->is($user) && $event->remember); - Event::assertDispatched(fn (ProvidedAuthenticationToken $event) => $event->user->is($user)); - } - - /** - * Test that a TOTP token cannot be reused by verifying that the OTP verification - * logic fails if the token's timestamp is before the `totp_authenticated_at` - * column value. - * - * @see https://github.com/pterodactyl/panel/security/advisories/GHSA-rgmp-4873-r683 - */ - #[TestWith([1])] - #[TestWith([30])] - #[TestWith([80])] - public function testTotpTokenCannotBeReused(int $seconds): void - { - $user = User::factory()->create([ - 'use_totp' => true, - 'totp_secret' => encrypt(str_repeat('a', 16)), - 'totp_authenticated_at' => now()->addSeconds($seconds), - ]); - - Session::put('auth_confirmation_token', [ - 'user_id' => $user->id, - 'token_value' => 'token', - 'expires_at' => now()->addMinutes(5), - ]); - - $totp = $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)); - - $this->postJson(route('auth.login-checkpoint', [ - 'confirmation_token' => 'token', - 'authentication_code' => $totp, - ])) - ->assertBadRequest() - ->assertJsonPath('errors.0.detail', 'The two-factor authentication token was invalid.'); - - $this->assertGuest(); - $this->assertEquals(now()->addSeconds($seconds), $user->refresh()->totp_authenticated_at); - - Event::assertDispatched(fn (Failed $event) => $event->guard === 'auth' && $event->user->is($user)); - } - - public function testEndpointReturnsErrorIfSessionMissing(): void - { - $this->postJson(route('auth.login-checkpoint')) - ->assertUnprocessable() - ->assertJsonPath('errors.0.meta.source_field', 'confirmation_token') - ->assertJsonPath('errors.1.meta.source_field', 'authentication_code') - ->assertJsonPath('errors.2.meta.source_field', 'recovery_token'); - - $this->postJson(route('auth.login-checkpoint', [ - 'confirmation_token' => 'token', - 'authentication_code' => '123456', - ])) - ->assertBadRequest() - ->assertJsonPath('errors.0.detail', 'The authentication token provided has expired, please refresh the page and try again.'); - - $this->assertGuest(); - - Event::assertDispatched(fn (Failed $event) => $event->guard === 'auth'); - } - - public function testEndpointAppliesThrottling(): void - { - for ($i = 0; $i < 5; ++$i) { - $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => '123456'])) - ->assertBadRequest(); - } - - $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => '123456'])) - ->assertTooManyRequests(); - } - - public function testEndpointBlocksSessionDataMismatch(): void - { - $user = User::factory()->create([ - 'use_totp' => true, - 'totp_secret' => str_repeat('a', 16), - ]); - - Session::put('auth_confirmation_token', [ - 'user_id' => $user->id, - 'token_value' => 'token', - 'expires_at' => now()->addMinutes(5), - ]); - - $this->postJson(route('auth.login-checkpoint', [ - 'confirmation_token' => 'wrong-token', - 'authentication_code' => $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)), - ])) - ->assertBadRequest(); - - $this->assertGuest(); - - Event::assertDispatched(Failed::class); - } - - public function testEndpointReturnsErrorIfUserDoesNotExist(): void - { - Session::put('auth_confirmation_token', [ - 'user_id' => 0, - 'token_value' => 'token', - 'expires_at' => now()->addMinutes(5), - ]); - - $this->postJson(route('auth.login-checkpoint', [ - 'confirmation_token' => 'token', - 'authentication_code' => '123456', - ])) - ->assertBadRequest() - ->assertJsonPath('errors.0.detail', 'The authentication token provided has expired, please refresh the page and try again.'); - } - - public function testEndpointAllowsRecoveryToken(): void - { - $user = User::factory()->create(); - $token = $user->recoveryTokens()->forceCreate(['token' => password_hash('recovery', PASSWORD_DEFAULT)]); - - Session::put('auth_confirmation_token', [ - 'user_id' => $user->id, - 'token_value' => 'token', - 'expires_at' => now()->addMinutes(5), - ]); - - $this->postJson(route('auth.login-checkpoint', [ - 'confirmation_token' => 'token', - 'recovery_token' => 'invalid', - ])) - ->assertBadRequest() - ->assertJsonPath('errors.0.detail', 'The recovery token provided is not valid.'); - - $this->assertGuest(); - - $this->postJson(route('auth.login-checkpoint', [ - 'confirmation_token' => 'token', - 'recovery_token' => 'recovery', - ])) - ->assertOk() - ->assertSessionMissing('auth_confirmation_token'); - - Event::assertDispatched(ProvidedAuthenticationToken::class); - Event::assertDispatched(DirectLogin::class); - } -} + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => '123456']))->assertTooManyRequests(); +}); +test('endpoint blocks session data mismatch', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => str_repeat('a', 16)]); + Session::put('auth_confirmation_token', new LoginCheckpoint($user->id, 'token', now()->addMinutes(5))); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'wrong-token', 'authentication_code' => $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16))]))->assertBadRequest(); + $this->assertGuest(); + Event::assertDispatched(Failed::class); +}); +test('endpoint returns error if user does not exist', function () { + Session::put('auth_confirmation_token', new LoginCheckpoint(0, 'token', now()->addMinutes(5))); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => '123456']))->assertBadRequest()->assertJsonPath('errors.0.detail', 'The authentication token provided has expired, please refresh the page and try again.'); +}); +test('endpoint allows recovery token', function () { + $user = User::factory()->create(); + $token = $user->recoveryTokens()->forceCreate(['token' => password_hash('recovery', PASSWORD_DEFAULT)]); + Session::put('auth_confirmation_token', new LoginCheckpoint($user->id, 'token', now()->addMinutes(5))); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'recovery_token' => 'invalid']))->assertBadRequest()->assertJsonPath('errors.0.detail', 'The recovery token provided is not valid.'); + $this->assertGuest(); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'recovery_token' => 'recovery']))->assertOk()->assertSessionMissing('auth_confirmation_token'); + Event::assertDispatched(ProvidedAuthenticationToken::class); + Event::assertDispatched(DirectLogin::class); +}); +test('endpoint rejects an expired checkpoint', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + Session::put('auth_confirmation_token', new LoginCheckpoint($user->id, 'token', now()->subSecond())); + $totp = $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => $totp]))->assertBadRequest()->assertJsonPath('errors.0.detail', 'The authentication token provided has expired, please refresh the page and try again.'); + $this->assertGuest(); + Event::assertNotDispatched(DirectLogin::class); +}); +test('endpoint rejects a checkpoint payload it did not issue', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + Session::put('auth_confirmation_token', ['user_id' => $user->id, 'token_value' => 'token', 'expires_at' => now()->addMinutes(5)]); + $totp = $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)); + $this->postJson(route('auth.login-checkpoint', ['confirmation_token' => 'token', 'authentication_code' => $totp]))->assertBadRequest()->assertJsonPath('errors.0.detail', 'The authentication token provided has expired, please refresh the page and try again.'); + $this->assertGuest(); +}); diff --git a/tests/Integration/Http/Controllers/Auth/LoginControllerTest.php b/tests/Integration/Http/Controllers/Auth/LoginControllerTest.php new file mode 100644 index 000000000..a1789fe7a --- /dev/null +++ b/tests/Integration/Http/Controllers/Auth/LoginControllerTest.php @@ -0,0 +1,97 @@ +get($uri)->assertOk()->assertViewIs('templates.auth.core'); + } +}); +test('user can log in with username', function () { + $user = User::factory()->create(); + $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'password'])->assertOk()->assertJsonPath('data.complete', true)->assertJsonPath('data.intended', '/')->assertJsonPath('data.user.uuid', $user->uuid); + $this->assertAuthenticatedAs($user); + Event::assertDispatched(fn (DirectLogin $event) => $event->user->is($user) && $event->remember); +}); +test('user can log in with email', function () { + $user = User::factory()->create(); + $this->postJson(route('auth.login'), ['user' => $user->email, 'password' => 'password'])->assertOk()->assertJsonPath('data.complete', true); + $this->assertAuthenticatedAs($user); +}); +test('login fails with invalid password', function () { + $user = User::factory()->create(); + $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'wrong'])->assertBadRequest()->assertJsonPath('errors.0.detail', trans('auth.failed')); + $this->assertGuest(); + Event::assertDispatched(fn (Failed $event) => $event->guard === 'auth' && $event->user->is($user)); + Event::assertNotDispatched(DirectLogin::class); +}); +test('login fails with unknown user', function () { + $this->postJson(route('auth.login'), ['user' => 'does-not-exist', 'password' => 'password'])->assertBadRequest()->assertJsonPath('errors.0.detail', trans('auth.failed')); + $this->assertGuest(); + Event::assertDispatched(fn (Failed $event) => $event->guard === 'auth' && is_null($event->user)); +}); +test('unknown user and bad password responses are identical', function () { + $user = User::factory()->create(); + $unknown = $this->postJson(route('auth.login'), ['user' => 'does-not-exist', 'password' => 'password']); + $badPassword = $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'wrong']); + expect($badPassword->getStatusCode())->toBe($unknown->getStatusCode()); + expect($badPassword->json())->toBe($unknown->json()); +}); +test('login with two factor enabled returns confirmation token', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + $response = $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'password']); + $response->assertOk()->assertJsonPath('data.complete', false)->assertSessionHas('auth_confirmation_token'); + $this->assertGuest(); + $token = $response->json('data.confirmation_token'); + expect($token)->toBeString(); + expect(session('auth_confirmation_token'))->toBeInstanceOf(LoginCheckpoint::class)->and(session('auth_confirmation_token')->token)->toBe($token)->and(session('auth_confirmation_token')->userId)->toBe($user->id); +}); +test('login is locked out after repeated failures', function () { + $user = User::factory()->create(); + for ($i = 0; $i < config('auth.lockout.attempts'); $i++) { + $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'wrong'])->assertBadRequest(); + } + $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'password'])->assertTooManyRequests(); + $this->assertGuest(); +}); +test('user can log out', function () { + $user = User::factory()->create(); + $this->actingAs($user)->postJson(route('auth.logout'))->assertNoContent(); + $this->assertGuest(); +}); +test('logout requires authentication', function () { + $this->postJson(route('auth.logout'))->assertUnauthorized(); +}); +test('two factor checkpoint is logged and can be completed through the checkpoint endpoint', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + $token = $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'password'])->assertOk()->json('data.confirmation_token'); + $this->assertActivityLogged('auth:checkpoint'); + Event::assertNotDispatched(DirectLogin::class); + $totp = $this->app->make(Google2FA::class)->getCurrentOtp(str_repeat('a', 16)); + $this->postJson(route('auth.login-checkpoint'), ['confirmation_token' => $token, 'authentication_code' => $totp])->assertOk()->assertJsonPath('data.complete', true)->assertSessionMissing('auth_confirmation_token'); + $this->assertAuthenticatedAs($user); +}); +test('successful login clears the lockout counter', function () { + $user = User::factory()->create(); + for ($i = 0; $i < config('auth.lockout.attempts') - 1; $i++) { + $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'wrong'])->assertBadRequest(); + } + $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'password'])->assertOk(); + $this->postJson(route('auth.logout'))->assertNoContent(); + $this->postJson(route('auth.login'), ['user' => $user->username, 'password' => 'wrong'])->assertBadRequest(); +}); diff --git a/tests/Integration/Http/Controllers/Auth/PasswordResetActivityTest.php b/tests/Integration/Http/Controllers/Auth/PasswordResetActivityTest.php new file mode 100644 index 000000000..7e26a201d --- /dev/null +++ b/tests/Integration/Http/Controllers/Auth/PasswordResetActivityTest.php @@ -0,0 +1,23 @@ +create(); + + Event::dispatch(new PasswordReset($user)); + + $log = ActivityLog::query()->where('event', 'auth:password-reset')->latest('id')->firstOrFail(); + expect($log->subjects->first()->subject_id)->toBe($user->id); + expect(trans('activity.'.str_replace(':', '.', $log->event)))->toBe('Password reset'); +}); diff --git a/tests/Integration/Http/Controllers/Auth/PasswordResetTest.php b/tests/Integration/Http/Controllers/Auth/PasswordResetTest.php new file mode 100644 index 000000000..389c1b210 --- /dev/null +++ b/tests/Integration/Http/Controllers/Auth/PasswordResetTest.php @@ -0,0 +1,67 @@ +create(); + $this->postJson(route('auth.post.forgot-password'), ['email' => $user->email])->assertOk()->assertJson(['status' => trans('passwords.sent')]); + Notification::assertSentTo($user, SendPasswordReset::class); +}); +test('unknown email returns identical response', function () { + $this->postJson(route('auth.post.forgot-password'), ['email' => 'unknown@example.com'])->assertOk()->assertJson(['status' => trans('passwords.sent')]); + Notification::assertNothingSent(); + Event::assertDispatched(fn (FailedPasswordReset $event) => $event->email === 'unknown@example.com'); +}); +test('email is required for reset link', function () { + $this->postJson(route('auth.post.forgot-password'), ['email' => 'not-an-email'])->assertUnprocessable(); + $this->postJson(route('auth.post.forgot-password'))->assertUnprocessable(); +}); +test('password can be reset with valid token', function () { + $user = User::factory()->create(); + $token = Password::broker()->createToken($user); + $this->postJson(route('auth.reset-password'), ['email' => $user->email, 'token' => $token, 'password' => 'new-password-123', 'password_confirmation' => 'new-password-123'])->assertOk()->assertJson(['success' => true, 'redirect_to' => '/', 'send_to_login' => false]); + $this->assertAuthenticatedAs($user); + expect(Hash::check('new-password-123', $user->refresh()->password))->toBeTrue(); + Event::assertDispatched(fn (PasswordReset $event) => $event->user->is($user)); + Event::assertDispatched(fn (PasswordChanged $event) => $event->user->is($user)); +}); +test('two factor account is sent back to login after reset', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + $token = Password::broker()->createToken($user); + $this->postJson(route('auth.reset-password'), ['email' => $user->email, 'token' => $token, 'password' => 'new-password-123', 'password_confirmation' => 'new-password-123'])->assertOk()->assertJsonPath('send_to_login', true); + $this->assertGuest(); + expect(Hash::check('new-password-123', $user->refresh()->password))->toBeTrue(); +}); +test('reset fails with invalid token', function () { + $user = User::factory()->create(); + $this->postJson(route('auth.reset-password'), ['email' => $user->email, 'token' => 'invalid-token', 'password' => 'new-password-123', 'password_confirmation' => 'new-password-123'])->assertBadRequest()->assertJsonPath('errors.0.detail', trans('passwords.token')); + $this->assertGuest(); + expect(Hash::check('password', $user->refresh()->password))->toBeTrue(); +}); +test('reset validates password rules', function () { + $user = User::factory()->create(); + $token = Password::broker()->createToken($user); + // Too short. + $this->postJson(route('auth.reset-password'), ['email' => $user->email, 'token' => $token, 'password' => 'short', 'password_confirmation' => 'short'])->assertUnprocessable(); + // Confirmation mismatch. + $this->postJson(route('auth.reset-password'), ['email' => $user->email, 'token' => $token, 'password' => 'new-password-123', 'password_confirmation' => 'different-password'])->assertUnprocessable(); + expect(Hash::check('password', $user->refresh()->password))->toBeTrue(); +}); diff --git a/tests/Integration/Http/Controllers/Base/BaseRoutesTest.php b/tests/Integration/Http/Controllers/Base/BaseRoutesTest.php new file mode 100644 index 000000000..2b9d44a49 --- /dev/null +++ b/tests/Integration/Http/Controllers/Base/BaseRoutesTest.php @@ -0,0 +1,26 @@ +create(); + $this->actingAs($user)->get('/')->assertOk()->assertViewIs('templates.base.core'); + $this->actingAs($user)->get('/account')->assertOk()->assertViewIs('templates.base.core'); + $this->actingAs($user)->get('/server/some-uuid')->assertOk()->assertViewIs('templates.base.core'); +}); +test('guests also receive the react shell', function () { + $this->get('/')->assertOk()->assertViewIs('templates.base.core'); +}); +test('locales are returned as json', function () { + $user = User::factory()->create(); + $response = $this->actingAs($user)->getJson('/locales/locale.json?locale=en&namespace=auth'); + $response->assertOk(); + expect($response->json())->toBeArray(); + expect($response->json())->not->toBeEmpty(); +}); diff --git a/tests/Integration/Http/ExtensionFrontendConfigTest.php b/tests/Integration/Http/ExtensionFrontendConfigTest.php new file mode 100644 index 000000000..b3d2491b8 --- /dev/null +++ b/tests/Integration/Http/ExtensionFrontendConfigTest.php @@ -0,0 +1,68 @@ +baseDirectory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'ptero-frontend-config-'.uniqid(); + $extensions = $this->baseDirectory.DIRECTORY_SEPARATOR.'extensions'; + File::ensureDirectoryExists($extensions.DIRECTORY_SEPARATOR.'config-probe'); + File::put($extensions.DIRECTORY_SEPARATOR.'config-probe'.DIRECTORY_SEPARATOR.'extension.json', json_encode([ + 'id' => 'config-probe', + 'name' => 'Config Probe', + 'version' => '1.0.0', + 'ui' => ['entry' => 'dist/client.js'], + ], JSON_THROW_ON_ERROR)); + config(['extensions.enabled' => true, 'extensions.directory' => $extensions, 'extensions.assets_directory' => $this->baseDirectory.DIRECTORY_SEPARATOR.'assets']); + Extension::query()->create(['identifier' => 'config-probe', 'version' => '1.0.0', 'enabled' => true]); + + $repository = $this->app->make(ExtensionRepository::class); + $repository->flushDiscovery(); + $this->app->make(ExtensionSettingsRegistry::class)->register('config-probe', new ExtensionSettingsDefinition($repository->settings('config-probe'), [ + ExtensionSettingDefinition::make('public_note', 'public_note', 'frontend-config-marker', ['required', 'string'])->frontend(), + ExtensionSettingDefinition::make('registration', 'registration', 'guest-config-marker', ['required', 'string'])->frontend()->public(), + ExtensionSettingDefinition::make('accent', 'accent', '#3b82f6')->color()->frontend()->public(), + ExtensionSettingDefinition::make('api_token', 'api_token', 'secret-config-marker')->secret(), + ])); +}); +afterEach(function (): void { + $this->app->make(ExtensionRepository::class)->flushDiscovery(); + File::deleteDirectory($this->baseDirectory); +}); +test('guests load extension bundles with only their public frontend settings', function (string $path): void { + $this->app->make(ExtensionRepository::class)->settings('config-probe')->set('accent', '#abcdef'); + $this->get($path)->assertOk() + ->assertSee('"id":"config-probe"', false) + ->assertSee('"config":{"registration":"guest-config-marker","accent":"#abcdef"}', false) + ->assertDontSee('frontend-config-marker', false) + ->assertDontSee('secret-config-marker', false); +})->with(['/auth/login', '/']); +test('guests of an extension without public settings receive an empty config', function (): void { + $repository = $this->app->make(ExtensionRepository::class); + $this->app->make(ExtensionSettingsRegistry::class)->register('config-probe', new ExtensionSettingsDefinition($repository->settings('config-probe'), [ + ExtensionSettingDefinition::make('public_note', 'public_note', 'frontend-config-marker', ['required', 'string'])->frontend(), + ])); + $this->get('/auth/login')->assertOk() + ->assertSee('"id":"config-probe"', false) + ->assertSee('"config":{}', false) + ->assertDontSee('frontend-config-marker', false); +}); +test('signed in users receive extension frontend settings', function (): void { + $this->actingAs(User::factory()->create())->get('/')->assertOk() + ->assertSee('"id":"config-probe"', false) + ->assertSee('"public_note":"frontend-config-marker"', false) + ->assertSee('"registration":"guest-config-marker"', false) + ->assertDontSee('secret-config-marker', false); +}); diff --git a/tests/Integration/Http/HttpTestCase.php b/tests/Integration/Http/HttpTestCase.php index e3a6621ac..d79a03f8e 100644 --- a/tests/Integration/Http/HttpTestCase.php +++ b/tests/Integration/Http/HttpTestCase.php @@ -1,9 +1,9 @@ buildRequestMock(); +}); +/** Tokens that should trigger a bad request exception due to their formatting. */ +dataset('badTokenDataProvider', function () { + return [['foo'], ['foobar'], ['foo-bar'], ['foo.bar.baz'], ['.foo'], ['foo.'], ['foo..bar']]; +}); +test('response should continue if route is exempted', function () { + $this->setRequestRouteName('daemon.configuration'); + $nextCalled = false; + getMiddleware()->handle($this->request, function ($response) use (&$nextCalled) { + $nextCalled = true; + ($this->getClosureAssertions())($response); + }); + expect($nextCalled)->toBeTrue(); +}); +test('response should fail if no token is provided', function () { + $this->setRequestRouteName('random.route'); + $this->setRequestBearerToken(null); + try { + getMiddleware()->handle($this->request, $this->getClosureAssertions()); + $this->fail('Expected an HttpException.'); + } catch (HttpException $exception) { + expect($exception->getStatusCode())->toEqual(401); + expect($exception->getHeaders())->toHaveKey('WWW-Authenticate'); + expect($exception->getHeaders()['WWW-Authenticate'])->toEqual('Bearer'); + } +}); +test('response should fail if token format is incorrect', function (string $token) { + $this->expectException(BadRequestHttpException::class); + $this->setRequestRouteName('random.route'); + $this->setRequestBearerToken($token); + getMiddleware()->handle($this->request, $this->getClosureAssertions()); +})->with('badTokenDataProvider'); +test('response should fail if token is not valid', function () { + $this->expectException(AccessDeniedHttpException::class); + $node = Node::factory()->withLocation()->create(); + $this->setRequestRouteName('random.route'); + $this->setRequestBearerToken($node->daemon_token_id.'.random_string_123'); + getMiddleware()->handle($this->request, $this->getClosureAssertions()); +}); +test('response should fail if node is not found', function () { + $this->expectException(AccessDeniedHttpException::class); + $this->setRequestRouteName('random.route'); + $this->setRequestBearerToken('abcd1234.random_string_123'); + getMiddleware()->handle($this->request, $this->getClosureAssertions()); +}); +test('successful middleware process', function () { + $node = Node::factory()->withLocation()->create(); + $this->setRequestRouteName('random.route'); + $this->setRequestBearerToken($node->daemon_token_id.'.'.decrypt($node->daemon_token)); + getMiddleware()->handle($this->request, $this->getClosureAssertions()); + $this->assertRequestHasAttribute('node'); + expect($this->request->attributes->get('node'))->toBeInstanceOf(Node::class); + expect($this->request->attributes->get('node')->is($node))->toBeTrue(); +}); +/** Resolve the middleware with the real encrypter. */ +function getMiddleware(): DaemonAuthenticate +{ + return app(DaemonAuthenticate::class); +} diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index 103c97b9b..3e1c86adb 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -1,20 +1,25 @@ 'application/json', ]; - public function setUp(): void + protected function setUp(): void { parent::setUp(); Event::fake(ActivityLogged::class); + + // The React shell reads the built Vite manifest; point the asset service at a + // committed fixture so view rendering does not depend on a frontend build. + $this->app->bind(AssetHashService::class, fn (Application $app): AssetHashService => new AssetHashService( + $app->make(FilesystemManager::class), + base_path('tests/Fixtures'), + )); } /** * Return an ISO-8601 formatted timestamp to use in the API response. */ - protected function formatTimestamp(string $timestamp): string + protected function formatTimestamp(CarbonInterface|string $timestamp): string { - return CarbonImmutable::createFromFormat(CarbonInterface::DEFAULT_TO_STRING_FORMAT, $timestamp) - ->setTimezone(BaseTransformer::RESPONSE_TIMEZONE) - ->toAtomString(); + $value = $timestamp instanceof CarbonInterface + ? CarbonImmutable::instance($timestamp) + : CarbonImmutable::createFromFormat(CarbonInterface::DEFAULT_TO_STRING_FORMAT, $timestamp); + + return $value->setTimezone(BaseTransformer::RESPONSE_TIMEZONE)->toAtomString(); } } diff --git a/tests/Integration/Jobs/RevokeSftpAccessJobTest.php b/tests/Integration/Jobs/RevokeSftpAccessJobTest.php index 90515a397..deec4e2f5 100644 --- a/tests/Integration/Jobs/RevokeSftpAccessJobTest.php +++ b/tests/Integration/Jobs/RevokeSftpAccessJobTest.php @@ -1,70 +1,55 @@ make(['uuid' => 'uuid-1234']); + $job = new RevokeSftpAccessJob('user-1', $model); + expect($job->uniqueId())->toEqual("revoke-sftp:user-1:{$key}:uuid-1234"); +})->with([ + 'server' => [Server::class, 'server'], + 'node' => [Node::class, 'node'], +]); +test('job releases back to queue on failure', function () { + $node = Node::factory()->make(['uuid' => 'uuid-1234']); + $fake = new FakeDaemonRevocation; + $fake->throwable = new DaemonConnectionException(new ConnectionException('Connection failed')); + $job = new class('user-1', $node) extends RevokeSftpAccessJob { - $model = $class::factory()->make(['uuid' => 'uuid-1234']); + /** @var list */ + public array $releasedDelays = []; - $job = new RevokeSftpAccessJob('user-1', $model); - - $this->assertEquals( - "revoke-sftp:user-1:{$key}:uuid-1234", - $job->uniqueId() - ); - } - - public function testJobReleasesBackToQueueOnFailure(): void - { - $node = Node::factory()->make(['uuid' => 'uuid-1234']); - - $mock = $this->mock(DaemonRevocationRepository::class, function ($mock) { - $mock->expects('setNode->deauthorize')->andThrows( - new DaemonConnectionException(new TransferException('Connection failed')) - ); - }); - - $job = \Mockery::mock(RevokeSftpAccessJob::class, ['user-1', $node])->makePartial(); - $job->expects('release')->with(10); - - $job->handle($mock); - } - - public function testJobDispatchesForNode(): void - { - $node = Node::factory()->make(['uuid' => 'uuid-1234']); - - $mock = $this->mock(DaemonRevocationRepository::class, function ($mock) { - $mock->expects('setNode')->andReturnSelf(); - $mock->expects('deauthorize')->with('user-1', [])->andReturnUndefined(); - }); - - (new RevokeSftpAccessJob('user-1', $node))->handle($mock); - } - - public function testJobDispatchesForIndividualServer(): void - { - $node = Node::factory()->make(['uuid' => 'node-1234']); - $server = Server::factory()->make(['uuid' => 'server-1234'])->setRelation('node', $node); - - $mock = $this->mock(DaemonRevocationRepository::class, function ($mock) { - $mock->expects('setNode')->with(\Mockery::on(fn (Node $node) => $node->uuid === 'node-1234'))->andReturnSelf(); - $mock->expects('deauthorize')->with('user-1', ['server-1234'])->andReturnUndefined(); - }); - - (new RevokeSftpAccessJob('user-1', $server))->handle($mock); - } -} + public function release($delay = 0): void + { + $this->releasedDelays[] = $delay; + } + }; + expect(fn () => $job->handle())->not->toThrow(Throwable::class); + expect($job->releasedDelays)->toBe([10]); + $fake->assertDeauthorized('user-1'); +}); +test('job dispatches for node', function () { + $node = Node::factory()->make(['uuid' => 'uuid-1234']); + $fake = new FakeDaemonRevocation; + (new RevokeSftpAccessJob('user-1', $node))->handle(); + $fake->assertDeauthorized('user-1', []); +}); +test('job dispatches for individual server', function () { + $node = Node::factory()->make(['uuid' => 'node-1234']); + $server = Server::factory()->make(['uuid' => 'server-1234'])->setRelation('node', $node); + $fake = new FakeDaemonRevocation; + (new RevokeSftpAccessJob('user-1', $server))->handle(); + $fake->assertDeauthorized('user-1', ['server-1234']); +}); diff --git a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php index 907454a84..7b516f6eb 100644 --- a/tests/Integration/Jobs/Schedule/RunTaskJobTest.php +++ b/tests/Integration/Jobs/Schedule/RunTaskJobTest.php @@ -1,178 +1,130 @@ createServerModel(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create([ - 'server_id' => $server->id, - 'is_processing' => true, - 'last_run_at' => null, - 'is_active' => false, - ]); - /** @var Task $task */ - $task = Task::factory()->create(['schedule_id' => $schedule->id, 'is_queued' => true]); - - $job = new RunTaskJob($task); - - Bus::dispatchSync($job); +uses(IntegrationTestCase::class, DatabaseTransactions::class); +dataset('isManualRunDataProvider', fn (): array => [[true], [false]]); +test('inactive job is not run', function (): void { + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id, 'is_processing' => true, 'last_run_at' => null, 'is_active' => false]); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'is_queued' => true]); + $job = new RunTaskJob($task); + Bus::dispatchSync($job); + $task->refresh(); + $schedule->refresh(); + expect($task->is_queued)->toBeFalse(); + expect($schedule->is_processing)->toBeFalse(); + expect($schedule->is_active)->toBeFalse(); + expect(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at))->toBeTrue(); +}); +test('job with invalid action throws exception', function (): void { + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'action' => 'foobar']); + $job = new RunTaskJob($task); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid task action provided: foobar'); + Bus::dispatchSync($job); +}); +test('job is executed', function (bool $isManualRun): void { + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id, 'is_active' => ! $isManualRun, 'is_processing' => true, 'last_run_at' => null]); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'action' => Task::ACTION_POWER, 'payload' => 'start', 'is_queued' => true, 'continue_on_failure' => false]); + $fake = new FakeDaemonPower; + Bus::dispatchSync(new RunTaskJob($task, $isManualRun)); + $fake->assertSent('start'); + $task->refresh(); + $schedule->refresh(); + expect($task->is_queued)->toBeFalse(); + expect($schedule->is_processing)->toBeFalse(); + expect(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at))->toBeTrue(); +})->with('isManualRunDataProvider'); +test('exception during run is handled correctly', function (bool $continueOnFailure): void { + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'action' => Task::ACTION_POWER, 'payload' => 'start', 'continue_on_failure' => $continueOnFailure]); + $fake = new FakeDaemonPower; + $fake->throwable = new DaemonConnectionException(Http::failedRequest([], 200)); + if (! $continueOnFailure) { + $this->expectException(DaemonConnectionException::class); + } + Bus::dispatchSync(new RunTaskJob($task)); + $fake->assertSent('start'); + if ($continueOnFailure) { $task->refresh(); $schedule->refresh(); - - $this->assertFalse($task->is_queued); - $this->assertFalse($schedule->is_processing); - $this->assertFalse($schedule->is_active); - $this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at)); + expect($task->is_queued)->toBeFalse(); + expect($schedule->is_processing)->toBeFalse(); + expect(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at))->toBeTrue(); } +})->with('isManualRunDataProvider'); +test('task is not run if server is suspended', function (): void { + $server = $this->createServerModel(['status' => Server::STATUS_SUSPENDED]); + $schedule = Schedule::factory()->for($server)->create(['last_run_at' => Date::now()->subHour()]); + $task = Task::factory()->for($schedule)->create(['action' => Task::ACTION_POWER, 'payload' => 'start']); + Bus::dispatchSync(new RunTaskJob($task)); + $task->refresh(); + $schedule->refresh(); + expect($task->is_queued)->toBeFalse(); + expect($schedule->is_processing)->toBeFalse(); + expect(Date::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at))->toBeTrue(); +}); - public function testJobWithInvalidActionThrowsException() - { - $server = $this->createServerModel(); +test('failure cleanup accepts PHP errors and clears every queued task in the run', function (): void { + $schedule = Schedule::factory()->for($this->createServerModel())->create(['is_processing' => true]); + $task = Task::factory()->for($schedule)->create(['is_queued' => true, 'sequence_id' => 1]); + $next = Task::factory()->for($schedule)->create(['is_queued' => true, 'sequence_id' => 2]); - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - /** @var Task $task */ - $task = Task::factory()->create(['schedule_id' => $schedule->id, 'action' => 'foobar']); + (new RunTaskJob($task))->failed(new TypeError('Task execution failed')); - $job = new RunTaskJob($task); + expect($task->refresh()->is_queued)->toBeFalse(); + expect($next->refresh()->is_queued)->toBeFalse(); + expect($schedule->refresh()->is_processing)->toBeFalse(); +}); - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid task action provided: foobar'); - Bus::dispatchSync($job); - } +test('failed next task publication terminates the queue job without retrying the completed command', function (): void { + $schedule = Schedule::factory()->for($this->createServerModel())->create(['is_processing' => true]); + $task = Task::factory()->for($schedule)->create(['action' => Task::ACTION_POWER, 'payload' => 'start', 'is_queued' => true, 'sequence_id' => 1]); + $next = Task::factory()->for($schedule)->create(['sequence_id' => 2]); + $power = new FakeDaemonPower; + $this->swap(Dispatcher::class, new ThrowingDispatcher(new TypeError('Unused synchronous failure'))); + $job = (new RunTaskJob($task))->withFakeQueueInteractions(); - #[\PHPUnit\Framework\Attributes\DataProvider('isManualRunDataProvider')] - public function testJobIsExecuted(bool $isManualRun) - { - $server = $this->createServerModel(); + $this->app->call($job->handle(...)); - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create([ - 'server_id' => $server->id, - 'is_active' => !$isManualRun, - 'is_processing' => true, - 'last_run_at' => null, - ]); - /** @var Task $task */ - $task = Task::factory()->create([ - 'schedule_id' => $schedule->id, - 'action' => Task::ACTION_POWER, - 'payload' => 'start', - 'is_queued' => true, - 'continue_on_failure' => false, - ]); - - $mock = \Mockery::mock(DaemonPowerRepository::class); - $this->instance(DaemonPowerRepository::class, $mock); - - $mock->expects('setServer')->with(\Mockery::on(function ($value) use ($server) { - return $value instanceof Server && $value->id === $server->id; - }))->andReturnSelf(); - $mock->expects('send')->with('start')->andReturn(new Response()); - - Bus::dispatchSync(new RunTaskJob($task, $isManualRun)); - - $task->refresh(); - $schedule->refresh(); - - $this->assertFalse($task->is_queued); - $this->assertFalse($schedule->is_processing); - $this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at)); - } - - #[\PHPUnit\Framework\Attributes\DataProvider('isManualRunDataProvider')] - public function testExceptionDuringRunIsHandledCorrectly(bool $continueOnFailure) - { - $server = $this->createServerModel(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - /** @var Task $task */ - $task = Task::factory()->create([ - 'schedule_id' => $schedule->id, - 'action' => Task::ACTION_POWER, - 'payload' => 'start', - 'continue_on_failure' => $continueOnFailure, - ]); - - $mock = \Mockery::mock(DaemonPowerRepository::class); - $this->instance(DaemonPowerRepository::class, $mock); - - $mock->expects('setServer->send')->andThrow( - new DaemonConnectionException(new BadResponseException('Bad request', new Request('GET', '/test'), new Response())) - ); - - if (!$continueOnFailure) { - $this->expectException(DaemonConnectionException::class); - } - - Bus::dispatchSync(new RunTaskJob($task)); - - if ($continueOnFailure) { - $task->refresh(); - $schedule->refresh(); - - $this->assertFalse($task->is_queued); - $this->assertFalse($schedule->is_processing); - $this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at)); - } - } - - /** - * Test that a schedule is not executed if the server is suspended. - * - * @see https://github.com/pterodactyl/panel/issues/4008 - */ - public function testTaskIsNotRunIfServerIsSuspended() - { - $server = $this->createServerModel([ - 'status' => Server::STATUS_SUSPENDED, - ]); - - $schedule = Schedule::factory()->for($server)->create([ - 'last_run_at' => Carbon::now()->subHour(), - ]); - - $task = Task::factory()->for($schedule)->create([ - 'action' => Task::ACTION_POWER, - 'payload' => 'start', - ]); - - Bus::dispatchSync(new RunTaskJob($task)); - - $task->refresh(); - $schedule->refresh(); - - $this->assertFalse($task->is_queued); - $this->assertFalse($schedule->is_processing); - $this->assertTrue(Carbon::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at)); - } - - public static function isManualRunDataProvider(): array - { - return [[true], [false]]; - } -} + $job->assertFailedWith(LogicException::class); + $power->assertSentTimes('start', 1); + expect($task->refresh()->is_queued)->toBeFalse(); + expect($next->refresh()->is_queued)->toBeFalse(); + expect($schedule->refresh()->is_processing)->toBeFalse(); +}); diff --git a/tests/Integration/Providers/ActionServiceProviderTest.php b/tests/Integration/Providers/ActionServiceProviderTest.php new file mode 100644 index 000000000..d7128cff5 --- /dev/null +++ b/tests/Integration/Providers/ActionServiceProviderTest.php @@ -0,0 +1,36 @@ +not->toBeEmpty(); + + foreach ($files as $file) { + $class = 'Pterodactyl\\Actions\\'.str_replace('/', '\\', $file->getRelativePathname()); + $class = mb_substr($class, 0, -4); + $reflection = new ReflectionClass($class); + $contracts = array_filter( + $reflection->getInterfaceNames(), + fn (string $contract): bool => str_starts_with($contract, 'Pterodactyl\\Contracts\\'), + ); + + expect($contracts)->not->toBeEmpty(); + + foreach ($contracts as $contract) { + expect($this->app->bound($contract))->toBeTrue(); + + $operation = $this->app->make($contract); + expect($operation)->toBeInstanceOf($class); + expect($this->app->make($contract))->not->toBe($operation); + } + } +}); diff --git a/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php b/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php index 3c116cbeb..d8935b1af 100644 --- a/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php +++ b/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php @@ -1,174 +1,121 @@ set('pterodactyl.client_features.allocations.enabled', true); + config()->set('pterodactyl.client_features.allocations.range_start', 0); + config()->set('pterodactyl.client_features.allocations.range_end', 0); +}); +test('existing allocation is preferred', function () { + $server = $this->createServerModel(); + $created = Allocation::factory()->create(['node_id' => $server->node_id, 'ip' => $server->allocation->ip]); + $response = getAction()->assignAvailable($server); + expect($response->id)->toBe($created->id); + expect($response->ip)->toBe($server->allocation->ip); + expect($response->node_id)->toBe($server->node_id); + expect($response->server_id)->toBe($server->id); + $this->assertNotSame($server->allocation_id, $response->id); +}); +test('new allocation is created if one is not found', function () { + $server = $this->createServerModel(); + config()->set('pterodactyl.client_features.allocations.range_start', 5000); + config()->set('pterodactyl.client_features.allocations.range_end', 5005); + $response = getAction()->assignAvailable($server); + expect($response->server_id)->toBe($server->id); + expect($response->ip)->toBe($server->allocation->ip); + expect($response->node_id)->toBe($server->node_id); + $this->assertNotSame($server->allocation_id, $response->id); + expect($response->port >= 5000 && $response->port <= 5005)->toBeTrue(); +}); +test('numeric string ranges are normalized', function () { + $server = $this->createServerModel(); + config()->set('pterodactyl.client_features.allocations.range_start', '5000'); + config()->set('pterodactyl.client_features.allocations.range_end', '5001'); + $response = getAction()->assignAvailable($server); + expect([5000, 5001])->toContain($response->port); +}); +test('only port not in use is created', function () { + $server = $this->createServerModel(); + $server2 = $this->createServerModel(['node_id' => $server->node_id]); + config()->set('pterodactyl.client_features.allocations.range_start', 5000); + config()->set('pterodactyl.client_features.allocations.range_end', 5001); + Allocation::factory()->create(['server_id' => $server2->id, 'node_id' => $server->node_id, 'ip' => $server->allocation->ip, 'port' => 5000]); + $response = getAction()->assignAvailable($server); + expect($response->port)->toBe(5001); +}); +test('exception is thrown if no more allocations can be created in range', function () { + $server = $this->createServerModel(); + $server2 = $this->createServerModel(['node_id' => $server->node_id]); + config()->set('pterodactyl.client_features.allocations.range_start', 5000); + config()->set('pterodactyl.client_features.allocations.range_end', 5005); + for ($i = 5000; $i <= 5005; $i++) { + Allocation::factory()->create(['ip' => $server->allocation->ip, 'port' => $i, 'node_id' => $server->node_id, 'server_id' => $server2->id]); + } + $this->expectException(NoAutoAllocationSpaceAvailableException::class); + $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); + getAction()->assignAvailable($server); +}); +test('exception is thrown if only free port is on a different ip', function () { + $server = $this->createServerModel(); + Allocation::factory()->times(5)->create(['node_id' => $server->node_id]); + $this->expectException(NoAutoAllocationSpaceAvailableException::class); + $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); + getAction()->assignAvailable($server); +}); +test('exception is thrown if start or end range is not defined', function () { + $server = $this->createServerModel(); + $this->expectException(NoAutoAllocationSpaceAvailableException::class); + $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); + getAction()->assignAvailable($server); +}); +test('exception is thrown if start or end range is not numeric', function () { + $server = $this->createServerModel(); + config()->set('pterodactyl.client_features.allocations.range_start', 'hodor'); + config()->set('pterodactyl.client_features.allocations.range_end', 10); + try { + getAction()->assignAvailable($server); + $this->fail('This assertion should not be reached.'); + } catch (Exception $exception) { + expect($exception)->toBeInstanceOf(InvalidArgumentException::class); + expect($exception->getMessage())->toBe('Expected allocation range start to be an integer-like value.'); + } + config()->set('pterodactyl.client_features.allocations.range_start', 10); + config()->set('pterodactyl.client_features.allocations.range_end', 'hodor'); + try { + getAction()->assignAvailable($server); + $this->fail('This assertion should not be reached.'); + } catch (Exception $exception) { + expect($exception)->toBeInstanceOf(InvalidArgumentException::class); + expect($exception->getMessage())->toBe('Expected allocation range end to be an integer-like value.'); + } +}); +test('exception is thrown if feature is not enabled', function () { + config()->set('pterodactyl.client_features.allocations.enabled', false); + $server = $this->createServerModel(); + $this->expectException(AutoAllocationNotEnabledException::class); + getAction()->assignAvailable($server); +}); +function getAction(): AssignAvailableAllocation { - /** - * Setup tests. - */ - public function setUp(): void - { - parent::setUp(); - - config()->set('pterodactyl.client_features.allocations.enabled', true); - config()->set('pterodactyl.client_features.allocations.range_start', 0); - config()->set('pterodactyl.client_features.allocations.range_end', 0); - } - - /** - * Test that an unassigned allocation is preferred rather than creating an entirely new - * allocation for the server. - */ - public function testExistingAllocationIsPreferred() - { - $server = $this->createServerModel(); - - $created = Allocation::factory()->create([ - 'node_id' => $server->node_id, - 'ip' => $server->allocation->ip, - ]); - - $response = $this->getService()->handle($server); - - $this->assertSame($created->id, $response->id); - $this->assertSame($server->allocation->ip, $response->ip); - $this->assertSame($server->node_id, $response->node_id); - $this->assertSame($server->id, $response->server_id); - $this->assertNotSame($server->allocation_id, $response->id); - } - - /** - * Test that a new allocation is created if there is not a free one available. - */ - public function testNewAllocationIsCreatedIfOneIsNotFound() - { - $server = $this->createServerModel(); - config()->set('pterodactyl.client_features.allocations.range_start', 5000); - config()->set('pterodactyl.client_features.allocations.range_end', 5005); - - $response = $this->getService()->handle($server); - $this->assertSame($server->id, $response->server_id); - $this->assertSame($server->allocation->ip, $response->ip); - $this->assertSame($server->node_id, $response->node_id); - $this->assertNotSame($server->allocation_id, $response->id); - $this->assertTrue($response->port >= 5000 && $response->port <= 5005); - } - - /** - * Test that a currently assigned port is never assigned to a server. - */ - public function testOnlyPortNotInUseIsCreated() - { - $server = $this->createServerModel(); - $server2 = $this->createServerModel(['node_id' => $server->node_id]); - - config()->set('pterodactyl.client_features.allocations.range_start', 5000); - config()->set('pterodactyl.client_features.allocations.range_end', 5001); - - Allocation::factory()->create([ - 'server_id' => $server2->id, - 'node_id' => $server->node_id, - 'ip' => $server->allocation->ip, - 'port' => 5000, - ]); - - $response = $this->getService()->handle($server); - $this->assertSame(5001, $response->port); - } - - public function testExceptionIsThrownIfNoMoreAllocationsCanBeCreatedInRange() - { - $server = $this->createServerModel(); - $server2 = $this->createServerModel(['node_id' => $server->node_id]); - config()->set('pterodactyl.client_features.allocations.range_start', 5000); - config()->set('pterodactyl.client_features.allocations.range_end', 5005); - - for ($i = 5000; $i <= 5005; ++$i) { - Allocation::factory()->create([ - 'ip' => $server->allocation->ip, - 'port' => $i, - 'node_id' => $server->node_id, - 'server_id' => $server2->id, - ]); - } - - $this->expectException(NoAutoAllocationSpaceAvailableException::class); - $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); - - $this->getService()->handle($server); - } - - /** - * Test that we only auto-allocate from the current server's IP address space, and not a random - * IP address available on that node. - */ - public function testExceptionIsThrownIfOnlyFreePortIsOnADifferentIp() - { - $server = $this->createServerModel(); - - Allocation::factory()->times(5)->create(['node_id' => $server->node_id]); - - $this->expectException(NoAutoAllocationSpaceAvailableException::class); - $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); - - $this->getService()->handle($server); - } - - public function testExceptionIsThrownIfStartOrEndRangeIsNotDefined() - { - $server = $this->createServerModel(); - - $this->expectException(NoAutoAllocationSpaceAvailableException::class); - $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); - - $this->getService()->handle($server); - } - - public function testExceptionIsThrownIfStartOrEndRangeIsNotNumeric() - { - $server = $this->createServerModel(); - config()->set('pterodactyl.client_features.allocations.range_start', 'hodor'); - config()->set('pterodactyl.client_features.allocations.range_end', 10); - - try { - $this->getService()->handle($server); - $this->fail('This assertion should not be reached.'); - } catch (\Exception $exception) { - $this->assertInstanceOf(\InvalidArgumentException::class, $exception); - $this->assertSame('Expected an integerish value. Got: string', $exception->getMessage()); - } - - config()->set('pterodactyl.client_features.allocations.range_start', 10); - config()->set('pterodactyl.client_features.allocations.range_end', 'hodor'); - - try { - $this->getService()->handle($server); - $this->fail('This assertion should not be reached.'); - } catch (\Exception $exception) { - $this->assertInstanceOf(\InvalidArgumentException::class, $exception); - $this->assertSame('Expected an integerish value. Got: string', $exception->getMessage()); - } - } - - public function testExceptionIsThrownIfFeatureIsNotEnabled() - { - config()->set('pterodactyl.client_features.allocations.enabled', false); - $server = $this->createServerModel(); - - $this->expectException(AutoAllocationNotEnabledException::class); - - $this->getService()->handle($server); - } - - private function getService(): FindAssignableAllocationService - { - return $this->app->make(FindAssignableAllocationService::class); - } + return (function () { + return $this->app->make(AssignAvailableAllocation::class); + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/BackendWriteConsistencyTest.php b/tests/Integration/Services/BackendWriteConsistencyTest.php new file mode 100644 index 000000000..bc8276647 --- /dev/null +++ b/tests/Integration/Services/BackendWriteConsistencyTest.php @@ -0,0 +1,196 @@ +set('database.connections.commit-publication-tests', ['driver' => 'sqlite', 'database' => ':memory:']); + config()->set('queue.default', 'commit-publication-tests'); + config()->set('queue.connections.commit-publication-tests', [ + 'driver' => 'database', 'connection' => 'commit-publication-tests', 'table' => 'jobs', + 'queue' => 'standard', 'retry_after' => 90, 'after_commit' => false, + ]); + Schema::connection('commit-publication-tests')->create('jobs', function (Blueprint $table): void { + $table->id(); + $table->string('queue'); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); +}); + +test('a transfer rejects an allocation claimed after request validation without reserving the rest', function (bool $claimPrimary): void { + $server = $this->createServerModel(); + $other = $this->createServerModel(); + $node = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + $primary = Allocation::factory()->for($node)->create(['server_id' => null]); + $additional = Allocation::factory()->for($node)->create(['server_id' => null]); + ($claimPrimary ? $primary : $additional)->update(['server_id' => $other->id]); + $fake = new FakeDaemonTransfer; + expect(fn () => $this->app->make(InitiatesTransfers::class)->initiate($server, $node, $primary->id, [$additional->id])) + ->toThrow(DisplayException::class, 'The selected allocations are no longer available on the target node.'); + $this->assertDatabaseMissing('server_transfers', ['server_id' => $server->id]); + expect($primary->refresh()->server_id)->toBe($claimPrimary ? $other->id : null); + expect($additional->refresh()->server_id)->toBe($claimPrimary ? null : $other->id); + + $fake->assertNothingHappened(); +})->with(['primary claimed' => true, 'additional claimed' => false]); + +test('a stale server cannot start another pending transfer', function (): void { + $server = $this->createServerModel(); + $server->load('transfer'); + + $node = Node::factory()->create(['location_id' => $server->node->location_id, 'memory' => 102400, 'disk' => 102400]); + $primary = Allocation::factory()->for($node)->create(['server_id' => null]); + ServerTransfer::factory()->create(['server_id' => $server->id, 'old_node' => $server->node_id, 'new_node' => $node->id]); + $fake = new FakeDaemonTransfer; + expect(fn () => $this->app->make(InitiatesTransfers::class)->initiate($server, $node, $primary->id, [])) + ->toThrow(ServerStateConflictException::class); + expect(ServerTransfer::query()->where('server_id', $server->id)->count())->toBe(1); + expect($primary->refresh()->server_id)->toBeNull(); + + $fake->assertNothingHappened(); +}); + +test('reordering a stale task uses its latest position', function (): void { + $server = $this->createServerModel(); + $schedule = Schedule::factory()->for($server)->create(); + $tasks = Task::factory()->for($schedule)->sequence(['sequence_id' => 1], ['sequence_id' => 2], ['sequence_id' => 3])->count(3)->create(); + $updates = $this->app->make(UpdatesScheduleTasks::class); + $data = ['action' => 'command', 'payload' => 'say test', 'time_offset' => 0, 'continue_on_failure' => false, 'sequence_id' => 3]; + $updates->update($schedule, $tasks[0], $data); + $updates->update($schedule, $tasks[1], $data); + + expect($tasks[0]->refresh()->sequence_id)->toBe(2); + expect($tasks[1]->refresh()->sequence_id)->toBe(3); + expect($tasks[2]->refresh()->sequence_id)->toBe(1); +}); + +test('deleting a stale task closes its latest sequence gap', function (): void { + $server = $this->createServerModel(); + $schedule = Schedule::factory()->for($server)->create(); + $tasks = Task::factory()->for($schedule)->sequence(['sequence_id' => 1], ['sequence_id' => 2], ['sequence_id' => 3])->count(3)->create(); + $this->app->make(UpdatesScheduleTasks::class)->update($schedule, $tasks[0], [ + 'action' => 'command', 'payload' => 'say test', 'time_offset' => 0, 'continue_on_failure' => false, 'sequence_id' => 3, + ]); + $this->app->make(DeletesScheduleTasks::class)->delete($schedule, $tasks[1]); + expect($tasks[0]->refresh()->sequence_id)->toBe(2); + expect($tasks[2]->refresh()->sequence_id)->toBe(1); + $this->assertDatabaseMissing('tasks', ['id' => $tasks[1]->id]); +}); + +test('an existing grant is rejected without changing its permissions', function (): void { + Notification::fake(); + $server = $this->createServerModel(); + $user = User::factory()->create(); + $creates = $this->app->make(CreatesSubusers::class); + $subuser = $creates->create($server, $user->email, ['control.start']); + expect(fn () => $creates->create($server, $user->email, ['control.stop']))->toThrow(ServerSubuserExistsException::class); + expect($server->subusers()->where('user_id', $user->id)->count())->toBe(1); + expect($subuser->refresh()->permissions)->toBe(['control.start']); +}); + +test('new account and subuser notifications are only published after the outer transaction commits', function (): void { + $server = $this->createServerModel(); + $email = fake()->unique()->safeEmail(); + DB::transaction(function () use ($server, $email): void { + $this->app->make(CreatesSubusers::class)->create($server, $email, ['control.start']); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(0); + }); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(2); +}); + +test('a rolled back invitation publishes no account or subuser notifications', function (): void { + $server = $this->createServerModel(); + $email = fake()->unique()->safeEmail(); + expect(fn () => DB::transaction(function () use ($server, $email): void { + $this->app->make(CreatesSubusers::class)->create($server, $email, ['control.start']); + throw new RuntimeException('rollback invitation'); + }))->toThrow(RuntimeException::class, 'rollback invitation'); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(0); + $this->assertDatabaseMissing('users', ['email' => $email]); +}); + +test('permission revocation waits for the outer transaction commit', function (): void { + $server = $this->createServerModel(); + $subuser = Subuser::factory()->for($server)->for(User::factory()->create())->create(['permissions' => ['control.start']]); + DB::connection('commit-publication-tests')->table('jobs')->delete(); + DB::transaction(function () use ($server, $subuser): void { + $this->app->make(UpdatesSubusers::class)->update($server, $subuser, ['control.stop']); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(0); + }); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(1); + expect($subuser->refresh()->permissions)->toBe(['control.stop']); +}); + +test('a rolled back permission update publishes no revocation', function (): void { + $server = $this->createServerModel(); + $subuser = Subuser::factory()->for($server)->for(User::factory()->create())->create(['permissions' => ['control.start']]); + DB::connection('commit-publication-tests')->table('jobs')->delete(); + expect(fn () => DB::transaction(function () use ($server, $subuser): void { + $this->app->make(UpdatesSubusers::class)->update($server, $subuser, ['control.stop']); + throw new RuntimeException('rollback permissions'); + }))->toThrow(RuntimeException::class, 'rollback permissions'); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(0); + expect($subuser->refresh()->permissions)->toBe(['control.start']); + + $this->app->make(UpdatesSubusers::class)->update($server, $subuser, ['control.stop']); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(1); +}); + +test('subuser removal publishes revocation and notification after commit', function (): void { + $server = $this->createServerModel(); + $subuser = Subuser::factory()->for($server)->for(User::factory()->create())->create(); + DB::connection('commit-publication-tests')->table('jobs')->delete(); + DB::transaction(function () use ($server, $subuser): void { + $this->app->make(DeletesSubusers::class)->delete($server, $subuser); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(0); + }); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(2); + $this->assertDatabaseMissing('subusers', ['id' => $subuser->id]); +}); + +test('a rolled back removal publishes neither revocation nor notification', function (): void { + $server = $this->createServerModel(); + $subuser = Subuser::factory()->for($server)->for(User::factory()->create())->create(); + DB::connection('commit-publication-tests')->table('jobs')->delete(); + expect(fn () => DB::transaction(function () use ($server, $subuser): void { + $this->app->make(DeletesSubusers::class)->delete($server, $subuser); + throw new RuntimeException('rollback removal'); + }))->toThrow(RuntimeException::class, 'rollback removal'); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(0); + $this->assertDatabaseHas('subusers', ['id' => $subuser->id]); + + $this->app->make(DeletesSubusers::class)->delete($server, Subuser::query()->findOrFail($subuser->id)); + expect(DB::connection('commit-publication-tests')->table('jobs')->count())->toBe(2); + $this->assertDatabaseMissing('subusers', ['id' => $subuser->id]); +}); diff --git a/tests/Integration/Services/Backups/DeleteBackupServiceTest.php b/tests/Integration/Services/Backups/DeleteBackupServiceTest.php index d1fb0faac..09b698ef2 100644 --- a/tests/Integration/Services/Backups/DeleteBackupServiceTest.php +++ b/tests/Integration/Services/Backups/DeleteBackupServiceTest.php @@ -1,114 +1,72 @@ createServerModel(); - $backup = Backup::factory()->create([ - 'server_id' => $server->id, - 'is_locked' => true, - ]); - - $this->expectException(BackupLockedException::class); - - $this->app->make(DeleteBackupService::class)->handle($backup); +uses(IntegrationTestCase::class, DatabaseTransactions::class); +test('locked backup cannot be deleted', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id, 'is_locked' => true]); + try { + $this->app->make(DeletesBackups::class)->delete($backup); + $this->fail('Expected BackupLockedException to be thrown.'); + } catch (BackupLockedException) { } - - public function testFailedBackupThatIsLockedCanBeDeleted() - { - $server = $this->createServerModel(); - $backup = Backup::factory()->create([ - 'server_id' => $server->id, - 'is_locked' => true, - 'is_successful' => false, - ]); - - $mock = $this->mock(DaemonBackupRepository::class); - $mock->expects('setServer->delete')->with($backup)->andReturn(new Response()); - - $this->app->make(DeleteBackupService::class)->handle($backup); - - $backup->refresh(); - - $this->assertNotNull($backup->deleted_at); + $this->assertModelExists($backup); +}); +test('failed backup that is locked can be deleted', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id, 'is_locked' => true, 'is_successful' => false]); + $fake = new FakeDaemonBackup; + $this->app->make(DeletesBackups::class)->delete($backup); + $backup->refresh(); + expect($backup->deleted_at)->not->toBeNull(); + $fake->assertDeleted($backup->uuid); +}); +test('exception thrown due to missing backup is ignored', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id]); + $fake = new FakeDaemonBackup; + $fake->throwable = new DaemonConnectionException(Http::failedRequest([], 404)); + $this->app->make(DeletesBackups::class)->delete($backup); + $backup->refresh(); + expect($backup->deleted_at)->not->toBeNull(); + $fake->assertDeleted($backup->uuid); +}); +test('exception is thrown if not404', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['server_id' => $server->id]); + $fake = new FakeDaemonBackup; + $fake->throwable = new DaemonConnectionException(Http::failedRequest([], 500)); + try { + $this->app->make(DeletesBackups::class)->delete($backup); + $this->fail('Expected DaemonConnectionException to be thrown.'); + } catch (DaemonConnectionException) { } - - public function testExceptionThrownDueToMissingBackupIsIgnored() - { - $server = $this->createServerModel(); - $backup = Backup::factory()->create(['server_id' => $server->id]); - - $mock = $this->mock(DaemonBackupRepository::class); - $mock->expects('setServer->delete')->with($backup)->andThrow( - new DaemonConnectionException( - new ClientException('', new Request('DELETE', '/'), new Response(404)) - ) - ); - - $this->app->make(DeleteBackupService::class)->handle($backup); - - $backup->refresh(); - - $this->assertNotNull($backup->deleted_at); - } - - public function testExceptionIsThrownIfNot404() - { - $server = $this->createServerModel(); - $backup = Backup::factory()->create(['server_id' => $server->id]); - - $mock = $this->mock(DaemonBackupRepository::class); - $mock->expects('setServer->delete')->with($backup)->andThrow( - new DaemonConnectionException( - new ClientException('', new Request('DELETE', '/'), new Response(500)) - ) - ); - - $this->expectException(DaemonConnectionException::class); - - $this->app->make(DeleteBackupService::class)->handle($backup); - - $backup->refresh(); - - $this->assertNull($backup->deleted_at); - } - - public function testS3ObjectCanBeDeleted() - { - $server = $this->createServerModel(); - $backup = Backup::factory()->create([ - 'disk' => Backup::ADAPTER_AWS_S3, - 'server_id' => $server->id, - ]); - - $manager = $this->mock(BackupManager::class); - $adapter = $this->mock(S3Filesystem::class); - - $manager->expects('adapter')->with(Backup::ADAPTER_AWS_S3)->andReturn($adapter); - - $adapter->expects('getBucket')->andReturn('foobar'); - $adapter->expects('getClient->deleteObject')->with([ - 'Bucket' => 'foobar', - 'Key' => sprintf('%s/%s.tar.gz', $server->uuid, $backup->uuid), - ]); - - $this->app->make(DeleteBackupService::class)->handle($backup); - - $this->assertSoftDeleted($backup); - } -} + $backup->refresh(); + expect($backup->deleted_at)->toBeNull(); + $fake->assertDeleted($backup->uuid); +}); +test('s3 object can be deleted', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->create(['disk' => Backup::ADAPTER_AWS_S3, 'server_id' => $server->id]); + $filesystem = new FakeS3Filesystem('foobar'); + $manager = new FakeBackupManager($filesystem); + $this->app->instance(BackupManager::class, $manager); + $this->app->make(DeletesBackups::class)->delete($backup); + $filesystem->assertDeleted(sprintf('%s/%s.tar.gz', $server->uuid, $backup->uuid)); + $this->assertSoftDeleted($backup); +}); diff --git a/tests/Integration/Services/Backups/DownloadLinkServiceTest.php b/tests/Integration/Services/Backups/DownloadLinkServiceTest.php index 94535a70d..8c1e4d59a 100644 --- a/tests/Integration/Services/Backups/DownloadLinkServiceTest.php +++ b/tests/Integration/Services/Backups/DownloadLinkServiceTest.php @@ -1,55 +1,40 @@ createServerModel(); - $backup = Backup::factory()->for($server)->create([ - 'disk' => Backup::ADAPTER_WINGS, - ]); - - $url = $this->app->make(DownloadLinkService::class)->handle($backup, $server->user); - - $this->assertStringStartsWith($prefix = $server->node->getConnectionAddress() . '/download/backup?token=', $url); - - $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); - $config = $config->withValidationConstraints(new SignedWith(new Sha256(), $key)); - - /** @var \Lcobucci\JWT\Token\Plain $token */ - $token = $config->parser()->parse(substr($url, strlen($prefix))); - - $this->assertTrue( - $config->validator()->validate($token, ...$config->validationConstraints()), - 'Failed to validate that the JWT data returned was signed using the Node\'s secret key.' - ); - - $timestamp = CarbonImmutable::createFromTimestamp(CarbonImmutable::now()->getTimestamp())->timezone('UTC'); - - // Check that the claims are generated correctly. - $this->assertTrue($token->hasBeenIssuedBy(config('app.url'))); - $this->assertTrue($token->isPermittedFor($server->node->getConnectionAddress())); - $this->assertEquals($timestamp, $token->claims()->get('iat')); - $this->assertEquals($timestamp->subMinutes(5), $token->claims()->get('nbf')); - $this->assertEquals($timestamp->addMinutes(15), $token->claims()->get('exp')); - $this->assertSame($backup->uuid, $token->claims()->get('backup_uuid')); - $this->assertSame($server->uuid, $token->claims()->get('server_uuid')); - $this->assertEquals(JwtScope::BackupDownload->value, $token->claims()->get('scope')); - } -} +uses(IntegrationTestCase::class, DatabaseTransactions::class); +test('it generates local url with jwt', function () { + $server = $this->createServerModel(); + $backup = Backup::factory()->for($server)->create(['disk' => Backup::ADAPTER_WINGS]); + $url = $this->app->make(GeneratesBackupDownloadLinks::class)->generate($backup, $server->user); + expect($url)->toStartWith($prefix = $server->node->getConnectionAddress().'/download/backup?token='); + $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); + $config = $config->withValidationConstraints(new SignedWith(new Sha256(), $key)); + /** @var Plain $token */ + $token = $config->parser()->parse(mb_substr($url, mb_strlen($prefix))); + expect($config->validator()->validate($token, ...$config->validationConstraints()))->toBeTrue('Failed to validate that the JWT data returned was signed using the Node\'s secret key.'); + $timestamp = CarbonImmutable::createFromTimestamp(CarbonImmutable::now()->getTimestamp())->timezone('UTC'); + // Check that the claims are generated correctly. + expect($token->hasBeenIssuedBy(config('app.url')))->toBeTrue(); + expect($token->isPermittedFor($server->node->getConnectionAddress()))->toBeTrue(); + expect($token->claims()->get('iat'))->toEqual($timestamp); + expect($token->claims()->get('nbf'))->toEqual($timestamp->subMinutes(5)); + expect($token->claims()->get('exp'))->toEqual($timestamp->addMinutes(15)); + expect($token->claims()->get('backup_uuid'))->toBe($backup->uuid); + expect($token->claims()->get('server_uuid'))->toBe($server->uuid); + expect($token->claims()->get('scope'))->toEqual(JwtScope::BackupDownload->value); +}); diff --git a/tests/Integration/Services/Daemon/DaemonClientTest.php b/tests/Integration/Services/Daemon/DaemonClientTest.php new file mode 100644 index 000000000..fb3390ad1 --- /dev/null +++ b/tests/Integration/Services/Daemon/DaemonClientTest.php @@ -0,0 +1,227 @@ +make([ + 'location_id' => 1, + 'fqdn' => $host, + 'scheme' => 'https', + 'daemonListen' => 8080, + 'daemon_token' => Crypt::encrypt($token), + ])->setRelation('mounts', new Collection); +} + +function server(Node $node, string $uuid = 'server-one'): Server +{ + return Server::factory()->make([ + 'uuid' => $uuid, + 'owner_id' => 1, + 'node_id' => 1, + 'egg_id' => 1, + 'allocation_id' => 1, + ])->setRelation('node', $node); +} + +test('retained clients keep their server and credentials across interleaved operations', function (): void { + $firstNode = node('first.example.test', 'first-token'); + $secondNode = node('second.example.test', 'second-token'); + $firstServer = server($firstNode, 'first-server'); + $first = Daemon::server($firstServer); + $second = Daemon::server(server($secondNode, 'second-server')); + Http::fake([ + 'https://first.example.test:8080/api/*' => Http::response(), + 'https://second.example.test:8080/api/*' => Http::response(), + ]); + $firstServer->uuid = 'changed-server'; + $firstNode->fqdn = 'changed.example.test'; + $firstNode->daemon_token = Crypt::encrypt('changed-token'); + + $first->sync(); + $second->power('restart'); + $first->files()->putContent('/file.txt', 'first'); + $first->backups()->delete(Backup::factory()->make(['server_id' => 1, 'uuid' => 'backup-one'])); + + expect(Http::recorded()->map(fn (array $pair): array => [ + $pair[0]->method(), $pair[0]->url(), $pair[0]->header('Authorization')[0], + ])->all())->toBe([ + ['POST', 'https://first.example.test:8080/api/servers/first-server/sync', 'Bearer first-token'], + ['POST', 'https://second.example.test:8080/api/servers/second-server/power', 'Bearer second-token'], + ['POST', 'https://first.example.test:8080/api/servers/first-server/files/write?file=%2Ffile.txt', 'Bearer first-token'], + ['DELETE', 'https://first.example.test:8080/api/servers/first-server/backup/backup-one', 'Bearer first-token'], + ]); +}); + +test('explicit source nodes override the server destination for transfer cleanup', function (): void { + $source = node('source.example.test', 'source-token'); + $destination = node('destination.example.test', 'destination-token'); + $server = server($destination); + Http::fake(['https://source.example.test:8080/api/servers/server-one' => Http::response()]); + + Daemon::server($server, $source)->delete(); + + Http::assertSent(fn (Request $request): bool => $request->method() === 'DELETE' + && $request->url() === 'https://source.example.test:8080/api/servers/server-one' + && $request->hasHeader('Authorization', 'Bearer source-token')); + Http::assertSentCount(1); +}); + +test('node configuration updates use selected credentials and the new configuration', function (): void { + $original = node(); + $client = Daemon::node($original); + $original->daemon_token = Crypt::encrypt('new-token'); + $original->daemonListen = 9090; + Http::fake(['https://wings.example.test:8080/api/update' => Http::response()]); + + $client->update($original); + + Http::assertSent(fn (Request $request): bool => $request->method() === 'POST' + && $request->hasHeader('Authorization', 'Bearer token-one') + && $request['token'] === 'new-token' + && $request['api']['port'] === 9090); +}); + +test('transport applies configured timeouts and the existing TLS policy', function (string $environment, bool $verify): void { + $this->app->detectEnvironment(fn (): string => $environment); + config()->set(['pterodactyl.guzzle.timeout' => '17', 'pterodactyl.guzzle.connect_timeout' => '4']); + $options = []; + Http::fake(['https://wings.example.test:8080/api/servers/server-one/sync' => function (Request $request, array $requestOptions) use (&$options) { + $options = $requestOptions; + + return Http::response(); + }]); + + Daemon::server(server(node()))->sync(); + + expect($options)->toMatchArray(['timeout' => 17, 'connect_timeout' => 4, 'verify' => $verify]); + Http::assertSent(fn (Request $request): bool => $request->hasHeader('Accept', 'application/json') + && $request->hasHeader('Content-Type', 'application/json')); +})->with([['production', true], ['testing', false]]); + +test('Wings HTTP errors retain status and request context without retrying', function (int $status): void { + Http::fake(['https://wings.example.test:8080/api/servers/server-one/sync' => Http::response(['error' => 'remote detail'], $status, ['X-Request-Id' => 'request-one'])]); + + try { + Daemon::server(server(node()))->sync(); + $this->fail('Expected a Wings error.'); + } catch (DaemonConnectionException $exception) { + expect($exception->getStatusCode())->toBe($status) + ->and($exception->getRequestId())->toBe('request-one') + ->and($exception->getPrevious())->toBeInstanceOf(RequestException::class); + expect(str_contains($exception->getMessage(), 'remote detail'))->toBe($status < 500); + } + + Http::assertSentCount(1); +})->with([400, 404, 422, 500, 502, 504]); + +test('connection failures use the gateway timeout contract', function (): void { + Http::fake(['https://wings.example.test:8080/api/servers/server-one/sync' => Http::failedConnection()]); + + try { + Daemon::server(server(node()))->sync(); + $this->fail('Expected a connection error.'); + } catch (DaemonConnectionException $exception) { + expect($exception->getStatusCode())->toBe(504) + ->and($exception->getRequestId())->toBeNull() + ->and($exception->getPrevious())->toBeInstanceOf(ConnectionException::class); + } +}); + +test('resource details retain the gateway timeout status for upstream errors', function (): void { + Http::fake(['https://wings.example.test:8080/api/servers/server-one' => Http::response([], 404, ['X-Request-Id' => 'resource-request'])]); + + try { + Daemon::server(server(node()))->details(); + $this->fail('Expected a resource error.'); + } catch (DaemonConnectionException $exception) { + expect($exception->getStatusCode())->toBe(504) + ->and($exception->getRequestId())->toBe('resource-request'); + } +}); + +test('file writes preserve raw content and encode the file query', function (): void { + $url = 'https://wings.example.test:8080/api/servers/server-one/files/write?file=%2Fhello%20world.txt'; + Http::fake([$url => Http::response()]); + $content = "line one\n{\"raw\": true}\n"; + + Daemon::server(server(node()))->files()->putContent('/hello world.txt', $content); + + Http::assertSent(fn (Request $request): bool => $request->url() === $url && $request->body() === $content); +}); + +test('file content limits reject oversized files', function (): void { + Http::fake(['https://wings.example.test:8080/api/servers/server-one/files/contents*' => Http::response('contents', 200, ['Content-Length' => 8])]); + + expect(fn (): string => Daemon::server(server(node()))->files()->getContent('/file.txt', 7))->toThrow(FileSizeTooLargeException::class); + expect(Daemon::server(server(node()))->files()->getContent('/file.txt', 8))->toBe('contents'); +}); + +test('archive timeouts and foreground pulls stay local to each request', function (): void { + $timeouts = []; + Http::fake(['https://wings.example.test:8080/api/servers/server-one/files/*' => function (Request $request, array $options) use (&$timeouts) { + $timeouts[] = $options['timeout']; + + return Http::response([]); + }]); + $files = Daemon::server(server(node()))->files(); + + $files->compressFiles('/', ['file.txt']); + $files->decompressFile('/', 'archive.tar.gz'); + $files->pull('https://downloads.example.test/archive', null, ['filename' => 'archive.zip', 'foreground' => true, 'use_header' => false, 'timeout' => 1200]); + $files->pull('https://downloads.example.test/other', null); + + expect($timeouts)->toBe([900, 900, 1200, 15]); + Http::assertSent(fn (Request $request): bool => ($request->data()['url'] ?? null) === 'https://downloads.example.test/archive' + && $request->data() === ['url' => 'https://downloads.example.test/archive', 'root' => '/', 'file_name' => 'archive.zip', 'use_header' => false, 'foreground' => true]); + Http::assertSent(fn (Request $request): bool => ($request->data()['url'] ?? null) === 'https://downloads.example.test/other' + && $request->data() === ['url' => 'https://downloads.example.test/other', 'root' => '/']); +}); + +test('backup adapters are chosen per backup and restore parameters are preserved', function (): void { + Http::fake(['https://wings.example.test:8080/api/servers/server-one/backup*' => Http::response()]); + $backup = Backup::factory()->make(['server_id' => 1, 'uuid' => 'backup-one', 'disk' => 'wings', 'ignored_files' => ['cache', '*.log']]); + $backups = Daemon::server(server(node()))->backups(); + + $backups->create($backup, 's3'); + $backups->create($backup); + $backups->restore($backup, 'https://download.example.test/backup', true); + + expect(Http::recorded()->map(fn (array $pair): array => $pair[0]->data())->all())->toBe([ + ['adapter' => 's3', 'uuid' => 'backup-one', 'ignore' => "cache\n*.log"], + ['adapter' => 'wings', 'uuid' => 'backup-one', 'ignore' => "cache\n*.log"], + ['adapter' => 'wings', 'truncate_directory' => true, 'download_url' => 'https://download.example.test/backup'], + ]); +}); + +test('commands preserve batch payloads and deauthorization preserves server scope', function (): void { + $node = node(); + Http::fake([ + 'https://wings.example.test:8080/api/servers/server-one/commands' => Http::response(), + 'https://wings.example.test:8080/api/deauthorize-user' => Http::response(), + ]); + + Daemon::server(server($node))->commands(['say first', 'say second']); + Daemon::node($node)->deauthorize('user-one', ['server-one']); + + Http::assertSent(fn (Request $request): bool => ($request->data()['commands'] ?? null) === ['say first', 'say second']); + Http::assertSent(fn (Request $request): bool => ($request->data()['user'] ?? null) === 'user-one' && ($request->data()['servers'] ?? null) === ['server-one']); +}); diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index 7ccfb8338..4508068fc 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -1,212 +1,152 @@ set('pterodactyl.client_features.databases.enabled', true); + $this->app->instance(DatabaseHostGateway::class, $this->fake = new FakeDatabaseHostGateway()); +}); +dataset('invalidDataDataProvider', fn (): array => [[[]], [['database' => '']], [['database' => 'something']], [['database' => 's_something']], [['database' => 's12s_something']], [['database' => 's12something']]]); +test('unique database name is generated correctly', function (): void { + expect(DatabaseName::generateUnique('example', 1))->toBe('s1_example'); + expect(DatabaseName::generateUnique('something_else', 123))->toBe('s123_something_else'); + expect(DatabaseName::generateUnique(str_repeat('a', 100), 123))->toBe('s123_'.str_repeat('a', 43)); +}); +test('exception is thrown if client databases are not enabled', function (): void { + config()->set('pterodactyl.client_features.databases.enabled', false); + $this->expectException(DatabaseClientFeatureNotEnabledException::class); + $server = $this->createServerModel(); + getService()->create($server, []); +}); +test('database cannot be created if server has reached limit', function (): void { + $server = $this->createServerModel(['database_limit' => 2]); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + $this->expectException(TooManyDatabasesException::class); + getService()->create($server, []); +}); +test('empty database name or invalid name triggers an exception', function (array $data): void { + $server = $this->createServerModel(); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('The database name passed to CreateDatabase::create MUST be prefixed with "s{server_id}_".'); + getService()->create($server, $data); +})->with('invalidDataDataProvider'); +test('creating database with identical name triggers an exception', function (): void { + $server = $this->createServerModel(); + $name = DatabaseName::generateUnique('soemthing', $server->id); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $host2 = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + Database::factory()->create(['database' => $name, 'database_host_id' => $host->id, 'server_id' => $server->id]); + // Try to create a database with the same name as a database on a different host. We expect + // this to fail since we don't account for the specific host when checking uniqueness. + try { + getService()->create($server, ['database' => $name, 'database_host_id' => $host2->id]); + $this->fail('Expected DuplicateDatabaseNameException to be thrown.'); + } catch (DuplicateDatabaseNameException $duplicateDatabaseNameException) { + expect($duplicateDatabaseNameException->getMessage())->toBe('A database with that name already exists for this server.'); + } + + $this->assertDatabaseMissing('databases', ['database' => $name, 'database_host_id' => $host2->id]); +}); +test('server database can be created', function (): void { + $server = $this->createServerModel(); + $name = DatabaseName::generateUnique('soemthing', $server->id); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + /** @var FakeDatabaseHostGateway $fake */ + $fake = $this->fake; + $response = getService()->create($server, ['remote' => '%', 'database' => $name, 'database_host_id' => $host->id]); + expect($response)->toBeInstanceOf(Database::class); + expect($server->id)->toBe($response->server_id); + $this->assertDatabaseHas('databases', ['server_id' => $server->id, 'id' => $response->id]); + + $fake->assertCreated($name); + expect($fake->count('createDatabase'))->toBe(1); + expect($fake->createdUsers)->toHaveCount(1); + expect($fake->createdUsers[0]['username'])->toMatch('/^(u\d+_)(\w){10}$/'); + expect($fake->createdUsers[0]['remote'])->toBe('%'); + expect(mb_strlen($fake->createdUsers[0]['password']))->toBe(24); + expect($fake->createdUsers[0]['maxConnections'])->toBeNull(); + + $fake->assertAssigned($name, $fake->createdUsers[0]['username'], '%'); + $fake->assertFlushed(1); +}); +test('exception encountered while creating database attempts to cleanup', function (): void { + $server = $this->createServerModel(); + $name = DatabaseName::generateUnique('soemthing', $server->id); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + /** @var FakeDatabaseHostGateway $fake */ + $fake = $this->fake; + $fake->throwOn['createDatabase'] = new BadMethodCallException(); + $fake->throwOn['dropUser'] = new InvalidArgumentException(); + expect(fn (): Database => getService()->create($server, ['remote' => '%', 'database' => $name, 'database_host_id' => $host->id])) + ->toThrow(BadMethodCallException::class); + $this->assertDatabaseMissing('databases', ['server_id' => $server->id]); + $fake->assertDroppedDatabase($name); + expect($fake->count('dropUser'))->toBe(1); +}); +test('each failed compensation is reported and does not skip the remaining cleanup', function (): void { + Exceptions::fake(); + $server = $this->createServerModel(); + $name = DatabaseName::generateUnique('cleanup', $server->id); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $fake = $this->fake; + $primary = new BadMethodCallException('provisioning failed'); + $databaseCleanup = new InvalidArgumentException('database cleanup failed'); + $userCleanup = new InvalidArgumentException('user cleanup failed'); + $fake->throwOn = ['createUser' => $primary, 'dropDatabase' => $databaseCleanup, 'dropUser' => $userCleanup]; + + expect(fn (): Database => getService()->create($server, ['remote' => '%', 'database' => $name, 'database_host_id' => $host->id])) + ->toThrow($primary); + + $this->assertDatabaseMissing('databases', ['server_id' => $server->id, 'database' => $name]); + expect($fake->count('dropDatabase'))->toBe(1); + expect($fake->count('dropUser'))->toBe(1); + + $fake->assertFlushed(1); + Exceptions::assertReported(fn (InvalidArgumentException $exception): bool => $exception === $databaseCleanup); + Exceptions::assertReported(fn (InvalidArgumentException $exception): bool => $exception === $userCleanup); +}); +test('host selection failure never mutates the previous database host', function (): void { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $dynamic = new FakeDynamicDatabaseConnection(); + $dynamic->throwOnSet = new InvalidArgumentException('host selection failed'); + + $this->app->instance(DynamicDatabaseConnection::class, $dynamic); + + expect(fn (): Database => getService()->create($server, [ + 'remote' => '%', 'database' => DatabaseName::generateUnique('selection', $server->id), 'database_host_id' => $host->id, + ]))->toThrow(InvalidArgumentException::class, 'host selection failed'); + + $this->assertDatabaseMissing('databases', ['server_id' => $server->id]); + expect($this->fake->calls)->toBe([]); +}); +function getService(): CreatesDatabases { - private MockInterface $repository; - - /** - * Setup tests. - */ - public function setUp(): void - { - parent::setUp(); - - config()->set('pterodactyl.client_features.databases.enabled', true); - - $this->repository = $this->mock(DatabaseRepository::class); - } - - /** - * Test that the name generated by the unique name function is what we expect. - */ - public function testUniqueDatabaseNameIsGeneratedCorrectly() - { - $this->assertSame('s1_example', DatabaseManagementService::generateUniqueDatabaseName('example', 1)); - $this->assertSame('s123_something_else', DatabaseManagementService::generateUniqueDatabaseName('something_else', 123)); - $this->assertSame('s123_' . str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); - } - - /** - * Test that disabling the client database feature flag prevents the creation of databases. - */ - public function testExceptionIsThrownIfClientDatabasesAreNotEnabled() - { - config()->set('pterodactyl.client_features.databases.enabled', false); - - $this->expectException(DatabaseClientFeatureNotEnabledException::class); - - $server = $this->createServerModel(); - $this->getService()->create($server, []); - } - - /** - * Test that a server at its database limit cannot have an additional one created if - * the $validateDatabaseLimit flag is not set to false. - */ - public function testDatabaseCannotBeCreatedIfServerHasReachedLimit() - { - $server = $this->createServerModel(['database_limit' => 2]); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - - Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); - - $this->expectException(TooManyDatabasesException::class); - - $this->getService()->create($server, []); - } - - /** - * Test that a missing or invalid database name format causes an exception to be thrown. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('invalidDataDataProvider')] - public function testEmptyDatabaseNameOrInvalidNameTriggersAnException(array $data) - { - $server = $this->createServerModel(); - - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".'); - - $this->getService()->create($server, $data); - } - - /** - * Test that creating a server database with an identical name triggers an exception. - */ - public function testCreatingDatabaseWithIdenticalNameTriggersAnException() - { - $server = $this->createServerModel(); - $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); - - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - $host2 = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - Database::factory()->create([ - 'database' => $name, - 'database_host_id' => $host->id, - 'server_id' => $server->id, - ]); - - $this->expectException(DuplicateDatabaseNameException::class); - $this->expectExceptionMessage('A database with that name already exists for this server.'); - - // Try to create a database with the same name as a database on a different host. We expect - // this to fail since we don't account for the specific host when checking uniqueness. - $this->getService()->create($server, [ - 'database' => $name, - 'database_host_id' => $host2->id, - ]); - - $this->assertDatabaseMissing('databases', ['server_id' => $server->id]); - } - - /** - * Test that a server database can be created successfully. - */ - public function testServerDatabaseCanBeCreated() - { - $server = $this->createServerModel(); - $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); - - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - - $this->repository->expects('createDatabase')->with($name); - - $username = null; - $secondUsername = null; - $password = null; - - // The value setting inside the closures if to avoid throwing an exception during the - // assertions that would get caught by the functions catcher and thus lead to the exception - // being swallowed incorrectly. - $this->repository->expects('createUser')->with( - \Mockery::on(function ($value) use (&$username) { - $username = $value; - - return true; - }), - '%', - \Mockery::on(function ($value) use (&$password) { - $password = $value; - - return true; - }), - null - ); - - $this->repository->expects('assignUserToDatabase')->with($name, \Mockery::on(function ($value) use (&$secondUsername) { - $secondUsername = $value; - - return true; - }), '%'); - - $this->repository->expects('flush')->withNoArgs(); - - $response = $this->getService()->create($server, [ - 'remote' => '%', - 'database' => $name, - 'database_host_id' => $host->id, - ]); - - $this->assertInstanceOf(Database::class, $response); - $this->assertSame($response->server_id, $server->id); - $this->assertMatchesRegularExpression('/^(u\d+_)(\w){10}$/', $username); - $this->assertSame($username, $secondUsername); - $this->assertSame(24, strlen($password)); - - $this->assertDatabaseHas('databases', ['server_id' => $server->id, 'id' => $response->id]); - } - - /** - * Test that an exception encountered while creating the database leads to the cleanup code - * being called and any exceptions encountered while cleaning up go unreported. - */ - public function testExceptionEncounteredWhileCreatingDatabaseAttemptsToCleanup() - { - $server = $this->createServerModel(); - $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); - - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - - $this->repository->expects('createDatabase')->with($name)->andThrows(new \BadMethodCallException()); - $this->repository->expects('dropDatabase')->with($name); - $this->repository->expects('dropUser')->withAnyArgs()->andThrows(new \InvalidArgumentException()); - - $this->expectException(\BadMethodCallException::class); - - $this->getService()->create($server, [ - 'remote' => '%', - 'database' => $name, - 'database_host_id' => $host->id, - ]); - - $this->assertDatabaseMissing('databases', ['server_id' => $server->id]); - } - - public static function invalidDataDataProvider(): array - { - return [ - [[]], - [['database' => '']], - [['database' => 'something']], - [['database' => 's_something']], - [['database' => 's12s_something']], - [['database' => 's12something']], - ]; - } - - private function getService(): DatabaseManagementService - { - return $this->app->make(DatabaseManagementService::class); - } + return (fn () => $this->app->make(CreatesDatabases::class))->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Databases/DatabasePasswordServiceTest.php b/tests/Integration/Services/Databases/DatabasePasswordServiceTest.php index 26f72c592..6e6f7a643 100644 --- a/tests/Integration/Services/Databases/DatabasePasswordServiceTest.php +++ b/tests/Integration/Services/Databases/DatabasePasswordServiceTest.php @@ -1,77 +1,53 @@ app->instance(DatabaseHostGateway::class, $this->fake = new FakeDatabaseHostGateway()); +}); +test('database password can be rotated', function () { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $database = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id, 'password' => encrypt('original')]); + $other = Database::factory()->create(['server_id' => $server->id, 'database_host_id' => $host->id, 'password' => encrypt('unchanged')]); + /** @var FakeDatabaseHostGateway $fake */ + $fake = $this->fake; + $expectedMaxConnections = $database->max_connections; + $response = getService()->rotate($database); + // The new password is returned, set on the host, and stored. + expect(mb_strlen($response))->toBe(24); + expect(decrypt($database->refresh()->password))->toBe($response); + // Other databases are untouched. + expect(decrypt($other->refresh()->password))->toBe('unchanged'); + + $fake->assertDroppedUser($database->username, $database->remote); + expect($fake->createdUsers)->toHaveCount(1); + expect($fake->createdUsers[0]['username'])->toBe($database->username); + expect($fake->createdUsers[0]['remote'])->toBe($database->remote); + expect($fake->createdUsers[0]['password'])->toBe($response); + expect($fake->createdUsers[0]['maxConnections'])->toBe($expectedMaxConnections); + $fake->assertAssigned($database->database, $database->username, $database->remote); + $fake->assertFlushed(1); +}); +function getService(): RotatesDatabasePasswords { - private MockInterface $repository; - - /** - * Setup tests. - */ - public function setUp(): void - { - parent::setUp(); - - $this->repository = $this->mock(DatabaseRepository::class); - } - - /** - * Test that a database password is rotated correctly. - */ - public function testDatabasePasswordCanBeRotated() - { - $server = $this->createServerModel(); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - - $database = Database::factory()->create([ - 'server_id' => $server->id, - 'database_host_id' => $host->id, - 'password' => encrypt('original'), - ]); - - $other = Database::factory()->create([ - 'server_id' => $server->id, - 'database_host_id' => $host->id, - 'password' => encrypt('unchanged'), - ]); - - $password = null; - - $this->repository->expects('dropUser')->with($database->username, $database->remote); - $this->repository->expects('createUser')->with( - $database->username, - $database->remote, - \Mockery::on(function ($value) use (&$password) { - $password = $value; - - return true; - }), - $database->max_connections - ); - $this->repository->expects('assignUserToDatabase')->with($database->database, $database->username, $database->remote); - $this->repository->expects('flush')->withNoArgs(); - - $response = $this->getService()->handle($database); - - // The new password is returned, set on the host, and stored. - $this->assertSame(24, strlen($response)); - $this->assertSame($response, $password); - $this->assertSame($response, decrypt($database->refresh()->password)); - - // Other databases are untouched. - $this->assertSame('unchanged', decrypt($other->refresh()->password)); - } - - private function getService(): DatabasePasswordService - { - return $this->app->make(DatabasePasswordService::class); - } + return (function () { + return $this->app->make(RotatesDatabasePasswords::class); + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php index f9afd8564..c0bea2d36 100644 --- a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php +++ b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php @@ -1,157 +1,92 @@ set('pterodactyl.client_features.databases.enabled', true); + $this->app->instance(DatabaseHostGateway::class, $this->gateway = new FakeDatabaseHostGateway()); +}); +/** + * Ensure we reset the config to the expected value. + */ +afterEach(function () { + config()->set('pterodactyl.client_features.databases.allow_random', true); + Database::query()->delete(); + DatabaseHost::query()->delete(); +}); +dataset('invalidDataProvider', function () { + return [[['remote' => '%']], [['database' => null, 'remote' => '%']], [['database' => '', 'remote' => '%']], [['database' => '']], [['database' => '', 'remote' => '']]]; +}); +test('error is thrown if database name is empty', function (array $data) { + $server = $this->createServerModel(['database_limit' => 5]); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Expected a non-empty database name.'); + getService()->deploy($server, $data); +})->with('invalidDataProvider'); +test('error is thrown if no database hosts exist on node', function () { + $server = $this->createServerModel(['database_limit' => 5]); + $node = Node::factory()->create(['location_id' => $server->location->id]); + DatabaseHost::factory()->create(['node_id' => $node->id]); + config()->set('pterodactyl.client_features.databases.allow_random', false); + $this->expectException(NoSuitableDatabaseHostException::class); + getService()->deploy($server, ['database' => 'something', 'remote' => '%']); +}); +test('error is thrown if no database hosts exist on system', function () { + $server = $this->createServerModel(['database_limit' => 5]); + $this->expectException(NoSuitableDatabaseHostException::class); + getService()->deploy($server, ['database' => 'something', 'remote' => '%']); +}); +test('database host on same node is preferred', function () { + $server = $this->createServerModel(['database_limit' => 5]); + $node = Node::factory()->create(['location_id' => $server->location->id]); + DatabaseHost::factory()->create(['node_id' => $node->id]); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $response = getService()->deploy($server, ['database' => 'something', 'remote' => '%']); + expect($response)->toBeInstanceOf(Database::class); + expect($response->database_host_id)->toBe($host->id); + expect($response->database)->toBe("s{$server->id}_something"); + $this->assertDatabaseHas('databases', ['id' => $response->id]); + /** @var FakeDatabaseHostGateway $gateway */ + $gateway = $this->gateway; + $gateway->assertCreated("s{$server->id}_something"); + $gateway->assertFlushed(1); +}); +test('database host is selected if no suitable host exists on same node', function () { + $server = $this->createServerModel(['database_limit' => 5]); + $node = Node::factory()->create(['location_id' => $server->location->id]); + $host = DatabaseHost::factory()->create(['node_id' => $node->id]); + $response = getService()->deploy($server, ['database' => 'something', 'remote' => '%']); + expect($response)->toBeInstanceOf(Database::class); + expect($response->database_host_id)->toBe($host->id); + expect($response->database)->toBe("s{$server->id}_something"); + $this->assertDatabaseHas('databases', ['id' => $response->id]); + /** @var FakeDatabaseHostGateway $gateway */ + $gateway = $this->gateway; + $gateway->assertCreated("s{$server->id}_something"); + $gateway->assertFlushed(1); +}); +function getService(): DeploysServerDatabases { - private MockInterface $managementService; - - /** - * Setup tests. - */ - public function setUp(): void - { - parent::setUp(); - - $this->managementService = \Mockery::mock(DatabaseManagementService::class); - $this->swap(DatabaseManagementService::class, $this->managementService); - } - - /** - * Ensure we reset the config to the expected value. - */ - protected function tearDown(): void - { - config()->set('pterodactyl.client_features.databases.allow_random', true); - - Database::query()->delete(); - DatabaseHost::query()->delete(); - - parent::tearDown(); - } - - /** - * Test that an error is thrown if either the database name or the remote host are empty. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('invalidDataProvider')] - public function testErrorIsThrownIfDatabaseNameIsEmpty(array $data) - { - $server = $this->createServerModel(); - - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageMatches('/^Expected a non-empty value\. Got: /'); - $this->getService()->handle($server, $data); - } - - /** - * Test that an error is thrown if there are no database hosts on the same node as the - * server and the allow_random config value is false. - */ - public function testErrorIsThrownIfNoDatabaseHostsExistOnNode() - { - $server = $this->createServerModel(); - - $node = Node::factory()->create(['location_id' => $server->location->id]); - DatabaseHost::factory()->create(['node_id' => $node->id]); - - config()->set('pterodactyl.client_features.databases.allow_random', false); - - $this->expectException(NoSuitableDatabaseHostException::class); - - $this->getService()->handle($server, [ - 'database' => 'something', - 'remote' => '%', - ]); - } - - /** - * Test that an error is thrown if no database hosts exist at all on the system. - */ - public function testErrorIsThrownIfNoDatabaseHostsExistOnSystem() - { - $server = $this->createServerModel(); - - $this->expectException(NoSuitableDatabaseHostException::class); - - $this->getService()->handle($server, [ - 'database' => 'something', - 'remote' => '%', - ]); - } - - /** - * Test that a database host on the same node as the server is preferred. - */ - public function testDatabaseHostOnSameNodeIsPreferred() - { - $server = $this->createServerModel(); - - $node = Node::factory()->create(['location_id' => $server->location->id]); - DatabaseHost::factory()->create(['node_id' => $node->id]); - $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - - $this->managementService->expects('create')->with($server, [ - 'database_host_id' => $host->id, - 'database' => "s{$server->id}_something", - 'remote' => '%', - ])->andReturns(new Database()); - - $response = $this->getService()->handle($server, [ - 'database' => 'something', - 'remote' => '%', - ]); - - $this->assertInstanceOf(Database::class, $response); - } - - /** - * Test that a database host not assigned to the same node as the server is used if - * there are no same-node hosts and the allow_random configuration value is set to - * true. - */ - public function testDatabaseHostIsSelectedIfNoSuitableHostExistsOnSameNode() - { - $server = $this->createServerModel(); - - $node = Node::factory()->create(['location_id' => $server->location->id]); - $host = DatabaseHost::factory()->create(['node_id' => $node->id]); - - $this->managementService->expects('create')->with($server, [ - 'database_host_id' => $host->id, - 'database' => "s{$server->id}_something", - 'remote' => '%', - ])->andReturns(new Database()); - - $response = $this->getService()->handle($server, [ - 'database' => 'something', - 'remote' => '%', - ]); - - $this->assertInstanceOf(Database::class, $response); - } - - public static function invalidDataProvider(): array - { - return [ - [['remote' => '%']], - [['database' => null, 'remote' => '%']], - [['database' => '', 'remote' => '%']], - [['database' => '']], - [['database' => '', 'remote' => '']], - ]; - } - - private function getService(): DeployServerDatabaseService - { - return $this->app->make(DeployServerDatabaseService::class); - } + return (function () { + return $this->app->make(DeploysServerDatabases::class); + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php b/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php index 64594c8b6..5575df5b7 100644 --- a/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php +++ b/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php @@ -1,187 +1,136 @@ delete(); + Server::query()->delete(); + Node::query()->delete(); +}); +test('exception is thrown if no disk space has been set', function () { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Disk space must be an int, got null'); + getService()->handle(); +}); +test('exception is thrown if no memory has been set', function () { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Memory usage must be an int, got null'); + getService()->setDisk(10)->handle(); +}); +test('no exception is thrown if stringified integers are passed for locations', function () { + getService()->setLocations([1, 2, 3]); + getService()->setLocations(['1', '2', '3']); + getService()->setLocations(['1', 2, 3]); + try { + getService()->setLocations(['a']); + $this->fail('This expectation should not be called.'); + } catch (Exception $exception) { + expect($exception)->toBeInstanceOf(InvalidArgumentException::class); + expect($exception->getMessage())->toBe('An array of location IDs should be provided when calling setLocations.'); + } + try { + getService()->setLocations(['1.2', '1', 2]); + $this->fail('This expectation should not be called.'); + } catch (Exception $exception) { + expect($exception)->toBeInstanceOf(InvalidArgumentException::class); + expect($exception->getMessage())->toBe('An array of location IDs should be provided when calling setLocations.'); + } +}); +test('expected node is returned for location', function () { + /** @var Location[] $locations */ + $locations = Location::factory()->times(2)->create(); + /** @var Node[] $nodes */ + $nodes = [ + // This node should never be returned once we've completed the initial test which + // runs without a location filter. + Node::factory()->create(['location_id' => $locations[0]->id, 'memory' => 2048, 'disk' => 1024 * 100]), + Node::factory()->create(['location_id' => $locations[1]->id, 'memory' => 1024, 'disk' => 10240, 'disk_overallocate' => 10]), + Node::factory()->create(['location_id' => $locations[1]->id, 'memory' => 1024 * 4, 'memory_overallocate' => 50, 'disk' => 102400]), + ]; + // Expect that all the nodes are returned as we're under all of their limits + // and there is no location filter being provided. + $response = getService()->setDisk(512)->setMemory(512)->handle(); + expect($response)->toBeInstanceOf(Collection::class); + expect($response)->toHaveCount(3); + expect($response[0])->toBeInstanceOf(Node::class); + // Expect that only the last node is returned because it is the only one with enough + // memory available to this instance. + $response = getService()->setDisk(512)->setMemory(2049)->handle(); + expect($response)->toBeInstanceOf(Collection::class); + expect($response)->toHaveCount(1); + expect($response[0]->id)->toBe($nodes[2]->id); + // Helper, I am lazy. + $base = function () use ($locations) { + return getService()->setLocations([$locations[1]->id])->setDisk(512); + }; + // Expect that we can create this server on either node since the disk and memory + // limits are below the allowed amount. + $response = $base()->setMemory(512)->handle(); + expect($response)->toHaveCount(2); + expect($response->where('location_id', $locations[1]->id)->count())->toBe(2); + // Expect that we can only create this server on the second node since the memory + // allocated is over the amount of memory available to the first node. + $response = $base()->setMemory(2048)->handle(); + expect($response)->toHaveCount(1); + expect($response[0]->id)->toBe($nodes[2]->id); + // Expect that we can only create this server on the second node since the disk + // allocated is over the limit assigned to the first node (even with the overallocate). + $response = $base()->setDisk(20480)->setMemory(256)->handle(); + expect($response)->toHaveCount(1); + expect($response[0]->id)->toBe($nodes[2]->id); + // Expect that we could create the server on either node since the disk allocated is + // right at the limit for Node 1 when the overallocate value is included in the calc. + $response = $base()->setDisk(11264)->setMemory(256)->handle(); + expect($response)->toHaveCount(2); + // Create two servers on the first node so that the disk space used is equal to the + // base amount available to the node (without overallocation included). + $servers = Collection::make([$this->createServerModel(['node_id' => $nodes[1]->id, 'disk' => 5120]), $this->createServerModel(['node_id' => $nodes[1]->id, 'disk' => 5120])]); + // Expect that we cannot create a server with a 1GB disk on the first node since there + // is not enough space (even with the overallocate) available to the node. + $response = $base()->setDisk(1024)->setMemory(256)->handle(); + expect($response)->toHaveCount(1); + expect($response[0]->id)->toBe($nodes[2]->id); + // Cleanup servers since we need to test some other stuff with memory here. + $servers->each->delete(); + // Expect that no viable node can be found when the memory limit for the given instance + // is greater than either node can support, even with the overallocation limits taken + // into account. + $this->expectException(NoViableNodeException::class); + $base()->setMemory(10000)->handle(); + // Create four servers so that the memory used for the second node is equal to the total + // limit for that node (pre-overallocate calculation). + Collection::make([$this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024]), $this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024]), $this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024]), $this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024])]); + // Expect that either node can support this server when we account for the overallocate + // value of the second node. + $response = $base()->setMemory(500)->handle(); + expect($response)->toHaveCount(2); + expect($response->where('location_id', $locations[1]->id)->count())->toBe(2); + // Expect that only the first node can support this server when we go over the remaining + // memory for the second nodes overallocate calculation. + $response = $base()->setMemory(640)->handle(); + expect($response)->toHaveCount(1); + expect($response[0]->id)->toBe($nodes[1]->id); +}); +function getService(): FindViableNodesService { - public function setUp(): void - { - parent::setUp(); - - Database::query()->delete(); - Server::query()->delete(); - Node::query()->delete(); - } - - public function testExceptionIsThrownIfNoDiskSpaceHasBeenSet() - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Disk space must be an int, got NULL'); - - $this->getService()->handle(); - } - - public function testExceptionIsThrownIfNoMemoryHasBeenSet() - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Memory usage must be an int, got NULL'); - - $this->getService()->setDisk(10)->handle(); - } - - /** - * Ensure that errors are not thrown back when passing in expected values. - * - * @see https://github.com/pterodactyl/panel/issues/2529 - */ - public function testNoExceptionIsThrownIfStringifiedIntegersArePassedForLocations() - { - $this->getService()->setLocations([1, 2, 3]); - $this->getService()->setLocations(['1', '2', '3']); - $this->getService()->setLocations(['1', 2, 3]); - - try { - $this->getService()->setLocations(['a']); - $this->fail('This expectation should not be called.'); - } catch (\Exception $exception) { - $this->assertInstanceOf(\InvalidArgumentException::class, $exception); - $this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage()); - } - - try { - $this->getService()->setLocations(['1.2', '1', 2]); - $this->fail('This expectation should not be called.'); - } catch (\Exception $exception) { - $this->assertInstanceOf(\InvalidArgumentException::class, $exception); - $this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage()); - } - } - - public function testExpectedNodeIsReturnedForLocation() - { - /** @var \Pterodactyl\Models\Location[] $locations */ - $locations = Location::factory()->times(2)->create(); - - /** @var \Pterodactyl\Models\Node[] $nodes */ - $nodes = [ - // This node should never be returned once we've completed the initial test which - // runs without a location filter. - Node::factory()->create([ - 'location_id' => $locations[0]->id, - 'memory' => 2048, - 'disk' => 1024 * 100, - ]), - Node::factory()->create([ - 'location_id' => $locations[1]->id, - 'memory' => 1024, - 'disk' => 10240, - 'disk_overallocate' => 10, - ]), - Node::factory()->create([ - 'location_id' => $locations[1]->id, - 'memory' => 1024 * 4, - 'memory_overallocate' => 50, - 'disk' => 102400, - ]), - ]; - - // Expect that all the nodes are returned as we're under all of their limits - // and there is no location filter being provided. - $response = $this->getService()->setDisk(512)->setMemory(512)->handle(); - $this->assertInstanceOf(Collection::class, $response); - $this->assertCount(3, $response); - $this->assertInstanceOf(Node::class, $response[0]); - - // Expect that only the last node is returned because it is the only one with enough - // memory available to this instance. - $response = $this->getService()->setDisk(512)->setMemory(2049)->handle(); - $this->assertInstanceOf(Collection::class, $response); - $this->assertCount(1, $response); - $this->assertSame($nodes[2]->id, $response[0]->id); - - // Helper, I am lazy. - $base = function () use ($locations) { - return $this->getService()->setLocations([$locations[1]->id])->setDisk(512); - }; - - // Expect that we can create this server on either node since the disk and memory - // limits are below the allowed amount. - $response = $base()->setMemory(512)->handle(); - $this->assertCount(2, $response); - $this->assertSame(2, $response->where('location_id', $locations[1]->id)->count()); - - // Expect that we can only create this server on the second node since the memory - // allocated is over the amount of memory available to the first node. - $response = $base()->setMemory(2048)->handle(); - $this->assertCount(1, $response); - $this->assertSame($nodes[2]->id, $response[0]->id); - - // Expect that we can only create this server on the second node since the disk - // allocated is over the limit assigned to the first node (even with the overallocate). - $response = $base()->setDisk(20480)->setMemory(256)->handle(); - $this->assertCount(1, $response); - $this->assertSame($nodes[2]->id, $response[0]->id); - - // Expect that we could create the server on either node since the disk allocated is - // right at the limit for Node 1 when the overallocate value is included in the calc. - $response = $base()->setDisk(11264)->setMemory(256)->handle(); - $this->assertCount(2, $response); - - // Create two servers on the first node so that the disk space used is equal to the - // base amount available to the node (without overallocation included). - $servers = Collection::make([ - $this->createServerModel(['node_id' => $nodes[1]->id, 'disk' => 5120]), - $this->createServerModel(['node_id' => $nodes[1]->id, 'disk' => 5120]), - ]); - - // Expect that we cannot create a server with a 1GB disk on the first node since there - // is not enough space (even with the overallocate) available to the node. - $response = $base()->setDisk(1024)->setMemory(256)->handle(); - $this->assertCount(1, $response); - $this->assertSame($nodes[2]->id, $response[0]->id); - - // Cleanup servers since we need to test some other stuff with memory here. - $servers->each->delete(); - - // Expect that no viable node can be found when the memory limit for the given instance - // is greater than either node can support, even with the overallocation limits taken - // into account. - $this->expectException(NoViableNodeException::class); - $base()->setMemory(10000)->handle(); - - // Create four servers so that the memory used for the second node is equal to the total - // limit for that node (pre-overallocate calculation). - Collection::make([ - $this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024]), - $this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024]), - $this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024]), - $this->createServerModel(['node_id' => $nodes[2]->id, 'memory' => 1024]), - ]); - - // Expect that either node can support this server when we account for the overallocate - // value of the second node. - $response = $base()->setMemory(500)->handle(); - $this->assertCount(2, $response); - $this->assertSame(2, $response->where('location_id', $locations[1]->id)->count()); - - // Expect that only the first node can support this server when we go over the remaining - // memory for the second nodes overallocate calculation. - $response = $base()->setMemory(640)->handle(); - $this->assertCount(1, $response); - $this->assertSame($nodes[1]->id, $response[0]->id); - } - - private function getService(): FindViableNodesService - { + return (function () { return $this->app->make(FindViableNodesService::class); - } + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Eggs/EggImporterServiceTest.php b/tests/Integration/Services/Eggs/EggImporterServiceTest.php new file mode 100644 index 000000000..f55d8c8a0 --- /dev/null +++ b/tests/Integration/Services/Eggs/EggImporterServiceTest.php @@ -0,0 +1,32 @@ +app->make(ImportsEggs::class)->import(fixture('minecraft/egg-paper.json')); + expect($egg->name)->toBe('Paper'); + expect($egg->author)->toBe('parker@pterodactyl.io'); + expect($egg->docker_images['Java 21'])->toBe('ghcr.io/pterodactyl/yolks:java_21'); + expect($egg->variables()->count())->toBe(4); + $updated = $this->app->make(UpdatesEggsFromImports::class)->update($egg, fixture('source-engine/egg-garrys-mod.json')); + expect($updated->name)->toBe('Garrys Mod'); + expect($updated->docker_images)->toBe(['ghcr.io/pterodactyl/games:source' => 'ghcr.io/pterodactyl/games:source']); + expect($updated->variables()->count())->toBe(8); + expect($updated->variables()->where('env_variable', 'MINECRAFT_VERSION')->exists())->toBeFalse(); +}); +function fixture(string $path): UploadedFile +{ + $absolutePath = base_path('database/Seeders/eggs/'.$path); + + return new UploadedFile($absolutePath, basename($absolutePath), 'application/json', UPLOAD_ERR_OK, true); +} diff --git a/tests/Integration/Services/Extensions/ExtensionInstallerTest.php b/tests/Integration/Services/Extensions/ExtensionInstallerTest.php new file mode 100644 index 000000000..61e717a52 --- /dev/null +++ b/tests/Integration/Services/Extensions/ExtensionInstallerTest.php @@ -0,0 +1,517 @@ +sourceDirectory = $base.DIRECTORY_SEPARATOR.'source'; + $this->installDirectory = $base.DIRECTORY_SEPARATOR.'installed'; + $this->assetsDirectory = $base.DIRECTORY_SEPARATOR.'assets'; + File::ensureDirectoryExists($this->sourceDirectory); + File::ensureDirectoryExists($this->installDirectory); + File::ensureDirectoryExists($this->assetsDirectory); + config(['extensions.directory' => $this->installDirectory, 'extensions.assets_directory' => $this->assetsDirectory]); + Extension::query()->where('identifier', 'eventful')->delete(); + $this->app->make(ExtensionRepository::class)->flushDiscovery(); +}); +afterEach(function (): void { + Extension::query()->where('identifier', 'eventful')->delete(); + File::deleteDirectory(dirname($this->sourceDirectory)); +}); +test('install enable disable and remove dispatch lifecycle events', function (): void { + Event::fake([ExtensionInstalling::class, ExtensionInstalled::class, ExtensionEnabling::class, ExtensionEnabled::class, ExtensionDisabling::class, ExtensionDisabled::class, ExtensionRemoving::class, ExtensionRemoved::class]); + $source = writeExtension('eventful'); + $installer = $this->app->make(InstallsExtensions::class); + $state = $this->app->make(SetsExtensionEnabled::class); + $remover = $this->app->make(RemovesExtensions::class); + $installer->install($source, enable: true); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful']); + expect(File::isDirectory($this->installDirectory.DIRECTORY_SEPARATOR.'eventful'))->toBeTrue(); + $state->setEnabled('eventful', false); + $remover->remove('eventful'); + $this->assertDatabaseMissing('extensions', ['identifier' => 'eventful']); + expect(File::isDirectory($this->installDirectory.DIRECTORY_SEPARATOR.'eventful'))->toBeFalse(); + Event::assertDispatched(ExtensionInstalling::class, fn (ExtensionInstalling $event): bool => $event->manifest->id === 'eventful'); + Event::assertDispatched(ExtensionInstalled::class, fn (ExtensionInstalled $event): bool => $event->manifest->id === 'eventful'); + Event::assertDispatched(ExtensionEnabling::class, fn (ExtensionEnabling $event): bool => $event->manifest->id === 'eventful'); + Event::assertDispatched(ExtensionEnabled::class, fn (ExtensionEnabled $event): bool => $event->manifest->id === 'eventful'); + Event::assertDispatched(ExtensionDisabling::class, fn (ExtensionDisabling $event): bool => $event->manifest->id === 'eventful'); + Event::assertDispatched(ExtensionDisabled::class, fn (ExtensionDisabled $event): bool => $event->manifest->id === 'eventful'); + Event::assertDispatched(ExtensionRemoving::class, fn (ExtensionRemoving $event): bool => $event->manifest->id === 'eventful'); + Event::assertDispatched(ExtensionRemoved::class, fn (ExtensionRemoved $event): bool => $event->identifier === 'eventful'); +}); +function writeExtension(string $identifier): string +{ + return (function () use ($identifier): string { + $path = $this->sourceDirectory.DIRECTORY_SEPARATOR.$identifier; + File::ensureDirectoryExists($path); + File::put($path.DIRECTORY_SEPARATOR.'extension.json', json_encode(['id' => $identifier, 'name' => 'Eventful', 'version' => '1.0.0'], JSON_THROW_ON_ERROR)); + + return $path; + })->call(pterodactylTestCase()); +} + +test('asset rollback failures preserve the previous package and the original error', function (): void { + $source = writeExtension('eventful'); + $this->app->make(InstallsExtensions::class)->install($source); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '2.0.0'], JSON_THROW_ON_ERROR)); + Exceptions::fake(); + $assets = Mockery::mock(ExtensionAssetPublisher::class)->makePartial(); + $assets->shouldReceive('publish')->once()->andThrow(new RuntimeException('asset publication failed')); + $assets->shouldReceive('activate')->once()->andThrow(new RuntimeException('asset rollback failed')); + $this->app->instance(ExtensionAssetPublisher::class, $assets); + + expect(fn () => $this->app->make(InstallsExtensions::class)->install($source))->toThrow(RuntimeException::class, 'asset publication failed'); + + expect($this->app->make(ExtensionManifestValidator::class)->fromDirectory($this->installDirectory.'/eventful')->version)->toBe('1.0.0'); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0', 'enabled' => false]); + Exceptions::assertReported(fn (RuntimeException $exception): bool => $exception->getMessage() === 'asset rollback failed'); + expect(glob($this->installDirectory.'/.previous-*'))->toBeEmpty(); +}); + +test('a failed package restore retains the backup for manual recovery', function (): void { + $source = writeExtension('eventful'); + $this->app->make(InstallsExtensions::class)->install($source); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '2.0.0'], JSON_THROW_ON_ERROR)); + Exceptions::fake(); + $filesystem = File::getFacadeRoot(); + File::partialMock()->shouldReceive('move')->andReturnUsing(static function (string $from, string $to) use ($filesystem): bool { + if (str_contains($from, '.previous-')) { + return false; + } + + return $filesystem->move($from, $to); + }); + $assets = Mockery::mock(ExtensionAssetPublisher::class)->makePartial(); + $assets->shouldReceive('publish')->once()->andThrow(new RuntimeException('asset publication failed')); + $this->app->instance(ExtensionAssetPublisher::class, $assets); + + expect(fn () => $this->app->make(InstallsExtensions::class)->install($source))->toThrow(RuntimeException::class, 'asset publication failed'); + + $backups = glob($this->installDirectory.'/.previous-*'); + expect($backups)->toHaveCount(1); + expect($this->app->make(ExtensionManifestValidator::class)->fromDirectory($backups[0])->version)->toBe('1.0.0'); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0']); + Exceptions::assertReported(fn (RuntimeException $exception): bool => str_contains($exception->getMessage(), $backups[0])); +}); + +test('invalid archive roots leave no extracted files', function (bool $ambiguous): void { + $this->app->useStoragePath(dirname($this->sourceDirectory).'/storage'); + $path = $this->sourceDirectory.'/invalid.zip'; + $zip = new ZipArchive; + $zip->open($path, ZipArchive::CREATE); + $zip->addFromString('readme.txt', 'No extension manifest'); + if ($ambiguous) { + $zip->addFromString('first/extension.json', '{}'); + $zip->addFromString('second/extension.json', '{}'); + } + + $zip->close(); + + expect(fn () => $this->app->make(ExtensionPackageLocator::class)->locate($path))->toThrow(InvalidExtensionException::class, 'Could not locate a single'); + + expect(glob(storage_path('app/extensions-tmp/*')))->toBeEmpty(); +})->with([false, true]); + +test('completion observer failures leave a successful install intact', function (): void { + $source = writeExtension('eventful'); + Exceptions::fake(); + Event::listen(ExtensionInstalled::class, static function (): void { + throw new RuntimeException('installation observer failed'); + }); + + $installed = $this->app->make(InstallsExtensions::class)->install($source); + + expect($installed->version)->toBe('1.0.0'); + expect($installed->directory)->toBeDirectory(); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0']); + Exceptions::assertReported(fn (RuntimeException $exception): bool => $exception->getMessage() === 'installation observer failed'); +}); + +test('state changes restart workers and notify observers only after commit', function (): void { + $source = writeExtension('eventful'); + $this->app->make(InstallsExtensions::class)->install($source); + Cache::forget('illuminate:queue:restart'); + Event::fake([ExtensionEnabled::class]); + $state = $this->app->make(SetsExtensionEnabled::class); + + DB::transaction(function () use ($state): void { + $state->setEnabled('eventful', true); + + expect(Cache::get('illuminate:queue:restart'))->toBeNull(); + Event::assertNotDispatched(ExtensionEnabled::class); + }); + + expect(Cache::get('illuminate:queue:restart'))->toBeInt(); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => true]); + Event::assertDispatchedTimes(ExtensionEnabled::class, 1); +}); + +test('rolled back state changes emit no completion notifications or restart signals', function (): void { + $source = writeExtension('eventful'); + $this->app->make(InstallsExtensions::class)->install($source); + Cache::forget('illuminate:queue:restart'); + Event::fake([ExtensionEnabled::class]); + $state = $this->app->make(SetsExtensionEnabled::class); + + expect(fn () => DB::transaction(function () use ($state): void { + $state->setEnabled('eventful', true); + + throw new RuntimeException('caller rolled back'); + }))->toThrow(RuntimeException::class, 'caller rolled back'); + + expect(Cache::get('illuminate:queue:restart'))->toBeNull(); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => false]); + Event::assertNotDispatched(ExtensionEnabled::class); +}); + +test('provider recovery clears errors in one write and leaves healthy timestamps alone', function (): void { + $repository = $this->app->make(ExtensionRepository::class); + $installer = $this->app->make(InstallsExtensions::class); + $identifiers = []; + try { + for ($i = 0; $i < 10; $i++) { + $identifier = 'batch-plugin-'.$i; + $identifiers[] = $identifier; + $installer->install(writeExtension($identifier), enable: true); + } + + $timestamp = now()->subDay()->startOfSecond(); + Extension::query()->whereIn('identifier', $identifiers)->update(['error' => null, 'updated_at' => $timestamp]); + Extension::query()->whereIn('identifier', array_slice($identifiers, 0, 2))->update(['error' => 'previous failure']); + $enabled = $repository->enabled(); + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $this->app->make(ExtensionProviderLoader::class)->registerProviders($enabled); + $writes = array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'update')); + expect($writes)->toHaveCount(1); + } finally { + DB::disableQueryLog(); + } + + expect(Extension::query()->whereIn('identifier', $identifiers)->whereNotNull('error')->count())->toBe(0); + expect(Extension::query()->where('identifier', $identifiers[9])->firstOrFail()->updated_at->equalTo($timestamp))->toBeTrue(); + } finally { + Extension::query()->whereIn('identifier', $identifiers)->delete(); + } +}); + +test('extension settings batch reads preserve values and subsequent mutations', function (): void { + $settings = []; + for ($i = 0; $i < 10; $i++) { + $setting = new ExtensionSettings('batch-settings-'.$i); + $setting->set('visible', 'value-'.$i); + $settings[] = new ExtensionSettings('batch-settings-'.$i); + } + + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + ExtensionSettings::preload($settings); + foreach ($settings as $i => $setting) { + expect($setting->get('visible'))->toBe('value-'.$i); + expect($setting->get('missing', 'default'))->toBe('default'); + } + + expect(DB::getQueryLog())->toHaveCount(1); + } finally { + DB::disableQueryLog(); + foreach ($settings as $setting) { + $setting->forget('visible'); + } + } + + expect($settings[0]->get('visible', 'gone'))->toBe('gone'); +}); + +test('a replacement without its build preserves the installed package and asset URL', function (): void { + $source = writeExtension('eventful'); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '1.0.0', 'ui' => ['entry' => 'dist/client.js']], JSON_THROW_ON_ERROR)); + File::ensureDirectoryExists($source.'/dist/chunks'); + File::put($source.'/dist/client.js', 'export const version = 1;'); + File::put($source.'/dist/chunks/lazy.js', 'export const lazy = 1;'); + $installer = $this->app->make(InstallsExtensions::class); + $assets = $this->app->make(ExtensionAssetPublisher::class); + $original = $installer->install($source, enable: true); + $url = $assets->entryUrl($original); + $version = $assets->currentVersion('eventful'); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '2.0.0', 'ui' => ['entry' => 'dist/client.js']], JSON_THROW_ON_ERROR)); + File::deleteDirectory($source.'/dist'); + + expect(fn () => $installer->install($source))->toThrow(InvalidExtensionException::class, 'built file is missing'); + expect(File::get($this->installDirectory.'/eventful/dist/client.js'))->toContain('version = 1'); + expect($assets->entryUrl($original))->toBe($url); + expect($assets->publishedPath('eventful').'/'.$version.'/chunks/lazy.js')->toBeFile(); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0', 'enabled' => true]); +}); + +/** A built frontend package whose stylesheet is compiled with the given Tailwind prefix. */ +function writeStyled(string $identifier, ?string $prefix, string $built, string $version = '1.0.0'): string +{ + $source = writeExtension($identifier); + File::put($source.'/extension.json', json_encode(['id' => $identifier, 'name' => $identifier, 'version' => $version, 'ui' => array_filter(['entry' => 'dist/client.js', 'prefix' => $prefix])], JSON_THROW_ON_ERROR)); + File::ensureDirectoryExists($source.'/dist'); + File::put($source.'/dist/client.js', 'export const version = 1;'); + File::put($source.'/dist/index.css', "@layer utilities{.{$built}\\:flex{display:flex}}"); + + return $source; +} + +test('a build without its declared tailwind prefix is neither installed nor enabled', function (): void { + $installer = $this->app->make(InstallsExtensions::class); + $assets = $this->app->make(ExtensionAssetPublisher::class); + $installer->install(writeStyled('eventful', 'ev', 'ev')); + $version = $assets->currentVersion('eventful'); + $source = writeStyled('eventful', 'ev', 'ev', '2.0.0'); + File::put($source.'/dist/index.css', '@layer utilities{.flex{display:flex}}'); + + expect(fn () => $installer->install($source))->toThrow(InvalidExtensionException::class, 'ships Tailwind utilities in dist/index.css (.flex) without its "ev" prefix'); + expect(fn () => $installer->install(writeStyled('eventful', 'ev', 'ext', '2.0.0')))->toThrow(InvalidExtensionException::class, 'ships Tailwind utilities in dist/index.css (.ext\:flex) without its "ev" prefix'); + expect(fn () => $installer->install(writeStyled('eventful', null, 'ev', '2.0.0')))->toThrow(InvalidExtensionException::class, 'declares no Tailwind prefix - add "prefix": "eventful" to "ui" in extension.json'); + expect(File::get($this->installDirectory.'/eventful/dist/index.css'))->toContain('.ev\:flex'); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0', 'enabled' => false]); + + // A package that reached the extensions directory another way is stopped when it is enabled. + Event::fake([ExtensionEnabling::class]); + File::put($this->installDirectory.'/eventful/dist/index.css', '@layer utilities{.flex{display:flex}}'); + expect(fn () => $this->app->make(SetsExtensionEnabled::class)->setEnabled('eventful', true))->toThrow(InvalidExtensionException::class, 'without its "ev" prefix'); + Event::assertNotDispatched(ExtensionEnabling::class); + expect($assets->currentVersion('eventful'))->toBe($version); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => false]); +}); + +test('two enabled extensions cannot build with the same tailwind prefix', function (): void { + $installer = $this->app->make(InstallsExtensions::class); + $enable = $this->app->make(SetsExtensionEnabled::class); + try { + $installer->install(writeStyled('prefix-owner', 'shared', 'shared'), enable: true); + + // Install with --enable, enable later and upgrade while enabled all go through the same comparison. + expect(fn () => $installer->install(writeStyled('eventful', 'shared', 'shared'), enable: true)) + ->toThrow(InvalidExtensionException::class, 'Extension "eventful" cannot use Tailwind prefix "shared": enabled extension "prefix-owner" also declares it.'); + $installer->install(writeStyled('eventful', 'shared', 'shared')); + Event::fake([ExtensionEnabling::class, ExtensionEnabled::class]); + expect(fn () => $enable->setEnabled('eventful', true)) + ->toThrow(InvalidExtensionException::class, 'Extension "eventful" cannot use Tailwind prefix "shared": enabled extension "prefix-owner" also declares it.'); + Event::assertNothingDispatched(); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => false]); + + $installer->install(writeStyled('eventful', 'ev', 'ev', '1.1.0'), enable: true); + expect(fn () => $installer->install(writeStyled('eventful', 'shared', 'shared', '2.0.0'))) + ->toThrow(InvalidExtensionException::class, 'cannot use Tailwind prefix "shared": enabled extension "prefix-owner" also declares it.'); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.1.0', 'enabled' => true]); + expect(File::get($this->installDirectory.'/eventful/dist/index.css'))->toContain('.ev\:flex'); + expect(collect($this->app->make(ExtensionRepository::class)->frontendPayload(false))->pluck('prefix', 'id')->all())->toBe(['eventful' => 'ev', 'prefix-owner' => 'shared']); + } finally { + Extension::query()->where('identifier', 'prefix-owner')->delete(); + } +}); + +test('successful upgrades preserve old chunks and point new sessions at new content', function (): void { + $source = writeExtension('eventful'); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '1.0.0', 'ui' => ['entry' => 'dist/client.js']], JSON_THROW_ON_ERROR)); + File::ensureDirectoryExists($source.'/dist/chunks'); + File::put($source.'/dist/client.js', 'export const version = 1;'); + File::put($source.'/dist/chunks/lazy.js', 'export const lazy = 1;'); + $installer = $this->app->make(InstallsExtensions::class); + $assets = $this->app->make(ExtensionAssetPublisher::class); + $original = $installer->install($source, enable: true); + $url = $assets->entryUrl($original); + $oldVersion = $assets->currentVersion('eventful'); + File::put($source.'/dist/client.js', 'export const version = 2;'); + $replacement = $installer->install($source); + + expect($assets->entryUrl($replacement))->not->toBe($url); + expect(File::get($assets->publishedPath('eventful').'/'.$oldVersion.'/chunks/lazy.js'))->toContain('lazy = 1'); + expect(File::get($assets->publishedPath('eventful').'/'.$assets->currentVersion('eventful').'/client.js'))->toContain('version = 2'); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => true]); +}); + +test('migration failure leaves a new extension inactive and restores an enabled upgrade', function (): void { + $source = writeExtension('eventful'); + $installer = $this->app->make(InstallsExtensions::class); + $installer->install($source, enable: true); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '2.0.0'], JSON_THROW_ON_ERROR)); + File::ensureDirectoryExists($source.'/database/migrations'); + Artisan::shouldReceive('call')->with('migrate', Mockery::type('array'))->twice()->andReturn(1); + + expect(fn () => $installer->install($source))->toThrow(InvalidExtensionException::class, 'migrations failed'); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0', 'enabled' => true]); + expect((new ExtensionManifestValidator)->fromDirectory($this->installDirectory.'/eventful')->version)->toBe('1.0.0'); + Extension::query()->where('identifier', 'eventful')->delete(); + File::deleteDirectory($this->installDirectory.'/eventful'); + $this->app->make(ExtensionRepository::class)->flushDiscovery(); + expect(fn () => $installer->install($source, enable: true))->toThrow(InvalidExtensionException::class, 'migrations failed'); + $this->assertDatabaseMissing('extensions', ['identifier' => 'eventful']); + expect($this->installDirectory.'/eventful')->not->toBeDirectory(); +}); + +test('completion observer failures do not undo committed upgrades', function (string $event): void { + $source = writeExtension('eventful'); + $installer = $this->app->make(InstallsExtensions::class); + $installer->install($source, enable: true); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '2.0.0'], JSON_THROW_ON_ERROR)); + Exceptions::fake(); + Event::listen($event, function (): never { + throw new RuntimeException('activation listener failed'); + }); + + $installed = $installer->install($source); + + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '2.0.0', 'enabled' => true]); + expect($this->app->make(ExtensionManifestValidator::class)->fromDirectory($installed->directory)->version)->toBe('2.0.0'); + Exceptions::assertReported(fn (RuntimeException $exception): bool => $exception->getMessage() === 'activation listener failed'); +})->with([ExtensionEnabled::class, ExtensionInstalled::class]); + +test('pre-activation observers can reject an upgrade without changing the installed package', function (string $event): void { + $source = writeExtension('eventful'); + $installer = $this->app->make(InstallsExtensions::class); + $installer->install($source, enable: true); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '2.0.0'], JSON_THROW_ON_ERROR)); + Event::listen($event, static function (): never { + throw new RuntimeException('upgrade rejected'); + }); + + expect(fn () => $installer->install($source))->toThrow(RuntimeException::class, 'upgrade rejected'); + + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0', 'enabled' => true]); + expect($this->app->make(ExtensionManifestValidator::class)->fromDirectory($this->installDirectory.'/eventful')->version)->toBe('1.0.0'); +})->with([ExtensionInstalling::class, ExtensionEnabling::class]); + +test('disabled packages can be installed before their dependencies and cannot be enabled early', function (): void { + $source = writeExtension('eventful'); + File::put($source.'/extension.json', json_encode(['id' => 'eventful', 'name' => 'Eventful', 'version' => '1.0.0', 'requires' => ['extensions' => ['missing-dependency' => '^1.0']]], JSON_THROW_ON_ERROR)); + $this->app->make(InstallsExtensions::class)->install($source); + + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0', 'enabled' => false]); + expect(fn () => $this->app->make(SetsExtensionEnabled::class)->setEnabled('eventful', true))->toThrow(InvalidExtensionException::class, 'requires enabled extension'); + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => false]); +}); + +/** @param list $components */ +function writePresentation(string $identifier, array $components, string $version = '1.0.0'): string +{ + $source = writeExtension($identifier); + File::put($source.'/extension.json', json_encode(['id' => $identifier, 'name' => $identifier, 'version' => $version, 'requires' => ['sdk' => '*'], 'ui' => ['entry' => 'dist/client.js', 'components' => $components]], JSON_THROW_ON_ERROR)); + File::ensureDirectoryExists($source.'/dist'); + File::put($source.'/dist/client.js', 'export default {setup() {}};'); + + return $source; +} + +test('rejects enabling a competing replacement before migrations or activation events', function (): void { + $installer = $this->app->make(InstallsExtensions::class); + try { + $installer->install(writePresentation('card-owner', ['dashboard.serverCard']), enable: true); + $installer->install(writePresentation('eventful', ['dashboard.serverCard'])); + File::ensureDirectoryExists($this->installDirectory.'/eventful/database/migrations'); + Event::fake([ExtensionEnabling::class, ExtensionEnabled::class]); + Artisan::shouldReceive('call')->never(); + + expect(fn () => $this->app->make(SetsExtensionEnabled::class)->setEnabled('eventful', true))->toThrow(InvalidExtensionException::class, 'card-owner'); + + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => false]); + $this->assertDatabaseHas('extensions', ['identifier' => 'card-owner', 'enabled' => true]); + Event::assertNothingDispatched(); + expect($this->app->make(ExtensionRepository::class)->frontendPayload(false)[0]['components'])->toBe(['dashboard.serverCard']); + } finally { + Extension::query()->where('identifier', 'card-owner')->delete(); + } +}); + +test('rejects an enabled upgrade with conflicting replacements and preserves its package', function (): void { + $installer = $this->app->make(InstallsExtensions::class); + try { + $installer->install(writePresentation('card-owner', ['dashboard.serverCard']), enable: true); + $installer->install(writeExtension('eventful'), enable: true); + $source = writePresentation('eventful', ['dashboard.serverCard'], '2.0.0'); + Event::fake([ExtensionInstalling::class, ExtensionEnabling::class]); + + expect(fn () => $installer->install($source))->toThrow(InvalidExtensionException::class, 'dashboard.serverCard'); + + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'version' => '1.0.0', 'enabled' => true]); + expect((new ExtensionManifestValidator)->fromDirectory($this->installDirectory.'/eventful')->components)->toBe([]); + Event::assertNothingDispatched(); + } finally { + Extension::query()->where('identifier', 'card-owner')->delete(); + } +}); + +test('failed removal restores the package and published assets with its metadata', function (): void { + $source = writeExtension('eventful'); + $this->app->make(InstallsExtensions::class)->install($source); + $assets = $this->app->make(ExtensionAssetPublisher::class)->publishedPath('eventful'); + File::ensureDirectoryExists($assets); + File::put($assets.'/client.js', 'original asset'); + $rejectDeletion = true; + DB::listen(static function (QueryExecuted $query) use (&$rejectDeletion): void { + if ($rejectDeletion && str_starts_with(mb_strtolower($query->sql), 'delete from `extensions`')) { + $rejectDeletion = false; + throw new RuntimeException('metadata removal failed'); + } + }); + + expect(fn () => $this->app->make(RemovesExtensions::class)->remove('eventful')) + ->toThrow(RuntimeException::class, 'metadata removal failed'); + + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful']); + expect($this->installDirectory.'/eventful/extension.json')->toBeFile(); + expect(File::get($assets.'/client.js'))->toBe('original asset'); + expect(glob($this->installDirectory.'/.previous-*'))->toBeEmpty(); +}); + +test('file editor and file browser replacements reach the frontend and stay exclusive per component', function (): void { + $installer = $this->app->make(InstallsExtensions::class); + try { + $installer->install(writePresentation('code-editor', ['server.files.editor']), enable: true); + $installer->install(writePresentation('tree-browser', ['server.files.manager']), enable: true); + $installer->install(writePresentation('eventful', ['server.files.details', 'server.files.editor'])); + + expect(fn () => $this->app->make(SetsExtensionEnabled::class)->setEnabled('eventful', true))->toThrow(InvalidExtensionException::class, 'code-editor'); + + $this->assertDatabaseHas('extensions', ['identifier' => 'eventful', 'enabled' => false]); + expect(collect($this->app->make(ExtensionRepository::class)->frontendPayload(false))->pluck('components', 'id')->all())->toBe([ + 'code-editor' => ['server.files.editor'], + 'tree-browser' => ['server.files.manager'], + ]); + } finally { + Extension::query()->whereIn('identifier', ['code-editor', 'tree-browser'])->delete(); + } +}); diff --git a/tests/Integration/Services/Extensions/ExtensionProviderLoaderTest.php b/tests/Integration/Services/Extensions/ExtensionProviderLoaderTest.php new file mode 100644 index 000000000..783c42db0 --- /dev/null +++ b/tests/Integration/Services/Extensions/ExtensionProviderLoaderTest.php @@ -0,0 +1,331 @@ +extensionDirectory = sys_get_temp_dir().'/ptero-registration-'.uniqid(); + File::ensureDirectoryExists($this->extensionDirectory); + config([ + 'extensions.enabled' => true, + 'extensions.directory' => $this->extensionDirectory, + 'extensions.assets_directory' => $this->extensionDirectory.'/assets', + 'extension-loader.failures' => [], + ]); + $this->app->forgetInstance(ExtensionRepository::class); + $this->app->forgetInstance(ExtensionProviderLoader::class); + $this->app->forgetInstance(ExtensionManager::class); +}); + +afterEach(function (): void { + File::deleteDirectory($this->extensionDirectory); +}); + +test('failed providers and their dependents expose no registrations while healthy extensions remain available', function (string $phase): void { + config(['extension-loader.failures.a-failed' => $phase]); + writeExtension('a-failed', routeFailure: $phase === 'route'); + writeExtension('b-dependent', ['a-failed' => '^1.0']); + writeExtension('c-transitive', ['b-dependent' => '^1.0']); + writeExtension('z-healthy'); + Event::fake([ExtensionLoadFailed::class, RegistrationOperationObserved::class]); + $repository = $this->app->make(ExtensionRepository::class); + + $this->app->make(ExtensionProviderLoader::class)->registerProviders($repository->enabled()); + Event::dispatch(new OperationCompleted('server', 'install', true, 'completed')); + + expect(array_column($repository->frontendPayload(false), 'id'))->toBe(['z-healthy']); + $repository->flushDiscovery(); + expect($repository->enabled()->keys()->all())->toBe(['z-healthy']); + foreach (['a-failed', 'b-dependent', 'c-transitive'] as $identifier) { + expect(Route::has('extensions.'.$identifier.'.client.status'))->toBeFalse(); + expect($this->app->make(ExtensionSettingsRegistry::class)->has($identifier))->toBeFalse(); + expect($this->app->make(ExtensionPermissionRegistry::class)->all())->not->toHaveKey('ext.'.$identifier); + $this->assertDatabaseHas('extensions', ['identifier' => $identifier, 'enabled' => true]); + } + + expect($this->app->make(ExtensionSettingsRegistry::class)->has('z-healthy'))->toBeTrue(); + expect($this->app->make(ExtensionPermissionRegistry::class)->all()['ext.z-healthy']['keys'])->toBe(['view' => 'View extension data.']); + $console = $this->app->make(ExtensionConsoleRegistry::class)->snapshot(); + expect($console['commands'])->toBe(['z-healthy' => [RegistrationProbeCommand::class]]); + expect(array_keys($console['schedules']))->toBe(['z-healthy']); + expect($this->app->make(ExtensionHeadTags::class)->toHtml())->toBe(''); + $action = $this->app->make(DeletesServers::class); + expect($action)->toBeInstanceOf(RegistrationProbeDeleter::class); + expect($action->owner)->toBe('z-healthy'); + expect($action->inner)->toBeInstanceOf(DeleteServer::class); + Event::assertDispatchedTimes(RegistrationOperationObserved::class, 1); + Event::assertDispatched(RegistrationOperationObserved::class, fn (RegistrationOperationObserved $event): bool => $event->identifier === 'z-healthy' && $event->resourceUuid === 'completed'); + Event::assertDispatched(ExtensionLoadFailed::class, fn (ExtensionLoadFailed $event): bool => $event->identifier === 'a-failed' && $event->phase === ($phase === 'register' ? 'register' : 'boot')); + $this->actingAs(User::factory()->create())->getJson('/api/client/extensions/z-healthy/status')->assertOk()->assertContent('ready'); +})->with(['register', 'boot', 'route']); + +test('failed activation restores existing routes and registry entries', function (): void { + writeExtension('a-failed', routeFailure: true); + Event::fake([ExtensionLoadFailed::class]); + $repository = $this->app->make(ExtensionRepository::class); + $definition = new ExtensionSettingsDefinition($repository->settings('a-failed'), []); + $settings = $this->app->make(ExtensionSettingsRegistry::class); + $permissions = $this->app->make(ExtensionPermissionRegistry::class); + $settings->register('a-failed', $definition); + $permissions->register('a-failed', 'Existing permissions.', ['previous' => 'Existing permission.']); + Route::get('/api/registration-preserved', RegistrationProbeController::class)->name('registration-preserved'); + Route::getRoutes()->refreshNameLookups(); + + $this->app->make(ExtensionProviderLoader::class)->registerProviders($repository->enabled()); + + expect($settings->get('a-failed'))->toBe($definition); + expect($permissions->all()['ext.a-failed'])->toBe(['description' => 'Existing permissions.', 'keys' => ['previous' => 'Existing permission.']]); + expect(Route::has('extensions.a-failed.client.status'))->toBeFalse(); + expect($this->app->make(ExtensionConsoleRegistry::class)->snapshot())->toBe(['commands' => [], 'schedules' => []]); + expect($this->app->make(ExtensionHeadTags::class)->toHtml())->toBe(''); + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(DeleteServer::class); + $this->getJson('/api/registration-preserved')->assertOk()->assertContent('ready'); +}); + +test('healthy registrations activate after boot and repeated loading does not duplicate listeners', function (): void { + writeExtension('healthy'); + Event::fake([RegistrationOperationObserved::class]); + $repository = $this->app->make(ExtensionRepository::class); + $loader = $this->app->make(ExtensionProviderLoader::class); + + $loader->registerProviders($repository->enabled()); + $loader->registerProviders($repository->enabled()); + Event::dispatch(new OperationCompleted('server', 'backup', true, 'completed')); + + Event::assertDispatchedTimes(RegistrationOperationObserved::class, 1); + Event::assertDispatched(RegistrationOperationObserved::class, fn (RegistrationOperationObserved $event): bool => $event->identifier === 'healthy' && $event->resourceUuid === 'completed'); + expect(array_column($repository->frontendPayload(false), 'id'))->toBe(['healthy']); + $this->actingAs(User::factory()->create())->getJson('/api/client/extensions/healthy/status')->assertOk()->assertContent('ready'); +}); + +test('cached extension routes return 404 when their provider fails or extensions are disabled', function (string $state): void { + $manifest = writeExtension('cached'); + (new RegistrationProbeProvider($this->app, $manifest))->routesForCache(); + $routes = new RouteCollection; + $route = Route::getRoutes()->getByName('extensions.cached.client.status'); + $routes->add($route); + Route::setCompiledRoutes($routes->compile()); + Event::fake([ExtensionLoadFailed::class, RegistrationOperationObserved::class]); + $repository = $this->app->make(ExtensionRepository::class); + if ($state === 'boot') { + config(['extension-loader.failures.cached' => 'boot']); + $this->app->make(ExtensionProviderLoader::class)->registerProviders($repository->enabled()); + } elseif ($state === 'disabled') { + Extension::query()->where('identifier', 'cached')->update(['enabled' => false]); + $repository->flushDiscovery(); + } else { + config(['extensions.enabled' => false]); + } + + $this->actingAs(User::factory()->create())->getJson('/api/client/extensions/cached/status')->assertNotFound(); +})->with(['boot', 'disabled', 'global']); + +test('healthy providers remain available when routes are compiled', function (): void { + $manifest = writeExtension('cached'); + (new RegistrationProbeProvider($this->app, $manifest))->routesForCache(); + $routes = new RouteCollection; + $routes->add(Route::getRoutes()->getByName('extensions.cached.client.status')); + Route::setCompiledRoutes($routes->compile()); + $repository = $this->app->make(ExtensionRepository::class); + + $this->app->make(ExtensionProviderLoader::class)->registerProviders($repository->enabled()); + + $this->actingAs(User::factory()->create())->getJson('/api/client/extensions/cached/status')->assertOk()->assertContent('ready'); + expect(array_column($repository->frontendPayload(false), 'id'))->toBe(['cached']); +}); + +test('wrappers, commands and head tags stop applying once their extension is disabled', function (): void { + writeExtension('healthy'); + $repository = $this->app->make(ExtensionRepository::class); + $this->app->make(ExtensionProviderLoader::class)->registerProviders($repository->enabled()); + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(RegistrationProbeDeleter::class); + expect($this->app->make(ExtensionHeadTags::class)->toHtml())->not->toBe(''); + + Extension::query()->where('identifier', 'healthy')->update(['enabled' => false]); + $repository->flushDiscovery(); + $headTags = $this->app->make(ExtensionHeadTags::class); + $headTags->restore($headTags->snapshot()); + + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(DeleteServer::class); + expect($headTags->toHtml())->toBe(''); + $schedule = new Schedule; + $this->app->make(ExtensionConsoleRegistry::class)->schedule($schedule); + expect($schedule->events())->toBe([]); +}); + +test('operation listener exceptions do not remove successfully loaded extensions', function (): void { + writeExtension('healthy'); + Event::fake([ExtensionLoadFailed::class]); + $repository = $this->app->make(ExtensionRepository::class); + $this->app->make(ExtensionProviderLoader::class)->registerProviders($repository->enabled()); + config(['extension-loader.failures.healthy' => 'event']); + + Event::dispatch(new OperationCompleted('server', 'backup', true, 'completed')); + + Event::assertDispatched(ExtensionLoadFailed::class, fn (ExtensionLoadFailed $event): bool => $event->identifier === 'healthy' && $event->phase === 'event'); + expect(array_column($repository->frontendPayload(false), 'id'))->toBe(['healthy']); +}); + +test('failure observer exceptions are reported and healthy providers still load', function (): void { + writeExtension('a-failed'); + writeExtension('z-healthy'); + config(['extension-loader.failures.a-failed' => 'boot']); + Exceptions::fake(); + Event::listen(ExtensionLoadFailed::class, static function (): void { + throw new RuntimeException('failure observer failed'); + }); + $repository = $this->app->make(ExtensionRepository::class); + + $this->app->make(ExtensionProviderLoader::class)->registerProviders($repository->enabled()); + + expect(array_column($repository->frontendPayload(false), 'id'))->toBe(['z-healthy']); + $this->assertDatabaseHas('extensions', ['identifier' => 'a-failed', 'error' => 'boot failed']); + Exceptions::assertReported(fn (RuntimeException $exception): bool => $exception->getMessage() === 'failure observer failed'); + $this->actingAs(User::factory()->create())->getJson('/api/client/extensions/z-healthy/status')->assertOk()->assertContent('ready'); +}); + +/** @param array $dependencies */ +function writeExtension(string $identifier, array $dependencies = [], bool $routeFailure = false): ExtensionManifest +{ + return (function () use ($identifier, $dependencies, $routeFailure): ExtensionManifest { + $directory = $this->extensionDirectory.'/'.$identifier; + File::ensureDirectoryExists($directory.'/routes'); + File::put($directory.'/extension.json', json_encode([ + 'id' => $identifier, + 'name' => $identifier, + 'version' => '1.0.0', + 'provider' => RegistrationProbeProvider::class, + 'requires' => ['extensions' => $dependencies], + 'ui' => ['entry' => 'dist/client.js'], + ], JSON_THROW_ON_ERROR)); + $source = <<<'PHP' + name('status'); + PHP; + if ($routeFailure) { + $source .= <<<'PHP' + + Route::prefix('unfinished')->group(function (): void { + Route::get('/leaked', RegistrationProbeController::class); + throw new \RuntimeException('route failed'); + }); + PHP; + } + + File::put($directory.'/routes/client.php', $source); + Extension::query()->create(['identifier' => $identifier, 'version' => '1.0.0', 'enabled' => true]); + + return $this->app->make(ExtensionManifestValidator::class)->fromDirectory($directory); + })->call(pterodactylTestCase()); +} + +final class RegistrationProbeProvider extends ExtensionProvider +{ + public function register(): void + { + $this->registerSettings(new ExtensionSettingsDefinition($this->settings(), [])); + $this->registerPermissions('Extension permissions.', ['view' => 'View extension data.']); + $this->wrapAction(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RegistrationProbeDeleter($inner, $this->id())); + $this->registerCommands([RegistrationProbeCommand::class]); + $this->registerSchedule(function (Schedule $schedule): void { + $schedule->call(fn (): null => null)->daily()->description('registration probe'); + }); + $this->registerHeadTags([['tag' => 'meta', 'name' => 'registration-probe-'.$this->id(), 'content' => 'ready']]); + $this->listenToServerOperations(function (OperationCompleted $event): void { + $this->failAt('event'); + Event::dispatch(new RegistrationOperationObserved($this->id(), $event->resourceUuid)); + }); + $this->failAt('register'); + } + + public function boot(): void + { + $this->registerApiRoutes(); + Event::dispatch(new OperationCompleted('server', 'install', true, 'during-boot')); + $this->failAt('boot'); + } + + public function routesForCache(): void + { + $this->registerApiRoutes(); + Route::getRoutes()->refreshNameLookups(); + } + + private function failAt(string $phase): void + { + throw_if(config('extension-loader.failures.'.$this->id()) === $phase, RuntimeException::class, $phase.' failed'); + } +} + +final class RegistrationProbeController +{ + public function __invoke(): Response + { + return new Response('ready'); + } +} + +final class RegistrationProbeDeleter implements DeletesServers +{ + public function __construct(public readonly DeletesServers $inner, public readonly string $owner) {} + + public function withForce(bool $bool = true): self + { + $this->inner->withForce($bool); + + return $this; + } + + public function delete(Server $server): void + { + $this->inner->delete($server); + } +} + +#[AsCommand(name: 'registration-probe:run')] +final class RegistrationProbeCommand extends Command {} + +final readonly class RegistrationOperationObserved +{ + public function __construct(public string $identifier, public string $resourceUuid) {} +} diff --git a/tests/Integration/Services/Extensions/ExtensionScopedSettingsTest.php b/tests/Integration/Services/Extensions/ExtensionScopedSettingsTest.php new file mode 100644 index 000000000..7acb871af --- /dev/null +++ b/tests/Integration/Services/Extensions/ExtensionScopedSettingsTest.php @@ -0,0 +1,79 @@ +create(); + $second = User::factory()->create(); + $server = $this->createServerModel(); + $global = new ExtensionSettings('scoped-probe'); + $userSettings = $global->forUser($first); + $otherUser = $global->forUser($second); + $serverSettings = $global->forServer($server); + $global->set('key', 'global'); + $userSettings->set('key', 'first'); + $otherUser->set('key', 'second'); + $serverSettings->set('key', 'server'); + $global->set('prefix.item', 'global-prefix'); + $userSettings->set('prefix.item', 'first-prefix'); + $fresh = [new ExtensionSettings('scoped-probe'), $global->forUser($first), $global->forUser($second), $global->forServer($server)]; + ExtensionSettings::preload($fresh); + + expect(array_map(fn (ExtensionSettings $settings) => $settings->get('key'), $fresh))->toBe(['global', 'first', 'second', 'server']); + expect($fresh[1]->getByPrefix('prefix.'))->toBe(['item' => 'first-prefix']); + $fresh[1]->forgetByPrefix('prefix.'); + expect($global->getByPrefix('prefix.'))->toBe(['item' => 'global-prefix']); + $first->delete(); + expect(ExtensionSetting::query()->where('user_id', $first->id)->exists())->toBeFalse(); + expect($otherUser->get('key'))->toBe('second'); +}); + +test('secret definitions encrypt storage mask responses preserve blank updates and cannot reach frontend config', function (): void { + $storage = new ExtensionSettings('secret-probe'); + $secret = ExtensionSettingDefinition::make('token', 'token', '', ['string'])->secret(); + $definition = new ExtensionSettingsDefinition($storage, [$secret, ExtensionSettingDefinition::make('label', 'label', 'name')->frontend()]); + $definition->update(['token' => 'private-token']); + $row = ExtensionSetting::query()->where('extension', 'secret-probe')->firstOrFail(); + + expect($row->is_secret)->toBeTrue(); + expect($row->value)->not->toContain('private-token'); + expect($row->toArray())->not->toHaveKey('value'); + expect((new ExtensionSettings('secret-probe'))->get('token'))->toBe('private-token'); + expect($definition->publicSettings()['token'])->toBe('********'); + expect($definition->schema()[0]['value'])->toBe('********'); + expect($definition->frontendConfig())->toBe(['label' => 'name']); + expect(fn () => $secret->frontend())->toThrow(InvalidArgumentException::class); + expect(fn () => ExtensionSettingDefinition::make('unsafe', 'unsafe', '')->frontend()->secret())->toThrow(InvalidArgumentException::class); + $definition->update(['token' => '']); + expect($definition->get('token'))->toBe('private-token'); + $row->update(['value' => json_encode('tampered', JSON_THROW_ON_ERROR)]); + expect(fn () => (new ExtensionSettings('secret-probe'))->get('token'))->toThrow(DecryptException::class); +}); + +test('secret values survive batch preload and scoped definitions', function (): void { + $user = User::factory()->create(); + $global = new ExtensionSettings('secret-scope'); + $definition = new ExtensionSettingsDefinition($global, [ExtensionSettingDefinition::make('token', 'token', null)->secret()]); + $definition->update(['token' => 'global-secret']); + $definition->forUser($user)->update(['token' => ['nested' => ['value' => 'user-secret']]]); + $settings = [new ExtensionSettings('secret-scope'), $global->forUser($user)]; + ExtensionSettings::preload($settings); + expect($settings[0]->get('token'))->toBe('global-secret'); + expect($settings[1]->get('token'))->toBe(['nested' => ['value' => 'user-secret']]); + expect($definition->forUser($user)->publicSettings()['token'])->toBe('********'); +}); diff --git a/tests/Integration/Services/Extensions/ServerOperationEventTest.php b/tests/Integration/Services/Extensions/ServerOperationEventTest.php new file mode 100644 index 000000000..cb5f0ed29 --- /dev/null +++ b/tests/Integration/Services/Extensions/ServerOperationEventTest.php @@ -0,0 +1,40 @@ +toBeEmpty(); + DB::rollBack(); + expect($events)->toBeEmpty(); + DB::beginTransaction(); + Event::dispatch(new OperationCompleted('server-uuid', 'backup', false, 'backup-uuid')); + expect($events)->toBeEmpty(); + DB::commit(); + expect($events)->toHaveCount(1); + expect($events[0]->serverUuid)->toBe('server-uuid'); + expect($events[0]->successful)->toBeFalse(); + expect($events[0]->resourceUuid)->toBe('backup-uuid'); + } finally { + while (DB::transactionLevel() > $depth) { + DB::rollBack(); + } + Event::forget(OperationCompleted::class); + } +}); diff --git a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php index 29c91f463..854121e97 100644 --- a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php +++ b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php @@ -1,159 +1,189 @@ [[true], [false]]); +test('schedule with no tasks returns exception', function (): void { + $server = $this->createServerModel(); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $this->expectException(DisplayException::class); + $this->expectExceptionMessage('Cannot process schedule for task execution: no tasks are registered.'); + getService()->process($schedule); +}); +test('error during schedule data update does not persist changes', function (): void { + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id, 'cron_minute' => 'hodor']); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); + try { + getService()->process($schedule); + $this->fail('Expected InvalidArgumentException to be thrown.'); + } catch (InvalidArgumentException) { + } + + $this->assertDatabaseHas('schedules', ['id' => $schedule->id, 'is_processing' => false]); + $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]); +}); +test('job can be dispatched with expected initial delay', function (bool $now): void { + Bus::fake(); + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]); + getService()->process($schedule, $now); + Bus::assertDispatched(RunTaskJob::class, function ($job) use ($now, $task): true { + expect($job)->toBeInstanceOf(RunTaskJob::class); + expect($job->task->id)->toBe($task->id); + // Jobs using dispatchNow should not have a delay associated with them. + expect($job->delay)->toBe($now ? null : 10); + + return true; + }); + $this->assertDatabaseHas('schedules', ['id' => $schedule->id, 'is_processing' => true]); + $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => true]); +})->with('dispatchNowDataProvider'); +test('first sequence task is found', function (): void { + Bus::fake(); + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + /** @var Task $task */ + $task2 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]); + $task3 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]); + getService()->process($schedule); + Bus::assertDispatched(RunTaskJob::class, fn (RunTaskJob $job): bool => $task->id === $job->task->id); + $this->assertDatabaseHas('schedules', ['id' => $schedule->id, 'is_processing' => true]); + $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => true]); + $this->assertDatabaseHas('tasks', ['id' => $task2->id, 'is_queued' => false]); + $this->assertDatabaseHas('tasks', ['id' => $task3->id, 'is_queued' => false]); +}); +test('task dispatched now is reset properly if error is encountered', function (string $failure): void { + $this->swap(Dispatcher::class, new ThrowingDispatcher(new $failure('Test thrown exception'))); + $server = $this->createServerModel(); + /** @var Schedule $schedule */ + $schedule = Schedule::factory()->create(['server_id' => $server->id, 'last_run_at' => null]); + /** @var Task $task */ + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); + try { + getService()->process($schedule, true); + $this->fail('Expected Exception to be thrown.'); + } catch (Throwable $throwable) { + expect($throwable->getMessage())->toBe('Test thrown exception'); + } + + $this->assertDatabaseHas('schedules', ['id' => $schedule->id, 'is_processing' => false, 'last_run_at' => CarbonImmutable::now()->toAtomString()]); + $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]); +})->with([Exception::class, TypeError::class]); +function getService(): ProcessesSchedules { - /** - * Test that a schedule with no tasks registered returns an error. - */ - public function testScheduleWithNoTasksReturnsException() - { - $server = $this->createServerModel(); - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - $this->expectException(DisplayException::class); - $this->expectExceptionMessage('Cannot process schedule for task execution: no tasks are registered.'); - - $this->getService()->handle($schedule); - } - - /** - * Test that an error during the schedule update is not persisted to the database. - */ - public function testErrorDuringScheduleDataUpdateDoesNotPersistChanges() - { - $server = $this->createServerModel(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create([ - 'server_id' => $server->id, - 'cron_minute' => 'hodor', // this will break the getNextRunDate() function. - ]); - - /** @var Task $task */ - $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); - - $this->expectException(\InvalidArgumentException::class); - - $this->getService()->handle($schedule); - - $this->assertDatabaseMissing('schedules', ['id' => $schedule->id, 'is_processing' => true]); - $this->assertDatabaseMissing('tasks', ['id' => $task->id, 'is_queued' => true]); - } - - /** - * Test that a job is dispatched as expected using the initial delay. - */ - #[\PHPUnit\Framework\Attributes\DataProvider('dispatchNowDataProvider')] - public function testJobCanBeDispatchedWithExpectedInitialDelay(bool $now) - { - Bus::fake(); - - $server = $this->createServerModel(); - - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - /** @var Task $task */ - $task = Task::factory()->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]); - - $this->getService()->handle($schedule, $now); - - Bus::assertDispatched(RunTaskJob::class, function ($job) use ($now, $task) { - $this->assertInstanceOf(RunTaskJob::class, $job); - $this->assertSame($task->id, $job->task->id); - // Jobs using dispatchNow should not have a delay associated with them. - $this->assertSame($now ? null : 10, $job->delay); - - return true; - }); - - $this->assertDatabaseHas('schedules', ['id' => $schedule->id, 'is_processing' => true]); - $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => true]); - } - - /** - * Test that even if a schedule's task sequence gets messed up the first task based on - * the ascending order of tasks is used. - * - * @see https://github.com/pterodactyl/panel/issues/2534 - */ - public function testFirstSequenceTaskIsFound() - { - Bus::fake(); - - $server = $this->createServerModel(); - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id]); - - /** @var Task $task */ - $task2 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]); - $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]); - $task3 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]); - - $this->getService()->handle($schedule); - - Bus::assertDispatched(RunTaskJob::class, function (RunTaskJob $job) use ($task) { - return $task->id === $job->task->id; - }); - - $this->assertDatabaseHas('schedules', ['id' => $schedule->id, 'is_processing' => true]); - $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => true]); - $this->assertDatabaseHas('tasks', ['id' => $task2->id, 'is_queued' => false]); - $this->assertDatabaseHas('tasks', ['id' => $task3->id, 'is_queued' => false]); - } - - /** - * Tests that a task's processing state is reset correctly if using "dispatchNow" and there is - * an exception encountered while running it. - * - * @see https://github.com/pterodactyl/panel/issues/2550 - */ - public function testTaskDispatchedNowIsResetProperlyIfErrorIsEncountered() - { - $this->swap(Dispatcher::class, $dispatcher = \Mockery::mock(Dispatcher::class)); - - $server = $this->createServerModel(); - /** @var Schedule $schedule */ - $schedule = Schedule::factory()->create(['server_id' => $server->id, 'last_run_at' => null]); - /** @var Task $task */ - $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); - - $dispatcher->expects('dispatchNow')->andThrows(new \Exception('Test thrown exception')); - - $this->expectException(\Exception::class); - $this->expectExceptionMessage('Test thrown exception'); - - $this->getService()->handle($schedule, true); - - $this->assertDatabaseHas('schedules', [ - 'id' => $schedule->id, - 'is_processing' => false, - 'last_run_at' => CarbonImmutable::now()->toAtomString(), - ]); - - $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]); - } - - public static function dispatchNowDataProvider(): array - { - return [[true], [false]]; - } - - private function getService(): ProcessScheduleService - { - return $this->app->make(ProcessScheduleService::class); - } + return (fn () => $this->app->make(ProcessesSchedules::class))->call(pterodactylTestCase()); } + +test('batch processing uses bounded reads while claiming schedules', function (): void { + $server = $this->createServerModel(); + $ids = []; + for ($i = 0; $i < 10; $i++) { + $schedule = Schedule::factory()->create(['server_id' => $server->id, 'only_when_online' => false]); + Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); + $ids[] = $schedule->id; + } + + Bus::fake([RunTaskJob::class]); + $schedules = Schedule::query()->whereKey($ids)->with('tasks')->get(); + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + foreach ($schedules as $schedule) { + getService()->process($schedule); + } + + $reads = array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select')); + expect(count($reads))->toBeLessThanOrEqual(20); + } finally { + DB::disableQueryLog(); + } + + Bus::assertDispatchedTimes(RunTaskJob::class, 10); +}); + +test('failed queue publication releases the schedule and preserves its retry time', function (): void { + $this->swap(Dispatcher::class, new ThrowingDispatcher(new Exception('Unused synchronous failure'))); + $schedule = Schedule::factory()->for($this->createServerModel())->create(['next_run_at' => now()->subMinute(), 'last_run_at' => now()->subHour()]); + $task = Task::factory()->for($schedule)->create(['sequence_id' => 1]); + $nextRun = $schedule->next_run_at; + $lastRun = $schedule->last_run_at; + + expect(fn () => getService()->process($schedule))->toThrow(LogicException::class, 'ThrowingDispatcher only supports dispatchNow().'); + + expect($schedule->refresh()->is_processing)->toBeFalse(); + expect($task->refresh()->is_queued)->toBeFalse(); + expect($schedule->next_run_at->equalTo($nextRun))->toBeTrue(); + expect($schedule->last_run_at->equalTo($lastRun))->toBeTrue(); +}); + +test('a stale schedule instance cannot claim an active run twice', function (): void { + Bus::fake([RunTaskJob::class]); + $schedule = Schedule::factory()->for($this->createServerModel())->create(); + Task::factory()->for($schedule)->create(['sequence_id' => 1]); + $stale = $schedule->fresh(); + + getService()->process($schedule); + + expect(fn () => getService()->process($stale))->toThrow(DisplayException::class, 'This schedule is already being processed.'); + Bus::assertDispatchedTimes(RunTaskJob::class, 1); +}); + +test('a schedule uses current task ordering instead of a previously loaded snapshot', function (): void { + Bus::fake([RunTaskJob::class]); + $schedule = Schedule::factory()->for($this->createServerModel())->create(); + $first = Task::factory()->for($schedule)->create(['sequence_id' => 1]); + $second = Task::factory()->for($schedule)->create(['sequence_id' => 2]); + $schedule->load('tasks'); + $first->update(['sequence_id' => 2]); + $second->update(['sequence_id' => 1]); + + getService()->process($schedule); + + Bus::assertDispatched(RunTaskJob::class, fn (RunTaskJob $job): bool => $job->task->is($second)); +}); + +test('a rolled back parent transaction never publishes the claimed schedule', function (): void { + Bus::fake([RunTaskJob::class]); + $schedule = Schedule::factory()->for($this->createServerModel())->create(); + $task = Task::factory()->for($schedule)->create(['sequence_id' => 1]); + + DB::beginTransaction(); + getService()->process($schedule); + Bus::assertNothingDispatched(); + DB::rollBack(); + + Bus::assertNothingDispatched(); + expect($schedule->refresh()->is_processing)->toBeFalse(); + expect($task->refresh()->is_queued)->toBeFalse(); +}); diff --git a/tests/Integration/Services/Servers/BuildModificationServiceTest.php b/tests/Integration/Services/Servers/BuildModificationServiceTest.php index 52d69685c..2cb88fe3b 100644 --- a/tests/Integration/Services/Servers/BuildModificationServiceTest.php +++ b/tests/Integration/Services/Servers/BuildModificationServiceTest.php @@ -1,254 +1,140 @@ daemonServerRepository = new FakeDaemonServer; +}); +test('allocations can be modified for the server', function () { + $server = $this->createServerModel(); + $server2 = $this->createServerModel(); + /** @var Allocation[] $allocations */ + $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']); + $initialAllocationId = $server->allocation_id; + $allocations[0]->update(['server_id' => $server->id, 'notes' => 'Test notes']); + // Some additional test allocations for the other server, not the server we are attempting + // to modify. + $allocations[2]->update(['server_id' => $server2->id]); + $allocations[3]->update(['server_id' => $server2->id]); + $response = getService()->update($server, [ + // Attempt to add one new allocation, and an allocation assigned to another server. The + // other server allocation should be ignored, and only the allocation for this server should + // be used. + 'add_allocations' => [$allocations[2]->id, $allocations[1]->id], + // Remove the default server allocation, ensuring that the new allocation passed through + // in the data becomes the default allocation. + 'remove_allocations' => [$server->allocation_id, $allocations[0]->id, $allocations[3]->id], + ]); + $this->daemonServerRepository->assertSynced(); + expect($response)->toBeInstanceOf(Server::class); + // Only one allocation should exist for this server now. + expect($response->allocations)->toHaveCount(1); + expect($response->allocation_id)->toBe($allocations[1]->id); + expect($response->allocation->notes)->toBeNull(); + // These two allocations should not have been touched. + $this->assertDatabaseHas('allocations', ['id' => $allocations[2]->id, 'server_id' => $server2->id]); + $this->assertDatabaseHas('allocations', ['id' => $allocations[3]->id, 'server_id' => $server2->id]); + // Both of these allocations should have been removed from the server, and have had their + // notes properly reset. + $this->assertDatabaseHas('allocations', ['id' => $initialAllocationId, 'server_id' => null, 'notes' => null]); + $this->assertDatabaseHas('allocations', ['id' => $allocations[0]->id, 'server_id' => null, 'notes' => null]); +}); +test('exception is thrown if removing the default allocation', function () { + $server = $this->createServerModel(); + /** @var Allocation[] $allocations */ + $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id]); + $allocations[0]->update(['server_id' => $server->id]); + $this->expectException(DisplayException::class); + $this->expectExceptionMessage('You are attempting to delete the default allocation for this server but there is no fallback allocation to use.'); + getService()->update($server, ['add_allocations' => [], 'remove_allocations' => [$server->allocation_id, $allocations[0]->id]]); +}); +test('server build data is properly updated on wings', function () { + $server = $this->createServerModel(); + $response = getService()->update($server, ['oom_disabled' => false, 'memory' => 256, 'swap' => 128, 'io' => 600, 'cpu' => 150, 'threads' => '1,2', 'disk' => 1024, 'backup_limit' => null, 'database_limit' => 10, 'allocation_limit' => 20]); + $this->daemonServerRepository->assertSynced(); + expect($response->oom_disabled)->toBeFalse(); + expect($response->memory)->toBe(256); + expect($response->swap)->toBe(128); + expect($response->io)->toBe(600); + expect($response->cpu)->toBe(150); + expect($response->threads)->toBe('1,2'); + expect($response->disk)->toBe(1024); + expect($response->backup_limit)->toBe(0); + expect($response->database_limit)->toBe(10); + expect($response->allocation_limit)->toBe(20); +}); +test('connection exception is ignored when updating server settings', function () { + $server = $this->createServerModel(); + $this->daemonServerRepository->throwable = new DaemonConnectionException(Http::failedRequest([], 200)); + $response = getService()->update($server, ['memory' => 256, 'disk' => 10240]); + $this->daemonServerRepository->assertSynced(); + expect($response)->toBeInstanceOf(Server::class); + expect($response->memory)->toBe(256); + expect($response->disk)->toBe(10240); + $this->assertDatabaseHas('servers', ['id' => $response->id, 'memory' => 256, 'disk' => 10240]); +}); +test('no exception is thrown if only removing allocation', function () { + $server = $this->createServerModel(); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); + getService()->update($server, ['remove_allocations' => [$allocation->id]]); + $this->daemonServerRepository->assertSynced(); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null]); +}); +test('allocation in both add and remove is added', function () { + $server = $this->createServerModel(); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id]); + getService()->update($server, ['add_allocations' => [$allocation->id], 'remove_allocations' => [$allocation->id]]); + $this->daemonServerRepository->assertSynced(); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => $server->id]); +}); +test('using same allocation id multiple times does not error', function () { + $server = $this->createServerModel(); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); + /** @var Allocation $allocation2 */ + $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]); + getService()->update($server, ['add_allocations' => [$allocation2->id, $allocation2->id], 'remove_allocations' => [$allocation->id, $allocation->id]]); + $this->daemonServerRepository->assertSynced(); + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null]); + $this->assertDatabaseHas('allocations', ['id' => $allocation2->id, 'server_id' => $server->id]); +}); +test('post-commit sync failures propagate without rolling back committed changes', function () { + $server = $this->createServerModel(); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id]); + $this->daemonServerRepository->throwable = new DisplayException('Test'); + try { + getService()->update($server, ['add_allocations' => [$allocation->id]]); + $this->fail('Expected DisplayException to be thrown.'); + } catch (DisplayException) { + } + $this->daemonServerRepository->assertSynced(); + // The allocation attach commits before Wings is contacted, so it persists. + $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => $server->id]); +}); +function getService(): UpdatesServerBuild { - private MockInterface $daemonServerRepository; - - /** - * Setup tests. - */ - public function setUp(): void - { - parent::setUp(); - - $this->daemonServerRepository = $this->mock(DaemonServerRepository::class); - } - - /** - * Test that allocations can be added and removed from a server. Only the allocations on the - * current node and belonging to this server should be modified. - */ - public function testAllocationsCanBeModifiedForTheServer() - { - $server = $this->createServerModel(); - $server2 = $this->createServerModel(); - - /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']); - - $initialAllocationId = $server->allocation_id; - $allocations[0]->update(['server_id' => $server->id, 'notes' => 'Test notes']); - - // Some additional test allocations for the other server, not the server we are attempting - // to modify. - $allocations[2]->update(['server_id' => $server2->id]); - $allocations[3]->update(['server_id' => $server2->id]); - - $this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined(); - - $response = $this->getService()->handle($server, [ - // Attempt to add one new allocation, and an allocation assigned to another server. The - // other server allocation should be ignored, and only the allocation for this server should - // be used. - 'add_allocations' => [$allocations[2]->id, $allocations[1]->id], - // Remove the default server allocation, ensuring that the new allocation passed through - // in the data becomes the default allocation. - 'remove_allocations' => [$server->allocation_id, $allocations[0]->id, $allocations[3]->id], - ]); - - $this->assertInstanceOf(Server::class, $response); - - // Only one allocation should exist for this server now. - $this->assertCount(1, $response->allocations); - $this->assertSame($allocations[1]->id, $response->allocation_id); - $this->assertNull($response->allocation->notes); - - // These two allocations should not have been touched. - $this->assertDatabaseHas('allocations', ['id' => $allocations[2]->id, 'server_id' => $server2->id]); - $this->assertDatabaseHas('allocations', ['id' => $allocations[3]->id, 'server_id' => $server2->id]); - - // Both of these allocations should have been removed from the server, and have had their - // notes properly reset. - $this->assertDatabaseHas('allocations', ['id' => $initialAllocationId, 'server_id' => null, 'notes' => null]); - $this->assertDatabaseHas('allocations', ['id' => $allocations[0]->id, 'server_id' => null, 'notes' => null]); - } - - /** - * Test that an exception is thrown if removing the default allocation without also assigning - * new allocations to the server. - */ - public function testExceptionIsThrownIfRemovingTheDefaultAllocation() - { - $server = $this->createServerModel(); - /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id]); - - $allocations[0]->update(['server_id' => $server->id]); - - $this->expectException(DisplayException::class); - $this->expectExceptionMessage('You are attempting to delete the default allocation for this server but there is no fallback allocation to use.'); - - $this->getService()->handle($server, [ - 'add_allocations' => [], - 'remove_allocations' => [$server->allocation_id, $allocations[0]->id], - ]); - } - - /** - * Test that the build data for the server is properly passed along to the Wings instance so that - * the server data is updated in realtime. This test also ensures that only certain fields get updated - * for the server, and not just any arbitrary field. - */ - public function testServerBuildDataIsProperlyUpdatedOnWings() - { - $server = $this->createServerModel(); - - $this->daemonServerRepository->expects('setServer')->with(\Mockery::on(function (Server $s) use ($server) { - return $s->id === $server->id; - }))->andReturnSelf(); - - $this->daemonServerRepository->expects('sync')->withNoArgs()->andReturnUndefined(); - - $response = $this->getService()->handle($server, [ - 'oom_disabled' => false, - 'memory' => 256, - 'swap' => 128, - 'io' => 600, - 'cpu' => 150, - 'threads' => '1,2', - 'disk' => 1024, - 'backup_limit' => null, - 'database_limit' => 10, - 'allocation_limit' => 20, - ]); - - $this->assertFalse($response->oom_disabled); - $this->assertSame(256, $response->memory); - $this->assertSame(128, $response->swap); - $this->assertSame(600, $response->io); - $this->assertSame(150, $response->cpu); - $this->assertSame('1,2', $response->threads); - $this->assertSame(1024, $response->disk); - $this->assertSame(0, $response->backup_limit); - $this->assertSame(10, $response->database_limit); - $this->assertSame(20, $response->allocation_limit); - } - - /** - * Test that an exception when connecting to the Wings instance is properly ignored - * when making updates. This allows for a server to be modified even when the Wings - * node is offline. - */ - public function testConnectionExceptionIsIgnoredWhenUpdatingServerSettings() - { - $server = $this->createServerModel(); - - $this->daemonServerRepository->expects('setServer->sync')->andThrows( - new DaemonConnectionException( - new RequestException('Bad request', new Request('GET', '/test'), new Response()) - ) - ); - - $response = $this->getService()->handle($server, ['memory' => 256, 'disk' => 10240]); - - $this->assertInstanceOf(Server::class, $response); - $this->assertSame(256, $response->memory); - $this->assertSame(10240, $response->disk); - - $this->assertDatabaseHas('servers', ['id' => $response->id, 'memory' => 256, 'disk' => 10240]); - } - - /** - * Test that no exception is thrown if we are only removing an allocation. - */ - public function testNoExceptionIsThrownIfOnlyRemovingAllocation() - { - $server = $this->createServerModel(); - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); - - $this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined(); - - $this->getService()->handle($server, [ - 'remove_allocations' => [$allocation->id], - ]); - - $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null]); - } - - /** - * Test that allocations in both the add and remove arrays are only added, and not removed. - * This scenario wouldn't really happen in the UI, but it is possible to perform via the API, - * so we want to make sure that the logic being used doesn't break if the allocation exists - * in both arrays. - * - * We'll default to adding the allocation in this case. - */ - public function testAllocationInBothAddAndRemoveIsAdded() - { - $server = $this->createServerModel(); - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->create(['node_id' => $server->node_id]); - - $this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined(); - - $this->getService()->handle($server, [ - 'add_allocations' => [$allocation->id], - 'remove_allocations' => [$allocation->id], - ]); - - $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => $server->id]); - } - - /** - * Test that using the same allocation ID multiple times in the array does not cause an error. - */ - public function testUsingSameAllocationIdMultipleTimesDoesNotError() - { - $server = $this->createServerModel(); - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); - /** @var Allocation $allocation2 */ - $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]); - - $this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined(); - - $this->getService()->handle($server, [ - 'add_allocations' => [$allocation2->id, $allocation2->id], - 'remove_allocations' => [$allocation->id, $allocation->id], - ]); - - $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null]); - $this->assertDatabaseHas('allocations', ['id' => $allocation2->id, 'server_id' => $server->id]); - } - - /** - * Test that any changes we made to the server or allocations are rolled back if there is an - * exception while performing any action. This is different from the connection exception - * test which should properly ignore connection issues. We want any other type of exception - * to properly be thrown back to the caller. - */ - public function testThatUpdatesAreRolledBackIfExceptionIsEncountered() - { - $server = $this->createServerModel(); - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->create(['node_id' => $server->node_id]); - - $this->daemonServerRepository->expects('setServer->sync')->andThrows(new DisplayException('Test')); - - $this->expectException(DisplayException::class); - - $this->getService()->handle($server, ['add_allocations' => [$allocation->id]]); - - $this->assertDatabaseHas('allocations', ['id' => $allocation->id, 'server_id' => null]); - } - - private function getService(): BuildModificationService - { - return $this->app->make(BuildModificationService::class); - } + return (function () { + return $this->app->make(UpdatesServerBuild::class); + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Servers/ChangeServerEggTest.php b/tests/Integration/Services/Servers/ChangeServerEggTest.php new file mode 100644 index 000000000..58a7b5146 --- /dev/null +++ b/tests/Integration/Services/Servers/ChangeServerEggTest.php @@ -0,0 +1,146 @@ +cloneEggAndVariables($server->egg); + $egg->forceFill(['startup' => 'java -jar new.jar', 'docker_images' => ['Java 21' => 'ghcr.io/example/java:21', 'Java 17' => 'ghcr.io/example/java:17']])->save(); + + return $egg->refresh(); + })->call(pterodactylTestCase()); +} + +function store(Server $server, string $environment, string $value): void +{ + $variable = EggVariable::query()->where('egg_id', $server->egg_id)->where('env_variable', $environment)->firstOrFail(); + ServerVariable::query()->updateOrCreate(['server_id' => $server->id, 'variable_id' => $variable->id], ['variable_value' => $value]); +} + +function changer(): ChangesServerEgg +{ + return (fn (): ChangesServerEgg => $this->app->make(ChangesServerEgg::class))->call(pterodactylTestCase()); +} + +test('egg, startup command and docker image are reset to the new egg defaults', function () { + $server = $this->createServerModel(['startup' => 'custom startup', 'image' => 'custom/image']); + $egg = targetEgg($server); + store($server, 'BUNGEE_VERSION', '1234'); + store($server, 'SERVER_JARFILE', 'custom.jar'); + + $result = changer()->change($server, $egg); + + expect($result)->toBeInstanceOf(Server::class) + ->and($result->id)->toBe($server->id) + ->and($result->egg_id)->toBe($egg->id) + ->and($result->startup)->toBe('java -jar new.jar') + ->and($result->image)->toBe('ghcr.io/example/java:21') + ->and($result->isInstalled())->toBeTrue() + ->and(ServerVariable::query()->where('server_id', $server->id)->count())->toBe(0); + expect($result->variables)->toHaveCount(2); + foreach ($result->variables as $variable) { + expect($variable->server_value)->toBeNull(); + } +}); + +test('matching variable values are carried over when requested', function () { + $server = $this->createServerModel(); + $egg = targetEgg($server); + store($server, 'BUNGEE_VERSION', '1234'); + store($server, 'SERVER_JARFILE', 'custom.jar'); + + $result = changer()->change($server, $egg, keepVariables: true); + + $values = $result->variables->pluck('server_value', 'env_variable')->all(); + expect($values)->toEqual(['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'custom.jar']); + // The values now belong to the new egg's variables, not the previous egg's. + expect(ServerVariable::query()->where('server_id', $server->id)->pluck('variable_id')->sort()->values()->all()) + ->toBe($egg->variables()->pluck('id')->sort()->values()->all()); +}); + +test('carried values must satisfy the new variable rules and exist on the new egg', function () { + $server = $this->createServerModel(); + $egg = targetEgg($server); + store($server, 'BUNGEE_VERSION', '1234'); + store($server, 'SERVER_JARFILE', 'custom.jar'); + $egg->variables()->where('env_variable', 'BUNGEE_VERSION')->update(['rules' => 'required|string|in:latest']); + $egg->variables()->where('env_variable', 'SERVER_JARFILE')->update(['env_variable' => 'JARFILE']); + + $result = changer()->change($server, $egg, keepVariables: true); + + expect(ServerVariable::query()->where('server_id', $server->id)->count())->toBe(0); + expect($result->variables->pluck('server_value', 'env_variable')->all())->toEqual(['BUNGEE_VERSION' => null, 'JARFILE' => null]); +}); + +test('current startup and image are kept when the new egg defines no defaults', function () { + $server = $this->createServerModel(['startup' => 'custom startup', 'image' => 'custom/image']); + $egg = targetEgg($server); + $egg->forceFill(['startup' => null, 'docker_images' => []])->save(); + + $result = changer()->change($server, $egg->refresh()); + + expect($result->egg_id)->toBe($egg->id) + ->and($result->startup)->toBe('custom startup') + ->and($result->image)->toBe('custom/image'); +}); + +test('changing to the current egg restores its defaults', function () { + $server = $this->createServerModel(['startup' => 'custom startup']); + store($server, 'BUNGEE_VERSION', '1234'); + + $kept = changer()->change($server, $server->egg, keepVariables: true); + expect($kept->startup)->toBe($server->egg->startup) + ->and($kept->variables->firstWhere('env_variable', 'BUNGEE_VERSION')->server_value)->toBe('1234'); + + $reset = changer()->change($kept, $server->egg); + expect($reset->variables->firstWhere('env_variable', 'BUNGEE_VERSION')->server_value)->toBeNull(); +}); + +test('other servers keep their variable values', function () { + $server = $this->createServerModel(); + $other = $this->createServerModel(); + store($other, 'BUNGEE_VERSION', '5678'); + + changer()->change($server, targetEgg($server)); + + expect(ServerVariable::query()->where('server_id', $other->id)->value('variable_value'))->toBe('5678'); +}); + +test('a failed change leaves the server untouched', function () { + $server = $this->createServerModel(['startup' => 'custom startup']); + store($server, 'BUNGEE_VERSION', '1234'); + // An egg that was deleted after it was loaded: the stored values are already + // gone by the time the server row is rejected by its foreign key. + $egg = targetEgg($server); + $original = $server->egg_id; + DB::table('egg_variables')->where('egg_id', $egg->id)->delete(); + DB::table('eggs')->where('id', $egg->id)->delete(); + + expect(fn () => changer()->change($server, $egg))->toThrow(QueryException::class); + + $fresh = Server::query()->findOrFail($server->id); + expect($fresh->egg_id)->toBe($original) + ->and($fresh->startup)->toBe('custom startup') + ->and(DB::table('server_variables')->where('server_id', $server->id)->value('variable_value'))->toBe('1234'); +}); diff --git a/tests/Integration/Services/Servers/ServerCreationServiceTest.php b/tests/Integration/Services/Servers/ServerCreationServiceTest.php index e840bb30d..fe1522c03 100644 --- a/tests/Integration/Services/Servers/ServerCreationServiceTest.php +++ b/tests/Integration/Services/Servers/ServerCreationServiceTest.php @@ -1,214 +1,115 @@ bungeecord = Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail(); + $this->daemonServerRepository = new FakeDaemonServer; +}); +test('server is created with deployment object', function () { + /** @var User $user */ + $user = User::factory()->create(); + /** @var Location $location */ + $location = Location::factory()->create(); + /** @var Node $node */ + $node = Node::factory()->create(['location_id' => $location->id]); + /** @var Allocation[]|Collection $allocations */ + $allocations = Allocation::factory()->times(5)->create(['node_id' => $node->id]); + $deployment = (new DeploymentObject())->setDedicated(true)->setLocations([$node->location_id])->setPorts([$allocations[0]->port]); + $egg = $this->cloneEggAndVariables($this->bungeecord); + // We want to make sure that the validator service runs as an admin, and not as a regular + // user when saving variables. + $egg->variables()->first()->update(['user_editable' => false]); + $data = ['name' => $this->faker->name, 'description' => $this->faker->sentence, 'owner_id' => $user->id, 'memory' => 256, 'swap' => 128, 'disk' => 100, 'io' => 500, 'cpu' => 0, 'startup' => 'java server2.jar', 'image' => 'java:8', 'egg_id' => $egg->id, 'allocation_additional' => [$allocations[4]->id], 'environment' => ['BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server2.jar'], 'start_on_completion' => true]; + try { + getService()->create(array_merge($data, ['environment' => ['BUNGEE_VERSION' => '', 'SERVER_JARFILE' => 'server2.jar']]), $deployment); + $this->fail('This execution pathway should not be reached.'); + } catch (ValidationException $exception) { + expect($exception->errors())->toHaveCount(1); + expect($exception->errors())->toHaveKey('environment.BUNGEE_VERSION'); + expect($exception->errors()['environment.BUNGEE_VERSION'][0])->toBe('The Bungeecord Version variable field is required.'); + } + $response = getService()->create($data, $deployment); + $this->daemonServerRepository->assertCreatedWith(true); + Event::assertDispatched(OperationCompleted::class, fn (OperationCompleted $event): bool => $event->serverUuid === $response->uuid && $event->operation === 'provision' && $event->successful); + expect($response)->toBeInstanceOf(Server::class); + expect($response->uuid)->not->toBeNull(); + expect(mb_substr($response->uuid, 0, 8))->toBe($response->uuidShort); + expect($response->egg_id)->toBe($egg->id); + expect($response->variables)->toHaveCount(2); + expect($response->variables[0]->server_value)->toBe('123'); + expect($response->variables[1]->server_value)->toBe('server2.jar'); + foreach ($data as $key => $value) { + if (in_array($key, ['allocation_additional', 'environment', 'start_on_completion'])) { + continue; + } + expect($response->{$key})->toBe($value, "Failed asserting equality of '{$key}' in server response. Got: [{$response->{$key}}] Expected: [{$value}]"); + } + expect($response->allocations)->toHaveCount(2); + expect($response->allocations[0]->id)->toBe($response->allocation_id); + expect($response->allocations[0]->id)->toBe($allocations[0]->id); + expect($response->allocations[1]->id)->toBe($allocations[4]->id); + expect($response->isSuspended())->toBeFalse(); + expect($response->oom_disabled)->toBeTrue(); + expect($response->database_limit)->toBe(0); + expect($response->allocation_limit)->toBe(0); + expect($response->backup_limit)->toBe(0); +}); +test('error encountered by wings causes server to be deleted', function () { + /** @var User $user */ + $user = User::factory()->create(); + /** @var Location $location */ + $location = Location::factory()->create(); + /** @var Node $node */ + $node = Node::factory()->create(['location_id' => $location->id]); + /** @var Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $node->id]); + $data = ['name' => $this->faker->name, 'description' => $this->faker->sentence, 'owner_id' => $user->id, 'allocation_id' => $allocation->id, 'node_id' => $allocation->node_id, 'memory' => 256, 'swap' => 128, 'disk' => 100, 'io' => 500, 'cpu' => 0, 'startup' => 'java server2.jar', 'image' => 'java:8', 'egg_id' => $this->bungeecord->id, 'environment' => ['BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server2.jar']]; + $this->daemonServerRepository->throwable = new DaemonConnectionException(Http::failedRequest([], 500)); + try { + getService()->create($data); + $this->fail('Expected DaemonConnectionException to be thrown.'); + } catch (DaemonConnectionException) { + } + $this->daemonServerRepository->assertCreated(); + $this->daemonServerRepository->assertDeleted(); + Event::assertNotDispatched(OperationCompleted::class, fn (OperationCompleted $event): bool => $event->operation === 'provision'); + Event::assertDispatched(OperationCompleted::class, fn (OperationCompleted $event): bool => $event->operation === 'delete' && $event->successful); + $this->assertDatabaseMissing('servers', ['owner_id' => $user->id]); +}); +function getService(): CreatesServers { - use WithFaker; - - protected MockInterface $daemonServerRepository; - - protected Egg $bungeecord; - - /** - * Stub the calls to Wings so that we don't actually hit those API endpoints. - */ - public function setUp(): void - { - parent::setUp(); - - /* @noinspection PhpFieldAssignmentTypeMismatchInspection */ - $this->bungeecord = Egg::query() - ->where('author', 'support@pterodactyl.io') - ->where('name', 'Bungeecord') - ->firstOrFail(); - - $this->daemonServerRepository = \Mockery::mock(DaemonServerRepository::class); - $this->swap(DaemonServerRepository::class, $this->daemonServerRepository); - } - - /** - * Test that a server can be created when a deployment object is provided to the service. - * - * This doesn't really do anything super complicated, we'll rely on other more specific - * tests to cover that the logic being used does indeed find suitable nodes and ports. For - * this test we just care that it is recognized and passed off to those functions. - */ - public function testServerIsCreatedWithDeploymentObject() - { - /** @var User $user */ - $user = User::factory()->create(); - - /** @var Location $location */ - $location = Location::factory()->create(); - - /** @var Node $node */ - $node = Node::factory()->create([ - 'location_id' => $location->id, - ]); - - /** @var \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations */ - $allocations = Allocation::factory()->times(5)->create([ - 'node_id' => $node->id, - ]); - - $deployment = (new DeploymentObject())->setDedicated(true)->setLocations([$node->location_id])->setPorts([ - $allocations[0]->port, - ]); - - $egg = $this->cloneEggAndVariables($this->bungeecord); - // We want to make sure that the validator service runs as an admin, and not as a regular - // user when saving variables. - $egg->variables()->first()->update([ - 'user_editable' => false, - ]); - - $data = [ - 'name' => $this->faker->name, - 'description' => $this->faker->sentence, - 'owner_id' => $user->id, - 'memory' => 256, - 'swap' => 128, - 'disk' => 100, - 'io' => 500, - 'cpu' => 0, - 'startup' => 'java server2.jar', - 'image' => 'java:8', - 'egg_id' => $egg->id, - 'allocation_additional' => [ - $allocations[4]->id, - ], - 'environment' => [ - 'BUNGEE_VERSION' => '123', - 'SERVER_JARFILE' => 'server2.jar', - ], - 'start_on_completion' => true, - ]; - - $this->daemonServerRepository->expects('setServer->create')->with(true)->andReturnUndefined(); - - try { - $this->getService()->handle(array_merge($data, [ - 'environment' => [ - 'BUNGEE_VERSION' => '', - 'SERVER_JARFILE' => 'server2.jar', - ], - ]), $deployment); - - $this->fail('This execution pathway should not be reached.'); - } catch (ValidationException $exception) { - $this->assertCount(1, $exception->errors()); - $this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors()); - $this->assertSame('The Bungeecord Version variable field is required.', $exception->errors()['environment.BUNGEE_VERSION'][0]); - } - - $response = $this->getService()->handle($data, $deployment); - - $this->assertInstanceOf(Server::class, $response); - $this->assertNotNull($response->uuid); - $this->assertSame($response->uuidShort, substr($response->uuid, 0, 8)); - $this->assertSame($egg->id, $response->egg_id); - $this->assertCount(2, $response->variables); - $this->assertSame('123', $response->variables[0]->server_value); - $this->assertSame('server2.jar', $response->variables[1]->server_value); - - foreach ($data as $key => $value) { - if (in_array($key, ['allocation_additional', 'environment', 'start_on_completion'])) { - continue; - } - - $this->assertSame($value, $response->{$key}, "Failed asserting equality of '$key' in server response. Got: [{$response->{$key}}] Expected: [$value]"); - } - - $this->assertCount(2, $response->allocations); - $this->assertSame($response->allocation_id, $response->allocations[0]->id); - $this->assertSame($allocations[0]->id, $response->allocations[0]->id); - $this->assertSame($allocations[4]->id, $response->allocations[1]->id); - - $this->assertFalse($response->isSuspended()); - $this->assertTrue($response->oom_disabled); - $this->assertSame(0, $response->database_limit); - $this->assertSame(0, $response->allocation_limit); - $this->assertSame(0, $response->backup_limit); - } - - /** - * Test that a server is deleted from the Panel if Wings returns an error during the creation - * process. - */ - public function testErrorEncounteredByWingsCausesServerToBeDeleted() - { - /** @var User $user */ - $user = User::factory()->create(); - - /** @var Location $location */ - $location = Location::factory()->create(); - - /** @var Node $node */ - $node = Node::factory()->create([ - 'location_id' => $location->id, - ]); - - /** @var Allocation $allocation */ - $allocation = Allocation::factory()->create([ - 'node_id' => $node->id, - ]); - - $data = [ - 'name' => $this->faker->name, - 'description' => $this->faker->sentence, - 'owner_id' => $user->id, - 'allocation_id' => $allocation->id, - 'node_id' => $allocation->node_id, - 'memory' => 256, - 'swap' => 128, - 'disk' => 100, - 'io' => 500, - 'cpu' => 0, - 'startup' => 'java server2.jar', - 'image' => 'java:8', - 'egg_id' => $this->bungeecord->id, - 'environment' => [ - 'BUNGEE_VERSION' => '123', - 'SERVER_JARFILE' => 'server2.jar', - ], - ]; - - $this->daemonServerRepository->expects('setServer->create')->andThrows( - new DaemonConnectionException( - new BadResponseException('Bad request', new Request('POST', '/create'), new Response(500)) - ) - ); - - $this->daemonServerRepository->expects('setServer->delete')->andReturnUndefined(); - - $this->expectException(DaemonConnectionException::class); - - $this->getService()->handle($data); - - $this->assertDatabaseMissing('servers', ['owner_id' => $user->id]); - } - - private function getService(): ServerCreationService - { - return $this->app->make(ServerCreationService::class); - } + return (function () { + return $this->app->make(CreatesServers::class); + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Servers/ServerDeletionServiceTest.php b/tests/Integration/Services/Servers/ServerDeletionServiceTest.php index 1a1446467..f3c21a1fd 100644 --- a/tests/Integration/Services/Servers/ServerDeletionServiceTest.php +++ b/tests/Integration/Services/Servers/ServerDeletionServiceTest.php @@ -1,160 +1,143 @@ defaultLogger = config('logging.default'); + // There will be some log calls during this test, don't actually write to the disk. + config()->set('logging.default', 'null'); + $this->daemonServerRepository = new FakeDaemonServer; + $this->app->instance(DatabaseHostGateway::class, $this->gateway = new FakeDatabaseHostGateway()); +}); +/** + * Reset the log driver. + */ +afterEach(function () { + config()->set('logging.default', $this->defaultLogger); + $this->defaultLogger = null; +}); +test('regular delete fails if wings returns error', function () { + $server = $this->createServerModel(); + $this->daemonServerRepository->throwable = new DaemonConnectionException(Http::failedRequest([], 200)); + try { + getService()->delete($server); + $this->fail('Expected DaemonConnectionException to be thrown.'); + } catch (DaemonConnectionException) { + } + $this->daemonServerRepository->assertDeleted(); + $this->assertDatabaseHas('servers', ['id' => $server->id]); +}); +test('regular delete ignores404 from wings', function () { + $server = $this->createServerModel(); + $this->daemonServerRepository->throwable = new DaemonConnectionException(Http::failedRequest([], 404)); + getService()->delete($server); + $this->daemonServerRepository->assertDeleted(); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); +}); +test('force delete ignores exception from wings', function () { + $server = $this->createServerModel(); + $this->daemonServerRepository->throwable = new DaemonConnectionException(Http::failedRequest([], 500)); + getService()->withForce()->delete($server); + $this->daemonServerRepository->assertDeleted(); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); +}); +test('exception while deleting stops process', function () { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + /** @var Database $db */ + $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]); + $server->refresh(); + $this->gateway->throwOn['dropDatabase'] = new Exception(); + try { + getService()->delete($server); + $this->fail('Expected Exception to be thrown.'); + } catch (Exception) { + } + $this->daemonServerRepository->assertDeleted(); + $this->assertDatabaseHas('servers', ['id' => $server->id]); + $this->assertDatabaseHas('databases', ['id' => $db->id]); +}); +test('exception while deleting databases does not abort if force deleted', function () { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(); + /** @var Database $db */ + $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]); + $server->refresh(); + $this->gateway->throwOn['dropDatabase'] = new Exception(); + getService()->withForce(true)->delete($server); + $this->daemonServerRepository->assertDeleted(); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); + $this->assertDatabaseMissing('databases', ['id' => $db->id]); +}); +function getService(): DeletesServers { - private MockInterface $daemonServerRepository; - - private MockInterface $databaseManagementService; - - private static ?string $defaultLogger; - - /** - * Stub out services that we don't want to test in here. - */ - public function setUp(): void - { - parent::setUp(); - - self::$defaultLogger = config('logging.default'); - // There will be some log calls during this test, don't actually write to the disk. - config()->set('logging.default', 'null'); - - $this->daemonServerRepository = \Mockery::mock(DaemonServerRepository::class); - $this->databaseManagementService = \Mockery::mock(DatabaseManagementService::class); - - $this->app->instance(DaemonServerRepository::class, $this->daemonServerRepository); - $this->app->instance(DatabaseManagementService::class, $this->databaseManagementService); - } - - /** - * Reset the log driver. - */ - protected function tearDown(): void - { - config()->set('logging.default', self::$defaultLogger); - self::$defaultLogger = null; - - parent::tearDown(); - } - - /** - * Test that a server is not deleted if the force option is not set and an error - * is returned by wings. - */ - public function testRegularDeleteFailsIfWingsReturnsError() - { - $server = $this->createServerModel(); - - $this->expectException(DaemonConnectionException::class); - - $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andThrows( - new DaemonConnectionException(new BadResponseException('Bad request', new Request('GET', '/test'), new Response())) - ); - - $this->getService()->handle($server); - - $this->assertDatabaseHas('servers', ['id' => $server->id]); - } - - /** - * Test that a 404 from Wings while deleting a server does not cause the deletion to fail. - */ - public function testRegularDeleteIgnores404FromWings() - { - $server = $this->createServerModel(); - - $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andThrows( - new DaemonConnectionException(new BadResponseException('Bad request', new Request('GET', '/test'), new Response(404))) - ); - - $this->getService()->handle($server); - - $this->assertDatabaseMissing('servers', ['id' => $server->id]); - } - - /** - * Test that an error from Wings does not cause the deletion to fail if the server is being - * force deleted. - */ - public function testForceDeleteIgnoresExceptionFromWings() - { - $server = $this->createServerModel(); - - $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andThrows( - new DaemonConnectionException(new BadResponseException('Bad request', new Request('GET', '/test'), new Response(500))) - ); - - $this->getService()->withForce()->handle($server); - - $this->assertDatabaseMissing('servers', ['id' => $server->id]); - } - - /** - * Test that a non-force-delete call does not delete the server if one of the databases - * cannot be deleted from the host. - */ - public function testExceptionWhileDeletingStopsProcess() - { - $server = $this->createServerModel(); - $host = DatabaseHost::factory()->create(); - - /** @var Database $db */ - $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]); - - $server->refresh(); - - $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined(); - $this->databaseManagementService->expects('delete')->with(\Mockery::on(function ($value) use ($db) { - return $value instanceof Database && $value->id === $db->id; - }))->andThrows(new \Exception()); - - $this->expectException(\Exception::class); - $this->getService()->handle($server); - - $this->assertDatabaseHas('servers', ['id' => $server->id]); - $this->assertDatabaseHas('databases', ['id' => $db->id]); - } - - /** - * Test that a server is deleted even if the server databases cannot be deleted from the host. - */ - public function testExceptionWhileDeletingDatabasesDoesNotAbortIfForceDeleted() - { - $server = $this->createServerModel(); - $host = DatabaseHost::factory()->create(); - - /** @var Database $db */ - $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]); - - $server->refresh(); - - $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined(); - $this->databaseManagementService->expects('delete')->with(\Mockery::on(function ($value) use ($db) { - return $value instanceof Database && $value->id === $db->id; - }))->andThrows(new \Exception()); - - $this->getService()->withForce(true)->handle($server); - - $this->assertDatabaseMissing('servers', ['id' => $server->id]); - $this->assertDatabaseMissing('databases', ['id' => $db->id]); - } - - private function getService(): ServerDeletionService - { - return $this->app->make(ServerDeletionService::class); - } + return (function () { + return $this->app->make(DeletesServers::class); + })->call(pterodactylTestCase()); } + +test('deleting a server reads database hosts once for all databases', function () { + $server = $this->createServerModel(); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + Database::factory()->count(10)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + /** @var FakeDatabaseHostGateway $gateway */ + $gateway = $this->gateway; + DB::flushQueryLog(); + DB::enableQueryLog(); + try { + $this->app->make(DeletesServers::class)->delete($server); + $reads = array_filter(DB::getQueryLog(), fn (array $query): bool => str_starts_with(mb_strtolower($query['query']), 'select') && str_contains($query['query'], 'from `database_hosts`')); + expect($reads)->toHaveCount(1); + } finally { + DB::disableQueryLog(); + } + expect($gateway->count('dropDatabase'))->toBe(10); + expect($gateway->count('dropUser'))->toBe(10); + expect($gateway->count('flush'))->toBe(10); + $this->daemonServerRepository->assertDeleted(); + $this->assertDatabaseMissing('servers', ['id' => $server->id]); + $this->assertDatabaseMissing('databases', ['server_id' => $server->id]); +}); + +test('a deleted server is reported to operation listeners by uuid only', function () { + Event::fake([OperationCompleted::class]); + $server = $this->createServerModel(); + $kept = $this->createServerModel(); + $this->daemonServerRepository->throwable = new DaemonConnectionException(Http::failedRequest([], 500)); + try { + getService()->delete($kept); + } catch (DaemonConnectionException) { + } + $this->daemonServerRepository->throwable = null; + + getService()->delete($server); + + Event::assertDispatchedTimes(OperationCompleted::class, 1); + Event::assertDispatched(OperationCompleted::class, fn (OperationCompleted $event): bool => $event->operation === 'delete' + && $event->successful + && $event->serverUuid === $server->uuid + && $event->resourceUuid === $server->uuid); +}); diff --git a/tests/Integration/Services/Servers/StartupModificationServiceTest.php b/tests/Integration/Services/Servers/StartupModificationServiceTest.php index 4f9ae90f0..5976e6f43 100644 --- a/tests/Integration/Services/Servers/StartupModificationServiceTest.php +++ b/tests/Integration/Services/Servers/StartupModificationServiceTest.php @@ -1,168 +1,111 @@ createServerModel(); + try { + $this->app->make(UpdatesServerStartup::class)->update($server, ['egg_id' => $server->egg_id + 1, 'environment' => ['BUNGEE_VERSION' => '$$', 'SERVER_JARFILE' => 'server.jar']]); + $this->fail('This assertion should not be called.'); + } catch (Exception $exception) { + expect($exception)->toBeInstanceOf(ValidationException::class); + /** @var ValidationException $exception */ + $errors = $exception->validator->errors()->toArray(); + expect($errors)->toHaveCount(1); + expect($errors)->toHaveKey('environment.BUNGEE_VERSION'); + expect($errors['environment.BUNGEE_VERSION'])->toHaveCount(1); + expect($errors['environment.BUNGEE_VERSION'][0])->toBe('The Bungeecord Version variable may only contain letters and numbers.'); + } + ServerVariable::query()->where('variable_id', $server->variables[1]->id)->delete(); + $result = getService()->update($server, ['egg_id' => $server->egg_id + 1, 'startup' => 'random gibberish', 'environment' => ['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'test.jar']]); + expect($result)->toBeInstanceOf(Server::class); + expect($result->variables)->toHaveCount(2); + expect($result->startup)->toBe($server->startup); + expect($result->variables[0]->server_value)->toBe('1234'); + expect($result->variables[1]->server_value)->toBe('test.jar'); +}); +test('server is properly modified as admin user', function () { + /** @var Egg $nextEgg */ + $nextEgg = Egg::query()->where('id', '!=', 1)->firstOrFail(); + $server = $this->createServerModel(['egg_id' => 1]); + $this->assertNotSame($nextEgg->id, $server->egg_id); + $response = getService()->update($server, ['egg_id' => $nextEgg->id, 'startup' => 'sample startup', 'skip_scripts' => true, 'docker_image' => 'docker/hodor'], User::USER_LEVEL_ADMIN); + expect($response)->toBeInstanceOf(Server::class); + expect($response->egg_id)->toBe($nextEgg->id); + expect($response->startup)->toBe('sample startup'); + expect($response->image)->toBe('docker/hodor'); + expect($response->skip_scripts)->toBeTrue(); + // Make sure we don't revert back to a lurking bug that causes servers to get marked + // as not installed when you modify the startup... + expect($response->isInstalled())->toBeTrue(); +}); +test('environment variables can be updated by admin', function () { + $server = $this->createServerModel(); + $server->loadMissing(['egg', 'variables']); + $clone = $this->cloneEggAndVariables($server->egg); + // This makes the BUNGEE_VERSION variable not user editable. + $clone->variables()->first()->update(['user_editable' => false]); + $server->fill(['egg_id' => $clone->id])->saveOrFail(); + $server->refresh(); + ServerVariable::query()->updateOrCreate(['server_id' => $server->id, 'variable_id' => $server->variables[0]->id], ['variable_value' => 'EXIST']); + $response = getService()->update($server, ['environment' => ['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'test.jar']]); + expect($response->variables)->toHaveCount(2); + expect($response->variables[0]->server_value)->toBe('EXIST'); + expect($response->variables[1]->server_value)->toBe('test.jar'); + $response = getService()->update($server, ['environment' => ['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'test.jar']], User::USER_LEVEL_ADMIN); + expect($response->variables)->toHaveCount(2); + expect($response->variables[0]->server_value)->toBe('1234'); + expect($response->variables[1]->server_value)->toBe('test.jar'); +}); +test('admin egg change keeps matching variables and falls back to the new egg defaults', function () { + $server = $this->createServerModel(['startup' => 'old startup', 'image' => 'old/image']); + $server->loadMissing('egg'); + $nextEgg = $this->cloneEggAndVariables($server->egg); + $nextEgg->forceFill(['startup' => 'new egg startup', 'docker_images' => ['Default' => 'new/image']])->save(); + $previous = $server->variables->pluck('id', 'env_variable'); + ServerVariable::query()->updateOrCreate(['server_id' => $server->id, 'variable_id' => $previous['BUNGEE_VERSION']], ['variable_value' => '1234']); + ServerVariable::query()->updateOrCreate(['server_id' => $server->id, 'variable_id' => $previous['SERVER_JARFILE']], ['variable_value' => 'old.jar']); + $response = getService()->update($server, ['egg_id' => $nextEgg->id, 'environment' => ['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'new.jar']], User::USER_LEVEL_ADMIN); + expect($response->egg_id)->toBe($nextEgg->id); + expect($response->startup)->toBe('new egg startup'); + expect($response->image)->toBe('new/image'); + expect($response->variables->pluck('server_value', 'env_variable')->all())->toEqual(['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'new.jar']); + // Values stored against the previous egg's variables do not linger. + expect(ServerVariable::query()->where('server_id', $server->id)->whereIn('variable_id', $previous->values())->count())->toBe(0); + expect(ServerVariable::query()->where('server_id', $server->id)->count())->toBe(2); +}); +test('non admin cannot move a server to another egg', function () { + $server = $this->createServerModel(); + $server->loadMissing('egg'); + $nextEgg = $this->cloneEggAndVariables($server->egg); + $response = getService()->update($server, ['egg_id' => $nextEgg->id, 'environment' => ['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'test.jar']]); + expect($response->egg_id)->toBe($server->egg_id); + expect($response->startup)->toBe($server->startup); +}); +test('invalid egg id triggers exception', function () { + $server = $this->createServerModel(); + $this->expectException(ModelNotFoundException::class); + getService()->update($server, ['egg_id' => 123456789], User::USER_LEVEL_ADMIN); +}); +function getService(): UpdatesServerStartup { - /** - * Test that a non-admin request to modify the server startup parameters does - * not perform any egg or nest updates. This also attempts to pass through an - * egg_id variable which should have no impact if the request is coming from - * a non-admin entity. - */ - public function testNonAdminCanModifyServerVariables() - { - $server = $this->createServerModel(); - - try { - $this->app->make(StartupModificationService::class)->handle($server, [ - 'egg_id' => $server->egg_id + 1, - 'environment' => [ - 'BUNGEE_VERSION' => '$$', - 'SERVER_JARFILE' => 'server.jar', - ], - ]); - - $this->fail('This assertion should not be called.'); - } catch (\Exception $exception) { - $this->assertInstanceOf(ValidationException::class, $exception); - - /** @var ValidationException $exception */ - $errors = $exception->validator->errors()->toArray(); - - $this->assertCount(1, $errors); - $this->assertArrayHasKey('environment.BUNGEE_VERSION', $errors); - $this->assertCount(1, $errors['environment.BUNGEE_VERSION']); - $this->assertSame('The Bungeecord Version variable may only contain letters and numbers.', $errors['environment.BUNGEE_VERSION'][0]); - } - - ServerVariable::query()->where('variable_id', $server->variables[1]->id)->delete(); - - $result = $this->getService() - ->handle($server, [ - 'egg_id' => $server->egg_id + 1, - 'startup' => 'random gibberish', - 'environment' => [ - 'BUNGEE_VERSION' => '1234', - 'SERVER_JARFILE' => 'test.jar', - ], - ]); - - $this->assertInstanceOf(Server::class, $result); - $this->assertCount(2, $result->variables); - $this->assertSame($server->startup, $result->startup); - $this->assertSame('1234', $result->variables[0]->server_value); - $this->assertSame('test.jar', $result->variables[1]->server_value); - } - - /** - * Test that modifying an egg as an admin properly updates the data for the server. - */ - public function testServerIsProperlyModifiedAsAdminUser() - { - /** @var \Pterodactyl\Models\Egg $nextEgg */ - $nextEgg = Nest::query()->findOrFail(2)->eggs()->firstOrFail(); - - $server = $this->createServerModel(['egg_id' => 1]); - - $this->assertNotSame($nextEgg->id, $server->egg_id); - $this->assertNotSame($nextEgg->nest_id, $server->nest_id); - - $response = $this->getService() - ->setUserLevel(User::USER_LEVEL_ADMIN) - ->handle($server, [ - 'egg_id' => $nextEgg->id, - 'startup' => 'sample startup', - 'skip_scripts' => true, - 'docker_image' => 'docker/hodor', - ]); - - $this->assertInstanceOf(Server::class, $response); - $this->assertSame($nextEgg->id, $response->egg_id); - $this->assertSame($nextEgg->nest_id, $response->nest_id); - $this->assertSame('sample startup', $response->startup); - $this->assertSame('docker/hodor', $response->image); - $this->assertTrue($response->skip_scripts); - // Make sure we don't revert back to a lurking bug that causes servers to get marked - // as not installed when you modify the startup... - $this->assertTrue($response->isInstalled()); - } - - /** - * Test that hidden variables can be updated by an admin but are not affected by a - * regular user who attempts to pass them through. - */ - public function testEnvironmentVariablesCanBeUpdatedByAdmin() - { - $server = $this->createServerModel(); - $server->loadMissing(['egg', 'variables']); - - $clone = $this->cloneEggAndVariables($server->egg); - // This makes the BUNGEE_VERSION variable not user editable. - $clone->variables()->first()->update([ - 'user_editable' => false, - ]); - - $server->fill(['egg_id' => $clone->id])->saveOrFail(); - $server->refresh(); - - ServerVariable::query()->updateOrCreate([ - 'server_id' => $server->id, - 'variable_id' => $server->variables[0]->id, - ], ['variable_value' => 'EXIST']); - - $response = $this->getService()->handle($server, [ - 'environment' => [ - 'BUNGEE_VERSION' => '1234', - 'SERVER_JARFILE' => 'test.jar', - ], - ]); - - $this->assertCount(2, $response->variables); - $this->assertSame('EXIST', $response->variables[0]->server_value); - $this->assertSame('test.jar', $response->variables[1]->server_value); - - $response = $this->getService() - ->setUserLevel(User::USER_LEVEL_ADMIN) - ->handle($server, [ - 'environment' => [ - 'BUNGEE_VERSION' => '1234', - 'SERVER_JARFILE' => 'test.jar', - ], - ]); - - $this->assertCount(2, $response->variables); - $this->assertSame('1234', $response->variables[0]->server_value); - $this->assertSame('test.jar', $response->variables[1]->server_value); - } - - /** - * Test that passing an invalid egg ID into the function throws an exception - * rather than silently failing or skipping. - */ - public function testInvalidEggIdTriggersException() - { - $server = $this->createServerModel(); - - $this->expectException(ModelNotFoundException::class); - - $this->getService() - ->setUserLevel(User::USER_LEVEL_ADMIN) - ->handle($server, ['egg_id' => 123456789]); - } - - private function getService(): StartupModificationService - { - return $this->app->make(StartupModificationService::class); - } + return (function () { + return $this->app->make(UpdatesServerStartup::class); + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Servers/SuspensionServiceTest.php b/tests/Integration/Services/Servers/SuspensionServiceTest.php index e3f925cf5..0e2d8831e 100644 --- a/tests/Integration/Services/Servers/SuspensionServiceTest.php +++ b/tests/Integration/Services/Servers/SuspensionServiceTest.php @@ -1,71 +1,83 @@ repository = new FakeDaemonServer; +}); +test('server is suspended and unsuspended', function () { + $server = $this->createServerModel(); + getService()->toggle($server); + expect($server->refresh()->isSuspended())->toBeTrue(); + getService()->toggle($server, TogglesServerSuspension::ACTION_UNSUSPEND); + expect($server->refresh()->isSuspended())->toBeFalse(); + $this->repository->assertSyncedTimes(2); +}); +test('no action is taken if suspension status is unchanged', function () { + $server = $this->createServerModel(); + getService()->toggle($server, TogglesServerSuspension::ACTION_UNSUSPEND); + $server->refresh(); + expect($server->isSuspended())->toBeFalse(); + $server->update(['status' => Server::STATUS_SUSPENDED]); + getService()->toggle($server); + $server->refresh(); + expect($server->isSuspended())->toBeTrue(); + $this->repository->assertNothingHappened(); +}); +test('exception is thrown if invalid actions are passed', function () { + $server = $this->createServerModel(); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Unsupported suspension action [foo].'); + getService()->toggle($server, 'foo'); +}); +function getService(): TogglesServerSuspension { - private MockInterface $repository; - - /** - * Setup test instance. - */ - public function setUp(): void - { - parent::setUp(); - - $this->repository = \Mockery::mock(DaemonServerRepository::class); - $this->app->instance(DaemonServerRepository::class, $this->repository); - } - - public function testServerIsSuspendedAndUnsuspended() - { - $server = $this->createServerModel(); - - $this->repository->expects('setServer->sync')->twice()->andReturnSelf(); - - $this->getService()->toggle($server); - - $this->assertTrue($server->refresh()->isSuspended()); - - $this->getService()->toggle($server, SuspensionService::ACTION_UNSUSPEND); - - $this->assertFalse($server->refresh()->isSuspended()); - } - - public function testNoActionIsTakenIfSuspensionStatusIsUnchanged() - { - $server = $this->createServerModel(); - - $this->getService()->toggle($server, SuspensionService::ACTION_UNSUSPEND); - - $server->refresh(); - $this->assertFalse($server->isSuspended()); - - $server->update(['status' => Server::STATUS_SUSPENDED]); - $this->getService()->toggle($server); - - $server->refresh(); - $this->assertTrue($server->isSuspended()); - } - - public function testExceptionIsThrownIfInvalidActionsArePassed() - { - $server = $this->createServerModel(); - - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Expected one of: "suspend", "unsuspend". Got: "foo"'); - - $this->getService()->toggle($server, 'foo'); - } - - private function getService(): SuspensionService - { - return $this->app->make(SuspensionService::class); - } + return (function () { + return $this->app->make(TogglesServerSuspension::class); + })->call(pterodactylTestCase()); } + +test('accepted suspension changes are reported to operation listeners', function () { + Event::fake([OperationCompleted::class]); + $server = $this->createServerModel(); + + getService()->toggle($server); + getService()->toggle($server); + getService()->toggle($server, TogglesServerSuspension::ACTION_UNSUSPEND); + + $operations = Event::dispatched(OperationCompleted::class)->map(fn (array $arguments): array => [$arguments[0]->operation, $arguments[0]->successful, $arguments[0]->serverUuid, $arguments[0]->resourceUuid]); + expect($operations->all())->toBe([ + ['suspend', true, $server->uuid, $server->uuid], + ['unsuspend', true, $server->uuid, $server->uuid], + ]); +}); + +test('a suspension Wings rejects is reverted and not reported', function () { + Event::fake([OperationCompleted::class]); + $server = $this->createServerModel(); + $this->repository->throwable = new DaemonConnectionException(Http::failedRequest([], 500)); + + expect(fn () => getService()->toggle($server))->toThrow(DaemonConnectionException::class); + + expect($server->refresh()->isSuspended())->toBeFalse(); + Event::assertNotDispatched(OperationCompleted::class); +}); diff --git a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php index 7f0e157fa..7d5d66755 100644 --- a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php +++ b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php @@ -1,142 +1,93 @@ egg = Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail(); +}); +test('environment variables can be validated', function () { + $egg = $this->cloneEggAndVariables($this->egg); + try { + getService()->handle($egg, ['BUNGEE_VERSION' => '1.2.3']); + $this->fail('This statement should not be reached.'); + } catch (ValidationException $exception) { + $errors = $exception->errors(); + expect($errors)->toHaveCount(2); + expect($errors)->toHaveKey('environment.BUNGEE_VERSION'); + expect($errors)->toHaveKey('environment.SERVER_JARFILE'); + expect($errors['environment.BUNGEE_VERSION'][0])->toBe('The Bungeecord Version variable may only contain letters and numbers.'); + expect($errors['environment.SERVER_JARFILE'][0])->toBe('The Bungeecord Jar File variable field is required.'); + } + $response = getService()->handle($egg, ['BUNGEE_VERSION' => '1234', 'SERVER_JARFILE' => 'server.jar']); + expect($response)->toBeInstanceOf(Collection::class); + expect($response)->toHaveCount(2); + expect($response->get(0)->key)->toBe('BUNGEE_VERSION'); + expect($response->get(0)->value)->toBe('1234'); + expect($response->get(1)->key)->toBe('SERVER_JARFILE'); + expect($response->get(1)->value)->toBe('server.jar'); +}); +test('normal user cannot validate non user editable variables', function () { + $egg = $this->cloneEggAndVariables($this->egg); + $egg->variables()->first()->update(['user_editable' => false]); + $response = getService()->handle($egg, [ + // This is an invalid value, but it shouldn't cause any issues since it should be skipped. + 'BUNGEE_VERSION' => '1.2.3', + 'SERVER_JARFILE' => 'server.jar', + ]); + expect($response)->toBeInstanceOf(Collection::class); + expect($response)->toHaveCount(1); + expect($response->get(0)->key)->toBe('SERVER_JARFILE'); + expect($response->get(0)->value)->toBe('server.jar'); +}); +test('environment variables can be updated as admin', function () { + $egg = $this->cloneEggAndVariables($this->egg); + $egg->variables()->first()->update(['user_editable' => false]); + try { + getService()->setUserLevel(User::USER_LEVEL_ADMIN)->handle($egg, ['BUNGEE_VERSION' => '1.2.3', 'SERVER_JARFILE' => 'server.jar']); + $this->fail('This statement should not be reached.'); + } catch (ValidationException $exception) { + expect($exception->errors())->toHaveCount(1); + expect($exception->errors())->toHaveKey('environment.BUNGEE_VERSION'); + } + $response = getService()->setUserLevel(User::USER_LEVEL_ADMIN)->handle($egg, ['BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server.jar']); + expect($response)->toBeInstanceOf(Collection::class); + expect($response)->toHaveCount(2); + expect($response->get(0)->key)->toBe('BUNGEE_VERSION'); + expect($response->get(0)->value)->toBe('123'); + expect($response->get(1)->key)->toBe('SERVER_JARFILE'); + expect($response->get(1)->value)->toBe('server.jar'); +}); +test('nullable environment variables can be used correctly', function () { + $egg = $this->cloneEggAndVariables($this->egg); + $egg->variables()->where('env_variable', '!=', 'BUNGEE_VERSION')->delete(); + $egg->variables()->update(['rules' => 'nullable|string']); + $response = getService()->handle($egg, []); + expect($response)->toHaveCount(1); + expect($response->get(0)->value)->toBeNull(); + $response = getService()->handle($egg, ['BUNGEE_VERSION' => null]); + expect($response)->toHaveCount(1); + expect($response->get(0)->value)->toBeNull(); + $response = getService()->handle($egg, ['BUNGEE_VERSION' => '']); + expect($response)->toHaveCount(1); + expect($response->get(0)->value)->toBe(''); +}); +function getService(): VariableValidatorService { - protected Egg $egg; - - public function setUp(): void - { - parent::setUp(); - - /* @noinspection PhpFieldAssignmentTypeMismatchInspection */ - $this->egg = Egg::query() - ->where('author', 'support@pterodactyl.io') - ->where('name', 'Bungeecord') - ->firstOrFail(); - } - - /** - * Test that environment variables for a server are validated as expected. - */ - public function testEnvironmentVariablesCanBeValidated() - { - $egg = $this->cloneEggAndVariables($this->egg); - - try { - $this->getService()->handle($egg->id, [ - 'BUNGEE_VERSION' => '1.2.3', - ]); - - $this->fail('This statement should not be reached.'); - } catch (ValidationException $exception) { - $errors = $exception->errors(); - - $this->assertCount(2, $errors); - $this->assertArrayHasKey('environment.BUNGEE_VERSION', $errors); - $this->assertArrayHasKey('environment.SERVER_JARFILE', $errors); - $this->assertSame('The Bungeecord Version variable may only contain letters and numbers.', $errors['environment.BUNGEE_VERSION'][0]); - $this->assertSame('The Bungeecord Jar File variable field is required.', $errors['environment.SERVER_JARFILE'][0]); - } - - $response = $this->getService()->handle($egg->id, [ - 'BUNGEE_VERSION' => '1234', - 'SERVER_JARFILE' => 'server.jar', - ]); - - $this->assertInstanceOf(Collection::class, $response); - $this->assertCount(2, $response); - $this->assertSame('BUNGEE_VERSION', $response->get(0)->key); - $this->assertSame('1234', $response->get(0)->value); - $this->assertSame('SERVER_JARFILE', $response->get(1)->key); - $this->assertSame('server.jar', $response->get(1)->value); - } - - /** - * Test that variables that are user_editable=false do not get validated (or returned) by - * the handler. - */ - public function testNormalUserCannotValidateNonUserEditableVariables() - { - $egg = $this->cloneEggAndVariables($this->egg); - $egg->variables()->first()->update([ - 'user_editable' => false, - ]); - - $response = $this->getService()->handle($egg->id, [ - // This is an invalid value, but it shouldn't cause any issues since it should be skipped. - 'BUNGEE_VERSION' => '1.2.3', - 'SERVER_JARFILE' => 'server.jar', - ]); - - $this->assertInstanceOf(Collection::class, $response); - $this->assertCount(1, $response); - $this->assertSame('SERVER_JARFILE', $response->get(0)->key); - $this->assertSame('server.jar', $response->get(0)->value); - } - - public function testEnvironmentVariablesCanBeUpdatedAsAdmin() - { - $egg = $this->cloneEggAndVariables($this->egg); - $egg->variables()->first()->update([ - 'user_editable' => false, - ]); - - try { - $this->getService()->setUserLevel(User::USER_LEVEL_ADMIN)->handle($egg->id, [ - 'BUNGEE_VERSION' => '1.2.3', - 'SERVER_JARFILE' => 'server.jar', - ]); - - $this->fail('This statement should not be reached.'); - } catch (ValidationException $exception) { - $this->assertCount(1, $exception->errors()); - $this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors()); - } - - $response = $this->getService()->setUserLevel(User::USER_LEVEL_ADMIN)->handle($egg->id, [ - 'BUNGEE_VERSION' => '123', - 'SERVER_JARFILE' => 'server.jar', - ]); - - $this->assertInstanceOf(Collection::class, $response); - $this->assertCount(2, $response); - $this->assertSame('BUNGEE_VERSION', $response->get(0)->key); - $this->assertSame('123', $response->get(0)->value); - $this->assertSame('SERVER_JARFILE', $response->get(1)->key); - $this->assertSame('server.jar', $response->get(1)->value); - } - - public function testNullableEnvironmentVariablesCanBeUsedCorrectly() - { - $egg = $this->cloneEggAndVariables($this->egg); - $egg->variables()->where('env_variable', '!=', 'BUNGEE_VERSION')->delete(); - - $egg->variables()->update(['rules' => 'nullable|string']); - - $response = $this->getService()->handle($egg->id, []); - $this->assertCount(1, $response); - $this->assertNull($response->get(0)->value); - - $response = $this->getService()->handle($egg->id, ['BUNGEE_VERSION' => null]); - $this->assertCount(1, $response); - $this->assertNull($response->get(0)->value); - - $response = $this->getService()->handle($egg->id, ['BUNGEE_VERSION' => '']); - $this->assertCount(1, $response); - $this->assertSame('', $response->get(0)->value); - } - - private function getService(): VariableValidatorService - { + return (function () { return $this->app->make(VariableValidatorService::class); - } + })->call(pterodactylTestCase()); } diff --git a/tests/Integration/Services/Users/CompleteLoginTest.php b/tests/Integration/Services/Users/CompleteLoginTest.php new file mode 100644 index 000000000..6b2d79fab --- /dev/null +++ b/tests/Integration/Services/Users/CompleteLoginTest.php @@ -0,0 +1,75 @@ +create(); + Session::put('auth_confirmation_token', LoginCheckpoint::issue($user->id)); + $result = $this->app->make(CompletesLogins::class)->complete($user); + expect($result->complete)->toBeTrue(); + expect($result->intended)->toBe('/'); + expect($result->toResponseData()['user']['uuid'])->toBe($user->uuid); + expect(Session::has('auth_confirmation_token'))->toBeFalse(); + expect($user->refresh()->remember_token)->not->toBeNull(); + $this->assertAuthenticatedAs($user); + Event::assertDispatched(fn (DirectLogin $event) => $event->user->is($user) && $event->remember); +}); +test('account with two factor receives a checkpoint instead of a session', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + $logins = $this->app->make(CompletesLogins::class); + $result = $logins->complete($user); + expect($result->complete)->toBeFalse(); + expect($result->confirmationToken)->toBeString()->toHaveLength(64); + $checkpoint = $logins->pendingCheckpoint(); + expect($checkpoint)->toBeInstanceOf(LoginCheckpoint::class); + expect($checkpoint->userId)->toBe($user->id); + expect($checkpoint->matches($result->confirmationToken))->toBeTrue(); + expect($checkpoint->expiresAt->equalTo(now()->addMinutes(5)))->toBeTrue(); + $this->assertGuest(); + $this->assertActivityFor('auth:checkpoint', null, $user); + Event::assertNotDispatched(DirectLogin::class); + $this->travel(5)->minutes(); + expect($logins->pendingCheckpoint())->not->toBeNull(); + $this->travel(1)->seconds(); + expect($logins->pendingCheckpoint())->toBeNull(); +}); +test('establishing a session discards the pending checkpoint', function () { + $user = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + $logins = $this->app->make(CompletesLogins::class); + $logins->complete($user); + $result = $logins->establish($user); + expect($result->complete)->toBeTrue(); + expect($logins->pendingCheckpoint())->toBeNull(); + $this->assertAuthenticatedAs($user); + Event::assertDispatched(DirectLogin::class); +}); +test('login can be completed from a web route outside the core controllers', function () { + $plain = User::factory()->create(); + $protected = User::factory()->create(['use_totp' => true, 'totp_secret' => encrypt(str_repeat('a', 16))]); + Route::middleware('web')->get('/api/_test/external-login/{user}', function (CompletesLogins $logins, User $user) { + $result = $logins->complete($user); + + return redirect($result->complete ? $result->intended : '/auth/login?checkpoint=1'); + }); + $this->get('/api/_test/external-login/'.$protected->uuid)->assertRedirect('/auth/login?checkpoint=1')->assertSessionHas('auth_confirmation_token'); + $this->assertGuest(); + $this->get('/api/_test/external-login/'.$plain->uuid)->assertRedirect('/')->assertSessionMissing('auth_confirmation_token'); + $this->assertAuthenticatedAs($plain); +}); diff --git a/tests/Integration/Services/Users/UserDeletionServiceTest.php b/tests/Integration/Services/Users/UserDeletionServiceTest.php index 06564eefa..48feba3f9 100644 --- a/tests/Integration/Services/Users/UserDeletionServiceTest.php +++ b/tests/Integration/Services/Users/UserDeletionServiceTest.php @@ -1,64 +1,44 @@ createServerModel(); - - $this->expectException(DisplayException::class); - $this->expectExceptionMessage(__('admin/user.exceptions.user_has_servers')); - - $this->app->make(UserDeletionService::class)->handle($server->user); - - $this->assertModelExists($server->user); - - Bus::assertNotDispatched(RevokeSftpAccessJob::class); - } - - public function testUserIsDeleted(): void - { - $user = User::factory()->create(); - - $this->app->make(UserDeletionService::class)->handle($user); - - $this->assertModelMissing($user); - - Bus::assertNotDispatched(RevokeSftpAccessJob::class); - } - - public function testUserIsDeletedAndAccessRevoked(): void - { - $user = User::factory()->create(); - - $server1 = $this->createServerModel(); - $server2 = $this->createServerModel(['node_id' => $server1->node_id]); - - Subuser::factory()->for($server1)->for($user)->create(); - Subuser::factory()->for($server2)->for($user)->create(); - - $this->app->make(UserDeletionService::class)->handle($user); - - $this->assertModelMissing($user); - - Bus::assertDispatchedTimes(RevokeSftpAccessJob::class); - Bus::assertDispatched(fn (RevokeSftpAccessJob $job) => $job->user === $user->uuid && $job->target->is($server1->node)); - } -} +uses(IntegrationTestCase::class, DatabaseTransactions::class); +beforeEach(function () { + Bus::fake([RevokeSftpAccessJob::class]); +}); +test('exception returned if user assigned to servers', function () { + $server = $this->createServerModel(); + $this->expectException(DisplayException::class); + $this->expectExceptionMessage(__('admin/user.exceptions.user_has_servers')); + $this->app->make(DeletesUsers::class)->delete($server->user); + $this->assertModelExists($server->user); + Bus::assertNotDispatched(RevokeSftpAccessJob::class); +}); +test('user is deleted', function () { + $user = User::factory()->create(); + $this->app->make(DeletesUsers::class)->delete($user); + $this->assertModelMissing($user); + Bus::assertNotDispatched(RevokeSftpAccessJob::class); +}); +test('user is deleted and access revoked', function () { + $user = User::factory()->create(); + $server1 = $this->createServerModel(); + $server2 = $this->createServerModel(['node_id' => $server1->node_id]); + Subuser::factory()->for($server1)->for($user)->create(); + Subuser::factory()->for($server2)->for($user)->create(); + $this->app->make(DeletesUsers::class)->delete($user); + $this->assertModelMissing($user); + Bus::assertDispatchedTimes(RevokeSftpAccessJob::class); + Bus::assertDispatched(fn (RevokeSftpAccessJob $job) => $job->user === $user->uuid && $job->target->is($server1->node)); +}); diff --git a/tests/Integration/TestResponse.php b/tests/Integration/TestResponse.php index a5a8609c8..fcb92fa77 100644 --- a/tests/Integration/TestResponse.php +++ b/tests/Integration/TestResponse.php @@ -1,12 +1,14 @@ getStatusCode(); @@ -23,7 +25,7 @@ class TestResponse extends IlluminateTestResponse // to fail so that debugging isn't such a nightmare. if ($actual !== $status && $status !== 500) { $this->dump(); - if (!is_null($this->exception) && !$this->exception instanceof DisplayException && !$this->exception instanceof ValidationException) { + if (! is_null($this->exception) && ! $this->exception instanceof DisplayException && ! $this->exception instanceof ValidationException) { dump([ 'exception_class' => get_class($this->exception), 'message' => $this->exception->getMessage(), diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 000000000..c546e2723 --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,17 @@ +target; +} diff --git a/tests/Support/Fakes/FakeBackupManager.php b/tests/Support/Fakes/FakeBackupManager.php new file mode 100644 index 000000000..6f18a1351 --- /dev/null +++ b/tests/Support/Fakes/FakeBackupManager.php @@ -0,0 +1,23 @@ + */ + public array $adapterCalls = []; + + public function __construct(private FakeS3Filesystem $filesystem) {} + + public function adapter(?string $name = null): FilesystemAdapter + { + $this->adapterCalls[] = $name; + + return $this->filesystem; + } +} diff --git a/tests/Support/Fakes/FakeDaemonBackup.php b/tests/Support/Fakes/FakeDaemonBackup.php new file mode 100644 index 000000000..a389eec71 --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonBackup.php @@ -0,0 +1,89 @@ +callsFor('backup'); + + Assert::assertNotEmpty($calls, 'Expected daemon backup to have been triggered.'); + + if ($backupUuid !== null) { + foreach ($calls as $call) { + if (($call['backup_uuid'] ?? null) === $backupUuid) { + return; + } + } + + Assert::fail(sprintf('Expected daemon backup for [%s] to have been triggered.', $backupUuid)); + } + } + + public function assertRestored(?string $backupUuid = null): void + { + $calls = $this->callsFor('restore'); + + Assert::assertNotEmpty($calls, 'Expected daemon backup restore to have been triggered.'); + + if ($backupUuid !== null) { + foreach ($calls as $call) { + if (($call['backup_uuid'] ?? null) === $backupUuid) { + return; + } + } + + Assert::fail(sprintf('Expected daemon backup restore for [%s] to have been triggered.', $backupUuid)); + } + } + + public function assertDeleted(?string $backupUuid = null): void + { + $calls = $this->callsFor('delete'); + + Assert::assertNotEmpty($calls, 'Expected daemon backup delete to have been called.'); + + if ($backupUuid !== null) { + foreach ($calls as $call) { + if (($call['backup_uuid'] ?? null) === $backupUuid) { + return; + } + } + + Assert::fail(sprintf('Expected daemon backup delete for [%s] to have been called.', $backupUuid)); + } + } + + protected function responseFor(Request $request): ?PromiseInterface + { + if (! preg_match('#^/api/servers/([^/]+)/backup(?:/([^/]+)(/restore)?)?$#', parse_url($request->url(), PHP_URL_PATH), $matches)) { + return null; + } + + $method = match ([$request->method(), isset($matches[2]), isset($matches[3])]) { + ['POST', false, false] => 'backup', + ['DELETE', true, false] => 'delete', + ['POST', true, true] => 'restore', + default => null, + }; + if ($method === null) { + return null; + } + + $this->record($method, [ + 'backup_uuid' => $matches[2] ?? ($request->data()['uuid'] ?? null), + 'adapter' => ($request->data()['adapter'] ?? null), + 'url' => ($request->data()['download_url'] ?? null), + 'truncate' => ($request->data()['truncate_directory'] ?? null), + ]); + + return $this->reply(); + } +} diff --git a/tests/Support/Fakes/FakeDaemonCommand.php b/tests/Support/Fakes/FakeDaemonCommand.php new file mode 100644 index 000000000..41c2bed06 --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonCommand.php @@ -0,0 +1,37 @@ +|string $command + */ + public function assertSent(array|string $command): void + { + foreach ($this->callsFor('send') as $call) { + if (($call['command'] ?? null) === (is_array($command) ? $command : [$command])) { + return; + } + } + + Assert::fail('Expected daemon command to have been sent.'); + } + + protected function responseFor(Request $request): ?PromiseInterface + { + if ($request->method() !== 'POST' || ! preg_match('#^/api/servers/([^/]+)/commands$#', parse_url($request->url(), PHP_URL_PATH), $matches)) { + return null; + } + + $this->record('send', ['command' => $request['commands'], 'server_uuid' => $matches[1]]); + + return $this->reply(); + } +} diff --git a/tests/Support/Fakes/FakeDaemonConfiguration.php b/tests/Support/Fakes/FakeDaemonConfiguration.php new file mode 100644 index 000000000..92acc7bc1 --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonConfiguration.php @@ -0,0 +1,43 @@ + */ + public array $systemInformation = []; + + public function assertSystemInformationFetched(): void + { + Assert::assertNotEmpty($this->callsFor('getSystemInformation'), 'Expected daemon system information to have been fetched.'); + } + + public function assertUpdated(): void + { + Assert::assertNotEmpty($this->callsFor('update'), 'Expected daemon configuration update to have been called.'); + } + + protected function responseFor(Request $request): ?PromiseInterface + { + $path = parse_url($request->url(), PHP_URL_PATH); + if ($path === '/api/system' && $request->method() === 'GET') { + $this->record('getSystemInformation', ['version' => $this->query($request)['v'] ?? null]); + + return $this->reply($this->systemInformation); + } + + if ($path === '/api/update' && $request->method() === 'POST') { + $this->record('update', ['configuration' => $request->data()]); + + return $this->reply(); + } + + return null; + } +} diff --git a/tests/Support/Fakes/FakeDaemonFile.php b/tests/Support/Fakes/FakeDaemonFile.php new file mode 100644 index 000000000..364b12de9 --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonFile.php @@ -0,0 +1,263 @@ +> */ + public array $directory = []; + + /** @var array */ + public array $compressed = []; + + public function assertContentFetched(string $path): void + { + foreach ($this->callsFor('getContent') as $call) { + if (($call['path'] ?? null) === $path) { + return; + } + } + + Assert::fail(sprintf('Expected daemon file content for [%s] to have been fetched.', $path)); + } + + public function assertContentPut(string $path, ?string $content = null): void + { + foreach ($this->callsFor('putContent') as $call) { + if (($call['path'] ?? null) === $path && ($content === null || ($call['content'] ?? null) === $content)) { + return; + } + } + + Assert::fail(sprintf('Expected daemon file content for [%s] to have been written.', $path)); + } + + public function assertDirectoryListed(string $path): void + { + foreach ($this->callsFor('getDirectory') as $call) { + if (($call['path'] ?? null) === $path) { + return; + } + } + + Assert::fail(sprintf('Expected daemon directory [%s] to have been listed.', $path)); + } + + public function assertDirectoryCreated(string $name, string $path): void + { + foreach ($this->callsFor('createDirectory') as $call) { + if (($call['name'] ?? null) === $name && ($call['path'] ?? null) === $path) { + return; + } + } + + Assert::fail(sprintf('Expected daemon directory [%s] in [%s] to have been created.', $name, $path)); + } + + public function assertFilesDeleted(?string $root = null, ?array $files = null): void + { + $calls = $this->callsFor('deleteFiles'); + + Assert::assertNotEmpty($calls, 'Expected daemon files to have been deleted.'); + + if ($root !== null || $files !== null) { + foreach ($calls as $call) { + if (($root === null || ($call['root'] ?? null) === $root) && ($files === null || $this->filesMatch($call['files'] ?? null, $files))) { + return; + } + } + + Assert::fail('Expected daemon files to have been deleted with the given arguments.'); + } + } + + /** + * @param array $files + */ + public function assertCompressedFiles(?string $root = null, ?array $files = null): void + { + $calls = $this->callsFor('compressFiles'); + + Assert::assertNotEmpty($calls, 'Expected daemon files to have been compressed.'); + + if ($root !== null || $files !== null) { + foreach ($calls as $call) { + if (($root === null || ($call['root'] ?? null) === $root) && ($files === null || $this->filesMatch($call['files'] ?? null, $files))) { + return; + } + } + + Assert::fail('Expected daemon files to have been compressed with the given arguments.'); + } + } + + /** + * @param array> $files + */ + public function assertFilesRenamed(?string $root = null, ?array $files = null): void + { + $calls = $this->callsFor('renameFiles'); + + Assert::assertNotEmpty($calls, 'Expected daemon files to have been renamed.'); + + if ($root !== null || $files !== null) { + foreach ($calls as $call) { + if (($root === null || ($call['root'] ?? null) === $root) && ($files === null || $this->filesMatch($call['files'] ?? null, $files))) { + return; + } + } + + Assert::fail('Expected daemon files to have been renamed with the given arguments.'); + } + } + + public function assertFileCopied(?string $location = null): void + { + $calls = $this->callsFor('copyFile'); + + Assert::assertNotEmpty($calls, 'Expected daemon file to have been copied.'); + + if ($location !== null) { + foreach ($calls as $call) { + if (($call['location'] ?? null) === $location) { + return; + } + } + + Assert::fail(sprintf('Expected daemon file [%s] to have been copied.', $location)); + } + } + + public function assertFileDecompressed(?string $root = null, ?string $file = null): void + { + $calls = $this->callsFor('decompressFile'); + + Assert::assertNotEmpty($calls, 'Expected daemon file to have been decompressed.'); + + if ($root !== null || $file !== null) { + foreach ($calls as $call) { + if (($root === null || ($call['root'] ?? null) === $root) && ($file === null || ($call['file'] ?? null) === $file)) { + return; + } + } + + Assert::fail('Expected daemon file to have been decompressed with the given arguments.'); + } + } + + /** + * @param array> $files + */ + public function assertFilesChmoded(?string $root = null, ?array $files = null): void + { + $calls = $this->callsFor('chmodFiles'); + + Assert::assertNotEmpty($calls, 'Expected daemon file permissions to have been updated.'); + + if ($root !== null || $files !== null) { + foreach ($calls as $call) { + if (($root === null || ($call['root'] ?? null) === $root) && ($files === null || $this->filesMatch($call['files'] ?? null, $files))) { + return; + } + } + + Assert::fail('Expected daemon file permissions to have been updated with the given arguments.'); + } + } + + public function assertPulled(string $url): void + { + foreach ($this->callsFor('pull') as $call) { + if (($call['url'] ?? null) === $url) { + return; + } + } + + Assert::fail(sprintf('Expected daemon pull for [%s] to have been triggered.', $url)); + } + + protected function responseFor(Request $request): ?PromiseInterface + { + if (! preg_match('#^/api/servers/([^/]+)/files/([^/]+)$#', parse_url($request->url(), PHP_URL_PATH), $matches)) { + return null; + } + + $operation = $matches[2]; + $method = match ([$request->method(), $operation]) { + ['GET', 'contents'] => 'getContent', + ['GET', 'list-directory'] => 'getDirectory', + ['POST', 'write'] => 'putContent', + ['POST', 'create-directory'] => 'createDirectory', + ['PUT', 'rename'] => 'renameFiles', + ['POST', 'copy'] => 'copyFile', + ['POST', 'delete'] => 'deleteFiles', + ['POST', 'compress'] => 'compressFiles', + ['POST', 'decompress'] => 'decompressFile', + ['POST', 'chmod'] => 'chmodFiles', + ['POST', 'pull'] => 'pull', + default => null, + }; + if ($method === null) { + return null; + } + + $query = $this->query($request); + $this->record($method, [ + 'path' => $query['file'] ?? $query['directory'] ?? ($request->data()['path'] ?? null), + 'content' => $request->body(), + 'root' => ($request->data()['root'] ?? null), + 'files' => ($request->data()['files'] ?? null), + 'file' => ($request->data()['file'] ?? null), + 'location' => ($request->data()['location'] ?? null), + 'name' => ($request->data()['name'] ?? null), + 'url' => ($request->data()['url'] ?? null), + ]); + + return $this->reply(match ($method) { + 'getContent' => $this->content, + 'getDirectory' => $this->directory, + 'compressFiles' => $this->compressed, + default => '', + }); + } + + /** + * Compare file payloads ignoring associative key order. Validated request + * data may reorder keys (e.g. "to" before "from") relative to the test input. + * + * @param array $expected + */ + private function filesMatch(mixed $actual, array $expected): bool + { + return is_array($actual) && $this->normalizeKeys($actual) === $this->normalizeKeys($expected); + } + + /** + * @param array $value + * @return array + */ + private function normalizeKeys(array $value): array + { + foreach ($value as $key => $item) { + if (is_array($item)) { + $value[$key] = $this->normalizeKeys($item); + } + } + + if (array_is_list($value)) { + return array_values($value); + } + + ksort($value); + + return $value; + } +} diff --git a/tests/Support/Fakes/FakeDaemonHttpClient.php b/tests/Support/Fakes/FakeDaemonHttpClient.php new file mode 100644 index 000000000..71990f554 --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonHttpClient.php @@ -0,0 +1,68 @@ +> */ + public array $calls = []; + + public function __construct() + { + Http::fake(fn (Request $request): ?PromiseInterface => $this->responseFor($request)); + } + + abstract protected function responseFor(Request $request): ?PromiseInterface; + + /** @return list> */ + public function callsFor(string $method): array + { + return array_values(array_filter($this->calls, fn (array $call): bool => $call['method'] === $method)); + } + + public function assertNothingHappened(): void + { + Assert::assertSame([], $this->calls, 'Expected no Wings requests to have been made.'); + } + + /** @param array $arguments */ + protected function record(string $method, array $arguments = []): void + { + $this->calls[] = ['method' => $method, ...$arguments]; + } + + /** @param string|array $body */ + protected function reply(string|array $body = ''): PromiseInterface + { + if ($this->throwable !== null) { + throw $this->throwable; + } + + if ($this->response !== null) { + return Http::response((string) $this->response->getBody(), $this->response->getStatusCode(), $this->response->getHeaders()); + } + + return Http::response($body); + } + + /** @return array */ + protected function query(Request $request): array + { + parse_str(parse_url($request->url(), PHP_URL_QUERY) ?: '', $query); + + return $query; + } +} diff --git a/tests/Support/Fakes/FakeDaemonPower.php b/tests/Support/Fakes/FakeDaemonPower.php new file mode 100644 index 000000000..8ffc14525 --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonPower.php @@ -0,0 +1,60 @@ +callsFor('send') as $call) { + if (($call['action'] ?? null) === $action) { + return; + } + } + + Assert::fail(sprintf('Expected daemon power action [%s] to have been sent.', $action)); + } + + public function assertSentTimes(string $action, int $times): void + { + $matching = array_values(array_filter( + $this->callsFor('send'), + fn (array $call): bool => ($call['action'] ?? null) === $action + )); + + Assert::assertCount($times, $matching, sprintf('Expected daemon power action [%s] to have been sent %d time(s).', $action, $times)); + } + + public function assertSentTo(string $action, string $serverUuid): void + { + foreach ($this->callsFor('send') as $call) { + if (($call['action'] ?? null) === $action && ($call['server_uuid'] ?? null) === $serverUuid) { + return; + } + } + + Assert::fail(sprintf('Expected power action [%s] for server [%s].', $action, $serverUuid)); + } + + public function assertNothingSent(): void + { + Assert::assertSame([], $this->callsFor('send'), 'Expected no daemon power action to have been sent.'); + } + + protected function responseFor(Request $request): ?PromiseInterface + { + if ($request->method() !== 'POST' || ! preg_match('#^/api/servers/([^/]+)/power$#', parse_url($request->url(), PHP_URL_PATH), $matches)) { + return null; + } + + $this->record('send', ['action' => $request['action'], 'server_uuid' => $matches[1]]); + + return $this->reply(); + } +} diff --git a/tests/Support/Fakes/FakeDaemonRevocation.php b/tests/Support/Fakes/FakeDaemonRevocation.php new file mode 100644 index 000000000..ac5eee3df --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonRevocation.php @@ -0,0 +1,45 @@ +callsFor('deauthorize'); + + Assert::assertNotEmpty($calls, 'Expected daemon deauthorize to have been called.'); + + foreach ($calls as $call) { + if (($call['user'] ?? null) !== $user) { + continue; + } + + if ($servers === null || ($call['servers'] ?? null) === $servers) { + return; + } + } + + Assert::fail(sprintf('Expected daemon deauthorize for user [%s] to have been called.', $user)); + } + + protected function responseFor(Request $request): ?PromiseInterface + { + if (parse_url($request->url(), PHP_URL_PATH) !== '/api/deauthorize-user' || $request->method() !== 'POST') { + return null; + } + + $this->record('deauthorize', ['user' => $request['user'], 'servers' => $request['servers']]); + + return $this->reply(); + } +} diff --git a/tests/Support/Fakes/FakeDaemonServer.php b/tests/Support/Fakes/FakeDaemonServer.php new file mode 100644 index 000000000..44fd40b7f --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonServer.php @@ -0,0 +1,119 @@ + */ + public array $details = []; + + /** @var list|null */ + public ?array $logs = []; + + public function assertDeleted(): void + { + Assert::assertNotEmpty($this->callsFor('delete'), 'Expected daemon server delete to have been called.'); + } + + public function assertDeletedTimes(int $times): void + { + Assert::assertCount($times, $this->callsFor('delete'), sprintf('Expected daemon server delete to have been called %d time(s).', $times)); + } + + public function assertCreated(): void + { + Assert::assertNotEmpty($this->callsFor('create'), 'Expected daemon server create to have been called.'); + } + + public function assertCreatedWith(bool $startOnCompletion): void + { + $calls = $this->callsFor('create'); + + Assert::assertNotEmpty($calls, 'Expected daemon server create to have been called.'); + + foreach ($calls as $call) { + if (($call['startOnCompletion'] ?? null) === $startOnCompletion) { + return; + } + } + + Assert::fail(sprintf('Expected daemon server create to have been called with startOnCompletion=%s.', var_export($startOnCompletion, true))); + } + + public function assertSynced(): void + { + Assert::assertNotEmpty($this->callsFor('sync'), 'Expected daemon server sync to have been called.'); + } + + public function assertSyncedTimes(int $times): void + { + Assert::assertCount($times, $this->callsFor('sync'), sprintf('Expected daemon server sync to have been called %d time(s).', $times)); + } + + public function assertReinstalled(): void + { + Assert::assertNotEmpty($this->callsFor('reinstall'), 'Expected daemon server reinstall to have been called.'); + } + + public function assertArchiveRequested(): void + { + Assert::assertNotEmpty($this->callsFor('requestArchive'), 'Expected daemon server archive request to have been called.'); + } + + public function assertDetailsFetched(): void + { + Assert::assertNotEmpty($this->callsFor('getDetails'), 'Expected daemon server details to have been fetched.'); + } + + public function assertLogsRead(int $lines): void + { + foreach ($this->callsFor('getLogs') as $call) { + if (($call['size'] ?? null) === (string) $lines) { + return; + } + } + + Assert::fail(sprintf('Expected %d daemon server log line(s) to have been requested.', $lines)); + } + + protected function responseFor(Request $request): ?PromiseInterface + { + $path = parse_url($request->url(), PHP_URL_PATH); + if ($path === '/api/servers' && $request->method() === 'POST') { + $this->record('create', ['startOnCompletion' => $request['start_on_completion'], 'server_uuid' => $request['uuid']]); + + return $this->reply(); + } + + if (! preg_match('#^/api/servers/([^/]+)(?:/(sync|reinstall|archive|logs))?$#', $path, $matches)) { + return null; + } + + $method = match ([$request->method(), $matches[2] ?? '']) { + ['GET', ''] => 'getDetails', + ['DELETE', ''] => 'delete', + ['POST', 'sync'] => 'sync', + ['POST', 'reinstall'] => 'reinstall', + ['POST', 'archive'] => 'requestArchive', + ['GET', 'logs'] => 'getLogs', + default => null, + }; + if ($method === null) { + return null; + } + + $this->record($method, ['server_uuid' => $matches[1], 'size' => $this->query($request)['size'] ?? null]); + + return $this->reply(match ($method) { + 'getDetails' => $this->details, + 'getLogs' => ['data' => $this->logs], + default => '', + }); + } +} diff --git a/tests/Support/Fakes/FakeDaemonTransfer.php b/tests/Support/Fakes/FakeDaemonTransfer.php new file mode 100644 index 000000000..5e0bcd117 --- /dev/null +++ b/tests/Support/Fakes/FakeDaemonTransfer.php @@ -0,0 +1,28 @@ +callsFor('notify'), 'Expected daemon transfer notify to have been called.'); + } + + protected function responseFor(Request $request): ?PromiseInterface + { + if ($request->method() !== 'POST' || ! preg_match('#^/api/servers/([^/]+)/transfer$#', parse_url($request->url(), PHP_URL_PATH))) { + return null; + } + + $this->record('notify', ['url' => $request['url'], 'token' => $request['token']]); + + return $this->reply(); + } +} diff --git a/tests/Support/Fakes/FakeDatabaseHostGateway.php b/tests/Support/Fakes/FakeDatabaseHostGateway.php new file mode 100644 index 000000000..237c15ed0 --- /dev/null +++ b/tests/Support/Fakes/FakeDatabaseHostGateway.php @@ -0,0 +1,188 @@ +}> */ + public array $calls = []; + + /** @var array */ + public array $throwOn = []; + + /** @var list */ + public array $createdDatabases = []; + + /** @var list */ + public array $droppedDatabases = []; + + /** @var list */ + public array $createdUsers = []; + + /** @var list */ + public array $droppedUsers = []; + + /** @var list */ + public array $assignments = []; + + public int $flushCount = 0; + + private string $connection = DatabaseHostGateway::DEFAULT_CONNECTION_NAME; + + public function __construct() {} + + public function setConnection(string $connection): self + { + $this->connection = $connection; + $this->calls[] = ['method' => 'setConnection', 'args' => [$connection]]; + + return $this; + } + + public function getConnection(): string + { + return $this->connection; + } + + public function createDatabase(string $database): bool + { + $this->calls[] = ['method' => 'createDatabase', 'args' => [$database]]; + $this->maybeThrow('createDatabase'); + $this->createdDatabases[] = $database; + + return true; + } + + public function createUser(string $username, string $remote, string $password, ?int $maxConnections): bool + { + $this->calls[] = ['method' => 'createUser', 'args' => [$username, $remote, $password, $maxConnections]]; + $this->maybeThrow('createUser'); + $this->createdUsers[] = [ + 'username' => $username, + 'remote' => $remote, + 'password' => $password, + 'maxConnections' => $maxConnections, + ]; + + return true; + } + + public function assignUserToDatabase(string $database, string $username, string $remote): bool + { + $this->calls[] = ['method' => 'assignUserToDatabase', 'args' => [$database, $username, $remote]]; + $this->maybeThrow('assignUserToDatabase'); + $this->assignments[] = [ + 'database' => $database, + 'username' => $username, + 'remote' => $remote, + ]; + + return true; + } + + public function flush(): bool + { + $this->calls[] = ['method' => 'flush', 'args' => []]; + $this->maybeThrow('flush'); + $this->flushCount++; + + return true; + } + + public function dropDatabase(string $database): bool + { + $this->calls[] = ['method' => 'dropDatabase', 'args' => [$database]]; + $this->maybeThrow('dropDatabase'); + $this->droppedDatabases[] = $database; + + return true; + } + + public function dropUser(string $username, string $remote): bool + { + $this->calls[] = ['method' => 'dropUser', 'args' => [$username, $remote]]; + $this->maybeThrow('dropUser'); + $this->droppedUsers[] = [ + 'username' => $username, + 'remote' => $remote, + ]; + + return true; + } + + /** + * Count how many times a method was recorded in $calls. + */ + public function count(string $method): int + { + $total = 0; + foreach ($this->calls as $call) { + if ($call['method'] === $method) { + $total++; + } + } + + return $total; + } + + public function assertCreated(string $database): void + { + Assert::assertContains($database, $this->createdDatabases, "Expected database [{$database}] to have been created."); + } + + public function assertDroppedDatabase(string $database): void + { + Assert::assertContains($database, $this->droppedDatabases, "Expected database [{$database}] to have been dropped."); + } + + public function assertDroppedUser(string $username, string $remote): void + { + Assert::assertContains( + ['username' => $username, 'remote' => $remote], + $this->droppedUsers, + "Expected user [{$username}@{$remote}] to have been dropped." + ); + } + + public function assertAssigned(string $database, string $username, string $remote): void + { + Assert::assertContains( + ['database' => $database, 'username' => $username, 'remote' => $remote], + $this->assignments, + "Expected user [{$username}@{$remote}] to have been assigned to [{$database}]." + ); + } + + public function assertFlushed(?int $times = null): void + { + if ($times === null) { + Assert::assertGreaterThan(0, $this->flushCount, 'Expected flush to have been called at least once.'); + } else { + Assert::assertSame($times, $this->flushCount, "Expected flush to have been called {$times} time(s)."); + } + } + + /** + * @throws Throwable + */ + private function maybeThrow(string $method): void + { + if (isset($this->throwOn[$method])) { + throw $this->throwOn[$method]; + } + } +} diff --git a/tests/Support/Fakes/FakeDynamicDatabaseConnection.php b/tests/Support/Fakes/FakeDynamicDatabaseConnection.php new file mode 100644 index 000000000..00f007130 --- /dev/null +++ b/tests/Support/Fakes/FakeDynamicDatabaseConnection.php @@ -0,0 +1,32 @@ + */ + public array $setCalls = []; + + public function __construct() {} + + public function set(string $connection, DatabaseHost|int $host, string $database = 'mysql'): void + { + $this->setCalls[] = [ + 'connection' => $connection, + 'host' => $host, + 'database' => $database, + ]; + + if ($this->throwOnSet !== null) { + throw $this->throwOnSet; + } + } +} diff --git a/tests/Support/Fakes/FakeResponseFactory.php b/tests/Support/Fakes/FakeResponseFactory.php new file mode 100644 index 000000000..35088a947 --- /dev/null +++ b/tests/Support/Fakes/FakeResponseFactory.php @@ -0,0 +1,102 @@ + */ + public array $views = []; + + public function make($content = '', $status = 200, array $headers = []) + { + return new Response($content, $status, $headers); + } + + public function noContent($status = 204, array $headers = []) + { + return new Response('', $status, $headers); + } + + public function view($view, $data = [], $status = 200, array $headers = []) + { + $this->views[] = $view; + + return new Response('', $status, $headers); + } + + public function json($data = [], $status = 200, array $headers = [], $options = 0) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function eventStream(Closure $callback, array $headers = [], \Illuminate\Http\StreamedEvent|string|null $endStreamWith = '') + { + throw new BadMethodCallException('Not implemented.'); + } + + public function stream($callback, $status = 200, array $headers = []) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function streamJson($data, $status = 200, $headers = [], $encodingOptions = 15) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment') + { + throw new BadMethodCallException('Not implemented.'); + } + + public function download($file, $name = null, array $headers = [], $disposition = 'attachment') + { + throw new BadMethodCallException('Not implemented.'); + } + + public function file($file, array $headers = []) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function redirectTo($path, $status = 302, $headers = [], $secure = null) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function redirectToRoute($route, $parameters = [], $status = 302, $headers = []) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function redirectToAction($action, $parameters = [], $status = 302, $headers = []) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function redirectGuest($path, $status = 302, $headers = [], $secure = null) + { + throw new BadMethodCallException('Not implemented.'); + } + + public function redirectToIntended($default = '/', $status = 302, $headers = [], $secure = null) + { + throw new BadMethodCallException('Not implemented.'); + } +} diff --git a/tests/Support/Fakes/FakeS3Client.php b/tests/Support/Fakes/FakeS3Client.php new file mode 100644 index 000000000..f4be04271 --- /dev/null +++ b/tests/Support/Fakes/FakeS3Client.php @@ -0,0 +1,38 @@ +> */ + public array $deleteObjectCalls = []; + + public function __construct() + { + // AwsClient derives the service name from the concrete class name, so + // provide the real S3 identifiers explicitly instead of "fakes3". + parent::__construct([ + 'service' => 's3', + 'exception_class' => S3Exception::class, + 'version' => 'latest', + 'region' => 'us-east-1', + 'credentials' => ['key' => 'fake', 'secret' => 'fake'], + ]); + } + + /** + * @param array $args + */ + public function deleteObject(array $args = []): Result + { + $this->deleteObjectCalls[] = $args; + + return new Result([]); + } +} diff --git a/tests/Support/Fakes/FakeS3Filesystem.php b/tests/Support/Fakes/FakeS3Filesystem.php new file mode 100644 index 000000000..467c20149 --- /dev/null +++ b/tests/Support/Fakes/FakeS3Filesystem.php @@ -0,0 +1,55 @@ +fakeClient = new FakeS3Client(); + + parent::__construct($this->fakeClient, $bucket, $prefix, $options); + } + + public function getClient(): FakeS3Client + { + return $this->fakeClient; + } + + public function getBucket(): string + { + $this->getBucketCalls++; + + return parent::getBucket(); + } + + /** + * @return list> + */ + public function deleteObjectCalls(): array + { + return $this->fakeClient->deleteObjectCalls; + } + + public function assertDeleted(string $key): void + { + $keys = []; + foreach ($this->fakeClient->deleteObjectCalls as $call) { + $candidate = $call['Key'] ?? null; + if (is_string($candidate)) { + $keys[] = $candidate; + } + } + + Assert::assertContains($key, $keys, sprintf('Expected S3 object [%s] to have been deleted.', $key)); + } +} diff --git a/tests/Support/Fakes/FakeSoftwareVersionService.php b/tests/Support/Fakes/FakeSoftwareVersionService.php new file mode 100644 index 000000000..45911afe1 --- /dev/null +++ b/tests/Support/Fakes/FakeSoftwareVersionService.php @@ -0,0 +1,62 @@ + HandlerStack::create(new MockHandler)]) + ); + } + + public function getPanel(): string + { + return $this->panel; + } + + public function getDaemon(): string + { + return $this->daemon; + } + + public function getDiscord(): string + { + return $this->discord; + } + + public function getDonations(): string + { + return $this->donations; + } + + public function isLatestPanel(): bool + { + return $this->isLatestPanel; + } + + public function isLatestDaemon(string $version): bool + { + if ($version === 'develop') { + return true; + } + + return version_compare($version, $this->daemon) >= 0; + } +} diff --git a/tests/Support/Fakes/ThrowingDispatcher.php b/tests/Support/Fakes/ThrowingDispatcher.php new file mode 100644 index 000000000..58b11ed7f --- /dev/null +++ b/tests/Support/Fakes/ThrowingDispatcher.php @@ -0,0 +1,156 @@ +>> */ + public array $calls = []; + + public function __construct(private readonly Throwable $failure) {} + + public function assertCalled(string $method): void + { + Assert::assertNotEmpty($this->calls[$method] ?? [], "Expected fake to have recorded a call to [{$method}]."); + } + + public function assertNothingCalled(): void + { + Assert::assertSame([], $this->calls, 'Expected fake to have recorded no calls.'); + } + + /** + * @param mixed $command + * @return mixed + * + * @throws LogicException + */ + public function dispatch($command) + { + $this->record(__FUNCTION__, $command); + + throw new LogicException('ThrowingDispatcher only supports dispatchNow().'); + } + + /** + * @param mixed $command + * @param mixed $handler + * @return mixed + * + * @throws LogicException + */ + public function dispatchSync($command, $handler = null) + { + $this->record(__FUNCTION__, $command, $handler); + + throw new LogicException('ThrowingDispatcher only supports dispatchNow().'); + } + + /** + * @param mixed $command + * @param mixed $handler + * @return mixed + * + * @throws Throwable + */ + public function dispatchNow($command, $handler = null) + { + $this->record(__FUNCTION__, $command, $handler); + + throw $this->failure; + } + + /** + * @param mixed $command + * @param mixed $handler + * @return void + * + * @throws LogicException + */ + public function dispatchAfterResponse($command, $handler = null) + { + $this->record(__FUNCTION__, $command, $handler); + + throw new LogicException('ThrowingDispatcher only supports dispatchNow().'); + } + + /** + * QueueingDispatcher-compatibility guard: this fake never queues. + * + * @param mixed $command + * @return mixed + * + * @throws LogicException + */ + public function dispatchToQueue($command) + { + $this->record(__FUNCTION__, $command); + + throw new LogicException('ThrowingDispatcher only supports dispatchNow().'); + } + + /** + * @param \Illuminate\Support\Collection|array|null $jobs + * @return mixed + * + * @throws LogicException + */ + public function chain($jobs = null) + { + throw new LogicException('ThrowingDispatcher does not support chaining.'); + } + + /** + * @param mixed $command + * @return bool + */ + public function hasCommandHandler($command) + { + return false; + } + + /** + * @param mixed $command + * @return mixed + */ + public function getCommandHandler($command) + { + return null; + } + + /** + * @param array $pipes + * @return $this + */ + public function pipeThrough(array $pipes) + { + return $this; + } + + /** + * @param array $map + * @return $this + */ + public function map(array $map) + { + return $this; + } + + protected function record(string $method, mixed ...$args): void + { + $this->calls[$method][] = array_values($args); + } +} diff --git a/tests/Support/OpenApiSpecValidator.php b/tests/Support/OpenApiSpecValidator.php new file mode 100644 index 000000000..75e537ac5 --- /dev/null +++ b/tests/Support/OpenApiSpecValidator.php @@ -0,0 +1,241 @@ +|null */ + private static ?array $spec = null; + + /** @var array>|null map of "METHOD /uri{}" to operation */ + private static ?array $operations = null; + + public static function specPath(): string + { + return storage_path('app/private/scribe/openapi.yaml'); + } + + public static function available(): bool + { + return is_file(self::specPath()); + } + + /** + * Returns a list of contract violations for the response, or an empty + * array when the response matches the documented schema. Responses for + * routes that are not part of the spec are ignored. + * + * @return string[] + */ + public static function validateResponse(string $method, string $routeUri, int $status, string $content): array + { + $operation = self::operations()[self::key($method, $routeUri)] ?? null; + if ($operation === null) { + return []; + } + + if ($status < 200 || $status >= 300 || $status === 204) { + return []; + } + + $response = $operation['responses'][$status] ?? $operation['responses'][(string) $status] ?? null; + if ($response === null) { + return ["response status {$status} is not documented for this operation"]; + } + + $schema = $response['content']['application/json']['schema'] ?? null; + if ($schema === null) { + // Documented as a non-JSON or empty response; nothing to check. + return []; + } + + $decoded = json_decode($content, true); + if (! is_array($decoded)) { + return ['response body is not a JSON object while the spec documents a JSON schema']; + } + + $errors = []; + self::validate($decoded, $schema, '$', $errors); + + return $errors; + } + + /** + * @param array $schema + * @param string[] $errors + */ + private static function validate(mixed $value, array $schema, string $path, array &$errors): void + { + if (isset($schema['$ref'])) { + $resolved = self::resolveRef($schema['$ref']); + if ($resolved === null) { + $errors[] = "{$path}: unresolvable \$ref {$schema['$ref']}"; + + return; + } + + self::validate($value, $resolved, $path, $errors); + + return; + } + + if ($value === null && ($schema['nullable'] ?? false) === true) { + return; + } + + if (isset($schema['oneOf']) && is_array($schema['oneOf'])) { + foreach ($schema['oneOf'] as $branch) { + $branchErrors = []; + self::validate($value, $branch, $path, $branchErrors); + if ($branchErrors === []) { + return; + } + } + + $errors[] = "{$path}: value matches no oneOf branch"; + + return; + } + + if ($value === null) { + if (($schema['nullable'] ?? false) !== true) { + $errors[] = "{$path}: null is not allowed (schema is not nullable)"; + } + + return; + } + + if (isset($schema['enum']) && is_array($schema['enum']) && ! in_array($value, $schema['enum'], true)) { + $errors[] = "{$path}: value ".json_encode($value).' is not one of the documented enum values'; + + return; + } + + match ($schema['type'] ?? null) { + 'integer' => is_int($value) || $errors[] = "{$path}: expected integer, got ".get_debug_type($value), + 'number' => is_int($value) || is_float($value) || $errors[] = "{$path}: expected number, got ".get_debug_type($value), + 'string' => is_string($value) || $errors[] = "{$path}: expected string, got ".get_debug_type($value), + 'boolean' => is_bool($value) || $errors[] = "{$path}: expected boolean, got ".get_debug_type($value), + 'array' => self::validateArray($value, $schema, $path, $errors), + 'object' => self::validateObject($value, $schema, $path, $errors), + default => null, + }; + } + + /** + * @param array $schema + * @param string[] $errors + */ + private static function validateArray(mixed $value, array $schema, string $path, array &$errors): void + { + if (! is_array($value) || ! array_is_list($value)) { + $errors[] = "{$path}: expected array, got ".get_debug_type($value); + + return; + } + + if (isset($schema['items']) && is_array($schema['items'])) { + foreach ($value as $index => $item) { + self::validate($item, $schema['items'], "{$path}[{$index}]", $errors); + } + } + } + + /** + * @param array $schema + * @param string[] $errors + */ + private static function validateObject(mixed $value, array $schema, string $path, array &$errors): void + { + // json_decode(assoc: true) turns objects into arrays; an empty object + // is indistinguishable from an empty list and both are acceptable. + if (! is_array($value) || ($value !== [] && array_is_list($value))) { + $errors[] = "{$path}: expected object, got ".get_debug_type($value); + + return; + } + + foreach (($schema['required'] ?? []) as $key) { + if (! array_key_exists($key, $value)) { + $errors[] = "{$path}: missing required property [{$key}]"; + } + } + + $properties = $schema['properties'] ?? []; + foreach ($value as $key => $item) { + if (isset($properties[$key]) && is_array($properties[$key])) { + self::validate($item, $properties[$key], "{$path}.{$key}", $errors); + } elseif (isset($schema['additionalProperties']) && is_array($schema['additionalProperties'])) { + self::validate($item, $schema['additionalProperties'], "{$path}.{$key}", $errors); + } + } + } + + /** + * @return array|null + */ + private static function resolveRef(string $ref): ?array + { + if (! str_starts_with($ref, '#/components/schemas/')) { + return null; + } + + $name = mb_substr($ref, mb_strlen('#/components/schemas/')); + $schema = self::spec()['components']['schemas'][$name] ?? null; + + return is_array($schema) ? $schema : null; + } + + /** + * @return array + */ + private static function spec(): array + { + return self::$spec ??= Yaml::parseFile(self::specPath()); + } + + /** + * @return array> + */ + private static function operations(): array + { + if (self::$operations !== null) { + return self::$operations; + } + + $operations = []; + foreach (self::spec()['paths'] ?? [] as $uri => $pathItem) { + if (! is_array($pathItem)) { + continue; + } + + foreach ($pathItem as $method => $operation) { + if (is_array($operation) && in_array($method, ['get', 'post', 'put', 'patch', 'delete'], true)) { + $operations[self::key($method, (string) $uri)] = $operation; + } + } + } + + return self::$operations = $operations; + } + + private static function key(string $method, string $uri): string + { + $uri = preg_replace('/\{[^}]+\}/', '{}', mb_trim($uri, '/')); + + return mb_strtoupper($method).' /'.$uri; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 9d4597e0f..c1f495dfa 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,20 +1,60 @@ route->methods()).' /'.mb_ltrim($event->route->uri(), '/').PHP_EOL, + FILE_APPEND | LOCK_EX, + ); + }); + } + + // When OPENAPI_VALIDATE is set, every JSON success response the suite produces + // is checked against the generated OpenAPI spec, turning contract drift into + // test failures. Requires a freshly generated storage spec (composer docs:openapi). + if (env('OPENAPI_VALIDATE') && OpenApiSpecValidator::available()) { + Event::listen(RouteMatched::class, function (RouteMatched $event) { + $this->lastMatchedRoute = $event->route->uri(); + }); + } + + Http::preventStrayRequests(); + Process::preventStrayProcesses(); + Sleep::fake(); + + Str::createRandomStringsNormally(); + Str::createUuidsNormally(); + $now = Carbon::now()->startOfSecond(); Carbon::setTestNow($now); @@ -47,8 +87,33 @@ abstract class TestCase extends BaseTestCase * Handles the known UUID handling in certain unit tests. Use the "KnownUuid" trait * in order to enable this ability. */ - public function setKnownUuidFactory() + public function setKnownUuidFactory(): void { // do nothing } + + public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null): TestResponse + { + $this->lastMatchedRoute = null; + + $response = parent::call($method, $uri, $parameters, $cookies, $files, $server, $content); + + if (env('OPENAPI_VALIDATE') && $this->lastMatchedRoute !== null && OpenApiSpecValidator::available()) { + $errors = OpenApiSpecValidator::validateResponse( + $method, + $this->lastMatchedRoute, + $response->getStatusCode(), + (string) $response->getContent(), + ); + + $this->assertSame([], $errors, sprintf( + "Response for [%s /%s] violates the OpenAPI contract:\n - %s", + mb_strtoupper($method), + mb_ltrim($this->lastMatchedRoute, '/'), + implode("\n - ", $errors), + )); + } + + return $response; + } } diff --git a/tests/Traits/Http/IntegrationJsonRequestAssertions.php b/tests/Traits/Http/IntegrationJsonRequestAssertions.php index 4583d5312..37e229535 100644 --- a/tests/Traits/Http/IntegrationJsonRequestAssertions.php +++ b/tests/Traits/Http/IntegrationJsonRequestAssertions.php @@ -1,5 +1,7 @@ request)) { - throw new \BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.'); + if (! isset($this->request)) { + throw new BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.'); } return function ($response) { diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php index 54cc0bd07..7326d7d31 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -1,18 +1,19 @@ request->shouldReceive('user')->andReturn($user); + $this->request->setUserResolver(fn () => $user); } /** @@ -57,20 +58,35 @@ trait RequestMockHelpers */ public function setRequestRouteName(string $name): void { - $this->request->shouldReceive('route->getName')->andReturn($name); + $route = new Route(['GET'], '/', ['as' => $name, 'uses' => fn () => null]); + $this->request->setRouteResolver(fn () => $route); } /** - * Set the active request object to be an instance of a mocked request. + * Set the bearer token carried by the request's Authorization header. + */ + public function setRequestBearerToken(?string $token): void + { + if ($token === null) { + $this->request->headers->remove('Authorization'); + + return; + } + + $this->request->headers->set('Authorization', 'Bearer '.$token); + } + + /** + * Set the active request object to be a real request instance. */ protected function buildRequestMock(): void { - $this->request = m::mock($this->requestMockClass); - if (!$this->request instanceof Request) { - throw new \InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.'); + if (! is_a($this->requestMockClass, Request::class, true)) { + throw new InvalidArgumentException('Request mock class must be an instance of '.Request::class.' when mocked.'); } - $this->request->attributes = new ParameterBag(); + $class = $this->requestMockClass; + $this->request = $class::create('/', 'GET'); } /** @@ -82,7 +98,7 @@ trait RequestMockHelpers protected function setRequestUser(?User $user = null): User { $user = $user instanceof User ? $user : User::factory()->make(); - $this->request->shouldReceive('user')->withNoArgs()->andReturn($user); + $this->setRequestUserModel($user); return $user; } diff --git a/tests/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php index a90de9f6c..e85d91c56 100644 --- a/tests/Traits/Integration/CreatesTestModels.php +++ b/tests/Traits/Integration/CreatesTestModels.php @@ -1,15 +1,17 @@ create(); $attributes['owner_id'] = $user->id; } - if (!isset($attributes['node_id'])) { - if (!isset($attributes['location_id'])) { + if (! isset($attributes['node_id'])) { + if (! isset($attributes['location_id'])) { /** @var Location $location */ $location = Location::factory()->create(); $attributes['location_id'] = $location->id; @@ -44,23 +46,14 @@ trait CreatesTestModels $attributes['node_id'] = $node->id; } - if (!isset($attributes['allocation_id'])) { + if (! isset($attributes['allocation_id'])) { /** @var Allocation $allocation */ $allocation = Allocation::factory()->create(['node_id' => $attributes['node_id']]); $attributes['allocation_id'] = $allocation->id; } if (empty($attributes['egg_id'])) { - $egg = !empty($attributes['nest_id']) - ? Egg::query()->where('nest_id', $attributes['nest_id'])->firstOrFail() - : $this->getBungeecordEgg(); - - $attributes['egg_id'] = $egg->id; - $attributes['nest_id'] = $egg->nest_id; - } - - if (empty($attributes['nest_id'])) { - $attributes['nest_id'] = Egg::query()->findOrFail($attributes['egg_id'])->nest_id; + $attributes['egg_id'] = $this->getBungeecordEgg()->id; } unset($attributes['user_id'], $attributes['location_id']); @@ -71,7 +64,7 @@ trait CreatesTestModels Allocation::query()->where('id', $server->allocation_id)->update(['server_id' => $server->id]); return $server->fresh([ - 'location', 'user', 'node', 'allocation', 'nest', 'egg', + 'location', 'user', 'node', 'allocation', 'egg', ]); } @@ -79,9 +72,8 @@ trait CreatesTestModels * Generates a user and a server for that user. If an array of permissions is passed it * is assumed that the user is actually a subuser of the server. * - * @param string[] $permissions - * - * @return array{\Pterodactyl\Models\User, \Pterodactyl\Models\Server} + * @param string[] $permissions + * @return array{User, Server} */ public function generateTestAccount(array $permissions = []): array { diff --git a/tests/Traits/MocksPdoConnection.php b/tests/Traits/MocksPdoConnection.php deleted file mode 100644 index 527fac62f..000000000 --- a/tests/Traits/MocksPdoConnection.php +++ /dev/null @@ -1,48 +0,0 @@ - $connection]); - $resolver->setDefaultConnection('mocked'); - - Model::setConnectionResolver($resolver); - - return $mock; - } - - /** - * Resets the mock state. - */ - protected function tearDownPdoMock(): void - { - if (!self::$initialResolver) { - return; - } - - Model::setConnectionResolver(self::$initialResolver); - - self::$initialResolver = null; - } -} diff --git a/tests/Traits/MocksRequestException.php b/tests/Traits/MocksRequestException.php deleted file mode 100644 index 16078707d..000000000 --- a/tests/Traits/MocksRequestException.php +++ /dev/null @@ -1,31 +0,0 @@ -getExceptionMock($abstract)->shouldReceive('getResponse')->andReturn(value($response)); - } - - /** - * Return a mocked instance of the request exception. - */ - protected function getExceptionMock(string $abstract = RequestException::class): MockInterface - { - return $this->exception ?? $this->exception = \Mockery::mock($abstract); - } -} diff --git a/tests/Traits/MocksUuids.php b/tests/Traits/MocksUuids.php deleted file mode 100644 index fb5b7c971..000000000 --- a/tests/Traits/MocksUuids.php +++ /dev/null @@ -1,36 +0,0 @@ -getKnownUuid()); - $factoryMock = m::mock(UuidFactory::class . '[uuid4]', [ - 'uuid4' => $uuid, - ]); - - Uuid::setFactory($factoryMock); - } - - /** - * Returns the known UUID for tests to use. - */ - public function getKnownUuid(): string - { - return $this->knownUuid; - } -} diff --git a/tests/Unit/Actions/Files/ReadFilesTest.php b/tests/Unit/Actions/Files/ReadFilesTest.php new file mode 100644 index 000000000..678e58c40 --- /dev/null +++ b/tests/Unit/Actions/Files/ReadFilesTest.php @@ -0,0 +1,87 @@ +make(['owner_id' => 1, 'node_id' => 1, 'egg_id' => 1, 'allocation_id' => 1]); + + return $server->setRelation('node', Node::factory()->make(['location_id' => 1])); +} + +test('file actions resolve from their contracts', function (): void { + expect($this->app->make(ReadsFileContents::class))->toBeInstanceOf(ReadFileContents::class) + ->and($this->app->make(ListsDirectories::class))->toBeInstanceOf(ListDirectory::class); +}); + +test('file contents are read from Wings', function (): void { + $fake = new FakeDaemonFile; + $fake->content = "motd=Hello\n"; + + expect($this->app->make(ReadsFileContents::class)->read(server(), '/server.properties'))->toBe("motd=Hello\n"); + $fake->assertContentFetched('/server.properties'); +}); + +test('reads are bounded by the configured edit size unless a limit is given', function (?int $limit, bool $rejected): void { + config()->set('pterodactyl.files.max_edit_size', 8); + Http::fake(['*/files/contents*' => Http::response('123456', 200, ['Content-Length' => '6'])]); + + $read = fn (): string => $this->app->make(ReadsFileContents::class)->read(server(), '/large.log', $limit); + + $rejected + ? expect($read)->toThrow(FileSizeTooLargeException::class) + : expect($read())->toBe('123456'); +})->with([ + 'default limit allows the file' => [null, false], + 'explicit limit equal to the size allows the file' => [6, false], + 'explicit lower limit rejects the file' => [5, true], +]); + +test('the configured edit size rejects larger files by default', function (): void { + config()->set('pterodactyl.files.max_edit_size', 4); + Http::fake(['*/files/contents*' => Http::response('123456', 200, ['Content-Length' => '6'])]); + + $this->app->make(ReadsFileContents::class)->read(server(), '/large.log'); +})->throws(FileSizeTooLargeException::class); + +test('directories are listed from Wings', function (): void { + $entry = ['name' => 'eula.txt', 'mode' => '-rw-r--r--', 'mode_bits' => '0644', 'size' => 9, 'file' => true, 'symlink' => false, 'mime' => 'text/plain', 'created' => '2024-01-01T00:00:00Z', 'modified' => '2024-01-01T00:00:00Z']; + $fake = new FakeDaemonFile; + $fake->directory = [$entry]; + + expect($this->app->make(ListsDirectories::class)->list(server(), '/config'))->toBe([$entry]); + $fake->assertDirectoryListed('/config'); +}); + +test('directory listings default to the server root', function (): void { + $fake = new FakeDaemonFile; + + expect($this->app->make(ListsDirectories::class)->list(server()))->toBe([]); + $fake->assertDirectoryListed('/'); +}); + +test('Wings failures surface as daemon connection exceptions', function (): void { + Http::fake(fn (Request $request) => Http::response(['error' => 'missing'], 404)); + + expect(fn (): string => $this->app->make(ReadsFileContents::class)->read(server(), '/missing.txt')) + ->toThrow(fn (DaemonConnectionException $exception) => expect($exception->getStatusCode())->toBe(404)); + expect(fn (): array => $this->app->make(ListsDirectories::class)->list(server(), '/missing')) + ->toThrow(DaemonConnectionException::class); +}); diff --git a/tests/Unit/Actions/Servers/ReadServerLogsTest.php b/tests/Unit/Actions/Servers/ReadServerLogsTest.php new file mode 100644 index 000000000..71740608d --- /dev/null +++ b/tests/Unit/Actions/Servers/ReadServerLogsTest.php @@ -0,0 +1,69 @@ +make(['owner_id' => 1, 'node_id' => 1, 'egg_id' => 1, 'allocation_id' => 1]); + + return $server->setRelation('node', Node::factory()->make(['location_id' => 1])); +} + +test('the action resolves from its contract', function (): void { + expect($this->app->make(ReadsServerLogs::class))->toBeInstanceOf(ReadServerLogs::class); +}); + +test('console lines are returned in the order Wings reports them', function (): void { + $fake = new FakeDaemonServer; + $fake->logs = ['first line', 'second line']; + + expect($this->app->make(ReadsServerLogs::class)->read(server(), 25))->toBe(['first line', 'second line']); + $fake->assertLogsRead(25); +}); + +test('the requested line count is clamped to what Wings serves', function (?int $requested, int $sent): void { + $fake = new FakeDaemonServer; + $logs = $this->app->make(ReadsServerLogs::class); + + $requested === null ? $logs->read(server()) : $logs->read(server(), $requested); + + expect($fake->callsFor('getLogs'))->toHaveCount(1); + $fake->assertLogsRead($sent); +})->with([ + 'default' => [null, ReadsServerLogs::MAX_LINES], + 'above the ceiling' => [5000, ReadsServerLogs::MAX_LINES], + 'zero' => [0, 1], + 'negative' => [-10, 1], + 'within range' => [42, 42], +]); + +test('a server without console output yields no lines', function (): void { + $fake = new FakeDaemonServer; + $fake->logs = null; + + expect($this->app->make(ReadsServerLogs::class)->read(server()))->toBe([]); +}); + +test('malformed Wings log responses are rejected', function (string $body): void { + Http::fake(['*/logs*' => Http::response($body)]); + + $this->app->make(ReadsServerLogs::class)->read(server()); +})->with([ + 'missing data' => ['{}'], + 'data is not a list' => ['{"data":{"first":"line"}}'], + 'non-string line' => ['{"data":["line",5]}'], + 'not json' => ['offline'], +])->throws(DaemonConnectionException::class); diff --git a/tests/Unit/Actions/Servers/ReadServerStateTest.php b/tests/Unit/Actions/Servers/ReadServerStateTest.php new file mode 100644 index 000000000..2ef3a50df --- /dev/null +++ b/tests/Unit/Actions/Servers/ReadServerStateTest.php @@ -0,0 +1,90 @@ +set('cache.default', 'array'); +}); + +function server(): Server +{ + $server = Server::factory()->make(['owner_id' => 1, 'node_id' => 1, 'egg_id' => 1, 'allocation_id' => 1]); + + return $server->setRelation('node', Node::factory()->make(['location_id' => 1])); +} + +test('the action resolves from its contract', function (): void { + expect($this->app->make(ReadsServerState::class))->toBeInstanceOf(ReadServerState::class); +}); + +test('live state and resource usage are mapped from Wings', function (): void { + $fake = new FakeDaemonServer; + $fake->details = ['state' => 'running', 'is_suspended' => true, 'utilization' => ['memory_bytes' => 1048576, 'cpu_absolute' => 12.5, 'disk_bytes' => 5242880, 'network' => ['rx_bytes' => 100, 'tx_bytes' => 200], 'uptime' => 3600]]; + + $state = $this->app->make(ReadsServerState::class)->read(server()); + + expect($state)->toEqual(new ServerState('running', true, 1048576, 12.5, 5242880, 100, 200, 3600)); + $fake->assertDetailsFetched(); +}); + +test('values Wings has not measured fall back to an idle reading', function (): void { + new FakeDaemonServer; + + expect($this->app->make(ReadsServerState::class)->read(server())) + ->toEqual(new ServerState('stopped', false, 0, 0, 0, 0, 0, 0)); +}); + +test('readings are cached per server under the shared resources key', function (): void { + $fake = new FakeDaemonServer; + $fake->details = ['state' => 'running']; + $first = server(); + $second = server(); + $state = $this->app->make(ReadsServerState::class); + + $state->read($first); + $fake->details = ['state' => 'offline']; + + expect($state->read($first)->state)->toBe('running') + ->and($state->read($second)->state)->toBe('offline') + ->and($fake->callsFor('getDetails'))->toHaveCount(2) + ->and(Cache::get("resources:$first->uuid"))->toBe(['state' => 'running']); + + $this->travel(21)->seconds(); + + expect($state->read($first)->state)->toBe('offline'); +}); + +test('an existing resources cache entry is reused without calling Wings', function (): void { + $fake = new FakeDaemonServer; + $server = server(); + Cache::put("resources:$server->uuid", ['state' => 'starting', 'utilization' => ['memory_bytes' => 64]], 20); + + $state = $this->app->make(ReadsServerState::class)->read($server); + + expect($state->state)->toBe('starting')->and($state->memoryBytes)->toBe(64); + $fake->assertNothingHappened(); +}); + +test('failed reads are not cached', function (): void { + Http::fake(['*/api/servers/*' => Http::sequence()->push('', 500)->push(['state' => 'running'])]); + $server = server(); + $state = $this->app->make(ReadsServerState::class); + + expect(fn (): ServerState => $state->read($server))->toThrow(DaemonConnectionException::class); + expect($state->read($server)->state)->toBe('running'); +}); diff --git a/tests/Unit/Actions/Users/CompleteLoginTest.php b/tests/Unit/Actions/Users/CompleteLoginTest.php new file mode 100644 index 000000000..475cf68ef --- /dev/null +++ b/tests/Unit/Actions/Users/CompleteLoginTest.php @@ -0,0 +1,121 @@ +set('session.driver', 'array'); + Event::fake([DirectLogin::class]); +}); + +function user(bool $twoFactor = false): User +{ + return User::factory()->make(['use_totp' => $twoFactor])->forceFill(['id' => 7])->syncOriginal(); +} + +function expectSessionLogin(User $user): void +{ + $guard = Mockery::mock(StatefulGuard::class); + $guard->shouldReceive('login')->once()->with($user, true); + Auth::shouldReceive('guard')->once()->withNoArgs()->andReturn($guard); +} + +test('the action resolves from its contract', function (): void { + expect($this->app->make(CompletesLogins::class))->toBeInstanceOf(CompleteLogin::class); +}); + +test('an account without two-factor is signed in immediately', function (): void { + $user = user(); + expectSessionLogin($user); + Session::put('auth_confirmation_token', LoginCheckpoint::issue(99)); + $previous = Session::getId(); + + $result = $this->app->make(CompletesLogins::class)->complete($user); + + expect($result->complete)->toBeTrue() + ->and($result->user)->toBe($user) + ->and($result->intended)->toBe('/') + ->and($result->confirmationToken)->toBeNull() + ->and($result->toResponseData())->toBe(['complete' => true, 'intended' => '/', 'user' => $user->toVueObject()]) + ->and(Session::has('auth_confirmation_token'))->toBeFalse() + ->and(Session::getId())->not->toBe($previous); + Event::assertDispatched(fn (DirectLogin $event): bool => $event->user === $user && $event->remember); +}); + +test('establishing a session signs in an account that uses two-factor', function (): void { + $user = user(twoFactor: true); + expectSessionLogin($user); + Session::put('auth_confirmation_token', LoginCheckpoint::issue($user->id)); + + $result = $this->app->make(CompletesLogins::class)->establish($user); + + expect($result->complete)->toBeTrue() + ->and($this->app->make(CompletesLogins::class)->pendingCheckpoint())->toBeNull(); + Event::assertDispatched(DirectLogin::class); +}); + +test('a pending checkpoint is only reported while it can be confirmed', function (string $case, bool $pending): void { + $stored = match ($case) { + 'unexpired' => new LoginCheckpoint(7, 'token', CarbonImmutable::now()->addMinute()), + 'expiring now' => new LoginCheckpoint(7, 'token', CarbonImmutable::now()), + 'expired' => new LoginCheckpoint(7, 'token', CarbonImmutable::now()->subSecond()), + 'array payload' => ['user_id' => 7, 'token_value' => 'token', 'expires_at' => CarbonImmutable::now()->addMinute()], + 'unrelated value' => 'token', + default => null, + }; + if ($stored !== null) { + Session::put('auth_confirmation_token', $stored); + } + + $checkpoint = $this->app->make(CompletesLogins::class)->pendingCheckpoint(); + + $pending + ? expect($checkpoint)->toBe($stored) + : expect($checkpoint)->toBeNull(); +})->with([ + ['nothing stored', false], + ['unexpired', true], + ['expiring now', true], + ['expired', false], + ['array payload', false], + ['unrelated value', false], +]); + +test('checkpoints are issued for five minutes with an unguessable token', function (): void { + $first = LoginCheckpoint::issue(7); + $second = LoginCheckpoint::issue(7); + + expect($first->userId)->toBe(7) + ->and($first->token)->toHaveLength(64) + ->and($second->token)->not->toBe($first->token) + ->and($first->expiresAt->equalTo(CarbonImmutable::now()->addMinutes(5)))->toBeTrue() + ->and($first->matches($first->token))->toBeTrue() + ->and($first->matches($second->token))->toBeFalse() + ->and($first->matches(''))->toBeFalse(); +}); + +test('a checkpoint result exposes only the confirmation token', function (): void { + $checkpoint = LoginCheckpoint::issue(7); + $result = LoginResult::checkpoint(user(twoFactor: true), $checkpoint, '/'); + + expect($result->complete)->toBeFalse() + ->and($result->confirmationToken)->toBe($checkpoint->token) + ->and($result->toResponseData())->toBe(['complete' => false, 'confirmation_token' => $checkpoint->token]); +}); diff --git a/tests/Unit/ActivityLogTranslationTest.php b/tests/Unit/ActivityLogTranslationTest.php new file mode 100644 index 000000000..5a6e8f5cc --- /dev/null +++ b/tests/Unit/ActivityLogTranslationTest.php @@ -0,0 +1,82 @@ + + */ +function loggedEventNames(): array +{ + $events = []; + foreach (Finder::create()->files()->in(base_path('app'))->name('*.php') as $file) { + preg_match_all("/event\(\s*'([a-z0-9-]+:[a-z0-9._-]+)'/i", $file->getContents(), $matches); + $events = array_merge($events, $matches[1]); + } + + return array_values(array_unique($events)); +} + +test('every activity event name has a translation', function () { + $events = loggedEventNames(); + expect($events)->not->toBeEmpty(); + + $missing = []; + foreach ($events as $event) { + $key = 'activity.'.str_replace(':', '.', $event); + if (! trans()->has($key) && ! trans()->has($key.'_one')) { + $missing[] = $event; + } + } + + expect($missing)->toBe([]); +}); + +test('every translation placeholder is a property the event always records', function () { + $recorded = []; + foreach (Finder::create()->files()->in(base_path('app'))->name('*.php') as $file) { + preg_match_all("/Activity::event\(\s*'([a-z0-9-]+:[a-z0-9._-]+)'(.*?);/is", $file->getContents(), $chains, PREG_SET_ORDER); + foreach ($chains as $chain) { + preg_match_all("/->property\(\s*\[?\s*'([a-z0-9_.-]+)'/i", $chain[2], $props); + $keys = $props[1]; + preg_match_all("/'([a-z0-9_.-]+)'\s*=>/i", $chain[2], $inline); + $keys = array_merge($keys, $inline[1]); + if (str_contains($chain[2], 'withRequestMetadata')) { + $keys = array_merge($keys, ['ip', 'useragent']); + } + + $recorded[$chain[1]] = isset($recorded[$chain[1]]) + ? array_intersect($recorded[$chain[1]], $keys) + : $keys; + } + } + + $unmet = []; + foreach ($recorded as $event => $properties) { + $key = 'activity.'.str_replace(':', '.', $event); + foreach ([$key, $key.'_one', $key.'_other'] as $candidate) { + if (! trans()->has($candidate)) { + continue; + } + + $line = trans($candidate); + expect($line)->toBeString(); + preg_match_all('/:([\w.-]+\w)/', $line, $matches); + foreach ($matches[1] as $placeholder) { + $root = explode('.', $placeholder)[0]; + $available = array_merge($properties, ['count'], array_map(fn (string $p): string => $p.'_count', $properties)); + if (! in_array($root, $available, true)) { + $unmet[] = "$candidate expects :$root, recorded: ".(implode(', ', $properties) ?: 'nothing'); + } + } + } + } + + expect($unmet)->toBe([]); +}); diff --git a/tests/Unit/ArchTest.php b/tests/Unit/ArchTest.php new file mode 100644 index 000000000..86c30426f --- /dev/null +++ b/tests/Unit/ArchTest.php @@ -0,0 +1,181 @@ +preset()->php()->ignoring('Rules'); + +// md5 is Gravatar's address scheme; sha1 is the +// activity log's public identifier. None of them protect anything. +arch()->preset()->security()->ignoring([ + AdminUserTransformer::class, + ClientUserTransformer::class, + FormatsActivityLogs::class, + 'Rules', +]); + +arch('strict types and comparisons everywhere') + ->expect('Pterodactyl') + ->toUseStrictTypes() + ->toUseStrictEquality(); + +arch('no sleeping, debugging, or environment reads outside config') + ->expect(['sleep', 'usleep', 'dd', 'ddd', 'dump', 'ray', 'exit', 'env']) + ->not->toBeUsed() + ->ignoring('Pterodactyl\Tests'); + +arch('actions use facades for framework services') + ->expect('Pterodactyl\Actions') + ->not->toUse([ + AuthManager::class, + PasswordBroker::class, + Dispatcher::class, + Repository::class, + Encrypter::class, + EventDispatcher::class, + Connection::class, + ConnectionInterface::class, + DatabaseManager::class, + ]); + +arch('controllers') + ->expect('Pterodactyl\Http\Controllers') + ->classes() + ->toHaveSuffix('Controller'); + +arch('only controllers are named Controller') + ->expect('Pterodactyl') + ->not->toHaveSuffix('Controller') + ->ignoring('Pterodactyl\Http\Controllers'); + +arch('form requests are named Request') + ->expect('Pterodactyl\Http\Requests') + ->classes() + ->toHaveSuffix('Request') + ->ignoring(RemoteRequestNode::class); + +arch('form requests extend FormRequest') + ->expect('Pterodactyl\Http\Requests') + ->classes() + ->toExtend(FormRequest::class) + ->ignoring(RemoteRequestNode::class); + +arch('form requests declare rules') + ->expect('Pterodactyl\Http\Requests') + ->classes() + ->toHaveMethod('rules') + ->ignoring(RemoteRequestNode::class); + +arch('form requests live in Http\Requests') + ->expect('Pterodactyl') + ->not->toExtend(FormRequest::class) + ->ignoring('Pterodactyl\Http\Requests'); + +arch('middleware') + ->expect('Pterodactyl\Http\Middleware') + ->classes() + ->toHaveMethod('handle'); + +arch('models') + ->expect('Pterodactyl\Models') + ->classes() + ->toExtend(Model::class) + ->ignoring([ + 'Pterodactyl\Models\Attributes', + 'Pterodactyl\Models\Filters', + 'Pterodactyl\Models\Objects', + 'Pterodactyl\Models\Traits', + ]); + +arch('models live in Models') + ->expect('Pterodactyl') + ->not->toExtend(Model::class) + ->ignoring('Pterodactyl\Models'); + +arch('exceptions') + ->expect('Pterodactyl\Exceptions') + ->classes() + ->toImplement(Throwable::class) + ->ignoring(ApiErrorResponse::class); + +arch('exceptions live in Exceptions') + ->expect('Pterodactyl') + ->not->toImplement(Throwable::class) + ->ignoring('Pterodactyl\Exceptions'); + +arch('console commands') + ->expect('Pterodactyl\Console\Commands') + ->classes() + ->toHaveSuffix('Command') + ->toExtend(Command::class) + ->toHaveMethod('handle'); + +arch('commands live in Console\Commands') + ->expect('Pterodactyl') + ->not->toExtend(Command::class) + ->ignoring('Pterodactyl\Console\Commands'); + +arch('jobs') + ->expect('Pterodactyl\Jobs') + ->classes() + ->toImplement(ShouldQueue::class) + ->toHaveMethod('handle'); + +arch('notifications') + ->expect('Pterodactyl\Notifications') + ->classes() + ->toExtend(Notification::class); + +arch('notifications live in Notifications') + ->expect('Pterodactyl') + ->not->toExtend(Notification::class) + ->ignoring('Pterodactyl\Notifications'); + +arch('service providers') + ->expect('Pterodactyl\Providers') + ->classes() + ->toHaveSuffix('ServiceProvider') + ->toExtend(ServiceProvider::class); + +// ExtensionProvider is the base class every extension's own provider extends. +arch('service providers live in Providers') + ->expect('Pterodactyl') + ->not->toExtend(ServiceProvider::class) + ->ignoring(['Pterodactyl\Providers', ExtensionProvider::class]); + +arch('policies') + ->expect('Pterodactyl\Policies') + ->classes() + ->toHaveSuffix('Policy'); + +arch('enums and traits') + ->expect('Pterodactyl\Enum') + ->toBeEnums(); + +arch('traits') + ->expect('Pterodactyl\Traits') + ->toBeTraits(); diff --git a/tests/Unit/Console/Commands/Environment/Addons/RunHooksCommandTest.php b/tests/Unit/Console/Commands/Environment/Addons/RunHooksCommandTest.php index 6685a7225..3c50d163c 100644 --- a/tests/Unit/Console/Commands/Environment/Addons/RunHooksCommandTest.php +++ b/tests/Unit/Console/Commands/Environment/Addons/RunHooksCommandTest.php @@ -1,119 +1,82 @@ false]); + Process::fake(); + makeHook('example'); + runHooks()->assertExitCode(Command::SUCCESS); + Process::assertNothingRan(); +}); +test('executable hooks run for event', function () { + config(['addons.hooks_enabled' => true]); + Process::fake(); + $first = makeHook('alpha'); + $second = makeHook('beta'); + runHooks()->assertExitCode(Command::SUCCESS); + Process::assertRan(fn ($process) => $process->command === [$first]); + Process::assertRan(fn ($process) => $process->command === [$second]); +}); +test('non executable files are ignored', function () { + config(['addons.hooks_enabled' => true]); + Process::fake(); + $executable = makeHook('alpha'); + $ignored = makeHook('beta', executable: false); + runHooks()->assertExitCode(Command::SUCCESS); + Process::assertRan(fn ($process) => $process->command === [$executable]); + Process::assertDidntRun(fn ($process) => $process->command === [$ignored]); +}); +test('invalid event name is rejected', function () { + config(['addons.hooks_enabled' => true]); + Process::fake(); + runHooks('BadEvent')->expectsOutputToContain('Invalid hook event name')->assertExitCode(Command::INVALID); + Process::assertNothingRan(); +}); +test('failing hook does not abort remaining hooks', function () { + config(['addons.hooks_enabled' => true]); + $failing = makeHook('broken'); + $passing = makeHook('healthy'); + Process::fake(['*broken*' => Process::result(exitCode: 3), '*' => Process::result()]); + runHooks()->expectsOutputToContain('exited with an error')->assertExitCode(Command::SUCCESS); + Process::assertRan(fn ($process) => $process->command === [$failing]); + Process::assertRan(fn ($process) => $process->command === [$passing]); +}); +test('declined confirmation skips hooks', function () { + config(['addons.hooks_enabled' => true]); + Process::fake(); + makeHook('example'); + $this->artisan('p:environment:addons:run-hooks', ['event' => 'post-install'])->expectsConfirmation('Execute 1 addon hook script(s) for the "post-install" event? They run with the privileges of this process.', 'no')->assertExitCode(Command::SUCCESS); + Process::assertNothingRan(); +}); +function runHooks(string $event = 'post-install'): PendingCommand { - protected function tearDown(): void - { - File::deleteDirectory(base_path('addons')); - - parent::tearDown(); - } - - public function testHooksAreSkippedWhenDisabled(): void - { - config(['addons.hooks_enabled' => false]); - Process::fake(); - $this->makeHook('example'); - - $this->runHooks()->assertExitCode(Command::SUCCESS); - - Process::assertNothingRan(); - } - - public function testExecutableHooksRunForEvent(): void - { - config(['addons.hooks_enabled' => true]); - Process::fake(); - $first = $this->makeHook('alpha'); - $second = $this->makeHook('beta'); - - $this->runHooks()->assertExitCode(Command::SUCCESS); - - Process::assertRan(fn ($process) => $process->command === [$first]); - Process::assertRan(fn ($process) => $process->command === [$second]); - } - - public function testNonExecutableFilesAreIgnored(): void - { - config(['addons.hooks_enabled' => true]); - Process::fake(); - $executable = $this->makeHook('alpha'); - $ignored = $this->makeHook('beta', executable: false); - - $this->runHooks()->assertExitCode(Command::SUCCESS); - - Process::assertRan(fn ($process) => $process->command === [$executable]); - Process::assertDidntRun(fn ($process) => $process->command === [$ignored]); - } - - public function testInvalidEventNameIsRejected(): void - { - config(['addons.hooks_enabled' => true]); - Process::fake(); - - $this->runHooks('BadEvent') - ->expectsOutputToContain('Invalid hook event name') - ->assertExitCode(Command::INVALID); - - Process::assertNothingRan(); - } - - public function testFailingHookDoesNotAbortRemainingHooks(): void - { - config(['addons.hooks_enabled' => true]); - $failing = $this->makeHook('broken'); - $passing = $this->makeHook('healthy'); - - Process::fake([ - '*broken*' => Process::result(exitCode: 3), - '*' => Process::result(), - ]); - - $this->runHooks() - ->expectsOutputToContain('exited with an error') - ->assertExitCode(Command::SUCCESS); - - Process::assertRan(fn ($process) => $process->command === [$failing]); - Process::assertRan(fn ($process) => $process->command === [$passing]); - } - - public function testDeclinedConfirmationSkipsHooks(): void - { - config(['addons.hooks_enabled' => true]); - Process::fake(); - $this->makeHook('example'); - - $this->artisan('p:environment:addons:run-hooks', ['event' => 'post-install']) - ->expectsConfirmation('Execute 1 addon hook script(s) for the "post-install" event? They run with the privileges of this process.', 'no') - ->assertExitCode(Command::SUCCESS); - - Process::assertNothingRan(); - } - - private function runHooks(string $event = 'post-install'): PendingCommand - { + return (function () use ($event) { return $this->artisan('p:environment:addons:run-hooks', ['event' => $event, '--no-interaction' => true]); - } - - private function makeHook(string $addon, string $event = 'post-install', bool $executable = true): string - { - $path = base_path("addons/{$addon}/hooks/{$event}"); - - File::ensureDirectoryExists(dirname($path)); - File::put($path, "#!/usr/bin/env bash\nexit 0\n"); - - if ($executable) { - chmod($path, 0o755); - } - - return $path; - } + })->call(pterodactylTestCase()); +} +function makeHook(string $addon, string $event = 'post-install', bool $executable = true): string +{ + $path = base_path("addons/{$addon}/hooks/{$event}"); + File::ensureDirectoryExists(dirname($path)); + File::put($path, "#!/usr/bin/env bash\nexit 0\n"); + if ($executable) { + chmod($path, 0755); + } + + return $path; } diff --git a/tests/Unit/Console/Commands/Environment/AppSettingsCommandTest.php b/tests/Unit/Console/Commands/Environment/AppSettingsCommandTest.php new file mode 100644 index 000000000..76e563868 --- /dev/null +++ b/tests/Unit/Console/Commands/Environment/AppSettingsCommandTest.php @@ -0,0 +1,57 @@ + $option]); + expect($environment)->toContain("PTERODACTYL_TELEMETRY_ENABLED={$expected}"); +})->with([['false', 'false'], ['true', 'true']]); +test('settings ui option is written as passed', function (string $option, string $expected): void { + $environment = runSetup(['--settings-ui' => $option]); + expect($environment)->toContain("APP_ENVIRONMENT_ONLY={$expected}"); +})->with([['false', 'true'], ['true', 'false']]); +/** + * Runs p:environment:setup against a temporary base path and returns the .env file it wrote. + * + * @param array $options + */ +function runSetup(array $options): string +{ + $directory = storage_path('framework/testing/'.Str::random(12)); + File::ensureDirectoryExists($directory); + File::put("{$directory}/.env", "APP_NAME=Pterodactyl\n"); + $basePath = base_path(); + + try { + (function () use ($options, $directory): void { + $command = $this->artisan('p:environment:setup', [ + '--author' => 'admin@example.com', + '--url' => 'https://panel.example.com', + '--timezone' => 'UTC', + '--cache' => 'file', + '--session' => 'file', + '--queue' => 'sync', + '--settings-ui' => 'true', + '--telemetry' => 'false', + '--no-interaction' => true, + ...$options, + ]); + $this->app->setBasePath($directory); + $command->assertSuccessful()->run(); + })->call(pterodactylTestCase()); + + return File::get("{$directory}/.env"); + } finally { + app()->setBasePath($basePath); + File::deleteDirectory($directory); + } +} diff --git a/tests/Unit/Console/GenerateKeyWithoutAppKeyTest.php b/tests/Unit/Console/GenerateKeyWithoutAppKeyTest.php new file mode 100644 index 000000000..e0f9cab56 --- /dev/null +++ b/tests/Unit/Console/GenerateKeyWithoutAppKeyTest.php @@ -0,0 +1,19 @@ +env(['APP_KEY' => '', 'APP_ENVIRONMENT_ONLY' => 'true', 'CLOCKWORK_ENABLE' => 'false']) + ->run([PHP_BINARY, 'artisan', 'key:generate', '--show', '--no-ansi']); + + expect($result->exitCode())->toBe(0, $result->errorOutput().$result->output()); + expect(mb_trim($result->output()))->toStartWith('base64:'); +}); diff --git a/tests/Unit/Database/SchemaDumpTest.php b/tests/Unit/Database/SchemaDumpTest.php new file mode 100644 index 000000000..013ce7ed1 --- /dev/null +++ b/tests/Unit/Database/SchemaDumpTest.php @@ -0,0 +1,17 @@ +toBeFile() + ->and(File::get(database_path("schema/{$connection}-schema.sql")))->toBe(File::get(database_path('schema/mysql-schema.sql'))); +})->with(fn (): array => collect((require dirname(__DIR__, 3).'/config/database.php')['connections']) + ->filter(fn (array $connection): bool => in_array($connection['driver'], ['mysql', 'mariadb'], true)) + ->keys() + ->all()); diff --git a/tests/Unit/DocumentationLinksTest.php b/tests/Unit/DocumentationLinksTest.php new file mode 100644 index 000000000..d790a13b8 --- /dev/null +++ b/tests/Unit/DocumentationLinksTest.php @@ -0,0 +1,21 @@ +flatMap(fn (string $directory): array => File::allFiles($directory)) + ->filter(fn (SplFileInfo $file): bool => preg_match('#pterodactyl\.io/(panel|wings)/1\.0/#', $file->getContents()) === 1) + ->map(fn (SplFileInfo $file): string => $file->getRelativePathname()) + ->values() + ->all(); + + expect($legacyLinks)->toBe([]); +}); diff --git a/tests/Unit/EggConfigurationServiceTest.php b/tests/Unit/EggConfigurationServiceTest.php new file mode 100644 index 000000000..b5625ecea --- /dev/null +++ b/tests/Unit/EggConfigurationServiceTest.php @@ -0,0 +1,56 @@ +handle($server))->toBe(['startup' => ['done' => ['Server started'], 'user_interaction' => [], 'strip_ansi' => false], 'stop' => ['type' => 'command', 'value' => 'stop'], 'configs' => [['parser' => 'properties', 'file' => 'server.properties', 'replace' => [['match' => 'server-port', 'replace_with' => '25565'], ['match' => 'enabled', 'replace_with' => true], ['match' => 'conditional', 'if_value' => 'old', 'replace_with' => '3000'], ['match' => 'conditional', 'if_value' => 'new', 'replace_with' => '25565'], ['match' => 'docker-interface', 'replace_with' => '{{config.docker.network.interface}}'], ['match' => 'mixed-placeholders', 'replace_with' => '{{config.docker.network.interface}} 25565 3000'], ['match' => 'missing-server', 'replace_with' => ''], ['match' => 'missing-env', 'replace_with' => ''], ['match' => 'empty-object', 'replace_with' => 'Array']]]]]); +}); +test('defaults missing startup flags and stop commands', function () { + $server = server('{}', '{"done":[]}', null); + $service = new EggConfigurationService(configurationStructure($server)); + expect($service->handle($server))->toBe(['startup' => ['done' => [], 'user_interaction' => [], 'strip_ansi' => false], 'stop' => ['type' => 'command', 'value' => ''], 'configs' => []]); +}); +test('preserves an enabled strip ansi flag', function () { + $server = server('{}', '{"done":[],"strip_ansi":true}'); + $service = new EggConfigurationService(configurationStructure($server)); + + expect($service->handle($server)['startup']['strip_ansi'])->toBeTrue(); +}); +function server(string $configurationFiles, ?string $configurationStartup = '{"done":"Server started","strip_ansi":false}', ?string $configurationStop = 'stop'): Server +{ + $egg = new Egg(); + $egg->forceFill(['config_files' => $configurationFiles, 'config_startup' => $configurationStartup, 'config_stop' => $configurationStop]); + $server = new Server(); + $server->setRelation('egg', $egg); + + return $server; +} +function configurationStructure(Server $server): ServerConfigurationStructureService +{ + return new class($server) extends ServerConfigurationStructureService + { + public function __construct(private readonly Server $expected) {} + + public function handle(Server $server, array $override = [], bool $legacy = false): array + { + Assert::assertSame($this->expected, $server); + Assert::assertSame([], $override); + Assert::assertTrue($legacy); + + return ['build' => ['default' => ['port' => 25565], 'env' => ['PORT' => 3000, 'EMPTY_OBJECT' => new JsonEmptyObject()]]]; + } + }; +} diff --git a/tests/Unit/Enum/EggSpecificTagsTest.php b/tests/Unit/Enum/EggSpecificTagsTest.php new file mode 100644 index 000000000..e2fe530c3 --- /dev/null +++ b/tests/Unit/Enum/EggSpecificTagsTest.php @@ -0,0 +1,43 @@ +toBeTrue(); + expect(EggSpecificTags::isSpecial('Minecraft'))->toBeFalse(); + expect(EggSpecificTags::isSpecial('my-custom-tag'))->toBeFalse(); +}); +test('try from slug folds case and whitespace', function () { + expect(EggSpecificTags::tryFromSlug(' RUST '))->toBe(EggSpecificTags::Rust); + expect(EggSpecificTags::tryFromSlug('GarrysMod'))->toBe(EggSpecificTags::GarrysMod); + expect(EggSpecificTags::tryFromSlug(''))->toBeNull(); + expect(EggSpecificTags::tryFromSlug(null))->toBeNull(); + expect(EggSpecificTags::tryFromSlug('not-a-game'))->toBeNull(); +}); +test('try from slug matches the friendly name', function () { + expect(EggSpecificTags::tryFromSlug('Source Engine'))->toBe(EggSpecificTags::Srcds); + expect(EggSpecificTags::tryFromSlug(' source engine '))->toBe(EggSpecificTags::Srcds); + expect(EggSpecificTags::tryFromSlug('Voice Servers'))->toBe(EggSpecificTags::Voice); + expect(EggSpecificTags::tryFromSlug('Minecraft: Bedrock'))->toBe(EggSpecificTags::Bedrock); + expect(EggSpecificTags::tryFromSlug("Garry's Mod"))->toBe(EggSpecificTags::GarrysMod); + // The slug still wins over any name, so canonical values are unaffected. + expect(EggSpecificTags::tryFromSlug('minecraft'))->toBe(EggSpecificTags::Minecraft); +}); +test('case for prefers the specific override', function () { + expect(EggSpecificTags::caseFor(['minecraft', 'bedrock']))->toBe(EggSpecificTags::Bedrock); + expect(EggSpecificTags::caseFor(['minecraft']))->toBe(EggSpecificTags::Minecraft); + expect(EggSpecificTags::caseFor(['my-custom-tag']))->toBeNull(); +}); +test('every case has a colour and name', function () { + foreach (EggSpecificTags::cases() as $case) { + expect($case->color())->toMatch('/^#[0-9A-Fa-f]{6}$/', $case->value); + expect($case->friendlyName())->not->toBeEmpty($case->value); + } + expect(EggSpecificTags::all())->toHaveCount(count(EggSpecificTags::cases())); +}); diff --git a/tests/Unit/EnvironmentServiceTest.php b/tests/Unit/EnvironmentServiceTest.php new file mode 100644 index 000000000..5ac03bda4 --- /dev/null +++ b/tests/Unit/EnvironmentServiceTest.php @@ -0,0 +1,66 @@ +set('pterodactyl.environment_variables', ['P_SERVER_ALLOCATION_LIMIT' => 'allocation_limit', 'CONFIGURED_CALLBACK' => static fn (Server $server): string => $server->uuid]); + $variable = new EggVariable(); + $variable->forceFill(['env_variable' => 'GAME_MODE', 'server_value' => 'creative', 'default_value' => 'survival']); + $service = environmentService(new Collection([$variable])); + $service->setEnvironmentKey('CUSTOM_FLAG', static fn (Server $server): bool => $server->oom_disabled); + expect($service->handle(server()))->toBe(['GAME_MODE' => 'creative', 'STARTUP' => 'java -jar server.jar', 'P_SERVER_LOCATION' => 'nyc', 'P_SERVER_UUID' => 'server-uuid', 'P_SERVER_ALLOCATION_LIMIT' => 4, 'CONFIGURED_CALLBACK' => 'server-uuid', 'CUSTOM_FLAG' => true]); +}); +test('rejects non scalar environment values', function () { + config()->set('pterodactyl.environment_variables', []); + $service = environmentService(new Collection()); + $service->setEnvironmentKey('INVALID', static fn (Server $server): stdClass => new stdClass()); + $this->expectException(InvalidArgumentException::class); + $service->handle(server()); +}); +test('rejects invalid configured environment mappings', function (array $configured) { + config()->set('pterodactyl.environment_variables', $configured); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Each configured server environment variable must map a string key to an attribute path or callable.'); + + environmentService(new Collection())->handle(server()); +})->with([ + 'numeric key' => [[0 => 'uuid']], + 'non-string source' => [['INVALID' => ['uuid']]], +]); +function server(): Server +{ + $location = new Location(); + $location->forceFill(['short' => 'nyc']); + $server = new Server(); + $server->forceFill(['startup' => 'java -jar server.jar', 'uuid' => 'server-uuid', 'allocation_limit' => 4, 'oom_disabled' => true]); + $server->setRelation('location', $location); + + return $server; +} +/** @param Collection $resolvedVariables */ +function environmentService(Collection $resolvedVariables): EnvironmentService +{ + return new class($resolvedVariables) extends EnvironmentService + { + /** @param Collection $resolvedVariables */ + public function __construct(private readonly Collection $resolvedVariables) {} + + /** @return Collection */ + public function variables(Server $server): Collection + { + return $this->resolvedVariables; + } + }; +} diff --git a/tests/Unit/Exceptions/ApiErrorResponseTest.php b/tests/Unit/Exceptions/ApiErrorResponseTest.php new file mode 100644 index 000000000..b36d636ce --- /dev/null +++ b/tests/Unit/Exceptions/ApiErrorResponseTest.php @@ -0,0 +1,50 @@ +set('app.debug', false); + $error = ApiErrorResponse::toArray(new RuntimeException('sensitive detail'))['errors'][0]; + expect($error['code'])->toBe('RuntimeException'); + expect($error['status'])->toBe('500'); + expect($error['detail'])->toBe('An unexpected error was encountered while processing this request, please try again.'); + $this->assertArrayNotHasKey('source', $error); + $this->assertArrayNotHasKey('meta', $error); +}); +test('debug traces remove arguments and use each previous exception trace', function () { + config()->set('app.debug', true); + $error = ApiErrorResponse::toArray(nestedException())['errors'][0]; + $trace = $error['meta']['trace']; + $previousTrace = $error['meta']['previous'][0]; + expect($trace)->not->toBeEmpty(); + expect($previousTrace)->not->toBeEmpty(); + expect($previousTrace[0]['function'])->toBe(__NAMESPACE__.'\\throwInnerException'); + foreach (array_merge($trace, $previousTrace) as $frame) { + $this->assertArrayNotHasKey('args', $frame); + $this->assertArrayNotHasKey('object', $frame); + } +}); +function nestedException(): Throwable +{ + try { + throwInnerException(); + } catch (Throwable $previous) { + try { + throw new RuntimeException('outer', previous: $previous); + } catch (Throwable $exception) { + return $exception; + } + } +} +function throwInnerException(): never +{ + throw new RuntimeException('inner'); +} diff --git a/tests/Unit/Exceptions/Http/Connection/DaemonConnectionExceptionTest.php b/tests/Unit/Exceptions/Http/Connection/DaemonConnectionExceptionTest.php new file mode 100644 index 000000000..8279dbb11 --- /dev/null +++ b/tests/Unit/Exceptions/Http/Connection/DaemonConnectionExceptionTest.php @@ -0,0 +1,40 @@ + 'bad request'], 400, ['X-Request-Id' => 'request-123']); + (new DaemonConnectionException($previous))->report(); + expect($handler->hasRecords(Level::Warning))->toBeTrue(); + expect($handler->hasRecords(Level::Error))->toBeFalse(); + $records = $handler->getRecords(); + expect($records)->toHaveCount(1); + expect($records[0]->message)->toBe($previous->getMessage()); + expect($records[0]->context['request_id'])->toBe('request-123'); + expect($records[0]->context['exception'])->toBe($previous); +}); +test('reports error for server errors', function () { + $handler = new TestHandler(); + Log::swap(new \Illuminate\Log\Logger(new Logger('test', [$handler]))); + $previous = Http::failedRequest([], 502); + (new DaemonConnectionException($previous))->report(); + expect($handler->hasRecords(Level::Error))->toBeTrue(); + expect($handler->hasRecords(Level::Warning))->toBeFalse(); + $records = $handler->getRecords(); + expect($records)->toHaveCount(1); + expect($records[0]->message)->toBe($previous->getMessage()); + expect($records[0]->context['exception'])->toBe($previous); +}); diff --git a/tests/Unit/Extensions/Backups/BackupManagerTest.php b/tests/Unit/Extensions/Backups/BackupManagerTest.php new file mode 100644 index 000000000..0d20660ee --- /dev/null +++ b/tests/Unit/Extensions/Backups/BackupManagerTest.php @@ -0,0 +1,24 @@ +set('backups.disks.archive', ['adapter' => 'custom']); + $adapter = new InMemoryFilesystemAdapter(); + $manager = (new BackupManager($this->app))->extend('custom', fn (): InMemoryFilesystemAdapter => $adapter); + expect($manager->adapter('archive'))->toBe($adapter); +}); +test('rejects s3 configuration without a bucket', function () { + config()->set('backups.disks.invalid-s3', ['adapter' => 's3']); + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('The S3 backup adapter requires a bucket.'); + (new BackupManager($this->app))->adapter('invalid-s3'); +}); diff --git a/tests/Unit/Extensions/ExtensionProviderRuntimeTest.php b/tests/Unit/Extensions/ExtensionProviderRuntimeTest.php new file mode 100644 index 000000000..d58d44143 --- /dev/null +++ b/tests/Unit/Extensions/ExtensionProviderRuntimeTest.php @@ -0,0 +1,457 @@ +directory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'ptero-extension-runtime-'.uniqid(); + File::ensureDirectoryExists($this->directory); + config(['extensions.enabled' => true]); + $this->available = []; + $this->failures = []; + $this->app->bind(DeletesServers::class, CoreDeleter::class); + // The layout reads the built Vite manifest; use the committed fixture instead. + $this->app->bind(AssetHashService::class, fn (): AssetHashService => new AssetHashService($this->app->make(FilesystemManager::class), base_path('tests/Fixtures'))); + CoreDeleter::$deleted = []; +}); + +afterEach(function (): void { + File::deleteDirectory($this->directory); +}); + +test('a wrapped action runs extension code around the core action and honours fluent options', function (): void { + extensions('dns'); + provider('dns')->wrap(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RecordingDeleter($inner)); + + $action = $this->app->make(DeletesServers::class); + expect($action)->toBeInstanceOf(RecordingDeleter::class); + expect($action->withForce())->toBe($action); + $action->delete(new Server); + + expect(CoreDeleter::$deleted)->toBe(['before', 'forced', 'after']); + expect($this->failures)->toBe([]); +}); + +test('extensions wrap in load order and each resolution is decorated afresh', function (): void { + extensions('first', 'second'); + provider('first')->wrap(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RecordingDeleter($inner, 'first')); + provider('second')->wrap(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RecordingDeleter($inner, 'second')); + + $this->app->make(DeletesServers::class)->delete(new Server); + $this->app->make(DeletesServers::class)->delete(new Server); + + expect(CoreDeleter::$deleted)->toBe([ + 'second:before', 'first:before', 'deleted', 'first:after', 'second:after', + 'second:before', 'first:before', 'deleted', 'first:after', 'second:after', + ]); +}); + +test('a wrapper is inert while its extension is not available', function (): void { + extensions(); + provider('dns')->wrap(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RecordingDeleter($inner)); + + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(CoreDeleter::class); + + extensions('dns'); + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(RecordingDeleter::class); +}); + +test('a wrapper staged by a provider that never commits or fails to commit is inert', function (): void { + extensions('dns'); + $discarded = provider('dns'); + $discarded->beginRegistration(); + $discarded->wrap(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RecordingDeleter($inner)); + $discarded->discardRegistration(); + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(CoreDeleter::class); + + $failed = provider('dns'); + $failed->beginRegistration(); + $failed->wrap(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RecordingDeleter($inner)); + $failed->consoleCommands([ProbeCommand::class]); + $failed->schedule(function (Schedule $schedule): void { + $schedule->call(fn (): null => null); + }); + $failed->headTags([['tag' => 'meta', 'name' => 'theme-color', 'content' => '#000000']]); + $failed->permissions('Broken.', []); + expect(fn () => $failed->commitRegistration())->toThrow(InvalidArgumentException::class); + + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(CoreDeleter::class); + expect($this->app->make(ExtensionConsoleRegistry::class)->snapshot())->toBe(['commands' => [], 'schedules' => []]); + expect($this->app->make(ExtensionHeadTags::class)->toHtml())->toBe(''); +}); + +test('a broken decorator is recorded and the core action stays resolvable', function (Closure $decorator, string $message): void { + extensions('dns'); + provider('dns')->wrap(DeletesServers::class, $decorator); + + expect($this->app->make(DeletesServers::class))->toBeInstanceOf(CoreDeleter::class); + expect($this->failures)->toBe([['dns', $message, 'action']]); +})->with([ + 'throws' => [fn (): never => throw new RuntimeException('decorator failed'), 'decorator failed'], + 'returns another type' => [fn (): Server => new Server, 'The decorator for '.DeletesServers::class.' must return an implementation of that contract.'], +]); + +test('exceptions of a wrapper and of the core action reach the caller unchanged', function (): void { + extensions('dns'); + provider('dns')->wrap(DeletesServers::class, fn (DeletesServers $inner): DeletesServers => new RecordingDeleter($inner, failure: new RuntimeException('dns cleanup failed'))); + expect(fn () => $this->app->make(DeletesServers::class)->delete(new Server))->toThrow(RuntimeException::class, 'dns cleanup failed'); + + CoreDeleter::$failure = $core = new RuntimeException('wings is unreachable'); + try { + $this->app->make(DeletesServers::class)->delete(new Server); + $this->fail('The core exception must propagate.'); + } catch (Throwable $throwable) { + expect($throwable)->toBe($core); + } finally { + CoreDeleter::$failure = null; + } +}); + +test('only bound panel contracts can be wrapped', function (string $contract): void { + extensions('dns'); + expect(fn () => provider('dns')->wrap($contract, fn ($inner) => $inner))->toThrow(InvalidArgumentException::class, 'can only wrap action contracts'); +})->with([ + 'a concrete action' => [CoreDeleter::class], + 'a framework contract' => [\Illuminate\Contracts\Cache\Repository::class], + 'a missing interface' => [DeletesServers::class.'Missing'], + 'an unbound panel interface' => [\Pterodactyl\Contracts\Models\Identifiable::class], + 'a shared panel service' => [\Pterodactyl\Contracts\Extensions\HashidsInterface::class], + 'an interface outside the contracts namespace' => [\Pterodactyl\Services\Extensions\Contracts\ManagesExtensionSettings::class], +]); + +test('registered commands reach artisan only for available extensions', function (): void { + extensions('probe'); + provider('probe')->consoleCommands([ProbeCommand::class]); + provider('disabled')->consoleCommands([DisabledProbeCommand::class]); + + expect(Artisan::all())->toHaveKey('probe:run')->not->toHaveKey('disabled:run'); + expect(Artisan::call('probe:run'))->toBe(7); +}); + +test('only console commands can be registered', function (): void { + expect(fn () => provider('probe')->consoleCommands([Server::class]))->toThrow(InvalidArgumentException::class, 'is not a console command'); +}); + +test('scheduled tasks run only while the extension is available and failures are attributed', function (): void { + extensions('probe'); + provider('probe')->schedule(function (Schedule $schedule): void { + $schedule->call(fn (): never => throw new RuntimeException('task failed'))->everyMinute()->description('probe task'); + }); + provider('disabled')->schedule(function (Schedule $schedule): void { + $schedule->call(fn (): null => null)->everyMinute()->description('disabled task'); + }); + $schedule = new Schedule; + + $this->app->make(ExtensionConsoleRegistry::class)->schedule($schedule); + + expect($schedule->events())->toHaveCount(1); + $event = $schedule->events()[0]; + expect($event->description)->toBe('probe task'); + expect($event->filtersPass($this->app))->toBeTrue(); + expect(fn () => $event->run($this->app))->toThrow(RuntimeException::class, 'task failed'); + expect($this->failures)->toBe([['probe', 'Scheduled task "probe task" failed.', 'schedule']]); + + extensions(); + expect($event->filtersPass($this->app))->toBeFalse(); +}); + +test('a schedule callback that throws is recorded and schedules nothing runnable', function (): void { + extensions('probe'); + provider('probe')->schedule(function (Schedule $schedule): void { + $schedule->call(fn (): null => null)->everyMinute(); + + throw new RuntimeException('schedule failed'); + }); + $schedule = new Schedule; + + $this->app->make(ExtensionConsoleRegistry::class)->schedule($schedule); + + expect($this->failures)->toBe([['probe', 'schedule failed', 'schedule']]); + expect($schedule->events()[0]->filtersPass($this->app))->toBeFalse(); +}); + +test('head tags are rendered into the layout for guests and replace the panel defaults', function (): void { + extensions('pwa'); + provider('pwa')->headTags([ + ['tag' => 'link', 'rel' => 'manifest', 'href' => '/extensions/pwa/manifest.webmanifest'], + ['tag' => 'meta', 'name' => 'theme-color', 'content' => '#0f172a">', ExtensionSettingFiles::IMAGES, 'Unsupported file type'], + 'svg when not listed' => [SVG, ExtensionSettingFiles::IMAGES, 'Unsupported file type'], + 'type outside the allow-list' => [fn (): string => base64_decode(PNG, true), ['image/jpeg'], 'Unsupported file type'], + 'truncated image' => ["\x89PNG\r\n\x1a\nnot really", ExtensionSettingFiles::IMAGES, 'corrupt or unreadable'], + 'svg with script' => ['', ['image/svg+xml'], 'active or external content'], + 'svg with handler' => ['', ['image/svg+xml'], 'active or external content'], + 'svg with script link' => ['', ['image/svg+xml'], 'active or external content'], + 'svg with doctype entity' => [']>&x;', ['image/svg+xml'], 'Unsupported file type'], + 'malformed svg' => ['', ['image/svg+xml'], 'not valid XML'], + 'empty' => ['', ExtensionSettingFiles::IMAGES, 'empty'], +]); + +test('enforces the size limit of the definition', function (): void { + $bytes = base64_decode(PNG, true).str_repeat("\0", 2048); + expect(fn () => (new ExtensionSettingFiles)->store('probe', upload($bytes), ExtensionSettingFiles::IMAGES, 1)) + ->toThrow(ValidationException::class, 'larger than the allowed 1 KB'); +}); + +test('svg is stored only when the definition lists it', function (): void { + $files = new ExtensionSettingFiles; + $name = $files->store('probe', upload(SVG, 'logo.svg', 'image/svg+xml'), ['image/png', 'image/svg+xml'], 64); + expect($name)->toEndWith('.svg'); + expect($files->read('probe', $name)['mime'] ?? null)->toBe('image/svg+xml'); +}); + +test('read and delete only touch well formed names inside the extension directory', function (): void { + $files = new ExtensionSettingFiles; + Storage::disk('local')->put('extension-files/probe/notes.txt', 'private'); + Storage::disk('local')->put('secret.png', 'private'); + $name = $files->store('probe', upload(base64_decode(PNG, true)), ExtensionSettingFiles::IMAGES, 64); + + expect($files->read('probe', 'notes.txt'))->toBeNull(); + expect($files->read('probe', '../../secret.png'))->toBeNull(); + expect($files->read('Bad/../probe', $name))->toBeNull(); + expect($files->read('other', $name))->toBeNull(); + $files->delete('probe', '../../secret.png'); + Storage::disk('local')->assertExists('secret.png'); + $files->delete('probe', $name); + Storage::disk('local')->assertMissing('extension-files/probe/'.$name); +}); + +test('replacing or clearing a file setting deletes the previous file', function (): void { + $definition = new ExtensionSettingsDefinition(settings(), [ + ExtensionSettingDefinition::make('logo', 'logo', '/favicons/favicon.ico')->file(maxKilobytes: 64), + ExtensionSettingDefinition::make('title', 'title', 'Panel'), + ]); + $action = new ReplaceExtensionSettingFile(new ExtensionSettingFiles); + + $first = $action->replace($definition, 'logo', upload(base64_decode(PNG, true)))[0]['value']; + expect($first)->toStartWith('/extension-files/test-fixture/'); + Storage::disk('local')->assertExists(mb_ltrim((string) $first, '/')); + + $second = $action->replace($definition, 'logo', upload(base64_decode(PNG, true)))[0]['value']; + expect($second)->not->toBe($first); + Storage::disk('local')->assertMissing(mb_ltrim((string) $first, '/')); + Storage::disk('local')->assertExists(mb_ltrim((string) $second, '/')); + + expect($action->replace($definition, 'logo', null)[0]['value'])->toBe('/favicons/favicon.ico'); + expect(Storage::disk('local')->allFiles())->toBe([]); +}); + +test('a rejected upload keeps the current file and non file settings refuse uploads', function (): void { + $definition = new ExtensionSettingsDefinition(settings(), [ + ExtensionSettingDefinition::make('logo', 'logo', null)->file(maxKilobytes: 64), + ExtensionSettingDefinition::make('title', 'title', 'Panel'), + ]); + $action = new ReplaceExtensionSettingFile(new ExtensionSettingFiles); + $current = $action->replace($definition, 'logo', upload(base64_decode(PNG, true)))[0]['value']; + + expect(fn () => $action->replace($definition, 'logo', upload('toThrow(ValidationException::class); + expect(fn () => $action->replace($definition, 'title', upload(base64_decode(PNG, true))))->toThrow(ValidationException::class, 'does not accept a file'); + expect($definition->get('logo'))->toBe($current); + expect(Storage::disk('local')->allFiles())->toHaveCount(1); +}); + +function upload(string $bytes, string $name = 'logo.png', string $mime = 'image/png'): UploadedFile +{ + $path = tempnam(sys_get_temp_dir(), 'ptero-setting-file-'); + file_put_contents($path, $bytes); + + return new UploadedFile($path, $name, $mime, null, true); +} + +function settings(): ExtensionSettings +{ + return (fn (): ExtensionSettings => new class extends ExtensionSettings + { + /** @var array */ + private array $values = []; + + public function __construct() + { + parent::__construct('test-fixture'); + } + + public function get(string $key, mixed $default = null): mixed + { + return array_key_exists($key, $this->values) ? $this->values[$key] : $default; + } + + public function setMany(array $values): void + { + $this->values = array_replace($this->values, $values); + } + + public function forget(string $key): void + { + unset($this->values[$key]); + } + })->call(pterodactylTestCase()); +} diff --git a/tests/Unit/Services/Extensions/ExtensionSettingValueGuardTest.php b/tests/Unit/Services/Extensions/ExtensionSettingValueGuardTest.php new file mode 100644 index 000000000..ca8927e18 --- /dev/null +++ b/tests/Unit/Services/Extensions/ExtensionSettingValueGuardTest.php @@ -0,0 +1,73 @@ +toBe(['enabled' => true, 'limits' => [1, 2.5, null]]); + expect(fn () => ExtensionSettingValueGuard::assertValue(new stdClass()))->toThrow(UnexpectedValueException::class); +}); +test('color accepts hex and oklch colours only', function (mixed $value, ?string $expected) { + expect(ExtensionSettingValueGuard::color($value))->toBe($expected); +})->with([ + ['#FFF', '#fff'], + ['#12ab', '#12ab'], + [' #A1B2C3 ', '#a1b2c3'], + ['#a1b2c3d4', '#a1b2c3d4'], + ['oklch(0.623 0.188 259.8)', 'oklch(0.623 0.188 259.8)'], + ["OKLCH(62.3%\t.188 259.8deg/0.5)", 'oklch(62.3% .188 259.8deg / 0.5)'], + ['#12345', null], + ['#ggg', null], + ['blue', null], + ['rgb(1 2 3)', null], + ['oklch(0.6 0.1)', null], + ['oklch(0.6 0.1 20 / 1 / 1)', null], + ['oklch(var(--l) 0.1 20)', null], + ['#fff;color:red', null], + ["#fff\n}", null], + [str_repeat('#', 65), null], + [0xFFFFFF, null], + [null, null], + [['#fff'], null], +]); +test('text strings and choices coerce stored values to their field shape', function () { + expect(ExtensionSettingValueGuard::text("a\r\nb\rc"))->toBe("a\nb\nc"); + expect(ExtensionSettingValueGuard::text(5))->toBeNull(); + expect(ExtensionSettingValueGuard::strings(['a', 1, null, 'b', ['c']]))->toBe(['a', 'b']); + expect(ExtensionSettingValueGuard::strings(['x' => 'a']))->toBeNull(); + expect(ExtensionSettingValueGuard::strings('a'))->toBeNull(); + expect(ExtensionSettingValueGuard::choices(['b', '2', 'b', 'zz', true, ['a']], ['a', 'b', 2]))->toBe(['b', 2]); + expect(ExtensionSettingValueGuard::choices(['x' => 'a'], ['a']))->toBeNull(); + expect(ExtensionSettingValueGuard::choices(null, ['a']))->toBeNull(); +}); +test('fileReference accepts only server generated names', function (mixed $value, bool $valid) { + expect(ExtensionSettingValueGuard::fileReference($value) !== null)->toBe($valid); +})->with([ + ['0123456789abcdef0123456789abcdef01234567.png', true], + ['0123456789abcdef0123456789abcdef01234567.woff2', true], + ['0123456789ABCDEF0123456789abcdef01234567.png', false], + ['0123456789abcdef0123456789abcdef01234567.php', false], + ['0123456789abcdef0123456789abcdef01234567.png.php', false], + ['../0123456789abcdef0123456789abcdef01234567.png', false], + ["0123456789abcdef0123456789abcdef01234567.png\n", false], + ['logo.png', false], + [null, false], + [['0123456789abcdef0123456789abcdef01234567.png'], false], +]); +test('assertValues accepts string-keyed objects of valid values', function () { + expect(fn () => ExtensionSettingValueGuard::assertValues(['enabled' => true, 'limits' => [1, 2.5, null]]))->not->toThrow(UnexpectedValueException::class); +}); +test('assertValues rejects invalid shapes', function (mixed $value) { + expect(fn () => ExtensionSettingValueGuard::assertValues($value))->toThrow(UnexpectedValueException::class); +})->with([ + 'non-array' => ['enabled'], + 'non-string key' => [[true]], + 'nested invalid value' => [['limits' => new stdClass()]], +]); diff --git a/tests/Unit/Services/Extensions/ExtensionSettingsDefinitionTest.php b/tests/Unit/Services/Extensions/ExtensionSettingsDefinitionTest.php new file mode 100644 index 000000000..21ecf8652 --- /dev/null +++ b/tests/Unit/Services/Extensions/ExtensionSettingsDefinitionTest.php @@ -0,0 +1,110 @@ + 'secret-xy'])->schema(); + expect($schema)->toHaveCount(3); + [$enabled, $apiKey, $pageSize] = $schema; + expect($enabled['input'])->toBe('enabled'); + expect($enabled['label'])->toBe('Enabled'); + expect($enabled['field'])->toBe('toggle'); + expect($enabled['value'])->toBeTrue(); + expect($apiKey['field'])->toBe('password'); + expect($apiKey['help'])->toBe('Secret value.'); + expect($apiKey['value'])->toBe('masked-xy', 'schema must serialize secrets through publicUsing'); + expect($pageSize['field'])->toBe('select'); + expect($pageSize['options'])->toBe([['value' => 25, 'label' => '25'], ['value' => 50, 'label' => '50']]); + expect($pageSize['value'])->toBe(50); +}); +test('labels default to headline of the input name', function (): void { + $definition = new ExtensionSettingsDefinition(settings(), [ExtensionSettingDefinition::make('some_flag', 'some_flag', false)]); + expect($definition->schema()[0]['label'])->toBe('Some Flag'); +}); +test('frontend config only contains frontend marked definitions', function (): void { + $config = definition(['api_key' => 'secret-xy'])->frontendConfig(); + expect($config)->toBe(['enabled' => true, 'page_size' => 50]); + $this->assertArrayNotHasKey('api_key', $config); + $this->assertArrayNotHasKey('api_key_mask', $config); +}); +test('update only writes submitted inputs', function (): void { + $settings = settings(['api_key' => 'keep-me']); + $definition = new ExtensionSettingsDefinition($settings, [ExtensionSettingDefinition::make('enabled', 'enabled', true)->normalizeUsing(fn ($value): bool => (bool) $value), ExtensionSettingDefinition::make('api_key', 'api_key', '')]); + $definition->update(['enabled' => '0']); + + expect($definition->get('enabled'))->toBeFalse(); + expect($definition->get('api_key'))->toBe('keep-me'); +}); +test('validation rules make every input optional and keep inputs without rules', function (): void { + $definition = new ExtensionSettingsDefinition(settings(), [ + ExtensionSettingDefinition::make('limit', 'limit', 10, ['required', 'integer']), + ExtensionSettingDefinition::make('enabled', 'enabled', true, ['sometimes', 'boolean']), + ExtensionSettingDefinition::make('greeting', 'greeting', 'hello'), + ]); + + expect($definition->validationRules())->toBe([ + 'limit' => ['sometimes', 'required', 'integer'], + 'enabled' => ['sometimes', 'boolean'], + 'greeting' => ['sometimes'], + ]); +}); +test('field rejects unknown types', function (): void { + $this->expectException(InvalidArgumentException::class); + ExtensionSettingDefinition::make('x', 'x', null)->field('markdown'); +}); +/** In-memory ExtensionSettings double — no database. */ +function settings(array $initial = []): ExtensionSettings +{ + return (fn (): ExtensionSettings => new class($initial) extends ExtensionSettings + { + public function __construct(private array $values) + { + parent::__construct('test-fixture'); + } + + public function get(string $key, mixed $default = null): mixed + { + return array_key_exists($key, $this->values) ? $this->values[$key] : $default; + } + + public function all(): array + { + return $this->values; + } + + public function setMany(array $values): void + { + $this->values = array_replace($this->values, $values); + } + })->call(pterodactylTestCase()); +} + +function definition(array $initial = []): ExtensionSettingsDefinition +{ + return new ExtensionSettingsDefinition(settings($initial), [ExtensionSettingDefinition::make('enabled', 'enabled', true, ['sometimes', 'boolean'])->label('Enabled')->field('toggle')->frontend()->normalizeUsing(fn ($value): bool => (bool) $value), ExtensionSettingDefinition::make('api_key', 'api_key', '', ['sometimes', 'string'], 'api_key_mask')->label('API Key')->help('Secret value.')->field('password')->publicUsing(fn ($value): ?string => $value === '' ? null : 'masked-'.mb_substr((string) $value, -2)), ExtensionSettingDefinition::make('page_size', 'page_size', 50, ['sometimes', 'integer'])->field('select', [['value' => 25, 'label' => '25'], ['value' => 50, 'label' => '50']])->frontend()->normalizeUsing(fn ($value): int => (int) $value)]); +} + +test('frontend type declarations exclude secrets and reject serialization drift', function (): void { + $typed = new ExtensionSettingsDefinition(settings(['flag' => true]), [ + ExtensionSettingDefinition::make('flag', 'flag', true)->frontend()->frontendType('boolean'), + ExtensionSettingDefinition::make('token', 'token', 'private')->secret(), + ]); + expect($typed->frontendConfigTypes())->toBe(['flag' => 'boolean']); + expect($typed->frontendConfig())->toBe(['flag' => true]); + $bad = new ExtensionSettingsDefinition(settings(['flag' => 'yes']), [ + ExtensionSettingDefinition::make('flag', 'flag', true)->frontend()->frontendType('boolean'), + ]); + expect(fn (): array => $bad->frontendConfig())->toThrow(UnexpectedValueException::class, 'declared boolean type'); +}); diff --git a/tests/Unit/Services/Extensions/ExtensionSettingsRegistryTest.php b/tests/Unit/Services/Extensions/ExtensionSettingsRegistryTest.php new file mode 100644 index 000000000..0a72a4a48 --- /dev/null +++ b/tests/Unit/Services/Extensions/ExtensionSettingsRegistryTest.php @@ -0,0 +1,22 @@ +has('demo'))->toBeFalse(); + expect($registry->get('demo'))->toBeNull(); + $registry->register('demo', $definition); + expect($registry->has('demo'))->toBeTrue(); + expect($registry->get('demo'))->toBe($definition); +}); diff --git a/tests/Unit/Services/Extensions/ExtensionStylesheetInspectorTest.php b/tests/Unit/Services/Extensions/ExtensionStylesheetInspectorTest.php new file mode 100755 index 000000000..7e476d455 --- /dev/null +++ b/tests/Unit/Services/Extensions/ExtensionStylesheetInspectorTest.php @@ -0,0 +1,168 @@ +:not(:last-child)){--tw-space-y-reverse:0}:is(.hw\:\*\:p-2>*){padding:calc(var(--spacing) * 2)}.hw\:before\:content-\[\"\{x\}\"\]:before{--tw-content:"{x}";content:var(--tw-content)}.hw\:group-hover\:underline:is(:where(.hw\:group):hover *),.hw\:dark\:bg-card:is(.dark *){text-decoration-line:underline}@media (hover:hover){.hw\:hover\:bg-accent:hover{background-color:var(--accent)}}@media (width>=64rem){.hw\:lg\:hidden{display:none}}} + @property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@keyframes spin{to{transform:rotate(360deg)}} + .my-banner{display:flex;color:var(--foreground)}.my-banner:hover{--local:1} + CSS; + +// The same build before minification: nested rules stay inside the utility they belong to. +const PREFIXED_NESTED = <<<'CSS' + @layer theme { + :root, :host { + --hw-text-sm: 0.875rem; + } + } + @layer utilities { + .hw\:space-y-2 { + :where(& > :not(:last-child)) { + --tw-space-y-reverse: 0; + } + } + .hw\:lg\:hidden { + @media (width >= 64rem) { + display: none; + } + } + .hw\:hover\:bg-accent { + &:hover { + @media (hover: hover) { + background-color: var(--accent); + } + } + } + } + CSS; + +// The scaffolded stylesheet with `prefix(hw)` removed: what every extension shipped before the prefix. +const UNPREFIXED = <<<'CSS' + @layer theme{:root,:host{--spacing:var(--spacing);--text-sm:.875rem;--font-sans:var(--font-sans)}} + @layer utilities{.flex{display:flex}.hidden{display:none}.p-4{padding:calc(var(--spacing) * 4)}@media (width>=64rem){.lg\:hidden{display:none}}} + CSS; + +/** Write a built package around one stylesheet and ask the inspector about it. */ +function conflictReason(string $css, ?string $prefix, string $stylesheet = 'dist/assets/index.css', bool $ui = true): ?string +{ + $directory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'ptero-stylesheets-'.uniqid(); + File::ensureDirectoryExists(dirname($directory.'/'.$stylesheet)); + File::put($directory.'/extension.json', json_encode(['id' => 'probe', 'name' => 'Probe', 'version' => '1.0.0', ...($ui ? ['ui' => array_filter(['entry' => 'dist/client.js', 'prefix' => $prefix])] : [])], JSON_THROW_ON_ERROR)); + File::put($directory.'/dist/client.js', 'export default {};'); + File::put($directory.'/'.$stylesheet, $css); + + try { + return (new ExtensionStylesheetInspector)->conflictReason((new ExtensionManifestValidator)->fromDirectory($directory)); + } finally { + File::deleteDirectory($directory); + } +} + +test('a build with the declared prefix has nothing to report', function (string $css): void { + expect((new ExtensionStylesheetInspector)->foreign($css, 'hw'))->toBe(['utilities' => [], 'theme' => []]); +})->with([ + 'minified' => [PREFIXED], + 'nested' => [PREFIXED_NESTED], + 'no tailwind at all' => ['.my-banner{display:flex}@media (width>=64rem){.my-banner{display:none}}'], + 'empty' => [''], +]); + +test('reports unprefixed utilities and theme variables', function (): void { + expect((new ExtensionStylesheetInspector)->foreign(UNPREFIXED, 'hw'))->toBe([ + 'utilities' => ['.flex', '.hidden', '.p-4', '.lg\:hidden'], + 'theme' => ['--spacing', '--text-sm', '--font-sans'], + ]); +}); + +test('reports utilities and theme variables built with the prefix of another extension', function (): void { + $inspector = new ExtensionStylesheetInspector; + $css = '@layer theme{:root,:host{--hw-text-sm:.875rem}}@layer utilities{.hw\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}@media (width>=40rem){.hw\:sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}}'; + + expect($inspector->foreign($css, 'hw'))->toBe(['utilities' => [], 'theme' => []]); + expect($inspector->foreign($css, 'ext'))->toBe(['utilities' => ['.hw\:grid-cols-2', '.hw\:sm\:grid-cols-3'], 'theme' => ['--hw-text-sm']]); + // `h` is not `hw`: the prefix ends at the escaped colon and the hyphen. + expect($inspector->foreign($css, 'h'))->toBe(['utilities' => ['.hw\:grid-cols-2', '.hw\:sm\:grid-cols-3'], 'theme' => ['--hw-text-sm']]); +}); + +test('two stylesheets accepted under different prefixes cannot define the same selector', function (): void { + // The bug: both extensions built with one shared prefix, so the later `.ext\:grid-cols-2` + // overrode the earlier `.ext\:sm\:grid-cols-3` and a responsive grid collapsed. + $build = fn (string $prefix): string => "@layer theme{:root,:host{--{$prefix}-text-sm:.875rem}}@layer utilities{.{$prefix}\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}@media (width>=40rem){.{$prefix}\\:sm\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}}"; + $inspector = new ExtensionStylesheetInspector; + $names = function (string $css) use ($inspector): array { + $all = $inspector->foreign($css, null); + + return [...$all['utilities'], ...$all['theme']]; + }; + + expect($names($build('ext')))->toBe(['.ext\:grid-cols-2', '.ext\:sm\:grid-cols-3', '--ext-text-sm']); + expect(array_intersect($names($build('ext')), $names($build('ext'))))->not->toBe([]); + + expect(conflictReason($build('aa'), 'aa'))->toBeNull(); + expect(conflictReason($build('bb'), 'bb'))->toBeNull(); + expect(array_intersect($names($build('aa')), $names($build('bb'))))->toBe([]); + // Whatever one extension is accepted with, the other is rejected for. + expect(conflictReason($build('aa'), 'bb'))->toContain('without its "bb" prefix', '.aa\:grid-cols-2, .aa\:sm\:grid-cols-3, --aa-text-sm'); +}); + +test('only looks inside the tailwind layers', function (): void { + $css = '.flex{display:flex}:root{--spacing:1rem}@layer components{.flex{display:flex}:root{--card:red}}@layer utilities{@keyframes pulse{50%{opacity:.5}}}'; + + expect((new ExtensionStylesheetInspector)->foreign($css, 'hw'))->toBe(['utilities' => [], 'theme' => []]); + expect((new ExtensionStylesheetInspector)->foreign($css, null))->toBe(['utilities' => [], 'theme' => []]); +}); + +test('reads past comments, strings and escapes that contain block syntax', function (): void { + $css = '/* } @layer utilities{.a{} */@layer utilities{.hw\:a[data-x="}{,"],.b[data-x=\'}\']{color:red}.hw\:c\,d{color:red}/* .e{} */.f{color:red}}.g{color:red}'; + + expect((new ExtensionStylesheetInspector)->foreign($css, 'hw'))->toBe(['utilities' => ['.b[data-x=\'}\']', '.f'], 'theme' => []]); +}); + +test('names the stylesheet, what it found and the prefix to build with', function (string $css, ?string $expected): void { + $reason = conflictReason($css, 'hw'); + + if ($expected === null) { + expect($reason)->toBeNull(); + } else { + expect($reason)->toContain('Extension "probe" ships '.$expected.' in dist/assets/index.css', 'without its "hw" prefix', 'build Tailwind with `prefix(hw)`', '`hw:flex`'); + } +})->with([ + 'prefixed' => [PREFIXED, null], + 'utilities and theme' => [UNPREFIXED, 'Tailwind utilities and theme variables'], + 'utilities' => ['@layer utilities{.flex{display:flex}}', 'Tailwind utilities'], + 'theme' => ['@layer theme{:root{--spacing:.25rem}}', 'Tailwind theme variables'], + 'another prefix' => ['@layer utilities{.ext\:flex{display:flex}}', 'Tailwind utilities'], +]); + +test('a build with Tailwind layers needs a declared prefix and is told which line to add', function (): void { + expect(conflictReason(PREFIXED, null))->toContain( + 'Extension "probe" ships Tailwind utilities and theme variables in dist/assets/index.css', + 'but declares no Tailwind prefix - add "prefix": "probe" to "ui" in extension.json, build Tailwind with `prefix(probe)`, write its classes as `probe:flex`', + ); + expect(conflictReason('@layer utilities{.flex{display:flex}}', null))->toContain('ships Tailwind utilities in', 'add "prefix": "probe"'); +}); + +test('a build without Tailwind layers needs no prefix', function (): void { + expect(conflictReason('.my-banner{display:flex}@layer components{.my-card{display:grid}}@layer utilities{}', null))->toBeNull(); +}); + +test('lists a handful of the offending names', function (): void { + expect(conflictReason('@layer utilities{.a{}.b{}.c{}.d{}.e{}.f{}.g{}}', 'hw', 'dist/index.css'))->toContain('(.a, .b, .c, .d, .e, ...)'); +}); + +test('an extension without a frontend has no stylesheets to inspect', function (): void { + expect(conflictReason('@layer utilities{.flex{display:flex}}', null, 'dist/index.css', ui: false))->toBeNull(); +}); diff --git a/tests/Unit/Services/Extensions/ExtensionToolingTest.php b/tests/Unit/Services/Extensions/ExtensionToolingTest.php new file mode 100644 index 000000000..097a21988 --- /dev/null +++ b/tests/Unit/Services/Extensions/ExtensionToolingTest.php @@ -0,0 +1,135 @@ +directory = sys_get_temp_dir().'/ptero-tooling-'.uniqid(); + File::ensureDirectoryExists($this->directory.'/src'); + File::ensureDirectoryExists($this->directory.'/dist/chunks'); + File::put($this->directory.'/extension.json', json_encode(['id' => 'probe', 'name' => 'Probe', 'version' => '1.0.0', 'autoload' => ['Probe\\' => 'src'], 'ui' => ['entry' => 'dist/client.js']], JSON_THROW_ON_ERROR)); + File::put($this->directory.'/dist/client.js', 'export default {};'); + File::put($this->directory.'/dist/chunks/lazy.js', 'export default 1;'); + File::put($this->directory.'/src/Example.php', 'directory); +}); + +test('doctor reports missing builds and valid runtime packages', function (): void { + $this->artisan('p:extension:doctor', ['path' => $this->directory])->assertSuccessful(); + File::delete($this->directory.'/dist/client.js'); + $this->artisan('p:extension:doctor', ['path' => $this->directory])->assertFailed(); +}); + +test('doctor reports navigation icons the panel does not ship without failing the package', function (): void { + File::put($this->directory.'/extension.json', json_encode(['id' => 'probe', 'name' => 'Probe', 'version' => '1.0.0', 'autoload' => ['Probe\\' => 'src'], 'ui' => ['entry' => 'dist/client.js', 'screens' => [ + ['id' => 'known', 'area' => 'admin', 'path' => 'known', 'nav' => ['label' => 'Known', 'icon' => 'life-buoy']], + ['id' => 'unknown', 'area' => 'admin', 'path' => 'unknown', 'nav' => ['label' => 'Unknown', 'icon' => 'not-an-icon']], + ['id' => 'plain', 'area' => 'admin', 'path' => 'plain', 'nav' => ['label' => 'Plain']], + ]]], JSON_THROW_ON_ERROR)); + + $this->artisan('p:extension:doctor', ['path' => $this->directory]) + ->expectsOutputToContain('Navigation icon "not-an-icon" is not a lucide icon this panel ships') + ->doesntExpectOutputToContain('life-buoy') + ->assertSuccessful(); +}); + +test('doctor and pack reject a stylesheet that is not built with the declared tailwind prefix', function (): void { + $manifest = ['id' => 'probe', 'name' => 'Probe', 'version' => '1.0.0', 'autoload' => ['Probe\\' => 'src'], 'ui' => ['entry' => 'dist/client.js', 'prefix' => 'pb']]; + File::put($this->directory.'/extension.json', json_encode($manifest, JSON_THROW_ON_ERROR)); + File::put($this->directory.'/dist/index.css', '@layer theme{:root,:host{--pb-text-sm:.875rem}}@layer utilities{.pb\:flex{display:flex}@media (width>=64rem){.pb\:lg\:hidden{display:none}}}.probe-banner{display:flex}'); + $this->artisan('p:extension:doctor', ['path' => $this->directory])->assertSuccessful(); + $archive = $this->directory.'/probe.pteroext'; + $this->artisan('p:extension:pack', ['path' => $this->directory, '--output' => $archive])->assertSuccessful(); + + File::put($this->directory.'/dist/index.css', '@layer theme{:root,:host{--spacing:.25rem}}@layer utilities{.flex{display:flex}}'); + $this->artisan('p:extension:doctor', ['path' => $this->directory]) + ->expectsOutputToContain('ships Tailwind utilities and theme variables in dist/index.css (.flex, --spacing) without its "pb" prefix') + ->assertFailed(); + $this->artisan('p:extension:pack', ['path' => $this->directory, '--output' => $archive, '--force' => true]) + ->expectsOutputToContain('build Tailwind with `prefix(pb)`') + ->assertFailed(); + + // The prefix every extension shared before each declared its own is as foreign as none. + File::put($this->directory.'/dist/index.css', '@layer utilities{.ext\:flex{display:flex}}'); + $this->artisan('p:extension:doctor', ['path' => $this->directory]) + ->expectsOutputToContain('ships Tailwind utilities in dist/index.css (.ext\:flex) without its "pb" prefix') + ->assertFailed(); + + unset($manifest['ui']['prefix']); + File::put($this->directory.'/extension.json', json_encode($manifest, JSON_THROW_ON_ERROR)); + File::put($this->directory.'/dist/index.css', '@layer utilities{.pb\:flex{display:flex}}'); + $this->artisan('p:extension:doctor', ['path' => $this->directory]) + ->expectsOutputToContain('declares no Tailwind prefix - add "prefix": "probe" to "ui" in extension.json') + ->assertFailed(); +}); + +test('packs runtime sources and lazy assets without developer files or hidden secrets', function (): void { + File::put($this->directory.'/.env', 'private'); + File::ensureDirectoryExists($this->directory.'/src/.private'); + File::put($this->directory.'/src/.private/secret.txt', 'private'); + File::ensureDirectoryExists($this->directory.'/node_modules'); + File::put($this->directory.'/node_modules/package.js', 'development'); + $archive = $this->directory.'/probe.pteroext'; + $this->artisan('p:extension:pack', ['path' => $this->directory, '--output' => $archive])->assertSuccessful(); + $zip = new ZipArchive; + expect($zip->open($archive))->toBeTrue(); + try { + expect($zip->getFromName('extension.json'))->toContain('probe'); + expect($zip->getFromName('dist/chunks/lazy.js'))->toBe('export default 1;'); + expect($zip->getFromName('src/Example.php'))->toBe('locateName('.env'))->toBeFalse(); + expect($zip->locateName('src/.private/secret.txt'))->toBeFalse(); + expect($zip->locateName('node_modules/package.js'))->toBeFalse(); + } finally { + $zip->close(); + } + $this->artisan('p:extension:pack', ['path' => $this->directory, '--output' => $archive])->assertFailed(); +}); + +test('a failed development build never publishes the incomplete package', function (): void { + Process::fake(['*' => Process::result(exitCode: 1, errorOutput: 'build failed')]); + $installer = Mockery::mock(InstallsExtensions::class); + $installer->shouldNotReceive('install'); + $this->app->instance(InstallsExtensions::class, $installer); + $this->artisan('p:extension:dev', ['path' => $this->directory])->assertFailed(); +}); + +test('development publishes after a successful build', function (): void { + Process::fake(['*' => Process::result(output: 'built in 100ms')]); + $manifest = resolve(ExtensionManifestValidator::class)->fromDirectory($this->directory); + $installer = Mockery::mock(InstallsExtensions::class); + $installer->shouldReceive('install')->once()->with($this->directory, false)->andReturn($manifest); + $this->app->instance(InstallsExtensions::class, $installer); + $this->artisan('p:extension:dev', ['path' => $this->directory])->assertSuccessful(); +}); + +test('generates literal screen ids and only declared frontend configuration keys', function (): void { + $this->app->make(\Pterodactyl\Services\Extensions\ExtensionPermissionRegistry::class)->register('probe', 'Probe', ['view' => 'View progress']); + $definition = new \Pterodactyl\Services\Extensions\ExtensionSettingsDefinition(new \Pterodactyl\Services\Extensions\ExtensionSettings('probe'), [ + \Pterodactyl\Services\Extensions\ExtensionSettingDefinition::make('flag', 'enabled', true)->frontend()->public()->frontendType('boolean'), + \Pterodactyl\Services\Extensions\ExtensionSettingDefinition::make('accent', 'accent', '#3b82f6')->color()->frontend(), + \Pterodactyl\Services\Extensions\ExtensionSettingDefinition::make('links', 'links', [])->list()->frontend(), + \Pterodactyl\Services\Extensions\ExtensionSettingDefinition::make('token', 'token', 'private')->secret(), + ]); + $this->app->make(\Pterodactyl\Services\Extensions\ExtensionSettingsRegistry::class)->register('probe', $definition); + $manifest = File::json($this->directory.'/extension.json'); + $manifest['ui']['screens'] = [['id' => 'main', 'area' => 'account', 'path' => 'probe']]; + File::put($this->directory.'/extension.json', json_encode($manifest, JSON_THROW_ON_ERROR)); + $this->artisan('p:extension:types', ['path' => $this->directory])->assertSuccessful(); + $source = File::get($this->directory.'/src/client/extension-types.ts'); + expect($source)->toContain('ExtensionScreenId = "main"', 'readonly "enabled": boolean', 'ExtensionPermission = "ext.probe.view"'); + expect($source)->toContain('readonly "accent": string;', 'readonly "links": readonly ExtensionConfigValue[];', 'ExtensionPublicConfigKey = "enabled";', 'ExtensionPublicConfig = Pick'); + expect($source)->not->toContain('token', 'private'); +}); diff --git a/tests/Unit/Services/Helpers/AssetHashServiceTest.php b/tests/Unit/Services/Helpers/AssetHashServiceTest.php new file mode 100644 index 000000000..4d863f4ef --- /dev/null +++ b/tests/Unit/Services/Helpers/AssetHashServiceTest.php @@ -0,0 +1,39 @@ +bindTo(null, AssetHashService::class)(); + config()->set('pterodactyl.assets.use_hash', true); + $manifest = [AssetHashService::MAIN_ENTRY => ['file' => 'bundle.abc.js', 'integrity' => 'sha384-main', 'css' => ['main.abc.css'], 'cssIntegrity' => ['main.abc.css' => 'sha384-css']], 'resources/scripts/ext-runtime/react.ts' => ['file' => 'ext-runtime.react.abc.js', 'integrity' => 'sha384-react'], 'invalid.ts' => ['file' => false]]; + $root = sys_get_temp_dir().'/pterodactyl-asset-hash-'.uniqid(); + mkdir($root.'/assets', 0777, true); + file_put_contents($root.'/'.AssetHashService::MANIFEST_PATH, json_encode($manifest, JSON_THROW_ON_ERROR)); + try { + $service = new AssetHashService($this->app->make(FilesystemManager::class), $root); + expect($service->url(AssetHashService::MAIN_ENTRY))->toBe('/assets/bundle.abc.js'); + $this->assertStringContainsString('href="/assets/main.abc.css"', $service->cssImports(AssetHashService::MAIN_ENTRY)); + $this->assertStringContainsString('integrity="sha384-css"', $service->cssImports(AssetHashService::MAIN_ENTRY)); + $this->assertStringContainsString('src="/assets/bundle.abc.js"', $service->js(AssetHashService::MAIN_ENTRY)); + $this->assertStringContainsString('integrity="sha384-main"', $service->js(AssetHashService::MAIN_ENTRY)); + expect($service->url('invalid.ts'))->toBe('invalid.ts'); + $map = $service->importMap(); + $this->assertStringContainsString('"react":"/assets/ext-runtime.react.abc.js"', $map); + $this->assertStringContainsString('"/assets/ext-runtime.react.abc.js":"sha384-react"', $map); + } finally { + unlink($root.'/'.AssetHashService::MANIFEST_PATH); + rmdir($root.'/assets'); + rmdir($root); + } +}); diff --git a/tests/Unit/Services/Helpers/SoftwareVersionServiceTest.php b/tests/Unit/Services/Helpers/SoftwareVersionServiceTest.php new file mode 100644 index 000000000..ddd6274f1 --- /dev/null +++ b/tests/Unit/Services/Helpers/SoftwareVersionServiceTest.php @@ -0,0 +1,38 @@ + '2.1.0', 'wings' => '1.12.0', 'discord' => 'https://example.com/discord', 'donations' => 'https://example.com/donate']); + expect($service->getPanel())->toBe('2.1.0'); + expect($service->getDaemon())->toBe('1.12.0'); + expect($service->getDiscord())->toBe('https://example.com/discord'); + expect($service->getDonations())->toBe('https://example.com/donate'); +}); +test('ignores version fields with invalid types', function () { + $service = service(['panel' => ['invalid'], 'wings' => '1.12.0']); + expect($service->getPanel())->toBe('error'); + expect($service->getDaemon())->toBe('1.12.0'); +}); +/** @param array $payload */ +function service(array $payload): SoftwareVersionService +{ + $cache = new Repository(new ArrayStore); + $client = new Client(['handler' => HandlerStack::create(new MockHandler([ + new Response(200, body: json_encode($payload, JSON_THROW_ON_ERROR)), + ]))]); + + return new SoftwareVersionService($cache, $client); +} diff --git a/tests/Unit/WingsJsonResponseTest.php b/tests/Unit/WingsJsonResponseTest.php new file mode 100644 index 000000000..922e28e59 --- /dev/null +++ b/tests/Unit/WingsJsonResponseTest.php @@ -0,0 +1,63 @@ + */ +function wingsResponse(string $operation, string $body): array +{ + Http::fake(['*/api/*' => Http::response($body, 200, ['X-Request-Id' => 'invalid-response-123'])]); + $node = Node::factory()->make(['location_id' => 1]); + $server = Server::factory()->make(['owner_id' => 1, 'node_id' => 1, 'egg_id' => 1, 'allocation_id' => 1]); + $server->setRelation('node', $node); + + return match ($operation) { + 'system' => Daemon::node($node)->systemInformation(), + 'details' => Daemon::server($server)->details(), + 'directory' => Daemon::server($server)->files()->getDirectory('/'), + 'compress' => Daemon::server($server)->files()->compressFiles('/', ['file.txt']), + }; +} + +test('malformed Wings responses use the gateway error contract', function (string $operation, string $body): void { + try { + wingsResponse($operation, $body); + $this->fail('Expected an invalid Wings response to be rejected.'); + } catch (DaemonConnectionException $daemonConnectionException) { + expect($daemonConnectionException->getStatusCode())->toBe(502) + ->and($daemonConnectionException->getRequestId())->toBe('invalid-response-123') + ->and($daemonConnectionException->getPrevious())->toBeInstanceOf(Throwable::class); + } +})->with(['system', 'details', 'directory', 'compress'])->with(['not-json', '"offline"', 'null']); + +test('Wings rejects invalid types before consumers run', function (string $operation, string $body): void { + expect(fn (): array => wingsResponse($operation, $body))->toThrow(DaemonConnectionException::class); +})->with([ + ['details', '{"utilization":{"network":"offline"}}'], + ['details', '{"utilization":{"memory_bytes":"1024"}}'], + ['directory', '{"unexpected":{}}'], + ['directory', '["file.txt"]'], + ['directory', '[{"created":"invalid-date"}]'], + ['compress', '{"size":"large"}'], + ['compress', '[1]'], +]); + +test('Wings preserves valid typed response values', function (string $operation, array $payload): void { + expect(wingsResponse($operation, json_encode($payload, JSON_THROW_ON_ERROR)))->toBe($payload); +})->with([ + ['system', ['version' => '1.0.0']], + ['details', ['state' => 'running', 'utilization' => ['memory_bytes' => 1024, 'cpu_absolute' => 2.5]]], + ['directory', [['name' => 'file.txt', 'size' => 42, 'file' => true]]], + ['compress', ['name' => 'archive.tar.gz', 'size' => 42, 'file' => true]], +]); diff --git a/tools/oxlint/rules/design-tokens.spec.ts b/tools/oxlint/rules/design-tokens.spec.ts new file mode 100644 index 000000000..ed8b331f9 --- /dev/null +++ b/tools/oxlint/rules/design-tokens.spec.ts @@ -0,0 +1,41 @@ +// @vitest-environment jsdom + +import { globSync, readFileSync } from 'node:fs'; +import postcss from 'postcss'; +import { expect, it } from 'vitest'; +import { paletteUtility } from './rules/design-tokens'; + +it('uses semantic colors and radii in custom CSS outside the theme definition', () => { + for (const path of globSync('resources/scripts/**/*.css').map((path) => path.replaceAll('\\', '/'))) { + const stylesheet = postcss.parse(readFileSync(path, 'utf8'), { from: path }); + stylesheet.walkDecls((declaration) => { + if (path === 'resources/scripts/assets/tailwind.css') return; + if ( + /^(?:color|background(?:-color)?|border(?:-[a-z]+)?-color|outline-color|fill|stroke)$/.test( + declaration.prop + ) + ) { + expect(declaration.value, `${path}:${declaration.source?.start?.line}`).toMatch( + /^(?:var\(|currentColor\b|transparent\b|none\b|inherit\b)/i + ); + } + if (/^(?:-webkit-)?border-radius$/.test(declaration.prop)) { + expect(declaration.value, `${path}:${declaration.source?.start?.line}`).toMatch(/^var\(/); + } + }); + stylesheet.walkAtRules('apply', (rule) => { + expect(rule.params, path).not.toMatch(paletteUtility); + }); + } +}); + +it('uses semantic color utilities in Blade template classes', () => { + for (const path of globSync('resources/views/**/*.blade.php').map((path) => path.replaceAll('\\', '/'))) { + if (path.startsWith('resources/views/scribe/')) continue; + const template = document.createElement('template'); + template.innerHTML = readFileSync(path, 'utf8'); + for (const element of template.content.querySelectorAll('[class]')) { + expect(element.getAttribute('class'), path).not.toMatch(paletteUtility); + } + } +}); diff --git a/tools/oxlint/rules/index.ts b/tools/oxlint/rules/index.ts new file mode 100644 index 000000000..705926156 --- /dev/null +++ b/tools/oxlint/rules/index.ts @@ -0,0 +1,39 @@ +import { definePlugin } from '@oxlint/plugins'; + +import { noChainedTypeAssertionsRule } from './rules/no-chained-type-assertions.ts'; +import { noConditionalEmptyObjectSpreadRule } from './rules/no-conditional-empty-object-spread.ts'; +import { noKnownValueWideningRule } from './rules/no-known-value-widening.ts'; +import { noObjectParametersRule } from './rules/no-object-parameters.ts'; +import { noRuntimeTypeofRule } from './rules/no-runtime-typeof.ts'; +import { noForbiddenTermInSymbolNamesRule } from './rules/no-shape-in-symbol-names.ts'; +import { noUnknownParametersRule } from './rules/no-unknown-parameters.ts'; +import { noUnknownTypeAliasesRule } from './rules/no-unknown-type-aliases.ts'; +import { noUnsafeDictionaryTypeRule } from './rules/no-unsafe-dictionary-type.ts'; +import { noWidenThenAssertRule } from './rules/no-widen-then-assert.ts'; +import { generatedApiImportsRule } from './rules/generated-api-imports.ts'; +import { generatedApiTypesRule } from './rules/generated-api-types.ts'; +import { generatedApiMutationsRule } from './rules/generated-api-mutations.ts'; +import { designTokensRule } from './rules/design-tokens.ts'; + +/** Generic Oxlint rules that reject low-evidence and low-signal implementation patterns. */ +const rulesPlugin = definePlugin({ + meta: { name: 'rules' }, + rules: { + 'generated-api-imports': generatedApiImportsRule, + 'generated-api-types': generatedApiTypesRule, + 'generated-api-mutations': generatedApiMutationsRule, + 'design-tokens': designTokensRule, + 'no-chained-type-assertions': noChainedTypeAssertionsRule, + 'no-conditional-empty-object-spread': noConditionalEmptyObjectSpreadRule, + 'no-known-value-widening': noKnownValueWideningRule, + 'no-object-parameters': noObjectParametersRule, + 'no-runtime-typeof': noRuntimeTypeofRule, + 'no-unsafe-dictionary-type': noUnsafeDictionaryTypeRule, + 'no-shape-in-symbol-names': noForbiddenTermInSymbolNamesRule, + 'no-unknown-parameters': noUnknownParametersRule, + 'no-unknown-type-aliases': noUnknownTypeAliasesRule, + 'no-widen-then-assert': noWidenThenAssertRule, + }, +}); + +export default rulesPlugin; diff --git a/tools/oxlint/rules/lint.spec.ts b/tools/oxlint/rules/lint.spec.ts new file mode 100644 index 000000000..f860b1967 --- /dev/null +++ b/tools/oxlint/rules/lint.spec.ts @@ -0,0 +1,172 @@ +import { spawnSync } from 'node:child_process'; +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { afterAll, beforeAll, expect, it } from 'vitest'; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '../../..'); +let directory: string; + +beforeAll(() => { + directory = mkdtempSync(resolve(tmpdir(), 'panel-lint-')); + const config = JSON.parse(readFileSync(resolve(root, '.oxlintrc.json'), 'utf8')); + config.jsPlugins = config.jsPlugins.map((plugin: { name: string; specifier: string }) => ({ + ...plugin, + specifier: resolve(root, plugin.specifier), + })); + writeFileSync(resolve(directory, '.oxlintrc.json'), JSON.stringify(config)); +}); + +afterAll(() => rmSync(directory, { recursive: true, force: true })); + +const components = 'resources/scripts/components/Probe.tsx'; +const api = 'resources/scripts/api/queries.ts'; +const generated = 'resources/scripts/api/generated/types.gen.ts'; + +it.each([ + [ + 'rejects aliased generated imports', + components, + "import type { User } from '@/api/generated/types.gen';", + 'generated-api-imports', + ], + [ + 'rejects relative generated imports', + components, + "import type { User } from '../api/generated/types.gen';", + 'generated-api-imports', + ], + ['rejects generated re-exports', components, "export * from '../api/generated';", 'generated-api-imports'], + [ + 'rejects dynamic generated imports', + components, + "export const load = () => import('@/api/generated/sdk.gen');", + 'generated-api-imports', + ], + ['rejects Zustand imports outside state', components, "import { create } from 'zustand';", 'no-restricted-imports'], + [ + 'rejects Zustand subpath imports outside state', + components, + "import { createStore } from 'zustand/vanilla';", + 'no-restricted-imports', + ], + [ + 'rejects direct JSON transport', + api, + "export const load = () => http.get('/api/client');", + 'no-restricted-properties', + ], + [ + 'rejects handwritten JSON mutations', + api, + 'export const options = { mutationFn: save };', + 'generated-api-mutations', + ], + [ + 'rejects computed handwritten mutation keys', + api, + "export const options = { ['mutationFn']: save };", + 'generated-api-mutations', + ], + [ + 'rejects double assertions', + api, + 'export const value = input as unknown as string;', + 'no-chained-type-assertions', + ], + ['rejects empty generated types', generated, 'export type User = {};', 'no-empty-object-type'], + ['rejects unknown generated aliases', generated, 'export type UserResponse = unknown;', 'generated-api-types'], + ['rejects unknown generated properties', generated, 'export type User = { name: unknown };', 'generated-api-types'], + ['rejects unknown generated arrays', generated, 'export type Users = unknown[];', 'generated-api-types'], + [ + 'rejects nested unknown in accepted responses', + generated, + 'export type Responses = { 202: { body: unknown } };', + 'generated-api-types', + ], + [ + 'rejects palette classes', + components, + 'export const View = () =>
;', + 'design-tokens', + ], + [ + 'rejects hardcoded colors', + components, + "export const View = () =>
;", + 'design-tokens', + ], + ['rejects literal template colors', components, 'export const colors = `bg-red-500`;', 'design-tokens'], + ['rejects escaped template colors', components, 'export const colors = `bg-\\u0072ed-500`;', 'design-tokens'], + [ + 'rejects embedded font stacks', + components, + "export const View = () =>
;", + 'design-tokens', + ], + [ + 'rejects literal SVG palette paint', + components, + 'export const View = () => ;', + 'design-tokens', + ], +])('%s', (_name, path, source, rule) => { + const result = lint(path, source); + expect(result.status).toBe(1); + expect(result.diagnostics.some((diagnostic) => diagnostic.code?.includes(rule))).toBe(true); +}); + +it.each([ + ['allows API wrappers to import generated clients', api, "import { getUsers } from '@/api/generated/sdk.gen';"], + ['allows the shared SDK API runtime', 'resources/scripts/sdk/api.ts', "export * from '@/api/generated/client';"], + ['allows state modules to import Zustand', 'resources/scripts/state/probe.ts', "import { create } from 'zustand';"], + ['allows generated mutation options', api, 'export const options = { ...generatedMutation() };'], + [ + 'allows browser file transport and custom mutations', + 'resources/scripts/api/server/files/queries.ts', + "export const options = { mutationFn: () => http.put('/upload') };", + ], + [ + 'allows signed backup download mutations', + 'resources/scripts/api/server/backups/queries.ts', + 'export const options = { mutationFn: download };', + ], + ['allows concrete generated schemas', generated, 'export type User = { name: string };'], + ['allows a documented empty accepted response', generated, 'export type Responses = { 202: unknown };'], + [ + 'allows theme tokens', + components, + 'export const View = () =>
;', + ], + [ + 'ignores examples in comments', + components, + '// bg-red-500; mutationFn: save; http.get(); as unknown as\nexport const value = 1;', + ], + [ + 'ignores generated imports in unrelated strings', + components, + 'export const example = "import { User } from \'@/api/generated/types.gen\'";', + ], +])('%s', (_name, path, source) => { + const result = lint(path, source); + expect(result.diagnostics.filter((diagnostic) => diagnostic.severity === 'error')).toEqual([]); + expect(result.status).toBe(0); +}); + +function lint( + path: string, + source: string +): { status: number | null; diagnostics: { code?: string; severity: string }[] } { + const filename = resolve(directory, path); + mkdirSync(dirname(filename), { recursive: true }); + writeFileSync(filename, source); + const result = spawnSync(resolve(root, 'node_modules/.bin/oxlint'), ['--format', 'json', path], { + cwd: directory, + encoding: 'utf8', + }); + rmSync(filename); + expect(result.stderr).toBe(''); + return { status: result.status, diagnostics: JSON.parse(result.stdout).diagnostics }; +} diff --git a/tools/oxlint/rules/package.json b/tools/oxlint/rules/package.json new file mode 100644 index 000000000..44e4a84a6 --- /dev/null +++ b/tools/oxlint/rules/package.json @@ -0,0 +1,4 @@ +{ + "private": true, + "type": "module" +} diff --git a/tools/oxlint/rules/rules/design-tokens.ts b/tools/oxlint/rules/rules/design-tokens.ts new file mode 100644 index 000000000..149130508 --- /dev/null +++ b/tools/oxlint/rules/rules/design-tokens.ts @@ -0,0 +1,54 @@ +import { defineRule } from '@oxlint/plugins'; +import type { ESTree } from '@oxlint/plugins'; + +const palette = + 'slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose|white|black'; +export const paletteUtility = new RegExp( + `(? { + if (paletteUtility.test(value) || colorLiteral.test(value) || arbitraryUtility.test(value)) { + context.report({ node, messageId: 'token' }); + } + }; + return { + Literal(node) { + if (typeof node.value === 'string') check(node, node.value); + }, + TemplateElement: (node) => check(node, node.value.cooked ?? node.value.raw), + Property(node) { + if (node.key.type !== 'Identifier' || node.key.name !== 'fontFamily') return; + if ( + node.value.type !== 'Literal' || + typeof node.value.value !== 'string' || + node.value.value.startsWith('var(') + ) + return; + context.report({ node: node.value, messageId: 'token' }); + }, + JSXAttribute(node) { + if ( + node.name.type !== 'JSXIdentifier' || + !['fill', 'stroke', 'stopColor', 'floodColor'].includes(node.name.name) + ) + return; + const value = node.value?.type === 'JSXExpressionContainer' ? node.value.expression : node.value; + if (value?.type === 'Literal' && typeof value.value === 'string' && paintNames.test(value.value)) { + context.report({ node: value, messageId: 'token' }); + } + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/generated-api-imports.ts b/tools/oxlint/rules/rules/generated-api-imports.ts new file mode 100644 index 000000000..ebdfdb9ea --- /dev/null +++ b/tools/oxlint/rules/rules/generated-api-imports.ts @@ -0,0 +1,39 @@ +import { dirname, resolve, sep } from 'node:path'; +import { defineRule } from '@oxlint/plugins'; +import type { ESTree } from '@oxlint/plugins'; + +/** Keep generated transport details behind the panel API wrappers. */ +export const generatedApiImportsRule = defineRule({ + meta: { + type: 'problem', + messages: { boundary: 'Import the panel API wrapper instead of its generated transport.' }, + }, + create(context) { + const sourceRoot = resolve(context.cwd, 'resources/scripts'); + const apiRoot = resolve(sourceRoot, 'api'); + const generatedRoot = resolve(apiRoot, 'generated'); + const filename = resolve(context.filename); + if (filename.startsWith(apiRoot + sep) || filename === resolve(sourceRoot, 'sdk/api.ts')) return {}; + + const check = (source: ESTree.Expression) => { + if (source.type !== 'Literal' || typeof source.value !== 'string') return; + const imported = source.value; + const target = imported.startsWith('@/') + ? resolve(sourceRoot, imported.slice(2)) + : imported.startsWith('.') + ? resolve(dirname(filename), imported) + : null; + if (target !== generatedRoot && !target?.startsWith(generatedRoot + sep)) return; + context.report({ node: source, messageId: 'boundary' }); + }; + + return { + ImportDeclaration: (node) => check(node.source), + ExportNamedDeclaration: (node) => { + if (node.source) check(node.source); + }, + ExportAllDeclaration: (node) => check(node.source), + ImportExpression: (node) => check(node.source), + }; + }, +}); diff --git a/tools/oxlint/rules/rules/generated-api-mutations.ts b/tools/oxlint/rules/rules/generated-api-mutations.ts new file mode 100644 index 000000000..780e5f531 --- /dev/null +++ b/tools/oxlint/rules/rules/generated-api-mutations.ts @@ -0,0 +1,22 @@ +import { defineRule } from '@oxlint/plugins'; + +/** JSON API mutations use the options emitted by HeyAPI. */ +export const generatedApiMutationsRule = defineRule({ + meta: { + type: 'problem', + messages: { mutation: 'Use generated mutation options for JSON API requests.' }, + }, + create(context) { + return { + Property(node) { + const name = + node.key.type === 'Identifier' && !node.computed + ? node.key.name + : node.key.type === 'Literal' + ? node.key.value + : null; + if (name === 'mutationFn') context.report({ node: node.key, messageId: 'mutation' }); + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/generated-api-types.ts b/tools/oxlint/rules/rules/generated-api-types.ts new file mode 100644 index 000000000..47ad7a372 --- /dev/null +++ b/tools/oxlint/rules/rules/generated-api-types.ts @@ -0,0 +1,23 @@ +import { defineRule } from '@oxlint/plugins'; + +/** Generated contracts must carry schema types, including nested properties and arrays. */ +export const generatedApiTypesRule = defineRule({ + meta: { + type: 'problem', + messages: { unknown: 'Document a concrete OpenAPI schema instead of generating unknown.' }, + }, + create(context) { + return { + TSUnknownKeyword(node) { + const property = node.parent.parent; + if ( + property?.type === 'TSPropertySignature' && + property.key.type === 'Literal' && + property.key.value === 202 + ) + return; + context.report({ node, messageId: 'unknown' }); + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-chained-type-assertions.ts b/tools/oxlint/rules/rules/no-chained-type-assertions.ts new file mode 100644 index 000000000..2a2a082f9 --- /dev/null +++ b/tools/oxlint/rules/rules/no-chained-type-assertions.ts @@ -0,0 +1,76 @@ +import { defineRule } from '@oxlint/plugins'; +import type { ESTree } from '@oxlint/plugins'; + +type TypeAssertionExpression = ESTree.TSAsExpression | ESTree.TSTypeAssertion; + +function isTypeAssertionExpression(node: ESTree.Node): node is TypeAssertionExpression { + return node.type === 'TSAsExpression' || node.type === 'TSTypeAssertion'; +} + +function unwrapParenthesizedExpression(expression: ESTree.Expression): ESTree.Expression { + let current = expression; + while (current.type === 'ParenthesizedExpression') { + current = current.expression; + } + return current; +} + +function isConstAssertion(node: TypeAssertionExpression): boolean { + const { typeAnnotation } = node; + return ( + typeAnnotation.type === 'TSTypeReference' && + typeAnnotation.typeName.type === 'Identifier' && + typeAnnotation.typeName.name === 'const' + ); +} + +function isOutermostAssertionInChain(node: TypeAssertionExpression): boolean { + let current: ESTree.Expression = node; + let parent = node.parent; + + while (parent.type === 'ParenthesizedExpression' && parent.expression === current) { + current = parent; + parent = parent.parent; + } + + return !isTypeAssertionExpression(parent) || parent.expression !== current; +} + +function isForbiddenAssertionChain(node: TypeAssertionExpression): boolean { + let assertionCount = 0; + let hasNonConstAssertion = false; + let current: ESTree.Expression = node; + + while (isTypeAssertionExpression(current)) { + assertionCount += 1; + hasNonConstAssertion ||= !isConstAssertion(current); + current = unwrapParenthesizedExpression(current.expression); + } + + return assertionCount > 1 && hasNonConstAssertion; +} + +/** Disallow nested TypeScript type assertions, while permitting chains made only of const assertions. */ +export const noChainedTypeAssertionsRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: 'Disallow chained TypeScript as and angle-bracket assertions, including parenthesized chains.', + }, + messages: { + chained: + "Chained type assertions discard existing type evidence and fabricate the target type without parsing. Preserve the value's original precise type, or parse genuinely unknown input at its boundary before using it.", + }, + }, + create(context) { + const checkTypeAssertion = (node: TypeAssertionExpression) => { + if (!isOutermostAssertionInChain(node) || !isForbiddenAssertionChain(node)) return; + context.report({ node, messageId: 'chained' }); + }; + + return { + TSAsExpression: checkTypeAssertion, + TSTypeAssertion: checkTypeAssertion, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-conditional-empty-object-spread.ts b/tools/oxlint/rules/rules/no-conditional-empty-object-spread.ts new file mode 100644 index 000000000..87ee6ab99 --- /dev/null +++ b/tools/oxlint/rules/rules/no-conditional-empty-object-spread.ts @@ -0,0 +1,46 @@ +import { defineRule } from '@oxlint/plugins'; +import type { ESTree } from '@oxlint/plugins'; + +function unwrapParentheses(node: ESTree.Expression): ESTree.Expression { + let current = node; + while (current.type === 'ParenthesizedExpression') { + current = current.expression; + } + return current; +} + +function isEmptyObjectExpression(node: ESTree.Expression): boolean { + return node.type === 'ObjectExpression' && node.properties.length === 0; +} + +function isConditionalEmptyObjectSpread(node: ESTree.Expression): boolean { + const conditional = unwrapParentheses(node); + return ( + conditional.type === 'ConditionalExpression' && + (isEmptyObjectExpression(conditional.consequent) || isEmptyObjectExpression(conditional.alternate)) + ); +} + +/** Ban conditional empty-object spreads without changing their omission semantics. */ +export const noConditionalEmptyObjectSpreadRule = defineRule({ + meta: { + type: 'suggestion', + docs: { + description: 'Disallow object spreads that conditionally spread an empty object to omit fields.', + }, + messages: { + avoid: 'Do not use conditional empty-object spreads. Prefer a direct property or build the object in separate statements.', + }, + }, + create(context) { + return { + SpreadElement(node) { + if (node.parent.type !== 'ObjectExpression') return; + + if (isConditionalEmptyObjectSpread(node.argument)) { + context.report({ node, messageId: 'avoid' }); + } + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-known-value-widening.ts b/tools/oxlint/rules/rules/no-known-value-widening.ts new file mode 100644 index 000000000..cb3bf07bd --- /dev/null +++ b/tools/oxlint/rules/rules/no-known-value-widening.ts @@ -0,0 +1,218 @@ +import { defineRule } from '@oxlint/plugins'; + +import { + classifyWideningTarget, + createTypeEnvironment, + isKnownEvidenceExpression, + type TypeEnvironment, + type WideningTarget, +} from '../shared/dictionary-types.ts'; + +import type { ESTree, Scope, SourceCode, Variable } from '@oxlint/plugins'; + +type FunctionExpression = ESTree.ArrowFunctionExpression | ESTree.Function; + +function unwrapExpression(expression: ESTree.Expression): ESTree.Expression { + let current = expression; + while ( + current.type === 'ParenthesizedExpression' || + current.type === 'TSAsExpression' || + current.type === 'TSSatisfiesExpression' || + current.type === 'TSTypeAssertion' || + current.type === 'TSNonNullExpression' + ) { + current = current.expression; + } + return current; +} + +function resolveVariable(sourceCode: SourceCode, identifier: ESTree.IdentifierReference): Variable | null { + let scope: Scope | null = sourceCode.getScope(identifier); + while (scope !== null) { + const variable = scope.set.get(identifier.name); + if (variable !== undefined) return variable; + scope = scope.upper; + } + return null; +} + +function variableDeclarator(variable: Variable): ESTree.VariableDeclarator | null { + if (variable.defs.length !== 1) return null; + const [definition] = variable.defs; + return definition?.type === 'Variable' && definition.node.type === 'VariableDeclarator' ? definition.node : null; +} + +function isStableConstVariable(variable: Variable, declarator: ESTree.VariableDeclarator): boolean { + return ( + declarator.parent.type === 'VariableDeclaration' && + declarator.parent.kind === 'const' && + variable.references.every((reference) => reference.init || !reference.isWrite()) + ); +} + +function hasKnownEvidence( + sourceCode: SourceCode, + expression: ESTree.Expression, + visitedVariables = new Set() +): boolean { + if (isKnownEvidenceExpression(expression)) return true; + const unwrapped = unwrapExpression(expression); + if (unwrapped.type !== 'Identifier') return false; + const variable = resolveVariable(sourceCode, unwrapped); + if (variable === null || visitedVariables.has(variable)) return false; + const declarator = variableDeclarator(variable); + if (declarator === null || declarator.init === null || !isStableConstVariable(variable, declarator)) { + return false; + } + visitedVariables.add(variable); + return hasKnownEvidence(sourceCode, declarator.init, visitedVariables); +} + +function annotationTarget( + annotation: ESTree.TSTypeAnnotation | null | undefined, + environment: TypeEnvironment +): WideningTarget | null { + return annotation === null || annotation === undefined + ? null + : classifyWideningTarget(annotation.typeAnnotation, environment); +} + +function enclosingFunction(node: ESTree.Node): FunctionExpression | null { + let current: ESTree.Node | null = node.parent; + while (current !== null && current.type !== 'Program') { + if ( + current.type === 'ArrowFunctionExpression' || + current.type === 'FunctionDeclaration' || + current.type === 'FunctionExpression' + ) { + return current; + } + current = current.parent; + } + return null; +} + +function sourceKeyName(sourceCode: SourceCode, key: ESTree.PropertyKey): string { + if (key.type === 'Identifier' || key.type === 'PrivateIdentifier') return key.name; + if (key.type === 'Literal') return String(key.value); + return sourceCode.getText(key); +} + +function functionName(sourceCode: SourceCode, owner: FunctionExpression | null): string { + if (owner === null) return 'anonymous function'; + if (owner.id !== null) return owner.id.name; + const parent = owner.parent; + if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') return parent.id.name; + if (parent.type === 'MethodDefinition') return sourceKeyName(sourceCode, parent.key); + return 'anonymous function'; +} + +function isEmptyObjectExpression(expression: ESTree.Expression): boolean { + const unwrapped = unwrapExpression(expression); + return unwrapped.type === 'ObjectExpression' && unwrapped.properties.length === 0; +} + +function isDictionaryAccumulatorTarget(destination: WideningTarget): boolean { + return destination.kind === 'open dictionary' || destination.kind === 'generic container'; +} + +function hasParentAssertion(node: ESTree.Node): boolean { + return node.parent?.type === 'TSAsExpression' || node.parent?.type === 'TSTypeAssertion'; +} + +/** Detect sound syntactic cases where a known value is explicitly widened and loses evidence. */ +export const noKnownValueWideningRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow syntactically established values from flowing into explicitly broad or anonymous target types that discard useful evidence.', + }, + messages: { + widening: + 'The known initializer supplying {{subject}} carries established type evidence, but the explicit {{target}} target type discards it. Preserve inference, use `satisfies`, or introduce/use a named owner contract; parse genuinely external data once at its boundary.', + }, + }, + createOnce(context) { + let environment: TypeEnvironment | null = null; + + const reportFlow = (expression: ESTree.Expression, destination: WideningTarget | null, subject: string) => { + if (destination === null) return; + if (isDictionaryAccumulatorTarget(destination) && isEmptyObjectExpression(expression)) { + return; + } + if (!hasKnownEvidence(context.sourceCode, expression)) return; + context.report({ + node: expression, + messageId: 'widening', + data: { subject, target: destination.kind }, + }); + }; + + const targetFromAnnotation = (annotation: ESTree.TSTypeAnnotation | null | undefined) => + environment === null ? null : annotationTarget(annotation, environment); + + return { + Program(node) { + environment = createTypeEnvironment(node); + }, + VariableDeclarator(node) { + if (node.init === null || node.id.type !== 'Identifier') return; + reportFlow(node.init, targetFromAnnotation(node.id.typeAnnotation), `binding \`${node.id.name}\``); + }, + PropertyDefinition(node) { + if (node.value === null) return; + reportFlow( + node.value, + targetFromAnnotation(node.typeAnnotation), + `property \`${sourceKeyName(context.sourceCode, node.key)}\`` + ); + }, + AccessorProperty(node) { + if (node.value === null) return; + reportFlow( + node.value, + targetFromAnnotation(node.typeAnnotation), + `property \`${sourceKeyName(context.sourceCode, node.key)}\`` + ); + }, + AssignmentExpression(node) { + if (node.operator !== '=' || node.left.type !== 'Identifier') return; + const variable = resolveVariable(context.sourceCode, node.left); + if (variable === null) return; + const declarator = variableDeclarator(variable); + if (declarator === null || declarator.id.type !== 'Identifier') return; + reportFlow( + node.right, + targetFromAnnotation(declarator.id.typeAnnotation), + `binding \`${declarator.id.name}\`` + ); + }, + ReturnStatement(node) { + if (node.argument === null) return; + const owner = enclosingFunction(node); + reportFlow( + node.argument, + targetFromAnnotation(owner?.returnType), + `return value of \`${functionName(context.sourceCode, owner)}\`` + ); + }, + ArrowFunctionExpression(node) { + if (node.body.type === 'BlockStatement') return; + reportFlow( + node.body, + targetFromAnnotation(node.returnType), + `return value of \`${functionName(context.sourceCode, node)}\`` + ); + }, + TSAsExpression(node) { + if (environment === null || hasParentAssertion(node)) return; + reportFlow(node.expression, classifyWideningTarget(node.typeAnnotation, environment), 'assertion'); + }, + TSTypeAssertion(node) { + if (environment === null || hasParentAssertion(node)) return; + reportFlow(node.expression, classifyWideningTarget(node.typeAnnotation, environment), 'assertion'); + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-object-parameters.ts b/tools/oxlint/rules/rules/no-object-parameters.ts new file mode 100644 index 000000000..bad22bead --- /dev/null +++ b/tools/oxlint/rules/rules/no-object-parameters.ts @@ -0,0 +1,110 @@ +import { defineRule } from '@oxlint/plugins'; + +import type { ESTree, SourceCode } from '@oxlint/plugins'; + +type Parameter = ESTree.ParamPattern; +type ParameterOwner = + | ESTree.ArrowFunctionExpression + | ESTree.Function + | ESTree.TSCallSignatureDeclaration + | ESTree.TSConstructSignatureDeclaration + | ESTree.TSConstructorType + | ESTree.TSFunctionType + | ESTree.TSMethodSignature; + +function parameterAnnotation(parameter: Parameter): ESTree.TSTypeAnnotation | null | undefined { + if (parameter.type === 'TSParameterProperty') { + return parameterAnnotation(parameter.parameter); + } + if (parameter.type === 'RestElement') { + return parameter.typeAnnotation ?? parameterAnnotation(parameter.argument); + } + if (parameter.type === 'AssignmentPattern') { + return parameter.typeAnnotation ?? parameter.left.typeAnnotation; + } + return parameter.typeAnnotation; +} + +function parameterName(parameter: Parameter, sourceCode: SourceCode): string { + return parameter.type === 'Identifier' + ? parameter.name + : sourceCode.getText(parameter).replace(/\s*:\s*object\s*$/u, ''); +} + +/** Ban the broad object type on function inputs, including local aliases to object. */ +export const noObjectParametersRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow object function parameters; inputs must use an owner-provided type and be parsed at their boundary.', + }, + messages: { + objectParameter: + 'Parameter `{{parameter}}` accepts the broad `object` type. Use the expected owner type or decode the external input at its boundary.', + }, + }, + create(context) { + const aliases = new Map(); + + const resolvesToObject = (type: ESTree.TSType, visited = new Set()): boolean => { + if (type.type === 'TSObjectKeyword') return true; + if (type.type === 'TSParenthesizedType') return resolvesToObject(type.typeAnnotation, visited); + if (type.type === 'TSUnionType') { + return type.types.some((member) => resolvesToObject(member, visited)); + } + if ( + type.type !== 'TSTypeReference' || + type.typeName.type !== 'Identifier' || + (type.typeArguments !== null && + type.typeArguments !== undefined && + type.typeArguments.params.length > 0) || + visited.has(type.typeName.name) + ) { + return false; + } + const alias = aliases.get(type.typeName.name); + if (alias === undefined) return false; + const nextVisited = new Set(visited); + nextVisited.add(type.typeName.name); + return resolvesToObject(alias, nextVisited); + }; + + const checkParameters = (node: ParameterOwner) => { + for (const parameter of node.params) { + const annotation = parameterAnnotation(parameter); + if (annotation === null || annotation === undefined) continue; + if (!resolvesToObject(annotation.typeAnnotation)) continue; + context.report({ + node: annotation.typeAnnotation, + messageId: 'objectParameter', + data: { parameter: parameterName(parameter, context.sourceCode) }, + }); + } + }; + + return { + Program(node) { + for (const statement of node.body) { + const declaration = statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement; + if ( + declaration?.type === 'TSTypeAliasDeclaration' && + (declaration.typeParameters === null || declaration.typeParameters === undefined) + ) { + aliases.set(declaration.id.name, declaration.typeAnnotation); + } + } + }, + ArrowFunctionExpression: checkParameters, + FunctionDeclaration: checkParameters, + FunctionExpression: checkParameters, + TSCallSignatureDeclaration: checkParameters, + TSConstructSignatureDeclaration: checkParameters, + TSConstructorType: checkParameters, + TSDeclareFunction: checkParameters, + TSEmptyBodyFunctionExpression: checkParameters, + TSFunctionType: checkParameters, + TSMethodSignature: checkParameters, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-runtime-typeof.ts b/tools/oxlint/rules/rules/no-runtime-typeof.ts new file mode 100644 index 000000000..fd1e2cc98 --- /dev/null +++ b/tools/oxlint/rules/rules/no-runtime-typeof.ts @@ -0,0 +1,25 @@ +import { defineRule } from '@oxlint/plugins'; + +/** Disallow runtime typeof checks that narrow unparsed values instead of decoding them. */ +export const noRuntimeTypeofRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow runtime typeof checks; external values must be decoded into meaningful types at their I/O boundary.', + }, + messages: { + runtimeTypeof: + 'A runtime `typeof` check only narrows an unparsed representation; it does not establish the expected contract. Parse the value into a strongly typed domain type at the earliest possible point, as close as possible to the I/O boundary where the data originated.', + }, + }, + create(context) { + return { + UnaryExpression(node) { + if (node.operator === 'typeof') { + context.report({ node, messageId: 'runtimeTypeof' }); + } + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-shape-in-symbol-names.ts b/tools/oxlint/rules/rules/no-shape-in-symbol-names.ts new file mode 100644 index 000000000..d273b19d7 --- /dev/null +++ b/tools/oxlint/rules/rules/no-shape-in-symbol-names.ts @@ -0,0 +1,39 @@ +import { defineRule } from '@oxlint/plugins'; +import type { ESTree } from '@oxlint/plugins'; + +const FORBIDDEN_SYMBOL_NAME = 'shape'; + +function containsForbiddenSymbolName(name: string): boolean { + return name.toLowerCase().includes(FORBIDDEN_SYMBOL_NAME); +} + +/** Ban the case-insensitive substring "shape" in every JavaScript and TypeScript symbol name. */ +export const noForbiddenTermInSymbolNamesRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow the case-insensitive substring "shape" in JavaScript, TypeScript, private, and JSX symbol names.', + }, + messages: { + forbiddenSymbolName: + 'Do not use the case-insensitive substring "shape" in symbol names (found "{{name}}").', + }, + }, + create(context) { + const reportForbiddenSymbolName = (node: ESTree.Node & { name: string }) => { + if (!containsForbiddenSymbolName(node.name)) return; + context.report({ + node, + messageId: 'forbiddenSymbolName', + data: { name: node.name }, + }); + }; + + return { + Identifier: reportForbiddenSymbolName, + PrivateIdentifier: reportForbiddenSymbolName, + JSXIdentifier: reportForbiddenSymbolName, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-unknown-parameters.ts b/tools/oxlint/rules/rules/no-unknown-parameters.ts new file mode 100644 index 000000000..f298bcdf4 --- /dev/null +++ b/tools/oxlint/rules/rules/no-unknown-parameters.ts @@ -0,0 +1,81 @@ +import { defineRule } from '@oxlint/plugins'; +import type { ESTree } from '@oxlint/plugins'; + +type Parameter = ESTree.ParamPattern; +type ParameterOwner = + | ESTree.ArrowFunctionExpression + | ESTree.Function + | ESTree.TSCallSignatureDeclaration + | ESTree.TSConstructSignatureDeclaration + | ESTree.TSConstructorType + | ESTree.TSFunctionType + | ESTree.TSMethodSignature; + +function parameterAnnotation(parameter: Parameter): ESTree.TSTypeAnnotation | null | undefined { + if (parameter.type === 'TSParameterProperty') { + return parameterAnnotation(parameter.parameter); + } + if (parameter.type === 'RestElement') { + return parameter.typeAnnotation ?? parameterAnnotation(parameter.argument); + } + if (parameter.type === 'AssignmentPattern') { + return parameter.typeAnnotation ?? parameter.left.typeAnnotation; + } + return parameter.typeAnnotation; +} + +function parameterName(parameter: Parameter, sourceText: string): string { + if (parameter.type === 'TSParameterProperty') { + return parameterName(parameter.parameter, sourceText); + } + if (parameter.type === 'AssignmentPattern') { + return parameterName(parameter.left, sourceText); + } + if (parameter.type === 'RestElement') { + return parameterName(parameter.argument, sourceText); + } + return parameter.type === 'Identifier' ? parameter.name : sourceText.replace(/\s*:\s*unknown\s*$/u, ''); +} + +/** Disallow unknown inputs except explicitly named error-cause enrichment. */ +export const noUnknownParametersRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow explicitly unknown function parameters except `cause`; decode unknown input at its I/O boundary instead.', + }, + messages: { + unknownParameter: + 'Parameter `{{parameter}}` accepts `unknown` without establishing its contract. Define the expected schema or parser so the value becomes a strongly typed domain type at the earliest possible point, as close as possible to the I/O boundary where the data originated.', + }, + }, + create(context) { + const checkParameters = (node: ParameterOwner) => { + for (const parameter of node.params) { + const annotation = parameterAnnotation(parameter); + if (annotation?.typeAnnotation.type !== 'TSUnknownKeyword') continue; + const name = parameterName(parameter, context.sourceCode.getText(parameter)); + if (name === 'cause') continue; + context.report({ + node: annotation.typeAnnotation, + messageId: 'unknownParameter', + data: { parameter: name }, + }); + } + }; + + return { + ArrowFunctionExpression: checkParameters, + FunctionDeclaration: checkParameters, + FunctionExpression: checkParameters, + TSCallSignatureDeclaration: checkParameters, + TSConstructSignatureDeclaration: checkParameters, + TSConstructorType: checkParameters, + TSDeclareFunction: checkParameters, + TSEmptyBodyFunctionExpression: checkParameters, + TSFunctionType: checkParameters, + TSMethodSignature: checkParameters, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-unknown-type-aliases.ts b/tools/oxlint/rules/rules/no-unknown-type-aliases.ts new file mode 100644 index 000000000..2de263d92 --- /dev/null +++ b/tools/oxlint/rules/rules/no-unknown-type-aliases.ts @@ -0,0 +1,62 @@ +import { defineRule } from '@oxlint/plugins'; + +import type { ESTree } from '@oxlint/plugins'; + +function referencedAliasName(type: ESTree.TSType): string | null { + if (type.type === 'TSParenthesizedType') return referencedAliasName(type.typeAnnotation); + if (type.type !== 'TSTypeReference' || type.typeName.type !== 'Identifier') return null; + return type.typeArguments === null || type.typeArguments === undefined || type.typeArguments.params.length === 0 + ? type.typeName.name + : null; +} + +/** Ban named aliases that merely conceal TypeScript's unknown top type. */ +export const noUnknownTypeAliasesRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow type aliases whose resolved type is unknown; unknown must remain visible at an allowed boundary.', + }, + messages: { + unknownAlias: + 'Type alias `{{alias}}` only renames `unknown`. Keep `unknown` explicit on an allowed `cause` field or replace it with the parsed owner type.', + }, + }, + create(context) { + const aliases = new Map(); + + const resolvesToUnknown = (type: ESTree.TSType, visited = new Set()): boolean => { + if (type.type === 'TSUnknownKeyword') return true; + if (type.type === 'TSParenthesizedType') return resolvesToUnknown(type.typeAnnotation, visited); + const name = referencedAliasName(type); + if (name === null || visited.has(name)) return false; + const alias = aliases.get(name); + if (alias === undefined || (alias.typeParameters !== null && alias.typeParameters !== undefined)) { + return false; + } + const nextVisited = new Set(visited); + nextVisited.add(name); + return resolvesToUnknown(alias.typeAnnotation, nextVisited); + }; + + return { + Program(node) { + for (const statement of node.body) { + const declaration = statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement; + if (declaration?.type === 'TSTypeAliasDeclaration') { + aliases.set(declaration.id.name, declaration); + } + } + for (const alias of aliases.values()) { + if (!resolvesToUnknown(alias.typeAnnotation, new Set([alias.id.name]))) continue; + context.report({ + node: alias.id, + messageId: 'unknownAlias', + data: { alias: alias.id.name }, + }); + } + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-unsafe-dictionary-type.ts b/tools/oxlint/rules/rules/no-unsafe-dictionary-type.ts new file mode 100644 index 000000000..7d464ad46 --- /dev/null +++ b/tools/oxlint/rules/rules/no-unsafe-dictionary-type.ts @@ -0,0 +1,86 @@ +import { defineRule } from '@oxlint/plugins'; + +import { + classifyUnsafeDictionary, + classifyUnsafeDictionaryValue, + createTypeEnvironment, + type TypeEnvironment, +} from '../shared/dictionary-types.ts'; + +import type { ESTree } from '@oxlint/plugins'; + +function isTypeNode(node: ESTree.Node): node is ESTree.TSType { + return node.type.startsWith('TS') && node.type !== 'TSTypeAnnotation'; +} + +function typeReferenceName(type: ESTree.TSTypeReference): string | null { + return type.typeName.type === 'Identifier' ? type.typeName.name : null; +} + +function isInsideTypeAliasDeclaration(node: ESTree.Node): boolean { + let current: ESTree.Node | null = node.parent; + while (current !== null && current.type !== 'Program') { + if (current.type === 'TSTypeAliasDeclaration') return true; + current = current.parent; + } + return false; +} + +function isPlainAliasConsumerUse(node: ESTree.TSType, environment: TypeEnvironment): boolean { + if (node.type !== 'TSTypeReference' || node.typeArguments?.params.length) return false; + const name = typeReferenceName(node); + return name !== null && environment.aliases.has(name) && !isInsideTypeAliasDeclaration(node); +} + +function shouldReportType(node: ESTree.TSType, environment: TypeEnvironment): boolean { + if (isPlainAliasConsumerUse(node, environment)) return false; + if (classifyUnsafeDictionary(node, environment) === null) return false; + let current: ESTree.Node | null = node.parent; + while (current !== null && current.type !== 'Program') { + if (isTypeNode(current) && classifyUnsafeDictionary(current, environment) !== null) return false; + current = current.parent; + } + return true; +} + +/** Disallow object-dictionary contracts whose direct value type is an unsafe escape hatch. */ +export const noUnsafeDictionaryTypeRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow object-dictionary contracts whose direct value type is unknown, any, object, {}, or a union/alias containing one of those escape hatches.', + }, + messages: { + unsafeDictionary: + "This object dictionary's direct value type is an unsafe {{value}} escape hatch. Replace it with a concrete owner/schema-derived value type and parse external data at its boundary.", + }, + }, + createOnce(context) { + let environment: TypeEnvironment | null = null; + const report = (node: ESTree.Node, value: string) => { + context.report({ node, messageId: 'unsafeDictionary', data: { value } }); + }; + const reportIfUnsafe = (node: ESTree.TSType) => { + if (environment === null || !shouldReportType(node, environment)) return; + const unsafe = classifyUnsafeDictionary(node, environment); + if (unsafe === null) return; + report(node, unsafe.unsafeValue); + }; + + return { + Program(node) { + environment = createTypeEnvironment(node); + }, + TSTypeReference: reportIfUnsafe, + TSTypeLiteral: reportIfUnsafe, + TSMappedType: reportIfUnsafe, + TSIndexSignature(node) { + if (environment === null || node.typeAnnotation === null || node.parent.type === 'TSTypeLiteral') + return; + const unsafe = classifyUnsafeDictionaryValue(node.typeAnnotation.typeAnnotation, environment); + if (unsafe !== null) report(node, unsafe.unsafeValue); + }, + }; + }, +}); diff --git a/tools/oxlint/rules/rules/no-widen-then-assert.ts b/tools/oxlint/rules/rules/no-widen-then-assert.ts new file mode 100644 index 000000000..fb8346c3c --- /dev/null +++ b/tools/oxlint/rules/rules/no-widen-then-assert.ts @@ -0,0 +1,340 @@ +import { defineRule } from '@oxlint/plugins'; +import type { ESTree, Variable } from '@oxlint/plugins'; + +type BroadTypeKind = 'top' | 'object' | 'record'; + +type KnownValueEvidence = { + readonly type: ESTree.TSType | null; +}; + +const functionBoundaryTypes = new Set([ + 'ArrowFunctionExpression', + 'FunctionDeclaration', + 'FunctionExpression', + 'TSDeclareFunction', + 'TSEmptyBodyFunctionExpression', +]); + +function unwrapExpressionParentheses(expression: ESTree.Expression): ESTree.Expression { + let current = expression; + while (current.type === 'ParenthesizedExpression') current = current.expression; + return current; +} + +function unwrapTypeParentheses(type: ESTree.TSType): ESTree.TSType { + let current = type; + while (current.type === 'TSParenthesizedType') current = current.typeAnnotation; + return current; +} + +function typeReferenceName(type: ESTree.TSTypeReference): string | null { + return type.typeName.type === 'Identifier' ? type.typeName.name : null; +} + +function isUnknownOrAnyType(type: ESTree.TSType): boolean { + const unwrapped = unwrapTypeParentheses(type); + return unwrapped.type === 'TSUnknownKeyword' || unwrapped.type === 'TSAnyKeyword'; +} + +function isBroadRecordKeyType(type: ESTree.TSType): boolean { + const unwrapped = unwrapTypeParentheses(type); + if ( + unwrapped.type === 'TSStringKeyword' || + unwrapped.type === 'TSNumberKeyword' || + unwrapped.type === 'TSSymbolKeyword' + ) { + return true; + } + if (unwrapped.type === 'TSUnionType') return unwrapped.types.every(isBroadRecordKeyType); + return unwrapped.type === 'TSTypeReference' && typeReferenceName(unwrapped) === 'PropertyKey'; +} + +function isBroadRecordType(type: ESTree.TSType): boolean { + const unwrapped = unwrapTypeParentheses(type); + + if (unwrapped.type === 'TSTypeReference') { + if (typeReferenceName(unwrapped) === 'Readonly') { + const [inner] = unwrapped.typeArguments?.params ?? []; + return inner !== undefined && isBroadRecordType(inner); + } + + if (typeReferenceName(unwrapped) !== 'Record') return false; + const parameters = unwrapped.typeArguments?.params ?? []; + return ( + parameters.length === 2 && + parameters[0] !== undefined && + parameters[1] !== undefined && + isBroadRecordKeyType(parameters[0]) && + isUnknownOrAnyType(parameters[1]) + ); + } + + if (unwrapped.type !== 'TSTypeLiteral' || unwrapped.members.length !== 1) return false; + const [member] = unwrapped.members; + const [parameter] = member?.type === 'TSIndexSignature' ? member.parameters : []; + return ( + member?.type === 'TSIndexSignature' && + member.parameters.length === 1 && + parameter !== undefined && + isBroadRecordKeyType(parameter.typeAnnotation.typeAnnotation) && + isUnknownOrAnyType(member.typeAnnotation.typeAnnotation) + ); +} + +function broadTypeKind(type: ESTree.TSType): BroadTypeKind | null { + const unwrapped = unwrapTypeParentheses(type); + if (unwrapped.type === 'TSUnknownKeyword' || unwrapped.type === 'TSAnyKeyword') return 'top'; + if (unwrapped.type === 'TSObjectKeyword') return 'object'; + return isBroadRecordType(unwrapped) ? 'record' : null; +} + +function assertedExpression(node: ESTree.TSAsExpression | ESTree.TSTypeAssertion): ESTree.Expression { + return unwrapExpressionParentheses(node.expression); +} + +function assertionFromExpression(expression: ESTree.Expression): ESTree.TSAsExpression | ESTree.TSTypeAssertion | null { + const unwrapped = unwrapExpressionParentheses(expression); + return unwrapped.type === 'TSAsExpression' || unwrapped.type === 'TSTypeAssertion' ? unwrapped : null; +} + +function normalizedTypeText(sourceText: string, type: ESTree.TSType): string { + return sourceText.slice(type.start, type.end).replaceAll(/\s+/gu, ''); +} + +function typesHaveSameSyntax(sourceText: string, left: ESTree.TSType | null, right: ESTree.TSType): boolean { + return ( + left !== null && + normalizedTypeText(sourceText, unwrapTypeParentheses(left)) === + normalizedTypeText(sourceText, unwrapTypeParentheses(right)) + ); +} + +function isDefinitelyObjectType(type: ESTree.TSType): boolean { + const unwrapped = unwrapTypeParentheses(type); + switch (unwrapped.type) { + case 'TSArrayType': + case 'TSConstructorType': + case 'TSFunctionType': + case 'TSMappedType': + case 'TSObjectKeyword': + case 'TSTupleType': + return true; + case 'TSTypeLiteral': + return unwrapped.members.length > 0; + case 'TSIntersectionType': + return unwrapped.types.every(isDefinitelyObjectType); + case 'TSTypeOperator': + return unwrapped.operator === 'readonly' && isDefinitelyObjectType(unwrapped.typeAnnotation); + default: + return false; + } +} + +function isDefinitelyNarrowerRecordType(type: ESTree.TSType): boolean { + const unwrapped = unwrapTypeParentheses(type); + if (unwrapped.type === 'TSTypeLiteral') { + return unwrapped.members.some((member) => member.type !== 'TSIndexSignature'); + } + + if (unwrapped.type !== 'TSTypeReference') return false; + if (typeReferenceName(unwrapped) === 'Readonly') { + const [inner] = unwrapped.typeArguments?.params ?? []; + return inner !== undefined && isDefinitelyNarrowerRecordType(inner); + } + if (typeReferenceName(unwrapped) !== 'Record') return false; + + const parameters = unwrapped.typeArguments?.params ?? []; + return parameters.length === 2 && parameters[1] !== undefined && !isUnknownOrAnyType(parameters[1]); +} + +function functionBoundary(node: ESTree.Node): ESTree.Node | null { + let current = node.parent; + while (current !== null && current.type !== 'Program') { + if (functionBoundaryTypes.has(current.type)) return current; + current = current.parent; + } + return null; +} + +function resolvedVariableForIdentifier( + scopes: readonly { + readonly references: readonly { + readonly identifier: ESTree.Node; + readonly resolved: Variable | null; + }[]; + }[], + identifier: ESTree.IdentifierReference +): Variable | null { + for (const scope of scopes) { + const reference = scope.references.find( + (candidate) => + candidate.identifier.start === identifier.start && candidate.identifier.end === identifier.end + ); + if (reference !== undefined) return reference.resolved; + } + return null; +} + +function variableDeclarator(variable: Variable): ESTree.VariableDeclarator | null { + for (const definition of variable.defs) { + if (definition.type === 'Variable' && definition.node.type === 'VariableDeclarator') { + return definition.node; + } + } + return null; +} + +function knownValueEvidence( + expression: ESTree.Expression, + scopes: Parameters[0], + boundary: ESTree.Node | null, + visitedVariables: ReadonlySet +): KnownValueEvidence | null { + const unwrapped = unwrapExpressionParentheses(expression); + + if (unwrapped.type === 'TSAsExpression' || unwrapped.type === 'TSTypeAssertion') { + if (broadTypeKind(unwrapped.typeAnnotation) !== null) return null; + return { type: unwrapped.typeAnnotation }; + } + + if (unwrapped.type === 'Literal' || unwrapped.type === 'TemplateLiteral') { + return { type: null }; + } + + if ( + unwrapped.type === 'ArrayExpression' || + unwrapped.type === 'ArrowFunctionExpression' || + unwrapped.type === 'ClassExpression' || + unwrapped.type === 'FunctionExpression' || + unwrapped.type === 'NewExpression' || + unwrapped.type === 'ObjectExpression' + ) { + return { type: null }; + } + + if (unwrapped.type !== 'Identifier') return null; + const variable = resolvedVariableForIdentifier(scopes, unwrapped); + if (variable === null || visitedVariables.has(variable)) return null; + + const annotatedIdentifier = variable.identifiers.find( + (identifier) => identifier.typeAnnotation !== null && identifier.typeAnnotation !== undefined + ); + const annotation = annotatedIdentifier?.typeAnnotation?.typeAnnotation; + if (annotation !== undefined && annotatedIdentifier !== undefined) { + if (functionBoundary(annotatedIdentifier) !== boundary || broadTypeKind(annotation) !== null) { + return null; + } + return { type: annotation }; + } + + const declarator = variableDeclarator(variable); + if ( + declarator === null || + declarator.parent.type !== 'VariableDeclaration' || + declarator.parent.kind !== 'const' || + declarator.init === null || + variable.references.some((reference) => reference.isWrite() && !reference.init) || + functionBoundary(declarator) !== boundary + ) { + return null; + } + + return knownValueEvidence(declarator.init, scopes, boundary, new Set([...visitedVariables, variable])); +} + +function widenedBinding( + variable: Variable, + scopes: Parameters[0] +): { + readonly broadKind: BroadTypeKind; + readonly evidence: KnownValueEvidence; + readonly declaredAt: number; + readonly boundary: ESTree.Node | null; +} | null { + const declarator = variableDeclarator(variable); + if ( + declarator === null || + declarator.parent.type !== 'VariableDeclaration' || + declarator.parent.kind !== 'const' || + declarator.id.type !== 'Identifier' || + declarator.init === null || + variable.references.some((reference) => reference.isWrite() && !reference.init) + ) { + return null; + } + + const boundary = functionBoundary(declarator); + const declaredType = declarator.id.typeAnnotation?.typeAnnotation; + const initializerAssertion = assertionFromExpression(declarator.init); + const initializerBroadKind = + initializerAssertion === null ? null : broadTypeKind(initializerAssertion.typeAnnotation); + const declaredBroadKind = declaredType === undefined ? null : broadTypeKind(declaredType); + const broadKind = declaredBroadKind ?? initializerBroadKind; + if (broadKind === null) return null; + + const originalExpression = + initializerAssertion !== null && initializerBroadKind !== null + ? assertedExpression(initializerAssertion) + : declarator.init; + const evidence = knownValueEvidence(originalExpression, scopes, boundary, new Set([variable])); + return evidence === null ? null : { broadKind, evidence, declaredAt: declarator.end, boundary }; +} + +function assertionIsNarrower( + sourceText: string, + broadKind: BroadTypeKind, + evidence: KnownValueEvidence, + assertedType: ESTree.TSType +): boolean { + if (broadTypeKind(assertedType) !== null) return false; + if (broadKind === 'top') return true; + if (typesHaveSameSyntax(sourceText, evidence.type, assertedType)) return true; + if (broadKind === 'object') return isDefinitelyObjectType(assertedType); + return isDefinitelyNarrowerRecordType(assertedType); +} + +/** Detect immutable local bindings that erase a known type and are later asserted back to a narrower type. */ +export const noWidenThenAssertRule = defineRule({ + meta: { + type: 'problem', + docs: { + description: + 'Disallow local const flows that explicitly widen a known value before asserting the widened binding to a narrower type.', + }, + messages: { + widenThenAssert: + 'Binding "{{name}}" erases established type evidence by widening the value, then reconstructs that evidence with a type assertion. Preserve the precise type end-to-end; if the input is genuinely unknown, parse it once at the boundary instead.', + }, + }, + create(context) { + const scopes = context.sourceCode.scopeManager.scopes; + + const checkAssertion = (node: ESTree.TSAsExpression | ESTree.TSTypeAssertion) => { + const expression = assertedExpression(node); + if (expression.type !== 'Identifier') return; + + const variable = resolvedVariableForIdentifier(scopes, expression); + if (variable === null) return; + const widened = widenedBinding(variable, scopes); + if ( + widened === null || + node.start <= widened.declaredAt || + functionBoundary(node) !== widened.boundary || + !assertionIsNarrower(context.sourceCode.text, widened.broadKind, widened.evidence, node.typeAnnotation) + ) { + return; + } + + context.report({ + node, + messageId: 'widenThenAssert', + data: { name: expression.name }, + }); + }; + + return { + TSAsExpression: checkAssertion, + TSTypeAssertion: checkAssertion, + }; + }, +}); diff --git a/tools/oxlint/rules/shared/dictionary-types.ts b/tools/oxlint/rules/shared/dictionary-types.ts new file mode 100644 index 000000000..138e4db52 --- /dev/null +++ b/tools/oxlint/rules/shared/dictionary-types.ts @@ -0,0 +1,398 @@ +import type { ESTree } from '@oxlint/plugins'; + +const BUILT_INS = new Set(['Record', 'Readonly', 'Partial', 'Required', 'Pick', 'Omit', 'PropertyKey', 'NonNullable']); +const TRANSPARENT_WRAPPERS = new Set(['Readonly', 'Partial', 'Required', 'NonNullable']); + +type TypeAliasEnvironment = ReadonlyMap; + +type ResolvedType = { + readonly type: ESTree.TSType; + readonly substitutions: TypeAliasEnvironment; +}; + +export type UnsafeDictionary = { + readonly kind: 'unsafe-dictionary'; + readonly unsafeValue: 'any' | 'empty-object' | 'object' | 'union' | 'unknown'; +}; + +export type WideningTargetKind = 'anonymous object' | 'generic container' | 'object' | 'open dictionary' | 'unknown'; + +export type WideningTarget = { + readonly kind: WideningTargetKind; +}; + +export type TypeEnvironment = { + readonly aliases: ReadonlyMap; + readonly interfaces: ReadonlyMap; + readonly shadowedBuiltIns: ReadonlySet; +}; + +function declaredStatement(statement: ESTree.Statement): ESTree.Node | null { + return statement.type === 'ExportNamedDeclaration' || statement.type === 'ExportDefaultDeclaration' + ? (statement.declaration ?? null) + : statement; +} + +export function createTypeEnvironment(program: ESTree.Program): TypeEnvironment { + const aliases = new Map(); + const interfaces = new Map(); + const shadowedBuiltIns = new Set(); + + for (const statement of program.body) { + const declaration = declaredStatement(statement); + if (declaration?.type === 'ImportDeclaration') { + for (const specifier of declaration.specifiers) { + if (BUILT_INS.has(specifier.local.name)) shadowedBuiltIns.add(specifier.local.name); + } + continue; + } + + if (declaration?.type === 'TSTypeAliasDeclaration') { + const existing = aliases.get(declaration.id.name); + if (existing === undefined) aliases.set(declaration.id.name, declaration); + else shadowedBuiltIns.add(declaration.id.name); + if (BUILT_INS.has(declaration.id.name)) shadowedBuiltIns.add(declaration.id.name); + continue; + } + + if (declaration?.type === 'TSInterfaceDeclaration') { + const declarations = interfaces.get(declaration.id.name) ?? []; + declarations.push(declaration); + interfaces.set(declaration.id.name, declarations); + if (BUILT_INS.has(declaration.id.name)) shadowedBuiltIns.add(declaration.id.name); + continue; + } + + if (declaration?.type === 'TSEnumDeclaration') { + if (BUILT_INS.has(declaration.id.name)) shadowedBuiltIns.add(declaration.id.name); + continue; + } + + if ( + (declaration?.type === 'ClassDeclaration' || declaration?.type === 'FunctionDeclaration') && + declaration.id !== null + ) { + if (BUILT_INS.has(declaration.id.name)) shadowedBuiltIns.add(declaration.id.name); + } + } + + return { aliases, interfaces, shadowedBuiltIns }; +} + +function typeReferenceName(type: ESTree.TSTypeReference): string | null { + return type.typeName.type === 'Identifier' ? type.typeName.name : null; +} + +function isBuiltIn(name: string, environment: TypeEnvironment): boolean { + return BUILT_INS.has(name) && !environment.shadowedBuiltIns.has(name); +} + +function isUnappliedReferenceTo(type: ESTree.TSType, name: string): boolean { + const unwrapped = unwrapTransparentType(type); + return ( + unwrapped.type === 'TSTypeReference' && + typeReferenceName(unwrapped) === name && + (unwrapped.typeArguments === null || + unwrapped.typeArguments === undefined || + unwrapped.typeArguments.params.length === 0) + ); +} + +function unwrapTransparentType(type: ESTree.TSType): ESTree.TSType { + let current = type; + while ( + current.type === 'TSParenthesizedType' || + (current.type === 'TSTypeOperator' && current.operator === 'readonly') + ) { + current = current.typeAnnotation; + } + return current; +} + +function isNeverType(type: ESTree.TSType): boolean { + return unwrapTransparentType(type).type === 'TSNeverKeyword'; +} + +function isEffectivelyEmptyMember(member: ESTree.TSSignature): boolean { + return ( + member.type === 'TSPropertySignature' && + member.optional === true && + member.typeAnnotation !== null && + member.typeAnnotation !== undefined && + isNeverType(member.typeAnnotation.typeAnnotation) + ); +} + +function isEffectivelyEmptyTypeLiteral(type: ESTree.TSTypeLiteral): boolean { + return type.members.length === 0 || type.members.every(isEffectivelyEmptyMember); +} + +function isEffectivelyEmptyInterface(declarations: readonly ESTree.TSInterfaceDeclaration[]): boolean { + if (declarations.length !== 1) return false; + const [type] = declarations; + return ( + type !== undefined && + type.extends.length === 0 && + (type.body.body.length === 0 || type.body.body.every(isEffectivelyEmptyMember)) + ); +} + +function resolvedSubstitutionArgument( + type: ESTree.TSType, + base: TypeAliasEnvironment, + resolving: ReadonlySet = new Set() +): ESTree.TSType { + const unwrapped = unwrapTransparentType(type); + if (unwrapped.type !== 'TSTypeReference') return type; + const name = typeReferenceName(unwrapped); + if (name === null || resolving.has(name)) return type; + const substitution = base.get(name); + if (substitution === undefined) return type; + const nextResolving = new Set(resolving); + nextResolving.add(name); + return resolvedSubstitutionArgument(substitution, base, nextResolving); +} + +function aliasSubstitution( + alias: ESTree.TSTypeAliasDeclaration, + type: ESTree.TSTypeReference, + base: TypeAliasEnvironment +): TypeAliasEnvironment | null { + const parameters = alias.typeParameters?.params ?? []; + const arguments_ = type.typeArguments?.params ?? []; + const next = new Map(base); + for (const [index, parameter] of parameters.entries()) { + const argument = arguments_[index] ?? parameter.default; + if (argument === null || argument === undefined) return null; + next.set(parameter.name.name, resolvedSubstitutionArgument(argument, next)); + } + return next; +} + +function unsafeDirectValue( + type: ESTree.TSType, + environment: TypeEnvironment, + substitutions: TypeAliasEnvironment, + resolvingAliases: ReadonlySet +): UnsafeDictionary['unsafeValue'] | null { + const unwrapped = unwrapTransparentType(type); + if (unwrapped.type === 'TSUnknownKeyword') return 'unknown'; + if (unwrapped.type === 'TSAnyKeyword') return 'any'; + if (unwrapped.type === 'TSObjectKeyword') return 'object'; + if (unwrapped.type === 'TSTypeLiteral' && isEffectivelyEmptyTypeLiteral(unwrapped)) return 'empty-object'; + if (unwrapped.type === 'TSUnionType') { + return unwrapped.types.some( + (member) => unsafeDirectValue(member, environment, substitutions, resolvingAliases) !== null + ) + ? 'union' + : null; + } + if (unwrapped.type === 'TSIntersectionType') { + const unsafeMembers = unwrapped.types.map((member) => + unsafeDirectValue(member, environment, substitutions, resolvingAliases) + ); + if (unsafeMembers.includes('any')) return 'any'; + return unsafeMembers.length > 0 && unsafeMembers.every((member) => member !== null) ? unsafeMembers[0] : null; + } + if (unwrapped.type !== 'TSTypeReference') return null; + const name = typeReferenceName(unwrapped); + if (name === null) return null; + if (TRANSPARENT_WRAPPERS.has(name) && isBuiltIn(name, environment)) { + const wrapped = unwrapped.typeArguments?.params[0]; + return wrapped === undefined ? null : unsafeDirectValue(wrapped, environment, substitutions, resolvingAliases); + } + const substitution = substitutions.get(name); + if (substitution !== undefined) { + return isUnappliedReferenceTo(substitution, name) + ? null + : unsafeDirectValue(substitution, environment, substitutions, resolvingAliases); + } + const interfaceDeclarations = environment.interfaces.get(name); + if (interfaceDeclarations !== undefined) { + return isEffectivelyEmptyInterface(interfaceDeclarations) ? 'empty-object' : null; + } + const alias = environment.aliases.get(name); + if (alias === undefined || resolvingAliases.has(name)) return null; + const nextSubstitutions = aliasSubstitution(alias, unwrapped, substitutions); + if (nextSubstitutions === null) return null; + const nextResolving = new Set(resolvingAliases); + nextResolving.add(name); + return unsafeDirectValue(alias.typeAnnotation, environment, nextSubstitutions, nextResolving); +} + +function dictionaryValueTypes( + type: ESTree.TSType, + environment: TypeEnvironment, + substitutions: TypeAliasEnvironment, + resolvingAliases: ReadonlySet +): readonly ResolvedType[] { + const unwrapped = unwrapTransparentType(type); + + if (unwrapped.type === 'TSTypeLiteral') { + return unwrapped.members.flatMap((member): readonly ResolvedType[] => + member.type === 'TSIndexSignature' && member.typeAnnotation !== null + ? [{ type: member.typeAnnotation.typeAnnotation, substitutions }] + : [] + ); + } + + if (unwrapped.type === 'TSMappedType') { + return unwrapped.typeAnnotation === null ? [] : [{ type: unwrapped.typeAnnotation, substitutions }]; + } + + if (unwrapped.type !== 'TSTypeReference') return []; + const name = typeReferenceName(unwrapped); + if (name === null) return []; + + const substitution = substitutions.get(name); + if (substitution !== undefined) { + return isUnappliedReferenceTo(substitution, name) + ? [] + : dictionaryValueTypes(substitution, environment, substitutions, resolvingAliases); + } + + if (TRANSPARENT_WRAPPERS.has(name) && isBuiltIn(name, environment)) { + const wrapped = unwrapped.typeArguments?.params[0]; + return wrapped === undefined ? [] : dictionaryValueTypes(wrapped, environment, substitutions, resolvingAliases); + } + + if (name === 'Record' && isBuiltIn(name, environment)) { + const value = unwrapped.typeArguments?.params[1] ?? null; + return value === null ? [] : [{ type: value, substitutions }]; + } + + if ((name === 'Pick' || name === 'Omit') && isBuiltIn(name, environment)) { + const source = unwrapped.typeArguments?.params[0]; + return source === undefined ? [] : dictionaryValueTypes(source, environment, substitutions, resolvingAliases); + } + + const alias = environment.aliases.get(name); + if (alias === undefined || resolvingAliases.has(name)) return []; + const nextSubstitutions = aliasSubstitution(alias, unwrapped, substitutions); + if (nextSubstitutions === null) return []; + const nextResolving = new Set(resolvingAliases); + nextResolving.add(name); + return dictionaryValueTypes(alias.typeAnnotation, environment, nextSubstitutions, nextResolving); +} + +export function classifyUnsafeDictionaryValue( + valueType: ESTree.TSType, + environment: TypeEnvironment +): UnsafeDictionary | null { + const unsafeValue = unsafeDirectValue(valueType, environment, new Map(), new Set()); + return unsafeValue === null ? null : { kind: 'unsafe-dictionary', unsafeValue }; +} + +export function classifyUnsafeDictionary(type: ESTree.TSType, environment: TypeEnvironment): UnsafeDictionary | null { + for (const valueType of dictionaryValueTypes(type, environment, new Map(), new Set())) { + const unsafeValue = unsafeDirectValue(valueType.type, environment, valueType.substitutions, new Set()); + if (unsafeValue !== null) return { kind: 'unsafe-dictionary', unsafeValue }; + } + return null; +} + +function resolvesToDictionary( + type: ESTree.TSType, + environment: TypeEnvironment, + substitutions: TypeAliasEnvironment, + resolvingAliases: ReadonlySet +): boolean { + return dictionaryValueTypes(type, environment, substitutions, resolvingAliases).length > 0; +} + +export function classifyWideningTarget(type: ESTree.TSType, environment: TypeEnvironment): WideningTarget | null { + const unwrapped = unwrapTransparentType(type); + if (unwrapped.type === 'TSUnknownKeyword') return { kind: 'unknown' }; + if (unwrapped.type === 'TSObjectKeyword') return { kind: 'object' }; + if (unwrapped.type === 'TSTypeLiteral') { + return unwrapped.members.some((member) => member.type === 'TSIndexSignature') + ? { kind: 'open dictionary' } + : unwrapped.members.length > 0 + ? { kind: 'anonymous object' } + : null; + } + if (unwrapped.type === 'TSMappedType') return { kind: 'open dictionary' }; + if (unwrapped.type !== 'TSTypeReference') return null; + const name = typeReferenceName(unwrapped); + if (name === null) return null; + if (TRANSPARENT_WRAPPERS.has(name) && isBuiltIn(name, environment)) { + const wrapped = unwrapped.typeArguments?.params[0]; + return wrapped === undefined ? null : classifyWideningTarget(wrapped, environment); + } + if (name === 'Record' && isBuiltIn(name, environment)) return { kind: 'open dictionary' }; + const alias = environment.aliases.get(name); + if (alias === undefined) return null; + if ((alias.typeParameters?.params.length ?? 0) > 0) { + const substitutions = aliasSubstitution(alias, unwrapped, new Map()); + return substitutions !== null && + resolvesToDictionary(alias.typeAnnotation, environment, substitutions, new Set([name])) + ? { kind: 'generic container' } + : null; + } + const substitutions = aliasSubstitution(alias, unwrapped, new Map()); + if (substitutions === null) return null; + const resolved = classifyAliasBroadTarget(alias.typeAnnotation, environment, substitutions, new Set([name])); + return resolved; +} + +function classifyAliasBroadTarget( + type: ESTree.TSType, + environment: TypeEnvironment, + substitutions: TypeAliasEnvironment, + resolvingAliases: ReadonlySet +): WideningTarget | null { + const unwrapped = unwrapTransparentType(type); + if (unwrapped.type === 'TSUnknownKeyword') return { kind: 'unknown' }; + if (unwrapped.type === 'TSObjectKeyword') return { kind: 'object' }; + if (unwrapped.type !== 'TSTypeReference') return null; + const name = typeReferenceName(unwrapped); + if (name === null) return null; + const substitution = substitutions.get(name); + if (substitution !== undefined) { + return classifyAliasBroadTarget(substitution, environment, substitutions, resolvingAliases); + } + const alias = environment.aliases.get(name); + if (alias === undefined || resolvingAliases.has(name)) return null; + const nextSubstitutions = aliasSubstitution(alias, unwrapped, substitutions); + if (nextSubstitutions === null) return null; + const nextResolving = new Set(resolvingAliases); + nextResolving.add(name); + return classifyAliasBroadTarget(alias.typeAnnotation, environment, nextSubstitutions, nextResolving); +} + +export function isPopulatedObjectExpression(expression: ESTree.Expression): boolean { + let current = expression; + while ( + current.type === 'ParenthesizedExpression' || + current.type === 'TSAsExpression' || + current.type === 'TSTypeAssertion' || + current.type === 'TSNonNullExpression' + ) { + current = current.expression; + } + return current.type === 'ObjectExpression' && current.properties.length > 0; +} + +export function isKnownEvidenceExpression(expression: ESTree.Expression): boolean { + let current = expression; + while ( + current.type === 'ParenthesizedExpression' || + current.type === 'TSAsExpression' || + current.type === 'TSTypeAssertion' || + current.type === 'TSNonNullExpression' || + current.type === 'TSSatisfiesExpression' + ) { + current = current.expression; + } + if (current.type === 'ObjectExpression') return true; + return ( + current.type === 'ArrayExpression' || + current.type === 'ArrowFunctionExpression' || + current.type === 'ClassExpression' || + current.type === 'FunctionExpression' || + current.type === 'NewExpression' || + current.type === 'Literal' || + current.type === 'TemplateLiteral' || + current.type === 'UnaryExpression' + ); +} diff --git a/tools/oxlint/rules/tsconfig.json b/tools/oxlint/rules/tsconfig.json new file mode 100644 index 000000000..38ba01220 --- /dev/null +++ b/tools/oxlint/rules/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "types": ["node"], + "allowImportingTsExtensions": true + }, + "include": ["**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/tools/phpstan/rules/README.md b/tools/phpstan/rules/README.md new file mode 100644 index 000000000..e7e2cd818 --- /dev/null +++ b/tools/phpstan/rules/README.md @@ -0,0 +1,199 @@ +# Rules (PHPStan) + +Opinionated PHPStan rules that reject low-evidence and low-signal PHP patterns. A port of [dmmulroy/anti-slop](https://github.com/dmmulroy/anti-slop) from Oxlint/TypeScript to PHPStan. + +Every rule rejects the same move: erasing type evidence and then re-manufacturing it. The evidence-erasing tools in PHP are `mixed`, `object`, `array`, inline `/** @var */`, `(cast)`, `assert()`, `is_*()` guards, reflection, dynamic member access, and class-loading mocks. The fix is always the same: parse external input once, at its I/O boundary, into a named domain type (a `final readonly class`, an enum, an `array{...}` shape) — [cuyz/valinor](https://github.com/CuyZ/Valinor) or [spatie/laravel-data](https://github.com/spatie/laravel-data) do the parsing step — and keep that type from the boundary to the point of use. + +This directory is meant to be vendored, not treated as a fixed dependency. Copy it into your repository, read the rules, and change them to match your team's standards. + +## Install + +```bash +php tools/phpstan/rules/install.php /path/to/target-repo +``` + +Or by hand: copy this directory to `tools/phpstan/rules/`, then install the dependencies and register the autoload: + +```bash +composer require --dev phpstan/phpstan phpstan/phpstan-strict-rules \ + phpstan/extension-installer spaze/phpstan-disallowed-calls symplify/phpstan-rules +``` + +```json +// composer.json +"autoload-dev": { + "psr-4": { "Rules\\": "tools/phpstan/rules/src/" } +} +``` + +```neon +# phpstan.neon — level 10 with checkImplicitMixed is the intended base +includes: + - tools/phpstan/rules/extension.neon +parameters: + level: 10 + checkImplicitMixed: true + excludePaths: + - tools/phpstan/rules + - .claude + - .cursor + - .agents + - .codex + - .windsurf +``` + +Keep every existing exclude, add any other agent-tooling directories your repository contains, and do not broadly exclude all dot-directories — some repositories keep owned source in them. + +If `phpstan/extension-installer` would auto-enable these packages for analysis runs that should not inherit them, ignore them in the installer's config and let `extension.neon` include them explicitly: + +```json +"extra": { + "phpstan/extension-installer": { + "ignore": [ + "phpstan/phpstan-strict-rules", + "spaze/phpstan-disallowed-calls", + "symplify/phpstan-rules" + ] + } +} +``` + +## Rules + +### Generic rules (`rules.*`) + +- `noMixedParameters` — rejects explicitly `mixed` parameters; functions carrying a `@phpstan-assert` tag for the parameter are boundary parsers and exempt. +- `noMixedReturns` — rejects `mixed` return contracts, including `Generator<..., mixed>` and `iterable` yields; `never` and the magic methods `__get`/`__call`/`__callStatic`/`offsetGet` are allowed (PHP defines those contracts as dynamic). +- `noMixedTypeAliases` — rejects `@phpstan-type`/`@psalm-type` aliases that resolve to `mixed`, including unions and chains through other local aliases. +- `noObjectParameters` — rejects the broad `object` type on inputs; `@template T of object` keeps its evidence and is allowed. +- `noUnsafeDictionaryType` — rejects dictionaries (`array`, `iterable`, `list`, `Traversable`, `ArrayAccess`) whose value type is `mixed`, `object`, an untyped `array`, `stdClass`, or a union containing one of those — in parameters, returns, and properties. Bare `array` stays with PHPStan level 6. +- `noRuntimeTypeChecks` — rejects `is_*()`, `gettype()`, `get_debug_type()`, `settype()` (via spaze/phpstan-disallowed-calls) and `instanceof` on `mixed` (custom); the configurable `rules.boundaryPaths` list and `@phpstan-assert` functions are exempt. +- `noDynamicAccess` — rejects `$obj->$name`, `$obj->{$expr}`, `$obj->$name()`, `$class::$name`, `[$obj, 'method']` callables (symplify + phpstan-strict-rules), and `call_user_func(_array)`, `ReflectionProperty::getValue/setValue`, `ReflectionMethod::invoke/invokeArgs`, `Closure::bind/bindTo/call` (spaze). +- `noClassLoadingMocks` — rejects mocks of concrete classes (`createMock`, `createStub`, `getMockBuilder`, `Mockery::mock`, Laravel `$this->mock()`/`partialMock()`/`spy()`), Mockery `overload:`/`alias:` prefixes, and uopz/runkit runtime patching. Mocks of interfaces and abstract classes are fine. +- `requireSafetyCommentForAssertion` — requires a `SAFETY:` comment on every inline `@var`, narrowing `assert()`, cast, and Webmozart `Assert::*` call. A cast that does not change the type is dead code, not an assertion, and is not flagged. +- `noChainedAssertions` — rejects cast chains (`(object) (array) $x`) and consecutive inline `@var` docblocks re-narrowing the same variable. +- `noKnownValueWidening` — rejects broad declared types on properties and returns whose values are known literals; the inline `@var` half is PHPStan's own `reportAnyTypeWideningInVarTag`, which the extension enables. +- `noWidenThenAssert` — rejects flows that widen a binding (`(array)`/`(object)` cast, `json_decode(json_encode(...))`, `get_object_vars`, `iterator_to_array`, `data_get`/`Arr::get`, broad inline `@var`) and later narrow it back with an assertion form. +- `noConditionalEmptyArraySpread` — rejects `...($c ? ['k' => $v] : [])` and the same dodge through `array_merge`/`array_replace`/`+`. +- `noForbiddenTermsInSymbolNames` — rejects the configurable `rules.forbiddenSymbolTerms` (default: `shape`) as a case-insensitive substring in class, method, function, property, parameter, variable, constant, enum-case, and `@phpstan-type` names. + +### Laravel rules (`rulesLaravel.*`, opt-in) + +Include `laravel/extension.neon` only in Laravel projects (requires larastan): + +- `noServiceConstruction` — rejects `new Service(...)`, `app()`, `resolve()`, `App::make()`, and `$container->make()` for classes under `rulesLaravel.serviceNamespaces` (default `App\Services\`, `App\Actions\`, `App\Repositories\`) outside providers, tests, factories, and the service's own static constructors. + +`canvural/larastan-strict-rules` was evaluated and deliberately not bundled: its facade / global-helper / dynamic-where bans are whole-app architecture policy beyond this set's scope. Add it yourself if your team wants that policy. + +## Violation examples + +### `noMixedParameters` + +```php +function handle(mixed $input): void {} +``` + +### `noMixedReturns` + +```php +function loadUser(): mixed { return $this->find(); } +``` + +### `noMixedTypeAliases` + +```php +/** @phpstan-type ExternalValue mixed */ +``` + +### `noObjectParameters` + +```php +function save(object $value): void {} +``` + +### `noUnsafeDictionaryType` + +```php +/** @param array $metadata */ +function tag(array $metadata): void {} +``` + +### `noRuntimeTypeChecks` + +```php +if (is_string($input)) { useName($input); } +``` + +### `noDynamicAccess` + +```php +$value = $owner->$key; +``` + +### `noClassLoadingMocks` + +```php +$store = $this->createMock(UserStore::class); // UserStore is concrete +``` + +### `requireSafetyCommentForAssertion` + +```php +$userId = (int) $value; +``` + +Add a specific justification immediately before a necessary assertion: + +```php +// SAFETY: the route pattern above only admits digit strings. +$userId = (int) $value; +``` + +### `noChainedAssertions` + +```php +$user = (object) (array) $input; +``` + +### `noKnownValueWidening` + +```php +/** @var array */ +public array $handlers = ['start' => 'startHandler']; +``` + +### `noWidenThenAssert` + +```php +$widened = (array) $payload; +/** @var array{id: string} $widened */ +``` + +### `noConditionalEmptyArraySpread` + +```php +$options = [...($timeout !== null ? ['timeout' => $timeout] : [])]; +``` + +### `noForbiddenTermsInSymbolNames` + +```php +interface UserShape {} +``` + +### Laravel: `noServiceConstruction` + +```php +return new \App\Services\ReportBuilder; +``` + +Inject the service through the constructor and let the container own the wiring. + +## Development + +```bash +vendor/bin/phpunit -c tools/phpstan/rules/phpunit.xml +vendor/bin/phpstan analyse -c tools/phpstan/rules/phpstan.neon +``` + +The second command runs the rule set against its own source at level 10; it must stay clean. diff --git a/tools/phpstan/rules/extension.neon b/tools/phpstan/rules/extension.neon new file mode 100644 index 000000000..fd1ac729f --- /dev/null +++ b/tools/phpstan/rules/extension.neon @@ -0,0 +1,225 @@ +# rules — generic PHPStan rule set. Vendored; edit to fit your team. +# +# Include from the consuming project's phpstan.neon: +# includes: +# - tools/phpstan/rules/extension.neon +# +# The vendor includes below assume this directory lives at +# tools/phpstan/rules/ inside a repository whose composer vendor dir is at +# the repository root. Adjust the relative paths if your layout differs. + +includes: + - ../../../vendor/phpstan/phpstan-strict-rules/rules.neon + - ../../../vendor/spaze/phpstan-disallowed-calls/extension.neon + +parameters: + # Resolve allowIn paths from the consuming project instead of from the + # location of whichever config file includes this extension. + filesRootDir: %rootDir%/../../.. + + # rules rule 11 (`no-known-value-widening`), inline @var half. + reportAnyTypeWideningInVarTag: true + + rules: + # Paths where runtime type checks are legitimate boundary parsing. + # Mirrors anti-slop's allowInTypeGuards option (default off — these + # paths are the PHP equivalent of "inside a type guard"). + boundaryPaths: + - src/Boundary/** + - app/Http/Requests/** + - app/Http/Middleware/** + - app/Http/Controllers/Api/Client/ClientApiController.php + - app/Http/Controllers/Api/Admin/Nodes/AllocationController.php + - app/Http/Controllers/Base/LocaleController.php + - app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php + - app/Http/Middleware/MaintenanceMiddleware.php + - app/Exceptions/ApiErrorResponse.php + - app/Exceptions/Http/Connection/DaemonConnectionException.php + - app/Models/ActivityLog.php + - app/Models/Database.php + - app/Models/Node.php + - app/Transformers/Api/Client/ActivityLogTransformer.php + - app/Transformers/Api/Admin/NodeTransformer.php + - app/Transformers/Api/Admin/ApiKeyTransformer.php + - app/Transformers/Api/Admin/DatabaseHostTransformer.php + - app/Transformers/Api/Application/NodeTransformer.php + - app/Data/** + - app/Extensions/Scribe/** + - app/Services/Extensions/ExtensionManifestValidator.php + - app/Services/Extensions/ExtensionSettingValueGuard.php + - app/Services/Extensions/ExtensionSettings.php + - app/Services/Extensions/Scaffolding/ExtensionScaffolder.php + - app/Services/Eggs/EggConfigurationService.php + - app/Services/Eggs/EggImportData.php + - app/Services/Helpers/AssetHashService.php + - app/Services/Helpers/SoftwareVersionService.php + - app/Extensions/Backups/BackupManager.php + - app/Console/Commands/Environment/EmailSettingsCommand.php + - app/Console/Commands/Environment/AppSettingsCommand.php + - app/Console/Commands/Environment/DatabaseSettingsCommand.php + - app/Console/Commands/UpgradeCommand.php + - app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php + - app/Console/Commands/User/DeleteUserCommand.php + - app/Console/Commands/Node/NodeConfigurationCommand.php + - app/Console/Commands/Node/MakeNodeCommand.php + - app/Helpers/Utilities.php + - app/Traits/Helpers/AvailableLanguages.php + - app/Http/Controllers/Api/Application/ApplicationApiController.php + - app/Http/Controllers/Api/Application/Nodes/AllocationController.php + - app/Http/Controllers/Api/Application/Servers/ServerController.php + - app/Http/Controllers/Auth/LoginCheckpointController.php + - app/Models/Model.php + - app/Providers/SettingsServiceProvider.php + - app/Rules/** + - app/Services/Acl/Api/AdminAcl.php + - app/Services/Activity/ActivityLogService.php + - app/Services/Extensions/ExtensionManifest.php + - app/Services/Themes/ThemeService.php + - app/Services/Tags/TagBackfiller.php + - app/Services/Deployment/AllocationSelectionService.php + - app/Services/Deployment/FindViableNodesService.php + - app/Services/Servers/EnvironmentService.php + - app/Support/JsonValueGuard.php + - app/Support/JsonValueTree.php + - app/Support/Alerts/AlertsMessageBag.php + - app/Http/Controllers/Api/Admin/DatabaseHosts/DatabaseHostController.php + - app/Http/Controllers/Api/Admin/Servers/ServerMountController.php + - app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php + - app/Http/Resources/Wings/ServerConfigurationCollection.php + - app/Models/Server.php + # Rule 14: case-insensitive substrings banned from symbol names. + forbiddenSymbolTerms: + - shape + + disallowedFunctionCalls: + # Rule 6 (`no-runtime-typeof`): ad hoc runtime type checks. + - + function: + - 'is_string()' + - 'is_int()' + - 'is_float()' + - 'is_bool()' + - 'is_array()' + - 'is_object()' + - 'is_null()' + - 'is_numeric()' + - 'is_scalar()' + - 'is_iterable()' + - 'is_callable()' + - 'gettype()' + - 'get_debug_type()' + - 'settype()' + message: 'runtime type checks narrow a representation without establishing its contract; parse input at its I/O boundary (cuyz/valinor, spatie/laravel-data), then branch on the domain value' + allowIn: %rules.boundaryPaths% + errorIdentifier: 'rules.noRuntimeTypeChecks' + # Rule 7 (`no-reflect-apply`): dynamic dispatch through strings. + - + function: + - 'call_user_func()' + - 'call_user_func_array()' + message: 'dynamic dispatch bypasses typed function calls; call the function directly or model dispatch behind a named interface' + errorIdentifier: 'rules.noDynamicAccess' + # Rule 8 (`no-module-mocking`): runtime patching of loaded code. + - + function: + - 'uopz_set_return()' + - 'uopz_set_mock()' + - 'uopz_redefine()' + - 'uopz_function()' + - 'runkit7_function_redefine()' + - 'runkit7_method_redefine()' + - 'runkit_function_redefine()' + - 'runkit_method_redefine()' + message: 'runtime patching replaces loaded code instead of a real dependency seam; extract an interface and inject a faithful in-memory fake' + errorIdentifier: 'rules.noClassLoadingMocks' + + disallowedMethodCalls: + # Rule 7 (`no-reflect-get` / `no-reflect-apply`): reflection access. + - + method: + - 'ReflectionProperty::getValue()' + - 'ReflectionProperty::setValue()' + - 'ReflectionMethod::invoke()' + - 'ReflectionMethod::invokeArgs()' + - 'Closure::call()' + - 'Closure::bindTo()' + message: 'reflection bypasses typed member access; use typed property access or parse dynamic input into a named domain type' + errorIdentifier: 'rules.noDynamicAccess' + + disallowedStaticCalls: + - + method: 'Closure::bind()' + message: 'rebinding closures bypasses the type system; model the behavior behind a named interface' + errorIdentifier: 'rules.noDynamicAccess' + +parametersSchema: + rules: structure([ + boundaryPaths: listOf(string()) + forbiddenSymbolTerms: listOf(string()) + ]) + +rules: + # Rule 7 (`no-reflect-get`): dynamic names ($obj->$name, $obj->{$expr}, + # $$var, $class::$name) and [$obj, 'method'] callables come from + # symplify/phpstan-rules; fixtures under tests/ prove the coverage. + - Symplify\PHPStanRules\Rules\NoDynamicNameRule + - Symplify\PHPStanRules\Rules\Complexity\ForbiddenArrayMethodCallRule + +services: + - Symplify\PHPStanRules\TypeAnalyzer\CallableTypeAnalyzer + - Rules\Support\AssertionForms + - Rules\Support\SignatureResolver + - Rules\Support\TypeAliasDocblock + - Rules\Support\TypeClassifier + - + class: Rules\Rules\NoMixedParametersRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoMixedReturnsRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoMixedTypeAliasesRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoObjectParametersRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoUnsafeDictionaryTypeRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoUnsafeDictionaryPropertyRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoInstanceofOnMixedRule + arguments: + boundaryPaths: %rules.boundaryPaths% + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoClassLoadingMocksRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\RequireSafetyCommentForAssertionRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoChainedAssertionsRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoChainedVarTagsRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoKnownValueWideningPropertyRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoKnownValueWideningReturnRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoWidenThenAssertRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoConditionalEmptyArraySpreadRule + tags: [phpstan.rules.rule] + - + class: Rules\Rules\NoForbiddenTermsInSymbolNamesRule + arguments: + forbiddenTerms: %rules.forbiddenSymbolTerms% + tags: [phpstan.rules.rule] diff --git a/tools/phpstan/rules/install.php b/tools/phpstan/rules/install.php new file mode 100644 index 000000000..220b92b00 --- /dev/null +++ b/tools/phpstan/rules/install.php @@ -0,0 +1,112 @@ + ! str_starts_with($argument, '--'))); + +$source = __DIR__; +$targetRepository = $positional[0] ?? getcwd(); +if ($targetRepository === false || ! is_dir($targetRepository)) { + fwrite(STDERR, "Target repository not found: {$targetRepository}\n"); + exit(1); +} + +$targetRepository = rtrim($targetRepository, '/'); +$destination = $targetRepository.'/tools/phpstan/rules'; + +if (realpath($destination) === realpath($source)) { + fwrite(STDERR, "Refusing to copy the rule set onto itself: {$destination}\n"); + exit(1); +} + +if (is_dir($destination) && ! $force) { + fwrite(STDERR, "Refusing to overwrite {$destination}. Re-run with --force only after reviewing the existing files.\n"); + exit(1); +} + +$copy = static function (string $from, string $to) use (&$copy): void { + if (! is_dir($to) && ! mkdir($to, 0755, true) && ! is_dir($to)) { + throw new RuntimeException("Could not create {$to}"); + } + + $entries = scandir($from); + if ($entries === false) { + throw new RuntimeException("Could not read {$from}"); + } + + foreach ($entries as $entry) { + if ($entry === '.' || $entry === '..' || $entry === '.phpunit.cache') { + continue; + } + + $fromPath = $from.'/'.$entry; + $toPath = $to.'/'.$entry; + if (is_dir($fromPath)) { + $copy($fromPath, $toPath); + } elseif (! copy($fromPath, $toPath)) { + throw new RuntimeException("Could not copy {$fromPath}"); + } + } +}; + +$copy($source, $destination); +echo "Copied the rules rule set to {$destination}\n\n"; + +$composerPath = $targetRepository.'/composer.json'; +$requiresLaravel = false; +if (is_file($composerPath)) { + $composerRaw = file_get_contents($composerPath); + if ($composerRaw !== false) { + $composer = json_decode($composerRaw, true); + $requiresLaravel = is_array($composer) + && isset($composer['require']) + && is_array($composer['require']) + && array_key_exists('laravel/framework', $composer['require']); + } +} + +echo "1. Install current dependency versions (do not pin remembered ones):\n\n"; +echo " composer require --dev phpstan/phpstan phpstan/phpstan-strict-rules \\\n"; +echo " phpstan/extension-installer spaze/phpstan-disallowed-calls symplify/phpstan-rules\n"; +if ($requiresLaravel) { + echo " composer require --dev larastan/larastan\n"; +} + +echo "\n2. Merge into composer.json:\n\n"; +echo " \"autoload-dev\": {\n"; +echo " \"psr-4\": { \"Rules\\\\\": \"tools/phpstan/rules/src/\" }\n"; +echo " }\n"; + +echo "\n3. Merge into phpstan.neon (keep existing excludes; add any other agent\n"; +echo " tooling directories found in the repository — do not broadly exclude\n"; +echo " all dot-directories):\n\n"; +echo " includes:\n"; +echo " - tools/phpstan/rules/extension.neon\n"; +if ($requiresLaravel) { + echo " - tools/phpstan/rules/laravel/extension.neon\n"; +} +echo " parameters:\n"; +echo " level: 10\n"; +echo " checkImplicitMixed: true\n"; +echo " excludePaths:\n"; +echo " - tools/phpstan/rules\n"; +foreach (['.claude', '.cursor', '.agents', '.codex', '.windsurf'] as $agentDirectory) { + if (is_dir($targetRepository.'/'.$agentDirectory)) { + echo " - {$agentDirectory}\n"; + } +} + +echo "\n4. Validate: vendor/bin/phpstan analyse\n"; diff --git a/tools/phpstan/rules/laravel/extension.neon b/tools/phpstan/rules/laravel/extension.neon new file mode 100644 index 000000000..d84b96233 --- /dev/null +++ b/tools/phpstan/rules/laravel/extension.neon @@ -0,0 +1,40 @@ +# rules — Laravel opt-in rules. Include only in Laravel projects: +# includes: +# - tools/phpstan/rules/extension.neon +# - tools/phpstan/rules/laravel/extension.neon +# +# larastan/larastan must be installed (its stubs make app()/resolve()/ +# App::make() resolve to class types this rule can inspect). Larastan's own +# noModelMake and noEnvCallsOutsideOfConfig checks share this set's spirit — +# enable them in your project config. +# +# canvural/larastan-strict-rules (^3, larastan-3 compatible) was evaluated and +# deliberately not included: its facade / global-helper / dynamic-where bans +# are whole-app architecture policy beyond this rule set's scope. Add it yourself +# with `composer require --dev canvural/larastan-strict-rules` if your team +# wants that policy. + +parameters: + rulesLaravel: + serviceNamespaces: + - App\Services\ + - App\Actions\ + - App\Repositories\ + allowedPaths: + - app/Providers/** + - tests/** + - database/factories/** + +parametersSchema: + rulesLaravel: structure([ + serviceNamespaces: listOf(string()) + allowedPaths: listOf(string()) + ]) + +services: + - + class: Rules\Laravel\Rules\NoServiceConstructionRule + arguments: + serviceNamespaces: %rulesLaravel.serviceNamespaces% + allowedPaths: %rulesLaravel.allowedPaths% + tags: [phpstan.rules.rule] diff --git a/tools/phpstan/rules/phpstan.neon b/tools/phpstan/rules/phpstan.neon new file mode 100644 index 000000000..303b43b93 --- /dev/null +++ b/tools/phpstan/rules/phpstan.neon @@ -0,0 +1,30 @@ +# Self-analysis config: the rule set analysed by the rule set it defines, at +# maximum strictness. Run from the repository root: +# vendor/bin/phpstan analyse -c tools/phpstan/rules/phpstan.neon +includes: + - extension.neon + +parameters: + level: 10 + checkImplicitMixed: true + paths: + - src + rules: + # Rule source is itself a boundary parser: it receives php-parser AST + # nodes and PHPStan types (external, unparsed input by this set's own + # definition) and narrows them with instanceof / is_* checks. This is + # the path-scoped re-allow mechanism the set prescribes for boundaries, + # not a baseline. + boundaryPaths: + - tools/phpstan/rules/src/** + forbiddenSymbolTerms: + - shape + ignoreErrors: + # The per-parameter @phpstan-assert exemption (rule 1) requires reading + # which parameter an AssertTag targets; no BC-covered PHPStan API + # exposes that today. This acknowledges the advisory for that one call + # rather than dropping the exemption the spec requires. + - + identifier: phpstanApi.method + path: src/Support/SignatureResolver.php + count: 1 diff --git a/tools/phpstan/rules/phpunit.xml b/tools/phpstan/rules/phpunit.xml new file mode 100644 index 000000000..bc09bc612 --- /dev/null +++ b/tools/phpstan/rules/phpunit.xml @@ -0,0 +1,13 @@ + + + + + tests + + + diff --git a/tools/phpstan/rules/src/Laravel/Rules/NoServiceConstructionRule.php b/tools/phpstan/rules/src/Laravel/Rules/NoServiceConstructionRule.php new file mode 100644 index 000000000..ea6f68b3e --- /dev/null +++ b/tools/phpstan/rules/src/Laravel/Rules/NoServiceConstructionRule.php @@ -0,0 +1,152 @@ +app->make()`. Providers, tests, factories, and the service's own + * static constructors are the composition roots and are exempt. + * + * @implements Rule + */ +final class NoServiceConstructionRule implements Rule +{ + private const array CONTAINER_FUNCTIONS = ['app', 'resolve']; + + /** + * @param list $serviceNamespaces + * @param list $allowedPaths fnmatch() patterns relative to the project root + */ + public function __construct( + private readonly array $serviceNamespaces = ['App\\Services\\', 'App\\Actions\\', 'App\\Repositories\\'], + private readonly array $allowedPaths = ['app/Providers/**', 'tests/**', 'database/factories/**'], + ) {} + + public function getNodeType(): string + { + return CallLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $serviceClass = $this->constructedServiceClass($node, $scope); + if ($serviceClass === null) { + return []; + } + + if ($this->isAllowedFile($scope->getFile()) || $this->isOwnClass($serviceClass, $scope)) { + return []; + } + + return [ + RuleErrorBuilder::message(sprintf( + 'Runtime code constructs the service `%s` instead of receiving it. Inject it through the constructor and let the container own the wiring.', + $serviceClass, + )) + ->identifier('rulesLaravel.noServiceConstruction') + ->line($node->getStartLine()) + ->build(), + ]; + } + + private function constructedServiceClass(CallLike $node, Scope $scope): ?string + { + if ($node instanceof New_ && $node->class instanceof Name) { + return $this->matchServiceNamespace($node->class->toString()); + } + + if ($node instanceof FuncCall && $node->name instanceof Name + && in_array($node->name->toLowerString(), self::CONTAINER_FUNCTIONS, true) + ) { + return $this->firstArgumentServiceClass($node, $scope); + } + + if ($node instanceof StaticCall && $node->class instanceof Name + && $node->name instanceof Identifier && $node->name->toLowerString() === 'make' + ) { + $class = $node->class->toString(); + if ($class === 'App' || str_ends_with($class, '\\App') || str_ends_with($class, '\\Facades\\App')) { + return $this->firstArgumentServiceClass($node, $scope); + } + + return null; + } + + if ($node instanceof MethodCall && $node->name instanceof Identifier + && in_array($node->name->toLowerString(), ['make', 'makewith'], true) + ) { + foreach ($scope->getType($node->var)->getObjectClassReflections() as $receiver) { + if ($receiver->is('Illuminate\Contracts\Container\Container')) { + return $this->firstArgumentServiceClass($node, $scope); + } + } + + return null; + } + + return null; + } + + private function firstArgumentServiceClass(CallLike $node, Scope $scope): ?string + { + $arguments = $node->getArgs(); + if ($arguments === []) { + return null; + } + + foreach ($scope->getType($arguments[0]->value)->getConstantStrings() as $constantString) { + $match = $this->matchServiceNamespace($constantString->getValue()); + if ($match !== null) { + return $match; + } + } + + return null; + } + + private function matchServiceNamespace(string $class): ?string + { + foreach ($this->serviceNamespaces as $namespace) { + if (str_starts_with($class, $namespace)) { + return $class; + } + } + + return null; + } + + private function isAllowedFile(string $file): bool + { + $normalized = str_replace('\\', '/', $file); + foreach ($this->allowedPaths as $pattern) { + if (fnmatch('*'.ltrim($pattern, '/'), $normalized)) { + return true; + } + } + + return false; + } + + private function isOwnClass(string $serviceClass, Scope $scope): bool + { + $classReflection = $scope->getClassReflection(); + + return $classReflection !== null && $classReflection->getName() === $serviceClass; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoChainedAssertionsRule.php b/tools/phpstan/rules/src/Rules/NoChainedAssertionsRule.php new file mode 100644 index 000000000..d0a6815a3 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoChainedAssertionsRule.php @@ -0,0 +1,43 @@ + + */ +final class NoChainedAssertionsRule implements Rule +{ + public function getNodeType(): string + { + return Cast::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (! $node->expr instanceof Cast) { + return []; + } + + return [ + RuleErrorBuilder::message( + 'This assertion chain discards type evidence and fabricates a new type. Keep the original precise type, or parse untrusted input once at its boundary.', + ) + ->identifier('rules.noChainedAssertions') + ->line($node->getStartLine()) + ->build(), + ]; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoChainedVarTagsRule.php b/tools/phpstan/rules/src/Rules/NoChainedVarTagsRule.php new file mode 100644 index 000000000..718d41f49 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoChainedVarTagsRule.php @@ -0,0 +1,78 @@ + + */ +final class NoChainedVarTagsRule implements Rule +{ + public function __construct(private readonly AssertionForms $assertionForms) {} + + public function getNodeType(): string + { + return FunctionLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (! $node instanceof ClassMethod && ! $node instanceof Function_ && ! $node instanceof Closure) { + return []; + } + + $statements = $node->getStmts(); + if ($statements === null) { + return []; + } + + $errors = []; + $this->scan($statements, $errors); + + return $errors; + } + + /** + * @param array $statements + * @param list<\PHPStan\Rules\IdentifierRuleError> $errors + */ + private function scan(array $statements, array &$errors): void + { + $previousVariable = null; + foreach ($statements as $statement) { + $variable = $this->assertionForms->inlineVarTagVariable($statement); + if ($variable !== null && $variable === $previousVariable) { + $errors[] = RuleErrorBuilder::message(sprintf( + 'Consecutive `@var` docblocks re-narrow `$%s` without new evidence. Keep the original precise type, or parse untrusted input once at its boundary.', + $variable, + )) + ->identifier('rules.noChainedAssertions') + ->line($statement->getStartLine()) + ->build(); + } + + $previousVariable = $variable; + + foreach (NodeChildren::statementLists($statement) as $statementList) { + $this->scan($statementList, $errors); + } + } + } +} diff --git a/tools/phpstan/rules/src/Rules/NoClassLoadingMocksRule.php b/tools/phpstan/rules/src/Rules/NoClassLoadingMocksRule.php new file mode 100644 index 000000000..2e1817ce7 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoClassLoadingMocksRule.php @@ -0,0 +1,132 @@ + + */ +final class NoClassLoadingMocksRule implements Rule +{ + private const array TEST_CASE_METHODS = ['createmock', 'createstub', 'getmockbuilder', 'createconfiguredmock', 'createpartialmock']; + + private const array LARAVEL_TEST_METHODS = ['mock', 'partialmock', 'spy']; + + private const array MOCKERY_METHODS = ['mock', 'spy', 'namedmock']; + + public function __construct(private readonly ReflectionProvider $reflectionProvider) {} + + public function getNodeType(): string + { + return CallLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $target = $this->mockTargetName($node, $scope); + if ($target === null) { + return []; + } + + if (str_starts_with($target, 'overload:') || str_starts_with($target, 'alias:')) { + return [$this->buildError($node, sprintf( + 'Mocking `%s` replaces the autoloaded class for the whole process. Extract a real interface and inject a faithful in-memory fake instead.', + $target, + ))]; + } + + if (! $this->reflectionProvider->hasClass($target)) { + return []; + } + + $classReflection = $this->reflectionProvider->getClass($target); + if ($classReflection->isInterface() || $classReflection->isAbstract()) { + return []; + } + + return [$this->buildError($node, sprintf( + 'Mocking the concrete class `%s` fakes an implementation instead of a contract. Extract a real interface, or inject a faithful in-memory fake.', + $target, + ))]; + } + + private function mockTargetName(CallLike $node, Scope $scope): ?string + { + if ($node instanceof StaticCall && $node->class instanceof Name && $node->name instanceof Identifier) { + if ($node->class->toString() !== 'Mockery' && ! str_ends_with($node->class->toString(), '\\Mockery')) { + return null; + } + + if (! in_array($node->name->toLowerString(), self::MOCKERY_METHODS, true)) { + return null; + } + + return $this->firstArgumentClassString($node, $scope); + } + + if ($node instanceof MethodCall && $node->name instanceof Identifier) { + $method = $node->name->toLowerString(); + $isTestCaseMethod = in_array($method, self::TEST_CASE_METHODS, true); + $isLaravelMethod = in_array($method, self::LARAVEL_TEST_METHODS, true); + if (! $isTestCaseMethod && ! $isLaravelMethod) { + return null; + } + + $callerType = $scope->getType($node->var); + $isTestCase = false; + foreach ($callerType->getObjectClassReflections() as $callerClass) { + if ($callerClass->is('PHPUnit\Framework\TestCase')) { + $isTestCase = true; + + break; + } + } + + if (! $isTestCase) { + return null; + } + + return $this->firstArgumentClassString($node, $scope); + } + + return null; + } + + private function firstArgumentClassString(CallLike $node, Scope $scope): ?string + { + $arguments = $node->getArgs(); + if ($arguments === []) { + return null; + } + + $type = $scope->getType($arguments[0]->value); + $strings = $type->getConstantStrings(); + + return $strings === [] ? null : $strings[0]->getValue(); + } + + private function buildError(CallLike $node, string $message): \PHPStan\Rules\IdentifierRuleError + { + return RuleErrorBuilder::message($message) + ->identifier('rules.noClassLoadingMocks') + ->line($node->getStartLine()) + ->build(); + } +} diff --git a/tools/phpstan/rules/src/Rules/NoConditionalEmptyArraySpreadRule.php b/tools/phpstan/rules/src/Rules/NoConditionalEmptyArraySpreadRule.php new file mode 100644 index 000000000..4f86a3590 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoConditionalEmptyArraySpreadRule.php @@ -0,0 +1,90 @@ + + */ +final class NoConditionalEmptyArraySpreadRule implements Rule +{ + private const array MERGE_FUNCTIONS = ['array_merge', 'array_replace']; + + public function getNodeType(): string + { + return Expr::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if ($node instanceof Array_) { + foreach ($node->items as $item) { + if ($item->unpack && $this->isConditionalEmptyArray($item->value)) { + return [$this->buildError($item->value)]; + } + } + + return []; + } + + if ($node instanceof FuncCall && $node->name instanceof Name + && in_array($node->name->toLowerString(), self::MERGE_FUNCTIONS, true) + ) { + foreach ($node->getArgs() as $argument) { + if ($this->isConditionalEmptyArray($argument->value)) { + return [$this->buildError($argument->value)]; + } + } + + return []; + } + + if ($node instanceof Plus + && ($this->isConditionalEmptyArray($node->left) || $this->isConditionalEmptyArray($node->right)) + ) { + return [$this->buildError($node)]; + } + + return []; + } + + private function isConditionalEmptyArray(Expr $expression): bool + { + if (! $expression instanceof Ternary || $expression->if === null) { + return false; + } + + return $this->isEmptyArray($expression->if) || $this->isEmptyArray($expression->else); + } + + private function isEmptyArray(Expr $expression): bool + { + return $expression instanceof Array_ && $expression->items === []; + } + + private function buildError(Expr $node): \PHPStan\Rules\IdentifierRuleError + { + return RuleErrorBuilder::message( + 'This conditional spread hides key omission behind an empty array. Build the array in separate statements and add the key only when present.', + ) + ->identifier('rules.noConditionalEmptyArraySpread') + ->line($node->getStartLine()) + ->build(); + } +} diff --git a/tools/phpstan/rules/src/Rules/NoForbiddenTermsInSymbolNamesRule.php b/tools/phpstan/rules/src/Rules/NoForbiddenTermsInSymbolNamesRule.php new file mode 100644 index 000000000..75a20a9e0 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoForbiddenTermsInSymbolNamesRule.php @@ -0,0 +1,126 @@ + + */ +final class NoForbiddenTermsInSymbolNamesRule implements Rule +{ + /** + * @param list $forbiddenTerms + */ + public function __construct(private readonly array $forbiddenTerms = ['shape']) {} + + public function getNodeType(): string + { + return Node::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $errors = []; + foreach ($this->symbolNames($node) as [$name, $line]) { + $term = $this->matchedTerm($name); + if ($term === null) { + continue; + } + + $errors[] = RuleErrorBuilder::message(sprintf( + 'Rename symbol `%s` for its domain role; `%s` describes structure rather than ownership.', + $name, + $term, + )) + ->identifier('rules.noForbiddenTermsInSymbolNames') + ->line($line) + ->build(); + } + + return $errors; + } + + /** + * @return list + */ + private function symbolNames(Node $node): array + { + if ($node instanceof ClassLike && $node->name !== null) { + $names = [[$node->name->toString(), $node->name->getStartLine()]]; + $docComment = $node->getDocComment(); + if ($docComment !== null) { + preg_match_all('/@(?:phpstan|psalm)-type\s+(\w+)/', $docComment->getText(), $matches); + foreach ($matches[1] as $aliasName) { + $names[] = [$aliasName, $node->getStartLine()]; + } + } + + return $names; + } + + if ($node instanceof ClassMethod || $node instanceof Function_) { + return [[$node->name->toString(), $node->name->getStartLine()]]; + } + + if ($node instanceof Property) { + $names = []; + foreach ($node->props as $property) { + $names[] = [$property->name->toString(), $property->getStartLine()]; + } + + return $names; + } + + if ($node instanceof Param && $node->var instanceof Variable && is_string($node->var->name)) { + return [[$node->var->name, $node->getStartLine()]]; + } + + if ($node instanceof Const_ || $node instanceof Node\Stmt\ClassConst) { + $names = []; + foreach ($node->consts as $const) { + $names[] = [$const->name->toString(), $const->getStartLine()]; + } + + return $names; + } + + if ($node instanceof EnumCase) { + return [[$node->name->toString(), $node->getStartLine()]]; + } + + if ($node instanceof Variable && is_string($node->name)) { + return [[$node->name, $node->getStartLine()]]; + } + + return []; + } + + private function matchedTerm(string $name): ?string + { + foreach ($this->forbiddenTerms as $term) { + if (stripos($name, $term) !== false) { + return $term; + } + } + + return null; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoInstanceofOnMixedRule.php b/tools/phpstan/rules/src/Rules/NoInstanceofOnMixedRule.php new file mode 100644 index 000000000..9dc1963da --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoInstanceofOnMixedRule.php @@ -0,0 +1,75 @@ + + */ +final class NoInstanceofOnMixedRule implements Rule +{ + /** + * @param list $boundaryPaths fnmatch() patterns relative to the project root + */ + public function __construct( + private readonly TypeClassifier $typeClassifier, + private readonly array $boundaryPaths = [], + ) {} + + public function getNodeType(): string + { + return Instanceof_::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (! $this->typeClassifier->isExplicitMixed($scope->getType($node->expr))) { + return []; + } + + if ($this->isBoundaryFunction($scope) || $this->isBoundaryFile($scope->getFile())) { + return []; + } + + return [ + RuleErrorBuilder::message( + 'This `instanceof` narrows a `mixed` value without establishing its contract. Parse the value at its I/O boundary (cuyz/valinor, spatie/laravel-data), then branch on the domain type.', + ) + ->identifier('rules.noRuntimeTypeChecks') + ->line($node->getStartLine()) + ->build(), + ]; + } + + private function isBoundaryFunction(Scope $scope): bool + { + $function = $scope->getFunction(); + + return $function !== null && $function->getAsserts()->getAll() !== []; + } + + private function isBoundaryFile(string $file): bool + { + $normalized = str_replace('\\', '/', $file); + foreach ($this->boundaryPaths as $pattern) { + if (fnmatch('*'.ltrim($pattern, '/'), $normalized)) { + return true; + } + } + + return false; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoKnownValueWideningPropertyRule.php b/tools/phpstan/rules/src/Rules/NoKnownValueWideningPropertyRule.php new file mode 100644 index 000000000..b4b5f9a4b --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoKnownValueWideningPropertyRule.php @@ -0,0 +1,80 @@ + + */ +final class NoKnownValueWideningPropertyRule implements Rule +{ + public function __construct(private readonly TypeClassifier $typeClassifier) {} + + public function getNodeType(): string + { + return ClassPropertyNode::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $default = $node->getDefault(); + if ($default === null || ! $this->isKnownEvidence($default) || $this->isEmptyArray($default)) { + return []; + } + + $type = $node->getPhpDocType() ?? $node->getNativeType(); + if ($type === null || ! $this->isBroadTarget($type)) { + return []; + } + + return [ + RuleErrorBuilder::message(sprintf( + 'The broad declared type on property `$%s` discards its default value\'s evidence. Delete the annotation and let inference stand, or introduce a named shape.', + $node->getName(), + )) + ->identifier('rules.noKnownValueWidening') + ->line($node->getStartLine()) + ->build(), + ]; + } + + private function isKnownEvidence(Expr $expression): bool + { + return $expression instanceof Array_ + || $expression instanceof New_ + || $expression instanceof Scalar + || $expression instanceof ClassConstFetch + || $expression instanceof ConstFetch; + } + + private function isEmptyArray(Expr $expression): bool + { + return $expression instanceof Array_ && $expression->items === []; + } + + private function isBroadTarget(\PHPStan\Type\Type $type): bool + { + return $this->typeClassifier->isExplicitMixed($type) + || $this->typeClassifier->containsBroadObject($type) + || $this->typeClassifier->unsafeDictionaryValueKind($type) !== null; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoKnownValueWideningReturnRule.php b/tools/phpstan/rules/src/Rules/NoKnownValueWideningReturnRule.php new file mode 100644 index 000000000..85fbbd594 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoKnownValueWideningReturnRule.php @@ -0,0 +1,87 @@ + + */ +final class NoKnownValueWideningReturnRule implements Rule +{ + public function __construct(private readonly TypeClassifier $typeClassifier) {} + + public function getNodeType(): string + { + return FunctionReturnStatementsNode::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $returnType = $node->getFunctionReflection()->getOnlyVariant()->getReturnType(); + if (! $this->isBroadTarget($returnType)) { + return []; + } + + $returns = $node->getReturnStatements(); + if ($returns === []) { + return []; + } + + foreach ($returns as $returnStatement) { + $expression = $returnStatement->getReturnNode()->expr; + if ($expression === null || ! $this->isKnownEvidence($expression) || $this->isEmptyArray($expression)) { + return []; + } + } + + return [ + RuleErrorBuilder::message( + 'The broad declared return type discards the known evidence of every returned value. Delete the annotation and let inference stand, or introduce a named shape.', + ) + ->identifier('rules.noKnownValueWidening') + ->line($node->getStartLine()) + ->build(), + ]; + } + + private function isKnownEvidence(Expr $expression): bool + { + return $expression instanceof Array_ + || $expression instanceof New_ + || $expression instanceof Scalar + || $expression instanceof ClassConstFetch + || $expression instanceof ConstFetch; + } + + private function isEmptyArray(Expr $expression): bool + { + return $expression instanceof Array_ && $expression->items === []; + } + + private function isBroadTarget(\PHPStan\Type\Type $type): bool + { + return $this->typeClassifier->isExplicitMixed($type) + || $this->typeClassifier->containsBroadObject($type) + || $this->typeClassifier->unsafeDictionaryValueKind($type) !== null; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoMixedParametersRule.php b/tools/phpstan/rules/src/Rules/NoMixedParametersRule.php new file mode 100644 index 000000000..4dd93b8de --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoMixedParametersRule.php @@ -0,0 +1,90 @@ + + */ +final class NoMixedParametersRule implements Rule +{ + public function __construct( + private readonly SignatureResolver $signatureResolver, + private readonly TypeClassifier $typeClassifier, + ) {} + + public function getNodeType(): string + { + return FunctionLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $signature = $this->signatureResolver->resolve($node, $scope); + if ($signature === null) { + return []; + } + + $errors = []; + foreach ($signature->parameters as $index => $parameter) { + if ($parameter->hasAssertTag || ! $this->typeClassifier->isExplicitMixed($parameter->type)) { + continue; + } + + if ($node instanceof ClassMethod && $this->ancestorRequiresMixed($node, $scope, $index)) { + continue; + } + + $errors[] = RuleErrorBuilder::message(sprintf( + 'Parameter `$%s` leaves input unparsed. Accept a named domain type; run the expected schema or parser (cuyz/valinor, spatie/laravel-data) at the I/O boundary before calling this function.', + $parameter->name, + )) + ->identifier('rules.noMixedParameters') + ->line($node->getStartLine()) + ->build(); + } + + return $errors; + } + + private function ancestorRequiresMixed(ClassMethod $node, Scope $scope, int $parameterIndex): bool + { + $classReflection = $scope->getClassReflection(); + if ($classReflection === null) { + return false; + } + + foreach ($classReflection->getAncestors() as $ancestor) { + if ($ancestor->getName() === $classReflection->getName() || ! $ancestor->hasNativeMethod($node->name->toString())) { + continue; + } + + foreach ($ancestor->getNativeMethod($node->name->toString())->getVariants() as $variant) { + $ancestorParameter = $variant->getParameters()[$parameterIndex] ?? null; + if ($ancestorParameter !== null && $ancestorParameter->getType() instanceof MixedType) { + return true; + } + } + } + + return false; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoMixedReturnsRule.php b/tools/phpstan/rules/src/Rules/NoMixedReturnsRule.php new file mode 100644 index 000000000..491381814 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoMixedReturnsRule.php @@ -0,0 +1,87 @@ +` and `iterable` yields — + * pushes the parsing burden onto every caller. `never` is allowed. Magic + * methods (`__get`, `__call`, `__callStatic`, `offsetGet`) are allowed because + * PHP defines their contracts as dynamic; that decision is documented in the + * README. + * + * @implements Rule + */ +final class NoMixedReturnsRule implements Rule +{ + private const array ALLOWED_MAGIC_METHODS = ['__get', '__call', '__callStatic', 'offsetGet']; + + public function __construct( + private readonly SignatureResolver $signatureResolver, + private readonly TypeClassifier $typeClassifier, + ) {} + + public function getNodeType(): string + { + return FunctionLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if ($node instanceof ClassMethod && in_array($node->name->toString(), self::ALLOWED_MAGIC_METHODS, true)) { + return []; + } + + // Scope-inferred closure types replace the declared return with the + // body's inferred type, so the declared contract is read from the AST. + if ($node instanceof Closure || $node instanceof ArrowFunction) { + $declared = $node->getReturnType(); + + return $declared instanceof Identifier && $declared->toLowerString() === 'mixed' + ? [$this->buildError($node, 'This function exposes `mixed` to its caller. Parse the value at its boundary (cuyz/valinor, spatie/laravel-data) and return a named domain type.')] + : []; + } + + $signature = $this->signatureResolver->resolve($node, $scope); + if ($signature === null || $signature->hasAsserts) { + return []; + } + + $returnType = $signature->returnType; + if ($this->typeClassifier->isNever($returnType)) { + return []; + } + + if ($this->typeClassifier->isExplicitMixed($returnType)) { + return [$this->buildError($node, 'This function exposes `mixed` to its caller. Parse the value at its boundary (cuyz/valinor, spatie/laravel-data) and return a named domain type.')]; + } + + if ($returnType->isIterable()->yes() && $this->typeClassifier->isExplicitMixed($returnType->getIterableValueType())) { + return [$this->buildError($node, 'This function yields `mixed` values to its caller. Parse each value at its boundary and yield a named domain type.')]; + } + + return []; + } + + private function buildError(FunctionLike $node, string $message): \PHPStan\Rules\IdentifierRuleError + { + return RuleErrorBuilder::message($message) + ->identifier('rules.noMixedReturns') + ->line($node->getStartLine()) + ->build(); + } +} diff --git a/tools/phpstan/rules/src/Rules/NoMixedTypeAliasesRule.php b/tools/phpstan/rules/src/Rules/NoMixedTypeAliasesRule.php new file mode 100644 index 000000000..a816f7ba0 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoMixedTypeAliasesRule.php @@ -0,0 +1,56 @@ + + */ +final class NoMixedTypeAliasesRule implements Rule +{ + public function __construct(private readonly TypeAliasDocblock $typeAliasDocblock) {} + + public function getNodeType(): string + { + return InClassNode::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $docComment = $node->getOriginalNode()->getDocComment(); + if ($docComment === null) { + return []; + } + + $aliases = $this->typeAliasDocblock->aliases($docComment->getText()); + + $errors = []; + foreach ($aliases as $name => $body) { + if (! $this->typeAliasDocblock->resolvesToMixed($body, $aliases, [$name => true])) { + continue; + } + + $errors[] = RuleErrorBuilder::message(sprintf( + 'Type alias `%s` hides `mixed`. Keep `mixed` explicit at the parsing boundary; otherwise alias the parsed owner type.', + $name, + )) + ->identifier('rules.noMixedTypeAliases') + ->line($node->getOriginalNode()->getStartLine()) + ->build(); + } + + return $errors; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoObjectParametersRule.php b/tools/phpstan/rules/src/Rules/NoObjectParametersRule.php new file mode 100644 index 000000000..2652a9f5e --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoObjectParametersRule.php @@ -0,0 +1,58 @@ + + */ +final class NoObjectParametersRule implements Rule +{ + public function __construct( + private readonly SignatureResolver $signatureResolver, + private readonly TypeClassifier $typeClassifier, + ) {} + + public function getNodeType(): string + { + return FunctionLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $signature = $this->signatureResolver->resolve($node, $scope); + if ($signature === null) { + return []; + } + + $errors = []; + foreach ($signature->parameters as $parameter) { + if (! $this->typeClassifier->containsBroadObject($parameter->type)) { + continue; + } + + $errors[] = RuleErrorBuilder::message(sprintf( + 'Parameter `$%s` uses the broad `object` type. Accept a named owner type; parse external input (cuyz/valinor, spatie/laravel-data) at its boundary before calling this function.', + $parameter->name, + )) + ->identifier('rules.noObjectParameters') + ->line($node->getStartLine()) + ->build(); + } + + return $errors; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoUnsafeDictionaryPropertyRule.php b/tools/phpstan/rules/src/Rules/NoUnsafeDictionaryPropertyRule.php new file mode 100644 index 000000000..942cea31d --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoUnsafeDictionaryPropertyRule.php @@ -0,0 +1,59 @@ + + */ +final class NoUnsafeDictionaryPropertyRule implements Rule +{ + public function __construct(private readonly TypeClassifier $typeClassifier) {} + + public function getNodeType(): string + { + return ClassPropertyNode::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $type = $node->getPhpDocType() ?? $node->getNativeType(); + if ($type === null) { + return []; + } + + $errors = []; + $kind = $this->typeClassifier->unsafeDictionaryValueKind($type); + if ($kind !== null) { + $errors[] = RuleErrorBuilder::message(sprintf( + 'Property `$%s` is a dictionary of `%s` values, which stores data without a value contract. Declare an `array{...}` shape or a readonly DTO; parse external payloads before insertion.', + $node->getName(), + $kind, + )) + ->identifier('rules.noUnsafeDictionaryType') + ->line($node->getStartLine()) + ->build(); + } elseif ($this->typeClassifier->containsStdClass($type)) { + $errors[] = RuleErrorBuilder::message(sprintf( + 'Property `$%s` is typed `stdClass`, an anonymous bag with no contract. Declare a named readonly DTO and parse external payloads into it.', + $node->getName(), + )) + ->identifier('rules.noUnsafeDictionaryType') + ->line($node->getStartLine()) + ->build(); + } + + return $errors; + } +} diff --git a/tools/phpstan/rules/src/Rules/NoUnsafeDictionaryTypeRule.php b/tools/phpstan/rules/src/Rules/NoUnsafeDictionaryTypeRule.php new file mode 100644 index 000000000..235d637c9 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoUnsafeDictionaryTypeRule.php @@ -0,0 +1,72 @@ + + */ +final class NoUnsafeDictionaryTypeRule implements Rule +{ + public function __construct( + private readonly SignatureResolver $signatureResolver, + private readonly TypeClassifier $typeClassifier, + ) {} + + public function getNodeType(): string + { + return FunctionLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $signature = $this->signatureResolver->resolve($node, $scope); + if ($signature === null || $signature->hasAsserts) { + return []; + } + + $errors = []; + foreach ($signature->parameters as $parameter) { + $kind = $this->typeClassifier->unsafeDictionaryValueKind($parameter->type); + if ($kind !== null) { + $errors[] = $this->buildError($node, sprintf( + "Parameter `\$%s` is a dictionary of `%s` values, which gives callers no value contract. Declare an `array{...}` shape or a readonly DTO; parse external payloads (cuyz/valinor, spatie/laravel-data) before insertion.", + $parameter->name, + $kind, + )); + } + } + + $returnKind = $this->typeClassifier->unsafeDictionaryValueKind($signature->returnType); + if ($returnKind !== null) { + $errors[] = $this->buildError($node, sprintf( + 'This function returns a dictionary of `%s` values, which gives callers no value contract. Declare an `array{...}` shape or a readonly DTO; parse external payloads before returning them.', + $returnKind, + )); + } + + return $errors; + } + + private function buildError(FunctionLike $node, string $message): \PHPStan\Rules\IdentifierRuleError + { + return RuleErrorBuilder::message($message) + ->identifier('rules.noUnsafeDictionaryType') + ->line($node->getStartLine()) + ->build(); + } +} diff --git a/tools/phpstan/rules/src/Rules/NoWidenThenAssertRule.php b/tools/phpstan/rules/src/Rules/NoWidenThenAssertRule.php new file mode 100644 index 000000000..ff6e236f7 --- /dev/null +++ b/tools/phpstan/rules/src/Rules/NoWidenThenAssertRule.php @@ -0,0 +1,198 @@ + + */ +final class NoWidenThenAssertRule implements Rule +{ + private const array WIDENING_FUNCTIONS = ['get_object_vars', 'iterator_to_array', 'data_get']; + + private const string BROAD_VAR_TAG = '/@var\s+(?:mixed|object|array(?!\{)|array<[^>]*mixed[^>]*>)\s+\$(\w+)/'; + + public function __construct(private readonly AssertionForms $assertionForms) {} + + public function getNodeType(): string + { + return FunctionLike::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (! $node instanceof ClassMethod && ! $node instanceof Function_ && ! $node instanceof Closure) { + return []; + } + + $statements = $node->getStmts(); + if ($statements === null) { + return []; + } + + $errors = []; + $this->scan($statements, [], $errors, $scope); + + return $errors; + } + + /** + * @param array $statements + * @param array $widened + * @param list<\PHPStan\Rules\IdentifierRuleError> $errors + */ + private function scan(array $statements, array $widened, array &$errors, Scope $scope): void + { + foreach ($statements as $statement) { + $broadTagVariable = $this->broadVarTagVariable($statement); + if ($broadTagVariable !== null) { + $widened[$broadTagVariable] = true; + } + + if ($statement instanceof Expression && $statement->expr instanceof Assign + && $statement->expr->var instanceof Variable && is_string($statement->expr->var->name) + ) { + $name = $statement->expr->var->name; + if ($this->isWideningExpression($statement->expr->expr)) { + $widened[$name] = true; + } elseif ($this->narrowedVariable($statement->expr->expr) !== $name) { + unset($widened[$name]); + } + } + + foreach ($this->narrowingsInStatement($statement, $scope) as [$variable, $line]) { + if (isset($widened[$variable])) { + $errors[] = RuleErrorBuilder::message(sprintf( + 'Binding `$%s` discards type evidence and later recreates it with an assertion. Keep the precise type from initialization through use; parse boundary input once.', + $variable, + )) + ->identifier('rules.noWidenThenAssert') + ->line($line) + ->build(); + unset($widened[$variable]); + } + } + + foreach (NodeChildren::statementLists($statement) as $statementList) { + $this->scan($statementList, $widened, $errors, $scope); + } + } + } + + private function broadVarTagVariable(Stmt $statement): ?string + { + $docComment = $statement->getDocComment(); + if ($docComment === null) { + return null; + } + + return preg_match(self::BROAD_VAR_TAG, $docComment->getText(), $match) === 1 ? $match[1] : null; + } + + private function isWideningExpression(Expr $expression): bool + { + if ($expression instanceof Cast\Array_ || $expression instanceof Cast\Object_) { + return true; + } + + if ($expression instanceof FuncCall && $expression->name instanceof Name) { + $function = $expression->name->toLowerString(); + if (in_array($function, self::WIDENING_FUNCTIONS, true)) { + return true; + } + + if ($function === 'json_decode') { + $arguments = $expression->getArgs(); + + return isset($arguments[0]) + && $arguments[0]->value instanceof FuncCall + && $arguments[0]->value->name instanceof Name + && $arguments[0]->value->name->toLowerString() === 'json_encode'; + } + } + + return $expression instanceof StaticCall + && $expression->class instanceof Name + && str_ends_with($expression->class->toString(), 'Arr') + && $expression->name instanceof Node\Identifier + && $expression->name->toLowerString() === 'get'; + } + + /** + * @return list + */ + private function narrowingsInStatement(Stmt $statement, Scope $scope): array + { + $narrowings = []; + + $tagVariable = $this->assertionForms->inlineVarTagVariable($statement); + if ($tagVariable !== null && $this->broadVarTagVariable($statement) === null) { + $narrowings[] = [$tagVariable, $statement->getStartLine()]; + } + + foreach ($this->assertionForms->assertionsInStatement($statement, $scope) as $assertion) { + $variable = $this->narrowedVariable($assertion); + if ($variable !== null) { + $narrowings[] = [$variable, $assertion->getStartLine()]; + } + } + + return $narrowings; + } + + private function narrowedVariable(Expr $expression): ?string + { + if ($expression instanceof Cast) { + return $expression->expr instanceof Variable && is_string($expression->expr->name) + ? $expression->expr->name + : null; + } + + if ($expression instanceof FuncCall || $expression instanceof StaticCall) { + foreach ($expression->getArgs() as $argument) { + $inner = $argument->value; + if ($inner instanceof Variable && is_string($inner->name)) { + return $inner->name; + } + + if ($inner instanceof FuncCall) { + foreach ($inner->getArgs() as $nested) { + if ($nested->value instanceof Variable && is_string($nested->value->name)) { + return $nested->value->name; + } + } + } + } + } + + return null; + } +} diff --git a/tools/phpstan/rules/src/Rules/RequireSafetyCommentForAssertionRule.php b/tools/phpstan/rules/src/Rules/RequireSafetyCommentForAssertionRule.php new file mode 100644 index 000000000..99b0f174b --- /dev/null +++ b/tools/phpstan/rules/src/Rules/RequireSafetyCommentForAssertionRule.php @@ -0,0 +1,67 @@ + + */ +final class RequireSafetyCommentForAssertionRule implements Rule +{ + public function __construct(private readonly AssertionForms $assertionForms) {} + + public function getNodeType(): string + { + return Stmt::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $errors = []; + + if ($this->assertionForms->inlineVarTagVariable($node) !== null + && ! $this->assertionForms->hasSafetyComment($node) + ) { + $errors[] = $this->buildError( + 'This inline `@var` overrides inference without a `SAFETY:` justification. State the checked invariant in the docblock or immediately before the statement.', + $node->getStartLine(), + ); + } + + foreach ($this->assertionForms->assertionsInStatement($node, $scope) as $assertion) { + if ($this->assertionForms->hasSafetyComment($assertion, $node)) { + continue; + } + + $errors[] = $this->buildError( + 'This type assertion has no `SAFETY:` justification. State the checked invariant immediately before the assertion or its containing statement.', + $assertion->getStartLine(), + ); + } + + return $errors; + } + + private function buildError(string $message, int $line): \PHPStan\Rules\IdentifierRuleError + { + return RuleErrorBuilder::message($message) + ->identifier('rules.requireSafetyCommentForAssertion') + ->line($line) + ->build(); + } +} diff --git a/tools/phpstan/rules/src/Support/AssertionForms.php b/tools/phpstan/rules/src/Support/AssertionForms.php new file mode 100644 index 000000000..5086068ef --- /dev/null +++ b/tools/phpstan/rules/src/Support/AssertionForms.php @@ -0,0 +1,157 @@ + + */ + public function assertionsInStatement(Stmt $statement, Scope $scope): array + { + $found = []; + foreach (NodeChildren::nodes($statement) as $child) { + if ($child instanceof Expr) { + $this->collect($child, $scope, $found); + } + } + + return $found; + } + + public function isDeadCast(Cast $cast, Scope $scope): bool + { + $type = $scope->getType($cast->expr); + + return match (true) { + $cast instanceof Cast\Int_ => $type->isInteger()->yes(), + $cast instanceof Cast\String_ => $type->isString()->yes(), + $cast instanceof Cast\Bool_ => $type->isBoolean()->yes(), + $cast instanceof Cast\Double => $type->isFloat()->yes(), + $cast instanceof Cast\Array_ => $type->isArray()->yes(), + $cast instanceof Cast\Object_ => $type->isObject()->yes(), + default => false, + }; + } + + public function isNarrowingAssertCall(Expr $expression): bool + { + if (! $expression instanceof FuncCall || ! $expression->name instanceof Name + || $expression->name->toLowerString() !== 'assert' + ) { + return false; + } + + $arguments = $expression->getArgs(); + if ($arguments === []) { + return false; + } + + return $this->containsNarrowingCheck($arguments[0]->value); + } + + public function isWebmozartAssertCall(Expr $expression): bool + { + return $expression instanceof StaticCall + && $expression->class instanceof Name + && str_ends_with($expression->class->toString(), 'Assert\\Assert'); + } + + public function hasSafetyComment(Node ...$nodes): bool + { + foreach ($nodes as $node) { + foreach ($node->getComments() as $comment) { + if (preg_match(self::SAFETY_PATTERN, $comment->getText()) === 1) { + return true; + } + } + } + + return false; + } + + public function inlineVarTagVariable(Stmt $statement): ?string + { + $docComment = $statement->getDocComment(); + if ($docComment === null) { + return null; + } + + return preg_match('/@var\s+.+?\s+\$(\w+)/', $docComment->getText(), $match) === 1 + ? $match[1] + : null; + } + + /** + * @param list $found + */ + private function collect(Expr $expression, Scope $scope, array &$found): void + { + if ($expression instanceof Closure) { + return; + } + + if (($expression instanceof Cast && ! $this->isDeadCast($expression, $scope)) + || $this->isNarrowingAssertCall($expression) + || $this->isWebmozartAssertCall($expression) + ) { + $found[] = $expression; + } + + foreach (NodeChildren::nodes($expression) as $child) { + if ($child instanceof Expr) { + $this->collect($child, $scope, $found); + } elseif ($child instanceof Node\Arg) { + $this->collect($child->value, $scope, $found); + } + } + } + + private function containsNarrowingCheck(Expr $expression): bool + { + if ($expression instanceof Instanceof_) { + return true; + } + + if ($expression instanceof FuncCall && $expression->name instanceof Name + && str_starts_with($expression->name->toLowerString(), 'is_') + ) { + return true; + } + + foreach (NodeChildren::nodes($expression) as $child) { + if ($child instanceof Expr && $this->containsNarrowingCheck($child)) { + return true; + } + + if ($child instanceof Node\Arg && $this->containsNarrowingCheck($child->value)) { + return true; + } + } + + return false; + } +} diff --git a/tools/phpstan/rules/src/Support/NodeChildren.php b/tools/phpstan/rules/src/Support/NodeChildren.php new file mode 100644 index 000000000..86e5264a5 --- /dev/null +++ b/tools/phpstan/rules/src/Support/NodeChildren.php @@ -0,0 +1,66 @@ +$name`) this rule set bans. + */ +final class NodeChildren +{ + /** + * @return list + */ + public static function nodes(Node $node): array + { + $children = []; + foreach (get_object_vars($node) as $value) { + if ($value instanceof Node) { + $children[] = $value; + + continue; + } + + if (is_array($value)) { + foreach ($value as $item) { + if ($item instanceof Node) { + $children[] = $item; + } + } + } + } + + return $children; + } + + /** + * @return list> + */ + public static function statementLists(Node $node): array + { + $lists = []; + foreach (get_object_vars($node) as $value) { + if (! is_array($value)) { + continue; + } + + $statements = []; + foreach ($value as $item) { + if ($item instanceof Node\Stmt) { + $statements[] = $item; + } + } + + if ($statements !== []) { + $lists[] = $statements; + } + } + + return $lists; + } +} diff --git a/tools/phpstan/rules/src/Support/ResolvedParameter.php b/tools/phpstan/rules/src/Support/ResolvedParameter.php new file mode 100644 index 000000000..d4d6158af --- /dev/null +++ b/tools/phpstan/rules/src/Support/ResolvedParameter.php @@ -0,0 +1,21 @@ + $parameters + */ + public function __construct( + public readonly array $parameters, + public readonly Type $returnType, + public readonly bool $hasAsserts, + public readonly string $describedName, + ) {} +} diff --git a/tools/phpstan/rules/src/Support/SignatureResolver.php b/tools/phpstan/rules/src/Support/SignatureResolver.php new file mode 100644 index 000000000..8f1df0b54 --- /dev/null +++ b/tools/phpstan/rules/src/Support/SignatureResolver.php @@ -0,0 +1,129 @@ +resolveMethod($node, $scope); + } + + if ($node instanceof Function_) { + return $this->resolveFunction($node, $scope); + } + + if ($node instanceof Closure || $node instanceof ArrowFunction) { + return $this->resolveClosure($node, $scope); + } + + return null; + } + + private function resolveMethod(ClassMethod $node, Scope $scope): ?ResolvedSignature + { + $classReflection = $scope->getClassReflection(); + if ($classReflection === null) { + return null; + } + + $method = $classReflection->getNativeMethod($node->name->toString()); + $variant = $method->getOnlyVariant(); + + return $this->buildSignature( + $variant->getParameters(), + $variant->getReturnType(), + $method->getAsserts(), + sprintf('%s::%s()', $classReflection->getDisplayName(), $node->name->toString()), + ); + } + + private function resolveFunction(Function_ $node, Scope $scope): ?ResolvedSignature + { + $name = $node->namespacedName ?? $node->name; + // SAFETY: php-parser Name nodes stringify to their qualified form. + $nameNode = new Node\Name\FullyQualified((string) $name); + if (! $this->reflectionProvider->hasFunction($nameNode, $scope)) { + return null; + } + + $function = $this->reflectionProvider->getFunction($nameNode, $scope); + $variant = $function->getOnlyVariant(); + + return $this->buildSignature( + $variant->getParameters(), + $variant->getReturnType(), + $function->getAsserts(), + $function->getName().'()', + ); + } + + private function resolveClosure(Closure|ArrowFunction $node, Scope $scope): ?ResolvedSignature + { + $type = $scope->getType($node); + if (! $type instanceof ClosureType) { + return null; + } + + $parameters = []; + foreach ($type->getParameters() as $parameter) { + $parameters[] = new ResolvedParameter($parameter->getName(), $parameter->getType(), false); + } + + return new ResolvedSignature( + $parameters, + $type->getReturnType(), + false, + $node instanceof ArrowFunction ? '{arrow function}' : '{closure}', + ); + } + + /** + * @param list<\PHPStan\Reflection\ParameterReflection> $parameters + */ + private function buildSignature( + array $parameters, + \PHPStan\Type\Type $returnType, + Assertions $assertions, + string $describedName, + ): ResolvedSignature { + $assertedParameterNames = []; + foreach ($assertions->getAll() as $assertTag) { + // describe() is the covered API; it prints the "$name" form. + $assertedParameterNames[ltrim($assertTag->getParameter()->describe(), '$')] = true; + } + + $resolved = []; + foreach ($parameters as $parameter) { + $resolved[] = new ResolvedParameter( + $parameter->getName(), + $parameter->getType(), + isset($assertedParameterNames[$parameter->getName()]), + ); + } + + return new ResolvedSignature($resolved, $returnType, $assertedParameterNames !== [], $describedName); + } +} diff --git a/tools/phpstan/rules/src/Support/TypeAliasDocblock.php b/tools/phpstan/rules/src/Support/TypeAliasDocblock.php new file mode 100644 index 000000000..f64e37539 --- /dev/null +++ b/tools/phpstan/rules/src/Support/TypeAliasDocblock.php @@ -0,0 +1,87 @@ + alias name => declared type string + */ + public function aliases(string $docComment): array + { + preg_match_all( + '/@(?:phpstan|psalm)-type\s+(\w+)\s*=?\s*([^\r\n]*?)\s*(?:\*\/|\r|\n)/', + $docComment, + $matches, + PREG_SET_ORDER, + ); + + $aliases = []; + foreach ($matches as $match) { + $aliases[$match[1]] = rtrim(trim($match[2]), '*/ '); + } + + return $aliases; + } + + /** + * Whether the alias body is `mixed` or a top-level union containing it, + * following references to other aliases declared in the same docblock. + * + * @param array $aliases + * @param array $visiting + */ + public function resolvesToMixed(string $body, array $aliases, array $visiting = []): bool + { + foreach ($this->topLevelUnionParts($body) as $part) { + if (strcasecmp($part, 'mixed') === 0) { + return true; + } + + if (isset($aliases[$part]) && ! isset($visiting[$part]) + && $this->resolvesToMixed($aliases[$part], $aliases, $visiting + [$part => true]) + ) { + return true; + } + } + + return false; + } + + /** + * @return list + */ + private function topLevelUnionParts(string $body): array + { + $parts = []; + $depth = 0; + $current = ''; + foreach (str_split($body) as $character) { + if ($character === '<' || $character === '{' || $character === '(' || $character === '[') { + $depth++; + } elseif ($character === '>' || $character === '}' || $character === ')' || $character === ']') { + $depth--; + } elseif ($character === '|' && $depth === 0) { + $parts[] = trim($current); + $current = ''; + + continue; + } + + $current .= $character; + } + + $parts[] = trim($current); + + return array_values(array_filter($parts, static fn (string $part): bool => $part !== '')); + } +} diff --git a/tools/phpstan/rules/src/Support/TypeClassifier.php b/tools/phpstan/rules/src/Support/TypeClassifier.php new file mode 100644 index 000000000..c31c8a542 --- /dev/null +++ b/tools/phpstan/rules/src/Support/TypeClassifier.php @@ -0,0 +1,153 @@ +isExplicitMixed(); + } + + public function isNever(Type $type): bool + { + return $type instanceof NeverType; + } + + /** + * Bare `object`, directly or as a union member (`?object`, `object|null`). + */ + public function containsBroadObject(Type $type): bool + { + foreach ($this->unionMembers($type) as $member) { + if ($this->isBareObject($member)) { + return true; + } + } + + return false; + } + + public function containsStdClass(Type $type): bool + { + foreach ($this->unionMembers($type) as $member) { + if (in_array('stdClass', $member->getObjectClassNames(), true)) { + return true; + } + } + + return false; + } + + /** + * Classifies a declared type as an unsafe dictionary: an array, iterable, + * list, Traversable, or ArrayAccess whose value type is explicit `mixed`, + * bare `object`, an untyped array, `stdClass`, or a union containing one + * of those. Constant array shapes (`array{...}`) are safe. Bare `array` + * with an implicit-mixed value is left to PHPStan level 6. + * + * @return string|null the offending value description, or null when safe + */ + public function unsafeDictionaryValueKind(Type $type): ?string + { + foreach ($this->unionMembers($type) as $member) { + $valueType = $this->dictionaryValueType($member); + if ($valueType === null) { + continue; + } + + $kind = $this->unsafeValueKind($valueType); + if ($kind !== null) { + return $kind; + } + } + + return null; + } + + private function dictionaryValueType(Type $type): ?Type + { + if ($type->isConstantArray()->yes()) { + return null; + } + + if ($type->isArray()->yes() || $type->isIterable()->yes()) { + return $type->getIterableValueType(); + } + + if (in_array('ArrayAccess', $type->getObjectClassNames(), true)) { + $valueType = $type->getTemplateType('ArrayAccess', 'TValue'); + + return $this->isNever($valueType) ? null : $valueType; + } + + return null; + } + + private function unsafeValueKind(Type $valueType): ?string + { + foreach ($this->unionMembers($valueType) as $member) { + if ($this->isExplicitMixed($member)) { + return 'mixed'; + } + + if ($this->isBareObject($member)) { + return 'object'; + } + + if (in_array('stdClass', $member->getObjectClassNames(), true)) { + return 'stdClass'; + } + + $memberValue = $member->isArray()->yes() ? $member->getIterableValueType() : null; + if ($memberValue instanceof MixedType && ! $memberValue->isExplicitMixed()) { + return 'untyped array'; + } + } + + return null; + } + + private function isBareObject(Type $type): bool + { + // A template constrained to object (`@template T of object`) keeps its + // evidence through the template, mirroring ``. + return $type->isObject()->yes() + && $type->getObjectClassNames() === [] + && ! $type instanceof TemplateType; + } + + /** + * @return list + */ + private function unionMembers(Type $type): array + { + if (! $type instanceof UnionType) { + return [$type]; + } + + $members = []; + foreach ($type->getTypes() as $member) { + foreach ($this->unionMembers($member) as $nested) { + $members[] = $nested; + } + } + + return $members; + } +} diff --git a/tools/phpstan/rules/tests/Integration/PackageCoverageTest.php b/tools/phpstan/rules/tests/Integration/PackageCoverageTest.php new file mode 100644 index 000000000..ef55c51e7 --- /dev/null +++ b/tools/phpstan/rules/tests/Integration/PackageCoverageTest.php @@ -0,0 +1,64 @@ +/dev/null', + escapeshellarg(PHP_BINARY), + escapeshellarg($projectRoot.'/vendor/bin/phpstan'), + escapeshellarg(__DIR__.'/integration.neon'), + ); + + exec($command, $output, $exitCode); + self::assertSame(1, $exitCode, 'phpstan should report errors for the fixture'); + + // Local tooling may prefix phpstan's stdout with guidance text; the + // JSON report starts at the first brace. + $raw = implode('', $output); + $braceOffset = strpos($raw, '{'); + self::assertIsInt($braceOffset, 'no JSON object found in phpstan output'); + $report = json_decode(substr($raw, $braceOffset), true, 32, JSON_THROW_ON_ERROR); + self::assertIsArray($report); + + $messages = []; + foreach ($report['files'] as $file) { + foreach ($file['messages'] as $message) { + $messages[] = [$message['identifier'] ?? '?', $message['line']]; + } + } + + $count = static fn (string $identifier): int => count( + array_filter($messages, static fn (array $entry): bool => $entry[0] === $identifier), + ); + + // Dynamic property/brace/method names: symplify NoDynamicNameRule. + self::assertSame(3, $count('symplify.noDynamicName'), var_export($messages, true)); + // The dynamic static-property form comes from phpstan-strict-rules' + // *.dynamicName family, which also doubles the instance forms. + $dynamicNameFamily = count(array_filter( + $messages, + static fn (array $entry): bool => str_ends_with($entry[0], '.dynamicName'), + )); + self::assertSame(4, $dynamicNameFamily, var_export($messages, true)); + // call_user_func / call_user_func_array / ReflectionProperty::getValue: spaze. + self::assertSame(3, $count('rules.noDynamicAccess'), var_export($messages, true)); + // is_string / is_numeric outside a boundary path: spaze. + self::assertSame(2, $count('rules.noRuntimeTypeChecks'), var_export($messages, true)); + } +} diff --git a/tools/phpstan/rules/tests/Integration/data/package-coverage.php b/tools/phpstan/rules/tests/Integration/data/package-coverage.php new file mode 100644 index 000000000..ced53570b --- /dev/null +++ b/tools/phpstan/rules/tests/Integration/data/package-coverage.php @@ -0,0 +1,41 @@ +known; + } +} + +function dynamicAccess(Target $target, string $name): array +{ + $viaProperty = $target->$name; // noDynamicName + $viaBraces = $target->{$name.'x'}; // noDynamicName + $viaMethod = $target->$name(); // noDynamicName + $viaStaticProperty = Target::$$name; // noDynamicName + + $viaCallUserFunc = call_user_func('strrev', $name); // disallowed + $viaCallUserFuncArray = call_user_func_array('strrev', [$name]); // disallowed + + $callable = [$target, 'known']; + $viaArrayCall = $callable(); // forbiddenArrayMethodCall + + $property = new \ReflectionProperty(Target::class, 'known'); + $viaReflection = $property->getValue($target); // disallowed + + return [$viaProperty, $viaBraces, $viaMethod, $viaStaticProperty, $viaCallUserFunc, $viaCallUserFuncArray, $viaArrayCall, $viaReflection]; +} + +function runtimeChecks(mixed $value): bool +{ + return is_string($value) || is_numeric($value); // disallowed x2 +} diff --git a/tools/phpstan/rules/tests/Integration/integration.neon b/tools/phpstan/rules/tests/Integration/integration.neon new file mode 100644 index 000000000..76645d5e3 --- /dev/null +++ b/tools/phpstan/rules/tests/Integration/integration.neon @@ -0,0 +1,7 @@ +includes: + - ../../extension.neon + +parameters: + level: 0 + paths: + - data diff --git a/tools/phpstan/rules/tests/Rules/NoChainedAssertionsRuleTest.php b/tools/phpstan/rules/tests/Rules/NoChainedAssertionsRuleTest.php new file mode 100644 index 000000000..06a3fe89c --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoChainedAssertionsRuleTest.php @@ -0,0 +1,32 @@ + + */ +final class NoChainedAssertionsRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoChainedAssertionsRule(new AssertionForms); + } + + public function testRule(): void + { + $message = 'This assertion chain discards type evidence and fabricates a new type. Keep the original precise type, or parse untrusted input once at its boundary.'; + + $this->analyse([__DIR__.'/data/no-chained-assertions.php'], [ + [$message, 9], + [$message, 11], + [$message, 11], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoChainedVarTagsRuleTest.php b/tools/phpstan/rules/tests/Rules/NoChainedVarTagsRuleTest.php new file mode 100644 index 000000000..4508d1e6e --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoChainedVarTagsRuleTest.php @@ -0,0 +1,28 @@ + + */ +final class NoChainedVarTagsRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoChainedVarTagsRule(new AssertionForms); + } + + public function testRule(): void + { + $this->analyse([__DIR__.'/data/no-chained-var-tags.php'], [ + ['Consecutive `@var` docblocks re-narrow `$decoded` without new evidence. Keep the original precise type, or parse untrusted input once at its boundary.', 14], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoClassLoadingMocksRuleTest.php b/tools/phpstan/rules/tests/Rules/NoClassLoadingMocksRuleTest.php new file mode 100644 index 000000000..f31639fd0 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoClassLoadingMocksRuleTest.php @@ -0,0 +1,36 @@ + + */ +final class NoClassLoadingMocksRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoClassLoadingMocksRule($this->createReflectionProvider()); + } + + public function testRule(): void + { + $concrete = 'Mocking the concrete class `%s` fakes an implementation instead of a contract. Extract a real interface, or inject a faithful in-memory fake.'; + $loading = 'Mocking `%s` replaces the autoloaded class for the whole process. Extract a real interface and inject a faithful in-memory fake instead.'; + $class = 'Rules\Tests\Data\NoClassLoadingMocks\SystemClock'; + + $this->analyse([__DIR__.'/data/no-class-loading-mocks.php'], [ + [sprintf($concrete, $class), 32], + [sprintf($concrete, $class), 33], + [sprintf($concrete, $class), 34], + [sprintf($concrete, $class), 37], + [sprintf($loading, 'overload:'.$class), 38], + [sprintf($loading, 'alias:'.$class), 39], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoConditionalEmptyArraySpreadRuleTest.php b/tools/phpstan/rules/tests/Rules/NoConditionalEmptyArraySpreadRuleTest.php new file mode 100644 index 000000000..ba4cfdfba --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoConditionalEmptyArraySpreadRuleTest.php @@ -0,0 +1,32 @@ + + */ +final class NoConditionalEmptyArraySpreadRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoConditionalEmptyArraySpreadRule; + } + + public function testRule(): void + { + $message = 'This conditional spread hides key omission behind an empty array. Build the array in separate statements and add the key only when present.'; + + $this->analyse([__DIR__.'/data/no-conditional-empty-array-spread.php'], [ + [$message, 11], + [$message, 14], + [$message, 16], + [$message, 18], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoForbiddenTermsInSymbolNamesRuleTest.php b/tools/phpstan/rules/tests/Rules/NoForbiddenTermsInSymbolNamesRuleTest.php new file mode 100644 index 000000000..9bebd244a --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoForbiddenTermsInSymbolNamesRuleTest.php @@ -0,0 +1,37 @@ + + */ +final class NoForbiddenTermsInSymbolNamesRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoForbiddenTermsInSymbolNamesRule(['shape']); + } + + public function testRule(): void + { + $message = 'Rename symbol `%s` for its domain role; `shape` describes structure rather than ownership.'; + + $this->analyse([__DIR__.'/data/no-forbidden-terms-in-symbol-names.php'], [ + [sprintf($message, 'ResponseShape'), 10], + [sprintf($message, 'UserShape'), 10], + [sprintf($message, 'SHAPE_VERSION'), 12], + [sprintf($message, 'payloadShape'), 15], + [sprintf($message, 'shapeOf'), 17], + [sprintf($message, 'shaped'), 17], + [sprintf($message, 'resultShape'), 19], + [sprintf($message, 'shaped'), 19], + [sprintf($message, 'resultShape'), 21], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoInstanceofOnMixedRuleTest.php b/tools/phpstan/rules/tests/Rules/NoInstanceofOnMixedRuleTest.php new file mode 100644 index 000000000..8c7c12e49 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoInstanceofOnMixedRuleTest.php @@ -0,0 +1,28 @@ + + */ +final class NoInstanceofOnMixedRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoInstanceofOnMixedRule(new TypeClassifier, ['src/Boundary/**']); + } + + public function testRule(): void + { + $this->analyse([__DIR__.'/data/no-instanceof-on-mixed.php'], [ + ['This `instanceof` narrows a `mixed` value without establishing its contract. Parse the value at its I/O boundary (cuyz/valinor, spatie/laravel-data), then branch on the domain type.', 9], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoKnownValueWideningReturnRuleTest.php b/tools/phpstan/rules/tests/Rules/NoKnownValueWideningReturnRuleTest.php new file mode 100644 index 000000000..36ff077f4 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoKnownValueWideningReturnRuleTest.php @@ -0,0 +1,28 @@ + + */ +final class NoKnownValueWideningReturnRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoKnownValueWideningReturnRule(new TypeClassifier); + } + + public function testRule(): void + { + $this->analyse([__DIR__.'/data/no-known-value-widening.php'], [ + ['The broad declared return type discards the known evidence of every returned value. Delete the annotation and let inference stand, or introduce a named shape.', 28], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoKnownValueWideningRuleTest.php b/tools/phpstan/rules/tests/Rules/NoKnownValueWideningRuleTest.php new file mode 100644 index 000000000..6221a6ee8 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoKnownValueWideningRuleTest.php @@ -0,0 +1,31 @@ + + */ +final class NoKnownValueWideningRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoKnownValueWideningPropertyRule(new TypeClassifier); + } + + public function testRule(): void + { + $message = 'The broad declared type on property `$%s` discards its default value\'s evidence. Delete the annotation and let inference stand, or introduce a named shape.'; + + $this->analyse([__DIR__.'/data/no-known-value-widening.php'], [ + [sprintf($message, 'handlers'), 10], + [sprintf($message, 'marker'), 20], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoMixedParametersRuleTest.php b/tools/phpstan/rules/tests/Rules/NoMixedParametersRuleTest.php new file mode 100644 index 000000000..396c83390 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoMixedParametersRuleTest.php @@ -0,0 +1,40 @@ + + */ +final class NoMixedParametersRuleTest extends RuleTestCase +{ + public function test_rule(): void + { + $message = 'Parameter `$%s` leaves input unparsed. Accept a named domain type; run the expected schema or parser (cuyz/valinor, spatie/laravel-data) at the I/O boundary before calling this function.'; + + $this->analyse([__DIR__.'/data/no-mixed-parameters.php'], [ + [sprintf($message, 'input'), 11], + [sprintf($message, 'payload'), 16], + [sprintf($message, 'input'), 32], + [sprintf($message, 'value'), 57], + [sprintf($message, 'value'), 62], + [sprintf($message, 'thing'), 65], + [sprintf($message, 'item'), 67], + ]); + } + + protected function getRule(): Rule + { + return new NoMixedParametersRule( + new SignatureResolver($this->createReflectionProvider()), + new TypeClassifier, + ); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoMixedReturnsRuleTest.php b/tools/phpstan/rules/tests/Rules/NoMixedReturnsRuleTest.php new file mode 100644 index 000000000..ccc32b38a --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoMixedReturnsRuleTest.php @@ -0,0 +1,40 @@ + + */ +final class NoMixedReturnsRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoMixedReturnsRule( + new SignatureResolver($this->createReflectionProvider()), + new TypeClassifier, + ); + } + + public function testRule(): void + { + $returns = 'This function exposes `mixed` to its caller. Parse the value at its boundary (cuyz/valinor, spatie/laravel-data) and return a named domain type.'; + $yields = 'This function yields `mixed` values to its caller. Parse each value at its boundary and yield a named domain type.'; + + $this->analyse([__DIR__.'/data/no-mixed-returns.php'], [ + [$returns, 7], + [$returns, 15], + [$yields, 23], + [$yields, 31], + [$returns, 64], + [$returns, 70], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoMixedTypeAliasesRuleTest.php b/tools/phpstan/rules/tests/Rules/NoMixedTypeAliasesRuleTest.php new file mode 100644 index 000000000..6e03c32d5 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoMixedTypeAliasesRuleTest.php @@ -0,0 +1,33 @@ + + */ +final class NoMixedTypeAliasesRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoMixedTypeAliasesRule(new TypeAliasDocblock); + } + + public function testRule(): void + { + $message = 'Type alias `%s` hides `mixed`. Keep `mixed` explicit at the parsing boundary; otherwise alias the parsed owner type.'; + + $this->analyse([__DIR__.'/data/no-mixed-type-aliases.php'], [ + [sprintf($message, 'ExternalValue'), 15], + [sprintf($message, 'MaybeMixed'), 15], + [sprintf($message, 'LoosePsalm'), 15], + [sprintf($message, 'Hidden'), 15], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoObjectParametersRuleTest.php b/tools/phpstan/rules/tests/Rules/NoObjectParametersRuleTest.php new file mode 100644 index 000000000..326cd0a79 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoObjectParametersRuleTest.php @@ -0,0 +1,38 @@ + + */ +final class NoObjectParametersRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoObjectParametersRule( + new SignatureResolver($this->createReflectionProvider()), + new TypeClassifier, + ); + } + + public function testRule(): void + { + $message = 'Parameter `$%s` uses the broad `object` type. Accept a named owner type; parse external input (cuyz/valinor, spatie/laravel-data) at its boundary before calling this function.'; + + $this->analyse([__DIR__.'/data/no-object-parameters.php'], [ + [sprintf($message, 'input'), 7], + [sprintf($message, 'payload'), 12], + [sprintf($message, 'maybe'), 14], + [sprintf($message, 'target'), 26], + [sprintf($message, 'thing'), 29], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoServiceConstructionRuleTest.php b/tools/phpstan/rules/tests/Rules/NoServiceConstructionRuleTest.php new file mode 100644 index 000000000..c022962e3 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoServiceConstructionRuleTest.php @@ -0,0 +1,31 @@ + + */ +final class NoServiceConstructionRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoServiceConstructionRule(['App\\Services\\'], ['app/Providers/**']); + } + + public function testRule(): void + { + $message = 'Runtime code constructs the service `App\Services\ReportBuilder` instead of receiving it. Inject it through the constructor and let the container own the wiring.'; + + $this->analyse([__DIR__.'/data/no-service-construction.php'], [ + [$message, 24], + [$message, 29], + [$message, 34], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryPropertyRuleTest.php b/tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryPropertyRuleTest.php new file mode 100644 index 000000000..f163e3d85 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryPropertyRuleTest.php @@ -0,0 +1,30 @@ + + */ +final class NoUnsafeDictionaryPropertyRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoUnsafeDictionaryPropertyRule(new TypeClassifier); + } + + public function testRule(): void + { + $this->analyse([__DIR__.'/data/no-unsafe-dictionary-property.php'], [ + ['Property `$meta` is a dictionary of `mixed` values, which stores data without a value contract. Declare an `array{...}` shape or a readonly DTO; parse external payloads before insertion.', 10], + ['Property `$bag` is a dictionary of `object` values, which stores data without a value contract. Declare an `array{...}` shape or a readonly DTO; parse external payloads before insertion.', 13], + ['Property `$blob` is typed `stdClass`, an anonymous bag with no contract. Declare a named readonly DTO and parse external payloads into it.', 15], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryTypeRuleTest.php b/tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryTypeRuleTest.php new file mode 100644 index 000000000..0320387c1 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoUnsafeDictionaryTypeRuleTest.php @@ -0,0 +1,41 @@ + + */ +final class NoUnsafeDictionaryTypeRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoUnsafeDictionaryTypeRule( + new SignatureResolver($this->createReflectionProvider()), + new TypeClassifier, + ); + } + + public function testRule(): void + { + $parameter = "Parameter `\$%s` is a dictionary of `%s` values, which gives callers no value contract. Declare an `array{...}` shape or a readonly DTO; parse external payloads (cuyz/valinor, spatie/laravel-data) before insertion."; + + $this->analyse([__DIR__.'/data/no-unsafe-dictionary-type.php'], [ + [sprintf($parameter, 'meta', 'mixed'), 10], + [sprintf($parameter, 'bag', 'object'), 15], + [sprintf($parameter, 'nested', 'untyped array'), 20], + [sprintf($parameter, 'items', 'mixed'), 25], + [sprintf($parameter, 'stream', 'mixed'), 30], + [sprintf($parameter, 'unionValues', 'object'), 35], + [sprintf($parameter, 'rows', 'stdClass'), 40], + ['This function returns a dictionary of `mixed` values, which gives callers no value contract. Declare an `array{...}` shape or a readonly DTO; parse external payloads before returning them.', 45], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/NoWidenThenAssertRuleTest.php b/tools/phpstan/rules/tests/Rules/NoWidenThenAssertRuleTest.php new file mode 100644 index 000000000..813b099d4 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/NoWidenThenAssertRuleTest.php @@ -0,0 +1,32 @@ + + */ +final class NoWidenThenAssertRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new NoWidenThenAssertRule(new AssertionForms); + } + + public function testRule(): void + { + $message = 'Binding `$%s` discards type evidence and later recreates it with an assertion. Keep the precise type from initialization through use; parse boundary input once.'; + + $this->analyse([__DIR__.'/data/no-widen-then-assert.php'], [ + [sprintf($message, 'widened'), 17], + [sprintf($message, 'data'), 26], + [sprintf($message, 'vars'), 35], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/RequireSafetyCommentForAssertionRuleTest.php b/tools/phpstan/rules/tests/Rules/RequireSafetyCommentForAssertionRuleTest.php new file mode 100644 index 000000000..2140f3a7e --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/RequireSafetyCommentForAssertionRuleTest.php @@ -0,0 +1,34 @@ + + */ +final class RequireSafetyCommentForAssertionRuleTest extends RuleTestCase +{ + protected function getRule(): Rule + { + return new RequireSafetyCommentForAssertionRule(new AssertionForms); + } + + public function testRule(): void + { + $assertion = 'This type assertion has no `SAFETY:` justification. State the checked invariant immediately before the assertion or its containing statement.'; + $varTag = 'This inline `@var` overrides inference without a `SAFETY:` justification. State the checked invariant in the docblock or immediately before the statement.'; + + $this->analyse([__DIR__.'/data/require-safety-comment.php'], [ + [$assertion, 14], + [$varTag, 20], + [$assertion, 25], + [$assertion, 30], + ]); + } +} diff --git a/tools/phpstan/rules/tests/Rules/data/no-chained-assertions.php b/tools/phpstan/rules/tests/Rules/data/no-chained-assertions.php new file mode 100644 index 000000000..850219bf2 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-chained-assertions.php @@ -0,0 +1,16 @@ +createMock(Clock::class); + $abstractMock = $this->createMock(BaseRepository::class); + + $concreteMock = $this->createMock(SystemClock::class); // error: line 32 + $concreteStub = $this->createStub(SystemClock::class); // error: line 33 + $builder = $this->getMockBuilder(SystemClock::class); // error: line 34 + + $mockeryInterface = \Mockery::mock(Clock::class); + $mockeryConcrete = \Mockery::mock(SystemClock::class); // error: line 37 + $overloaded = \Mockery::mock('overload:Rules\Tests\Data\NoClassLoadingMocks\SystemClock'); // error: line 38 + $aliased = \Mockery::mock('alias:Rules\Tests\Data\NoClassLoadingMocks\SystemClock'); // error: line 39 + + \assert($interfaceMock instanceof Clock || true); + unset($abstractMock, $concreteMock, $concreteStub, $builder, $mockeryInterface, $mockeryConcrete, $overloaded, $aliased); + } +} + +final class NotATest +{ + public function mock(string $class): string + { + return $class; + } + + public function usesOwnMock(): string + { + return $this->mock(SystemClock::class); + } +} diff --git a/tools/phpstan/rules/tests/Rules/data/no-conditional-empty-array-spread.php b/tools/phpstan/rules/tests/Rules/data/no-conditional-empty-array-spread.php new file mode 100644 index 000000000..9309cc36d --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-conditional-empty-array-spread.php @@ -0,0 +1,25 @@ + 1, + ...($condition ? ['key' => $value] : []), // error: line 11 + ]; + + $viaMerge = array_merge(['base' => 1], $condition ? ['key' => $value] : []); // error: line 14 + + $viaReplace = array_replace(['base' => 1], $condition ? [] : ['key' => $value]); // error: line 16 + + $viaPlus = ['base' => 1] + ($condition ? ['key' => $value] : []); // error: line 18 + + $fineSpread = [...['a' => 1], ...['b' => 2]]; + $fineTernary = $condition ? ['key' => $value] : ['key' => 0]; + $fineMerge = array_merge(['a' => 1], ['b' => 2]); + + return [$viaSpread, $viaMerge, $viaReplace, $viaPlus, $fineSpread, $fineTernary, $fineMerge]; +} diff --git a/tools/phpstan/rules/tests/Rules/data/no-forbidden-terms-in-symbol-names.php b/tools/phpstan/rules/tests/Rules/data/no-forbidden-terms-in-symbol-names.php new file mode 100644 index 000000000..a496377c3 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-forbidden-terms-in-symbol-names.php @@ -0,0 +1,31 @@ + */ + public array $handlers = ['start' => 'startHandler']; // error: line 10 + + public object $config; // no default: fine here (dictionary rule owns the type itself) + + /** @var array */ + public array $empty = []; // empty array carries no evidence: fine + + /** @var array{start: string} */ + public array $shaped = ['start' => 'startHandler']; + + public mixed $marker = 'sentinel'; // error: line 20 + + public function __construct() + { + $this->config = new \stdClass; + } +} + +function widensReturn(): mixed // error: line 28 +{ + return ['start' => 'startHandler']; +} + +function keepsInference(): array // level 6 owns the missing value type; evidence intact +{ + return ['start' => 'startHandler']; +} + +/** + * @return array{start: string} + */ +function named(): array +{ + return ['start' => 'startHandler']; +} + +function conditional(bool $flag): mixed +{ + if ($flag) { + return ['start' => 'startHandler']; + } + + return unserialize('b:0;'); // one un-known return: not flagged +} diff --git a/tools/phpstan/rules/tests/Rules/data/no-mixed-parameters.php b/tools/phpstan/rules/tests/Rules/data/no-mixed-parameters.php new file mode 100644 index 000000000..66cdd7e95 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-mixed-parameters.php @@ -0,0 +1,69 @@ + 1; // error: line 45 + +$typedClosure = function (string $name): void {}; diff --git a/tools/phpstan/rules/tests/Rules/data/no-mixed-returns.php b/tools/phpstan/rules/tests/Rules/data/no-mixed-returns.php new file mode 100644 index 000000000..9db140f15 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-mixed-returns.php @@ -0,0 +1,72 @@ + + */ +function generatorOfMixed(): \Generator // error: line 23 +{ + yield 1; +} + +/** + * @return iterable + */ +function iterableOfMixed(): iterable // error: line 30 +{ + return []; +} + +function typed(): string +{ + return 'a'; +} + +function nothing(): never +{ + throw new \RuntimeException('halt'); +} + +/** + * @return \Generator + */ +function generatorOfString(): \Generator +{ + yield 'a'; +} + +final class Bag +{ + /** @var array */ + private array $items = []; + + public function __get(string $name): mixed + { + return $this->items[$name] ?? null; + } + + public function grab(string $name): mixed // error: line 63 + { + return $this->items[$name] ?? null; + } +} + +$closure = function (): mixed { // error: line 69 + return 1; +}; diff --git a/tools/phpstan/rules/tests/Rules/data/no-mixed-type-aliases.php b/tools/phpstan/rules/tests/Rules/data/no-mixed-type-aliases.php new file mode 100644 index 000000000..e134699c9 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-mixed-type-aliases.php @@ -0,0 +1,26 @@ +injected; + } + + public function otherClass(): \DateTimeImmutable + { + return new \DateTimeImmutable; // not a service namespace: fine + } + } +} diff --git a/tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-property.php b/tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-property.php new file mode 100644 index 000000000..c2fe6906e --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-property.php @@ -0,0 +1,28 @@ + */ + public array $meta = []; // error: line 10 + + /** @var array */ + private array $bag = []; // error: line 13 + + public \stdClass $blob; // error: line 15 + + /** @var array */ + public array $safe = []; + + /** @var array{id: int} */ + public array $shape = ['id' => 1]; + + public function touch(): void + { + $this->bag = []; + $this->blob = new \stdClass; + } +} diff --git a/tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-type.php b/tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-type.php new file mode 100644 index 000000000..ea3c3d908 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-unsafe-dictionary-type.php @@ -0,0 +1,55 @@ + $meta + */ +function mixedValues(array $meta): void {} // error: line 10 + +/** + * @param array $bag + */ +function objectValues(array $bag): void {} // error: line 15 + +/** + * @param array $nested + */ +function untypedArrayValues(array $nested): void {} // error: line 20 + +/** + * @param list $items + */ +function mixedList(array $items): void {} // error: line 25 + +/** + * @param iterable $stream + */ +function mixedIterable(iterable $stream): void {} // error: line 30 + +/** + * @param array $unionValues + */ +function unionEscape(array $unionValues): void {} // error: line 35 + +/** + * @param array $rows + */ +function stdClassValues(array $rows): void {} // error: line 40 + +/** + * @return array + */ +function returnsMixedDict(): array // error: line 45 +{ + return []; +} + +/** + * @param array $safe + * @param array{id: int, meta: mixed} $shape + * @param list<\DateTimeImmutable> $moments + */ +function fine(array $safe, array $shape, array $moments): void {} diff --git a/tools/phpstan/rules/tests/Rules/data/no-widen-then-assert.php b/tools/phpstan/rules/tests/Rules/data/no-widen-then-assert.php new file mode 100644 index 000000000..87613e9db --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/no-widen-then-assert.php @@ -0,0 +1,56 @@ + 'fresh']; + + /** @var array{id: string} $value */ + $value; + + return $value['id']; +} + +function neverWidened(Payload $payload): string +{ + $direct = $payload->id; + + return (string) $direct; +} diff --git a/tools/phpstan/rules/tests/Rules/data/require-safety-comment.php b/tools/phpstan/rules/tests/Rules/data/require-safety-comment.php new file mode 100644 index 000000000..ea316d9c4 --- /dev/null +++ b/tools/phpstan/rules/tests/Rules/data/require-safety-comment.php @@ -0,0 +1,35 @@ + $attributes + * @param list $mutatedAttributes + * @return array + */ + protected function addCastAttributesToArray(array $attributes, array $mutatedAttributes); + + /** @return list */ + public function getMutatedAttributes(); +} diff --git a/tsconfig.json b/tsconfig.json index a425fd922..ef160cfd6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,47 +1,28 @@ { "compilerOptions": { - "target": "es2015", - "module": "es2020", + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", "jsx": "react-jsx", - "moduleResolution": "node", - "lib": [ - "es2015", - "dom" - ], + "lib": ["ES2022", "DOM", "DOM.Iterable"], + // Browser-only ambient types. We deliberately do NOT auto-load @types/node so + // node globals (process/Buffer/NodeJS) can't leak in and clash with lib.dom; + // everything else resolves through imports under `moduleResolution: bundler`. + "types": ["vite/client"], "strict": true, + "isolatedModules": true, "noEmit": true, "sourceMap": true, "noImplicitReturns": true, "skipLibCheck": true, - "skipDefaultLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "baseUrl": ".", "verbatimModuleSyntax": false, "paths": { - "@/*": [ - "./resources/scripts/*" - ], - "@definitions/*": [ - "./resources/scripts/api/definitions/*" - ], - "@feature/*": [ - "./resources/scripts/components/server/features/*" - ] - }, - "plugins": [ - { - "name": "typescript-plugin-tw-template" - } - ], - "typeRoots": [ - "node_modules/@types" - ] + "@/*": ["./resources/scripts/*"], + "@feature/*": ["./resources/scripts/components/server/features/*"] + } }, - "include": [ - "./resources/scripts/**/*" - ], - "exclude": [ - "/node_modules/" - ] + "include": ["./resources/scripts/**/*"], + "exclude": ["node_modules"] } diff --git a/vite.config.mts b/vite.config.mts new file mode 100644 index 000000000..1ec666b7b --- /dev/null +++ b/vite.config.mts @@ -0,0 +1,130 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react-swc'; +import { fileURLToPath, URL } from 'node:url'; +import { createHash } from 'node:crypto'; +import { readFileSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; + +// A single build hash exposed to the app the same way the old webpack EnvironmentPlugin did. +const buildHash = process.env.PTERODACTYL_BUILD_HASH ?? Date.now().toString(16); + +type ViteManifestEntry = { + file: string; + integrity: string; + css?: string[]; + cssIntegrity?: Record; +}; + +function integrityFor(outDir: string, fileName: string) { + const contents = readFileSync(join(outDir, fileName)); + + return 'sha384-' + createHash('sha384').update(contents).digest('base64'); +} + +/** Add SRI data to Vite's native manifest without changing its shape or keys. */ +function manifestIntegrity() { + return { + name: 'pterodactyl-manifest-integrity', + apply: 'build' as const, + enforce: 'post' as const, + writeBundle(options: { dir?: string }) { + const outDir = options.dir!; + const manifestPath = join(outDir, 'manifest.json'); + const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as Record; + + for (const entry of Object.values(manifest)) { + entry.integrity = integrityFor(outDir, entry.file); + if (entry.css?.length) { + entry.cssIntegrity = Object.fromEntries( + entry.css.map((fileName) => [fileName, integrityFor(outDir, fileName)]) + ); + } + } + + writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n'); + }, + }; +} + +export default defineConfig(({ mode }) => { + const isProduction = mode === 'production'; + + return { + base: '/assets/', + // Laravel already serves public/ directly; copying it into public/assets + // would recurse because the build output itself lives under public/. + publicDir: false, + define: { + // process.env.NODE_ENV is still consumed by bundled third-party libs (React et al.). + 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'), + // App code reads the build hash via import.meta.env (see resources/scripts/vite-env.d.ts); + // debug toggling uses Vite's built-in import.meta.env.DEV. + 'import.meta.env.WEBPACK_BUILD_HASH': JSON.stringify(buildHash), + }, + resolve: { + alias: { + '@': fileURLToPath(new URL('./resources/scripts', import.meta.url)), + '@feature': fileURLToPath(new URL('./resources/scripts/components/server/features', import.meta.url)), + }, + }, + plugins: [ + // SWC-based React plugin (Fast Refresh + automatic JSX runtime) — replaces the + // Babel-based @vitejs/plugin-react, removing Babel from the toolchain entirely. + // No custom transforms are needed (twin.macro / styled-components are long gone). + react(), + manifestIntegrity(), + ], + build: { + outDir: 'public/assets', + manifest: 'manifest.json', + // Don't wipe the directory — it holds tracked legacy webpack output + fonts/images. + // Hashed filenames prevent collisions; stale files can be pruned separately. + emptyOutDir: false, + assetsDir: '', + sourcemap: !isProduction, + chunkSizeWarningLimit: 2000, + rollupOptions: { + input: { + main: fileURLToPath(new URL('./resources/scripts/index.tsx', import.meta.url)), + // Shared extension-runtime entries: each is emitted as a real module + // chunk whose exports ARE the package's exports, at a URL recorded in + // manifest.json. The import map maps bare specifiers ("react", ...) + // to these URLs, so runtime-loaded extension bundles share the exact + // module instances the panel itself uses — one React, one QueryClient. + // Each entry goes through a tiny wrapper module (see ext-runtime/*.ts): + // React et al. are CommonJS, and a direct package entry would emit a + // default-only facade — the wrappers force full named-export synthesis. + react: fileURLToPath(new URL('./resources/scripts/ext-runtime/react.ts', import.meta.url)), + 'react-jsx-runtime': fileURLToPath( + new URL('./resources/scripts/ext-runtime/react-jsx-runtime.ts', import.meta.url) + ), + 'react-dom': fileURLToPath( + new URL('./resources/scripts/ext-runtime/react-dom.ts', import.meta.url) + ), + 'react-dom-client': fileURLToPath( + new URL('./resources/scripts/ext-runtime/react-dom-client.ts', import.meta.url) + ), + 'tanstack-react-query': fileURLToPath( + new URL('./resources/scripts/ext-runtime/tanstack-react-query.ts', import.meta.url) + ), + sdk: fileURLToPath(new URL('./resources/scripts/sdk/index.ts', import.meta.url)), + 'sdk-api': fileURLToPath(new URL('./resources/scripts/sdk/api.ts', import.meta.url)), + }, + // Keep every entry's export signature intact — the runtime entries are + // consumed as libraries by extension bundles via the import map. + preserveEntrySignatures: 'strict' as const, + output: { + entryFileNames: (chunk: { name: string }) => + chunk.name === 'main' ? 'bundle.[hash].js' : 'ext-runtime.[name].[hash].js', + chunkFileNames: '[name].[hash].js', + assetFileNames: '[name].[hash][extname]', + }, + }, + }, + server: { + host: true, + port: 5173, + strictPort: false, + }, + }; +}); diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 000000000..1d192b36a --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,29 @@ +import { defineConfig } from 'vitest/config'; +import { fileURLToPath, URL } from 'node:url'; + +// Standalone Vitest config — deliberately separate from vite.config.ts so the test +// run doesn't pull in the SPA build plugins (CSS-injected-by-JS, manifest emitter). +// The specs are pure-function unit tests, so the default `node` environment is enough. +export default defineConfig({ + resolve: { + alias: { + '@': fileURLToPath(new URL('./resources/scripts', import.meta.url)), + '@feature': fileURLToPath(new URL('./resources/scripts/components/server/features', import.meta.url)), + }, + }, + test: { + projects: [{ extends: true, test: { name: 'panel' } }, 'packages/hello-world/vitest.config.ts'], + environment: 'node', + setupFiles: ['./resources/scripts/setup-tests.ts'], + include: [ + 'resources/scripts/**/*.spec.{ts,tsx}', + 'examples/*/build-contract.spec.ts', + 'extensions/*/build-contract.spec.ts', + 'packages/sdk/*.spec.ts', + 'tools/oxlint/**/*.spec.ts', + ], + // Keep transient git worktrees (under .claude/) out of the run so the suite + // count reflects the real tracked specs, not duplicated copies. + exclude: ['**/node_modules/**', '.claude/**'], + }, +}); diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index af808697e..000000000 --- a/webpack.config.js +++ /dev/null @@ -1,161 +0,0 @@ -const path = require('node:path'); -const webpack = require('webpack'); -const { WebpackAssetsManifest } = require('webpack-assets-manifest'); -const TerserPlugin = require('terser-webpack-plugin'); - -const isProduction = process.env.NODE_ENV === 'production'; - -module.exports = { - cache: true, - target: 'web', - mode: isProduction ? 'production' : 'development', - devtool: process.env.DEVTOOL || (isProduction ? false : 'eval-source-map'), - performance: { - hints: false, - }, - entry: ['react-hot-loader/patch', './resources/scripts/index.tsx'], - output: { - path: path.join(__dirname, '/public/assets'), - filename: isProduction ? 'bundle.[chunkhash:8].js' : 'bundle.[fullhash:8].js', - chunkFilename: isProduction ? '[name].[chunkhash:8].js' : '[name].[fullhash:8].js', - publicPath: process.env.WEBPACK_PUBLIC_PATH || '/assets/', - crossOriginLoading: 'anonymous', - }, - module: { - rules: [ - { - test: /\.tsx?$/, - exclude: /node_modules|\.spec\.tsx?$/, - loader: 'babel-loader', - }, - { - test: /\.mjs$/, - include: /node_modules/, - type: 'javascript/auto', - }, - { - test: /\.css$/, - use: [ - { loader: 'style-loader' }, - { - loader: 'css-loader', - options: { - modules: { - auto: true, - // https://github.com/webpack/css-loader/blob/main/CHANGELOG.md#700-2024-04-04 - namedExport: false, - exportLocalsConvention: 'as-is', - localIdentName: isProduction ? '[name]_[hash:base64:8]' : '[path][name]__[local]', - localIdentContext: path.join(__dirname, 'resources/scripts/components'), - }, - sourceMap: !isProduction, - importLoaders: 1, - }, - }, - { - loader: 'postcss-loader', - options: { sourceMap: !isProduction }, - }, - ], - }, - { - test: /\.(png|jp(e?)g|gif)$/, - loader: 'file-loader', - options: { - name: 'images/[name].[hash:8].[ext]', - }, - }, - { - test: /\.(woff|woff2)$/i, - type: 'asset/resource', - }, - { - test: /\.svg$/, - loader: 'svg-url-loader', - }, - { - test: /\.js$/, - enforce: 'pre', - loader: 'source-map-loader', - }, - ], - }, - stats: { - // Ignore warnings emitted by "source-map-loader" when trying to parse source maps from - // JS plugins we use, namely brace editor. - warningsFilter: [/Failed to parse source map/], - }, - resolve: { - extensions: ['.ts', '.tsx', '.js', '.json'], - alias: { - '@': path.join(__dirname, '/resources/scripts'), - '@definitions': path.join(__dirname, '/resources/scripts/api/definitions'), - '@feature': path.join(__dirname, '/resources/scripts/components/server/features'), - }, - symlinks: false, - }, - externals: { - // Mark moment as an external to exclude it from the Chart.js build since we don't need to use - // it for anything. - moment: 'moment', - }, - plugins: [ - new webpack.EnvironmentPlugin({ - NODE_ENV: process.env.NODE_ENV || 'development', - DEBUG: process.env.NODE_ENV !== 'production', - WEBPACK_BUILD_HASH: Date.now().toString(16), - }), - new WebpackAssetsManifest({ - output: 'manifest.json', - writeToDisk: true, - publicPath: true, - integrity: true, - integrityHashes: ['sha384'], - }), - ], - optimization: { - usedExports: true, - sideEffects: false, - runtimeChunk: false, - removeEmptyChunks: true, - minimize: isProduction, - minimizer: [ - new TerserPlugin({ - parallel: true, - extractComments: false, - terserOptions: { - mangle: true, - output: { - comments: false, - }, - }, - }), - ], - }, - watchOptions: { - poll: 1000, - ignored: /node_modules/, - }, - devServer: { - compress: true, - port: 5173, - server: { - type: 'https', - options: process.env.USE_LOCAL_CERTS - ? { - ca: path.join(__dirname, '../../docker/certificates/root_ca.pem'), - cert: path.join(__dirname, '../../docker/certificates/pterodactyl.test.pem'), - key: path.join(__dirname, '../../docker/certificates/pterodactyl.test-key.pem'), - } - : undefined, - }, - static: { - directory: path.join(__dirname, '/public'), - publicPath: process.env.WEBPACK_PUBLIC_PATH || '/assets/', - }, - allowedHosts: ['.pterodactyl.test'], - headers: { - 'Access-Control-Allow-Origin': '*', - }, - }, -}; diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index e85789403..000000000 --- a/yarn.lock +++ /dev/null @@ -1,9856 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@alloc/quick-lru@^5.2.0": - version "5.2.0" - resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30" - integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw== - -"@ampproject/remapping@^2.1.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.3.0.tgz#ed441b6fa600072520ce18b43d2c8cc8caecc7f4" - integrity sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.5" - "@jridgewell/trace-mapping" "^0.3.24" - -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.27.1.tgz#200f715e66d52a23b221a9435534a91cc13ad5be" - integrity sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg== - dependencies: - "@babel/helper-validator-identifier" "^7.27.1" - js-tokens "^4.0.0" - picocolors "^1.1.1" - -"@babel/code-frame@^7.10.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789" - integrity sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg== - dependencies: - "@babel/highlight" "^7.16.7" - -"@babel/compat-data@^7.12.1": - version "7.18.5" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.18.5.tgz#acac0c839e317038c73137fbb6ef71a1d6238471" - integrity sha512-BxhE40PVCBxVEJsSBhB6UWyAuqJRxGsAw8BdHMJ3AKGydcwuWW4kOO3HmqBQAdcq/OP+/DlTVxLvsCzRTnZuGg== - -"@babel/compat-data@^7.17.10", "@babel/compat-data@^7.27.2": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.28.5.tgz#a8a4962e1567121ac0b3b487f52107443b455c7f" - integrity sha512-6uFXyCayocRbqhZOB+6XcuZbkMNimwfVGFji8CTZnCzOHVGvDqzvitu1re2AU5LROliz7eQPhB8CpAMvnx9EjA== - -"@babel/core@^7.11.6", "@babel/core@^7.12.3": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.28.5.tgz#4c81b35e51e1b734f510c99b07dfbc7bbbb48f7e" - integrity sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw== - dependencies: - "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.28.5" - "@babel/helper-compilation-targets" "^7.27.2" - "@babel/helper-module-transforms" "^7.28.3" - "@babel/helpers" "^7.28.4" - "@babel/parser" "^7.28.5" - "@babel/template" "^7.27.2" - "@babel/traverse" "^7.28.5" - "@babel/types" "^7.28.5" - "@jridgewell/remapping" "^2.3.5" - convert-source-map "^2.0.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.2.3" - semver "^6.3.1" - -"@babel/core@^7.12.1": - version "7.18.5" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.18.5.tgz#c597fa680e58d571c28dda9827669c78cdd7f000" - integrity sha512-MGY8vg3DxMnctw0LdvSEojOsumc70g0t18gNyUdAZqB1Rpd1Bqo/svHGvt+UJ6JcGX+DIekGFDxxIWofBxLCnQ== - dependencies: - "@ampproject/remapping" "^2.1.0" - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.18.2" - "@babel/helper-compilation-targets" "^7.18.2" - "@babel/helper-module-transforms" "^7.18.0" - "@babel/helpers" "^7.18.2" - "@babel/parser" "^7.18.5" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.18.5" - "@babel/types" "^7.18.4" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.2.1" - semver "^6.3.0" - -"@babel/generator@^7.18.2", "@babel/generator@^7.28.5", "@babel/generator@^7.7.2": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.28.5.tgz#712722d5e50f44d07bc7ac9fe84438742dd61298" - integrity sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ== - dependencies: - "@babel/parser" "^7.28.5" - "@babel/types" "^7.28.5" - "@jridgewell/gen-mapping" "^0.3.12" - "@jridgewell/trace-mapping" "^0.3.28" - jsesc "^3.0.2" - -"@babel/helper-annotate-as-pure@^7.10.4", "@babel/helper-annotate-as-pure@^7.16.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" - integrity sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-annotate-as-pure@^7.22.5": - version "7.27.3" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz#f31fd86b915fc4daf1f3ac6976c59be7084ed9c5" - integrity sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg== - dependencies: - "@babel/types" "^7.27.3" - -"@babel/helper-builder-binary-assignment-operator-visitor@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.10.4.tgz#bb0b75f31bf98cbf9ff143c1ae578b87274ae1a3" - integrity sha512-L0zGlFrGWZK4PbT8AszSfLTM5sDU1+Az/En9VrdT8/LmEiJt4zXt+Jve9DCAnQcbqDhCI+29y/L93mrDzddCcg== - dependencies: - "@babel/helper-explode-assignable-expression" "^7.10.4" - "@babel/types" "^7.10.4" - -"@babel/helper-builder-react-jsx-experimental@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx-experimental/-/helper-builder-react-jsx-experimental-7.12.1.tgz#1f1ad4c95f1d059856d2fdbc0763489d020cd02d" - integrity sha512-82to8lR7TofZWbTd3IEZT1xNHfeU/Ef4rDm/GLXddzqDh+yQ19QuGSzqww51aNxVH8rwfRIzL0EUQsvODVhtyw== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-module-imports" "^7.12.1" - "@babel/types" "^7.12.1" - -"@babel/helper-builder-react-jsx@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.10.4.tgz#8095cddbff858e6fa9c326daee54a2f2732c1d5d" - integrity sha512-5nPcIZ7+KKDxT1427oBivl9V9YTal7qk0diccnh7RrcgrT/pGFOjgGw1dgryyx1GvHEpXVfoDF6Ak3rTiWh8Rg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/types" "^7.10.4" - -"@babel/helper-compilation-targets@^7.12.1": - version "7.18.2" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.2.tgz#67a85a10cbd5fc7f1457fec2e7f45441dc6c754b" - integrity sha512-s1jnPotJS9uQnzFtiZVBUxe67CuBa679oWFHpxYYnTpRL/1ffhyX44R9uYiXoa/pLXcY9H2moJta0iaanlk/rQ== - dependencies: - "@babel/compat-data" "^7.17.10" - "@babel/helper-validator-option" "^7.16.7" - browserslist "^4.20.2" - semver "^6.3.0" - -"@babel/helper-compilation-targets@^7.18.2", "@babel/helper-compilation-targets@^7.27.2": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz#46a0f6efab808d51d29ce96858dd10ce8732733d" - integrity sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ== - dependencies: - "@babel/compat-data" "^7.27.2" - "@babel/helper-validator-option" "^7.27.1" - browserslist "^4.24.0" - lru-cache "^5.1.1" - semver "^6.3.1" - -"@babel/helper-create-class-features-plugin@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.12.1.tgz#3c45998f431edd4a9214c5f1d3ad1448a6137f6e" - integrity sha512-hkL++rWeta/OVOBTRJc9a5Azh5mt5WgZUGAKMD8JM141YsE08K//bp1unBBieO6rUKkIPyUE0USQ30jAy3Sk1w== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-member-expression-to-functions" "^7.12.1" - "@babel/helper-optimise-call-expression" "^7.10.4" - "@babel/helper-replace-supers" "^7.12.1" - "@babel/helper-split-export-declaration" "^7.10.4" - -"@babel/helper-create-regexp-features-plugin@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.12.1.tgz#18b1302d4677f9dc4740fe8c9ed96680e29d37e8" - integrity sha512-rsZ4LGvFTZnzdNZR5HZdmJVuXK8834R5QkF3WvcnBhrlVtF0HSIUC6zbreL9MgjTywhKokn8RIYRiq99+DLAxA== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-regex" "^7.10.4" - regexpu-core "^4.7.1" - -"@babel/helper-define-map@^7.10.4": - version "7.10.5" - resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.10.5.tgz#b53c10db78a640800152692b13393147acb9bb30" - integrity sha512-fMw4kgFB720aQFXSVaXr79pjjcW5puTCM16+rECJ/plGS+zByelE8l9nCpV1GibxTnFVmUuYG9U8wYfQHdzOEQ== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/types" "^7.10.5" - lodash "^4.17.19" - -"@babel/helper-environment-visitor@^7.16.7", "@babel/helper-environment-visitor@^7.18.2": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz#4b31ba9551d1f90781ba83491dd59cf9b269f7d9" - integrity sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ== - dependencies: - "@babel/types" "^7.24.7" - -"@babel/helper-explode-assignable-expression@^7.10.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.12.1.tgz#8006a466695c4ad86a2a5f2fb15b5f2c31ad5633" - integrity sha512-dmUwH8XmlrUpVqgtZ737tK88v07l840z9j3OEhCLwKTkjlvKpfqXVIZ0wpK3aeOxspwGrf/5AP5qLx4rO3w5rA== - dependencies: - "@babel/types" "^7.12.1" - -"@babel/helper-function-name@^7.10.4": - version "7.17.9" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz#136fcd54bc1da82fcb47565cf16fd8e444b1ff12" - integrity sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg== - dependencies: - "@babel/template" "^7.16.7" - "@babel/types" "^7.17.0" - -"@babel/helper-function-name@^7.17.9": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz#75f1e1725742f39ac6584ee0b16d94513da38dd2" - integrity sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA== - dependencies: - "@babel/template" "^7.24.7" - "@babel/types" "^7.24.7" - -"@babel/helper-globals@^7.28.0": - version "7.28.0" - resolved "https://registry.yarnpkg.com/@babel/helper-globals/-/helper-globals-7.28.0.tgz#b9430df2aa4e17bc28665eadeae8aa1d985e6674" - integrity sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw== - -"@babel/helper-hoist-variables@^7.10.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz#86bcb19a77a509c7b77d0e22323ef588fa58c246" - integrity sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-hoist-variables@^7.16.7": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz#b4ede1cde2fd89436397f30dc9376ee06b0f25ee" - integrity sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ== - dependencies: - "@babel/types" "^7.24.7" - -"@babel/helper-member-expression-to-functions@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.12.1.tgz#fba0f2fcff3fba00e6ecb664bb5e6e26e2d6165c" - integrity sha512-k0CIe3tXUKTRSoEx1LQEPFU9vRQfqHtl+kf8eNnDqb4AUJEy5pz6aIiog+YWtVm2jpggjS1laH68bPsR+KWWPQ== - dependencies: - "@babel/types" "^7.12.1" - -"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.16.7", "@babel/helper-module-imports@^7.22.5", "@babel/helper-module-imports@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz#7ef769a323e2655e126673bb6d2d6913bbead204" - integrity sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w== - dependencies: - "@babel/traverse" "^7.27.1" - "@babel/types" "^7.27.1" - -"@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.16.0": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz#25612a8091a999704461c8a222d0efec5d091437" - integrity sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-module-transforms@^7.12.1": - version "7.18.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.18.0.tgz#baf05dec7a5875fb9235bd34ca18bad4e21221cd" - integrity sha512-kclUYSUBIjlvnzN2++K9f2qzYKFgjmnmjwL4zlmU5f8ZtzgWe8s0rUPSTGy2HmK4P8T52MQsS+HTQAgZd3dMEA== - dependencies: - "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-module-imports" "^7.16.7" - "@babel/helper-simple-access" "^7.17.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/helper-validator-identifier" "^7.16.7" - "@babel/template" "^7.16.7" - "@babel/traverse" "^7.18.0" - "@babel/types" "^7.18.0" - -"@babel/helper-module-transforms@^7.18.0", "@babel/helper-module-transforms@^7.28.3": - version "7.28.3" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.28.3.tgz#a2b37d3da3b2344fe085dab234426f2b9a2fa5f6" - integrity sha512-gytXUbs8k2sXS9PnQptz5o0QnpLL51SwASIORY6XaBKF88nsOT0Zw9szLqlSGQDP/4TljBAD5y98p2U1fqkdsw== - dependencies: - "@babel/helper-module-imports" "^7.27.1" - "@babel/helper-validator-identifier" "^7.27.1" - "@babel/traverse" "^7.28.3" - -"@babel/helper-optimise-call-expression@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz#50dc96413d594f995a77905905b05893cd779673" - integrity sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg== - dependencies: - "@babel/types" "^7.10.4" - -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.17.12", "@babel/helper-plugin-utils@^7.27.1", "@babel/helper-plugin-utils@^7.8.0": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz#ddb2f876534ff8013e6c2b299bf4d39b3c51d44c" - integrity sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw== - -"@babel/helper-plugin-utils@^7.8.3": - version "7.17.12" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.17.12.tgz#86c2347da5acbf5583ba0a10aed4c9bf9da9cf96" - integrity sha512-JDkf04mqtN3y4iAbO1hv9U2ARpPyPL1zqyWs/2WG1pgSq9llHFjStX5jdxb84himgJm+8Ng+x0oiWF/nw/XQKA== - -"@babel/helper-regex@^7.10.4": - version "7.10.5" - resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.10.5.tgz#32dfbb79899073c415557053a19bd055aae50ae0" - integrity sha512-68kdUAzDrljqBrio7DYAEgCoJHxppJOERHOgOrDN7WjOzP0ZQ1LsSDRXcemzVZaLvjaJsJEESb6qt+znNuENDg== - dependencies: - lodash "^4.17.19" - -"@babel/helper-remap-async-to-generator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.12.1.tgz#8c4dbbf916314f6047dc05e6a2217074238347fd" - integrity sha512-9d0KQCRM8clMPcDwo8SevNs+/9a8yWVVmaE80FGJcEP8N1qToREmWEGnBn8BUlJhYRFz6fqxeRL1sl5Ogsed7A== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-wrap-function" "^7.10.4" - "@babel/types" "^7.12.1" - -"@babel/helper-replace-supers@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.12.1.tgz#f15c9cc897439281891e11d5ce12562ac0cf3fa9" - integrity sha512-zJjTvtNJnCFsCXVi5rUInstLd/EIVNmIKA1Q9ynESmMBWPWd+7sdR+G4/wdu+Mppfep0XLyG2m7EBPvjCeFyrw== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.12.1" - "@babel/helper-optimise-call-expression" "^7.10.4" - "@babel/traverse" "^7.12.1" - "@babel/types" "^7.12.1" - -"@babel/helper-simple-access@^7.17.7": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.27.1.tgz#7f2171e29d95d6283ede286a4994f985cbe07973" - integrity sha512-OU4zVQrJgFBNXMjrHs1yFSdlTgufO4tefcUZoqNhukVfw0p8x1Asht/gcGZ3bpHbi8gu/76m4JhrlKPqkrs/WQ== - dependencies: - "@babel/traverse" "^7.27.1" - "@babel/types" "^7.27.1" - -"@babel/helper-simple-access@^7.18.2": - version "7.18.2" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.18.2.tgz#4dc473c2169ac3a1c9f4a51cfcd091d1c36fcff9" - integrity sha512-7LIrjYzndorDY88MycupkpQLKS1AFfsVRm2k/9PtKScSy5tZq0McZTj+DiMRynboZfIqOKvo03pmhTaUgiD6fQ== - dependencies: - "@babel/types" "^7.18.2" - -"@babel/helper-skip-transparent-expression-wrappers@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.12.1.tgz#462dc63a7e435ade8468385c63d2b84cce4b3cbf" - integrity sha512-Mf5AUuhG1/OCChOJ/HcADmvcHM42WJockombn8ATJG3OnyiSxBK/Mm5x78BQWvmtXZKHgbjdGL2kin/HOLlZGA== - dependencies: - "@babel/types" "^7.12.1" - -"@babel/helper-split-export-declaration@^7.10.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz#0b648c0c42da9d3920d85ad585f2778620b8726b" - integrity sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw== - dependencies: - "@babel/types" "^7.16.7" - -"@babel/helper-split-export-declaration@^7.16.7": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz#83949436890e07fa3d6873c61a96e3bbf692d856" - integrity sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA== - dependencies: - "@babel/types" "^7.24.7" - -"@babel/helper-string-parser@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz#54da796097ab19ce67ed9f88b47bb2ec49367687" - integrity sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA== - -"@babel/helper-validator-identifier@^7.10.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad" - integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw== - -"@babel/helper-validator-identifier@^7.16.7", "@babel/helper-validator-identifier@^7.25.9", "@babel/helper-validator-identifier@^7.27.1", "@babel/helper-validator-identifier@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz#010b6938fab7cb7df74aa2bbc06aa503b8fe5fb4" - integrity sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q== - -"@babel/helper-validator-option@^7.12.1": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23" - integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ== - -"@babel/helper-validator-option@^7.16.7", "@babel/helper-validator-option@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz#fa52f5b1e7db1ab049445b421c4471303897702f" - integrity sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg== - -"@babel/helper-wrap-function@^7.10.4": - version "7.12.3" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.12.3.tgz#3332339fc4d1fbbf1c27d7958c27d34708e990d9" - integrity sha512-Cvb8IuJDln3rs6tzjW3Y8UeelAOdnpB8xtQ4sme2MSZ9wOxrbThporC0y/EtE16VAtoyEfLM404Xr1e0OOp+ow== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/template" "^7.10.4" - "@babel/traverse" "^7.10.4" - "@babel/types" "^7.10.4" - -"@babel/helpers@^7.18.2", "@babel/helpers@^7.28.4": - version "7.28.4" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.28.4.tgz#fe07274742e95bdf7cf1443593eeb8926ab63827" - integrity sha512-HFN59MmQXGHVyYadKLVumYsA9dBFun/ldYxipEjzA4196jpLZd8UjEEBLkbEkvfYreDqJhZxYAWFPtrfhNpj4w== - dependencies: - "@babel/template" "^7.27.2" - "@babel/types" "^7.28.4" - -"@babel/highlight@^7.16.7": - version "7.25.9" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.25.9.tgz#8141ce68fc73757946f983b343f1231f4691acc6" - integrity sha512-llL88JShoCsth8fF8R4SJnIn+WLvR6ccFxu1H3FlMhDontdcmZWf2HgIZ7AIqV3Xcck1idlohrN4EUBQz6klbw== - dependencies: - "@babel/helper-validator-identifier" "^7.25.9" - chalk "^2.4.2" - js-tokens "^4.0.0" - picocolors "^1.0.0" - -"@babel/parser@^7.1.0", "@babel/parser@^7.12.5", "@babel/parser@^7.14.7", "@babel/parser@^7.16.7", "@babel/parser@^7.18.5", "@babel/parser@^7.20.7", "@babel/parser@^7.27.2", "@babel/parser@^7.28.5": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.28.5.tgz#0b0225ee90362f030efd644e8034c99468893b08" - integrity sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ== - dependencies: - "@babel/types" "^7.28.5" - -"@babel/plugin-proposal-async-generator-functions@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.12.1.tgz#dc6c1170e27d8aca99ff65f4925bd06b1c90550e" - integrity sha512-d+/o30tJxFxrA1lhzJqiUcEJdI6jKlNregCv5bASeGf2Q4MXmnwH7viDo7nhx1/ohf09oaH8j1GVYG/e3Yqk6A== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-remap-async-to-generator" "^7.12.1" - "@babel/plugin-syntax-async-generators" "^7.8.0" - -"@babel/plugin-proposal-class-properties@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz#a082ff541f2a29a4821065b8add9346c0c16e5de" - integrity sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-proposal-dynamic-import@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.12.1.tgz#43eb5c2a3487ecd98c5c8ea8b5fdb69a2749b2dc" - integrity sha512-a4rhUSZFuq5W8/OO8H7BL5zspjnc1FLd9hlOxIK/f7qG4a0qsqk8uvF/ywgBA8/OmjsapjpvaEOYItfGG1qIvQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-dynamic-import" "^7.8.0" - -"@babel/plugin-proposal-export-namespace-from@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.12.1.tgz#8b9b8f376b2d88f5dd774e4d24a5cc2e3679b6d4" - integrity sha512-6CThGf0irEkzujYS5LQcjBx8j/4aQGiVv7J9+2f7pGfxqyKh3WnmVJYW3hdrQjyksErMGBPQrCnHfOtna+WLbw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - -"@babel/plugin-proposal-json-strings@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.12.1.tgz#d45423b517714eedd5621a9dfdc03fa9f4eb241c" - integrity sha512-GoLDUi6U9ZLzlSda2Df++VSqDJg3CG+dR0+iWsv6XRw1rEq+zwt4DirM9yrxW6XWaTpmai1cWJLMfM8qQJf+yw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-json-strings" "^7.8.0" - -"@babel/plugin-proposal-logical-assignment-operators@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.12.1.tgz#f2c490d36e1b3c9659241034a5d2cd50263a2751" - integrity sha512-k8ZmVv0JU+4gcUGeCDZOGd0lCIamU/sMtIiX3UWnUc5yzgq6YUGyEolNYD+MLYKfSzgECPcqetVcJP9Afe/aCA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - -"@babel/plugin-proposal-nullish-coalescing-operator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.12.1.tgz#3ed4fff31c015e7f3f1467f190dbe545cd7b046c" - integrity sha512-nZY0ESiaQDI1y96+jk6VxMOaL4LPo/QDHBqL+SF3/vl6dHkTwHlOI8L4ZwuRBHgakRBw5zsVylel7QPbbGuYgg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.0" - -"@babel/plugin-proposal-numeric-separator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.12.1.tgz#0e2c6774c4ce48be412119b4d693ac777f7685a6" - integrity sha512-MR7Ok+Af3OhNTCxYVjJZHS0t97ydnJZt/DbR4WISO39iDnhiD8XHrY12xuSJ90FFEGjir0Fzyyn7g/zY6hxbxA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - -"@babel/plugin-proposal-object-rest-spread@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.12.1.tgz#def9bd03cea0f9b72283dac0ec22d289c7691069" - integrity sha512-s6SowJIjzlhx8o7lsFx5zmY4At6CTtDvgNQDdPzkBQucle58A6b/TTeEBYtyDgmcXjUTM+vE8YOGHZzzbc/ioA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.0" - "@babel/plugin-transform-parameters" "^7.12.1" - -"@babel/plugin-proposal-optional-catch-binding@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.12.1.tgz#ccc2421af64d3aae50b558a71cede929a5ab2942" - integrity sha512-hFvIjgprh9mMw5v42sJWLI1lzU5L2sznP805zeT6rySVRA0Y18StRhDqhSxlap0oVgItRsB6WSROp4YnJTJz0g== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.0" - -"@babel/plugin-proposal-optional-chaining@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.12.1.tgz#cce122203fc8a32794296fc377c6dedaf4363797" - integrity sha512-c2uRpY6WzaVDzynVY9liyykS+kVU+WRZPMPYpkelXH8KBt1oXoI89kPbZKKG/jDT5UK92FTW2fZkZaJhdiBabw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" - "@babel/plugin-syntax-optional-chaining" "^7.8.0" - -"@babel/plugin-proposal-private-methods@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.12.1.tgz#86814f6e7a21374c980c10d38b4493e703f4a389" - integrity sha512-mwZ1phvH7/NHK6Kf8LP7MYDogGV+DKB1mryFOEwx5EBNQrosvIczzZFTUmWaeujd5xT6G1ELYWUz3CutMhjE1w== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-proposal-unicode-property-regex@^7.12.1", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.12.1.tgz#2a183958d417765b9eae334f47758e5d6a82e072" - integrity sha512-MYq+l+PvHuw/rKUz1at/vb6nCnQ2gmJBNaM62z0OgH7B2W1D9pvkpYtlti9bGtizNIU1K3zm4bZF9F91efVY0w== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-async-generators@^7.8.0", "@babel/plugin-syntax-async-generators@^7.8.4": - version "7.8.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" - integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-bigint@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz#4c9a6f669f5d0cdf1b90a1671e9a146be5300cea" - integrity sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-class-properties@^7.12.1", "@babel/plugin-syntax-class-properties@^7.12.13": - version "7.12.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10" - integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA== - dependencies: - "@babel/helper-plugin-utils" "^7.12.13" - -"@babel/plugin-syntax-class-static-block@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz#195df89b146b4b78b3bf897fd7a257c84659d406" - integrity sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-dynamic-import@^7.8.0", "@babel/plugin-syntax-dynamic-import@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" - integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-export-namespace-from@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz#028964a9ba80dbc094c915c487ad7c4e7a66465a" - integrity sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.3" - -"@babel/plugin-syntax-import-attributes@^7.24.7": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.27.1.tgz#34c017d54496f9b11b61474e7ea3dfd5563ffe07" - integrity sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww== - dependencies: - "@babel/helper-plugin-utils" "^7.27.1" - -"@babel/plugin-syntax-import-meta@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz#ee601348c370fa334d2207be158777496521fd51" - integrity sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-json-strings@^7.8.0", "@babel/plugin-syntax-json-strings@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" - integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-jsx@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.12.1.tgz#9d9d357cc818aa7ae7935917c1257f67677a0926" - integrity sha512-1yRi7yAtB0ETgxdY9ti/p2TivUxJkTdhu/ZbF9MshVGqOx1TdB3b7xCXs49Fupgg50N45KcAsRP/ZqWjs9SRjg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-jsx@^7.22.5": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.27.1.tgz#2f9beb5eff30fa507c5532d107daac7b888fa34c" - integrity sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w== - dependencies: - "@babel/helper-plugin-utils" "^7.27.1" - -"@babel/plugin-syntax-logical-assignment-operators@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" - integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-nullish-coalescing-operator@^7.8.0", "@babel/plugin-syntax-nullish-coalescing-operator@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz#167ed70368886081f74b5c36c65a88c03b66d1a9" - integrity sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-numeric-separator@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" - integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-syntax-object-rest-spread@^7.8.0", "@babel/plugin-syntax-object-rest-spread@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" - integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-catch-binding@^7.8.0", "@babel/plugin-syntax-optional-catch-binding@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" - integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-optional-chaining@^7.8.0", "@babel/plugin-syntax-optional-chaining@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz#4f69c2ab95167e0180cd5336613f8c5788f7d48a" - dependencies: - "@babel/helper-plugin-utils" "^7.8.0" - -"@babel/plugin-syntax-private-property-in-object@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz#0dc6671ec0ea22b6e94a1114f857970cd39de1ad" - integrity sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-top-level-await@^7.12.1", "@babel/plugin-syntax-top-level-await@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz#c1cfdadc35a646240001f06138247b741c34d94c" - integrity sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw== - dependencies: - "@babel/helper-plugin-utils" "^7.14.5" - -"@babel/plugin-syntax-typescript@^7.12.1": - version "7.17.12" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.17.12.tgz#b54fc3be6de734a56b87508f99d6428b5b605a7b" - integrity sha512-TYY0SXFiO31YXtNg3HtFwNJHjLsAyIIhAhNWkQ5whPPS7HWUFlg9z0Ta4qAQNjQbP1wsSt/oKkmZ/4/WWdMUpw== - dependencies: - "@babel/helper-plugin-utils" "^7.17.12" - -"@babel/plugin-syntax-typescript@^7.7.2": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz#5147d29066a793450f220c63fa3a9431b7e6dd18" - integrity sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ== - dependencies: - "@babel/helper-plugin-utils" "^7.27.1" - -"@babel/plugin-transform-arrow-functions@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.12.1.tgz#8083ffc86ac8e777fbe24b5967c4b2521f3cb2b3" - integrity sha512-5QB50qyN44fzzz4/qxDPQMBCTHgxg3n0xRBLJUmBlLoU/sFvxVWGZF/ZUfMVDQuJUKXaBhbupxIzIfZ6Fwk/0A== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-async-to-generator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.12.1.tgz#3849a49cc2a22e9743cbd6b52926d30337229af1" - integrity sha512-SDtqoEcarK1DFlRJ1hHRY5HvJUj5kX4qmtpMAm2QnhOlyuMC4TMdCRgW6WXpv93rZeYNeLP22y8Aq2dbcDRM1A== - dependencies: - "@babel/helper-module-imports" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-remap-async-to-generator" "^7.12.1" - -"@babel/plugin-transform-block-scoped-functions@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.12.1.tgz#f2a1a365bde2b7112e0a6ded9067fdd7c07905d9" - integrity sha512-5OpxfuYnSgPalRpo8EWGPzIYf0lHBWORCkj5M0oLBwHdlux9Ri36QqGW3/LR13RSVOAoUUMzoPI/jpE4ABcHoA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-block-scoping@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.12.1.tgz#f0ee727874b42a208a48a586b84c3d222c2bbef1" - integrity sha512-zJyAC9sZdE60r1nVQHblcfCj29Dh2Y0DOvlMkcqSo0ckqjiCwNiUezUKw+RjOCwGfpLRwnAeQ2XlLpsnGkvv9w== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-classes@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.12.1.tgz#65e650fcaddd3d88ddce67c0f834a3d436a32db6" - integrity sha512-/74xkA7bVdzQTBeSUhLLJgYIcxw/dpEpCdRDiHgPJ3Mv6uC11UhjpOhl72CgqbBCmt1qtssCyB2xnJm1+PFjog== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-define-map" "^7.10.4" - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-optimise-call-expression" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-replace-supers" "^7.12.1" - "@babel/helper-split-export-declaration" "^7.10.4" - globals "^11.1.0" - -"@babel/plugin-transform-computed-properties@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.12.1.tgz#d68cf6c9b7f838a8a4144badbe97541ea0904852" - integrity sha512-vVUOYpPWB7BkgUWPo4C44mUQHpTZXakEqFjbv8rQMg7TC6S6ZhGZ3otQcRH6u7+adSlE5i0sp63eMC/XGffrzg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-destructuring@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.12.1.tgz#b9a570fe0d0a8d460116413cb4f97e8e08b2f847" - integrity sha512-fRMYFKuzi/rSiYb2uRLiUENJOKq4Gnl+6qOv5f8z0TZXg3llUwUhsNNwrwaT/6dUhJTzNpBr+CUvEWBtfNY1cw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-dotall-regex@^7.12.1", "@babel/plugin-transform-dotall-regex@^7.4.4": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.12.1.tgz#a1d16c14862817b6409c0a678d6f9373ca9cd975" - integrity sha512-B2pXeRKoLszfEW7J4Hg9LoFaWEbr/kzo3teWHmtFCszjRNa/b40f9mfeqZsIDLLt/FjwQ6pz/Gdlwy85xNckBA== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-duplicate-keys@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.12.1.tgz#745661baba295ac06e686822797a69fbaa2ca228" - integrity sha512-iRght0T0HztAb/CazveUpUQrZY+aGKKaWXMJ4uf9YJtqxSUe09j3wteztCUDRHs+SRAL7yMuFqUsLoAKKzgXjw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-exponentiation-operator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.12.1.tgz#b0f2ed356ba1be1428ecaf128ff8a24f02830ae0" - integrity sha512-7tqwy2bv48q+c1EHbXK0Zx3KXd2RVQp6OC7PbwFNt/dPTAV3Lu5sWtWuAj8owr5wqtWnqHfl2/mJlUmqkChKug== - dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-for-of@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.12.1.tgz#07640f28867ed16f9511c99c888291f560921cfa" - integrity sha512-Zaeq10naAsuHo7heQvyV0ptj4dlZJwZgNAtBYBnu5nNKJoW62m0zKcIEyVECrUKErkUkg6ajMy4ZfnVZciSBhg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-function-name@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.12.1.tgz#2ec76258c70fe08c6d7da154003a480620eba667" - integrity sha512-JF3UgJUILoFrFMEnOJLJkRHSk6LUSXLmEFsA23aR2O5CSLUxbeUX1IZ1YQ7Sn0aXb601Ncwjx73a+FVqgcljVw== - dependencies: - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.12.1.tgz#d73b803a26b37017ddf9d3bb8f4dc58bfb806f57" - integrity sha512-+PxVGA+2Ag6uGgL0A5f+9rklOnnMccwEBzwYFL3EUaKuiyVnUipyXncFcfjSkbimLrODoqki1U9XxZzTvfN7IQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-member-expression-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.12.1.tgz#496038602daf1514a64d43d8e17cbb2755e0c3ad" - integrity sha512-1sxePl6z9ad0gFMB9KqmYofk34flq62aqMt9NqliS/7hPEpURUCMbyHXrMPlo282iY7nAvUB1aQd5mg79UD9Jg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-modules-amd@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.12.1.tgz#3154300b026185666eebb0c0ed7f8415fefcf6f9" - integrity sha512-tDW8hMkzad5oDtzsB70HIQQRBiTKrhfgwC/KkJeGsaNFTdWhKNt/BiE8c5yj19XiGyrxpbkOfH87qkNg1YGlOQ== - dependencies: - "@babel/helper-module-transforms" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-commonjs@^7.12.1", "@babel/plugin-transform-modules-commonjs@^7.18.2": - version "7.18.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.18.2.tgz#1aa8efa2e2a6e818b6a7f2235fceaf09bdb31e9e" - integrity sha512-f5A865gFPAJAEE0K7F/+nm5CmAE3y8AWlMBG9unu5j9+tk50UQVK0QS8RNxSp7MJf0wh97uYyLWt3Zvu71zyOQ== - dependencies: - "@babel/helper-module-transforms" "^7.18.0" - "@babel/helper-plugin-utils" "^7.17.12" - "@babel/helper-simple-access" "^7.18.2" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-systemjs@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.12.1.tgz#663fea620d593c93f214a464cd399bf6dc683086" - integrity sha512-Hn7cVvOavVh8yvW6fLwveFqSnd7rbQN3zJvoPNyNaQSvgfKmDBO9U1YL9+PCXGRlZD9tNdWTy5ACKqMuzyn32Q== - dependencies: - "@babel/helper-hoist-variables" "^7.10.4" - "@babel/helper-module-transforms" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-validator-identifier" "^7.10.4" - babel-plugin-dynamic-import-node "^2.3.3" - -"@babel/plugin-transform-modules-umd@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.12.1.tgz#eb5a218d6b1c68f3d6217b8fa2cc82fec6547902" - integrity sha512-aEIubCS0KHKM0zUos5fIoQm+AZUMt1ZvMpqz0/H5qAQ7vWylr9+PLYurT+Ic7ID/bKLd4q8hDovaG3Zch2uz5Q== - dependencies: - "@babel/helper-module-transforms" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-named-capturing-groups-regex@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.12.1.tgz#b407f5c96be0d9f5f88467497fa82b30ac3e8753" - integrity sha512-tB43uQ62RHcoDp9v2Nsf+dSM8sbNodbEicbQNA53zHz8pWUhsgHSJCGpt7daXxRydjb0KnfmB+ChXOv3oADp1Q== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - -"@babel/plugin-transform-new-target@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.12.1.tgz#80073f02ee1bb2d365c3416490e085c95759dec0" - integrity sha512-+eW/VLcUL5L9IvJH7rT1sT0CzkdUTvPrXC2PXTn/7z7tXLBuKvezYbGdxD5WMRoyvyaujOq2fWoKl869heKjhw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-object-super@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.12.1.tgz#4ea08696b8d2e65841d0c7706482b048bed1066e" - integrity sha512-AvypiGJH9hsquNUn+RXVcBdeE3KHPZexWRdimhuV59cSoOt5kFBmqlByorAeUlGG2CJWd0U+4ZtNKga/TB0cAw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-replace-supers" "^7.12.1" - -"@babel/plugin-transform-parameters@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.12.1.tgz#d2e963b038771650c922eff593799c96d853255d" - integrity sha512-xq9C5EQhdPK23ZeCdMxl8bbRnAgHFrw5EOC3KJUsSylZqdkCaFEXxGSBuTSObOpiiHHNyb82es8M1QYgfQGfNg== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-property-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.12.1.tgz#41bc81200d730abb4456ab8b3fbd5537b59adecd" - integrity sha512-6MTCR/mZ1MQS+AwZLplX4cEySjCpnIF26ToWo942nqn8hXSm7McaHQNeGx/pt7suI1TWOWMfa/NgBhiqSnX0cQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-react-display-name@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.12.1.tgz#1cbcd0c3b1d6648c55374a22fc9b6b7e5341c00d" - integrity sha512-cAzB+UzBIrekfYxyLlFqf/OagTvHLcVBb5vpouzkYkBclRPraiygVnafvAoipErZLI8ANv8Ecn6E/m5qPXD26w== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-react-jsx-development@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.12.1.tgz#0b8f8cd531dcf7991f1e5f2c10a2a4f1cfc78e36" - integrity sha512-IilcGWdN1yNgEGOrB96jbTplRh+V2Pz1EoEwsKsHfX1a/L40cUYuD71Zepa7C+ujv7kJIxnDftWeZbKNEqZjCQ== - dependencies: - "@babel/helper-builder-react-jsx-experimental" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-jsx" "^7.12.1" - -"@babel/plugin-transform-react-jsx-self@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.12.1.tgz#ef43cbca2a14f1bd17807dbe4376ff89d714cf28" - integrity sha512-FbpL0ieNWiiBB5tCldX17EtXgmzeEZjFrix72rQYeq9X6nUK38HCaxexzVQrZWXanxKJPKVVIU37gFjEQYkPkA== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-react-jsx-source@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.12.1.tgz#d07de6863f468da0809edcf79a1aa8ce2a82a26b" - integrity sha512-keQ5kBfjJNRc6zZN1/nVHCd6LLIHq4aUKcVnvE/2l+ZZROSbqoiGFRtT5t3Is89XJxBQaP7NLZX2jgGHdZvvFQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-react-jsx@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.12.1.tgz#c2d96c77c2b0e4362cc4e77a43ce7c2539d478cb" - integrity sha512-RmKejwnT0T0QzQUzcbP5p1VWlpnP8QHtdhEtLG55ZDQnJNalbF3eeDyu3dnGKvGzFIQiBzFhBYTwvv435p9Xpw== - dependencies: - "@babel/helper-builder-react-jsx" "^7.10.4" - "@babel/helper-builder-react-jsx-experimental" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-jsx" "^7.12.1" - -"@babel/plugin-transform-react-pure-annotations@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.12.1.tgz#05d46f0ab4d1339ac59adf20a1462c91b37a1a42" - integrity sha512-RqeaHiwZtphSIUZ5I85PEH19LOSzxfuEazoY7/pWASCAIBuATQzpSVD+eT6MebeeZT2F4eSL0u4vw6n4Nm0Mjg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-regenerator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.12.1.tgz#5f0a28d842f6462281f06a964e88ba8d7ab49753" - integrity sha512-gYrHqs5itw6i4PflFX3OdBPMQdPbF4bj2REIUxlMRUFk0/ZOAIpDFuViuxPjUL7YC8UPnf+XG7/utJvqXdPKng== - dependencies: - regenerator-transform "^0.14.2" - -"@babel/plugin-transform-reserved-words@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.12.1.tgz#6fdfc8cc7edcc42b36a7c12188c6787c873adcd8" - integrity sha512-pOnUfhyPKvZpVyBHhSBoX8vfA09b7r00Pmm1sH+29ae2hMTKVmSp4Ztsr8KBKjLjx17H0eJqaRC3bR2iThM54A== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-runtime@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.12.1.tgz#04b792057eb460389ff6a4198e377614ea1e7ba5" - integrity sha512-Ac/H6G9FEIkS2tXsZjL4RAdS3L3WHxci0usAnz7laPWUmFiGtj7tIASChqKZMHTSQTQY6xDbOq+V1/vIq3QrWg== - dependencies: - "@babel/helper-module-imports" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - resolve "^1.8.1" - semver "^5.5.1" - -"@babel/plugin-transform-shorthand-properties@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.12.1.tgz#0bf9cac5550fce0cfdf043420f661d645fdc75e3" - integrity sha512-GFZS3c/MhX1OusqB1MZ1ct2xRzX5ppQh2JU1h2Pnfk88HtFTM+TWQqJNfwkmxtPQtb/s1tk87oENfXJlx7rSDw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-spread@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.12.1.tgz#527f9f311be4ec7fdc2b79bb89f7bf884b3e1e1e" - integrity sha512-vuLp8CP0BE18zVYjsEBZ5xoCecMK6LBMMxYzJnh01rxQRvhNhH1csMMmBfNo5tGpGO+NhdSNW2mzIvBu3K1fng== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-skip-transparent-expression-wrappers" "^7.12.1" - -"@babel/plugin-transform-sticky-regex@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.12.1.tgz#5c24cf50de396d30e99afc8d1c700e8bce0f5caf" - integrity sha512-CiUgKQ3AGVk7kveIaPEET1jNDhZZEl1RPMWdTBE1799bdz++SwqDHStmxfCtDfBhQgCl38YRiSnrMuUMZIWSUQ== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-regex" "^7.10.4" - -"@babel/plugin-transform-template-literals@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.12.1.tgz#b43ece6ed9a79c0c71119f576d299ef09d942843" - integrity sha512-b4Zx3KHi+taXB1dVRBhVJtEPi9h1THCeKmae2qP0YdUHIFhVjtpqqNfxeVAa1xeHVhAy4SbHxEwx5cltAu5apw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-typeof-symbol@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.12.1.tgz#9ca6be343d42512fbc2e68236a82ae64bc7af78a" - integrity sha512-EPGgpGy+O5Kg5pJFNDKuxt9RdmTgj5sgrus2XVeMp/ZIbOESadgILUbm50SNpghOh3/6yrbsH+NB5+WJTmsA7Q== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-typescript@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.1.tgz#d92cc0af504d510e26a754a7dbc2e5c8cd9c7ab4" - integrity sha512-VrsBByqAIntM+EYMqSm59SiMEf7qkmI9dqMt6RbD/wlwueWmYcI0FFK5Fj47pP6DRZm+3teXjosKlwcZJ5lIMw== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-syntax-typescript" "^7.12.1" - -"@babel/plugin-transform-unicode-escapes@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.12.1.tgz#5232b9f81ccb07070b7c3c36c67a1b78f1845709" - integrity sha512-I8gNHJLIc7GdApm7wkVnStWssPNbSRMPtgHdmH3sRM1zopz09UWPS4x5V4n1yz/MIWTVnJ9sp6IkuXdWM4w+2Q== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/plugin-transform-unicode-regex@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.12.1.tgz#cc9661f61390db5c65e3febaccefd5c6ac3faecb" - integrity sha512-SqH4ClNngh/zGwHZOOQMTD+e8FGWexILV+ePMyiDJttAWRh5dhDL8rcl5lSgU3Huiq6Zn6pWTMvdPAb21Dwdyg== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - -"@babel/preset-env@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.1.tgz#9c7e5ca82a19efc865384bb4989148d2ee5d7ac2" - integrity sha512-H8kxXmtPaAGT7TyBvSSkoSTUK6RHh61So05SyEbpmr0MCZrsNYn7mGMzzeYoOUCdHzww61k8XBft2TaES+xPLg== - dependencies: - "@babel/compat-data" "^7.12.1" - "@babel/helper-compilation-targets" "^7.12.1" - "@babel/helper-module-imports" "^7.12.1" - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/helper-validator-option" "^7.12.1" - "@babel/plugin-proposal-async-generator-functions" "^7.12.1" - "@babel/plugin-proposal-class-properties" "^7.12.1" - "@babel/plugin-proposal-dynamic-import" "^7.12.1" - "@babel/plugin-proposal-export-namespace-from" "^7.12.1" - "@babel/plugin-proposal-json-strings" "^7.12.1" - "@babel/plugin-proposal-logical-assignment-operators" "^7.12.1" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.12.1" - "@babel/plugin-proposal-numeric-separator" "^7.12.1" - "@babel/plugin-proposal-object-rest-spread" "^7.12.1" - "@babel/plugin-proposal-optional-catch-binding" "^7.12.1" - "@babel/plugin-proposal-optional-chaining" "^7.12.1" - "@babel/plugin-proposal-private-methods" "^7.12.1" - "@babel/plugin-proposal-unicode-property-regex" "^7.12.1" - "@babel/plugin-syntax-async-generators" "^7.8.0" - "@babel/plugin-syntax-class-properties" "^7.12.1" - "@babel/plugin-syntax-dynamic-import" "^7.8.0" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-json-strings" "^7.8.0" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.0" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.0" - "@babel/plugin-syntax-optional-chaining" "^7.8.0" - "@babel/plugin-syntax-top-level-await" "^7.12.1" - "@babel/plugin-transform-arrow-functions" "^7.12.1" - "@babel/plugin-transform-async-to-generator" "^7.12.1" - "@babel/plugin-transform-block-scoped-functions" "^7.12.1" - "@babel/plugin-transform-block-scoping" "^7.12.1" - "@babel/plugin-transform-classes" "^7.12.1" - "@babel/plugin-transform-computed-properties" "^7.12.1" - "@babel/plugin-transform-destructuring" "^7.12.1" - "@babel/plugin-transform-dotall-regex" "^7.12.1" - "@babel/plugin-transform-duplicate-keys" "^7.12.1" - "@babel/plugin-transform-exponentiation-operator" "^7.12.1" - "@babel/plugin-transform-for-of" "^7.12.1" - "@babel/plugin-transform-function-name" "^7.12.1" - "@babel/plugin-transform-literals" "^7.12.1" - "@babel/plugin-transform-member-expression-literals" "^7.12.1" - "@babel/plugin-transform-modules-amd" "^7.12.1" - "@babel/plugin-transform-modules-commonjs" "^7.12.1" - "@babel/plugin-transform-modules-systemjs" "^7.12.1" - "@babel/plugin-transform-modules-umd" "^7.12.1" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.12.1" - "@babel/plugin-transform-new-target" "^7.12.1" - "@babel/plugin-transform-object-super" "^7.12.1" - "@babel/plugin-transform-parameters" "^7.12.1" - "@babel/plugin-transform-property-literals" "^7.12.1" - "@babel/plugin-transform-regenerator" "^7.12.1" - "@babel/plugin-transform-reserved-words" "^7.12.1" - "@babel/plugin-transform-shorthand-properties" "^7.12.1" - "@babel/plugin-transform-spread" "^7.12.1" - "@babel/plugin-transform-sticky-regex" "^7.12.1" - "@babel/plugin-transform-template-literals" "^7.12.1" - "@babel/plugin-transform-typeof-symbol" "^7.12.1" - "@babel/plugin-transform-unicode-escapes" "^7.12.1" - "@babel/plugin-transform-unicode-regex" "^7.12.1" - "@babel/preset-modules" "^0.1.3" - "@babel/types" "^7.12.1" - core-js-compat "^3.6.2" - semver "^5.5.0" - -"@babel/preset-modules@^0.1.3": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.4.tgz#362f2b68c662842970fdb5e254ffc8fc1c2e415e" - integrity sha512-J36NhwnfdzpmH41M1DrnkkgAqhZaqr/NBdPfQ677mLzlaXo+oDiv1deyCDtgAhz8p328otdob0Du7+xgHGZbKg== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" - "@babel/plugin-transform-dotall-regex" "^7.4.4" - "@babel/types" "^7.4.4" - esutils "^2.0.2" - -"@babel/preset-react@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.12.1.tgz#7f022b13f55b6dd82f00f16d1c599ae62985358c" - integrity sha512-euCExymHCi0qB9u5fKw7rvlw7AZSjw/NaB9h7EkdTt5+yHRrXdiRTh7fkG3uBPpJg82CqLfp1LHLqWGSCrab+g== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-transform-react-display-name" "^7.12.1" - "@babel/plugin-transform-react-jsx" "^7.12.1" - "@babel/plugin-transform-react-jsx-development" "^7.12.1" - "@babel/plugin-transform-react-jsx-self" "^7.12.1" - "@babel/plugin-transform-react-jsx-source" "^7.12.1" - "@babel/plugin-transform-react-pure-annotations" "^7.12.1" - -"@babel/preset-typescript@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.12.1.tgz#86480b483bb97f75036e8864fe404cc782cc311b" - integrity sha512-hNK/DhmoJPsksdHuI/RVrcEws7GN5eamhi28JkO52MqIxU8Z0QpmiSOQxZHWOHV7I3P4UjHV97ay4TcamMA6Kw== - dependencies: - "@babel/helper-plugin-utils" "^7.10.4" - "@babel/plugin-transform-typescript" "^7.12.1" - -"@babel/runtime@^7.1.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.4.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2": - version "7.18.3" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.3.tgz#c7b654b57f6f63cf7f8b418ac9ca04408c4579f4" - integrity sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug== - dependencies: - regenerator-runtime "^0.13.4" - -"@babel/runtime@^7.10.5", "@babel/runtime@^7.7.2": - version "7.28.4" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.4.tgz#a70226016fabe25c5783b2f22d3e1c9bc5ca3326" - integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ== - -"@babel/runtime@^7.28.4": - version "7.28.6" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.6.tgz#d267a43cb1836dc4d182cce93ae75ba954ef6d2b" - integrity sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA== - -"@babel/template@^7.10.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155" - integrity sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/parser" "^7.16.7" - "@babel/types" "^7.16.7" - -"@babel/template@^7.14.5", "@babel/template@^7.16.7", "@babel/template@^7.24.7", "@babel/template@^7.27.2", "@babel/template@^7.3.3": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.27.2.tgz#fa78ceed3c4e7b63ebf6cb39e5852fca45f6809d" - integrity sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw== - dependencies: - "@babel/code-frame" "^7.27.1" - "@babel/parser" "^7.27.2" - "@babel/types" "^7.27.1" - -"@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1": - version "7.18.5" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.18.5.tgz#94a8195ad9642801837988ab77f36e992d9a20cd" - integrity sha512-aKXj1KT66sBj0vVzk6rEeAO6Z9aiiQ68wfDgge3nHhA/my6xMM/7HGQUNumKZaoa2qUPQ5whJG9aAifsxUKfLA== - dependencies: - "@babel/code-frame" "^7.16.7" - "@babel/generator" "^7.18.2" - "@babel/helper-environment-visitor" "^7.18.2" - "@babel/helper-function-name" "^7.17.9" - "@babel/helper-hoist-variables" "^7.16.7" - "@babel/helper-split-export-declaration" "^7.16.7" - "@babel/parser" "^7.18.5" - "@babel/types" "^7.18.4" - debug "^4.1.0" - globals "^11.1.0" - -"@babel/traverse@^7.18.0", "@babel/traverse@^7.18.5", "@babel/traverse@^7.27.1", "@babel/traverse@^7.28.3", "@babel/traverse@^7.28.5", "@babel/traverse@^7.4.5", "@babel/traverse@^7.7.2": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.28.5.tgz#450cab9135d21a7a2ca9d2d35aa05c20e68c360b" - integrity sha512-TCCj4t55U90khlYkVV/0TfkJkAkUg3jZFA3Neb7unZT8CPok7iiRfaX0F+WnqWqt7OxhOn0uBKXCw4lbL8W0aQ== - dependencies: - "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.28.5" - "@babel/helper-globals" "^7.28.0" - "@babel/parser" "^7.28.5" - "@babel/template" "^7.27.2" - "@babel/types" "^7.28.5" - debug "^4.3.1" - -"@babel/types@^7.0.0", "@babel/types@^7.16.7", "@babel/types@^7.17.0", "@babel/types@^7.18.0", "@babel/types@^7.18.2", "@babel/types@^7.18.4", "@babel/types@^7.20.7", "@babel/types@^7.24.7", "@babel/types@^7.27.1", "@babel/types@^7.27.3", "@babel/types@^7.28.2", "@babel/types@^7.28.4", "@babel/types@^7.28.5", "@babel/types@^7.3.3": - version "7.28.5" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.28.5.tgz#10fc405f60897c35f07e85493c932c7b5ca0592b" - integrity sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA== - dependencies: - "@babel/helper-string-parser" "^7.27.1" - "@babel/helper-validator-identifier" "^7.28.5" - -"@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.12.1", "@babel/types@^7.4.4": - version "7.18.4" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.18.4.tgz#27eae9b9fd18e9dccc3f9d6ad051336f307be354" - integrity sha512-ThN1mBcMq5pG/Vm2IcBmPPfyPXbd8S02rS+OBIDENdufvqC7Z/jHPCv9IcP01277aKtDI8g/2XysBN4hA8niiw== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - to-fast-properties "^2.0.0" - -"@bcoe/v8-coverage@^0.2.3": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" - integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== - -"@csstools/cascade-layer-name-parser@^2.0.5": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@csstools/cascade-layer-name-parser/-/cascade-layer-name-parser-2.0.5.tgz#43f962bebead0052a9fed1a2deeb11f85efcbc72" - integrity sha512-p1ko5eHgV+MgXFVa4STPKpvPxr6ReS8oS2jzTukjR74i5zJNyWO1ZM1m8YKBXnzDKWfBN1ztLYlHxbVemDD88A== - -"@csstools/color-helpers@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@csstools/color-helpers/-/color-helpers-5.1.0.tgz#106c54c808cabfd1ab4c602d8505ee584c2996ef" - integrity sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA== - -"@csstools/css-calc@^2.1.4": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@csstools/css-calc/-/css-calc-2.1.4.tgz#8473f63e2fcd6e459838dd412401d5948f224c65" - integrity sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ== - -"@csstools/css-color-parser@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@csstools/css-color-parser/-/css-color-parser-3.1.0.tgz#4e386af3a99dd36c46fef013cfe4c1c341eed6f0" - integrity sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA== - dependencies: - "@csstools/color-helpers" "^5.1.0" - "@csstools/css-calc" "^2.1.4" - -"@csstools/css-parser-algorithms@^3.0.5": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz#5755370a9a29abaec5515b43c8b3f2cf9c2e3076" - integrity sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ== - -"@csstools/css-tokenizer@^3.0.4": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz#333fedabc3fd1a8e5d0100013731cf19e6a8c5d3" - integrity sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw== - -"@csstools/media-query-list-parser@^4.0.3": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@csstools/media-query-list-parser/-/media-query-list-parser-4.0.3.tgz#7aec77bcb89c2da80ef207e73f474ef9e1b3cdf1" - integrity sha512-HAYH7d3TLRHDOUQK4mZKf9k9Ph/m8Akstg66ywKR4SFAigjs3yBiUeZtFxywiTm5moZMAp/5W/ZuFnNXXYLuuQ== - -"@csstools/postcss-alpha-function@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@csstools/postcss-alpha-function/-/postcss-alpha-function-1.0.1.tgz#7989605711de7831bc7cd75b94c9b5bac9c3728e" - integrity sha512-isfLLwksH3yHkFXfCI2Gcaqg7wGGHZZwunoJzEZk0yKYIokgre6hYVFibKL3SYAoR1kBXova8LB+JoO5vZzi9w== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-cascade-layers@^5.0.2": - version "5.0.2" - resolved "https://registry.yarnpkg.com/@csstools/postcss-cascade-layers/-/postcss-cascade-layers-5.0.2.tgz#dd2c70db3867b88975f2922da3bfbae7d7a2cae7" - integrity sha512-nWBE08nhO8uWl6kSAeCx4im7QfVko3zLrtgWZY4/bP87zrSPpSyN/3W3TDqz1jJuH+kbKOHXg5rJnK+ZVYcFFg== - dependencies: - "@csstools/selector-specificity" "^5.0.0" - postcss-selector-parser "^7.0.0" - -"@csstools/postcss-color-function-display-p3-linear@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@csstools/postcss-color-function-display-p3-linear/-/postcss-color-function-display-p3-linear-1.0.1.tgz#3017ff5e1f65307d6083e58e93d76724fb1ebf9f" - integrity sha512-E5qusdzhlmO1TztYzDIi8XPdPoYOjoTY6HBYBCYSj+Gn4gQRBlvjgPQXzfzuPQqt8EhkC/SzPKObg4Mbn8/xMg== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-color-function@^4.0.12": - version "4.0.12" - resolved "https://registry.yarnpkg.com/@csstools/postcss-color-function/-/postcss-color-function-4.0.12.tgz#a7c85a98c77b522a194a1bbb00dd207f40c7a771" - integrity sha512-yx3cljQKRaSBc2hfh8rMZFZzChaFgwmO2JfFgFr1vMcF3C/uyy5I4RFIBOIWGq1D+XbKCG789CGkG6zzkLpagA== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-color-mix-function@^3.0.12": - version "3.0.12" - resolved "https://registry.yarnpkg.com/@csstools/postcss-color-mix-function/-/postcss-color-mix-function-3.0.12.tgz#2f1ee9f8208077af069545c9bd79bb9733382c2a" - integrity sha512-4STERZfCP5Jcs13P1U5pTvI9SkgLgfMUMhdXW8IlJWkzOOOqhZIjcNhWtNJZes2nkBDsIKJ0CJtFtuaZ00moag== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-color-mix-variadic-function-arguments@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@csstools/postcss-color-mix-variadic-function-arguments/-/postcss-color-mix-variadic-function-arguments-1.0.2.tgz#b4012b62a4eaa24d694172bb7137f9d2319cb8f2" - integrity sha512-rM67Gp9lRAkTo+X31DUqMEq+iK+EFqsidfecmhrteErxJZb6tUoJBVQca1Vn1GpDql1s1rD1pKcuYzMsg7Z1KQ== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-content-alt-text@^2.0.8": - version "2.0.8" - resolved "https://registry.yarnpkg.com/@csstools/postcss-content-alt-text/-/postcss-content-alt-text-2.0.8.tgz#1d52da1762893c32999ff76839e48d6ec7c7a4cb" - integrity sha512-9SfEW9QCxEpTlNMnpSqFaHyzsiRpZ5J5+KqCu1u5/eEJAWsMhzT40qf0FIbeeglEvrGRMdDzAxMIz3wqoGSb+Q== - dependencies: - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-contrast-color-function@^2.0.12": - version "2.0.12" - resolved "https://registry.yarnpkg.com/@csstools/postcss-contrast-color-function/-/postcss-contrast-color-function-2.0.12.tgz#ca46986d095c60f208d9e3f24704d199c9172637" - integrity sha512-YbwWckjK3qwKjeYz/CijgcS7WDUCtKTd8ShLztm3/i5dhh4NaqzsbYnhm4bjrpFpnLZ31jVcbK8YL77z3GBPzA== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-exponential-functions@^2.0.9": - version "2.0.9" - resolved "https://registry.yarnpkg.com/@csstools/postcss-exponential-functions/-/postcss-exponential-functions-2.0.9.tgz#fc03d1272888cb77e64cc1a7d8a33016e4f05c69" - integrity sha512-abg2W/PI3HXwS/CZshSa79kNWNZHdJPMBXeZNyPQFbbj8sKO3jXxOt/wF7juJVjyDTc6JrvaUZYFcSBZBhaxjw== - dependencies: - "@csstools/css-calc" "^2.1.4" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - -"@csstools/postcss-font-format-keywords@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-font-format-keywords/-/postcss-font-format-keywords-4.0.0.tgz#6730836eb0153ff4f3840416cc2322f129c086e6" - integrity sha512-usBzw9aCRDvchpok6C+4TXC57btc4bJtmKQWOHQxOVKen1ZfVqBUuCZ/wuqdX5GHsD0NRSr9XTP+5ID1ZZQBXw== - dependencies: - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -"@csstools/postcss-gamut-mapping@^2.0.11": - version "2.0.11" - resolved "https://registry.yarnpkg.com/@csstools/postcss-gamut-mapping/-/postcss-gamut-mapping-2.0.11.tgz#be0e34c9f0142852cccfc02b917511f0d677db8b" - integrity sha512-fCpCUgZNE2piVJKC76zFsgVW1apF6dpYsqGyH8SIeCcM4pTEsRTWTLCaJIMKFEundsCKwY1rwfhtrio04RJ4Dw== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - -"@csstools/postcss-gradients-interpolation-method@^5.0.12": - version "5.0.12" - resolved "https://registry.yarnpkg.com/@csstools/postcss-gradients-interpolation-method/-/postcss-gradients-interpolation-method-5.0.12.tgz#0955cce4d97203b861bf66742bbec611b2f3661c" - integrity sha512-jugzjwkUY0wtNrZlFeyXzimUL3hN4xMvoPnIXxoZqxDvjZRiSh+itgHcVUWzJ2VwD/VAMEgCLvtaJHX+4Vj3Ow== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-hwb-function@^4.0.12": - version "4.0.12" - resolved "https://registry.yarnpkg.com/@csstools/postcss-hwb-function/-/postcss-hwb-function-4.0.12.tgz#07f7ecb08c50e094673bd20eaf7757db0162beee" - integrity sha512-mL/+88Z53KrE4JdePYFJAQWFrcADEqsLprExCM04GDNgHIztwFzj0Mbhd/yxMBngq0NIlz58VVxjt5abNs1VhA== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-ic-unit@^4.0.4": - version "4.0.4" - resolved "https://registry.yarnpkg.com/@csstools/postcss-ic-unit/-/postcss-ic-unit-4.0.4.tgz#2ee2da0690db7edfbc469279711b9e69495659d2" - integrity sha512-yQ4VmossuOAql65sCPppVO1yfb7hDscf4GseF0VCA/DTDaBc0Wtf8MTqVPfjGYlT5+2buokG0Gp7y0atYZpwjg== - dependencies: - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -"@csstools/postcss-initial@^2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@csstools/postcss-initial/-/postcss-initial-2.0.1.tgz#c385bd9d8ad31ad159edd7992069e97ceea4d09a" - integrity sha512-L1wLVMSAZ4wovznquK0xmC7QSctzO4D0Is590bxpGqhqjboLXYA16dWZpfwImkdOgACdQ9PqXsuRroW6qPlEsg== - -"@csstools/postcss-is-pseudo-class@^5.0.3": - version "5.0.3" - resolved "https://registry.yarnpkg.com/@csstools/postcss-is-pseudo-class/-/postcss-is-pseudo-class-5.0.3.tgz#d34e850bcad4013c2ed7abe948bfa0448aa8eb74" - integrity sha512-jS/TY4SpG4gszAtIg7Qnf3AS2pjcUM5SzxpApOrlndMeGhIbaTzWBzzP/IApXoNWEW7OhcjkRT48jnAUIFXhAQ== - dependencies: - "@csstools/selector-specificity" "^5.0.0" - postcss-selector-parser "^7.0.0" - -"@csstools/postcss-light-dark-function@^2.0.11": - version "2.0.11" - resolved "https://registry.yarnpkg.com/@csstools/postcss-light-dark-function/-/postcss-light-dark-function-2.0.11.tgz#0df448aab9a33cb9a085264ff1f396fb80c4437d" - integrity sha512-fNJcKXJdPM3Lyrbmgw2OBbaioU7yuKZtiXClf4sGdQttitijYlZMD5K7HrC/eF83VRWRrYq6OZ0Lx92leV2LFA== - dependencies: - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-logical-float-and-clear@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-logical-float-and-clear/-/postcss-logical-float-and-clear-3.0.0.tgz#62617564182cf86ab5d4e7485433ad91e4c58571" - integrity sha512-SEmaHMszwakI2rqKRJgE+8rpotFfne1ZS6bZqBoQIicFyV+xT1UF42eORPxJkVJVrH9C0ctUgwMSn3BLOIZldQ== - -"@csstools/postcss-logical-overflow@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-logical-overflow/-/postcss-logical-overflow-2.0.0.tgz#c6de7c5f04e3d4233731a847f6c62819bcbcfa1d" - integrity sha512-spzR1MInxPuXKEX2csMamshR4LRaSZ3UXVaRGjeQxl70ySxOhMpP2252RAFsg8QyyBXBzuVOOdx1+bVO5bPIzA== - -"@csstools/postcss-logical-overscroll-behavior@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-logical-overscroll-behavior/-/postcss-logical-overscroll-behavior-2.0.0.tgz#43c03eaecdf34055ef53bfab691db6dc97a53d37" - integrity sha512-e/webMjoGOSYfqLunyzByZj5KKe5oyVg/YSbie99VEaSDE2kimFm0q1f6t/6Jo+VVCQ/jbe2Xy+uX+C4xzWs4w== - -"@csstools/postcss-logical-resize@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-logical-resize/-/postcss-logical-resize-3.0.0.tgz#4df0eeb1a61d7bd85395e56a5cce350b5dbfdca6" - integrity sha512-DFbHQOFW/+I+MY4Ycd/QN6Dg4Hcbb50elIJCfnwkRTCX05G11SwViI5BbBlg9iHRl4ytB7pmY5ieAFk3ws7yyg== - dependencies: - postcss-value-parser "^4.2.0" - -"@csstools/postcss-logical-viewport-units@^3.0.4": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@csstools/postcss-logical-viewport-units/-/postcss-logical-viewport-units-3.0.4.tgz#016d98a8b7b5f969e58eb8413447eb801add16fc" - integrity sha512-q+eHV1haXA4w9xBwZLKjVKAWn3W2CMqmpNpZUk5kRprvSiBEGMgrNH3/sJZ8UA3JgyHaOt3jwT9uFa4wLX4EqQ== - dependencies: - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-media-minmax@^2.0.9": - version "2.0.9" - resolved "https://registry.yarnpkg.com/@csstools/postcss-media-minmax/-/postcss-media-minmax-2.0.9.tgz#184252d5b93155ae526689328af6bdf3fc113987" - integrity sha512-af9Qw3uS3JhYLnCbqtZ9crTvvkR+0Se+bBqSr7ykAnl9yKhk6895z9rf+2F4dClIDJWxgn0iZZ1PSdkhrbs2ig== - dependencies: - "@csstools/css-calc" "^2.1.4" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/media-query-list-parser" "^4.0.3" - -"@csstools/postcss-media-queries-aspect-ratio-number-values@^3.0.5": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@csstools/postcss-media-queries-aspect-ratio-number-values/-/postcss-media-queries-aspect-ratio-number-values-3.0.5.tgz#f485c31ec13d6b0fb5c528a3474334a40eff5f11" - integrity sha512-zhAe31xaaXOY2Px8IYfoVTB3wglbJUVigGphFLj6exb7cjZRH9A6adyE22XfFK3P2PzwRk0VDeTJmaxpluyrDg== - dependencies: - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/media-query-list-parser" "^4.0.3" - -"@csstools/postcss-nested-calc@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-nested-calc/-/postcss-nested-calc-4.0.0.tgz#754e10edc6958d664c11cde917f44ba144141c62" - integrity sha512-jMYDdqrQQxE7k9+KjstC3NbsmC063n1FTPLCgCRS2/qHUbHM0mNy9pIn4QIiQGs9I/Bg98vMqw7mJXBxa0N88A== - dependencies: - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -"@csstools/postcss-normalize-display-values@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-normalize-display-values/-/postcss-normalize-display-values-4.0.0.tgz#ecdde2daf4e192e5da0c6fd933b6d8aff32f2a36" - integrity sha512-HlEoG0IDRoHXzXnkV4in47dzsxdsjdz6+j7MLjaACABX2NfvjFS6XVAnpaDyGesz9gK2SC7MbNwdCHusObKJ9Q== - dependencies: - postcss-value-parser "^4.2.0" - -"@csstools/postcss-oklab-function@^4.0.12": - version "4.0.12" - resolved "https://registry.yarnpkg.com/@csstools/postcss-oklab-function/-/postcss-oklab-function-4.0.12.tgz#416640ef10227eea1375b47b72d141495950971d" - integrity sha512-HhlSmnE1NKBhXsTnNGjxvhryKtO7tJd1w42DKOGFD6jSHtYOrsJTQDKPMwvOfrzUAk8t7GcpIfRyM7ssqHpFjg== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-progressive-custom-properties@^4.2.1": - version "4.2.1" - resolved "https://registry.yarnpkg.com/@csstools/postcss-progressive-custom-properties/-/postcss-progressive-custom-properties-4.2.1.tgz#c39780b9ff0d554efb842b6bd75276aa6f1705db" - integrity sha512-uPiiXf7IEKtUQXsxu6uWtOlRMXd2QWWy5fhxHDnPdXKCQckPP3E34ZgDoZ62r2iT+UOgWsSbM4NvHE5m3mAEdw== - dependencies: - postcss-value-parser "^4.2.0" - -"@csstools/postcss-random-function@^2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@csstools/postcss-random-function/-/postcss-random-function-2.0.1.tgz#3191f32fe72936e361dadf7dbfb55a0209e2691e" - integrity sha512-q+FQaNiRBhnoSNo+GzqGOIBKoHQ43lYz0ICrV+UudfWnEF6ksS6DsBIJSISKQT2Bvu3g4k6r7t0zYrk5pDlo8w== - dependencies: - "@csstools/css-calc" "^2.1.4" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - -"@csstools/postcss-relative-color-syntax@^3.0.12": - version "3.0.12" - resolved "https://registry.yarnpkg.com/@csstools/postcss-relative-color-syntax/-/postcss-relative-color-syntax-3.0.12.tgz#ced792450102441f7c160e1d106f33e4b44181f8" - integrity sha512-0RLIeONxu/mtxRtf3o41Lq2ghLimw0w9ByLWnnEVuy89exmEEq8bynveBxNW3nyHqLAFEeNtVEmC1QK9MZ8Huw== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -"@csstools/postcss-scope-pseudo-class@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@csstools/postcss-scope-pseudo-class/-/postcss-scope-pseudo-class-4.0.1.tgz#9fe60e9d6d91d58fb5fc6c768a40f6e47e89a235" - integrity sha512-IMi9FwtH6LMNuLea1bjVMQAsUhFxJnyLSgOp/cpv5hrzWmrUYU5fm0EguNDIIOHUqzXode8F/1qkC/tEo/qN8Q== - dependencies: - postcss-selector-parser "^7.0.0" - -"@csstools/postcss-sign-functions@^1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@csstools/postcss-sign-functions/-/postcss-sign-functions-1.1.4.tgz#a9ac56954014ae4c513475b3f1b3e3424a1e0c12" - integrity sha512-P97h1XqRPcfcJndFdG95Gv/6ZzxUBBISem0IDqPZ7WMvc/wlO+yU0c5D/OCpZ5TJoTt63Ok3knGk64N+o6L2Pg== - dependencies: - "@csstools/css-calc" "^2.1.4" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - -"@csstools/postcss-stepped-value-functions@^4.0.9": - version "4.0.9" - resolved "https://registry.yarnpkg.com/@csstools/postcss-stepped-value-functions/-/postcss-stepped-value-functions-4.0.9.tgz#36036f1a0e5e5ee2308e72f3c9cb433567c387b9" - integrity sha512-h9btycWrsex4dNLeQfyU3y3w40LMQooJWFMm/SK9lrKguHDcFl4VMkncKKoXi2z5rM9YGWbUQABI8BT2UydIcA== - dependencies: - "@csstools/css-calc" "^2.1.4" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - -"@csstools/postcss-text-decoration-shorthand@^4.0.3": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@csstools/postcss-text-decoration-shorthand/-/postcss-text-decoration-shorthand-4.0.3.tgz#fae1b70f07d1b7beb4c841c86d69e41ecc6f743c" - integrity sha512-KSkGgZfx0kQjRIYnpsD7X2Om9BUXX/Kii77VBifQW9Ih929hK0KNjVngHDH0bFB9GmfWcR9vJYJJRvw/NQjkrA== - dependencies: - "@csstools/color-helpers" "^5.1.0" - postcss-value-parser "^4.2.0" - -"@csstools/postcss-trigonometric-functions@^4.0.9": - version "4.0.9" - resolved "https://registry.yarnpkg.com/@csstools/postcss-trigonometric-functions/-/postcss-trigonometric-functions-4.0.9.tgz#3f94ed2e319b57f2c59720b64e4d0a8a6fb8c3b2" - integrity sha512-Hnh5zJUdpNrJqK9v1/E3BbrQhaDTj5YiX7P61TOvUhoDHnUmsNNxcDAgkQ32RrcWx9GVUvfUNPcUkn8R3vIX6A== - dependencies: - "@csstools/css-calc" "^2.1.4" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - -"@csstools/postcss-unset-value@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@csstools/postcss-unset-value/-/postcss-unset-value-4.0.0.tgz#7caa981a34196d06a737754864baf77d64de4bba" - integrity sha512-cBz3tOCI5Fw6NIFEwU3RiwK6mn3nKegjpJuzCndoGq3BZPkUjnsq7uQmIeMNeMbMk7YD2MfKcgCpZwX5jyXqCA== - -"@csstools/selector-resolve-nested@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@csstools/selector-resolve-nested/-/selector-resolve-nested-3.1.0.tgz#848c6f44cb65e3733e478319b9342b7aa436fac7" - integrity sha512-mf1LEW0tJLKfWyvn5KdDrhpxHyuxpbNwTIwOYLIvsTffeyOf85j5oIzfG0yosxDgx/sswlqBnESYUcQH0vgZ0g== - -"@csstools/selector-specificity@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-5.0.0.tgz#037817b574262134cabd68fc4ec1a454f168407b" - integrity sha512-PCqQV3c4CoVm3kdPhyeZ07VmBRdH2EpMFA/pd9OASpOEC3aXNGoqPDAZ80D0cLpMBxnmk0+yNhGsEx31hq7Gtw== - -"@csstools/utilities@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@csstools/utilities/-/utilities-2.0.0.tgz#f7ff0fee38c9ffb5646d47b6906e0bc8868bde60" - integrity sha512-5VdOr0Z71u+Yp3ozOx8T11N703wIFGVRgOWbOZMKgglPJsWA54MRIoMNVMa7shUToIhx5J8vX4sOZgD2XiihiQ== - -"@discoveryjs/json-ext@^0.6.1": - version "0.6.3" - resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz#f13c7c205915eb91ae54c557f5e92bddd8be0e83" - integrity sha512-4B4OijXeVNOPZlYA2oEwWOTkzyltLao+xbotHQeqN++Rv27Y6s818+n2Qkp8q+Fxhn0t/5lA5X1Mxktud8eayQ== - -"@emotion/is-prop-valid@^0.8.2": - version "0.8.8" - resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a" - integrity sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA== - dependencies: - "@emotion/memoize" "0.7.4" - -"@emotion/is-prop-valid@^1.1.0": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.4.0.tgz#e9ad47adff0b5c94c72db3669ce46de33edf28c0" - integrity sha512-QgD4fyscGcbbKwJmqNvUMSE02OsHUa+lAWKdEUIJKgqe5IwRSKd7+KhibEWdaKwgjLj0DRSHA9biAIqGBk05lw== - dependencies: - "@emotion/memoize" "^0.9.0" - -"@emotion/memoize@0.7.4": - version "0.7.4" - resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.4.tgz#19bf0f5af19149111c40d98bb0cf82119f5d9eeb" - integrity sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw== - -"@emotion/memoize@^0.9.0": - version "0.9.0" - resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.9.0.tgz#745969d649977776b43fc7648c556aaa462b4102" - integrity sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ== - -"@emotion/stylis@^0.8.4": - version "0.8.5" - resolved "https://registry.yarnpkg.com/@emotion/stylis/-/stylis-0.8.5.tgz#deacb389bd6ee77d1e7fcaccce9e16c5c7e78e04" - integrity sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ== - -"@emotion/unitless@^0.7.4": - version "0.7.5" - resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed" - integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg== - -"@eslint-community/eslint-utils@^4.2.0": - version "4.9.0" - resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz#7308df158e064f0dd8b8fdb58aa14fa2a7f913b3" - integrity sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g== - dependencies: - eslint-visitor-keys "^3.4.3" - -"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.6.1": - version "4.12.2" - resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.2.tgz#bccdf615bcf7b6e8db830ec0b8d21c9a25de597b" - integrity sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew== - -"@eslint/eslintrc@^2.1.4": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.4.tgz#388a269f0f25c1b6adc317b5a2c55714894c70ad" - integrity sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ== - dependencies: - ajv "^6.12.4" - debug "^4.3.2" - espree "^9.6.0" - globals "^13.19.0" - ignore "^5.2.0" - import-fresh "^3.2.1" - js-yaml "^4.1.0" - minimatch "^3.1.2" - strip-json-comments "^3.1.1" - -"@eslint/js@8.57.1": - version "8.57.1" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2" - integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q== - -"@floating-ui/core@^0.7.3": - version "0.7.3" - resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-0.7.3.tgz#d274116678ffae87f6b60e90f88cc4083eefab86" - integrity sha512-buc8BXHmG9l82+OQXOFU3Kr2XQx9ys01U/Q9HMIrZ300iLc8HLMgh7dcCqgYzAzf4BkoQvDcXf5Y+CuEZ5JBYg== - -"@floating-ui/dom@^0.5.3": - version "0.5.4" - resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-0.5.4.tgz#4eae73f78bcd4bd553ae2ade30e6f1f9c73fe3f1" - integrity sha512-419BMceRLq0RrmTSDxn8hf9R3VCJv2K9PUfugh5JyEFmdjzDo+e8U5EdR8nzKq8Yj1htzLm3b6eQEEam3/rrtg== - dependencies: - "@floating-ui/core" "^0.7.3" - -"@floating-ui/react-dom-interactions@^0.6.6": - version "0.6.6" - resolved "https://registry.yarnpkg.com/@floating-ui/react-dom-interactions/-/react-dom-interactions-0.6.6.tgz#8542e8c4bcbee2cd0d512de676c6a493e0a2d168" - integrity sha512-qnao6UPjSZNHnXrF+u4/n92qVroQkx0Umlhy3Avk1oIebm/5ee6yvDm4xbHob0OjY7ya8WmUnV3rQlPwX3Atwg== - dependencies: - "@floating-ui/react-dom" "^0.7.2" - aria-hidden "^1.1.3" - use-isomorphic-layout-effect "^1.1.1" - -"@floating-ui/react-dom@^0.7.2": - version "0.7.2" - resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-0.7.2.tgz#0bf4ceccb777a140fc535c87eb5d6241c8e89864" - integrity sha512-1T0sJcpHgX/u4I1OzIEhlcrvkUN8ln39nz7fMoE/2HDHrPiMFoOGR7++GYyfUmIQHkkrTinaeQsO3XWubjSvGg== - dependencies: - "@floating-ui/dom" "^0.5.3" - use-isomorphic-layout-effect "^1.1.1" - -"@fontsource-variable/ibm-plex-sans@^5.2.8": - version "5.2.8" - resolved "https://registry.yarnpkg.com/@fontsource-variable/ibm-plex-sans/-/ibm-plex-sans-5.2.8.tgz#8947cca46a35ca91266b88ebcbcac09ff264aabc" - integrity sha512-n5PF2iFa0CZT0QYTPzxvZ39opC9LnU0zdoRccoADbs+Dtsd+lbXOZF7RNuIPHcQX1dKjF63sxnRImQIB5eD0Ag== - -"@fortawesome/fontawesome-common-types@^0.2.32": - version "0.2.32" - resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.32.tgz#3436795d5684f22742989bfa08f46f50f516f259" - integrity sha512-ux2EDjKMpcdHBVLi/eWZynnPxs0BtFVXJkgHIxXRl+9ZFaHPvYamAfCzeeQFqHRjuJtX90wVnMRaMQAAlctz3w== - -"@fortawesome/fontawesome-svg-core@^1.2.32": - version "1.2.32" - resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.32.tgz#da092bfc7266aa274be8604de610d7115f9ba6cf" - integrity sha512-XjqyeLCsR/c/usUpdWcOdVtWFVjPbDFBTQkn2fQRrWhhUoxriQohO2RWDxLyUM8XpD+Zzg5xwJ8gqTYGDLeGaQ== - dependencies: - "@fortawesome/fontawesome-common-types" "^0.2.32" - -"@fortawesome/free-solid-svg-icons@^5.15.1": - version "5.15.1" - resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.15.1.tgz#e1432676ddd43108b41197fee9f86d910ad458ef" - integrity sha512-EFMuKtzRMNbvjab/SvJBaOOpaqJfdSap/Nl6hst7CgrJxwfORR1drdTV6q1Ib/JVzq4xObdTDcT6sqTaXMqfdg== - dependencies: - "@fortawesome/fontawesome-common-types" "^0.2.32" - -"@fortawesome/react-fontawesome@^0.1.11": - version "0.1.11" - resolved "https://registry.yarnpkg.com/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.11.tgz#c1a95a2bdb6a18fa97b355a563832e248bf6ef4a" - integrity sha512-sClfojasRifQKI0OPqTy8Ln8iIhnxR/Pv/hukBhWnBz9kQRmqi6JSH3nghlhAY7SUeIIM7B5/D2G8WjX0iepVg== - dependencies: - prop-types "^15.7.2" - -"@headlessui/react@^1.6.4": - version "1.6.4" - resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.6.4.tgz#c73084e23386bef5fb86cd16da3352c3a844bb4c" - integrity sha512-0yqz1scwbFtwljmbbKjXsSGl5ABEYNICVHZnMCWo0UtOZodo2Tpu94uOVgCRjRZ77l2WcTi2S0uidINDvG7lsA== - -"@heroicons/react@^1.0.6": - version "1.0.6" - resolved "https://registry.yarnpkg.com/@heroicons/react/-/react-1.0.6.tgz#35dd26987228b39ef2316db3b1245c42eb19e324" - integrity sha512-JJCXydOFWMDpCP4q13iEplA503MQO3xLoZiKum+955ZCtHINWnx26CUxVxxFQu/uLb4LW3ge15ZpzIkXKkJ8oQ== - -"@hot-loader/react-dom@^16.14.0": - version "16.14.0" - resolved "https://registry.yarnpkg.com/@hot-loader/react-dom/-/react-dom-16.14.0.tgz#3cfc64e40bb78fa623e59b582b8f09dcdaad648a" - integrity sha512-EN9czvcLsMYmSDo5yRKZOAq3ZGRlDpad1gPtX0NdMMomJXcPE3yFSeFzE94X/NjOaiSVimB7LuqPYpkWVaIi4Q== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" - scheduler "^0.19.1" - -"@humanwhocodes/config-array@^0.13.0": - version "0.13.0" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.13.0.tgz#fb907624df3256d04b9aa2df50d7aa97ec648748" - integrity sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw== - dependencies: - "@humanwhocodes/object-schema" "^2.0.3" - debug "^4.3.1" - minimatch "^3.0.5" - -"@humanwhocodes/module-importer@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" - integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== - -"@humanwhocodes/object-schema@^2.0.3": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" - integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== - -"@istanbuljs/load-nyc-config@^1.0.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" - integrity sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ== - dependencies: - camelcase "^5.3.1" - find-up "^4.1.0" - get-package-type "^0.1.0" - js-yaml "^3.13.1" - resolve-from "^5.0.0" - -"@istanbuljs/schema@^0.1.2": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" - integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== - -"@jest/console@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/console/-/console-28.1.3.tgz#2030606ec03a18c31803b8a36382762e447655df" - integrity sha512-QPAkP5EwKdK/bxIr6C1I4Vs0rm2nHiANzj/Z5X2JQkrZo6IqvC4ldZ9K95tF0HdidhA8Bo6egxSzUFPYKcEXLw== - dependencies: - "@jest/types" "^28.1.3" - "@types/node" "*" - chalk "^4.0.0" - jest-message-util "^28.1.3" - jest-util "^28.1.3" - slash "^3.0.0" - -"@jest/core@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/core/-/core-28.1.3.tgz#0ebf2bd39840f1233cd5f2d1e6fc8b71bd5a1ac7" - integrity sha512-CIKBrlaKOzA7YG19BEqCw3SLIsEwjZkeJzf5bdooVnW4bH5cktqe3JX+G2YV1aK5vP8N9na1IGWFzYaTp6k6NA== - dependencies: - "@jest/console" "^28.1.3" - "@jest/reporters" "^28.1.3" - "@jest/test-result" "^28.1.3" - "@jest/transform" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/node" "*" - ansi-escapes "^4.2.1" - chalk "^4.0.0" - ci-info "^3.2.0" - exit "^0.1.2" - graceful-fs "^4.2.9" - jest-changed-files "^28.1.3" - jest-config "^28.1.3" - jest-haste-map "^28.1.3" - jest-message-util "^28.1.3" - jest-regex-util "^28.0.2" - jest-resolve "^28.1.3" - jest-resolve-dependencies "^28.1.3" - jest-runner "^28.1.3" - jest-runtime "^28.1.3" - jest-snapshot "^28.1.3" - jest-util "^28.1.3" - jest-validate "^28.1.3" - jest-watcher "^28.1.3" - micromatch "^4.0.4" - pretty-format "^28.1.3" - rimraf "^3.0.0" - slash "^3.0.0" - strip-ansi "^6.0.0" - -"@jest/environment@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-28.1.3.tgz#abed43a6b040a4c24fdcb69eab1f97589b2d663e" - integrity sha512-1bf40cMFTEkKyEf585R9Iz1WayDjHoHqvts0XFYEqyKM3cFWDpeMoqKKTAF9LSYQModPUlh8FKptoM2YcMWAXA== - dependencies: - "@jest/fake-timers" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/node" "*" - jest-mock "^28.1.3" - -"@jest/expect-utils@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-28.1.3.tgz#58561ce5db7cd253a7edddbc051fb39dda50f525" - integrity sha512-wvbi9LUrHJLn3NlDW6wF2hvIMtd4JUl2QNVrjq+IBSHirgfrR3o9RnVtxzdEGO2n9JyIWwHnLfby5KzqBGg2YA== - dependencies: - jest-get-type "^28.0.2" - -"@jest/expect@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/expect/-/expect-28.1.3.tgz#9ac57e1d4491baca550f6bdbd232487177ad6a72" - integrity sha512-lzc8CpUbSoE4dqT0U+g1qODQjBRHPpCPXissXD4mS9+sWQdmmpeJ9zSH1rS1HEkrsMN0fb7nKrJ9giAR1d3wBw== - dependencies: - expect "^28.1.3" - jest-snapshot "^28.1.3" - -"@jest/fake-timers@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-28.1.3.tgz#230255b3ad0a3d4978f1d06f70685baea91c640e" - integrity sha512-D/wOkL2POHv52h+ok5Oj/1gOG9HSywdoPtFsRCUmlCILXNn5eIWmcnd3DIiWlJnpGvQtmajqBP95Ei0EimxfLw== - dependencies: - "@jest/types" "^28.1.3" - "@sinonjs/fake-timers" "^9.1.2" - "@types/node" "*" - jest-message-util "^28.1.3" - jest-mock "^28.1.3" - jest-util "^28.1.3" - -"@jest/globals@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-28.1.3.tgz#a601d78ddc5fdef542728309894895b4a42dc333" - integrity sha512-XFU4P4phyryCXu1pbcqMO0GSQcYe1IsalYCDzRNyhetyeyxMcIxa11qPNDpVNLeretItNqEmYYQn1UYz/5x1NA== - dependencies: - "@jest/environment" "^28.1.3" - "@jest/expect" "^28.1.3" - "@jest/types" "^28.1.3" - -"@jest/reporters@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-28.1.3.tgz#9adf6d265edafc5fc4a434cfb31e2df5a67a369a" - integrity sha512-JuAy7wkxQZVNU/V6g9xKzCGC5LVXx9FDcABKsSXp5MiKPEE2144a/vXTEDoyzjUpZKfVwp08Wqg5A4WfTMAzjg== - dependencies: - "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "^28.1.3" - "@jest/test-result" "^28.1.3" - "@jest/transform" "^28.1.3" - "@jest/types" "^28.1.3" - "@jridgewell/trace-mapping" "^0.3.13" - "@types/node" "*" - chalk "^4.0.0" - collect-v8-coverage "^1.0.0" - exit "^0.1.2" - glob "^7.1.3" - graceful-fs "^4.2.9" - istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^5.1.0" - istanbul-lib-report "^3.0.0" - istanbul-lib-source-maps "^4.0.0" - istanbul-reports "^3.1.3" - jest-message-util "^28.1.3" - jest-util "^28.1.3" - jest-worker "^28.1.3" - slash "^3.0.0" - string-length "^4.0.1" - strip-ansi "^6.0.0" - terminal-link "^2.0.0" - v8-to-istanbul "^9.0.1" - -"@jest/schemas@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-28.1.3.tgz#ad8b86a66f11f33619e3d7e1dcddd7f2d40ff905" - integrity sha512-/l/VWsdt/aBXgjshLWOFyFt3IVdYypu5y2Wn2rOO1un6nkqIn8SLXzgIMYXFyYsRWDyF5EthmKJMIdJvk08grg== - dependencies: - "@sinclair/typebox" "^0.24.1" - -"@jest/source-map@^28.1.2": - version "28.1.2" - resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-28.1.2.tgz#7fe832b172b497d6663cdff6c13b0a920e139e24" - integrity sha512-cV8Lx3BeStJb8ipPHnqVw/IM2VCMWO3crWZzYodSIkxXnRcXJipCdx1JCK0K5MsJJouZQTH73mzf4vgxRaH9ww== - dependencies: - "@jridgewell/trace-mapping" "^0.3.13" - callsites "^3.0.0" - graceful-fs "^4.2.9" - -"@jest/test-result@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-28.1.3.tgz#5eae945fd9f4b8fcfce74d239e6f725b6bf076c5" - integrity sha512-kZAkxnSE+FqE8YjW8gNuoVkkC9I7S1qmenl8sGcDOLropASP+BkcGKwhXoyqQuGOGeYY0y/ixjrd/iERpEXHNg== - dependencies: - "@jest/console" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/istanbul-lib-coverage" "^2.0.0" - collect-v8-coverage "^1.0.0" - -"@jest/test-sequencer@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-28.1.3.tgz#9d0c283d906ac599c74bde464bc0d7e6a82886c3" - integrity sha512-NIMPEqqa59MWnDi1kvXXpYbqsfQmSJsIbnd85mdVGkiDfQ9WQQTXOLsvISUfonmnBT+w85WEgneCigEEdHDFxw== - dependencies: - "@jest/test-result" "^28.1.3" - graceful-fs "^4.2.9" - jest-haste-map "^28.1.3" - slash "^3.0.0" - -"@jest/transform@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-28.1.3.tgz#59d8098e50ab07950e0f2fc0fc7ec462371281b0" - integrity sha512-u5dT5di+oFI6hfcLOHGTAfmUxFRrjK+vnaP0kkVow9Md/M7V/MxqQMOz/VV25UZO8pzeA9PjfTpOu6BDuwSPQA== - dependencies: - "@babel/core" "^7.11.6" - "@jest/types" "^28.1.3" - "@jridgewell/trace-mapping" "^0.3.13" - babel-plugin-istanbul "^6.1.1" - chalk "^4.0.0" - convert-source-map "^1.4.0" - fast-json-stable-stringify "^2.0.0" - graceful-fs "^4.2.9" - jest-haste-map "^28.1.3" - jest-regex-util "^28.0.2" - jest-util "^28.1.3" - micromatch "^4.0.4" - pirates "^4.0.4" - slash "^3.0.0" - write-file-atomic "^4.0.1" - -"@jest/types@^28.1.3": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-28.1.3.tgz#b05de80996ff12512bc5ceb1d208285a7d11748b" - integrity sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ== - dependencies: - "@jest/schemas" "^28.1.3" - "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^3.0.0" - "@types/node" "*" - "@types/yargs" "^17.0.8" - chalk "^4.0.0" - -"@jridgewell/gen-mapping@^0.3.12", "@jridgewell/gen-mapping@^0.3.2", "@jridgewell/gen-mapping@^0.3.5": - version "0.3.13" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz#6342a19f44347518c93e43b1ac69deb3c4656a1f" - integrity sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA== - dependencies: - "@jridgewell/sourcemap-codec" "^1.5.0" - "@jridgewell/trace-mapping" "^0.3.24" - -"@jridgewell/remapping@^2.3.5": - version "2.3.5" - resolved "https://registry.yarnpkg.com/@jridgewell/remapping/-/remapping-2.3.5.tgz#375c476d1972947851ba1e15ae8f123047445aa1" - integrity sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ== - dependencies: - "@jridgewell/gen-mapping" "^0.3.5" - "@jridgewell/trace-mapping" "^0.3.24" - -"@jridgewell/resolve-uri@^3.1.0": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" - integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== - -"@jridgewell/source-map@^0.3.3": - version "0.3.11" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.11.tgz#b21835cbd36db656b857c2ad02ebd413cc13a9ba" - integrity sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA== - dependencies: - "@jridgewell/gen-mapping" "^0.3.5" - "@jridgewell/trace-mapping" "^0.3.25" - -"@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.5.0": - version "1.5.5" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz#6912b00d2c631c0d15ce1a7ab57cd657f2a8f8ba" - integrity sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og== - -"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.13", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25", "@jridgewell/trace-mapping@^0.3.28": - version "0.3.31" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz#db15d6781c931f3a251a3dac39501c98a6082fd0" - integrity sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw== - dependencies: - "@jridgewell/resolve-uri" "^3.1.0" - "@jridgewell/sourcemap-codec" "^1.4.14" - -"@jsonjoy.com/base64@17.67.0": - version "17.67.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/base64/-/base64-17.67.0.tgz#7eeda3cb41138d77a90408fd2e42b2aba10576d7" - integrity sha512-5SEsJGsm15aP8TQGkDfJvz9axgPwAEm98S5DxOuYe8e1EbfajcDmgeXXzccEjh+mLnjqEKrkBdjHWS5vFNwDdw== - -"@jsonjoy.com/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/base64/-/base64-1.1.2.tgz#cf8ea9dcb849b81c95f14fc0aaa151c6b54d2578" - integrity sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA== - -"@jsonjoy.com/buffers@17.67.0", "@jsonjoy.com/buffers@^17.65.0": - version "17.67.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/buffers/-/buffers-17.67.0.tgz#5c58dbcdeea8824ce296bd1cfce006c2eb167b3d" - integrity sha512-tfExRpYxBvi32vPs9ZHaTjSP4fHAfzSmcahOfNxtvGHcyJel+aibkPlGeBB+7AoC6hL7lXIE++8okecBxx7lcw== - -"@jsonjoy.com/buffers@^1.0.0", "@jsonjoy.com/buffers@^1.2.0": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/buffers/-/buffers-1.2.1.tgz#8d99c7f67eaf724d3428dfd9826c6455266a5c83" - integrity sha512-12cdlDwX4RUM3QxmUbVJWqZ/mrK6dFQH4Zxq6+r1YXKXYBNgZXndx2qbCJwh3+WWkCSn67IjnlG3XYTvmvYtgA== - -"@jsonjoy.com/codegen@17.67.0": - version "17.67.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/codegen/-/codegen-17.67.0.tgz#3635fd8769d77e19b75dc5574bc9756019b2e591" - integrity sha512-idnkUplROpdBOV0HMcwhsCUS5TRUi9poagdGs70A6S4ux9+/aPuKbh8+UYRTLYQHtXvAdNfQWXDqZEx5k4Dj2Q== - -"@jsonjoy.com/codegen@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/codegen/-/codegen-1.0.0.tgz#5c23f796c47675f166d23b948cdb889184b93207" - integrity sha512-E8Oy+08cmCf0EK/NMxpaJZmOxPqM+6iSe2S4nlSBrPZOORoDJILxtbSUEDKQyTamm/BVAhIGllOBNU79/dwf0g== - -"@jsonjoy.com/fs-core@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-core/-/fs-core-4.56.10.tgz#320728b4b7bef63abb60e7630351623899237411" - integrity sha512-PyAEA/3cnHhsGcdY+AmIU+ZPqTuZkDhCXQ2wkXypdLitSpd6d5Ivxhnq4wa2ETRWFVJGabYynBWxIijOswSmOw== - dependencies: - "@jsonjoy.com/fs-node-builtins" "4.56.10" - "@jsonjoy.com/fs-node-utils" "4.56.10" - thingies "^2.5.0" - -"@jsonjoy.com/fs-fsa@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-fsa/-/fs-fsa-4.56.10.tgz#02bac88c4968ddf2effbd7452861aaed60ba3557" - integrity sha512-/FVK63ysNzTPOnCCcPoPHt77TOmachdMS422txM4KhxddLdbW1fIbFMYH0AM0ow/YchCyS5gqEjKLNyv71j/5Q== - dependencies: - "@jsonjoy.com/fs-core" "4.56.10" - "@jsonjoy.com/fs-node-builtins" "4.56.10" - "@jsonjoy.com/fs-node-utils" "4.56.10" - thingies "^2.5.0" - -"@jsonjoy.com/fs-node-builtins@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-node-builtins/-/fs-node-builtins-4.56.10.tgz#a32a5bcb093f8b34a99aa8957e993a52ec316662" - integrity sha512-uUnKz8R0YJyKq5jXpZtkGV9U0pJDt8hmYcLRrPjROheIfjMXsz82kXMgAA/qNg0wrZ1Kv+hrg7azqEZx6XZCVw== - -"@jsonjoy.com/fs-node-to-fsa@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-node-to-fsa/-/fs-node-to-fsa-4.56.10.tgz#33fc503e50d283ac5fc510e3accced7fccecf2f4" - integrity sha512-oH+O6Y4lhn9NyG6aEoFwIBNKZeYy66toP5LJcDOMBgL99BKQMUf/zWJspdRhMdn/3hbzQsZ8EHHsuekbFLGUWw== - dependencies: - "@jsonjoy.com/fs-fsa" "4.56.10" - "@jsonjoy.com/fs-node-builtins" "4.56.10" - "@jsonjoy.com/fs-node-utils" "4.56.10" - -"@jsonjoy.com/fs-node-utils@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-node-utils/-/fs-node-utils-4.56.10.tgz#788e95052aa99744f6e8e55b5098afc203df2b9e" - integrity sha512-8EuPBgVI2aDPwFdaNQeNpHsyqPi3rr+85tMNG/lHvQLiVjzoZsvxA//Xd8aB567LUhy4QS03ptT+unkD/DIsNg== - dependencies: - "@jsonjoy.com/fs-node-builtins" "4.56.10" - -"@jsonjoy.com/fs-node@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-node/-/fs-node-4.56.10.tgz#70b18bfaf14544a9820d2016e913dde12c6de991" - integrity sha512-7R4Gv3tkUdW3dXfXiOkqxkElxKNVdd8BDOWC0/dbERd0pXpPY+s2s1Mino+aTvkGrFPiY+mmVxA7zhskm4Ue4Q== - dependencies: - "@jsonjoy.com/fs-core" "4.56.10" - "@jsonjoy.com/fs-node-builtins" "4.56.10" - "@jsonjoy.com/fs-node-utils" "4.56.10" - "@jsonjoy.com/fs-print" "4.56.10" - "@jsonjoy.com/fs-snapshot" "4.56.10" - glob-to-regex.js "^1.0.0" - thingies "^2.5.0" - -"@jsonjoy.com/fs-print@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-print/-/fs-print-4.56.10.tgz#7c181b9aefcc1b268be0e6233bff26310c355335" - integrity sha512-JW4fp5mAYepzFsSGrQ48ep8FXxpg4niFWHdF78wDrFGof7F3tKDJln72QFDEn/27M1yHd4v7sKHHVPh78aWcEw== - dependencies: - "@jsonjoy.com/fs-node-utils" "4.56.10" - tree-dump "^1.1.0" - -"@jsonjoy.com/fs-snapshot@4.56.10": - version "4.56.10" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/fs-snapshot/-/fs-snapshot-4.56.10.tgz#05aadd2c0eaa855b13d6cb17d29b7c8cee239c8c" - integrity sha512-DkR6l5fj7+qj0+fVKm/OOXMGfDFCGXLfyHkORH3DF8hxkpDgIHbhf/DwncBMs2igu/ST7OEkexn1gIqoU6Y+9g== - dependencies: - "@jsonjoy.com/buffers" "^17.65.0" - "@jsonjoy.com/fs-node-utils" "4.56.10" - "@jsonjoy.com/json-pack" "^17.65.0" - "@jsonjoy.com/util" "^17.65.0" - -"@jsonjoy.com/json-pack@^1.11.0": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/json-pack/-/json-pack-1.21.0.tgz#93f8dd57fe3a3a92132b33d1eb182dcd9e7629fa" - integrity sha512-+AKG+R2cfZMShzrF2uQw34v3zbeDYUqnQ+jg7ORic3BGtfw9p/+N6RJbq/kkV8JmYZaINknaEQ2m0/f693ZPpg== - dependencies: - "@jsonjoy.com/base64" "^1.1.2" - "@jsonjoy.com/buffers" "^1.2.0" - "@jsonjoy.com/codegen" "^1.0.0" - "@jsonjoy.com/json-pointer" "^1.0.2" - "@jsonjoy.com/util" "^1.9.0" - hyperdyperid "^1.2.0" - thingies "^2.5.0" - tree-dump "^1.1.0" - -"@jsonjoy.com/json-pack@^17.65.0": - version "17.67.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/json-pack/-/json-pack-17.67.0.tgz#8dd8ff65dd999c5d4d26df46c63915c7bdec093a" - integrity sha512-t0ejURcGaZsn1ClbJ/3kFqSOjlryd92eQY465IYrezsXmPcfHPE/av4twRSxf6WE+TkZgLY+71vCZbiIiFKA/w== - dependencies: - "@jsonjoy.com/base64" "17.67.0" - "@jsonjoy.com/buffers" "17.67.0" - "@jsonjoy.com/codegen" "17.67.0" - "@jsonjoy.com/json-pointer" "17.67.0" - "@jsonjoy.com/util" "17.67.0" - hyperdyperid "^1.2.0" - thingies "^2.5.0" - tree-dump "^1.1.0" - -"@jsonjoy.com/json-pointer@17.67.0": - version "17.67.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/json-pointer/-/json-pointer-17.67.0.tgz#74439573dc046e0c9a3a552fb94b391bc75313b8" - integrity sha512-+iqOFInH+QZGmSuaybBUNdh7yvNrXvqR+h3wjXm0N/3JK1EyyFAeGJvqnmQL61d1ARLlk/wJdFKSL+LHJ1eaUA== - dependencies: - "@jsonjoy.com/util" "17.67.0" - -"@jsonjoy.com/json-pointer@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/json-pointer/-/json-pointer-1.0.2.tgz#049cb530ac24e84cba08590c5e36b431c4843408" - integrity sha512-Fsn6wM2zlDzY1U+v4Nc8bo3bVqgfNTGcn6dMgs6FjrEnt4ZCe60o6ByKRjOGlI2gow0aE/Q41QOigdTqkyK5fg== - dependencies: - "@jsonjoy.com/codegen" "^1.0.0" - "@jsonjoy.com/util" "^1.9.0" - -"@jsonjoy.com/util@17.67.0", "@jsonjoy.com/util@^17.65.0": - version "17.67.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/util/-/util-17.67.0.tgz#7c4288fc3808233e55c7610101e7bb4590cddd3f" - integrity sha512-6+8xBaz1rLSohlGh68D1pdw3AwDi9xydm8QNlAFkvnavCJYSze+pxoW2VKP8p308jtlMRLs5NTHfPlZLd4w7ew== - dependencies: - "@jsonjoy.com/buffers" "17.67.0" - "@jsonjoy.com/codegen" "17.67.0" - -"@jsonjoy.com/util@^1.9.0": - version "1.9.0" - resolved "https://registry.yarnpkg.com/@jsonjoy.com/util/-/util-1.9.0.tgz#7ee95586aed0a766b746cd8d8363e336c3c47c46" - integrity sha512-pLuQo+VPRnN8hfPqUTLTHk126wuYdXVxE6aDmjSeV4NCAgyxWbiOIeNJVtID3h1Vzpoi9m4jXezf73I6LgabgQ== - dependencies: - "@jsonjoy.com/buffers" "^1.0.0" - "@jsonjoy.com/codegen" "^1.0.0" - -"@leichtgewicht/ip-codec@^2.0.1": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz#4fc56c15c580b9adb7dc3c333a134e540b44bfb1" - integrity sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw== - -"@noble/hashes@1.4.0": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" - integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== - -"@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" - -"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== - -"@nodelib/fs.walk@^1.2.3", "@nodelib/fs.walk@^1.2.8": - version "1.2.8" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== - dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" - -"@peculiar/asn1-cms@^2.6.0", "@peculiar/asn1-cms@^2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-cms/-/asn1-cms-2.6.1.tgz#cb5445c1bad9197d176073bf142a5c035b460640" - integrity sha512-vdG4fBF6Lkirkcl53q6eOdn3XYKt+kJTG59edgRZORlg/3atWWEReRCx5rYE1ZzTTX6vLK5zDMjHh7vbrcXGtw== - dependencies: - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.1" - "@peculiar/asn1-x509-attr" "^2.6.1" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-csr@^2.6.0": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-csr/-/asn1-csr-2.6.1.tgz#9629d403bc5a61254f28ed0b90e99cee61c0e8be" - integrity sha512-WRWnKfIocHyzFYQTka8O/tXCiBquAPSrRjXbOkHbO4qdmS6loffCEGs+rby6WxxGdJCuunnhS2duHURhjyio6w== - dependencies: - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.1" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-ecc@^2.6.0": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-ecc/-/asn1-ecc-2.6.1.tgz#d29c4af671508a9934edc78e7c9419fbf7bc9870" - integrity sha512-+Vqw8WFxrtDIN5ehUdvlN2m73exS2JVG0UAyfVB31gIfor3zWEAQPD+K9ydCxaj3MLen9k0JhKpu9LqviuCE1g== - dependencies: - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.1" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-pfx@^2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-pfx/-/asn1-pfx-2.6.1.tgz#75cddd14d43ef875109e91ea150377d679c8fbc1" - integrity sha512-nB5jVQy3MAAWvq0KY0R2JUZG8bO/bTLpnwyOzXyEh/e54ynGTatAR+csOnXkkVD9AFZ2uL8Z7EV918+qB1qDvw== - dependencies: - "@peculiar/asn1-cms" "^2.6.1" - "@peculiar/asn1-pkcs8" "^2.6.1" - "@peculiar/asn1-rsa" "^2.6.1" - "@peculiar/asn1-schema" "^2.6.0" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-pkcs8@^2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.6.1.tgz#bd56b4bb9e8a3702369049713a89134c87c6931a" - integrity sha512-JB5iQ9Izn5yGMw3ZG4Nw3Xn/hb/G38GYF3lf7WmJb8JZUydhVGEjK/ZlFSWhnlB7K/4oqEs8HnfFIKklhR58Tw== - dependencies: - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.1" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-pkcs9@^2.6.0": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.6.1.tgz#ddc5222952f25b59a0562a6f8cabdb72f586a496" - integrity sha512-5EV8nZoMSxeWmcxWmmcolg22ojZRgJg+Y9MX2fnE2bGRo5KQLqV5IL9kdSQDZxlHz95tHvIq9F//bvL1OeNILw== - dependencies: - "@peculiar/asn1-cms" "^2.6.1" - "@peculiar/asn1-pfx" "^2.6.1" - "@peculiar/asn1-pkcs8" "^2.6.1" - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.1" - "@peculiar/asn1-x509-attr" "^2.6.1" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-rsa@^2.6.0", "@peculiar/asn1-rsa@^2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-rsa/-/asn1-rsa-2.6.1.tgz#2cdf9f9ea6d6fdbaae214b9fed6de0534b654437" - integrity sha512-1nVMEh46SElUt5CB3RUTV4EG/z7iYc7EoaDY5ECwganibQPkZ/Y2eMsTKB/LeyrUJ+W/tKoD9WUqIy8vB+CEdA== - dependencies: - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.1" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-schema@^2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.6.0.tgz#0dca1601d5b0fed2a72fed7a5f1d0d7dbe3a6f82" - integrity sha512-xNLYLBFTBKkCzEZIw842BxytQQATQv+lDTCEMZ8C196iJcJJMBUZxrhSTxLaohMyKK8QlzRNTRkUmanucnDSqg== - dependencies: - asn1js "^3.0.6" - pvtsutils "^1.3.6" - tslib "^2.8.1" - -"@peculiar/asn1-x509-attr@^2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.6.1.tgz#6425008b8099476010aace5b8ae9f9cbc41db0ab" - integrity sha512-tlW6cxoHwgcQghnJwv3YS+9OO1737zgPogZ+CgWRUK4roEwIPzRH4JEiG770xe5HX2ATfCpmX60gurfWIF9dcQ== - dependencies: - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.1" - asn1js "^3.0.6" - tslib "^2.8.1" - -"@peculiar/asn1-x509@^2.6.0", "@peculiar/asn1-x509@^2.6.1": - version "2.6.1" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-x509/-/asn1-x509-2.6.1.tgz#4e8995659e16178e0e90fe90519aa269045af262" - integrity sha512-O9jT5F1A2+t3r7C4VT7LYGXqkGLK7Kj1xFpz7U0isPrubwU5PbDoyYtx6MiGst29yq7pXN5vZbQFKRCP+lLZlA== - dependencies: - "@peculiar/asn1-schema" "^2.6.0" - asn1js "^3.0.6" - pvtsutils "^1.3.6" - tslib "^2.8.1" - -"@peculiar/x509@^1.14.2": - version "1.14.3" - resolved "https://registry.yarnpkg.com/@peculiar/x509/-/x509-1.14.3.tgz#2c44c2b89474346afec38a0c2803ec4fb8ce959e" - integrity sha512-C2Xj8FZ0uHWeCXXqX5B4/gVFQmtSkiuOolzAgutjTfseNOHT3pUjljDZsTSxXFGgio54bCzVFqmEOUrIVk8RDA== - dependencies: - "@peculiar/asn1-cms" "^2.6.0" - "@peculiar/asn1-csr" "^2.6.0" - "@peculiar/asn1-ecc" "^2.6.0" - "@peculiar/asn1-pkcs9" "^2.6.0" - "@peculiar/asn1-rsa" "^2.6.0" - "@peculiar/asn1-schema" "^2.6.0" - "@peculiar/asn1-x509" "^2.6.0" - pvtsutils "^1.3.6" - reflect-metadata "^0.2.2" - tslib "^2.8.1" - tsyringe "^4.10.0" - -"@preact/signals-core@^1.2.2": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@preact/signals-core/-/signals-core-1.2.2.tgz#279dcc5ab249de2f2e8f6e6779b1958256ba843e" - integrity sha512-z3/bCj7rRA21RJb4FeJ4guCrD1CQbaURHkCTunUWQpxUMAFOPXCD8tSFqERyGrrcSb4T3Hrmdc1OAl0LXBHwiw== - -"@preact/signals-react@^1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@preact/signals-react/-/signals-react-1.2.1.tgz#6d5d305ebdb38c879043acebc65c0d9351e663c1" - integrity sha512-73J8sL1Eru7Ot4yBYOCPj1izEZjzCEXlembRgk6C7PkwsqoAVbCxMlDOFfCLoPFuJ6qeGatrJzRkcycXppMqVQ== - dependencies: - "@preact/signals-core" "^1.2.2" - use-sync-external-store "^1.2.0" - -"@sinclair/typebox@^0.24.1": - version "0.24.51" - resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.51.tgz#645f33fe4e02defe26f2f5c0410e1c094eac7f5f" - integrity sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA== - -"@sinonjs/commons@^1.7.0": - version "1.8.6" - resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.6.tgz#80c516a4dc264c2a69115e7578d62581ff455ed9" - integrity sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ== - dependencies: - type-detect "4.0.8" - -"@sinonjs/fake-timers@^9.1.2": - version "9.1.2" - resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz#4eaab737fab77332ab132d396a3c0d364bd0ea8c" - integrity sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw== - dependencies: - "@sinonjs/commons" "^1.7.0" - -"@tailwindcss/forms@^0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@tailwindcss/forms/-/forms-0.5.2.tgz#4ef45f9916dcb37838cbe7fecdcc4ba7a7c2ab59" - integrity sha512-pSrFeJB6Bg1Mrg9CdQW3+hqZXAKsBrSG9MAfFLKy1pVA4Mb4W7C0k7mEhlmS2Dfo/otxrQOET7NJiJ9RrS563w== - dependencies: - mini-svg-data-uri "^1.2.3" - -"@tailwindcss/line-clamp@^0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@tailwindcss/line-clamp/-/line-clamp-0.4.0.tgz#03353e31e77636b785f2336e8c978502cec1de81" - integrity sha512-HQZo6gfx1D0+DU3nWlNLD5iA6Ef4JAXh0LeD8lOGrJwEDBwwJNKQza6WoXhhY1uQrxOuU8ROxV7CqiQV4CoiLw== - -"@testing-library/dom@^8.0.0", "@testing-library/dom@^8.11.1", "@testing-library/dom@^8.14.0": - version "8.14.0" - resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.14.0.tgz#c9830a21006d87b9ef6e1aae306cf49b0283e28e" - integrity sha512-m8FOdUo77iMTwVRCyzWcqxlEIk+GnopbrRI15a0EaLbpZSCinIVI4kSQzWhkShK83GogvEFJSsHF3Ws0z1vrqA== - dependencies: - "@babel/code-frame" "^7.10.4" - "@babel/runtime" "^7.12.5" - "@types/aria-query" "^4.2.0" - aria-query "^5.0.0" - chalk "^4.1.0" - dom-accessibility-api "^0.5.9" - lz-string "^1.4.4" - pretty-format "^27.0.2" - -"@testing-library/jest-dom@^5.16.4": - version "5.16.4" - resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.4.tgz#938302d7b8b483963a3ae821f1c0808f872245cd" - integrity sha512-Gy+IoFutbMQcky0k+bqqumXZ1cTGswLsFqmNLzNdSKkU9KGV2u9oXhukCbbJ9/LRPKiqwxEE8VpV/+YZlfkPUA== - dependencies: - "@babel/runtime" "^7.9.2" - "@types/testing-library__jest-dom" "^5.9.1" - aria-query "^5.0.0" - chalk "^3.0.0" - css "^3.0.0" - css.escape "^1.5.1" - dom-accessibility-api "^0.5.6" - lodash "^4.17.15" - redent "^3.0.0" - -"@testing-library/react@12.1.5": - version "12.1.5" - resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-12.1.5.tgz#bb248f72f02a5ac9d949dea07279095fa577963b" - integrity sha512-OfTXCJUFgjd/digLUuPxa0+/3ZxsQmE7ub9kcbW/wi96Bh3o/p5vrETcBGfP17NWPGqeYYl5LTRpwyGoMC4ysg== - dependencies: - "@babel/runtime" "^7.12.5" - "@testing-library/dom" "^8.0.0" - "@types/react-dom" "<18.0.0" - -"@testing-library/user-event@^14.2.1": - version "14.2.1" - resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.2.1.tgz#8c5ff2d004544bb2220e1d864f7267fe7eb6c556" - integrity sha512-HOr1QiODrq+0j9lKU5i10y9TbhxMBMRMGimNx10asdmau9cb8Xb1Vyg0GvTwyIL2ziQyh2kAloOtAQFBQVuecA== - -"@types/aria-query@^4.2.0": - version "4.2.2" - resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc" - integrity sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig== - -"@types/babel__core@^7.1.14": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" - integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA== - dependencies: - "@babel/parser" "^7.20.7" - "@babel/types" "^7.20.7" - "@types/babel__generator" "*" - "@types/babel__template" "*" - "@types/babel__traverse" "*" - -"@types/babel__generator@*": - version "7.27.0" - resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.27.0.tgz#b5819294c51179957afaec341442f9341e4108a9" - integrity sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg== - dependencies: - "@babel/types" "^7.0.0" - -"@types/babel__template@*": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.4.tgz#5672513701c1b2199bc6dad636a9d7491586766f" - integrity sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A== - dependencies: - "@babel/parser" "^7.1.0" - "@babel/types" "^7.0.0" - -"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": - version "7.28.0" - resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.28.0.tgz#07d713d6cce0d265c9849db0cbe62d3f61f36f74" - integrity sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q== - dependencies: - "@babel/types" "^7.28.2" - -"@types/body-parser@*": - version "1.19.6" - resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.6.tgz#1859bebb8fd7dac9918a45d54c1971ab8b5af474" - integrity sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g== - dependencies: - "@types/connect" "*" - "@types/node" "*" - -"@types/bonjour@^3.5.13": - version "3.5.13" - resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.13.tgz#adf90ce1a105e81dd1f9c61fdc5afda1bfb92956" - integrity sha512-z9fJ5Im06zvUL548KvYNecEVlA7cVDkGUi6kZusb04mpyEFKCIZJvloCcmpmLaIahDpOQGHaHmG6imtPMmPXGQ== - dependencies: - "@types/node" "*" - -"@types/codemirror@^0.0.98": - version "0.0.98" - resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-0.0.98.tgz#b35c7a4ab1fc1684b08a4e3eb65240020556ebfb" - integrity sha512-cbty5LPayy2vNSeuUdjNA9tggG+go5vAxmnLDRWpiZI5a+RDBi9dlozy4/jW/7P/gletbBWbQREEa7A81YxstA== - dependencies: - "@types/tern" "*" - -"@types/connect-history-api-fallback@^1.5.4": - version "1.5.4" - resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.5.4.tgz#7de71645a103056b48ac3ce07b3520b819c1d5b3" - integrity sha512-n6Cr2xS1h4uAulPRdlw6Jl6s1oG8KrVilPN2yUITEs+K48EzMJJ3W1xy8K5eWuFvjp3R74AOIGSmp2UfBJ8HFw== - dependencies: - "@types/express-serve-static-core" "*" - "@types/node" "*" - -"@types/connect@*": - version "3.4.38" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" - integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== - dependencies: - "@types/node" "*" - -"@types/debounce@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@types/debounce/-/debounce-1.2.0.tgz#9ee99259f41018c640b3929e1bb32c3dcecdb192" - integrity sha512-bWG5wapaWgbss9E238T0R6bfo5Fh3OkeoSt245CM7JJwVwpw6MEBCbIxLq5z8KzsE3uJhzcIuQkyiZmzV3M/Dw== - -"@types/eslint-scope@^3.7.7": - version "3.7.7" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" - integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== - dependencies: - "@types/eslint" "*" - "@types/estree" "*" - -"@types/eslint@*": - version "9.6.1" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-9.6.1.tgz#d5795ad732ce81715f27f75da913004a56751584" - integrity sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag== - dependencies: - "@types/estree" "*" - "@types/json-schema" "*" - -"@types/estree@*", "@types/estree@^1.0.8": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e" - integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== - -"@types/events@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" - -"@types/express-serve-static-core@*", "@types/express-serve-static-core@^5.0.0": - version "5.1.1" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-5.1.1.tgz#1a77faffee9572d39124933259be2523837d7eaa" - integrity sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A== - dependencies: - "@types/node" "*" - "@types/qs" "*" - "@types/range-parser" "*" - "@types/send" "*" - -"@types/express-serve-static-core@^4.17.21", "@types/express-serve-static-core@^4.17.33": - version "4.19.8" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.19.8.tgz#99b960322a4d576b239a640ab52ef191989b036f" - integrity sha512-02S5fmqeoKzVZCHPZid4b8JH2eM5HzQLZWN2FohQEy/0eXTq8VXZfSN6Pcr3F6N9R/vNrj7cpgbhjie6m/1tCA== - dependencies: - "@types/node" "*" - "@types/qs" "*" - "@types/range-parser" "*" - "@types/send" "*" - -"@types/express@*": - version "5.0.6" - resolved "https://registry.yarnpkg.com/@types/express/-/express-5.0.6.tgz#2d724b2c990dcb8c8444063f3580a903f6d500cc" - integrity sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA== - dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "^5.0.0" - "@types/serve-static" "^2" - -"@types/express@^4.17.25": - version "4.17.25" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.25.tgz#070c8c73a6fee6936d65c195dbbfb7da5026649b" - integrity sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw== - dependencies: - "@types/body-parser" "*" - "@types/express-serve-static-core" "^4.17.33" - "@types/qs" "*" - "@types/serve-static" "^1" - -"@types/graceful-fs@^4.1.3": - version "4.1.9" - resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" - integrity sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ== - dependencies: - "@types/node" "*" - -"@types/history@*": - version "4.7.2" - resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.2.tgz#0e670ea254d559241b6eeb3894f8754991e73220" - -"@types/hoist-non-react-statics@*", "@types/hoist-non-react-statics@^3.3.0": - version "3.3.1" - resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" - dependencies: - "@types/react" "*" - hoist-non-react-statics "^3.3.0" - -"@types/hoist-non-react-statics@^3.3.1": - version "3.3.7" - resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.7.tgz#306e3a3a73828522efa1341159da4846e7573a6c" - integrity sha512-PQTyIulDkIDro8P+IHbKCsw7U2xxBYflVzW/FgWdCAePD9xGSidgA76/GeJ6lBKoblyhf9pBY763gbrN+1dI8g== - dependencies: - hoist-non-react-statics "^3.3.0" - -"@types/http-errors@*": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.5.tgz#5b749ab2b16ba113423feb1a64a95dcd30398472" - integrity sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg== - -"@types/http-proxy@^1.17.8": - version "1.17.17" - resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.17.tgz#d9e2c4571fe3507343cb210cd41790375e59a533" - integrity sha512-ED6LB+Z1AVylNTu7hdzuBqOgMnvG/ld6wGCG8wFnAzKX5uyW2K3WD52v0gnLCTK/VLpXtKckgWuyScYK6cSPaw== - dependencies: - "@types/node" "*" - -"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": - version "2.0.6" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" - integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== - -"@types/istanbul-lib-report@*": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz#53047614ae72e19fc0401d872de3ae2b4ce350bf" - integrity sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA== - dependencies: - "@types/istanbul-lib-coverage" "*" - -"@types/istanbul-reports@^3.0.0": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" - integrity sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ== - dependencies: - "@types/istanbul-lib-report" "*" - -"@types/jest@*": - version "28.1.3" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-28.1.3.tgz#52f3f3e50ce59191ff5fbb1084896cc0cf30c9ce" - integrity sha512-Tsbjk8Y2hkBaY/gJsataeb4q9Mubw9EOz7+4RjPkzD5KjTvHHs7cpws22InaoXxAVAhF5HfFbzJjo6oKWqSZLw== - dependencies: - jest-matcher-utils "^28.0.0" - pretty-format "^28.0.0" - -"@types/jest@^28.1.3": - version "28.1.8" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-28.1.8.tgz#6936409f3c9724ea431efd412ea0238a0f03b09b" - integrity sha512-8TJkV++s7B6XqnDrzR1m/TT0A0h948Pnl/097veySPN67VRAgQ4gZ7n2KfJo2rVq6njQjdxU3GCCyDvAeuHoiw== - dependencies: - expect "^28.0.0" - pretty-format "^28.0.0" - -"@types/json-schema@*", "@types/json-schema@^7.0.15", "@types/json-schema@^7.0.9": - version "7.0.15" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" - integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== - -"@types/json-schema@^7.0.8": - version "7.0.11" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" - integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== - -"@types/mime@^1": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" - integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== - -"@types/node@*": - version "25.2.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-25.2.3.tgz#9c18245be768bdb4ce631566c7da303a5c99a7f8" - integrity sha512-m0jEgYlYz+mDJZ2+F4v8D1AyQb+QzsNqRuI7xg1VQX/KlKS0qT9r1Mo16yo5F/MtifXFgaofIFsdFMox2SxIbQ== - dependencies: - undici-types "~7.16.0" - -"@types/node@^22.0.0": - version "22.19.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.19.1.tgz#1188f1ddc9f46b4cc3aec76749050b4e1f459b7b" - integrity sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ== - dependencies: - undici-types "~6.21.0" - -"@types/parse-json@^4.0.0": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239" - integrity sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw== - -"@types/path-browserify@^1.0.3": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@types/path-browserify/-/path-browserify-1.0.3.tgz#25de712d4def94b3901f033c30d3d3bd16eba8d3" - integrity sha512-ZmHivEbNCBtAfcrFeBCiTjdIc2dey0l7oCGNGpSuRTy8jP6UVND7oUowlvDujBy8r2Hoa8bfFUOCiPWfmtkfxw== - -"@types/prettier@^2.1.5": - version "2.7.3" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f" - integrity sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA== - -"@types/prop-types@*": - version "15.7.1" - resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6" - -"@types/qrcode.react@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@types/qrcode.react/-/qrcode.react-1.0.1.tgz#0904e7a075a6274a5258f19567b4f64013c159d8" - integrity sha512-PcVCjpsiT2KFKfJibOgTQtkt0QQT/6GbQUp1Np/hMPhwUzMJ2DRUkR9j7tXN9Q8X06qukw+RbaJ8lJ22SBod+Q== - dependencies: - "@types/react" "*" - -"@types/qs@*": - version "6.14.0" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.14.0.tgz#d8b60cecf62f2db0fb68e5e006077b9178b85de5" - integrity sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ== - -"@types/range-parser@*": - version "1.2.7" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" - integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== - -"@types/react-copy-to-clipboard@^4.3.0": - version "4.3.0" - resolved "https://registry.yarnpkg.com/@types/react-copy-to-clipboard/-/react-copy-to-clipboard-4.3.0.tgz#8e07becb4f11cfced4bd36038cb5bdf5c2658be5" - integrity sha512-iideNPRyroENqsOFh1i2Dv3zkviYS9r/9qD9Uh3Z9NNoAAqqa2x53i7iGndGNnJFIo20wIu7Hgh77tx1io8bgw== - dependencies: - "@types/react" "*" - -"@types/react-dom@<18.0.0": - version "17.0.17" - resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.17.tgz#2e3743277a793a96a99f1bf87614598289da68a1" - integrity sha512-VjnqEmqGnasQKV0CWLevqMTXBYG9GbwuE6x3VetERLh0cq2LTptFE73MrQi2S7GkKXCf2GgwItB/melLnxfnsg== - dependencies: - "@types/react" "^17" - -"@types/react-dom@^16.9.16": - version "16.9.16" - resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.16.tgz#c591f2ed1c6f32e9759dfa6eb4abfd8041f29e39" - integrity sha512-Oqc0RY4fggGA3ltEgyPLc3IV9T73IGoWjkONbsyJ3ZBn+UPPCYpU2ec0i3cEbJuEdZtkqcCF2l1zf2pBdgUGSg== - dependencies: - "@types/react" "^16" - -"@types/react-redux@^7.1.1": - version "7.1.1" - resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.1.tgz#eb01e89cf71cad77df9f442b819d5db692b997cb" - dependencies: - "@types/hoist-non-react-statics" "^3.3.0" - "@types/react" "*" - hoist-non-react-statics "^3.3.0" - redux "^4.0.0" - -"@types/react-router-dom@^5.1.3": - version "5.1.3" - resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.1.3.tgz#b5d28e7850bd274d944c0fbbe5d57e6b30d71196" - dependencies: - "@types/history" "*" - "@types/react" "*" - "@types/react-router" "*" - -"@types/react-router@*", "@types/react-router@^5.1.3": - version "5.1.3" - resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.3.tgz#7c7ca717399af64d8733d8cb338dd43641b96f2d" - dependencies: - "@types/history" "*" - "@types/react" "*" - -"@types/react-transition-group@^4.4.0": - version "4.4.0" - resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.0.tgz#882839db465df1320e4753e6e9f70ca7e9b4d46d" - integrity sha512-/QfLHGpu+2fQOqQaXh8MG9q03bFENooTb/it4jr5kKaZlDQfWvjqWZg48AwzPVMBHlRuTRAY7hRHCEOXz5kV6w== - dependencies: - "@types/react" "*" - -"@types/react@*", "@types/react@^17": - version "17.0.47" - resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.47.tgz#4ee71aaf4c5a9e290e03aa4d0d313c5d666b3b78" - integrity sha512-mk0BL8zBinf2ozNr3qPnlu1oyVTYq+4V7WA76RgxUAtf0Em/Wbid38KN6n4abEkvO4xMTBWmnP1FtQzgkEiJoA== - dependencies: - "@types/prop-types" "*" - "@types/scheduler" "*" - csstype "^3.0.2" - -"@types/react@^16", "@types/react@^16.14.0": - version "16.14.26" - resolved "https://registry.yarnpkg.com/@types/react/-/react-16.14.26.tgz#82540a240ba7207ebe87d9579051bc19c9ef7605" - integrity sha512-c/5CYyciOO4XdFcNhZW1O2woVx86k4T+DO2RorHZL7EhitkNQgSD/SgpdZJAUJa/qjVgOmTM44gHkAdZSXeQuQ== - dependencies: - "@types/prop-types" "*" - "@types/scheduler" "*" - csstype "^3.0.2" - -"@types/retry@0.12.2": - version "0.12.2" - resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.2.tgz#ed279a64fa438bb69f2480eda44937912bb7480a" - integrity sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow== - -"@types/scheduler@*": - version "0.16.2" - resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" - integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== - -"@types/semver@^7.3.12": - version "7.7.1" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.7.1.tgz#3ce3af1a5524ef327d2da9e4fd8b6d95c8d70528" - integrity sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA== - -"@types/send@*": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@types/send/-/send-1.2.1.tgz#6a784e45543c18c774c049bff6d3dbaf045c9c74" - integrity sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ== - dependencies: - "@types/node" "*" - -"@types/send@<1": - version "0.17.6" - resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.6.tgz#aeb5385be62ff58a52cd5459daa509ae91651d25" - integrity sha512-Uqt8rPBE8SY0RK8JB1EzVOIZ32uqy8HwdxCnoCOsYrvnswqmFZ/k+9Ikidlk/ImhsdvBsloHbAlewb2IEBV/Og== - dependencies: - "@types/mime" "^1" - "@types/node" "*" - -"@types/serve-index@^1.9.4": - version "1.9.4" - resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.4.tgz#e6ae13d5053cb06ed36392110b4f9a49ac4ec898" - integrity sha512-qLpGZ/c2fhSs5gnYsQxtDEq3Oy8SXPClIXkW5ghvAvsNuVSA8k+gCONcUCS/UjLEYvYps+e8uBtfgXgvhwfNug== - dependencies: - "@types/express" "*" - -"@types/serve-static@^1", "@types/serve-static@^1.15.5": - version "1.15.10" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.10.tgz#768169145a778f8f5dfcb6360aead414a3994fee" - integrity sha512-tRs1dB+g8Itk72rlSI2ZrW6vZg0YrLI81iQSTkMmOqnqCaNr/8Ek4VwWcN5vZgCYWbg/JJSGBlUaYGAOP73qBw== - dependencies: - "@types/http-errors" "*" - "@types/node" "*" - "@types/send" "<1" - -"@types/serve-static@^2": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-2.2.0.tgz#d4a447503ead0d1671132d1ab6bd58b805d8de6a" - integrity sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ== - dependencies: - "@types/http-errors" "*" - "@types/node" "*" - -"@types/sockjs@^0.3.36": - version "0.3.36" - resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.36.tgz#ce322cf07bcc119d4cbf7f88954f3a3bd0f67535" - integrity sha512-MK9V6NzAS1+Ud7JV9lJLFqW85VbC9dq3LmwZCuBe4wBDgKC0Kj/jd8Xl+nSviU+Qc3+m7umHHyHg//2KSa0a0Q== - dependencies: - "@types/node" "*" - -"@types/stack-utils@^2.0.0": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" - integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== - -"@types/styled-components@5.1.7": - version "5.1.7" - resolved "https://registry.yarnpkg.com/@types/styled-components/-/styled-components-5.1.7.tgz#3cd10b088c1cb1acde2e4b166b3e8275a3083710" - integrity sha512-BJzPhFygYspyefAGFZTZ/8lCEY4Tk+Iqktvnko3xmJf9LrLqs3+grxPeU3O0zLl6yjbYBopD0/VikbHgXDbJtA== - dependencies: - "@types/hoist-non-react-statics" "*" - "@types/react" "*" - csstype "^3.0.2" - -"@types/tern@*": - version "0.23.3" - resolved "https://registry.yarnpkg.com/@types/tern/-/tern-0.23.3.tgz#4b54538f04a88c9ff79de1f6f94f575a7f339460" - integrity sha512-imDtS4TAoTcXk0g7u4kkWqedB3E4qpjXzCpD2LU5M5NAXHzCDsypyvXSaG7mM8DKYkCRa7tFp4tS/lp/Wo7Q3w== - dependencies: - "@types/estree" "*" - -"@types/testing-library__jest-dom@^5.9.1": - version "5.14.5" - resolved "https://registry.yarnpkg.com/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.5.tgz#d113709c90b3c75fdb127ec338dad7d5f86c974f" - integrity sha512-SBwbxYoyPIvxHbeHxTZX2Pe/74F/tX2/D3mMvzabdeJ25bBojfW0TyB8BHrbq/9zaaKICJZjLP+8r6AeZMFCuQ== - dependencies: - "@types/jest" "*" - -"@types/uuid@^3.4.5": - version "3.4.5" - resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-3.4.5.tgz#d4dc10785b497a1474eae0ba7f0cb09c0ddfd6eb" - dependencies: - "@types/node" "*" - -"@types/webpack-env@^1.18.8": - version "1.18.8" - resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.18.8.tgz#71f083718c094204d7b64443701d32f1db3989e3" - integrity sha512-G9eAoJRMLjcvN4I08wB5I7YofOb/kaJNd5uoCMX+LbKXTPCF+ZIHuqTnFaK9Jz1rgs035f9JUPUhNFtqgucy/A== - -"@types/ws@^8.5.10": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.18.1.tgz#48464e4bf2ddfd17db13d845467f6070ffea4aa9" - integrity sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg== - dependencies: - "@types/node" "*" - -"@types/yargs-parser@*": - version "21.0.3" - resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" - integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== - -"@types/yargs@^17.0.8": - version "17.0.35" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.35.tgz#07013e46aa4d7d7d50a49e15604c1c5340d4eb24" - integrity sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg== - dependencies: - "@types/yargs-parser" "*" - -"@types/yup@^0.29.3": - version "0.29.3" - resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.29.3.tgz#5a85024796bffe0eb01601bfc180fe218356dba4" - integrity sha512-XxZFKnxzTfm+DR8MMBA35UUXfUPmjPpi8HJ90VZg7q/LIbtiOhVGJ26gNnATcflcpnIyf2Qm9A+oEhswaqoDpA== - -"@typescript-eslint/eslint-plugin@^5": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz#aeef0328d172b9e37d9bab6dbc13b87ed88977db" - integrity sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag== - dependencies: - "@eslint-community/regexpp" "^4.4.0" - "@typescript-eslint/scope-manager" "5.62.0" - "@typescript-eslint/type-utils" "5.62.0" - "@typescript-eslint/utils" "5.62.0" - debug "^4.3.4" - graphemer "^1.4.0" - ignore "^5.2.0" - natural-compare-lite "^1.4.0" - semver "^7.3.7" - tsutils "^3.21.0" - -"@typescript-eslint/parser@^5": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.62.0.tgz#1b63d082d849a2fcae8a569248fbe2ee1b8a56c7" - integrity sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA== - dependencies: - "@typescript-eslint/scope-manager" "5.62.0" - "@typescript-eslint/types" "5.62.0" - "@typescript-eslint/typescript-estree" "5.62.0" - debug "^4.3.4" - -"@typescript-eslint/scope-manager@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz#d9457ccc6a0b8d6b37d0eb252a23022478c5460c" - integrity sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w== - dependencies: - "@typescript-eslint/types" "5.62.0" - "@typescript-eslint/visitor-keys" "5.62.0" - -"@typescript-eslint/type-utils@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz#286f0389c41681376cdad96b309cedd17d70346a" - integrity sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew== - dependencies: - "@typescript-eslint/typescript-estree" "5.62.0" - "@typescript-eslint/utils" "5.62.0" - debug "^4.3.4" - tsutils "^3.21.0" - -"@typescript-eslint/types@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f" - integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ== - -"@typescript-eslint/typescript-estree@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz#7d17794b77fabcac615d6a48fb143330d962eb9b" - integrity sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA== - dependencies: - "@typescript-eslint/types" "5.62.0" - "@typescript-eslint/visitor-keys" "5.62.0" - debug "^4.3.4" - globby "^11.1.0" - is-glob "^4.0.3" - semver "^7.3.7" - tsutils "^3.21.0" - -"@typescript-eslint/utils@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86" - integrity sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ== - dependencies: - "@eslint-community/eslint-utils" "^4.2.0" - "@types/json-schema" "^7.0.9" - "@types/semver" "^7.3.12" - "@typescript-eslint/scope-manager" "5.62.0" - "@typescript-eslint/types" "5.62.0" - "@typescript-eslint/typescript-estree" "5.62.0" - eslint-scope "^5.1.1" - semver "^7.3.7" - -"@typescript-eslint/visitor-keys@5.62.0": - version "5.62.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz#2174011917ce582875954ffe2f6912d5931e353e" - integrity sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw== - dependencies: - "@typescript-eslint/types" "5.62.0" - eslint-visitor-keys "^3.3.0" - -"@ungap/structured-clone@^1.2.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.0.tgz#d06bbb384ebcf6c505fde1c3d0ed4ddffe0aaff8" - integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g== - -"@webassemblyjs/ast@1.14.1", "@webassemblyjs/ast@^1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.14.1.tgz#a9f6a07f2b03c95c8d38c4536a1fdfb521ff55b6" - integrity sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ== - dependencies: - "@webassemblyjs/helper-numbers" "1.13.2" - "@webassemblyjs/helper-wasm-bytecode" "1.13.2" - -"@webassemblyjs/floating-point-hex-parser@1.13.2": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz#fcca1eeddb1cc4e7b6eed4fc7956d6813b21b9fb" - integrity sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA== - -"@webassemblyjs/helper-api-error@1.13.2": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.13.2.tgz#e0a16152248bc38daee76dd7e21f15c5ef3ab1e7" - integrity sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ== - -"@webassemblyjs/helper-buffer@1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.14.1.tgz#822a9bc603166531f7d5df84e67b5bf99b72b96b" - integrity sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA== - -"@webassemblyjs/helper-numbers@1.13.2": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.13.2.tgz#dbd932548e7119f4b8a7877fd5a8d20e63490b2d" - integrity sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA== - dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.13.2" - "@webassemblyjs/helper-api-error" "1.13.2" - "@xtuc/long" "4.2.2" - -"@webassemblyjs/helper-wasm-bytecode@1.13.2": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz#e556108758f448aae84c850e593ce18a0eb31e0b" - integrity sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA== - -"@webassemblyjs/helper-wasm-section@1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.14.1.tgz#9629dda9c4430eab54b591053d6dc6f3ba050348" - integrity sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw== - dependencies: - "@webassemblyjs/ast" "1.14.1" - "@webassemblyjs/helper-buffer" "1.14.1" - "@webassemblyjs/helper-wasm-bytecode" "1.13.2" - "@webassemblyjs/wasm-gen" "1.14.1" - -"@webassemblyjs/ieee754@1.13.2": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.13.2.tgz#1c5eaace1d606ada2c7fd7045ea9356c59ee0dba" - integrity sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw== - dependencies: - "@xtuc/ieee754" "^1.2.0" - -"@webassemblyjs/leb128@1.13.2": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.13.2.tgz#57c5c3deb0105d02ce25fa3fd74f4ebc9fd0bbb0" - integrity sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw== - dependencies: - "@xtuc/long" "4.2.2" - -"@webassemblyjs/utf8@1.13.2": - version "1.13.2" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.13.2.tgz#917a20e93f71ad5602966c2d685ae0c6c21f60f1" - integrity sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ== - -"@webassemblyjs/wasm-edit@^1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.14.1.tgz#ac6689f502219b59198ddec42dcd496b1004d597" - integrity sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ== - dependencies: - "@webassemblyjs/ast" "1.14.1" - "@webassemblyjs/helper-buffer" "1.14.1" - "@webassemblyjs/helper-wasm-bytecode" "1.13.2" - "@webassemblyjs/helper-wasm-section" "1.14.1" - "@webassemblyjs/wasm-gen" "1.14.1" - "@webassemblyjs/wasm-opt" "1.14.1" - "@webassemblyjs/wasm-parser" "1.14.1" - "@webassemblyjs/wast-printer" "1.14.1" - -"@webassemblyjs/wasm-gen@1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.14.1.tgz#991e7f0c090cb0bb62bbac882076e3d219da9570" - integrity sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg== - dependencies: - "@webassemblyjs/ast" "1.14.1" - "@webassemblyjs/helper-wasm-bytecode" "1.13.2" - "@webassemblyjs/ieee754" "1.13.2" - "@webassemblyjs/leb128" "1.13.2" - "@webassemblyjs/utf8" "1.13.2" - -"@webassemblyjs/wasm-opt@1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.14.1.tgz#e6f71ed7ccae46781c206017d3c14c50efa8106b" - integrity sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw== - dependencies: - "@webassemblyjs/ast" "1.14.1" - "@webassemblyjs/helper-buffer" "1.14.1" - "@webassemblyjs/wasm-gen" "1.14.1" - "@webassemblyjs/wasm-parser" "1.14.1" - -"@webassemblyjs/wasm-parser@1.14.1", "@webassemblyjs/wasm-parser@^1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.14.1.tgz#b3e13f1893605ca78b52c68e54cf6a865f90b9fb" - integrity sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ== - dependencies: - "@webassemblyjs/ast" "1.14.1" - "@webassemblyjs/helper-api-error" "1.13.2" - "@webassemblyjs/helper-wasm-bytecode" "1.13.2" - "@webassemblyjs/ieee754" "1.13.2" - "@webassemblyjs/leb128" "1.13.2" - "@webassemblyjs/utf8" "1.13.2" - -"@webassemblyjs/wast-printer@1.14.1": - version "1.14.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.14.1.tgz#3bb3e9638a8ae5fdaf9610e7a06b4d9f9aa6fe07" - integrity sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw== - dependencies: - "@webassemblyjs/ast" "1.14.1" - "@xtuc/long" "4.2.2" - -"@webpack-cli/configtest@^3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-3.0.1.tgz#76ac285b9658fa642ce238c276264589aa2b6b57" - integrity sha512-u8d0pJ5YFgneF/GuvEiDA61Tf1VDomHHYMjv/wc9XzYj7nopltpG96nXN5dJRstxZhcNpV1g+nT6CydO7pHbjA== - -"@webpack-cli/info@^3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-3.0.1.tgz#3cff37fabb7d4ecaab6a8a4757d3826cf5888c63" - integrity sha512-coEmDzc2u/ffMvuW9aCjoRzNSPDl/XLuhPdlFRpT9tZHmJ/039az33CE7uH+8s0uL1j5ZNtfdv0HkfaKRBGJsQ== - -"@webpack-cli/serve@^3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-3.0.1.tgz#bd8b1f824d57e30faa19eb78e4c0951056f72f00" - integrity sha512-sbgw03xQaCLiT6gcY/6u3qBDn01CWw/nbaXl3gTdTFuJJ75Gffv3E3DBpgvY2fkkrdS1fpjaXNOmJlnbtKauKg== - -"@xtuc/ieee754@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" - integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== - -"@xtuc/long@4.2.2": - version "4.2.2" - resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" - integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== - -accepts@~1.3.8: - version "1.3.8" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" - integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== - dependencies: - mime-types "~2.1.34" - negotiator "0.6.3" - -acorn-import-phases@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz#16eb850ba99a056cb7cbfe872ffb8972e18c8bd7" - integrity sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ== - -acorn-jsx@^5.3.2: - version "5.3.2" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" - integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== - -acorn-node@^1.8.2: - version "1.8.2" - resolved "https://registry.yarnpkg.com/acorn-node/-/acorn-node-1.8.2.tgz#114c95d64539e53dede23de8b9d96df7c7ae2af8" - integrity sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A== - dependencies: - acorn "^7.0.0" - acorn-walk "^7.0.0" - xtend "^4.0.2" - -acorn-walk@^7.0.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" - integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== - -acorn@^7.0.0: - version "7.4.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" - integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== - -acorn@^8.15.0, acorn@^8.9.0: - version "8.15.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.15.0.tgz#a360898bc415edaac46c8241f6383975b930b816" - integrity sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg== - -ajv-formats@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" - integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA== - dependencies: - ajv "^8.0.0" - -ajv-keywords@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" - integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== - -ajv-keywords@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16" - integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw== - dependencies: - fast-deep-equal "^3.1.3" - -ajv@^6.12.4, ajv@^6.12.5: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ajv@^8.0.0, ajv@^8.9.0: - version "8.18.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.18.0.tgz#8864186b6738d003eb3a933172bb3833e10cefbc" - integrity sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A== - dependencies: - fast-deep-equal "^3.1.3" - fast-uri "^3.0.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - -ansi-escapes@^4.2.1: - version "4.3.2" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" - integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== - dependencies: - type-fest "^0.21.3" - -ansi-html-community@^0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/ansi-html-community/-/ansi-html-community-0.0.8.tgz#69fbc4d6ccbe383f9736934ae34c3f8290f1bf41" - integrity sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw== - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== - dependencies: - color-convert "^1.9.0" - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -ansi-styles@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" - integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== - -any-promise@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" - integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== - -anymatch@^3.0.3, anymatch@~3.1.2: - version "3.1.3" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" - integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -arg@^5.0.1, arg@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c" - integrity sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg== - -argparse@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" - integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== - dependencies: - sprintf-js "~1.0.2" - -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== - -aria-hidden@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/aria-hidden/-/aria-hidden-1.1.3.tgz#bb48de18dc84787a3c6eee113709c473c64ec254" - integrity sha512-RhVWFtKH5BiGMycI72q2RAFMLQi8JP9bLuQXgR5a8Znp7P5KOIADSJeyfI8PCVxLEp067B2HbP5JIiI/PXIZeA== - dependencies: - tslib "^1.0.0" - -aria-query@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.0.0.tgz#210c21aaf469613ee8c9a62c7f86525e058db52c" - integrity sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg== - -array-buffer-byte-length@^1.0.1, array-buffer-byte-length@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz#384d12a37295aec3769ab022ad323a18a51ccf8b" - integrity sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw== - dependencies: - call-bound "^1.0.3" - is-array-buffer "^3.0.5" - -array-flatten@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" - integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== - -array-includes@^3.1.2: - version "3.1.5" - resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.5.tgz#2c320010db8d31031fd2a5f6b3bbd4b1aad31bdb" - integrity sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" - es-abstract "^1.19.5" - get-intrinsic "^1.1.1" - is-string "^1.0.7" - -array-includes@^3.1.8: - version "3.1.9" - resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.9.tgz#1f0ccaa08e90cdbc3eb433210f903ad0f17c3f3a" - integrity sha512-FmeCCAenzH0KH381SPT5FZmiA/TmpndpcaShhfgEN9eCVjnFBqq3l1xrI42y8+PPLI6hypzou4GXw00WHmPBLQ== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.4" - define-properties "^1.2.1" - es-abstract "^1.24.0" - es-object-atoms "^1.1.1" - get-intrinsic "^1.3.0" - is-string "^1.1.1" - math-intrinsics "^1.1.0" - -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - -array.prototype.findlast@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/array.prototype.findlast/-/array.prototype.findlast-1.2.5.tgz#3e4fbcb30a15a7f5bf64cf2faae22d139c2e4904" - integrity sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ== - dependencies: - call-bind "^1.0.7" - define-properties "^1.2.1" - es-abstract "^1.23.2" - es-errors "^1.3.0" - es-object-atoms "^1.0.0" - es-shim-unscopables "^1.0.2" - -array.prototype.flatmap@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.3.tgz#712cc792ae70370ae40586264629e33aab5dd38b" - integrity sha512-Y7Wt51eKJSyi80hFrJCePGGNo5ktJCslFuboqJsbf57CCPcm5zztluPlc4/aD8sWsKvlwatezpV4U1efk8kpjg== - dependencies: - call-bind "^1.0.8" - define-properties "^1.2.1" - es-abstract "^1.23.5" - es-shim-unscopables "^1.0.2" - -array.prototype.tosorted@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz#fe954678ff53034e717ea3352a03f0b0b86f7ffc" - integrity sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA== - dependencies: - call-bind "^1.0.7" - define-properties "^1.2.1" - es-abstract "^1.23.3" - es-errors "^1.3.0" - es-shim-unscopables "^1.0.2" - -arraybuffer.prototype.slice@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz#9d760d84dbdd06d0cbf92c8849615a1a7ab3183c" - integrity sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ== - dependencies: - array-buffer-byte-length "^1.0.1" - call-bind "^1.0.8" - define-properties "^1.2.1" - es-abstract "^1.23.5" - es-errors "^1.3.0" - get-intrinsic "^1.2.6" - is-array-buffer "^3.0.4" - -asn1js@^3.0.6: - version "3.0.7" - resolved "https://registry.yarnpkg.com/asn1js/-/asn1js-3.0.7.tgz#15f1f2f59e60f80d5b43ef14047a294a969f824f" - integrity sha512-uLvq6KJu04qoQM6gvBfKFjlh6Gl0vOKQuR5cJMDHQkmwfMOQeN3F3SHCv9SNYSL+CRoHvOGFfllDlVz03GQjvQ== - dependencies: - pvtsutils "^1.3.6" - pvutils "^1.1.3" - tslib "^2.8.1" - -async-function@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/async-function/-/async-function-1.0.0.tgz#509c9fca60eaf85034c6829838188e4e4c8ffb2b" - integrity sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA== - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -atob@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" - integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== - -autoprefixer@^10.2.5, autoprefixer@^10.4.21: - version "10.4.22" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.22.tgz#90b27ab55ec0cf0684210d1f056f7d65dac55f16" - integrity sha512-ARe0v/t9gO28Bznv6GgqARmVqcWOV3mfgUPn9becPHMiD3o9BwlRgaeccZnwTpZ7Zwqrm+c1sUSsMxIzQzc8Xg== - dependencies: - browserslist "^4.27.0" - caniuse-lite "^1.0.30001754" - fraction.js "^5.3.4" - normalize-range "^0.1.2" - picocolors "^1.1.1" - postcss-value-parser "^4.2.0" - -autoprefixer@^10.4.7: - version "10.4.7" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.7.tgz#1db8d195f41a52ca5069b7593be167618edbbedf" - integrity sha512-ypHju4Y2Oav95SipEcCcI5J7CGPuvz8oat7sUtYj3ClK44bldfvtvcxK6IEK++7rqB7YchDGzweZIBG+SD0ZAA== - dependencies: - browserslist "^4.20.3" - caniuse-lite "^1.0.30001335" - fraction.js "^4.2.0" - normalize-range "^0.1.2" - picocolors "^1.0.0" - postcss-value-parser "^4.2.0" - -available-typed-arrays@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846" - integrity sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ== - dependencies: - possible-typed-array-names "^1.0.0" - -axios@^1.13.2: - version "1.13.5" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.13.5.tgz#5e464688fa127e11a660a2c49441c009f6567a43" - integrity sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q== - dependencies: - follow-redirects "^1.15.11" - form-data "^4.0.5" - proxy-from-env "^1.1.0" - -babel-jest@^28.1.1, babel-jest@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-28.1.3.tgz#c1187258197c099072156a0a121c11ee1e3917d5" - integrity sha512-epUaPOEWMk3cWX0M/sPvCHHCe9fMFAa/9hXEgKP8nFfNl/jlGkE9ucq9NqkZGXLDduCJYS0UvSlPUwC0S+rH6Q== - dependencies: - "@jest/transform" "^28.1.3" - "@types/babel__core" "^7.1.14" - babel-plugin-istanbul "^6.1.1" - babel-preset-jest "^28.1.3" - chalk "^4.0.0" - graceful-fs "^4.2.9" - slash "^3.0.0" - -babel-loader@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-10.0.0.tgz#b9743714c0e1e084b3e4adef3cd5faee33089977" - integrity sha512-z8jt+EdS61AMw22nSfoNJAZ0vrtmhPRVi6ghL3rCeRZI8cdNYFiV5xeV3HbE7rlZZNmGH8BVccwWt8/ED0QOHA== - dependencies: - find-up "^5.0.0" - -babel-plugin-dynamic-import-node@^2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3" - integrity sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ== - dependencies: - object.assign "^4.1.0" - -babel-plugin-istanbul@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz#fa88ec59232fd9b4e36dbbc540a8ec9a9b47da73" - integrity sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA== - dependencies: - "@babel/helper-plugin-utils" "^7.0.0" - "@istanbuljs/load-nyc-config" "^1.0.0" - "@istanbuljs/schema" "^0.1.2" - istanbul-lib-instrument "^5.0.4" - test-exclude "^6.0.0" - -babel-plugin-jest-hoist@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-28.1.3.tgz#1952c4d0ea50f2d6d794353762278d1d8cca3fbe" - integrity sha512-Ys3tUKAmfnkRUpPdpa98eYrAR0nV+sSFUZZEGuQ2EbFd1y4SOLtD5QDNHAq+bb9a+bbXvYQC4b+ID/THIMcU6Q== - dependencies: - "@babel/template" "^7.3.3" - "@babel/types" "^7.3.3" - "@types/babel__core" "^7.1.14" - "@types/babel__traverse" "^7.0.6" - -babel-plugin-macros@^2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/babel-plugin-macros/-/babel-plugin-macros-2.8.0.tgz#0f958a7cc6556b1e65344465d99111a1e5e10138" - integrity sha512-SEP5kJpfGYqYKpBrj5XU3ahw5p5GOHJ0U5ssOSQ/WBVdwkD2Dzlce95exQTs3jOVWPPKLBN2rlEWkCK7dSmLvg== - dependencies: - "@babel/runtime" "^7.7.2" - cosmiconfig "^6.0.0" - resolve "^1.12.0" - -"babel-plugin-styled-components@>= 1.12.0": - version "2.1.4" - resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.1.4.tgz#9a1f37c7f32ef927b4b008b529feb4a2c82b1092" - integrity sha512-Xgp9g+A/cG47sUyRwwYxGM4bR/jDRg5N6it/8+HxCnbT5XNKSKDT9xm4oag/osgqjC2It/vH0yXsomOG6k558g== - dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-module-imports" "^7.22.5" - "@babel/plugin-syntax-jsx" "^7.22.5" - lodash "^4.17.21" - picomatch "^2.3.1" - -babel-plugin-styled-components@^2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.7.tgz#c81ef34b713f9da2b7d3f5550df0d1e19e798086" - integrity sha512-i7YhvPgVqRKfoQ66toiZ06jPNA3p6ierpfUuEWxNF+fV27Uv5gxBkf8KZLHUCc1nFA9j6+80pYoIpqCeyW3/bA== - dependencies: - "@babel/helper-annotate-as-pure" "^7.16.0" - "@babel/helper-module-imports" "^7.16.0" - babel-plugin-syntax-jsx "^6.18.0" - lodash "^4.17.11" - picomatch "^2.3.0" - -babel-plugin-syntax-jsx@^6.18.0: - version "6.18.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946" - -babel-preset-current-node-syntax@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.2.0.tgz#20730d6cdc7dda5d89401cab10ac6a32067acde6" - integrity sha512-E/VlAEzRrsLEb2+dv8yp3bo4scof3l9nR4lrld+Iy5NyVqgVYUJnDAmunkhPMisRI32Qc4iRiz425d8vM++2fg== - dependencies: - "@babel/plugin-syntax-async-generators" "^7.8.4" - "@babel/plugin-syntax-bigint" "^7.8.3" - "@babel/plugin-syntax-class-properties" "^7.12.13" - "@babel/plugin-syntax-class-static-block" "^7.14.5" - "@babel/plugin-syntax-import-attributes" "^7.24.7" - "@babel/plugin-syntax-import-meta" "^7.10.4" - "@babel/plugin-syntax-json-strings" "^7.8.3" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - "@babel/plugin-syntax-private-property-in-object" "^7.14.5" - "@babel/plugin-syntax-top-level-await" "^7.14.5" - -babel-preset-jest@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-28.1.3.tgz#5dfc20b99abed5db994406c2b9ab94c73aaa419d" - integrity sha512-L+fupJvlWAHbQfn74coNX3zf60LXMJsezNvvx8eIh7iOR1luJ1poxYgQk1F8PYtNq/6QODDHCqsSnTFSWC491A== - dependencies: - babel-plugin-jest-hoist "^28.1.3" - babel-preset-current-node-syntax "^1.0.0" - -babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -baseline-browser-mapping@^2.8.25, baseline-browser-mapping@^2.9.0: - version "2.9.19" - resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.9.19.tgz#3e508c43c46d961eb4d7d2e5b8d1dd0f9ee4f488" - integrity sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg== - -batch@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" - integrity sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw== - -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - -binary-extensions@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" - integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== - -body-parser@~1.20.3: - version "1.20.4" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.4.tgz#f8e20f4d06ca8a50a71ed329c15dccad1cdc547f" - integrity sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA== - dependencies: - bytes "~3.1.2" - content-type "~1.0.5" - debug "2.6.9" - depd "2.0.0" - destroy "~1.2.0" - http-errors "~2.0.1" - iconv-lite "~0.4.24" - on-finished "~2.4.1" - qs "~6.14.0" - raw-body "~2.5.3" - type-is "~1.6.18" - unpipe "~1.0.0" - -bonjour-service@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.3.0.tgz#80d867430b5a0da64e82a8047fc1e355bdb71722" - integrity sha512-3YuAUiSkWykd+2Azjgyxei8OWf8thdn8AITIog2M4UICzoqfjlqr64WIjEXZllf/W6vK1goqleSR6brGomxQqA== - dependencies: - fast-deep-equal "^3.1.3" - multicast-dns "^7.2.5" - -boring-avatars@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/boring-avatars/-/boring-avatars-1.7.0.tgz#70ac7146bbf37d8e69a35544b24f1d75558f868a" - integrity sha512-ZNHd8J7C/V0IjQMGQowLJ5rScEFU23WxePigH6rqKcT2Esf0qhYvYxw8s9i3srmlfCnCV00ddBjaoGey1eNOfA== - -brace-expansion@^1.1.7: - version "1.1.12" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.12.tgz#ab9b454466e5a8cc3a187beaad580412a9c5b843" - integrity sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^3.0.3, braces@~3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" - integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== - dependencies: - fill-range "^7.1.1" - -browserslist@^4.20.2, browserslist@^4.20.3, browserslist@^4.24.0, browserslist@^4.26.0, browserslist@^4.27.0: - version "4.28.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.28.0.tgz#9cefece0a386a17a3cd3d22ebf67b9deca1b5929" - integrity sha512-tbydkR/CxfMwelN0vwdP/pLkDwyAASZ+VfWm4EOwlB6SWhx1sYnWLqo8N5j0rAzPfzfRaxt0mM/4wPU/Su84RQ== - dependencies: - baseline-browser-mapping "^2.8.25" - caniuse-lite "^1.0.30001754" - electron-to-chromium "^1.5.249" - node-releases "^2.0.27" - update-browserslist-db "^1.1.4" - -browserslist@^4.28.1: - version "4.28.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.28.1.tgz#7f534594628c53c63101079e27e40de490456a95" - integrity sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA== - dependencies: - baseline-browser-mapping "^2.9.0" - caniuse-lite "^1.0.30001759" - electron-to-chromium "^1.5.263" - node-releases "^2.0.27" - update-browserslist-db "^1.2.0" - -browserslist@^4.8.5: - version "4.21.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.0.tgz#7ab19572361a140ecd1e023e2c1ed95edda0cefe" - integrity sha512-UQxE0DIhRB5z/zDz9iA03BOfxaN2+GQdBYH/2WrSIWEUrnpzTPJbhqt+umq6r3acaPRTW1FNTkrcp0PXgtFkvA== - dependencies: - caniuse-lite "^1.0.30001358" - electron-to-chromium "^1.4.164" - node-releases "^2.0.5" - update-browserslist-db "^1.0.0" - -bs-logger@0.x: - version "0.2.6" - resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" - integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== - dependencies: - fast-json-stable-stringify "2.x" - -bser@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" - integrity sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ== - dependencies: - node-int64 "^0.4.0" - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -bundle-name@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-4.1.0.tgz#f3b96b34160d6431a19d7688135af7cfb8797889" - integrity sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q== - dependencies: - run-applescript "^7.0.0" - -bytes@3.1.2, bytes@^3.0.0, bytes@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" - integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== - -bytestreamjs@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/bytestreamjs/-/bytestreamjs-2.0.1.tgz#a32947c7ce389a6fa11a09a9a563d0a45889535e" - integrity sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ== - -call-bind-apply-helpers@^1.0.0, call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz#4b5428c222be985d79c3d82657479dbe0b59b2d6" - integrity sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ== - dependencies: - es-errors "^1.3.0" - function-bind "^1.1.2" - -call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - -call-bind@^1.0.7, call-bind@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.8.tgz#0736a9660f537e3388826f440d5ec45f744eaa4c" - integrity sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww== - dependencies: - call-bind-apply-helpers "^1.0.0" - es-define-property "^1.0.0" - get-intrinsic "^1.2.4" - set-function-length "^1.2.2" - -call-bound@^1.0.2, call-bound@^1.0.3, call-bound@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/call-bound/-/call-bound-1.0.4.tgz#238de935d2a2a692928c538c7ccfa91067fd062a" - integrity sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg== - dependencies: - call-bind-apply-helpers "^1.0.2" - get-intrinsic "^1.3.0" - -callsites@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" - integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== - -camelcase-css@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" - integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== - -camelcase@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" - integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== - -camelcase@^6.2.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" - integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== - -camelize@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.1.tgz#89b7e16884056331a35d6b5ad064332c91daa6c3" - integrity sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ== - -caniuse-lite@^1.0.30001335, caniuse-lite@^1.0.30001358: - version "1.0.30001757" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001757.tgz#a46ff91449c69522a462996c6aac4ef95d7ccc5e" - integrity sha512-r0nnL/I28Zi/yjk1el6ilj27tKcdjLsNqAOZr0yVjWPrSQyHgKI2INaEWw21bAQSv2LXRt1XuCS/GomNpWOxsQ== - -caniuse-lite@^1.0.30001754, caniuse-lite@^1.0.30001759: - version "1.0.30001769" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001769.tgz#1ad91594fad7dc233777c2781879ab5409f7d9c2" - integrity sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg== - -chalk@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -char-regex@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" - integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== - -chart.js@^3.8.0: - version "3.8.0" - resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-3.8.0.tgz#c6c14c457b9dc3ce7f1514a59e9b262afd6f1a94" - integrity sha512-cr8xhrXjLIXVLOBZPkBZVF6NDeiVIrPLHcMhnON7UufudL+CNeRrD+wpYanswlm8NpudMdrt3CHoLMQMxJhHRg== - -chokidar@^3.5.2, chokidar@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" - integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -chrome-trace-event@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz#05bffd7ff928465093314708c93bdfa9bd1f0f5b" - integrity sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ== - -ci-info@^3.2.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" - integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== - -cjs-module-lexer@^1.0.0: - version "1.4.3" - resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.4.3.tgz#0f79731eb8cfe1ec72acd4066efac9d61991b00d" - integrity sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q== - -classnames@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.1.tgz#dfcfa3891e306ec1dad105d0e88f4417b8535e8e" - integrity sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA== - -clean-set@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/clean-set/-/clean-set-1.1.2.tgz#76d8bf238c3e27827bfa73073ecdfdc767187070" - integrity sha512-cA8uCj0qSoG9e0kevyOWXwPaELRPVg5Pxp6WskLMwerx257Zfnh8Nl0JBH59d7wQzij2CK7qEfJQK3RjuKKIug== - -cliui@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" - integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.1" - wrap-ansi "^7.0.0" - -clone-deep@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" - integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== - dependencies: - is-plain-object "^2.0.4" - kind-of "^6.0.2" - shallow-clone "^3.0.0" - -co@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" - integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== - -codemirror@^5.57.0: - version "5.57.0" - resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.57.0.tgz#d26365b72f909f5d2dbb6b1209349ca1daeb2d50" - integrity sha512-WGc6UL7Hqt+8a6ZAsj/f1ApQl3NPvHY/UQSzG6fB6l4BjExgVdhFaxd7mRTw1UCiYe/6q86zHP+kfvBQcZGvUg== - -collect-v8-coverage@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.3.tgz#cc1f01eb8d02298cbc9a437c74c70ab4e5210b80" - integrity sha512-1L5aqIkwPfiodaMgQunkF1zRhNqifHBmtbbbxcr6yVxxBnliw4TDOW6NxpO8DJLgJ16OT+Y4ztZqP6p/FtXnAw== - -color-convert@^1.9.0, color-convert@^1.9.3: - version "1.9.3" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== - dependencies: - color-name "1.1.3" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== - -color-name@^1.0.0, color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -color-string@^1.6.0, color-string@^1.9.0: - version "1.9.1" - resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4" - integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg== - dependencies: - color-name "^1.0.0" - simple-swizzle "^0.2.2" - -color@^3.1.3: - version "3.2.1" - resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164" - integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA== - dependencies: - color-convert "^1.9.3" - color-string "^1.6.0" - -color@^4.0.1: - version "4.2.3" - resolved "https://registry.yarnpkg.com/color/-/color-4.2.3.tgz#d781ecb5e57224ee43ea9627560107c0e0c6463a" - integrity sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A== - dependencies: - color-convert "^2.0.1" - color-string "^1.9.0" - -colorette@^2.0.10, colorette@^2.0.14: - version "2.0.20" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" - integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^12.1.0: - version "12.1.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" - integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== - -commander@^2.20.0: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" - integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== - -commander@^8.0.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" - integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== - -compressible@~2.0.18: - version "2.0.18" - resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.18.tgz#af53cca6b070d4c3c0750fbd77286a6d7cc46fba" - integrity sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg== - dependencies: - mime-db ">= 1.43.0 < 2" - -compression@^1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/compression/-/compression-1.8.1.tgz#4a45d909ac16509195a9a28bd91094889c180d79" - integrity sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w== - dependencies: - bytes "3.1.2" - compressible "~2.0.18" - debug "2.6.9" - negotiator "~0.6.4" - on-headers "~1.1.0" - safe-buffer "5.2.1" - vary "~1.1.2" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -connect-history-api-fallback@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz#647264845251a0daf25b97ce87834cace0f5f1c8" - integrity sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA== - -content-disposition@~0.5.4: - version "0.5.4" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" - integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== - dependencies: - safe-buffer "5.2.1" - -content-type@~1.0.4, content-type@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" - integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== - -convert-source-map@^1.4.0, convert-source-map@^1.7.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" - integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== - -convert-source-map@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" - integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== - -cookie-signature@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.7.tgz#ab5dd7ab757c54e60f37ef6550f481c426d10454" - integrity sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA== - -cookie@~0.7.1: - version "0.7.2" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.2.tgz#556369c472a2ba910f2979891b526b3436237ed7" - integrity sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w== - -copy-to-clipboard@^3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.3.1.tgz#115aa1a9998ffab6196f93076ad6da3b913662ae" - integrity sha512-i13qo6kIHTTpCm8/Wup+0b1mVWETvu2kIMzKoK8FpkLkFxlt0znUAHcMzox+T8sPlqtZXq3CulEjQHsYiGFJUw== - dependencies: - toggle-selection "^1.0.6" - -core-js-compat@^3.6.2: - version "3.6.5" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.6.5.tgz#2a51d9a4e25dfd6e690251aa81f99e3c05481f1c" - integrity sha512-7ItTKOhOZbznhXAQ2g/slGg1PJV5zDO/WdkTwi7UEOJmkvsE32PWvx6mKtDjiMpjnR2CNf6BAD6sSxIlv7ptng== - dependencies: - browserslist "^4.8.5" - semver "7.0.0" - -core-js@^2.4.0: - version "2.6.11" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c" - integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg== - -core-util-is@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" - integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== - -cosmiconfig@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-6.0.0.tgz#da4fee853c52f6b1e6935f41c1a2fc50bd4a9982" - integrity sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.1.0" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.7.2" - -cosmiconfig@^7.0.1: - version "7.1.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" - integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.2.1" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.10.0" - -cosmiconfig@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.0.tgz#34c3fc58287b915f3ae905ab6dc3de258b55ad9d" - integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg== - dependencies: - env-paths "^2.2.1" - import-fresh "^3.3.0" - js-yaml "^4.1.0" - parse-json "^5.2.0" - -cross-env@^7.0.2: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" - integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== - dependencies: - cross-spawn "^7.0.1" - -cross-fetch@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-4.0.0.tgz#f037aef1580bb3a1a35164ea2a848ba81b445983" - integrity sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g== - dependencies: - node-fetch "^2.6.12" - -cross-spawn@^7.0.1, cross-spawn@^7.0.3: - version "7.0.6" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" - integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -cross-spawn@^7.0.2: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - -css-blank-pseudo@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/css-blank-pseudo/-/css-blank-pseudo-7.0.1.tgz#32020bff20a209a53ad71b8675852b49e8d57e46" - integrity sha512-jf+twWGDf6LDoXDUode+nc7ZlrqfaNphrBIBrcmeP3D8yw1uPaix1gCC8LUQUGQ6CycuK2opkbFFWFuq/a94ag== - dependencies: - postcss-selector-parser "^7.0.0" - -css-color-keywords@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05" - integrity sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg== - -css-color-names@^0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0" - integrity sha512-zj5D7X1U2h2zsXOAM8EyUREBnnts6H+Jm+d1M2DbiQQcUtnqgQsMrdo8JW9R80YFUmIdBZeMu5wvYM7hcgWP/Q== - -css-has-pseudo@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/css-has-pseudo/-/css-has-pseudo-7.0.3.tgz#a5ee2daf5f70a2032f3cefdf1e36e7f52a243873" - integrity sha512-oG+vKuGyqe/xvEMoxAQrhi7uY16deJR3i7wwhBerVrGQKSqUC5GiOVxTpM9F9B9hw0J+eKeOWLH7E9gZ1Dr5rA== - dependencies: - "@csstools/selector-specificity" "^5.0.0" - postcss-selector-parser "^7.0.0" - postcss-value-parser "^4.2.0" - -css-loader@^7.1.2: - version "7.1.2" - resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-7.1.2.tgz#64671541c6efe06b0e22e750503106bdd86880f8" - integrity sha512-6WvYYn7l/XEGN8Xu2vWFt9nVzrCn39vKyTEFf/ExEyoksJjjSZV/0/35XPlMbpnr6VGhZIUg5yJrL8tGfes/FA== - dependencies: - icss-utils "^5.1.0" - postcss "^8.4.33" - postcss-modules-extract-imports "^3.1.0" - postcss-modules-local-by-default "^4.0.5" - postcss-modules-scope "^3.2.0" - postcss-modules-values "^4.0.0" - postcss-value-parser "^4.2.0" - semver "^7.5.4" - -css-prefers-color-scheme@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/css-prefers-color-scheme/-/css-prefers-color-scheme-10.0.0.tgz#ba001b99b8105b8896ca26fc38309ddb2278bd3c" - integrity sha512-VCtXZAWivRglTZditUfB4StnsWr6YVZ2PRtuxQLKTNRdtAf8tpzaVPE9zXIF3VaSc7O70iK/j1+NXxyQCqdPjQ== - -css-to-react-native@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-3.2.0.tgz#cdd8099f71024e149e4f6fe17a7d46ecd55f1e32" - integrity sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ== - dependencies: - camelize "^1.0.0" - css-color-keywords "^1.0.0" - postcss-value-parser "^4.0.2" - -css-unit-converter@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/css-unit-converter/-/css-unit-converter-1.1.2.tgz#4c77f5a1954e6dbff60695ecb214e3270436ab21" - integrity sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA== - -css.escape@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb" - integrity sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg== - -css@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/css/-/css-3.0.0.tgz#4447a4d58fdd03367c516ca9f64ae365cee4aa5d" - integrity sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ== - dependencies: - inherits "^2.0.4" - source-map "^0.6.1" - source-map-resolve "^0.6.0" - -cssdb@^8.4.2: - version "8.4.2" - resolved "https://registry.yarnpkg.com/cssdb/-/cssdb-8.4.2.tgz#1a367ab1904c97af0bb2c7ae179764deae7b078b" - integrity sha512-PzjkRkRUS+IHDJohtxkIczlxPPZqRo0nXplsYXOMBRPjcVRjj1W4DfvRgshUYTVuUigU7ptVYkFJQ7abUB0nyg== - -cssesc@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" - integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== - -csstype@^2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.7.tgz#20b0024c20b6718f4eda3853a1f5a1cce7f5e4a5" - -csstype@^3.0.2: - version "3.0.5" - resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.5.tgz#7fdec6a28a67ae18647c51668a9ff95bb2fa7bb8" - integrity sha512-uVDi8LpBUKQj6sdxNaTetL6FpeCqTjOvAQuQUa/qAqq8oOd4ivkbhgnqayl0dnPal8Tb/yB1tF+gOvCBiicaiQ== - -data-view-buffer@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/data-view-buffer/-/data-view-buffer-1.0.2.tgz#211a03ba95ecaf7798a8c7198d79536211f88570" - integrity sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ== - dependencies: - call-bound "^1.0.3" - es-errors "^1.3.0" - is-data-view "^1.0.2" - -data-view-byte-length@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz#9e80f7ca52453ce3e93d25a35318767ea7704735" - integrity sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ== - dependencies: - call-bound "^1.0.3" - es-errors "^1.3.0" - is-data-view "^1.0.2" - -data-view-byte-offset@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz#068307f9b71ab76dbbe10291389e020856606191" - integrity sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ== - dependencies: - call-bound "^1.0.2" - es-errors "^1.3.0" - is-data-view "^1.0.1" - -date-fns@^2.28.0: - version "2.28.0" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2" - integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw== - -debounce@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131" - integrity sha512-mYtLl1xfZLi1m4RtQYlZgJUNQjl4ZxVnHzIR8nLLgi4q1YT8o/WM+MK/f8yfcc9s5Ir5zRaPZyZU6xs1Syoocg== - -debug@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - dependencies: - ms "2.0.0" - -debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: - version "4.4.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a" - integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA== - dependencies: - ms "^2.1.3" - -debug@^4.3.2, debug@^4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -decode-uri-component@^0.2.0: - version "0.2.2" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" - integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== - -dedent@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" - integrity sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA== - -deep-is@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= - -deepmerge-ts@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/deepmerge-ts/-/deepmerge-ts-4.2.1.tgz#104fe27c91abde4597bad1dcfd00a7a8be22d532" - integrity sha512-xzJLiUo4z1dD2nggSfaMvHo5qWLoy/JVa9rKuktC6FrQQEBI8Qnj7KwuCYZhqBoGOOpGqs6+3MR2ZhSMcTr4BA== - -deepmerge@^2.1.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170" - integrity sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA== - -deepmerge@^4.2.2, deepmerge@^4.3.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" - integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== - -default-browser-id@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/default-browser-id/-/default-browser-id-5.0.1.tgz#f7a7ccb8f5104bf8e0f71ba3b1ccfa5eafdb21e8" - integrity sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q== - -default-browser@^5.2.1: - version "5.5.0" - resolved "https://registry.yarnpkg.com/default-browser/-/default-browser-5.5.0.tgz#2792e886f2422894545947cc80e1a444496c5976" - integrity sha512-H9LMLr5zwIbSxrmvikGuI/5KGhZ8E2zH3stkMgM5LpOWDutGM2JZaj460Udnf1a+946zc7YBgrqEWwbk7zHvGw== - dependencies: - bundle-name "^4.1.0" - default-browser-id "^5.0.0" - -define-data-property@^1.0.1, define-data-property@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" - integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== - dependencies: - es-define-property "^1.0.0" - es-errors "^1.3.0" - gopd "^1.0.1" - -define-lazy-prop@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" - integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== - -define-properties@^1.1.3, define-properties@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1" - integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA== - dependencies: - has-property-descriptors "^1.0.0" - object-keys "^1.1.1" - -define-properties@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.1.tgz#10781cc616eb951a80a034bafcaa7377f6af2b6c" - integrity sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg== - dependencies: - define-data-property "^1.0.1" - has-property-descriptors "^1.0.0" - object-keys "^1.1.1" - -defined@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.1.tgz#c0b9db27bfaffd95d6f61399419b893df0f91ebf" - integrity sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -depd@2.0.0, depd@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" - integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== - -destroy@1.2.0, destroy@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" - integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== - -detect-newline@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" - integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== - -detect-node@^2.0.4: - version "2.1.0" - resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" - integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== - -detective@^5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.1.tgz#6af01eeda11015acb0e73f933242b70f24f91034" - integrity sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw== - dependencies: - acorn-node "^1.8.2" - defined "^1.0.0" - minimist "^1.2.6" - -didyoumean@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037" - integrity sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw== - -diff-sequences@^28.1.1: - version "28.1.1" - resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-28.1.1.tgz#9989dc731266dc2903457a70e996f3a041913ac6" - integrity sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw== - -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - -dlv@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/dlv/-/dlv-1.1.3.tgz#5c198a8a11453596e751494d49874bc7732f2e79" - integrity sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA== - -dns-packet@^5.2.2: - version "5.6.1" - resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.6.1.tgz#ae888ad425a9d1478a0674256ab866de1012cf2f" - integrity sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw== - dependencies: - "@leichtgewicht/ip-codec" "^2.0.1" - -doctrine@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" - integrity sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw== - dependencies: - esutils "^2.0.2" - -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - dependencies: - esutils "^2.0.2" - -dom-accessibility-api@^0.5.6, dom-accessibility-api@^0.5.9: - version "0.5.14" - resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.14.tgz#56082f71b1dc7aac69d83c4285eef39c15d93f56" - integrity sha512-NMt+m9zFMPZe0JcY9gN224Qvk6qLIdqex29clBvc/y75ZBX9YA9wNK3frsYvu2DI1xcCIwxwnX+TlsJ2DSOADg== - -dom-helpers@^5.0.1: - version "5.1.3" - resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-5.1.3.tgz#7233248eb3a2d1f74aafca31e52c5299cc8ce821" - dependencies: - "@babel/runtime" "^7.6.3" - csstype "^2.6.7" - -dom-walk@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" - integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== - -dset@^2.0.1: - version "2.1.0" - resolved "https://registry.yarnpkg.com/dset/-/dset-2.1.0.tgz#cd1e99e55cf32366d8f144f906c42f7fb3bf431e" - integrity sha512-hlQYwNEdW7Qf8zxysy+yN1E8C/SxRst3Z9n+IvXOR35D9bPVwNHhnL8ZBeoZjvinuGrlvGg6pAMDwhmjqFDgjA== - -dunder-proto@^1.0.0, dunder-proto@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" - integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== - dependencies: - call-bind-apply-helpers "^1.0.1" - es-errors "^1.3.0" - gopd "^1.2.0" - -easy-peasy@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/easy-peasy/-/easy-peasy-4.0.2.tgz#653662216276d0f27d91c7ce82a26ace4526da12" - integrity sha512-U68qh0GneNCeHkuyk4JScuuSJLb3xdhZhANV5Kyam7paxuz28sO8pVXaCDjHO+wcBUSB9ApmNFJUN3BqmwF4oQ== - dependencies: - immer "^9.0.6" - is-plain-object "^5.0.0" - memoizerific "^1.11.3" - redux "^4.0.5" - redux-thunk "^2.3.0" - symbol-observable "^2.0.3" - ts-toolbelt "^8.0.7" - use-memo-one "^1.1.1" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== - -electron-to-chromium@^1.4.164: - version "1.5.260" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.260.tgz#73f555d3e9b9fd16ff48fc406bbad84efa9b86c7" - integrity sha512-ov8rBoOBhVawpzdre+Cmz4FB+y66Eqrk6Gwqd8NGxuhv99GQ8XqMAr351KEkOt7gukXWDg6gJWEMKgL2RLMPtA== - -electron-to-chromium@^1.5.249, electron-to-chromium@^1.5.263: - version "1.5.286" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.286.tgz#142be1ab5e1cd5044954db0e5898f60a4960384e" - integrity sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A== - -emittery@^0.10.2: - version "0.10.2" - resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.10.2.tgz#902eec8aedb8c41938c46e9385e9db7e03182933" - integrity sha512-aITqOwnLanpHLNXZJENbOgjUBeHocD+xsSJmNrjovKBW5HbSpW3d1pEls7GFQPUWXiwG9+0P4GtHfEqC/4M0Iw== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - -encodeurl@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-2.0.0.tgz#7b8ea898077d7e409d3ac45474ea38eaf0857a58" - integrity sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg== - -enhanced-resolve@^5.19.0: - version "5.19.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.19.0.tgz#6687446a15e969eaa63c2fa2694510e17ae6d97c" - integrity sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg== - dependencies: - graceful-fs "^4.2.4" - tapable "^2.3.0" - -env-paths@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" - integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== - -envinfo@^7.14.0: - version "7.20.0" - resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.20.0.tgz#3fd9de69fb6af3e777a017dfa033676368d67dd7" - integrity sha512-+zUomDcLXsVkQ37vUqWBvQwLaLlj8eZPSi61llaEFAVBY5mhcXdaSw1pSJVl4yTYD5g/gEfpNl28YYk4IPvrrg== - -error-ex@^1.3.1: - version "1.3.4" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.4.tgz#b3a8d8bb6f92eecc1629e3e27d3c8607a8a32414" - integrity sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ== - dependencies: - is-arrayish "^0.2.1" - -es-abstract@^1.17.5, es-abstract@^1.23.2, es-abstract@^1.23.3, es-abstract@^1.23.5, es-abstract@^1.23.6, es-abstract@^1.23.9, es-abstract@^1.24.0: - version "1.24.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.24.0.tgz#c44732d2beb0acc1ed60df840869e3106e7af328" - integrity sha512-WSzPgsdLtTcQwm4CROfS5ju2Wa1QQcVeT37jFjYzdFz1r9ahadC8B8/a4qxJxM+09F18iumCdRmlr96ZYkQvEg== - dependencies: - array-buffer-byte-length "^1.0.2" - arraybuffer.prototype.slice "^1.0.4" - available-typed-arrays "^1.0.7" - call-bind "^1.0.8" - call-bound "^1.0.4" - data-view-buffer "^1.0.2" - data-view-byte-length "^1.0.2" - data-view-byte-offset "^1.0.1" - es-define-property "^1.0.1" - es-errors "^1.3.0" - es-object-atoms "^1.1.1" - es-set-tostringtag "^2.1.0" - es-to-primitive "^1.3.0" - function.prototype.name "^1.1.8" - get-intrinsic "^1.3.0" - get-proto "^1.0.1" - get-symbol-description "^1.1.0" - globalthis "^1.0.4" - gopd "^1.2.0" - has-property-descriptors "^1.0.2" - has-proto "^1.2.0" - has-symbols "^1.1.0" - hasown "^2.0.2" - internal-slot "^1.1.0" - is-array-buffer "^3.0.5" - is-callable "^1.2.7" - is-data-view "^1.0.2" - is-negative-zero "^2.0.3" - is-regex "^1.2.1" - is-set "^2.0.3" - is-shared-array-buffer "^1.0.4" - is-string "^1.1.1" - is-typed-array "^1.1.15" - is-weakref "^1.1.1" - math-intrinsics "^1.1.0" - object-inspect "^1.13.4" - object-keys "^1.1.1" - object.assign "^4.1.7" - own-keys "^1.0.1" - regexp.prototype.flags "^1.5.4" - safe-array-concat "^1.1.3" - safe-push-apply "^1.0.0" - safe-regex-test "^1.1.0" - set-proto "^1.0.0" - stop-iteration-iterator "^1.1.0" - string.prototype.trim "^1.2.10" - string.prototype.trimend "^1.0.9" - string.prototype.trimstart "^1.0.8" - typed-array-buffer "^1.0.3" - typed-array-byte-length "^1.0.3" - typed-array-byte-offset "^1.0.4" - typed-array-length "^1.0.7" - unbox-primitive "^1.1.0" - which-typed-array "^1.1.19" - -es-abstract@^1.19.0, es-abstract@^1.19.5: - version "1.20.1" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.1.tgz#027292cd6ef44bd12b1913b828116f54787d1814" - integrity sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA== - dependencies: - call-bind "^1.0.2" - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - function.prototype.name "^1.1.5" - get-intrinsic "^1.1.1" - get-symbol-description "^1.0.0" - has "^1.0.3" - has-property-descriptors "^1.0.0" - has-symbols "^1.0.3" - internal-slot "^1.0.3" - is-callable "^1.2.4" - is-negative-zero "^2.0.2" - is-regex "^1.1.4" - is-shared-array-buffer "^1.0.2" - is-string "^1.0.7" - is-weakref "^1.0.2" - object-inspect "^1.12.0" - object-keys "^1.1.1" - object.assign "^4.1.2" - regexp.prototype.flags "^1.4.3" - string.prototype.trimend "^1.0.5" - string.prototype.trimstart "^1.0.5" - unbox-primitive "^1.0.2" - -es-define-property@^1.0.0, es-define-property@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.1.tgz#983eb2f9a6724e9303f61addf011c72e09e0b0fa" - integrity sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g== - -es-errors@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" - integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== - -es-iterator-helpers@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-iterator-helpers/-/es-iterator-helpers-1.2.1.tgz#d1dd0f58129054c0ad922e6a9a1e65eef435fe75" - integrity sha512-uDn+FE1yrDzyC0pCo961B2IHbdM8y/ACZsKD4dG6WqrjV53BADjwa7D+1aom2rsNVfLyDgU/eigvlJGJ08OQ4w== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.3" - define-properties "^1.2.1" - es-abstract "^1.23.6" - es-errors "^1.3.0" - es-set-tostringtag "^2.0.3" - function-bind "^1.1.2" - get-intrinsic "^1.2.6" - globalthis "^1.0.4" - gopd "^1.2.0" - has-property-descriptors "^1.0.2" - has-proto "^1.2.0" - has-symbols "^1.1.0" - internal-slot "^1.1.0" - iterator.prototype "^1.1.4" - safe-array-concat "^1.1.3" - -es-module-lexer@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-2.0.0.tgz#f657cd7a9448dcdda9c070a3cb75e5dc1e85f5b1" - integrity sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw== - -es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz#1c4f2c4837327597ce69d2ca190a7fdd172338c1" - integrity sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA== - dependencies: - es-errors "^1.3.0" - -es-set-tostringtag@^2.0.3, es-set-tostringtag@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz#f31dbbe0c183b00a6d26eb6325c810c0fd18bd4d" - integrity sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA== - dependencies: - es-errors "^1.3.0" - get-intrinsic "^1.2.6" - has-tostringtag "^1.0.2" - hasown "^2.0.2" - -es-shim-unscopables@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/es-shim-unscopables/-/es-shim-unscopables-1.1.0.tgz#438df35520dac5d105f3943d927549ea3b00f4b5" - integrity sha512-d9T8ucsEhh8Bi1woXCf+TIKDIROLG5WCkxg8geBCbvk22kzwC5G2OnXVMO6FUsvQlgUUXQ2itephWDLqDzbeCw== - dependencies: - hasown "^2.0.2" - -es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" - -es-to-primitive@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.3.0.tgz#96c89c82cc49fd8794a24835ba3e1ff87f214e18" - integrity sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g== - dependencies: - is-callable "^1.2.7" - is-date-object "^1.0.5" - is-symbol "^1.0.4" - -escalade@^3.1.1, escalade@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" - integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== - -escape-string-regexp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" - integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== - -escape-string-regexp@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" - integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== - -eslint-config-prettier@^8: - version "8.10.2" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.10.2.tgz#0642e53625ebc62c31c24726b0f050df6bd97a2e" - integrity sha512-/IGJ6+Dka158JnP5n5YFMOszjDWrXggGz1LaK/guZq9vZTmniaKlHcsscvkAhn9y4U+BU3JuUdYvtAMcv30y4A== - -eslint-plugin-jest-dom@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest-dom/-/eslint-plugin-jest-dom-4.0.2.tgz#9d3e2f51055f74c74e745d89c4b1a9781e0ec7a9" - integrity sha512-Jo51Atwyo2TdcUncjmU+UQeSTKh3sc2LF/M5i/R3nTU0Djw9V65KGJisdm/RtuKhy2KH/r7eQ1n6kwYFPNdHlA== - dependencies: - "@babel/runtime" "^7.16.3" - "@testing-library/dom" "^8.11.1" - requireindex "^1.2.0" - -eslint-plugin-prettier@^4: - version "4.2.5" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.5.tgz#91ca3f2f01a84f1272cce04e9717550494c0fe06" - integrity sha512-9Ni+xgemM2IWLq6aXEpP2+V/V30GeA/46Ar629vcMqVPodFFWC9skHu/D1phvuqtS8bJCFnNf01/qcmqYEwNfg== - dependencies: - prettier-linter-helpers "^1.0.0" - -eslint-plugin-react-hooks@^4: - version "4.6.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz#c829eb06c0e6f484b3fbb85a97e57784f328c596" - integrity sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ== - -eslint-plugin-react@^7: - version "7.37.5" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.37.5.tgz#2975511472bdda1b272b34d779335c9b0e877065" - integrity sha512-Qteup0SqU15kdocexFNAJMvCJEfa2xUKNV4CC1xsVMrIIqEy3SQ/rqyxCWNzfrd3/ldy6HMlD2e0JDVpDg2qIA== - dependencies: - array-includes "^3.1.8" - array.prototype.findlast "^1.2.5" - array.prototype.flatmap "^1.3.3" - array.prototype.tosorted "^1.1.4" - doctrine "^2.1.0" - es-iterator-helpers "^1.2.1" - estraverse "^5.3.0" - hasown "^2.0.2" - jsx-ast-utils "^2.4.1 || ^3.0.0" - minimatch "^3.1.2" - object.entries "^1.1.9" - object.fromentries "^2.0.8" - object.values "^1.2.1" - prop-types "^15.8.1" - resolve "^2.0.0-next.5" - semver "^6.3.1" - string.prototype.matchall "^4.0.12" - string.prototype.repeat "^1.0.0" - -eslint-scope@5.1.1, eslint-scope@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" - integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== - dependencies: - esrecurse "^4.3.0" - estraverse "^4.1.1" - -eslint-scope@^7.2.2: - version "7.2.2" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" - integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== - dependencies: - esrecurse "^4.3.0" - estraverse "^5.2.0" - -eslint-visitor-keys@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" - integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== - -eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3: - version "3.4.3" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" - integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== - -eslint@^8: - version "8.57.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.1.tgz#7df109654aba7e3bbe5c8eae533c5e461d3c6ca9" - integrity sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA== - dependencies: - "@eslint-community/eslint-utils" "^4.2.0" - "@eslint-community/regexpp" "^4.6.1" - "@eslint/eslintrc" "^2.1.4" - "@eslint/js" "8.57.1" - "@humanwhocodes/config-array" "^0.13.0" - "@humanwhocodes/module-importer" "^1.0.1" - "@nodelib/fs.walk" "^1.2.8" - "@ungap/structured-clone" "^1.2.0" - ajv "^6.12.4" - chalk "^4.0.0" - cross-spawn "^7.0.2" - debug "^4.3.2" - doctrine "^3.0.0" - escape-string-regexp "^4.0.0" - eslint-scope "^7.2.2" - eslint-visitor-keys "^3.4.3" - espree "^9.6.1" - esquery "^1.4.2" - esutils "^2.0.2" - fast-deep-equal "^3.1.3" - file-entry-cache "^6.0.1" - find-up "^5.0.0" - glob-parent "^6.0.2" - globals "^13.19.0" - graphemer "^1.4.0" - ignore "^5.2.0" - imurmurhash "^0.1.4" - is-glob "^4.0.0" - is-path-inside "^3.0.3" - js-yaml "^4.1.0" - json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.4.1" - lodash.merge "^4.6.2" - minimatch "^3.1.2" - natural-compare "^1.4.0" - optionator "^0.9.3" - strip-ansi "^6.0.1" - text-table "^0.2.0" - -espree@^9.6.0, espree@^9.6.1: - version "9.6.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" - integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== - dependencies: - acorn "^8.9.0" - acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.4.1" - -esprima@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - -esquery@^1.4.2: - version "1.6.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" - integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== - dependencies: - estraverse "^5.1.0" - -esrecurse@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" - integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== - dependencies: - estraverse "^5.2.0" - -estraverse@^4.1.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" - integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== - -estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" - integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== - -esutils@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - -etag@~1.8.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" - integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== - -eventemitter3@^4.0.0: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -events@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.0.0.tgz#9a0a0dfaf62893d92b875b8f2698ca4114973e88" - -events@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" - integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== - -execa@^5.0.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" - integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== - dependencies: - cross-spawn "^7.0.3" - get-stream "^6.0.0" - human-signals "^2.1.0" - is-stream "^2.0.0" - merge-stream "^2.0.0" - npm-run-path "^4.0.1" - onetime "^5.1.2" - signal-exit "^3.0.3" - strip-final-newline "^2.0.0" - -exit@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" - integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ== - -expect@^28.0.0, expect@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/expect/-/expect-28.1.3.tgz#90a7c1a124f1824133dd4533cce2d2bdcb6603ec" - integrity sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g== - dependencies: - "@jest/expect-utils" "^28.1.3" - jest-get-type "^28.0.2" - jest-matcher-utils "^28.1.3" - jest-message-util "^28.1.3" - jest-util "^28.1.3" - -express@^4.22.1: - version "4.22.1" - resolved "https://registry.yarnpkg.com/express/-/express-4.22.1.tgz#1de23a09745a4fffdb39247b344bb5eaff382069" - integrity sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g== - dependencies: - accepts "~1.3.8" - array-flatten "1.1.1" - body-parser "~1.20.3" - content-disposition "~0.5.4" - content-type "~1.0.4" - cookie "~0.7.1" - cookie-signature "~1.0.6" - debug "2.6.9" - depd "2.0.0" - encodeurl "~2.0.0" - escape-html "~1.0.3" - etag "~1.8.1" - finalhandler "~1.3.1" - fresh "~0.5.2" - http-errors "~2.0.0" - merge-descriptors "1.0.3" - methods "~1.1.2" - on-finished "~2.4.1" - parseurl "~1.3.3" - path-to-regexp "~0.1.12" - proxy-addr "~2.0.7" - qs "~6.14.0" - range-parser "~1.2.1" - safe-buffer "5.2.1" - send "~0.19.0" - serve-static "~1.16.2" - setprototypeof "1.2.0" - statuses "~2.0.1" - type-is "~1.6.18" - utils-merge "1.0.1" - vary "~1.1.2" - -fast-deep-equal@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" - -fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-diff@^1.1.2: - version "1.2.0" - resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" - integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== - -fast-glob@^3.2.7, fast-glob@^3.3.2: - version "3.3.3" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.3.tgz#d06d585ce8dba90a16b0505c543c3ccfb3aeb818" - integrity sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.8" - -fast-glob@^3.2.9: - version "3.2.11" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" - integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - -fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fast-levenshtein@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== - -fast-uri@^3.0.1: - version "3.1.0" - resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.1.0.tgz#66eecff6c764c0df9b762e62ca7edcfb53b4edfa" - integrity sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA== - -fastest-levenshtein@^1.0.12: - version "1.0.16" - resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5" - integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== - -fastq@^1.6.0: - version "1.19.1" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.19.1.tgz#d50eaba803c8846a883c16492821ebcd2cda55f5" - integrity sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ== - dependencies: - reusify "^1.0.4" - -faye-websocket@^0.11.3: - version "0.11.4" - resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da" - integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== - dependencies: - websocket-driver ">=0.5.1" - -fb-watchman@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" - integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== - dependencies: - bser "2.1.1" - -fdir@^6.5.0: - version "6.5.0" - resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.5.0.tgz#ed2ab967a331ade62f18d077dae192684d50d350" - integrity sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg== - -file-entry-cache@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" - integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== - dependencies: - flat-cache "^3.0.4" - -file-loader@~6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.2.0.tgz#baef7cf8e1840df325e4390b4484879480eebe4d" - integrity sha512-qo3glqyTa61Ytg4u73GultjHGjdRyig3tG6lPtyX/jOEJvHif9uB0/OCI2Kif6ctF3caQTW2G5gym21oAsI4pw== - dependencies: - loader-utils "^2.0.0" - schema-utils "^3.0.0" - -fill-range@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" - integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== - dependencies: - to-regex-range "^5.0.1" - -finalhandler@~1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.3.2.tgz#1ebc2228fc7673aac4a472c310cc05b77d852b88" - integrity sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg== - dependencies: - debug "2.6.9" - encodeurl "~2.0.0" - escape-html "~1.0.3" - on-finished "~2.4.1" - parseurl "~1.3.3" - statuses "~2.0.2" - unpipe "~1.0.0" - -find-up@^4.0.0, find-up@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" - integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== - dependencies: - locate-path "^5.0.0" - path-exists "^4.0.0" - -find-up@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" - integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== - dependencies: - locate-path "^6.0.0" - path-exists "^4.0.0" - -flat-cache@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" - integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== - dependencies: - flatted "^3.1.0" - rimraf "^3.0.2" - -flat@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" - integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== - -flatted@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469" - integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== - -fn-name@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-3.0.0.tgz#0596707f635929634d791f452309ab41558e3c5c" - integrity sha512-eNMNr5exLoavuAMhIUVsOKF79SWd/zG104ef6sxBTSw+cZc6BXdQXDvYcGvp0VbxVVSp1XDUNoz7mg1xMtSznA== - -follow-redirects@^1.0.0, follow-redirects@^1.15.11: - version "1.15.11" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.11.tgz#777d73d72a92f8ec4d2e410eb47352a56b8e8340" - integrity sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ== - -for-each@^0.3.3, for-each@^0.3.5: - version "0.3.5" - resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.5.tgz#d650688027826920feeb0af747ee7b9421a41d47" - integrity sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg== - dependencies: - is-callable "^1.2.7" - -form-data@^4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.5.tgz#b49e48858045ff4cbf6b03e1805cebcad3679053" - integrity sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - es-set-tostringtag "^2.1.0" - hasown "^2.0.2" - mime-types "^2.1.12" - -formik@^2.2.6: - version "2.4.9" - resolved "https://registry.yarnpkg.com/formik/-/formik-2.4.9.tgz#7e5b81e9c9e215d0ce2ac8fed808cf7fba0cd204" - integrity sha512-5nI94BMnlFDdQRBY4Sz39WkhxajZJ57Fzs8wVbtsQlm5ScKIR1QLYqv/ultBnobObtlUyxpxoLodpixrsf36Og== - dependencies: - "@types/hoist-non-react-statics" "^3.3.1" - deepmerge "^2.1.1" - hoist-non-react-statics "^3.3.0" - lodash "^4.17.21" - lodash-es "^4.17.21" - react-fast-compare "^2.0.1" - tiny-warning "^1.0.2" - tslib "^2.0.0" - -forwarded@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" - integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== - -fraction.js@^4.2.0: - version "4.3.7" - resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7" - integrity sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew== - -fraction.js@^5.3.4: - version "5.3.4" - resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-5.3.4.tgz#8c0fcc6a9908262df4ed197427bdeef563e0699a" - integrity sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ== - -framer-motion@^6.3.10: - version "6.3.10" - resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-6.3.10.tgz#e71f8c4ee09612de8328725c4fb1a1c204ae451f" - integrity sha512-modFplFb1Fznsm0MrmRAJUC32UDA5jbGU9rDvkGzhAHksru2tnoKbU/Pa3orzdsJI0CJviG4NGBrmwGveU98Cg== - dependencies: - framesync "6.0.1" - hey-listen "^1.0.8" - popmotion "11.0.3" - style-value-types "5.0.0" - tslib "^2.1.0" - optionalDependencies: - "@emotion/is-prop-valid" "^0.8.2" - -framesync@6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/framesync/-/framesync-6.0.1.tgz#5e32fc01f1c42b39c654c35b16440e07a25d6f20" - integrity sha512-fUY88kXvGiIItgNC7wcTOl0SNRCVXMKSWW2Yzfmn7EKNc+MpCzcz9DhdHcdjbrtN3c6R4H5dTY2jiCpPdysEjA== - dependencies: - tslib "^2.1.0" - -fresh@~0.5.2: - version "0.5.2" - resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" - integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== - -fs-extra@^10.0.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" - integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - -fsevents@^2.3.2, fsevents@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== - -function-bind@^1.1.1, function-bind@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" - integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== - -function.prototype.name@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" - integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.0" - functions-have-names "^1.2.2" - -function.prototype.name@^1.1.6, function.prototype.name@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.8.tgz#e68e1df7b259a5c949eeef95cdbde53edffabb78" - integrity sha512-e5iwyodOHhbMr/yNrc7fDYG4qlbIvI5gajyzPnb5TCwyhjApznQh1BMFou9b30SevY43gCJKXycoCBjMbsuW0Q== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.3" - define-properties "^1.2.1" - functions-have-names "^1.2.3" - hasown "^2.0.2" - is-callable "^1.2.7" - -functions-have-names@^1.2.2, functions-have-names@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" - integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== - -generator-function@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/generator-function/-/generator-function-2.0.1.tgz#0e75dd410d1243687a0ba2e951b94eedb8f737a2" - integrity sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g== - -gensync@^1.0.0-beta.2: - version "1.0.0-beta.2" - resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" - integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - -get-intrinsic@^1.2.4, get-intrinsic@^1.2.5, get-intrinsic@^1.2.6, get-intrinsic@^1.2.7, get-intrinsic@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz#743f0e3b6964a93a5491ed1bffaae054d7f98d01" - integrity sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ== - dependencies: - call-bind-apply-helpers "^1.0.2" - es-define-property "^1.0.1" - es-errors "^1.3.0" - es-object-atoms "^1.1.1" - function-bind "^1.1.2" - get-proto "^1.0.1" - gopd "^1.2.0" - has-symbols "^1.1.0" - hasown "^2.0.2" - math-intrinsics "^1.1.0" - -get-package-type@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" - integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== - -get-proto@^1.0.0, get-proto@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" - integrity sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g== - dependencies: - dunder-proto "^1.0.1" - es-object-atoms "^1.0.0" - -get-stream@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" - integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== - -get-symbol-description@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz#7fdb81c900101fbd564dd5f1a30af5aadc1e58d6" - integrity sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw== - dependencies: - call-bind "^1.0.2" - get-intrinsic "^1.1.1" - -get-symbol-description@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.1.0.tgz#7bdd54e0befe8ffc9f3b4e203220d9f1e881b6ee" - integrity sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg== - dependencies: - call-bound "^1.0.3" - es-errors "^1.3.0" - get-intrinsic "^1.2.6" - -glob-parent@^5.1.2, glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob-parent@^6.0.1, glob-parent@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" - integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== - dependencies: - is-glob "^4.0.3" - -glob-to-regex.js@^1.0.0, glob-to-regex.js@^1.0.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/glob-to-regex.js/-/glob-to-regex.js-1.2.0.tgz#2b323728271d133830850e32311f40766c5f6413" - integrity sha512-QMwlOQKU/IzqMUOAZWubUOT8Qft+Y0KQWnX9nK3ch0CJg0tTp4TvGZsTfudYKv2NzoQSyPcnA6TYeIQ3jGichQ== - -glob-to-regexp@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" - integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== - -glob@^7.1.3, glob@^7.1.4, glob@^7.1.7: - version "7.2.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - -global@^4.3.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/global/-/global-4.4.0.tgz#3e7b105179006a323ed71aafca3e9c57a5cc6406" - integrity sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w== - dependencies: - min-document "^2.19.0" - process "^0.11.10" - -globals@^11.1.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -globals@^13.19.0: - version "13.24.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171" - integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ== - dependencies: - type-fest "^0.20.2" - -globalthis@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.4.tgz#7430ed3a975d97bfb59bcce41f5cabbafa651236" - integrity sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ== - dependencies: - define-properties "^1.2.1" - gopd "^1.0.1" - -globby@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" - -gopd@^1.0.1, gopd@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" - integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== - -graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.11, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: - version "4.2.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" - integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== - -graphemer@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" - integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== - -gud@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0" - -handle-thing@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e" - integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg== - -harmony-reflect@^1.4.6: - version "1.6.2" - resolved "https://registry.yarnpkg.com/harmony-reflect/-/harmony-reflect-1.6.2.tgz#31ecbd32e648a34d030d86adb67d4d47547fe710" - integrity sha512-HIp/n38R9kQjDEziXyDTuW3vvoxxyxjxFzXLrBr18uB47GnSt+G9D29fqrpM5ZkspMcPICud3XsBJQ4Y2URg8g== - -has-bigints@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" - integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-property-descriptors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" - integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== - dependencies: - get-intrinsic "^1.1.1" - -has-property-descriptors@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" - integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== - dependencies: - es-define-property "^1.0.0" - -has-proto@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.2.0.tgz#5de5a6eabd95fdffd9818b43055e8065e39fe9d5" - integrity sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ== - dependencies: - dunder-proto "^1.0.0" - -has-symbols@^1.0.1, has-symbols@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" - integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== - -has-symbols@^1.0.3, has-symbols@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.1.0.tgz#fc9c6a783a084951d0b971fe1018de813707a338" - integrity sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ== - -has-tostringtag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" - integrity sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ== - dependencies: - has-symbols "^1.0.2" - -has-tostringtag@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz#2cdc42d40bef2e5b4eeab7c01a73c54ce7ab5abc" - integrity sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw== - dependencies: - has-symbols "^1.0.3" - -has@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.4.tgz#2eb2860e000011dae4f1406a86fe80e530fb2ec6" - integrity sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ== - -hasown@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" - integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== - dependencies: - function-bind "^1.1.2" - -hex-color-regex@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e" - integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ== - -hey-listen@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/hey-listen/-/hey-listen-1.0.8.tgz#8e59561ff724908de1aa924ed6ecc84a56a9aa68" - integrity sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q== - -history@^4.9.0: - version "4.9.0" - resolved "https://registry.yarnpkg.com/history/-/history-4.9.0.tgz#84587c2068039ead8af769e9d6a6860a14fa1bca" - dependencies: - "@babel/runtime" "^7.1.2" - loose-envify "^1.2.0" - resolve-pathname "^2.2.0" - tiny-invariant "^1.0.2" - tiny-warning "^1.0.0" - value-equal "^0.4.0" - -hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: - version "3.3.2" - resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" - integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== - dependencies: - react-is "^16.7.0" - -hpack.js@^2.1.6: - version "2.1.6" - resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" - integrity sha512-zJxVehUdMGIKsRaNt7apO2Gqp0BdqW5yaiGHXXmbpvxgBYVZnAql+BJb4RO5ad2MgpbZKn5G6nMnegrH1FcNYQ== - dependencies: - inherits "^2.0.1" - obuf "^1.0.0" - readable-stream "^2.0.1" - wbuf "^1.1.0" - -hsl-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/hsl-regex/-/hsl-regex-1.0.0.tgz#d49330c789ed819e276a4c0d272dffa30b18fe6e" - integrity sha512-M5ezZw4LzXbBKMruP+BNANf0k+19hDQMgpzBIYnya//Al+fjNct9Wf3b1WedLqdEs2hKBvxq/jh+DsHJLj0F9A== - -hsla-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/hsla-regex/-/hsla-regex-1.0.0.tgz#c1ce7a3168c8c6614033a4b5f7877f3b225f9c38" - integrity sha512-7Wn5GMLuHBjZCb2bTmnDOycho0p/7UVaAeqXZGbHrBCl6Yd/xDhQJAXe6Ga9AXJH2I5zY1dEdYw2u1UptnSBJA== - -html-escaper@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" - integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== - -html-parse-stringify@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2" - integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg== - dependencies: - void-elements "3.1.0" - -html-tags@^3.1.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.3.1.tgz#a04026a18c882e4bba8a01a3d39cfe465d40b5ce" - integrity sha512-ztqyC3kLto0e9WbNp0aeP+M3kTt+nbaIveGmUxAtZa+8iFgKLUOD4YKM5j+f3QD89bra7UeumolZHKuOXnTmeQ== - -http-deceiver@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87" - integrity sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw== - -http-errors@~1.8.0: - version "1.8.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" - integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - -http-errors@~2.0.0, http-errors@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.1.tgz#36d2f65bc909c8790018dd36fb4d93da6caae06b" - integrity sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ== - dependencies: - depd "~2.0.0" - inherits "~2.0.4" - setprototypeof "~1.2.0" - statuses "~2.0.2" - toidentifier "~1.0.1" - -http-parser-js@>=0.5.1: - version "0.5.10" - resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.10.tgz#b3277bd6d7ed5588e20ea73bf724fcbe44609075" - integrity sha512-Pysuw9XpUq5dVc/2SMHpuTY01RFl8fttgcyunjL7eEMhGM3cI4eOmiCycJDVCo/7O7ClfQD3SaI6ftDzqOXYMA== - -http-proxy-middleware@^2.0.9: - version "2.0.9" - resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.9.tgz#e9e63d68afaa4eee3d147f39149ab84c0c2815ef" - integrity sha512-c1IyJYLYppU574+YI7R4QyX2ystMtVXZwIdzazUIPIJsHuWNd+mho2j+bKoHftndicGj9yh+xjd+l0yj7VeT1Q== - dependencies: - "@types/http-proxy" "^1.17.8" - http-proxy "^1.18.1" - is-glob "^4.0.1" - is-plain-obj "^3.0.0" - micromatch "^4.0.2" - -http-proxy@^1.18.1: - version "1.18.1" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" - integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== - dependencies: - eventemitter3 "^4.0.0" - follow-redirects "^1.0.0" - requires-port "^1.0.0" - -human-signals@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" - integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== - -hyperdyperid@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" - integrity sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A== - -i18next-http-backend@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/i18next-http-backend/-/i18next-http-backend-3.0.2.tgz#7c8daa31aa69679e155ec1f96a37846225bdf907" - integrity sha512-PdlvPnvIp4E1sYi46Ik4tBYh/v/NbYfFFgTjkwFl0is8A18s7/bx9aXqsrOax9WUbeNS6mD2oix7Z0yGGf6m5g== - dependencies: - cross-fetch "4.0.0" - -i18next-multiload-backend-adapter@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/i18next-multiload-backend-adapter/-/i18next-multiload-backend-adapter-2.3.0.tgz#d3a0249671b560c186ccf74c15869f781af81b28" - integrity sha512-k52N4CImVEDeA+jJo16EJIDdlemSIsWmX6MuBPyR5V8Ig1vQSqVG1acXiQkKE+txLxD8LnR6WKYhkcxTcR86kw== - -i18next@^25.8.0: - version "25.8.0" - resolved "https://registry.yarnpkg.com/i18next/-/i18next-25.8.0.tgz#8b4ac516db016ebba70d2b68f5ba17e6ffcd4935" - integrity sha512-urrg4HMFFMQZ2bbKRK7IZ8/CTE7D8H4JRlAwqA2ZwDRFfdd0K/4cdbNNLgfn9mo+I/h9wJu61qJzH7jCFAhUZQ== - dependencies: - "@babel/runtime" "^7.28.4" - -iconv-lite@^0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" - integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== - dependencies: - safer-buffer ">= 2.1.2 < 3.0.0" - -iconv-lite@~0.4.24: - version "0.4.24" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" - integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== - dependencies: - safer-buffer ">= 2.1.2 < 3" - -icss-utils@^5.0.0, icss-utils@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae" - integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA== - -identity-obj-proxy@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14" - integrity sha512-00n6YnVHKrinT9t0d9+5yZC6UBNJANpYEQvL2LlX6Ab9lnmxzIRcEmTPuyGScvl1+jKuCICX1Z0Ab1pPKKdikA== - dependencies: - harmony-reflect "^1.4.6" - -ignore@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== - -immer@^9.0.6: - version "9.0.21" - resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.21.tgz#1e025ea31a40f24fb064f1fef23e931496330176" - integrity sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA== - -import-fresh@^3.1.0, import-fresh@^3.2.1, import-fresh@^3.3.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.1.tgz#9cecb56503c0ada1f2741dbbd6546e4b13b57ccf" - integrity sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ== - dependencies: - parent-module "^1.0.0" - resolve-from "^4.0.0" - -import-local@^3.0.2: - version "3.2.0" - resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.2.0.tgz#c3d5c745798c02a6f8b897726aba5100186ee260" - integrity sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA== - dependencies: - pkg-dir "^4.2.0" - resolve-cwd "^3.0.0" - -imurmurhash@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== - -indent-string@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" - integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3, inherits@~2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - -internal-slot@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" - integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== - dependencies: - get-intrinsic "^1.1.0" - has "^1.0.3" - side-channel "^1.0.4" - -internal-slot@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.1.0.tgz#1eac91762947d2f7056bc838d93e13b2e9604961" - integrity sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw== - dependencies: - es-errors "^1.3.0" - hasown "^2.0.2" - side-channel "^1.1.0" - -interpret@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" - integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== - -ipaddr.js@1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" - integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== - -ipaddr.js@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.3.0.tgz#71dce70e1398122208996d1c22f2ba46a24b1abc" - integrity sha512-Zv/pA+ciVFbCSBBjGfaKUya/CcGmUHzTydLMaTwrUUEM2DIEO3iZvueGxmacvmN50fGpGVKeTXpb2LcYQxeVdg== - -is-array-buffer@^3.0.4, is-array-buffer@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.5.tgz#65742e1e687bd2cc666253068fd8707fe4d44280" - integrity sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.3" - get-intrinsic "^1.2.6" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== - -is-arrayish@^0.3.1: - version "0.3.4" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.4.tgz#1ee5553818511915685d33bb13d31bf854e5059d" - integrity sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA== - -is-async-function@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-async-function/-/is-async-function-2.1.1.tgz#3e69018c8e04e73b738793d020bfe884b9fd3523" - integrity sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ== - dependencies: - async-function "^1.0.0" - call-bound "^1.0.3" - get-proto "^1.0.1" - has-tostringtag "^1.0.2" - safe-regex-test "^1.1.0" - -is-bigint@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.2.tgz#ffb381442503235ad245ea89e45b3dbff040ee5a" - integrity sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA== - -is-bigint@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.1.0.tgz#dda7a3445df57a42583db4228682eba7c4170672" - integrity sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ== - dependencies: - has-bigints "^1.0.2" - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-boolean-object@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.1.tgz#3c0878f035cb821228d350d2e1e36719716a3de8" - integrity sha512-bXdQWkECBUIAcCkeH1unwJLIpZYaa5VvuygSyS/c2lf719mTKZDU5UdDRlpd01UjADgmW8RfqaP+mRaVPdr/Ng== - dependencies: - call-bind "^1.0.2" - -is-boolean-object@^1.2.1: - version "1.2.2" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.2.2.tgz#7067f47709809a393c71ff5bb3e135d8a9215d9e" - integrity sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A== - dependencies: - call-bound "^1.0.3" - has-tostringtag "^1.0.2" - -is-callable@^1.1.4, is-callable@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945" - integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w== - -is-callable@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" - integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== - -is-color-stop@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-color-stop/-/is-color-stop-1.1.0.tgz#cfff471aee4dd5c9e158598fbe12967b5cdad345" - integrity sha512-H1U8Vz0cfXNujrJzEcvvwMDW9Ra+biSYA3ThdQvAnMLJkEHQXn6bWzLkxHtVYJ+Sdbx0b6finn3jZiaVe7MAHA== - dependencies: - css-color-names "^0.0.4" - hex-color-regex "^1.1.0" - hsl-regex "^1.0.0" - hsla-regex "^1.0.0" - rgb-regex "^1.0.1" - rgba-regex "^1.0.0" - -is-core-module@^2.13.0, is-core-module@^2.16.1, is-core-module@^2.8.1: - version "2.16.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.16.1.tgz#2a98801a849f43e2add644fbb6bc6229b19a4ef4" - integrity sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w== - dependencies: - hasown "^2.0.2" - -is-data-view@^1.0.1, is-data-view@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-data-view/-/is-data-view-1.0.2.tgz#bae0a41b9688986c2188dda6657e56b8f9e63b8e" - integrity sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw== - dependencies: - call-bound "^1.0.2" - get-intrinsic "^1.2.6" - is-typed-array "^1.1.13" - -is-date-object@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" - -is-date-object@^1.0.5, is-date-object@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.1.0.tgz#ad85541996fc7aa8b2729701d27b7319f95d82f7" - integrity sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg== - dependencies: - call-bound "^1.0.2" - has-tostringtag "^1.0.2" - -is-docker@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-3.0.0.tgz#90093aa3106277d8a77a5910dbae71747e15a200" - integrity sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ== - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-finalizationregistry@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz#eefdcdc6c94ddd0674d9c85887bf93f944a97c90" - integrity sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg== - dependencies: - call-bound "^1.0.3" - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-generator-fn@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" - integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== - -is-generator-function@^1.0.10: - version "1.1.2" - resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.1.2.tgz#ae3b61e3d5ea4e4839b90bad22b02335051a17d5" - integrity sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA== - dependencies: - call-bound "^1.0.4" - generator-function "^2.0.0" - get-proto "^1.0.1" - has-tostringtag "^1.0.2" - safe-regex-test "^1.1.0" - -is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-inside-container@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-inside-container/-/is-inside-container-1.0.0.tgz#e81fba699662eb31dbdaf26766a61d4814717ea4" - integrity sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA== - dependencies: - is-docker "^3.0.0" - -is-map@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.3.tgz#ede96b7fe1e270b3c4465e3a465658764926d62e" - integrity sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw== - -is-negative-zero@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" - integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== - -is-negative-zero@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.3.tgz#ced903a027aca6381b777a5743069d7376a49747" - integrity sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw== - -is-network-error@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/is-network-error/-/is-network-error-1.3.0.tgz#2ce62cbca444abd506f8a900f39d20b898d37512" - integrity sha512-6oIwpsgRfnDiyEDLMay/GqCl3HoAtH5+RUKW29gYkL0QA+ipzpDLA16yQs7/RHCSu+BwgbJaOUqa4A99qNVQVw== - -is-number-object@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.5.tgz#6edfaeed7950cff19afedce9fbfca9ee6dd289eb" - integrity sha512-RU0lI/n95pMoUKu9v1BZP5MBcZuNSVJkMkAG2dJqC4z2GlkGUNeH68SuHuBKBD/XFe+LHZ+f9BKkLET60Niedw== - -is-number-object@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.1.1.tgz#144b21e95a1bc148205dcc2814a9134ec41b2541" - integrity sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw== - dependencies: - call-bound "^1.0.3" - has-tostringtag "^1.0.2" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-path-inside@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" - integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== - -is-plain-obj@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" - integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== - -is-plain-object@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" - integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== - dependencies: - isobject "^3.0.1" - -is-plain-object@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" - integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== - -is-regex@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" - integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - -is-regex@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.2.1.tgz#76d70a3ed10ef9be48eb577887d74205bf0cad22" - integrity sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g== - dependencies: - call-bound "^1.0.2" - gopd "^1.2.0" - has-tostringtag "^1.0.2" - hasown "^2.0.2" - -is-set@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.3.tgz#8ab209ea424608141372ded6e0cb200ef1d9d01d" - integrity sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg== - -is-shared-array-buffer@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" - integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== - dependencies: - call-bind "^1.0.2" - -is-shared-array-buffer@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz#9b67844bd9b7f246ba0708c3a93e34269c774f6f" - integrity sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A== - dependencies: - call-bound "^1.0.3" - -is-stream@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" - integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== - -is-string@^1.0.5, is-string@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" - integrity sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg== - dependencies: - has-tostringtag "^1.0.0" - -is-string@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.1.1.tgz#92ea3f3d5c5b6e039ca8677e5ac8d07ea773cbb9" - integrity sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA== - dependencies: - call-bound "^1.0.3" - has-tostringtag "^1.0.2" - -is-symbol@^1.0.2, is-symbol@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" - integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== - dependencies: - has-symbols "^1.0.2" - -is-symbol@^1.0.4, is-symbol@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.1.1.tgz#f47761279f532e2b05a7024a7506dbbedacd0634" - integrity sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w== - dependencies: - call-bound "^1.0.2" - has-symbols "^1.1.0" - safe-regex-test "^1.1.0" - -is-typed-array@^1.1.13, is-typed-array@^1.1.14, is-typed-array@^1.1.15: - version "1.1.15" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.15.tgz#4bfb4a45b61cee83a5a46fba778e4e8d59c0ce0b" - integrity sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ== - dependencies: - which-typed-array "^1.1.16" - -is-weakmap@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.2.tgz#bf72615d649dfe5f699079c54b83e47d1ae19cfd" - integrity sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w== - -is-weakref@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" - integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== - dependencies: - call-bind "^1.0.2" - -is-weakref@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.1.1.tgz#eea430182be8d64174bd96bffbc46f21bf3f9293" - integrity sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew== - dependencies: - call-bound "^1.0.3" - -is-weakset@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.4.tgz#c9f5deb0bc1906c6d6f1027f284ddf459249daca" - integrity sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ== - dependencies: - call-bound "^1.0.3" - get-intrinsic "^1.2.6" - -is-wsl@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-3.1.0.tgz#e1c657e39c10090afcbedec61720f6b924c3cbd2" - integrity sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw== - dependencies: - is-inside-container "^1.0.0" - -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - -isarray@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" - integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== - -isobject@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" - integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== - -istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756" - integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg== - -istanbul-lib-instrument@^5.0.4, istanbul-lib-instrument@^5.1.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz#d10c8885c2125574e1c231cacadf955675e1ce3d" - integrity sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg== - dependencies: - "@babel/core" "^7.12.3" - "@babel/parser" "^7.14.7" - "@istanbuljs/schema" "^0.1.2" - istanbul-lib-coverage "^3.2.0" - semver "^6.3.0" - -istanbul-lib-report@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" - integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw== - dependencies: - istanbul-lib-coverage "^3.0.0" - make-dir "^4.0.0" - supports-color "^7.1.0" - -istanbul-lib-source-maps@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz#895f3a709fcfba34c6de5a42939022f3e4358551" - integrity sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw== - dependencies: - debug "^4.1.1" - istanbul-lib-coverage "^3.0.0" - source-map "^0.6.1" - -istanbul-reports@^3.1.3: - version "3.2.0" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.2.0.tgz#cb4535162b5784aa623cee21a7252cf2c807ac93" - integrity sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA== - dependencies: - html-escaper "^2.0.0" - istanbul-lib-report "^3.0.0" - -iterator.prototype@^1.1.4: - version "1.1.5" - resolved "https://registry.yarnpkg.com/iterator.prototype/-/iterator.prototype-1.1.5.tgz#12c959a29de32de0aa3bbbb801f4d777066dae39" - integrity sha512-H0dkQoCa3b2VEeKQBOxFph+JAbcrQdE7KC0UkqwpLmv2EC4P41QXP+rqo9wYodACiG5/WM5s9oDApTU8utwj9g== - dependencies: - define-data-property "^1.1.4" - es-object-atoms "^1.0.0" - get-intrinsic "^1.2.6" - get-proto "^1.0.0" - has-symbols "^1.1.0" - set-function-name "^2.0.2" - -jest-changed-files@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-28.1.3.tgz#d9aeee6792be3686c47cb988a8eaf82ff4238831" - integrity sha512-esaOfUWJXk2nfZt9SPyC8gA1kNfdKLkQWyzsMlqq8msYSlNKfmZxfRgZn4Cd4MGVUF+7v6dBs0d5TOAKa7iIiA== - dependencies: - execa "^5.0.0" - p-limit "^3.1.0" - -jest-circus@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-28.1.3.tgz#d14bd11cf8ee1a03d69902dc47b6bd4634ee00e4" - integrity sha512-cZ+eS5zc79MBwt+IhQhiEp0OeBddpc1n8MBo1nMB8A7oPMKEO+Sre+wHaLJexQUj9Ya/8NOBY0RESUgYjB6fow== - dependencies: - "@jest/environment" "^28.1.3" - "@jest/expect" "^28.1.3" - "@jest/test-result" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/node" "*" - chalk "^4.0.0" - co "^4.6.0" - dedent "^0.7.0" - is-generator-fn "^2.0.0" - jest-each "^28.1.3" - jest-matcher-utils "^28.1.3" - jest-message-util "^28.1.3" - jest-runtime "^28.1.3" - jest-snapshot "^28.1.3" - jest-util "^28.1.3" - p-limit "^3.1.0" - pretty-format "^28.1.3" - slash "^3.0.0" - stack-utils "^2.0.3" - -jest-cli@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-28.1.3.tgz#558b33c577d06de55087b8448d373b9f654e46b2" - integrity sha512-roY3kvrv57Azn1yPgdTebPAXvdR2xfezaKKYzVxZ6It/5NCxzJym6tUI5P1zkdWhfUYkxEI9uZWcQdaFLo8mJQ== - dependencies: - "@jest/core" "^28.1.3" - "@jest/test-result" "^28.1.3" - "@jest/types" "^28.1.3" - chalk "^4.0.0" - exit "^0.1.2" - graceful-fs "^4.2.9" - import-local "^3.0.2" - jest-config "^28.1.3" - jest-util "^28.1.3" - jest-validate "^28.1.3" - prompts "^2.0.1" - yargs "^17.3.1" - -jest-config@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-28.1.3.tgz#e315e1f73df3cac31447eed8b8740a477392ec60" - integrity sha512-MG3INjByJ0J4AsNBm7T3hsuxKQqFIiRo/AUqb1q9LRKI5UU6Aar9JHbr9Ivn1TVwfUD9KirRoM/T6u8XlcQPHQ== - dependencies: - "@babel/core" "^7.11.6" - "@jest/test-sequencer" "^28.1.3" - "@jest/types" "^28.1.3" - babel-jest "^28.1.3" - chalk "^4.0.0" - ci-info "^3.2.0" - deepmerge "^4.2.2" - glob "^7.1.3" - graceful-fs "^4.2.9" - jest-circus "^28.1.3" - jest-environment-node "^28.1.3" - jest-get-type "^28.0.2" - jest-regex-util "^28.0.2" - jest-resolve "^28.1.3" - jest-runner "^28.1.3" - jest-util "^28.1.3" - jest-validate "^28.1.3" - micromatch "^4.0.4" - parse-json "^5.2.0" - pretty-format "^28.1.3" - slash "^3.0.0" - strip-json-comments "^3.1.1" - -jest-diff@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-28.1.3.tgz#948a192d86f4e7a64c5264ad4da4877133d8792f" - integrity sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw== - dependencies: - chalk "^4.0.0" - diff-sequences "^28.1.1" - jest-get-type "^28.0.2" - pretty-format "^28.1.3" - -jest-docblock@^28.1.1: - version "28.1.1" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-28.1.1.tgz#6f515c3bf841516d82ecd57a62eed9204c2f42a8" - integrity sha512-3wayBVNiOYx0cwAbl9rwm5kKFP8yHH3d/fkEaL02NPTkDojPtheGB7HZSFY4wzX+DxyrvhXz0KSCVksmCknCuA== - dependencies: - detect-newline "^3.0.0" - -jest-each@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-28.1.3.tgz#bdd1516edbe2b1f3569cfdad9acd543040028f81" - integrity sha512-arT1z4sg2yABU5uogObVPvSlSMQlDA48owx07BDPAiasW0yYpYHYOo4HHLz9q0BVzDVU4hILFjzJw0So9aCL/g== - dependencies: - "@jest/types" "^28.1.3" - chalk "^4.0.0" - jest-get-type "^28.0.2" - jest-util "^28.1.3" - pretty-format "^28.1.3" - -jest-environment-node@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-28.1.3.tgz#7e74fe40eb645b9d56c0c4b70ca4357faa349be5" - integrity sha512-ugP6XOhEpjAEhGYvp5Xj989ns5cB1K6ZdjBYuS30umT4CQEETaxSiPcZ/E1kFktX4GkrcM4qu07IIlDYX1gp+A== - dependencies: - "@jest/environment" "^28.1.3" - "@jest/fake-timers" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/node" "*" - jest-mock "^28.1.3" - jest-util "^28.1.3" - -jest-get-type@^28.0.2: - version "28.0.2" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-28.0.2.tgz#34622e628e4fdcd793d46db8a242227901fcf203" - integrity sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA== - -jest-haste-map@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-28.1.3.tgz#abd5451129a38d9841049644f34b034308944e2b" - integrity sha512-3S+RQWDXccXDKSWnkHa/dPwt+2qwA8CJzR61w3FoYCvoo3Pn8tvGcysmMF0Bj0EX5RYvAI2EIvC57OmotfdtKA== - dependencies: - "@jest/types" "^28.1.3" - "@types/graceful-fs" "^4.1.3" - "@types/node" "*" - anymatch "^3.0.3" - fb-watchman "^2.0.0" - graceful-fs "^4.2.9" - jest-regex-util "^28.0.2" - jest-util "^28.1.3" - jest-worker "^28.1.3" - micromatch "^4.0.4" - walker "^1.0.8" - optionalDependencies: - fsevents "^2.3.2" - -jest-leak-detector@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-28.1.3.tgz#a6685d9b074be99e3adee816ce84fd30795e654d" - integrity sha512-WFVJhnQsiKtDEo5lG2mM0v40QWnBM+zMdHHyJs8AWZ7J0QZJS59MsyKeJHWhpBZBH32S48FOVvGyOFT1h0DlqA== - dependencies: - jest-get-type "^28.0.2" - pretty-format "^28.1.3" - -jest-matcher-utils@^28.0.0, jest-matcher-utils@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-28.1.3.tgz#5a77f1c129dd5ba3b4d7fc20728806c78893146e" - integrity sha512-kQeJ7qHemKfbzKoGjHHrRKH6atgxMk8Enkk2iPQ3XwO6oE/KYD8lMYOziCkeSB9G4adPM4nR1DE8Tf5JeWH6Bw== - dependencies: - chalk "^4.0.0" - jest-diff "^28.1.3" - jest-get-type "^28.0.2" - pretty-format "^28.1.3" - -jest-message-util@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-28.1.3.tgz#232def7f2e333f1eecc90649b5b94b0055e7c43d" - integrity sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g== - dependencies: - "@babel/code-frame" "^7.12.13" - "@jest/types" "^28.1.3" - "@types/stack-utils" "^2.0.0" - chalk "^4.0.0" - graceful-fs "^4.2.9" - micromatch "^4.0.4" - pretty-format "^28.1.3" - slash "^3.0.0" - stack-utils "^2.0.3" - -jest-mock@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-28.1.3.tgz#d4e9b1fc838bea595c77ab73672ebf513ab249da" - integrity sha512-o3J2jr6dMMWYVH4Lh/NKmDXdosrsJgi4AviS8oXLujcjpCMBb1FMsblDnOXKZKfSiHLxYub1eS0IHuRXsio9eA== - dependencies: - "@jest/types" "^28.1.3" - "@types/node" "*" - -jest-pnp-resolver@^1.2.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" - integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== - -jest-regex-util@^28.0.2: - version "28.0.2" - resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-28.0.2.tgz#afdc377a3b25fb6e80825adcf76c854e5bf47ead" - integrity sha512-4s0IgyNIy0y9FK+cjoVYoxamT7Zeo7MhzqRGx7YDYmaQn1wucY9rotiGkBzzcMXTtjrCAP/f7f+E0F7+fxPNdw== - -jest-resolve-dependencies@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-28.1.3.tgz#8c65d7583460df7275c6ea2791901fa975c1fe66" - integrity sha512-qa0QO2Q0XzQoNPouMbCc7Bvtsem8eQgVPNkwn9LnS+R2n8DaVDPL/U1gngC0LTl1RYXJU0uJa2BMC2DbTfFrHA== - dependencies: - jest-regex-util "^28.0.2" - jest-snapshot "^28.1.3" - -jest-resolve@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-28.1.3.tgz#cfb36100341ddbb061ec781426b3c31eb51aa0a8" - integrity sha512-Z1W3tTjE6QaNI90qo/BJpfnvpxtaFTFw5CDgwpyE/Kz8U/06N1Hjf4ia9quUhCh39qIGWF1ZuxFiBiJQwSEYKQ== - dependencies: - chalk "^4.0.0" - graceful-fs "^4.2.9" - jest-haste-map "^28.1.3" - jest-pnp-resolver "^1.2.2" - jest-util "^28.1.3" - jest-validate "^28.1.3" - resolve "^1.20.0" - resolve.exports "^1.1.0" - slash "^3.0.0" - -jest-runner@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-28.1.3.tgz#5eee25febd730b4713a2cdfd76bdd5557840f9a1" - integrity sha512-GkMw4D/0USd62OVO0oEgjn23TM+YJa2U2Wu5zz9xsQB1MxWKDOlrnykPxnMsN0tnJllfLPinHTka61u0QhaxBA== - dependencies: - "@jest/console" "^28.1.3" - "@jest/environment" "^28.1.3" - "@jest/test-result" "^28.1.3" - "@jest/transform" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/node" "*" - chalk "^4.0.0" - emittery "^0.10.2" - graceful-fs "^4.2.9" - jest-docblock "^28.1.1" - jest-environment-node "^28.1.3" - jest-haste-map "^28.1.3" - jest-leak-detector "^28.1.3" - jest-message-util "^28.1.3" - jest-resolve "^28.1.3" - jest-runtime "^28.1.3" - jest-util "^28.1.3" - jest-watcher "^28.1.3" - jest-worker "^28.1.3" - p-limit "^3.1.0" - source-map-support "0.5.13" - -jest-runtime@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-28.1.3.tgz#a57643458235aa53e8ec7821949e728960d0605f" - integrity sha512-NU+881ScBQQLc1JHG5eJGU7Ui3kLKrmwCPPtYsJtBykixrM2OhVQlpMmFWJjMyDfdkGgBMNjXCGB/ebzsgNGQw== - dependencies: - "@jest/environment" "^28.1.3" - "@jest/fake-timers" "^28.1.3" - "@jest/globals" "^28.1.3" - "@jest/source-map" "^28.1.2" - "@jest/test-result" "^28.1.3" - "@jest/transform" "^28.1.3" - "@jest/types" "^28.1.3" - chalk "^4.0.0" - cjs-module-lexer "^1.0.0" - collect-v8-coverage "^1.0.0" - execa "^5.0.0" - glob "^7.1.3" - graceful-fs "^4.2.9" - jest-haste-map "^28.1.3" - jest-message-util "^28.1.3" - jest-mock "^28.1.3" - jest-regex-util "^28.0.2" - jest-resolve "^28.1.3" - jest-snapshot "^28.1.3" - jest-util "^28.1.3" - slash "^3.0.0" - strip-bom "^4.0.0" - -jest-snapshot@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-28.1.3.tgz#17467b3ab8ddb81e2f605db05583d69388fc0668" - integrity sha512-4lzMgtiNlc3DU/8lZfmqxN3AYD6GGLbl+72rdBpXvcV+whX7mDrREzkPdp2RnmfIiWBg1YbuFSkXduF2JcafJg== - dependencies: - "@babel/core" "^7.11.6" - "@babel/generator" "^7.7.2" - "@babel/plugin-syntax-typescript" "^7.7.2" - "@babel/traverse" "^7.7.2" - "@babel/types" "^7.3.3" - "@jest/expect-utils" "^28.1.3" - "@jest/transform" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/babel__traverse" "^7.0.6" - "@types/prettier" "^2.1.5" - babel-preset-current-node-syntax "^1.0.0" - chalk "^4.0.0" - expect "^28.1.3" - graceful-fs "^4.2.9" - jest-diff "^28.1.3" - jest-get-type "^28.0.2" - jest-haste-map "^28.1.3" - jest-matcher-utils "^28.1.3" - jest-message-util "^28.1.3" - jest-util "^28.1.3" - natural-compare "^1.4.0" - pretty-format "^28.1.3" - semver "^7.3.5" - -jest-util@^28.0.0, jest-util@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-28.1.3.tgz#f4f932aa0074f0679943220ff9cbba7e497028b0" - integrity sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ== - dependencies: - "@jest/types" "^28.1.3" - "@types/node" "*" - chalk "^4.0.0" - ci-info "^3.2.0" - graceful-fs "^4.2.9" - picomatch "^2.2.3" - -jest-validate@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-28.1.3.tgz#e322267fd5e7c64cea4629612c357bbda96229df" - integrity sha512-SZbOGBWEsaTxBGCOpsRWlXlvNkvTkY0XxRfh7zYmvd8uL5Qzyg0CHAXiXKROflh801quA6+/DsT4ODDthOC/OA== - dependencies: - "@jest/types" "^28.1.3" - camelcase "^6.2.0" - chalk "^4.0.0" - jest-get-type "^28.0.2" - leven "^3.1.0" - pretty-format "^28.1.3" - -jest-watcher@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-28.1.3.tgz#c6023a59ba2255e3b4c57179fc94164b3e73abd4" - integrity sha512-t4qcqj9hze+jviFPUN3YAtAEeFnr/azITXQEMARf5cMwKY2SMBRnCQTXLixTl20OR6mLh9KLMrgVJgJISym+1g== - dependencies: - "@jest/test-result" "^28.1.3" - "@jest/types" "^28.1.3" - "@types/node" "*" - ansi-escapes "^4.2.1" - chalk "^4.0.0" - emittery "^0.10.2" - jest-util "^28.1.3" - string-length "^4.0.1" - -jest-worker@^27.4.5: - version "27.5.1" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" - integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^8.0.0" - -jest-worker@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-28.1.3.tgz#7e3c4ce3fa23d1bb6accb169e7f396f98ed4bb98" - integrity sha512-CqRA220YV/6jCo8VWvAt1KKx6eek1VIHMPeLEbpcfSfkEeWyBNppynM/o6q+Wmw+sOhos2ml34wZbSX3G13//g== - dependencies: - "@types/node" "*" - merge-stream "^2.0.0" - supports-color "^8.0.0" - -jest@^28.1.1: - version "28.1.3" - resolved "https://registry.yarnpkg.com/jest/-/jest-28.1.3.tgz#e9c6a7eecdebe3548ca2b18894a50f45b36dfc6b" - integrity sha512-N4GT5on8UkZgH0O5LUavMRV1EDEhNTL0KEfRmDIeZHSV7p2XgLoY9t9VDUgL6o+yfdgYHVxuz81G8oB9VG5uyA== - dependencies: - "@jest/core" "^28.1.3" - "@jest/types" "^28.1.3" - import-local "^3.0.2" - jest-cli "^28.1.3" - -jiti@^1.21.7: - version "1.21.7" - resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.7.tgz#9dd81043424a3d28458b193d965f0d18a2300ba9" - integrity sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A== - -jiti@^2.5.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/jiti/-/jiti-2.6.1.tgz#178ef2fc9a1a594248c20627cd820187a4d78d92" - integrity sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ== - -"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@^3.13.1: - version "3.14.2" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.2.tgz#77485ce1dd7f33c061fd1b16ecea23b55fcb04b0" - integrity sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - -js-yaml@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" - integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== - dependencies: - argparse "^2.0.1" - -jsesc@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.1.0.tgz#74d335a234f67ed19907fdadfac7ccf9d409825d" - integrity sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA== - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - -json-parse-even-better-errors@^2.3.0, json-parse-even-better-errors@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" - integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-schema-traverse@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" - integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== - -json-stable-stringify-without-jsonify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - -json5@^2.1.2: - version "2.2.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== - -json5@^2.2.1, json5@^2.2.3: - version "2.2.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" - integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== - -jsonfile@^6.0.1: - version "6.2.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.2.0.tgz#7c265bd1b65de6977478300087c99f1c84383f62" - integrity sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - -"jsx-ast-utils@^2.4.1 || ^3.0.0": - version "3.2.0" - resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.2.0.tgz#41108d2cec408c3453c1bbe8a4aae9e1e2bd8f82" - integrity sha512-EIsmt3O3ljsU6sot/J4E1zDRxfBNrhjyf/OKjlydwgEimQuznlM4Wv7U+ueONJMyEn1WRE0K8dhi3dVAXYT24Q== - dependencies: - array-includes "^3.1.2" - object.assign "^4.1.2" - -kind-of@^6.0.2: - version "6.0.3" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" - integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== - -kleur@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" - integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== - -launch-editor@^2.6.1: - version "2.12.0" - resolved "https://registry.yarnpkg.com/launch-editor/-/launch-editor-2.12.0.tgz#cc740f4e0263a6b62ead2485f9896e545321f817" - integrity sha512-giOHXoOtifjdHqUamwKq6c49GzBdLjvxrd2D+Q4V6uOHopJv7p9VJxikDsQ/CBXZbEITgUqSVHXLTG3VhPP1Dg== - dependencies: - picocolors "^1.1.1" - shell-quote "^1.8.3" - -leven@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" - integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== - -levn@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" - integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== - dependencies: - prelude-ls "^1.2.1" - type-check "~0.4.0" - -lilconfig@^2.0.5: - version "2.1.0" - resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" - integrity sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ== - -lilconfig@^3.1.1, lilconfig@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.3.tgz#a1bcfd6257f9585bf5ae14ceeebb7b559025e4c4" - integrity sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw== - -lines-and-columns@^1.1.6: - version "1.2.4" - resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" - integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== - -loader-runner@^4.3.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.1.tgz#6c76ed29b0ccce9af379208299f07f876de737e3" - integrity sha512-IWqP2SCPhyVFTBtRcgMHdzlf9ul25NwaFx4wCEH/KjAXuuHY4yNjvPXsBokp8jCB936PyWRaPKUNh8NvylLp2Q== - -loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - -loader-utils@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c" - integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^2.1.2" - -locate-path@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" - integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== - dependencies: - p-locate "^4.1.0" - -locate-path@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" - integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== - dependencies: - p-locate "^5.0.0" - -lockfile@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lockfile/-/lockfile-1.0.4.tgz#07f819d25ae48f87e538e6578b6964a4981a5609" - integrity sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA== - dependencies: - signal-exit "^3.0.2" - -lodash-es@^4.17.11, lodash-es@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" - integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== - -lodash.flatmap@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz#ef8cbf408f6e48268663345305c6acc0b778702e" - integrity sha512-/OcpcAGWlrZyoHGeHh3cAoa6nGdX6QYtmzNP84Jqol6UEQQ2gIaU3H+0eICcjcKGl0/XF8LWOujNn9lffsnaOg== - -lodash.get@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" - integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ== - -lodash.memoize@4.x: - version "4.1.2" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" - integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag== - -lodash.merge@^4.6.2: - version "4.6.2" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" - integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== - -lodash.topath@^4.5.2: - version "4.5.2" - resolved "https://registry.yarnpkg.com/lodash.topath/-/lodash.topath-4.5.2.tgz#3616351f3bba61994a0931989660bd03254fd009" - integrity sha512-1/W4dM+35DwvE/iEd1M9ekewOSTlpFekhw9mhAtrwjVqUr83/ilQiyAvmg4tVX7Unkcfl1KC+i9WdaT4B6aQcg== - -lodash@^4.17.11, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" - integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== - dependencies: - js-tokens "^3.0.0 || ^4.0.0" - -lru-cache@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" - integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== - dependencies: - yallist "^3.0.2" - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -lz-string@^1.4.4: - version "1.4.4" - resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26" - integrity sha512-0ckx7ZHRPqb0oUm8zNr+90mtf9DQB60H1wMCjBtfi62Kl3a7JbHob6gA2bC+xRvZoOL+1hzUK8jeuEIQE8svEQ== - -make-dir@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" - integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== - dependencies: - semver "^7.5.3" - -make-error@1.x: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -makeerror@1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.12.tgz#3e5dd2079a82e812e983cc6610c4a2cb0eaa801a" - integrity sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg== - dependencies: - tmpl "1.0.5" - -map-or-similar@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/map-or-similar/-/map-or-similar-1.5.0.tgz#6de2653174adfb5d9edc33c69d3e92a1b76faf08" - integrity sha512-0aF7ZmVon1igznGI4VS30yugpduQW3y3GkcgGJOp7d8x8QrizhigUxjI/m2UojsXXto+jLAH3KSz+xOJTiORjg== - -math-intrinsics@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" - integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== - -memfs@^4.43.1: - version "4.56.10" - resolved "https://registry.yarnpkg.com/memfs/-/memfs-4.56.10.tgz#eaf2f6556db10f91f1e9ad9f1274fd988c646202" - integrity sha512-eLvzyrwqLHnLYalJP7YZ3wBe79MXktMdfQbvMrVD80K+NhrIukCVBvgP30zTJYEEDh9hZ/ep9z0KOdD7FSHo7w== - dependencies: - "@jsonjoy.com/fs-core" "4.56.10" - "@jsonjoy.com/fs-fsa" "4.56.10" - "@jsonjoy.com/fs-node" "4.56.10" - "@jsonjoy.com/fs-node-builtins" "4.56.10" - "@jsonjoy.com/fs-node-to-fsa" "4.56.10" - "@jsonjoy.com/fs-node-utils" "4.56.10" - "@jsonjoy.com/fs-print" "4.56.10" - "@jsonjoy.com/fs-snapshot" "4.56.10" - "@jsonjoy.com/json-pack" "^1.11.0" - "@jsonjoy.com/util" "^1.9.0" - glob-to-regex.js "^1.0.1" - thingies "^2.5.0" - tree-dump "^1.0.3" - tslib "^2.0.0" - -memoizerific@^1.11.3: - version "1.11.3" - resolved "https://registry.yarnpkg.com/memoizerific/-/memoizerific-1.11.3.tgz#7c87a4646444c32d75438570905f2dbd1b1a805a" - integrity sha512-/EuHYwAPdLtXwAwSZkh/Gutery6pD2KYd44oQLhAvQp/50mpyduZh8Q7PYHXTCJ+wuXxt7oij2LXyIJOOYFPog== - dependencies: - map-or-similar "^1.5.0" - -merge-descriptors@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.3.tgz#d80319a65f3c7935351e5cfdac8f9318504dbed5" - integrity sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ== - -merge-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" - integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== - -merge2@^1.3.0, merge2@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - -methods@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" - integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== - -micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" - integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== - dependencies: - braces "^3.0.3" - picomatch "^2.3.1" - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -"mime-db@>= 1.43.0 < 2", mime-db@^1.54.0: - version "1.54.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.54.0.tgz#cddb3ee4f9c64530dff640236661d42cb6a314f5" - integrity sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ== - -mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.24, mime-types@~2.1.34, mime-types@~2.1.35: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mime-types@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-3.0.2.tgz#39002d4182575d5af036ffa118100f2524b2e2ab" - integrity sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A== - dependencies: - mime-db "^1.54.0" - -mime@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -min-document@^2.19.0: - version "2.19.2" - resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.2.tgz#f95db44639eaae3ac8ea85ae6809ae85ff7e3b81" - integrity sha512-8S5I8db/uZN8r9HSLFVWPdJCvYOejMcEC82VIzNUc6Zkklf/d1gg2psfE79/vyhWOj4+J8MtwmoOz3TmvaGu5A== - dependencies: - dom-walk "^0.1.0" - -min-indent@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869" - integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg== - -mini-create-react-context@^0.3.0: - version "0.3.2" - resolved "https://registry.yarnpkg.com/mini-create-react-context/-/mini-create-react-context-0.3.2.tgz#79fc598f283dd623da8e088b05db8cddab250189" - dependencies: - "@babel/runtime" "^7.4.0" - gud "^1.0.0" - tiny-warning "^1.0.2" - -mini-svg-data-uri@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.2.3.tgz#e16baa92ad55ddaa1c2c135759129f41910bc39f" - integrity sha512-zd6KCAyXgmq6FV1mR10oKXYtvmA9vRoB6xPSTUJTbFApCtkefDnYueVR1gkof3KcdLZo1Y8mjF2DFmQMIxsHNQ== - -minimalistic-assert@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.6: - version "1.2.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" - integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== - -modern-normalize@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/modern-normalize/-/modern-normalize-1.1.0.tgz#da8e80140d9221426bd4f725c6e11283d34f90b7" - integrity sha512-2lMlY1Yc1+CUy0gw4H95uNN7vjbpoED7NNRSBHE25nWfLBdmMzFCsPshlzbxHz+gYMcBEUN8V4pU16prcdPSgA== - -ms@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@2.1.3, ms@^2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -multicast-dns@^7.2.5: - version "7.2.5" - resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-7.2.5.tgz#77eb46057f4d7adbd16d9290fa7299f6fa64cced" - integrity sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg== - dependencies: - dns-packet "^5.2.2" - thunky "^1.0.2" - -mz@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" - integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== - dependencies: - any-promise "^1.0.0" - object-assign "^4.0.1" - thenify-all "^1.0.0" - -nanoid@^3.3.11: - version "3.3.11" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.11.tgz#4f4f112cefbe303202f2199838128936266d185b" - integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w== - -natural-compare-lite@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" - integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== - -natural-compare@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== - -negotiator@0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" - integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== - -negotiator@~0.6.4: - version "0.6.4" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.4.tgz#777948e2452651c570b712dd01c23e262713fff7" - integrity sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w== - -neo-async@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" - integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== - -node-emoji@^1.11.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.11.0.tgz#69a0150e6946e2f115e9d7ea4df7971e2628301c" - integrity sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A== - dependencies: - lodash "^4.17.21" - -node-fetch@^2.6.12: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== - dependencies: - whatwg-url "^5.0.0" - -node-int64@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" - integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== - -node-releases@^2.0.27, node-releases@^2.0.5: - version "2.0.27" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.27.tgz#eedca519205cf20f650f61d56b070db111231e4e" - integrity sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -normalize-range@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" - integrity sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA== - -npm-run-path@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" - integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== - dependencies: - path-key "^3.0.0" - -object-assign@^4.0.1, object-assign@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== - -object-hash@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.2.0.tgz#5ad518581eefc443bd763472b8ff2e9c2c0d54a5" - integrity sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw== - -object-hash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-3.0.0.tgz#73f97f753e7baffc0e2cc9d6e079079744ac82e9" - integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== - -object-inspect@^1.12.0, object-inspect@^1.9.0: - version "1.12.2" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" - integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== - -object-inspect@^1.13.3, object-inspect@^1.13.4: - version "1.13.4" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.4.tgz#8375265e21bc20d0fa582c22e1b13485d6e00213" - integrity sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew== - -object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - -object.assign@^4.1.0, object.assign@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" - integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - has-symbols "^1.0.1" - object-keys "^1.1.1" - -object.assign@^4.1.7: - version "4.1.7" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.7.tgz#8c14ca1a424c6a561b0bb2a22f66f5049a945d3d" - integrity sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.3" - define-properties "^1.2.1" - es-object-atoms "^1.0.0" - has-symbols "^1.1.0" - object-keys "^1.1.1" - -object.entries@^1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.9.tgz#e4770a6a1444afb61bd39f984018b5bede25f8b3" - integrity sha512-8u/hfXFRBD1O0hPUjioLhoWFHRmt6tKA4/vZPyckBr18l1KE9uHrFaFaUi8MDRTpi4uak2goyPTSNJLXX2k2Hw== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.4" - define-properties "^1.2.1" - es-object-atoms "^1.1.1" - -object.fromentries@^2.0.8: - version "2.0.8" - resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.8.tgz#f7195d8a9b97bd95cbc1999ea939ecd1a2b00c65" - integrity sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ== - dependencies: - call-bind "^1.0.7" - define-properties "^1.2.1" - es-abstract "^1.23.2" - es-object-atoms "^1.0.0" - -object.values@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.2.1.tgz#deed520a50809ff7f75a7cfd4bc64c7a038c6216" - integrity sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.3" - define-properties "^1.2.1" - es-object-atoms "^1.0.0" - -obuf@^1.0.0, obuf@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" - integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== - -on-finished@^2.4.1, on-finished@~2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" - integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== - dependencies: - ee-first "1.1.1" - -on-headers@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.1.0.tgz#59da4f91c45f5f989c6e4bcedc5a3b0aed70ff65" - integrity sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A== - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -onetime@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -open@^10.0.3: - version "10.2.0" - resolved "https://registry.yarnpkg.com/open/-/open-10.2.0.tgz#b9d855be007620e80b6fb05fac98141fe62db73c" - integrity sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA== - dependencies: - default-browser "^5.2.1" - define-lazy-prop "^3.0.0" - is-inside-container "^1.0.0" - wsl-utils "^0.1.0" - -optionator@^0.9.3: - version "0.9.4" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.4.tgz#7ea1c1a5d91d764fb282139c88fe11e182a3a734" - integrity sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g== - dependencies: - deep-is "^0.1.3" - fast-levenshtein "^2.0.6" - levn "^0.4.1" - prelude-ls "^1.2.1" - type-check "^0.4.0" - word-wrap "^1.2.5" - -own-keys@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/own-keys/-/own-keys-1.0.1.tgz#e4006910a2bf913585289676eebd6f390cf51358" - integrity sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg== - dependencies: - get-intrinsic "^1.2.6" - object-keys "^1.1.1" - safe-push-apply "^1.0.0" - -p-limit@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" - integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== - dependencies: - p-try "^2.0.0" - -p-limit@^3.0.2, p-limit@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" - integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== - dependencies: - yocto-queue "^0.1.0" - -p-locate@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" - integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== - dependencies: - p-limit "^2.2.0" - -p-locate@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" - integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== - dependencies: - p-limit "^3.0.2" - -p-retry@^6.2.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-6.2.1.tgz#81828f8dc61c6ef5a800585491572cc9892703af" - integrity sha512-hEt02O4hUct5wtwg4H4KcWgDdm+l1bOaEy/hWzd8xtXB9BqxTWBBhb+2ImAtH4Cv4rPjV76xN3Zumqk3k3AhhQ== - dependencies: - "@types/retry" "0.12.2" - is-network-error "^1.0.0" - retry "^0.13.1" - -p-try@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" - integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== - -parent-module@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" - integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== - dependencies: - callsites "^3.0.0" - -parse-json@^5.0.0, parse-json@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" - integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== - dependencies: - "@babel/code-frame" "^7.0.0" - error-ex "^1.3.1" - json-parse-even-better-errors "^2.3.0" - lines-and-columns "^1.1.6" - -parseurl@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" - integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - -path-key@^3.0.0, path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -path-to-regexp@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d" - dependencies: - isarray "0.0.1" - -path-to-regexp@~0.1.12: - version "0.1.12" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz#d5e1a12e478a976d432ef3c58d534b9923164bb7" - integrity sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ== - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -pathe@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/pathe/-/pathe-2.0.3.tgz#3ecbec55421685b70a9da872b2cff3e1cbed1716" - integrity sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w== - -picocolors@^1.0.0, picocolors@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" - integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== - -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.0, picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -picomatch@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.3.tgz#796c76136d1eead715db1e7bad785dedd695a042" - integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q== - -pify@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - -pirates@^4.0.1, pirates@^4.0.4: - version "4.0.7" - resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.7.tgz#643b4a18c4257c8a65104b73f3049ce9a0a15e22" - integrity sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA== - -pkg-dir@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" - integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== - dependencies: - find-up "^4.0.0" - -pkijs@^3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/pkijs/-/pkijs-3.3.3.tgz#b3f04d7b2eaacb05c81675f882be374e591626ec" - integrity sha512-+KD8hJtqQMYoTuL1bbGOqxb4z+nZkTAwVdNtWwe8Tc2xNbEmdJYIYoc6Qt0uF55e6YW6KuTHw1DjQ18gMhzepw== - dependencies: - "@noble/hashes" "1.4.0" - asn1js "^3.0.6" - bytestreamjs "^2.0.1" - pvtsutils "^1.3.6" - pvutils "^1.1.3" - tslib "^2.8.1" - -popmotion@11.0.3: - version "11.0.3" - resolved "https://registry.yarnpkg.com/popmotion/-/popmotion-11.0.3.tgz#565c5f6590bbcddab7a33a074bb2ba97e24b0cc9" - integrity sha512-Y55FLdj3UxkR7Vl3s7Qr4e9m0onSnP8W7d/xQLsoJM40vs6UKHFdygs6SWryasTZYqugMjm3BepCF4CWXDiHgA== - dependencies: - framesync "6.0.1" - hey-listen "^1.0.8" - style-value-types "5.0.0" - tslib "^2.1.0" - -possible-typed-array-names@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz#93e3582bc0e5426586d9d07b79ee40fc841de4ae" - integrity sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg== - -postcss-attribute-case-insensitive@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-7.0.1.tgz#0c4500e3bcb2141848e89382c05b5a31c23033a3" - integrity sha512-Uai+SupNSqzlschRyNx3kbCTWgY/2hcwtHEI/ej2LJWc9JJ77qKgGptd8DHwY1mXtZ7Aoh4z4yxfwMBue9eNgw== - dependencies: - postcss-selector-parser "^7.0.0" - -postcss-clamp@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/postcss-clamp/-/postcss-clamp-4.1.0.tgz#7263e95abadd8c2ba1bd911b0b5a5c9c93e02363" - integrity sha512-ry4b1Llo/9zz+PKC+030KUnPITTJAHeOwjfAyyB60eT0AorGLdzp52s31OsPRHRf8NchkgFoG2y6fCfn1IV1Ow== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-color-functional-notation@^7.0.12: - version "7.0.12" - resolved "https://registry.yarnpkg.com/postcss-color-functional-notation/-/postcss-color-functional-notation-7.0.12.tgz#9a3df2296889e629fde18b873bb1f50a4ecf4b83" - integrity sha512-TLCW9fN5kvO/u38/uesdpbx3e8AkTYhMvDZYa9JpmImWuTE99bDQ7GU7hdOADIZsiI9/zuxfAJxny/khknp1Zw== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -postcss-color-hex-alpha@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/postcss-color-hex-alpha/-/postcss-color-hex-alpha-10.0.0.tgz#5dd3eba1f8facb4ea306cba6e3f7712e876b0c76" - integrity sha512-1kervM2cnlgPs2a8Vt/Qbe5cQ++N7rkYo/2rz2BkqJZIHQwaVuJgQH38REHrAi4uM0b1fqxMkWYmese94iMp3w== - dependencies: - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -postcss-color-rebeccapurple@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/postcss-color-rebeccapurple/-/postcss-color-rebeccapurple-10.0.0.tgz#5ada28406ac47e0796dff4056b0a9d5a6ecead98" - integrity sha512-JFta737jSP+hdAIEhk1Vs0q0YF5P8fFcj+09pweS8ktuGuZ8pPlykHsk6mPxZ8awDl4TrcxUqJo9l1IhVr/OjQ== - dependencies: - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -postcss-custom-media@^11.0.6: - version "11.0.6" - resolved "https://registry.yarnpkg.com/postcss-custom-media/-/postcss-custom-media-11.0.6.tgz#6b450e5bfa209efb736830066682e6567bd04967" - integrity sha512-C4lD4b7mUIw+RZhtY7qUbf4eADmb7Ey8BFA2px9jUbwg7pjTZDl4KY4bvlUV+/vXQvzQRfiGEVJyAbtOsCMInw== - dependencies: - "@csstools/cascade-layer-name-parser" "^2.0.5" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/media-query-list-parser" "^4.0.3" - -postcss-custom-properties@^14.0.6: - version "14.0.6" - resolved "https://registry.yarnpkg.com/postcss-custom-properties/-/postcss-custom-properties-14.0.6.tgz#1af73a650bf115ba052cf915287c9982825fc90e" - integrity sha512-fTYSp3xuk4BUeVhxCSJdIPhDLpJfNakZKoiTDx7yRGCdlZrSJR7mWKVOBS4sBF+5poPQFMj2YdXx1VHItBGihQ== - dependencies: - "@csstools/cascade-layer-name-parser" "^2.0.5" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -postcss-custom-selectors@^8.0.5: - version "8.0.5" - resolved "https://registry.yarnpkg.com/postcss-custom-selectors/-/postcss-custom-selectors-8.0.5.tgz#9448ed37a12271d7ab6cb364b6f76a46a4a323e8" - integrity sha512-9PGmckHQswiB2usSO6XMSswO2yFWVoCAuih1yl9FVcwkscLjRKjwsjM3t+NIWpSU2Jx3eOiK2+t4vVTQaoCHHg== - dependencies: - "@csstools/cascade-layer-name-parser" "^2.0.5" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - postcss-selector-parser "^7.0.0" - -postcss-dir-pseudo-class@^9.0.1: - version "9.0.1" - resolved "https://registry.yarnpkg.com/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-9.0.1.tgz#80d9e842c9ae9d29f6bf5fd3cf9972891d6cc0ca" - integrity sha512-tRBEK0MHYvcMUrAuYMEOa0zg9APqirBcgzi6P21OhxtJyJADo/SWBwY1CAwEohQ/6HDaa9jCjLRG7K3PVQYHEA== - dependencies: - postcss-selector-parser "^7.0.0" - -postcss-double-position-gradients@^6.0.4: - version "6.0.4" - resolved "https://registry.yarnpkg.com/postcss-double-position-gradients/-/postcss-double-position-gradients-6.0.4.tgz#b482d08b5ced092b393eb297d07976ab482d4cad" - integrity sha512-m6IKmxo7FxSP5nF2l63QbCC3r+bWpFUWmZXZf096WxG0m7Vl1Q1+ruFOhpdDRmKrRS+S3Jtk+TVk/7z0+BVK6g== - dependencies: - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -postcss-focus-visible@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/postcss-focus-visible/-/postcss-focus-visible-10.0.1.tgz#1f7904904368a2d1180b220595d77b6f8a957868" - integrity sha512-U58wyjS/I1GZgjRok33aE8juW9qQgQUNwTSdxQGuShHzwuYdcklnvK/+qOWX1Q9kr7ysbraQ6ht6r+udansalA== - dependencies: - postcss-selector-parser "^7.0.0" - -postcss-focus-within@^9.0.1: - version "9.0.1" - resolved "https://registry.yarnpkg.com/postcss-focus-within/-/postcss-focus-within-9.0.1.tgz#ac01ce80d3f2e8b2b3eac4ff84f8e15cd0057bc7" - integrity sha512-fzNUyS1yOYa7mOjpci/bR+u+ESvdar6hk8XNK/TRR0fiGTp2QT5N+ducP0n3rfH/m9I7H/EQU6lsa2BrgxkEjw== - dependencies: - postcss-selector-parser "^7.0.0" - -postcss-font-variant@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/postcss-font-variant/-/postcss-font-variant-5.0.0.tgz#efd59b4b7ea8bb06127f2d031bfbb7f24d32fa66" - integrity sha512-1fmkBaCALD72CK2a9i468mA/+tr9/1cBxRRMXOUaZqO43oWPR5imcyPjXwuv7PXbCid4ndlP5zWhidQVVa3hmA== - -postcss-gap-properties@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/postcss-gap-properties/-/postcss-gap-properties-6.0.0.tgz#d5ff0bdf923c06686499ed2b12e125fe64054fed" - integrity sha512-Om0WPjEwiM9Ru+VhfEDPZJAKWUd0mV1HmNXqp2C29z80aQ2uP9UVhLc7e3aYMIor/S5cVhoPgYQ7RtfeZpYTRw== - -postcss-image-set-function@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/postcss-image-set-function/-/postcss-image-set-function-7.0.0.tgz#538e94e16716be47f9df0573b56bbaca86e1da53" - integrity sha512-QL7W7QNlZuzOwBTeXEmbVckNt1FSmhQtbMRvGGqqU4Nf4xk6KUEQhAoWuMzwbSv5jxiRiSZ5Tv7eiDB9U87znA== - dependencies: - "@csstools/utilities" "^2.0.0" - postcss-value-parser "^4.2.0" - -postcss-import@^14.1.0: - version "14.1.0" - resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-14.1.0.tgz#a7333ffe32f0b8795303ee9e40215dac922781f0" - integrity sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw== - dependencies: - postcss-value-parser "^4.0.0" - read-cache "^1.0.0" - resolve "^1.1.7" - -postcss-import@^15.1.0: - version "15.1.0" - resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-15.1.0.tgz#41c64ed8cc0e23735a9698b3249ffdbf704adc70" - integrity sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew== - dependencies: - postcss-value-parser "^4.0.0" - read-cache "^1.0.0" - resolve "^1.1.7" - -postcss-js@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-3.0.3.tgz#2f0bd370a2e8599d45439f6970403b5873abda33" - integrity sha512-gWnoWQXKFw65Hk/mi2+WTQTHdPD5UJdDXZmX073EY/B3BWnYjO4F4t0VneTCnCGQ5E5GsCdMkzPaTXwl3r5dJw== - dependencies: - camelcase-css "^2.0.1" - postcss "^8.1.6" - -postcss-js@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-4.1.0.tgz#003b63c6edde948766e40f3daf7e997ae43a5ce6" - integrity sha512-oIAOTqgIo7q2EOwbhb8UalYePMvYoIeRY2YKntdpFQXNosSu3vLrniGgmH9OKs/qAkfoj5oB3le/7mINW1LCfw== - dependencies: - camelcase-css "^2.0.1" - -postcss-lab-function@^7.0.12: - version "7.0.12" - resolved "https://registry.yarnpkg.com/postcss-lab-function/-/postcss-lab-function-7.0.12.tgz#eb555ac542607730eb0a87555074e4a5c6eef6e4" - integrity sha512-tUcyRk1ZTPec3OuKFsqtRzW2Go5lehW29XA21lZ65XmzQkz43VY2tyWEC202F7W3mILOjw0voOiuxRGTsN+J9w== - dependencies: - "@csstools/css-color-parser" "^3.1.0" - "@csstools/css-parser-algorithms" "^3.0.5" - "@csstools/css-tokenizer" "^3.0.4" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/utilities" "^2.0.0" - -postcss-load-config@^3.1.0: - version "3.1.4" - resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.1.4.tgz#1ab2571faf84bb078877e1d07905eabe9ebda855" - integrity sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg== - dependencies: - lilconfig "^2.0.5" - yaml "^1.10.2" - -"postcss-load-config@^4.0.2 || ^5.0 || ^6.0": - version "6.0.1" - resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-6.0.1.tgz#6fd7dcd8ae89badcf1b2d644489cbabf83aa8096" - integrity sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g== - dependencies: - lilconfig "^3.1.1" - -postcss-loader@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-8.2.0.tgz#9b830af550bc0829d565d4e774738d84df88eab7" - integrity sha512-tHX+RkpsXVcc7st4dSdDGliI+r4aAQDuv+v3vFYHixb6YgjreG5AG4SEB0kDK8u2s6htqEEpKlkhSBUTvWKYnA== - dependencies: - cosmiconfig "^9.0.0" - jiti "^2.5.1" - semver "^7.6.2" - -postcss-logical@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/postcss-logical/-/postcss-logical-8.1.0.tgz#4092b16b49e3ecda70c4d8945257da403d167228" - integrity sha512-pL1hXFQ2fEXNKiNiAgtfA005T9FBxky5zkX6s4GZM2D8RkVgRqz3f4g1JUoq925zXv495qk8UNldDwh8uGEDoA== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-modules-extract-imports@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.1.0.tgz#b4497cb85a9c0c4b5aabeb759bb25e8d89f15002" - integrity sha512-k3kNe0aNFQDAZGbin48pL2VNidTF0w4/eASDsxlyspobzU3wZQLOGj7L9gfRe0Jo9/4uud09DsjFNH7winGv8Q== - -postcss-modules-local-by-default@^4.0.5: - version "4.2.0" - resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.2.0.tgz#d150f43837831dae25e4085596e84f6f5d6ec368" - integrity sha512-5kcJm/zk+GJDSfw+V/42fJ5fhjL5YbFDl8nVdXkJPLLW+Vf9mTD5Xe0wqIaDnLuL2U6cDNpTr+UQ+v2HWIBhzw== - dependencies: - icss-utils "^5.0.0" - postcss-selector-parser "^7.0.0" - postcss-value-parser "^4.1.0" - -postcss-modules-scope@^3.2.0: - version "3.2.1" - resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.2.1.tgz#1bbccddcb398f1d7a511e0a2d1d047718af4078c" - integrity sha512-m9jZstCVaqGjTAuny8MdgE88scJnCiQSlSrOWcTQgM2t32UBe+MUmFSO5t7VMSfAf/FJKImAxBav8ooCHJXCJA== - dependencies: - postcss-selector-parser "^7.0.0" - -postcss-modules-values@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/postcss-modules-values/-/postcss-modules-values-4.0.0.tgz#d7c5e7e68c3bb3c9b27cbf48ca0bb3ffb4602c9c" - integrity sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ== - dependencies: - icss-utils "^5.0.0" - -postcss-nested@5.0.6: - version "5.0.6" - resolved "https://registry.yarnpkg.com/postcss-nested/-/postcss-nested-5.0.6.tgz#466343f7fc8d3d46af3e7dba3fcd47d052a945bc" - integrity sha512-rKqm2Fk0KbA8Vt3AdGN0FB9OBOMDVajMG6ZCf/GoHgdxUJ4sBFp0A/uMIRm+MJUdo33YXEtjqIz8u7DAp8B7DA== - dependencies: - postcss-selector-parser "^6.0.6" - -postcss-nested@^6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/postcss-nested/-/postcss-nested-6.2.0.tgz#4c2d22ab5f20b9cb61e2c5c5915950784d068131" - integrity sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ== - dependencies: - postcss-selector-parser "^6.1.1" - -postcss-nesting@^13.0.2: - version "13.0.2" - resolved "https://registry.yarnpkg.com/postcss-nesting/-/postcss-nesting-13.0.2.tgz#fde0d4df772b76d03b52eccc84372e8d1ca1402e" - integrity sha512-1YCI290TX+VP0U/K/aFxzHzQWHWURL+CtHMSbex1lCdpXD1SoR2sYuxDu5aNI9lPoXpKTCggFZiDJbwylU0LEQ== - dependencies: - "@csstools/selector-resolve-nested" "^3.1.0" - "@csstools/selector-specificity" "^5.0.0" - postcss-selector-parser "^7.0.0" - -postcss-opacity-percentage@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/postcss-opacity-percentage/-/postcss-opacity-percentage-3.0.0.tgz#0b0db5ed5db5670e067044b8030b89c216e1eb0a" - integrity sha512-K6HGVzyxUxd/VgZdX04DCtdwWJ4NGLG212US4/LA1TLAbHgmAsTWVR86o+gGIbFtnTkfOpb9sCRBx8K7HO66qQ== - -postcss-overflow-shorthand@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/postcss-overflow-shorthand/-/postcss-overflow-shorthand-6.0.0.tgz#f5252b4a2ee16c68cd8a9029edb5370c4a9808af" - integrity sha512-BdDl/AbVkDjoTofzDQnwDdm/Ym6oS9KgmO7Gr+LHYjNWJ6ExORe4+3pcLQsLA9gIROMkiGVjjwZNoL/mpXHd5Q== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-page-break@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/postcss-page-break/-/postcss-page-break-3.0.4.tgz#7fbf741c233621622b68d435babfb70dd8c1ee5f" - integrity sha512-1JGu8oCjVXLa9q9rFTo4MbeeA5FMe00/9C7lN4va606Rdb+HkxXtXsmEDrIraQ11fGz/WvKWa8gMuCKkrXpTsQ== - -postcss-place@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/postcss-place/-/postcss-place-10.0.0.tgz#ba36ee4786ca401377ced17a39d9050ed772e5a9" - integrity sha512-5EBrMzat2pPAxQNWYavwAfoKfYcTADJ8AXGVPcUZ2UkNloUTWzJQExgrzrDkh3EKzmAx1evfTAzF9I8NGcc+qw== - dependencies: - postcss-value-parser "^4.2.0" - -postcss-preset-env@^10.4.0: - version "10.4.0" - resolved "https://registry.yarnpkg.com/postcss-preset-env/-/postcss-preset-env-10.4.0.tgz#fa6167a307f337b2bcdd1d125604ff97cdeb5142" - integrity sha512-2kqpOthQ6JhxqQq1FSAAZGe9COQv75Aw8WbsOvQVNJ2nSevc9Yx/IKZGuZ7XJ+iOTtVon7LfO7ELRzg8AZ+sdw== - dependencies: - "@csstools/postcss-alpha-function" "^1.0.1" - "@csstools/postcss-cascade-layers" "^5.0.2" - "@csstools/postcss-color-function" "^4.0.12" - "@csstools/postcss-color-function-display-p3-linear" "^1.0.1" - "@csstools/postcss-color-mix-function" "^3.0.12" - "@csstools/postcss-color-mix-variadic-function-arguments" "^1.0.2" - "@csstools/postcss-content-alt-text" "^2.0.8" - "@csstools/postcss-contrast-color-function" "^2.0.12" - "@csstools/postcss-exponential-functions" "^2.0.9" - "@csstools/postcss-font-format-keywords" "^4.0.0" - "@csstools/postcss-gamut-mapping" "^2.0.11" - "@csstools/postcss-gradients-interpolation-method" "^5.0.12" - "@csstools/postcss-hwb-function" "^4.0.12" - "@csstools/postcss-ic-unit" "^4.0.4" - "@csstools/postcss-initial" "^2.0.1" - "@csstools/postcss-is-pseudo-class" "^5.0.3" - "@csstools/postcss-light-dark-function" "^2.0.11" - "@csstools/postcss-logical-float-and-clear" "^3.0.0" - "@csstools/postcss-logical-overflow" "^2.0.0" - "@csstools/postcss-logical-overscroll-behavior" "^2.0.0" - "@csstools/postcss-logical-resize" "^3.0.0" - "@csstools/postcss-logical-viewport-units" "^3.0.4" - "@csstools/postcss-media-minmax" "^2.0.9" - "@csstools/postcss-media-queries-aspect-ratio-number-values" "^3.0.5" - "@csstools/postcss-nested-calc" "^4.0.0" - "@csstools/postcss-normalize-display-values" "^4.0.0" - "@csstools/postcss-oklab-function" "^4.0.12" - "@csstools/postcss-progressive-custom-properties" "^4.2.1" - "@csstools/postcss-random-function" "^2.0.1" - "@csstools/postcss-relative-color-syntax" "^3.0.12" - "@csstools/postcss-scope-pseudo-class" "^4.0.1" - "@csstools/postcss-sign-functions" "^1.1.4" - "@csstools/postcss-stepped-value-functions" "^4.0.9" - "@csstools/postcss-text-decoration-shorthand" "^4.0.3" - "@csstools/postcss-trigonometric-functions" "^4.0.9" - "@csstools/postcss-unset-value" "^4.0.0" - autoprefixer "^10.4.21" - browserslist "^4.26.0" - css-blank-pseudo "^7.0.1" - css-has-pseudo "^7.0.3" - css-prefers-color-scheme "^10.0.0" - cssdb "^8.4.2" - postcss-attribute-case-insensitive "^7.0.1" - postcss-clamp "^4.1.0" - postcss-color-functional-notation "^7.0.12" - postcss-color-hex-alpha "^10.0.0" - postcss-color-rebeccapurple "^10.0.0" - postcss-custom-media "^11.0.6" - postcss-custom-properties "^14.0.6" - postcss-custom-selectors "^8.0.5" - postcss-dir-pseudo-class "^9.0.1" - postcss-double-position-gradients "^6.0.4" - postcss-focus-visible "^10.0.1" - postcss-focus-within "^9.0.1" - postcss-font-variant "^5.0.0" - postcss-gap-properties "^6.0.0" - postcss-image-set-function "^7.0.0" - postcss-lab-function "^7.0.12" - postcss-logical "^8.1.0" - postcss-nesting "^13.0.2" - postcss-opacity-percentage "^3.0.0" - postcss-overflow-shorthand "^6.0.0" - postcss-page-break "^3.0.4" - postcss-place "^10.0.0" - postcss-pseudo-class-any-link "^10.0.1" - postcss-replace-overflow-wrap "^4.0.0" - postcss-selector-not "^8.0.1" - -postcss-pseudo-class-any-link@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/postcss-pseudo-class-any-link/-/postcss-pseudo-class-any-link-10.0.1.tgz#06455431171bf44b84d79ebaeee9fd1c05946544" - integrity sha512-3el9rXlBOqTFaMFkWDOkHUTQekFIYnaQY55Rsp8As8QQkpiSgIYEcF/6Ond93oHiDsGb4kad8zjt+NPlOC1H0Q== - dependencies: - postcss-selector-parser "^7.0.0" - -postcss-replace-overflow-wrap@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/postcss-replace-overflow-wrap/-/postcss-replace-overflow-wrap-4.0.0.tgz#d2df6bed10b477bf9c52fab28c568b4b29ca4319" - integrity sha512-KmF7SBPphT4gPPcKZc7aDkweHiKEEO8cla/GjcBK+ckKxiZslIu3C4GCRW3DNfL0o7yW7kMQu9xlZ1kXRXLXtw== - -postcss-selector-not@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/postcss-selector-not/-/postcss-selector-not-8.0.1.tgz#f2df9c6ac9f95e9fe4416ca41a957eda16130172" - integrity sha512-kmVy/5PYVb2UOhy0+LqUYAhKj7DUGDpSWa5LZqlkWJaaAV+dxxsOG3+St0yNLu6vsKD7Dmqx+nWQt0iil89+WA== - dependencies: - postcss-selector-parser "^7.0.0" - -postcss-selector-parser@^6.0.6, postcss-selector-parser@^6.1.1, postcss-selector-parser@^6.1.2: - version "6.1.2" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz#27ecb41fb0e3b6ba7a1ec84fff347f734c7929de" - integrity sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg== - dependencies: - cssesc "^3.0.0" - util-deprecate "^1.0.2" - -postcss-selector-parser@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz#4d6af97eba65d73bc4d84bcb343e865d7dd16262" - integrity sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA== - dependencies: - cssesc "^3.0.0" - util-deprecate "^1.0.2" - -postcss-value-parser@^3.3.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281" - integrity sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ== - -postcss-value-parser@^4.0.0, postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" - integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== - -postcss@^8.1.6, postcss@^8.1.8, postcss@^8.3.5, postcss@^8.4.33, postcss@^8.4.47, postcss@^8.5.6: - version "8.5.6" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.6.tgz#2825006615a619b4f62a9e7426cc120b349a8f3c" - integrity sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg== - dependencies: - nanoid "^3.3.11" - picocolors "^1.1.1" - source-map-js "^1.2.1" - -prelude-ls@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" - integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== - -prettier-linter-helpers@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" - integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== - dependencies: - fast-diff "^1.1.2" - -prettier@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" - integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== - -pretty-format@^27.0.2: - version "27.5.1" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e" - integrity sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ== - dependencies: - ansi-regex "^5.0.1" - ansi-styles "^5.0.0" - react-is "^17.0.1" - -pretty-format@^28.0.0, pretty-format@^28.1.3: - version "28.1.3" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-28.1.3.tgz#c9fba8cedf99ce50963a11b27d982a9ae90970d5" - integrity sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q== - dependencies: - "@jest/schemas" "^28.1.3" - ansi-regex "^5.0.1" - ansi-styles "^5.0.0" - react-is "^18.0.0" - -pretty-hrtime@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" - integrity sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A== - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== - -prompts@^2.0.1: - version "2.4.2" - resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" - integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== - dependencies: - kleur "^3.0.3" - sisteransi "^1.0.5" - -prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: - version "15.8.1" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" - integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== - dependencies: - loose-envify "^1.4.0" - object-assign "^4.1.1" - react-is "^16.13.1" - -property-expr@^2.0.2: - version "2.0.6" - resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-2.0.6.tgz#f77bc00d5928a6c748414ad12882e83f24aec1e8" - integrity sha512-SVtmxhRE/CGkn3eZY1T6pC8Nln6Fr/lu1mKSgRud0eC73whjGfoAogbn78LkD8aFL0zz3bAFerKSnOl7NlErBA== - -proxy-addr@~2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" - integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== - dependencies: - forwarded "0.2.0" - ipaddr.js "1.9.1" - -proxy-from-env@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" - integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== - -punycode@^2.1.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" - integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== - -purgecss@^4.0.3: - version "4.1.3" - resolved "https://registry.yarnpkg.com/purgecss/-/purgecss-4.1.3.tgz#683f6a133c8c4de7aa82fe2746d1393b214918f7" - integrity sha512-99cKy4s+VZoXnPxaoM23e5ABcP851nC2y2GROkkjS8eJaJtlciGavd7iYAw2V84WeBqggZ12l8ef44G99HmTaw== - dependencies: - commander "^8.0.0" - glob "^7.1.7" - postcss "^8.3.5" - postcss-selector-parser "^6.0.6" - -pvtsutils@^1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.3.6.tgz#ec46e34db7422b9e4fdc5490578c1883657d6001" - integrity sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg== - dependencies: - tslib "^2.8.1" - -pvutils@^1.1.3: - version "1.1.5" - resolved "https://registry.yarnpkg.com/pvutils/-/pvutils-1.1.5.tgz#84b0dea4a5d670249aa9800511804ee0b7c2809c" - integrity sha512-KTqnxsgGiQ6ZAzZCVlJH5eOjSnvlyEgx1m8bkRJfOhmGRqfo5KLvmAlACQkrjEtOQ4B7wF9TdSLIs9O90MX9xA== - -qr.js@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/qr.js/-/qr.js-0.0.0.tgz#cace86386f59a0db8050fa90d9b6b0e88a1e364f" - integrity sha1-ys6GOG9ZoNuAUPqQ2baw6IoeNk8= - -qrcode.react@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/qrcode.react/-/qrcode.react-1.0.1.tgz#2834bb50e5e275ffe5af6906eff15391fe9e38a5" - integrity sha512-8d3Tackk8IRLXTo67Y+c1rpaiXjoz/Dd2HpcMdW//62/x8J1Nbho14Kh8x974t9prsLHN6XqVgcnRiBGFptQmg== - dependencies: - loose-envify "^1.4.0" - prop-types "^15.6.0" - qr.js "0.0.0" - -qs@~6.14.0: - version "6.14.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.14.2.tgz#b5634cf9d9ad9898e31fba3504e866e8efb6798c" - integrity sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q== - dependencies: - side-channel "^1.1.0" - -queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== - -quick-lru@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" - integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -range-parser@^1.2.1, range-parser@~1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" - integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== - -raw-body@~2.5.3: - version "2.5.3" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.3.tgz#11c6650ee770a7de1b494f197927de0c923822e2" - integrity sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA== - dependencies: - bytes "~3.1.2" - http-errors "~2.0.1" - iconv-lite "~0.4.24" - unpipe "~1.0.0" - -react-chartjs-2@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/react-chartjs-2/-/react-chartjs-2-4.2.0.tgz#bc5693a8b161f125301cf28ab0fe980d7dce54aa" - integrity sha512-9Vm9Sg9XAKiR579/FnBkesofjW9goaaFLfS7XlGTzUJlWFZGSE6A/pBI6+i/bP3pobKZoFcWJdFnjShytToqXw== - -"react-dom@npm:@hot-loader/react-dom": - version "16.11.0" - resolved "https://registry.yarnpkg.com/@hot-loader/react-dom/-/react-dom-16.11.0.tgz#c0b483923b289db5431516f56ee2a69448ebf9bd" - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" - scheduler "^0.17.0" - -react-fast-compare@^2.0.1: - version "2.0.4" - resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9" - integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw== - -react-fast-compare@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb" - integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA== - -react-hot-loader@^4.12.21: - version "4.13.1" - resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.13.1.tgz#979fd7598e27338b3faffae6ed01c65374dace5e" - integrity sha512-ZlqCfVRqDJmMXTulUGic4lN7Ic1SXgHAFw7y/Jb7t25GBgTR0fYAJ8uY4mrpxjRyWGWmqw77qJQGnYbzCvBU7g== - dependencies: - fast-levenshtein "^2.0.6" - global "^4.3.0" - hoist-non-react-statics "^3.3.0" - loader-utils "^2.0.3" - prop-types "^15.6.1" - react-lifecycles-compat "^3.0.4" - shallowequal "^1.1.0" - source-map "^0.7.3" - -react-i18next@^16.5.4: - version "16.5.4" - resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-16.5.4.tgz#4f458b1baab274dca439ab67629c854203bf97c6" - integrity sha512-6yj+dcfMncEC21QPhOTsW8mOSO+pzFmT6uvU7XXdvM/Cp38zJkmTeMeKmTrmCMD5ToT79FmiE/mRWiYWcJYW4g== - dependencies: - "@babel/runtime" "^7.28.4" - html-parse-stringify "^3.0.1" - use-sync-external-store "^1.6.0" - -react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" - integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== - -react-is@^17.0.1: - version "17.0.2" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" - integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== - -react-is@^18.0.0: - version "18.3.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" - integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== - -react-lifecycles-compat@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" - integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA== - -react-router-dom@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.1.2.tgz#06701b834352f44d37fbb6311f870f84c76b9c18" - dependencies: - "@babel/runtime" "^7.1.2" - history "^4.9.0" - loose-envify "^1.3.1" - prop-types "^15.6.2" - react-router "5.1.2" - tiny-invariant "^1.0.2" - tiny-warning "^1.0.0" - -react-router@5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/react-router/-/react-router-5.1.2.tgz#6ea51d789cb36a6be1ba5f7c0d48dd9e817d3418" - dependencies: - "@babel/runtime" "^7.1.2" - history "^4.9.0" - hoist-non-react-statics "^3.1.0" - loose-envify "^1.3.1" - mini-create-react-context "^0.3.0" - path-to-regexp "^1.7.0" - prop-types "^15.6.2" - react-is "^16.6.0" - tiny-invariant "^1.0.2" - tiny-warning "^1.0.0" - -react-transition-group@^4.4.1: - version "4.4.1" - resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.1.tgz#63868f9325a38ea5ee9535d828327f85773345c9" - integrity sha512-Djqr7OQ2aPUiYurhPalTrVy9ddmFCCzwhqQmtN+J3+3DzLO209Fdr70QrN8Z3DsglWql6iY1lDWAfpFiBtuKGw== - dependencies: - "@babel/runtime" "^7.5.5" - dom-helpers "^5.0.1" - loose-envify "^1.4.0" - prop-types "^15.6.2" - -react@^16.14.0: - version "16.14.0" - resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d" - integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.2" - -read-cache@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/read-cache/-/read-cache-1.0.0.tgz#e664ef31161166c9751cdbe8dbcf86b5fb58f774" - integrity sha1-5mTvMRYRZsl1HNvo28+GtftY93Q= - dependencies: - pify "^2.3.0" - -readable-stream@^2.0.1: - version "2.3.8" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" - integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readable-stream@^3.0.6: - version "3.6.2" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" - integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -reaptcha@^1.7.2: - version "1.7.2" - resolved "https://registry.yarnpkg.com/reaptcha/-/reaptcha-1.7.2.tgz#d829f54270c241f46501e92a5a7badeb1fcf372d" - integrity sha512-/RXiPeMd+fPUGByv+kAaQlCXCsSflZ9bKX5Fcwv9IYGS1oyT2nntL/8zn9IaiUFHL66T1jBtOABcb92g2+3w8w== - -rechoir@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.8.0.tgz#49f866e0d32146142da3ad8f0eff352b3215ff22" - integrity sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ== - dependencies: - resolve "^1.20.0" - -redent@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" - integrity sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg== - dependencies: - indent-string "^4.0.0" - strip-indent "^3.0.0" - -reduce-css-calc@^2.1.8: - version "2.1.8" - resolved "https://registry.yarnpkg.com/reduce-css-calc/-/reduce-css-calc-2.1.8.tgz#7ef8761a28d614980dc0c982f772c93f7a99de03" - integrity sha512-8liAVezDmUcH+tdzoEGrhfbGcP7nOV4NkGE3a74+qqvE7nt9i4sKLGBuZNOnpI4WiGksiNPklZxva80061QiPg== - dependencies: - css-unit-converter "^1.1.1" - postcss-value-parser "^3.3.0" - -redux-devtools-extension@^2.13.8: - version "2.13.8" - resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.8.tgz#37b982688626e5e4993ff87220c9bbb7cd2d96e1" - -redux-thunk@^2.3.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.4.2.tgz#b9d05d11994b99f7a91ea223e8b04cf0afa5ef3b" - integrity sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q== - -redux@^4.0.0: - version "4.0.5" - resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f" - integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w== - dependencies: - loose-envify "^1.4.0" - symbol-observable "^1.2.0" - -redux@^4.0.5: - version "4.2.1" - resolved "https://registry.yarnpkg.com/redux/-/redux-4.2.1.tgz#c08f4306826c49b5e9dc901dee0452ea8fce6197" - integrity sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w== - dependencies: - "@babel/runtime" "^7.9.2" - -reflect-metadata@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.2.2.tgz#400c845b6cba87a21f2c65c4aeb158f4fa4d9c5b" - integrity sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q== - -reflect.getprototypeof@^1.0.6, reflect.getprototypeof@^1.0.9: - version "1.0.10" - resolved "https://registry.yarnpkg.com/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz#c629219e78a3316d8b604c765ef68996964e7bf9" - integrity sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw== - dependencies: - call-bind "^1.0.8" - define-properties "^1.2.1" - es-abstract "^1.23.9" - es-errors "^1.3.0" - es-object-atoms "^1.0.0" - get-intrinsic "^1.2.7" - get-proto "^1.0.1" - which-builtin-type "^1.2.1" - -regenerate-unicode-properties@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" - integrity sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA== - dependencies: - regenerate "^1.4.0" - -regenerate@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" - -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== - -regenerator-runtime@^0.13.4: - version "0.13.11" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" - integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== - -regenerator-transform@^0.14.2: - version "0.14.5" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4" - integrity sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw== - dependencies: - "@babel/runtime" "^7.8.4" - -regexp.prototype.flags@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" - integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - functions-have-names "^1.2.2" - -regexp.prototype.flags@^1.5.3, regexp.prototype.flags@^1.5.4: - version "1.5.4" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz#1ad6c62d44a259007e55b3970e00f746efbcaa19" - integrity sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA== - dependencies: - call-bind "^1.0.8" - define-properties "^1.2.1" - es-errors "^1.3.0" - get-proto "^1.0.1" - gopd "^1.2.0" - set-function-name "^2.0.2" - -regexpu-core@^4.7.1: - version "4.7.1" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.1.tgz#2dea5a9a07233298fbf0db91fa9abc4c6e0f8ad6" - integrity sha512-ywH2VUraA44DZQuRKzARmw6S66mr48pQVva4LBeRhcOltJ6hExvWly5ZjFLYo67xbIxb6W1q4bAGtgfEl20zfQ== - dependencies: - regenerate "^1.4.0" - regenerate-unicode-properties "^8.2.0" - regjsgen "^0.5.1" - regjsparser "^0.6.4" - unicode-match-property-ecmascript "^1.0.4" - unicode-match-property-value-ecmascript "^1.2.0" - -regjsgen@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.2.tgz#92ff295fb1deecbf6ecdab2543d207e91aa33733" - integrity sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A== - -regjsparser@^0.6.4: - version "0.6.4" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.4.tgz#a769f8684308401a66e9b529d2436ff4d0666272" - integrity sha512-64O87/dPDgfk8/RQqC4gkZoGyyWFIEUTTh80CU6CWuK5vkCGyekIx+oKcEIYtP/RAxSQltCZHCNu/mdd7fqlJw== - dependencies: - jsesc "~0.5.0" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== - -require-from-string@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" - integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== - -requireindex@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef" - integrity sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww== - -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== - -resize-observer-polyfill@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464" - integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg== - -resolve-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" - integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== - dependencies: - resolve-from "^5.0.0" - -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== - -resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" - integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== - -resolve-pathname@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.2.0.tgz#7e9ae21ed815fd63ab189adeee64dc831eefa879" - -resolve.exports@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.1.tgz#05cfd5b3edf641571fd46fa608b610dda9ead999" - integrity sha512-/NtpHNDN7jWhAaQ9BvBUYZ6YTXsRBgfqWFWP7BZBaoMJO/I3G5OFzvTuWNlZC3aPjins1F+TNrLKsGbH4rfsRQ== - -resolve@^1.1.7, resolve@^1.8.1: - version "1.22.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" - integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== - dependencies: - is-core-module "^2.8.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -resolve@^1.12.0, resolve@^1.20.0, resolve@^1.22.8: - version "1.22.11" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.11.tgz#aad857ce1ffb8bfa9b0b1ac29f1156383f68c262" - integrity sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ== - dependencies: - is-core-module "^2.16.1" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -resolve@^2.0.0-next.5: - version "2.0.0-next.5" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.5.tgz#6b0ec3107e671e52b68cd068ef327173b90dc03c" - integrity sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA== - dependencies: - is-core-module "^2.13.0" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -retry@^0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" - integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== - -reusify@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.1.0.tgz#0fe13b9522e1473f51b558ee796e08f11f9b489f" - integrity sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw== - -rgb-regex@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/rgb-regex/-/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1" - integrity sha512-gDK5mkALDFER2YLqH6imYvK6g02gpNGM4ILDZ472EwWfXZnC2ZEpoB2ECXTyOVUKuk/bPJZMzwQPBYICzP+D3w== - -rgba-regex@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3" - integrity sha512-zgn5OjNQXLUTdq8m17KdaicF6w89TZs8ZU8y0AYENIU6wG8GG6LLm0yLSiPY8DmaYmHdgRW8rnApjoT0fQRfMg== - -rimraf@^3.0.0, rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - -run-applescript@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/run-applescript/-/run-applescript-7.1.0.tgz#2e9e54c4664ec3106c5b5630e249d3d6595c4911" - integrity sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q== - -run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== - dependencies: - queue-microtask "^1.2.2" - -rxjs-compat@^6.5.4: - version "6.6.3" - resolved "https://registry.yarnpkg.com/rxjs-compat/-/rxjs-compat-6.6.3.tgz#141405fcee11f48718d428b99c8f01826f594e5c" - integrity sha512-y+wUqq7bS2dG+7rH2fNMoxsDiJ32RQzFxZQE/JdtpnmEZmwLQrb1tCiItyHxdXJHXjmHnnzFscn3b6PEmORGKw== - -safe-array-concat@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/safe-array-concat/-/safe-array-concat-1.1.3.tgz#c9e54ec4f603b0bbb8e7e5007a5ee7aecd1538c3" - integrity sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.2" - get-intrinsic "^1.2.6" - has-symbols "^1.1.0" - isarray "^2.0.5" - -safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.1.0, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-push-apply@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/safe-push-apply/-/safe-push-apply-1.0.0.tgz#01850e981c1602d398c85081f360e4e6d03d27f5" - integrity sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA== - dependencies: - es-errors "^1.3.0" - isarray "^2.0.5" - -safe-regex-test@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.1.0.tgz#7f87dfb67a3150782eaaf18583ff5d1711ac10c1" - integrity sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw== - dependencies: - call-bound "^1.0.2" - es-errors "^1.3.0" - is-regex "^1.2.1" - -"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - -scheduler@^0.17.0: - version "0.17.0" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.17.0.tgz#7c9c673e4ec781fac853927916d1c426b6f3ddfe" - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - -scheduler@^0.19.1: - version "0.19.1" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196" - integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - -schema-utils@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" - integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== - dependencies: - "@types/json-schema" "^7.0.8" - ajv "^6.12.5" - ajv-keywords "^3.5.2" - -schema-utils@^4.0.0, schema-utils@^4.2.0, schema-utils@^4.3.0, schema-utils@^4.3.3: - version "4.3.3" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.3.3.tgz#5b1850912fa31df90716963d45d9121fdfc09f46" - integrity sha512-eflK8wEtyOE6+hsaRVPxvUKYCpRgzLqDTb8krvAsRIwOGlHoSgYLgBXoubGgLd2fT41/OUYdb48v4k4WWHQurA== - dependencies: - "@types/json-schema" "^7.0.9" - ajv "^8.9.0" - ajv-formats "^2.1.1" - ajv-keywords "^5.1.0" - -select-hose@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" - integrity sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg== - -selfsigned@^5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-5.5.0.tgz#4c9ab7c7c9f35f18fb6a9882c253eb0e6bd6557b" - integrity sha512-ftnu3TW4+3eBfLRFnDEkzGxSF/10BJBkaLJuBHZX0kiPS7bRdlpZGu6YGt4KngMkdTwJE6MbjavFpqHvqVt+Ew== - dependencies: - "@peculiar/x509" "^1.14.2" - pkijs "^3.3.3" - -semver@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - -semver@7.x, semver@^7.3.5, semver@^7.5.3, semver@^7.5.4, semver@^7.6.2: - version "7.7.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.3.tgz#4b5f4143d007633a8dc671cd0a6ef9147b8bb946" - integrity sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q== - -semver@^5.5.0: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== - -semver@^5.5.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - -semver@^6.3.0, semver@^6.3.1: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== - -semver@^7.3.7: - version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== - dependencies: - lru-cache "^6.0.0" - -send@~0.19.0, send@~0.19.1: - version "0.19.2" - resolved "https://registry.yarnpkg.com/send/-/send-0.19.2.tgz#59bc0da1b4ea7ad42736fd642b1c4294e114ff29" - integrity sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg== - dependencies: - debug "2.6.9" - depd "2.0.0" - destroy "1.2.0" - encodeurl "~2.0.0" - escape-html "~1.0.3" - etag "~1.8.1" - fresh "~0.5.2" - http-errors "~2.0.1" - mime "1.6.0" - ms "2.1.3" - on-finished "~2.4.1" - range-parser "~1.2.1" - statuses "~2.0.2" - -serialize-javascript@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" - integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== - dependencies: - randombytes "^2.1.0" - -serve-index@^1.9.1: - version "1.9.2" - resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.2.tgz#2988e3612106d78a5e4849ddff552ce7bd3d9bcb" - integrity sha512-KDj11HScOaLmrPxl70KYNW1PksP4Nb/CLL2yvC+Qd2kHMPEEpfc4Re2e4FOay+bC/+XQl/7zAcWON3JVo5v3KQ== - dependencies: - accepts "~1.3.8" - batch "0.6.1" - debug "2.6.9" - escape-html "~1.0.3" - http-errors "~1.8.0" - mime-types "~2.1.35" - parseurl "~1.3.3" - -serve-static@~1.16.2: - version "1.16.3" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.16.3.tgz#a97b74d955778583f3862a4f0b841eb4d5d78cf9" - integrity sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA== - dependencies: - encodeurl "~2.0.0" - escape-html "~1.0.3" - parseurl "~1.3.3" - send "~0.19.1" - -set-function-length@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" - integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== - dependencies: - define-data-property "^1.1.4" - es-errors "^1.3.0" - function-bind "^1.1.2" - get-intrinsic "^1.2.4" - gopd "^1.0.1" - has-property-descriptors "^1.0.2" - -set-function-name@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/set-function-name/-/set-function-name-2.0.2.tgz#16a705c5a0dc2f5e638ca96d8a8cd4e1c2b90985" - integrity sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ== - dependencies: - define-data-property "^1.1.4" - es-errors "^1.3.0" - functions-have-names "^1.2.3" - has-property-descriptors "^1.0.2" - -set-proto@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/set-proto/-/set-proto-1.0.0.tgz#0760dbcff30b2d7e801fd6e19983e56da337565e" - integrity sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw== - dependencies: - dunder-proto "^1.0.1" - es-errors "^1.3.0" - es-object-atoms "^1.0.0" - -setprototypeof@1.2.0, setprototypeof@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" - integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== - -shallow-clone@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" - integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== - dependencies: - kind-of "^6.0.2" - -shallowequal@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8" - integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ== - -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - -shell-quote@^1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.3.tgz#55e40ef33cf5c689902353a3d8cd1a6725f08b4b" - integrity sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw== - -side-channel-list@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/side-channel-list/-/side-channel-list-1.0.0.tgz#10cb5984263115d3b7a0e336591e290a830af8ad" - integrity sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA== - dependencies: - es-errors "^1.3.0" - object-inspect "^1.13.3" - -side-channel-map@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/side-channel-map/-/side-channel-map-1.0.1.tgz#d6bb6b37902c6fef5174e5f533fab4c732a26f42" - integrity sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA== - dependencies: - call-bound "^1.0.2" - es-errors "^1.3.0" - get-intrinsic "^1.2.5" - object-inspect "^1.13.3" - -side-channel-weakmap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz#11dda19d5368e40ce9ec2bdc1fb0ecbc0790ecea" - integrity sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A== - dependencies: - call-bound "^1.0.2" - es-errors "^1.3.0" - get-intrinsic "^1.2.5" - object-inspect "^1.13.3" - side-channel-map "^1.0.1" - -side-channel@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" - integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== - dependencies: - call-bind "^1.0.0" - get-intrinsic "^1.0.2" - object-inspect "^1.9.0" - -side-channel@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.1.0.tgz#c3fcff9c4da932784873335ec9765fa94ff66bc9" - integrity sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw== - dependencies: - es-errors "^1.3.0" - object-inspect "^1.13.3" - side-channel-list "^1.0.0" - side-channel-map "^1.0.1" - side-channel-weakmap "^1.0.2" - -signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: - version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - -simple-swizzle@^0.2.2: - version "0.2.4" - resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.4.tgz#a8d11a45a11600d6a1ecdff6363329e3648c3667" - integrity sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw== - dependencies: - is-arrayish "^0.3.1" - -sisteransi@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" - integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -sockette@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/sockette/-/sockette-2.0.6.tgz#63b533f3cfe3b592fc84178beea6577fa18cebf3" - -sockjs@^0.3.24: - version "0.3.24" - resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.24.tgz#c9bc8995f33a111bea0395ec30aa3206bdb5ccce" - integrity sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ== - dependencies: - faye-websocket "^0.11.3" - uuid "^8.3.2" - websocket-driver "^0.7.4" - -source-map-js@^1.0.2, source-map-js@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" - integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== - -source-map-loader@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-5.0.0.tgz#f593a916e1cc54471cfc8851b905c8a845fc7e38" - integrity sha512-k2Dur7CbSLcAH73sBcIkV5xjPV4SzqO1NJ7+XaQl8if3VODDUj3FNchNGpqgJSKbvUfJuhVdv8K2Eu8/TNl2eA== - dependencies: - iconv-lite "^0.6.3" - source-map-js "^1.0.2" - -source-map-resolve@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2" - integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w== - dependencies: - atob "^2.1.2" - decode-uri-component "^0.2.0" - -source-map-support@0.5.13: - version "0.5.13" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" - integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map-support@~0.5.20: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0, source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -source-map@^0.7.3: - version "0.7.6" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.6.tgz#a3658ab87e5b6429c8a1f3ba0083d4c61ca3ef02" - integrity sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ== - -spdy-transport@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/spdy-transport/-/spdy-transport-3.0.0.tgz#00d4863a6400ad75df93361a1608605e5dcdcf31" - integrity sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw== - dependencies: - debug "^4.1.0" - detect-node "^2.0.4" - hpack.js "^2.1.6" - obuf "^1.1.2" - readable-stream "^3.0.6" - wbuf "^1.7.3" - -spdy@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/spdy/-/spdy-4.0.2.tgz#b74f466203a3eda452c02492b91fb9e84a27677b" - integrity sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA== - dependencies: - debug "^4.1.0" - handle-thing "^2.0.0" - http-deceiver "^1.2.7" - select-hose "^2.0.0" - spdy-transport "^3.0.0" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== - -stack-utils@^2.0.3: - version "2.0.6" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" - integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== - dependencies: - escape-string-regexp "^2.0.0" - -"statuses@>= 1.5.0 < 2": - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== - -statuses@~2.0.1, statuses@~2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.2.tgz#8f75eecef765b5e1cfcdc080da59409ed424e382" - integrity sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw== - -stop-iteration-iterator@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz#f481ff70a548f6124d0312c3aa14cbfa7aa542ad" - integrity sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ== - dependencies: - es-errors "^1.3.0" - internal-slot "^1.1.0" - -string-length@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" - integrity sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ== - dependencies: - char-regex "^1.0.2" - strip-ansi "^6.0.0" - -string-similarity@^4.0.3: - version "4.0.4" - resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-4.0.4.tgz#42d01ab0b34660ea8a018da8f56a3309bb8b2a5b" - integrity sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ== - -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string.prototype.matchall@^4.0.12: - version "4.0.12" - resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.12.tgz#6c88740e49ad4956b1332a911e949583a275d4c0" - integrity sha512-6CC9uyBL+/48dYizRf7H7VAYCMCNTBeM78x/VTUe9bFEaxBepPJDa1Ow99LqI/1yF7kuy7Q3cQsYMrcjGUcskA== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.3" - define-properties "^1.2.1" - es-abstract "^1.23.6" - es-errors "^1.3.0" - es-object-atoms "^1.0.0" - get-intrinsic "^1.2.6" - gopd "^1.2.0" - has-symbols "^1.1.0" - internal-slot "^1.1.0" - regexp.prototype.flags "^1.5.3" - set-function-name "^2.0.2" - side-channel "^1.1.0" - -string.prototype.repeat@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/string.prototype.repeat/-/string.prototype.repeat-1.0.0.tgz#e90872ee0308b29435aa26275f6e1b762daee01a" - integrity sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -string.prototype.trim@^1.2.10: - version "1.2.10" - resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz#40b2dd5ee94c959b4dcfb1d65ce72e90da480c81" - integrity sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.2" - define-data-property "^1.1.4" - define-properties "^1.2.1" - es-abstract "^1.23.5" - es-object-atoms "^1.0.0" - has-property-descriptors "^1.0.2" - -string.prototype.trimend@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz#914a65baaab25fbdd4ee291ca7dde57e869cb8d0" - integrity sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" - es-abstract "^1.19.5" - -string.prototype.trimend@^1.0.9: - version "1.0.9" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.9.tgz#62e2731272cd285041b36596054e9f66569b6942" - integrity sha512-G7Ok5C6E/j4SGfyLCloXTrngQIQU3PWtXGst3yM7Bea9FRURf1S42ZHlZZtsNque2FN2PoUhfZXYLNWwEr4dLQ== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.2" - define-properties "^1.2.1" - es-object-atoms "^1.0.0" - -string.prototype.trimstart@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz#5466d93ba58cfa2134839f81d7f42437e8c01fef" - integrity sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" - es-abstract "^1.19.5" - -string.prototype.trimstart@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz#7ee834dda8c7c17eff3118472bb35bfedaa34dde" - integrity sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg== - dependencies: - call-bind "^1.0.7" - define-properties "^1.2.1" - es-object-atoms "^1.0.0" - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-bom@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" - integrity sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w== - -strip-final-newline@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" - integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== - -strip-indent@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" - integrity sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ== - dependencies: - min-indent "^1.0.0" - -strip-json-comments@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" - integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== - -style-loader@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-4.0.0.tgz#0ea96e468f43c69600011e0589cb05c44f3b17a5" - integrity sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA== - -style-value-types@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/style-value-types/-/style-value-types-5.0.0.tgz#76c35f0e579843d523187989da866729411fc8ad" - integrity sha512-08yq36Ikn4kx4YU6RD7jWEv27v4V+PUsOGa4n/as8Et3CuODMJQ00ENeAVXAeydX4Z2j1XHZF1K2sX4mGl18fA== - dependencies: - hey-listen "^1.0.8" - tslib "^2.1.0" - -styled-components-breakpoint@^3.0.0-preview.20: - version "3.0.0-preview.20" - resolved "https://registry.yarnpkg.com/styled-components-breakpoint/-/styled-components-breakpoint-3.0.0-preview.20.tgz#877e88a00c0cf66976f610a1d347839a1a0b6d70" - -styled-components@^5.3.0: - version "5.3.11" - resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-5.3.11.tgz#9fda7bf1108e39bf3f3e612fcc18170dedcd57a8" - integrity sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw== - dependencies: - "@babel/helper-module-imports" "^7.0.0" - "@babel/traverse" "^7.4.5" - "@emotion/is-prop-valid" "^1.1.0" - "@emotion/stylis" "^0.8.4" - "@emotion/unitless" "^0.7.4" - babel-plugin-styled-components ">= 1.12.0" - css-to-react-native "^3.0.0" - hoist-non-react-statics "^3.0.0" - shallowequal "^1.1.0" - supports-color "^5.5.0" - -sucrase@^3.35.0: - version "3.35.1" - resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.35.1.tgz#4619ea50393fe8bd0ae5071c26abd9b2e346bfe1" - integrity sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw== - dependencies: - "@jridgewell/gen-mapping" "^0.3.2" - commander "^4.0.0" - lines-and-columns "^1.1.6" - mz "^2.7.0" - pirates "^4.0.1" - tinyglobby "^0.2.11" - ts-interface-checker "^0.1.9" - -supports-color@^5.3.0, supports-color@^5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - dependencies: - has-flag "^3.0.0" - -supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -supports-hyperlinks@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz#3943544347c1ff90b15effb03fc14ae45ec10624" - integrity sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA== - dependencies: - has-flag "^4.0.0" - supports-color "^7.0.0" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -svg-url-loader@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/svg-url-loader/-/svg-url-loader-8.0.0.tgz#05d57af5b19d7caa39624a88e3cd535243634991" - integrity sha512-5doSXvl18hY1fGsRLdhWAU5jgzgxJ06/gc/26cpuDnN0xOz1HmmfhkpL29SSrdIvhtxQ1UwGzmk7wTT/l48mKw== - dependencies: - file-loader "~6.2.0" - -swr@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/swr/-/swr-0.2.3.tgz#e0fb260d27f12fafa2388312083368f45127480d" - integrity sha512-JhuuD5ojqgjAQpZAhoPBd8Di0Mr1+ykByVKuRJdtKaxkUX/y8kMACWKkLgLQc8pcDOKEAnbIreNjU7HfqI9nHQ== - dependencies: - fast-deep-equal "2.0.1" - -symbol-observable@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" - integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== - -symbol-observable@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-2.0.3.tgz#5b521d3d07a43c351055fa43b8355b62d33fd16a" - integrity sha512-sQV7phh2WCYAn81oAkakC5qjq2Ml0g8ozqz03wOGnx9dDlG1de6yrF+0RAzSJD8fPUow3PTSMf2SAbOGxb93BA== - -synchronous-promise@^2.0.13: - version "2.0.17" - resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.17.tgz#38901319632f946c982152586f2caf8ddc25c032" - integrity sha512-AsS729u2RHUfEra9xJrE39peJcc2stq2+poBXX8bcM08Y6g9j/i/PUzwNQqkaJde7Ntg1TO7bSREbR5sdosQ+g== - -tailwindcss@^2.2.7: - version "2.2.19" - resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-2.2.19.tgz#540e464832cd462bb9649c1484b0a38315c2653c" - integrity sha512-6Ui7JSVtXadtTUo2NtkBBacobzWiQYVjYW0ZnKaP9S1ZCKQ0w7KVNz+YSDI/j7O7KCMHbOkz94ZMQhbT9pOqjw== - dependencies: - arg "^5.0.1" - bytes "^3.0.0" - chalk "^4.1.2" - chokidar "^3.5.2" - color "^4.0.1" - cosmiconfig "^7.0.1" - detective "^5.2.0" - didyoumean "^1.2.2" - dlv "^1.1.3" - fast-glob "^3.2.7" - fs-extra "^10.0.0" - glob-parent "^6.0.1" - html-tags "^3.1.0" - is-color-stop "^1.1.0" - is-glob "^4.0.1" - lodash "^4.17.21" - lodash.topath "^4.5.2" - modern-normalize "^1.1.0" - node-emoji "^1.11.0" - normalize-path "^3.0.0" - object-hash "^2.2.0" - postcss-js "^3.0.3" - postcss-load-config "^3.1.0" - postcss-nested "5.0.6" - postcss-selector-parser "^6.0.6" - postcss-value-parser "^4.1.0" - pretty-hrtime "^1.0.3" - purgecss "^4.0.3" - quick-lru "^5.1.1" - reduce-css-calc "^2.1.8" - resolve "^1.20.0" - tmp "^0.2.1" - -tailwindcss@^3.0.24: - version "3.4.18" - resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.4.18.tgz#9fa9650aace186644b608242f1e57d2d55593301" - integrity sha512-6A2rnmW5xZMdw11LYjhcI5846rt9pbLSabY5XPxo+XWdxwZaFEn47Go4NzFiHu9sNNmr/kXivP1vStfvMaK1GQ== - dependencies: - "@alloc/quick-lru" "^5.2.0" - arg "^5.0.2" - chokidar "^3.6.0" - didyoumean "^1.2.2" - dlv "^1.1.3" - fast-glob "^3.3.2" - glob-parent "^6.0.2" - is-glob "^4.0.3" - jiti "^1.21.7" - lilconfig "^3.1.3" - micromatch "^4.0.8" - normalize-path "^3.0.0" - object-hash "^3.0.0" - picocolors "^1.1.1" - postcss "^8.4.47" - postcss-import "^15.1.0" - postcss-js "^4.0.1" - postcss-load-config "^4.0.2 || ^5.0 || ^6.0" - postcss-nested "^6.2.0" - postcss-selector-parser "^6.1.2" - resolve "^1.22.8" - sucrase "^3.35.0" - -tapable@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.3.0.tgz#7e3ea6d5ca31ba8e078b560f0d83ce9a14aa8be6" - integrity sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg== - -terminal-link@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" - integrity sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ== - dependencies: - ansi-escapes "^4.2.1" - supports-hyperlinks "^2.0.0" - -terser-webpack-plugin@^5.3.14: - version "5.3.14" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.14.tgz#9031d48e57ab27567f02ace85c7d690db66c3e06" - integrity sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw== - dependencies: - "@jridgewell/trace-mapping" "^0.3.25" - jest-worker "^27.4.5" - schema-utils "^4.3.0" - serialize-javascript "^6.0.2" - terser "^5.31.1" - -terser-webpack-plugin@^5.3.16: - version "5.3.16" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.16.tgz#741e448cc3f93d8026ebe4f7ef9e4afacfd56330" - integrity sha512-h9oBFCWrq78NyWWVcSwZarJkZ01c2AyGrzs1crmHZO3QUg9D61Wu4NPjBy69n7JqylFF5y+CsUZYmYEIZ3mR+Q== - dependencies: - "@jridgewell/trace-mapping" "^0.3.25" - jest-worker "^27.4.5" - schema-utils "^4.3.0" - serialize-javascript "^6.0.2" - terser "^5.31.1" - -terser@^5.31.1: - version "5.46.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.46.0.tgz#1b81e560d584bbdd74a8ede87b4d9477b0ff9695" - integrity sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg== - dependencies: - "@jridgewell/source-map" "^0.3.3" - acorn "^8.15.0" - commander "^2.20.0" - source-map-support "~0.5.20" - -test-exclude@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" - integrity sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w== - dependencies: - "@istanbuljs/schema" "^0.1.2" - glob "^7.1.4" - minimatch "^3.0.4" - -text-table@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - -thenify-all@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" - integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== - dependencies: - thenify ">= 3.1.0 < 4" - -"thenify@>= 3.1.0 < 4": - version "3.3.1" - resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" - integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== - dependencies: - any-promise "^1.0.0" - -thingies@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/thingies/-/thingies-2.5.0.tgz#5f7b882c933b85989f8466b528a6247a6881e04f" - integrity sha512-s+2Bwztg6PhWUD7XMfeYm5qliDdSiZm7M7n8KjTkIsm3l/2lgVRc2/Gx/v+ZX8lT4FMA+i8aQvhcWylldc+ZNw== - -thunky@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d" - integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA== - -timsort@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" - integrity sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A== - -tiny-invariant@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.0.4.tgz#346b5415fd93cb696b0c4e8a96697ff590f92463" - -tiny-warning@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.2.tgz#1dfae771ee1a04396bdfde27a3adcebc6b648b28" - -tiny-warning@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" - integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA== - -tinyglobby@^0.2.11: - version "0.2.15" - resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.15.tgz#e228dd1e638cea993d2fdb4fcd2d4602a79951c2" - integrity sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ== - dependencies: - fdir "^6.5.0" - picomatch "^4.0.3" - -tmp@^0.2.1: - version "0.2.5" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8" - integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow== - -tmpl@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" - integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw== - -to-fast-properties@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog== - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toggle-selection@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32" - integrity sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ== - -toidentifier@1.0.1, toidentifier@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" - integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== - -toposort@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" - integrity sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg== - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - -tree-dump@^1.0.3, tree-dump@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/tree-dump/-/tree-dump-1.1.0.tgz#ab29129169dc46004414f5a9d4a3c6e89f13e8a4" - integrity sha512-rMuvhU4MCDbcbnleZTFezWsaZXRFemSqAM+7jPnzUl1fo9w3YEKOxAeui0fz3OI4EU4hf23iyA7uQRVko+UaBA== - -ts-essentials@^9.1.2: - version "9.1.2" - resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-9.1.2.tgz#46db6944b73b4cd603f3d959ef1123c16ba56f59" - integrity sha512-EaSmXsAhEiirrTY1Oaa7TSpei9dzuCuFPmjKRJRPamERYtfaGS8/KpOSbjergLz/Y76/aZlV9i/krgzsuWEBbg== - -ts-interface-checker@^0.1.9: - version "0.1.13" - resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" - integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== - -ts-jest@^28.0.5: - version "28.0.8" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-28.0.8.tgz#cd204b8e7a2f78da32cf6c95c9a6165c5b99cc73" - integrity sha512-5FaG0lXmRPzApix8oFG8RKjAz4ehtm8yMKOTy5HX3fY6W8kmvOrmcY0hKDElW52FJov+clhUbrKAqofnj4mXTg== - dependencies: - bs-logger "0.x" - fast-json-stable-stringify "2.x" - jest-util "^28.0.0" - json5 "^2.2.1" - lodash.memoize "4.x" - make-error "1.x" - semver "7.x" - yargs-parser "^21.0.1" - -ts-toolbelt@^8.0.7: - version "8.4.0" - resolved "https://registry.yarnpkg.com/ts-toolbelt/-/ts-toolbelt-8.4.0.tgz#af6e64b87be3e097fac63600ce9556e78542fa27" - integrity sha512-hnGJXIgC49ZuF5g5oDthoge8t4cvT0dYg2pYO5C6yV/HmUUy1koooU2U/5K2N+Uw++hcXQpJAToLRa+GRp28Sg== - -tslib@^1.0.0, tslib@^1.8.1, tslib@^1.9.3: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tslib@^2.0.0, tslib@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" - integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== - -tslib@^2.1.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" - integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== - -tsutils@^3.21.0: - version "3.21.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" - integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== - dependencies: - tslib "^1.8.1" - -tsyringe@^4.10.0: - version "4.10.0" - resolved "https://registry.yarnpkg.com/tsyringe/-/tsyringe-4.10.0.tgz#d0c95815d584464214060285eaaadd94aa03299c" - integrity sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw== - dependencies: - tslib "^1.9.3" - -twin.macro@^2.8.2: - version "2.8.2" - resolved "https://registry.yarnpkg.com/twin.macro/-/twin.macro-2.8.2.tgz#7f1344b4b1c3811da93a62fa204fe08999df7a75" - integrity sha512-2Vg09mp+nA70AWUedJ8WRgB2me3buq7JGbOnjHnFnNaBzomVu5k7lJ9YGpByIlre+UYr7QRhtlj7+IUKxvCrUA== - dependencies: - "@babel/parser" "^7.12.5" - "@babel/template" "^7.14.5" - autoprefixer "^10.2.5" - babel-plugin-macros "^2.8.0" - chalk "^4.1.0" - clean-set "^1.1.1" - color "^3.1.3" - dset "^2.0.1" - lodash.flatmap "^4.5.0" - lodash.get "^4.4.2" - lodash.merge "^4.6.2" - postcss "^8.1.8" - string-similarity "^4.0.3" - tailwindcss "^2.2.7" - timsort "^0.3.0" - -type-check@^0.4.0, type-check@~0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" - integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== - dependencies: - prelude-ls "^1.2.1" - -type-detect@4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" - integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== - -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== - -type-fest@^0.21.3: - version "0.21.3" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" - integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== - -type-is@~1.6.18: - version "1.6.18" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" - integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== - dependencies: - media-typer "0.3.0" - mime-types "~2.1.24" - -typed-array-buffer@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536" - integrity sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw== - dependencies: - call-bound "^1.0.3" - es-errors "^1.3.0" - is-typed-array "^1.1.14" - -typed-array-byte-length@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz#8407a04f7d78684f3d252aa1a143d2b77b4160ce" - integrity sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg== - dependencies: - call-bind "^1.0.8" - for-each "^0.3.3" - gopd "^1.2.0" - has-proto "^1.2.0" - is-typed-array "^1.1.14" - -typed-array-byte-offset@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.4.tgz#ae3698b8ec91a8ab945016108aef00d5bff12355" - integrity sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ== - dependencies: - available-typed-arrays "^1.0.7" - call-bind "^1.0.8" - for-each "^0.3.3" - gopd "^1.2.0" - has-proto "^1.2.0" - is-typed-array "^1.1.15" - reflect.getprototypeof "^1.0.9" - -typed-array-length@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.7.tgz#ee4deff984b64be1e118b0de8c9c877d5ce73d3d" - integrity sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg== - dependencies: - call-bind "^1.0.7" - for-each "^0.3.3" - gopd "^1.0.1" - is-typed-array "^1.1.13" - possible-typed-array-names "^1.0.0" - reflect.getprototypeof "^1.0.6" - -typescript@~5.1.0: - version "5.1.6" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274" - integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA== - -unbox-primitive@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" - integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== - dependencies: - call-bind "^1.0.2" - has-bigints "^1.0.2" - has-symbols "^1.0.3" - which-boxed-primitive "^1.0.2" - -unbox-primitive@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.1.0.tgz#8d9d2c9edeea8460c7f35033a88867944934d1e2" - integrity sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw== - dependencies: - call-bound "^1.0.3" - has-bigints "^1.0.2" - has-symbols "^1.1.0" - which-boxed-primitive "^1.1.1" - -undici-types@~6.21.0: - version "6.21.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" - integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== - -undici-types@~7.16.0: - version "7.16.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" - integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw== - -unicode-canonical-property-names-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" - -unicode-match-property-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz#8ed2a32569961bce9227d09cd3ffbb8fed5f020c" - dependencies: - unicode-canonical-property-names-ecmascript "^1.0.4" - unicode-property-aliases-ecmascript "^1.0.4" - -unicode-match-property-value-ecmascript@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz#0d91f600eeeb3096aa962b1d6fc88876e64ea531" - integrity sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ== - -unicode-property-aliases-ecmascript@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.4.tgz#5a533f31b4317ea76f17d807fa0d116546111dd0" - -universalify@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" - integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== - -unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== - -update-browserslist-db@^1.0.0: - version "1.1.4" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.4.tgz#7802aa2ae91477f255b86e0e46dbc787a206ad4a" - integrity sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A== - dependencies: - escalade "^3.2.0" - picocolors "^1.1.1" - -update-browserslist-db@^1.1.4, update-browserslist-db@^1.2.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz#64d76db58713136acbeb4c49114366cc6cc2e80d" - integrity sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w== - dependencies: - escalade "^3.2.0" - picocolors "^1.1.1" - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -use-fit-text@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/use-fit-text/-/use-fit-text-2.4.0.tgz#d3d1cd72f6d29cfb2233ec0e0b38c6f25d319f67" - integrity sha512-Iy4LMrXcdxWlyZ5phntMpJMgyXGB1p3tV73y2r0QrZ6f/thPh+/QU3ie6RCXmjF8tHMs20FKMPskXeDYIla/Ww== - dependencies: - resize-observer-polyfill "^1.5.1" - -use-isomorphic-layout-effect@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.2.tgz#497cefb13d863d687b08477d9e5a164ad8c1a6fb" - integrity sha512-49L8yCO3iGT/ZF9QttjwLF/ZD9Iwto5LnH5LmEdk/6cFmXddqi2ulF0edxTwjj+7mqvpVVGQWvbXZdn32wRSHA== - -use-memo-one@^1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/use-memo-one/-/use-memo-one-1.1.3.tgz#2fd2e43a2169eabc7496960ace8c79efef975e99" - integrity sha512-g66/K7ZQGYrI6dy8GLpVcMsBp4s17xNkYJVSMvTEevGy3nDxHOfE6z8BVE22+5G5x7t3+bhzrlTDB7ObrEE0cQ== - -use-sync-external-store@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" - integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA== - -use-sync-external-store@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz#b174bfa65cb2b526732d9f2ac0a408027876f32d" - integrity sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w== - -util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== - -utils-merge@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" - integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== - -uuid@^13.0.0: - version "13.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-13.0.0.tgz#263dc341b19b4d755eb8fe36b78d95a6b65707e8" - integrity sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w== - -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - -v8-to-istanbul@^9.0.1: - version "9.3.0" - resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz#b9572abfa62bd556c16d75fdebc1a411d5ff3175" - integrity sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA== - dependencies: - "@jridgewell/trace-mapping" "^0.3.12" - "@types/istanbul-lib-coverage" "^2.0.1" - convert-source-map "^2.0.0" - -value-equal@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7" - -vary@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== - -void-elements@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09" - integrity sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w== - -walker@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.8.tgz#bd498db477afe573dc04185f011d3ab8a8d7653f" - integrity sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ== - dependencies: - makeerror "1.0.12" - -watchpack@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.5.1.tgz#dd38b601f669e0cbf567cb802e75cead82cde102" - integrity sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg== - dependencies: - glob-to-regexp "^0.4.1" - graceful-fs "^4.1.2" - -wbuf@^1.1.0, wbuf@^1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.3.tgz#c1d8d149316d3ea852848895cb6a0bfe887b87df" - integrity sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA== - dependencies: - minimalistic-assert "^1.0.0" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -webpack-assets-manifest@^6.4.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/webpack-assets-manifest/-/webpack-assets-manifest-6.4.0.tgz#e04b69394d2409a64f0cb11f00c49cab4a788540" - integrity sha512-7BDswzFlfqEP63E3uF5J1V4g4JYN0I5PQecFqLZ1OP9qVzlfzDaX4G4RK6GEeUYylv+W86dycbOkHHGfxKdLTA== - dependencies: - deepmerge "^4.3.1" - lockfile "^1.0.4" - schema-utils "^4.3.3" - tapable "^2.3.0" - -webpack-cli@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-6.0.1.tgz#a1ce25da5ba077151afd73adfa12e208e5089207" - integrity sha512-MfwFQ6SfwinsUVi0rNJm7rHZ31GyTcpVE5pgVA3hwFRb7COD4TzjUUwhGWKfO50+xdc2MQPuEBBJoqIMGt3JDw== - dependencies: - "@discoveryjs/json-ext" "^0.6.1" - "@webpack-cli/configtest" "^3.0.1" - "@webpack-cli/info" "^3.0.1" - "@webpack-cli/serve" "^3.0.1" - colorette "^2.0.14" - commander "^12.1.0" - cross-spawn "^7.0.3" - envinfo "^7.14.0" - fastest-levenshtein "^1.0.12" - import-local "^3.0.2" - interpret "^3.1.1" - rechoir "^0.8.0" - webpack-merge "^6.0.1" - -webpack-dev-middleware@^7.4.2: - version "7.4.5" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-7.4.5.tgz#d4e8720aa29cb03bc158084a94edb4594e3b7ac0" - integrity sha512-uxQ6YqGdE4hgDKNf7hUiPXOdtkXvBJXrfEGYSx7P7LC8hnUYGK70X6xQXUvXeNyBDDcsiQXpG2m3G9vxowaEuA== - dependencies: - colorette "^2.0.10" - memfs "^4.43.1" - mime-types "^3.0.1" - on-finished "^2.4.1" - range-parser "^1.2.1" - schema-utils "^4.0.0" - -webpack-dev-server@^5.2.2: - version "5.2.3" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-5.2.3.tgz#7f36a78be7ac88833fd87757edee31469a9e47d3" - integrity sha512-9Gyu2F7+bg4Vv+pjbovuYDhHX+mqdqITykfzdM9UyKqKHlsE5aAjRhR+oOEfXW5vBeu8tarzlJFIZva4ZjAdrQ== - dependencies: - "@types/bonjour" "^3.5.13" - "@types/connect-history-api-fallback" "^1.5.4" - "@types/express" "^4.17.25" - "@types/express-serve-static-core" "^4.17.21" - "@types/serve-index" "^1.9.4" - "@types/serve-static" "^1.15.5" - "@types/sockjs" "^0.3.36" - "@types/ws" "^8.5.10" - ansi-html-community "^0.0.8" - bonjour-service "^1.2.1" - chokidar "^3.6.0" - colorette "^2.0.10" - compression "^1.8.1" - connect-history-api-fallback "^2.0.0" - express "^4.22.1" - graceful-fs "^4.2.6" - http-proxy-middleware "^2.0.9" - ipaddr.js "^2.1.0" - launch-editor "^2.6.1" - open "^10.0.3" - p-retry "^6.2.0" - schema-utils "^4.2.0" - selfsigned "^5.5.0" - serve-index "^1.9.1" - sockjs "^0.3.24" - spdy "^4.0.2" - webpack-dev-middleware "^7.4.2" - ws "^8.18.0" - -webpack-merge@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-6.0.1.tgz#50c776868e080574725abc5869bd6e4ef0a16c6a" - integrity sha512-hXXvrjtx2PLYx4qruKl+kyRSLc52V+cCvMxRjmKwoA+CBbbF5GfIBtR6kCvl0fYGqTUPKB+1ktVmTHqMOzgCBg== - dependencies: - clone-deep "^4.0.1" - flat "^5.0.2" - wildcard "^2.0.1" - -webpack-sources@^3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.3.3.tgz#d4bf7f9909675d7a070ff14d0ef2a4f3c982c723" - integrity sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg== - -webpack@^5.103.0: - version "5.105.2" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.105.2.tgz#f3b76f9fc36f1152e156e63ffda3bbb82e6739ea" - integrity sha512-dRXm0a2qcHPUBEzVk8uph0xWSjV/xZxenQQbLwnwP7caQCYpqG1qddwlyEkIDkYn0K8tvmcrZ+bOrzoQ3HxCDw== - dependencies: - "@types/eslint-scope" "^3.7.7" - "@types/estree" "^1.0.8" - "@types/json-schema" "^7.0.15" - "@webassemblyjs/ast" "^1.14.1" - "@webassemblyjs/wasm-edit" "^1.14.1" - "@webassemblyjs/wasm-parser" "^1.14.1" - acorn "^8.15.0" - acorn-import-phases "^1.0.3" - browserslist "^4.28.1" - chrome-trace-event "^1.0.2" - enhanced-resolve "^5.19.0" - es-module-lexer "^2.0.0" - eslint-scope "5.1.1" - events "^3.2.0" - glob-to-regexp "^0.4.1" - graceful-fs "^4.2.11" - json-parse-even-better-errors "^2.3.1" - loader-runner "^4.3.1" - mime-types "^2.1.27" - neo-async "^2.6.2" - schema-utils "^4.3.3" - tapable "^2.3.0" - terser-webpack-plugin "^5.3.16" - watchpack "^2.5.1" - webpack-sources "^3.3.3" - -websocket-driver@>=0.5.1, websocket-driver@^0.7.4: - version "0.7.4" - resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" - integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== - dependencies: - http-parser-js ">=0.5.1" - safe-buffer ">=5.1.0" - websocket-extensions ">=0.1.1" - -websocket-extensions@>=0.1.1: - version "0.1.4" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" - integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which-boxed-primitive@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" - integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== - dependencies: - is-bigint "^1.0.1" - is-boolean-object "^1.1.0" - is-number-object "^1.0.4" - is-string "^1.0.5" - is-symbol "^1.0.3" - -which-boxed-primitive@^1.1.0, which-boxed-primitive@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz#d76ec27df7fa165f18d5808374a5fe23c29b176e" - integrity sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA== - dependencies: - is-bigint "^1.1.0" - is-boolean-object "^1.2.1" - is-number-object "^1.1.1" - is-string "^1.1.1" - is-symbol "^1.1.1" - -which-builtin-type@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/which-builtin-type/-/which-builtin-type-1.2.1.tgz#89183da1b4907ab089a6b02029cc5d8d6574270e" - integrity sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q== - dependencies: - call-bound "^1.0.2" - function.prototype.name "^1.1.6" - has-tostringtag "^1.0.2" - is-async-function "^2.0.0" - is-date-object "^1.1.0" - is-finalizationregistry "^1.1.0" - is-generator-function "^1.0.10" - is-regex "^1.2.1" - is-weakref "^1.0.2" - isarray "^2.0.5" - which-boxed-primitive "^1.1.0" - which-collection "^1.0.2" - which-typed-array "^1.1.16" - -which-collection@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/which-collection/-/which-collection-1.0.2.tgz#627ef76243920a107e7ce8e96191debe4b16c2a0" - integrity sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw== - dependencies: - is-map "^2.0.3" - is-set "^2.0.3" - is-weakmap "^2.0.2" - is-weakset "^2.0.3" - -which-typed-array@^1.1.16, which-typed-array@^1.1.19: - version "1.1.19" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.19.tgz#df03842e870b6b88e117524a4b364b6fc689f956" - integrity sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw== - dependencies: - available-typed-arrays "^1.0.7" - call-bind "^1.0.8" - call-bound "^1.0.4" - for-each "^0.3.5" - get-proto "^1.0.1" - gopd "^1.2.0" - has-tostringtag "^1.0.2" - -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -wildcard@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67" - integrity sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ== - -word-wrap@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" - integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - -write-file-atomic@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.2.tgz#a9df01ae5b77858a027fd2e80768ee433555fcfd" - integrity sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg== - dependencies: - imurmurhash "^0.1.4" - signal-exit "^3.0.7" - -ws@^8.18.0: - version "8.19.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.19.0.tgz#ddc2bdfa5b9ad860204f5a72a4863a8895fd8c8b" - integrity sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg== - -wsl-utils@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/wsl-utils/-/wsl-utils-0.1.0.tgz#8783d4df671d4d50365be2ee4c71917a0557baab" - integrity sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw== - dependencies: - is-wsl "^3.1.0" - -xtend@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -xterm-addon-fit@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/xterm-addon-fit/-/xterm-addon-fit-0.5.0.tgz#2d51b983b786a97dcd6cde805e700c7f913bc596" - integrity sha512-DsS9fqhXHacEmsPxBJZvfj2la30Iz9xk+UKjhQgnYNkrUIN5CYLbw7WEfz117c7+S86S/tpHPfvNxJsF5/G8wQ== - -xterm-addon-search-bar@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/xterm-addon-search-bar/-/xterm-addon-search-bar-0.2.0.tgz#e03c020a5ed22f1e8d503946b26a14ade508bc91" - integrity sha512-xvXmBA/ShbnzGe5CCy0kqPNNGqjkpuaRgH3Z1iW0V71vCAPRrtJ/v/hMnysZBH7WGUYhlCQr1cJZagW2fBVvSg== - dependencies: - babel-runtime "^6.26.0" - rxjs-compat "^6.5.4" - -xterm-addon-search@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.9.0.tgz#95278ebb818cfcf882209ae75be96e0bea5d52a5" - integrity sha512-aoolI8YuHvdGw+Qjg8g2M4kst0v86GtB7WeBm4F0jNXA005/6QbWWy9eCsvnIDLJOFI5JSSrZnD6CaOkvBQYPA== - -xterm-addon-unicode11@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.6.0.tgz#733fd17bdf2ae6e818493db1d41241c999de0786" - integrity sha512-5pkb8YoS/deRtNqQRw8t640mu+Ga8B2MG3RXGQu0bwgcfr8XiXIRI880TWM49ICAHhTmnOLPzIIBIjEnCq7k2A== - -xterm-addon-web-links@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.6.0.tgz#0296cb6c99588847894670d998c9ea6a6aeb26ee" - integrity sha512-H6XzjWWZu8FBo+fnYpxdPk9w5M6drbsvwPEJZGRS38MihiQaVFpKlCMKdfRgDbKGE530tw1yH54rhpZfHgt2/A== - -xterm@^4.19.0: - version "4.19.0" - resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.19.0.tgz#c0f9d09cd61de1d658f43ca75f992197add9ef6d" - integrity sha512-c3Cp4eOVsYY5Q839dR5IejghRPpxciGmLWWaP9g+ppfMeBChMeLa1DCA+pmX/jyDZ+zxFOmlJL/82qVdayVoGQ== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yallist@^3.0.2: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" - integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yaml@^1.10.0, yaml@^1.10.2, yaml@^1.7.2: - version "1.10.2" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" - integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== - -yargs-parser@^21.0.1, yargs-parser@^21.1.1: - version "21.1.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" - integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== - -yargs@^17.3.1: - version "17.7.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" - integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== - dependencies: - cliui "^8.0.1" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.1.1" - -yocto-queue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== - -yup@^0.29.1: - version "0.29.3" - resolved "https://registry.yarnpkg.com/yup/-/yup-0.29.3.tgz#69a30fd3f1c19f5d9e31b1cf1c2b851ce8045fea" - integrity sha512-RNUGiZ/sQ37CkhzKFoedkeMfJM0vNQyaz+wRZJzxdKE7VfDeVKH8bb4rr7XhRLbHJz5hSjoDNwMEIaKhuMZ8gQ== - dependencies: - "@babel/runtime" "^7.10.5" - fn-name "~3.0.0" - lodash "^4.17.15" - lodash-es "^4.17.11" - property-expr "^2.0.2" - synchronous-promise "^2.0.13" - toposort "^2.0.2"