[ 'internal_hosts' => config('app.url'), 'html_class' => $class, 'open_in_new_window' => $openInNewWindow, 'nofollow' => '', 'noopener' => 'external', 'noreferrer' => 'external', ], ]; $environment = new Environment($config); $environment->addExtension(new CommonMarkCoreExtension); $environment->addExtension(new GithubFlavoredMarkdownExtension); $environment->addExtension(new ExternalLinkExtension); $converter = new MarkdownConverter($environment); $result = (string) $converter->convert($string); $result = ltrim($result, '

'); $result = rtrim($result, '

'); return $result; }); } if (! Http::hasMacro('getDnsRecord')) { Http::macro('getDnsRecord', function (string $hostname, int $type): ?Collection { try { if (($entries = \Safe\dns_get_record($hostname, $type)) != null) { return collect($entries); } } catch (\Safe\Exceptions\NetworkException) { // ignore } return null; }); } if (! Collection::hasMacro('sortByCollator')) { Collection::macro('sortByCollator', function (callable|string $callback) { /** @var Collection */ $collect = $this; return CollectionHelper::sortByCollator($collect, $callback); }); } if (! Collection::hasMacro('sortByCollatorDesc')) { Collection::macro('sortByCollatorDesc', function (callable|string $callback) { /** @var Collection */ $collect = $this; return CollectionHelper::sortByCollator($collect, $callback, descending: true); }); } Builder::defaultMorphKeyType('uuid'); if ($this->app->environment('local') && class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) { $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class); $this->app->register(TelescopeServiceProvider::class); } } /** * Bootstrap any application services. * * @return void */ public function boot() { if (Config::get('app.force_url') === true) { URL::forceRootUrl(Str::of(config('app.url'))->ltrim('/')); URL::forceScheme('https'); } RedirectIfAuthenticated::redirectUsing(fn () => route('vault.index', absolute: false)); Password::defaults(function () { return $this->app->environment('production') // @codeCoverageIgnoreStart ? Password::min(8) ->letters() ->mixedCase() ->numbers() ->symbols() // @codeCoverageIgnoreEnd : Password::min(4); }); RateLimiter::for('api', fn (Request $request) => Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip())); RateLimiter::for('oauth2-socialite', fn (Request $request) => Limit::perMinute(5)->by(optional($request->user())->id ?: $request->ip())); Webauthn::updateViewResponseUsing(WebauthnUpdateResponse::class); Webauthn::destroyViewResponseUsing(WebauthnDestroyResponse::class); Event::subscribe(LoginViaRemember::class); Event::listen(FileDeleted::class, DeleteFileInStorage::class); Event::listen(SocialiteWasCalled::class, AzureExtendSocialite::class); Event::listen(SocialiteWasCalled::class, FacebookExtendSocialite::class); Event::listen(SocialiteWasCalled::class, GitHubExtendSocialite::class); Event::listen(SocialiteWasCalled::class, GoogleExtendSocialite::class); Event::listen(SocialiteWasCalled::class, LinkedInExtendSocialite::class); Event::listen(SocialiteWasCalled::class, KanidmExtendSocialite::class); Event::listen(SocialiteWasCalled::class, KeycloakExtendSocialite::class); Vite::prefetch(concurrency: 3); Gate::define('viewPulse', fn (User $user) => $user->is_instance_administrator || $this->app->environment('local')); } }