From 9e2fdcd30d46bfb2a25415f7333137bc0cd88da9 Mon Sep 17 00:00:00 2001 From: IgorAlymov Date: Mon, 26 Aug 2024 11:30:56 +0500 Subject: [PATCH] feat: updated PuppeteerSharp Refs: SITKO-CORE-T-25 --- src/Directory.Packages.props | 2 +- src/Sitko.Core.Puppeteer/BrowserProvider.cs | 26 ++++++------------- .../PuppeteerModuleOptions.cs | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index e4f41330f..5feb42b14 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -20,7 +20,7 @@ - + diff --git a/src/Sitko.Core.Puppeteer/BrowserProvider.cs b/src/Sitko.Core.Puppeteer/BrowserProvider.cs index 52c52a9f1..718e9c6b2 100644 --- a/src/Sitko.Core.Puppeteer/BrowserProvider.cs +++ b/src/Sitko.Core.Puppeteer/BrowserProvider.cs @@ -4,23 +4,14 @@ namespace Sitko.Core.Puppeteer; -public class BrowserProvider : IBrowserProvider +public class BrowserProvider( + IOptionsMonitor optionsMonitor, + ILoggerFactory loggerFactory, + ILogger logger) + : IBrowserProvider { - private readonly ILogger logger; - private readonly ILoggerFactory loggerFactory; - private readonly IOptionsMonitor optionsMonitor; - - public BrowserProvider(IOptionsMonitor optionsMonitor, ILoggerFactory loggerFactory, - ILogger logger) - { - this.optionsMonitor = optionsMonitor; - this.loggerFactory = loggerFactory; - this.logger = logger; - } - private PuppeteerModuleOptions Options => optionsMonitor.CurrentValue; - public async Task GetBrowserAsync() { if (!string.IsNullOrEmpty(Options.BrowserWsEndpoint)) @@ -30,7 +21,7 @@ public async Task GetBrowserAsync() new ConnectOptions { BrowserWSEndpoint = Options.BrowserWsEndpoint, - IgnoreHTTPSErrors = Options.IgnoreHTTPSErrors, + AcceptInsecureCerts = Options.AcceptInsecureCerts, DefaultViewport = Options.ViewPortOptions }, loggerFactory); @@ -39,7 +30,7 @@ public async Task GetBrowserAsync() if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("PUPPETEER_EXECUTABLE_PATH"))) { logger.LogDebug("Download browser"); - using var browserFetcher = new BrowserFetcher(Options.Product); + var browserFetcher = new BrowserFetcher(Options.Product); if (!string.IsNullOrEmpty(Options.Revision)) { await browserFetcher.DownloadAsync(Options.Revision); @@ -58,9 +49,8 @@ public async Task GetBrowserAsync() { Headless = Options.Headless, Args = Options.BrowserArgs, - IgnoreHTTPSErrors = Options.IgnoreHTTPSErrors, + AcceptInsecureCerts = Options.AcceptInsecureCerts, DefaultViewport = Options.ViewPortOptions }, loggerFactory); } } - diff --git a/src/Sitko.Core.Puppeteer/PuppeteerModuleOptions.cs b/src/Sitko.Core.Puppeteer/PuppeteerModuleOptions.cs index 8b0bb425e..08554ca98 100644 --- a/src/Sitko.Core.Puppeteer/PuppeteerModuleOptions.cs +++ b/src/Sitko.Core.Puppeteer/PuppeteerModuleOptions.cs @@ -7,7 +7,7 @@ namespace Sitko.Core.Puppeteer; public class PuppeteerModuleOptions : BaseModuleOptions { public string? BrowserWsEndpoint { get; set; } - public bool IgnoreHTTPSErrors { get; set; } + public bool AcceptInsecureCerts { get; set; } [JsonIgnore] public ViewPortOptions ViewPortOptions { get; set; } = ViewPortOptions.Default; public string[] BrowserArgs { get; set; } = { "--no-sandbox" };