## Summary - move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling - update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location - add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation` - integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404` ## Remaining Rollout Checks - validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout - confirm web, queue, and scheduler processes all start from the expected working directory in staging/production - verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #213
86 lines
1.9 KiB
PHP
86 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Baselines;
|
|
|
|
use JsonException;
|
|
|
|
final class BaselineEvidenceResumeToken
|
|
{
|
|
private const int VERSION = 1;
|
|
|
|
/**
|
|
* @param array<string, mixed> $state
|
|
*/
|
|
public static function encode(array $state): string
|
|
{
|
|
$payload = [
|
|
'v' => self::VERSION,
|
|
'state' => $state,
|
|
];
|
|
|
|
$json = json_encode($payload, JSON_THROW_ON_ERROR);
|
|
|
|
return self::base64UrlEncode($json);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>|null
|
|
*/
|
|
public static function decode(string $token): ?array
|
|
{
|
|
$token = trim($token);
|
|
|
|
if ($token === '') {
|
|
return null;
|
|
}
|
|
|
|
$json = self::base64UrlDecode($token);
|
|
|
|
if ($json === null) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
$decoded = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
|
|
} catch (JsonException) {
|
|
return null;
|
|
}
|
|
|
|
if (! is_array($decoded)) {
|
|
return null;
|
|
}
|
|
|
|
$version = $decoded['v'] ?? null;
|
|
$version = is_int($version) ? $version : (is_numeric($version) ? (int) $version : null);
|
|
|
|
if ($version !== self::VERSION) {
|
|
return null;
|
|
}
|
|
|
|
$state = $decoded['state'] ?? null;
|
|
|
|
return is_array($state) ? $state : null;
|
|
}
|
|
|
|
private static function base64UrlEncode(string $value): string
|
|
{
|
|
return rtrim(strtr(base64_encode($value), '+/', '-_'), '=');
|
|
}
|
|
|
|
private static function base64UrlDecode(string $value): ?string
|
|
{
|
|
$padded = strtr($value, '-_', '+/');
|
|
$padding = strlen($padded) % 4;
|
|
|
|
if ($padding !== 0) {
|
|
$padded .= str_repeat('=', 4 - $padding);
|
|
}
|
|
|
|
$decoded = base64_decode($padded, true);
|
|
|
|
return is_string($decoded) ? $decoded : null;
|
|
}
|
|
}
|