$workspaceId, 'nonce' => Str::lower(Str::random(16)), 'expires_at' => $expiresAt->getTimestamp(), 'reconnect_id' => $reconnectId, ])); } /** * Decode and validate a code, returning its payload or null when the code is * missing, tampered with, malformed, or expired. * * @return array{workspace_id: string, nonce: string, expires_at: int, reconnect_id: string|null}|null */ public static function decode(mixed $code): ?array { if (! is_string($code) || $code === '') { return null; } try { $payload = json_decode(Crypt::decryptString($code), true); } catch (DecryptException) { return null; } if ( ! is_array($payload) || ! is_string(data_get($payload, 'workspace_id')) || ! is_string(data_get($payload, 'nonce')) || now()->getTimestamp() > (int) data_get($payload, 'expires_at') ) { return null; } return $payload; } }