From 220d7d8abc8d27a59b3c4af93dd6da8f05ab4fde Mon Sep 17 00:00:00 2001 From: Arnold Cubici-Jones Date: Tue, 27 Aug 2024 10:39:10 +0100 Subject: [PATCH 1/6] refactor(repo): change instances of urlbox.io to urlbox.com --- README.md | 18 ++++++------ composer.json | 2 +- src/Facades/Urlbox.php | 2 +- src/Urlbox.php | 8 +++--- tests/UrlboxTest.php | 62 +++++++++++++++++++++--------------------- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 1112e24..c1703bd 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Urlbox/Screenshots -## Capture highly accurate webpage screenshots of any site using Urlbox.io in PHP +## Capture highly accurate webpage screenshots of any site using Urlbox.com in PHP -This package uses the [Urlbox.io](https://urlbox.io) screenshot as a service to generate website screenshots. +This package uses the [Urlbox.com](https://urlbox.com) screenshot as a service to generate website screenshots. ## Installation @@ -47,11 +47,11 @@ URLBOX_SECRET=YOUR_URLBOX_SECRET URLBOX_WEBHOOK_SECRET=YOUR_URLBOX_WEBHOOK_SECRET ``` -You can find your API Credentials and Webhook Secret [here](https://www.urlbox.io/dashboard/projects) +You can find your API Credentials and Webhook Secret [here](https://www.urlbox.com/dashboard/projects) ## Usage -You will need a [Urlbox](https://urlbox.io) account to use this package. Please signup [here](https://urlbox.io/pricing) and get your API Key and Secret from the Urlbox dashboard once you have logged in. +You will need a [Urlbox](https:// account to use this package. Please signup [here](https://urlbox.com/pricing) and get your API Key and Secret from the Urlbox dashboard once you have logged in. Here is a sample call to generate a Urlbox screenshot URL: @@ -70,7 +70,7 @@ Here is a sample call to generate a Urlbox screenshot URL: // Create the Urlbox URL $urlboxUrl = $urlbox->generateSignedUrl( $options ); - // $urlboxUrl is now 'https://api.urlbox.io/v1/API_KEY/TOKEN/png?url=example.com' + // $urlboxUrl is now 'https://api.urlbox.com/v1/API_KEY/TOKEN/png?url=example.com' // Generate a screenshot by loading the Urlbox URL in an img tag: echo 'Test screenshot generated by Urlbox' @@ -83,7 +83,7 @@ use Urlbox\Screenshots\Facades\Urlbox; $options = [ 'url' => 'example.com' ]; $urlboxUrl = Urlbox::generateUrl( $options ); -// $urlboxUrl is now 'https://api.urlbox.io/v1/API_KEY/TOKEN/png?url=example.com' +// $urlboxUrl is now 'https://api.urlbox.com/v1/API_KEY/TOKEN/png?url=example.com' ``` You can now use the result (`$urlboxUrl`) by placing it inside an `` tag as the `src` parameter. @@ -92,7 +92,7 @@ When you load the image, a screenshot of example.com will be returned. ## Options -You can find the full list of available options within the [docs](https://urlbox.io/docs/options). Below is a list of the most commonly used options: +You can find the full list of available options within the [docs](https://urlbox.com/docs/options). Below is a list of the most commonly used options: | Option | Default | Description | |-----------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| @@ -137,11 +137,11 @@ We are open to pull requests. ## Security -If you discover any security related issues, please email services@urlbox.io instead of using the issue tracker. +If you discover any security related issues, please email services@urlbox.com instead of using the issue tracker. ## About Urlbox -Urlbox is a premium Screenshot as a Service API. It lets you render highly accurate screenshots of webpages and display them anywhere you like. [Urlbox.io](https://urlbox.io). +Urlbox is a premium Screenshot as a Service API. It lets you render highly accurate screenshots of webpages and display them anywhere you like. [urlbox.com](https://urlbox.com). ## License diff --git a/composer.json b/composer.json index f4770a0..5d095e4 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "authors": [ { "name": "Chris Roebuck", - "email": "chris@urlbox.io", + "email": "chris@urlbox.com", "role": "Developer" } ], diff --git a/src/Facades/Urlbox.php b/src/Facades/Urlbox.php index 548cb1f..a0cc495 100644 --- a/src/Facades/Urlbox.php +++ b/src/Facades/Urlbox.php @@ -8,7 +8,7 @@ * Class Datatables. * * @package Urlbox\Screenshots\Facades - * @author Chris Roebuck + * @author Chris Roebuck */ class Urlbox extends Facade { diff --git a/src/Urlbox.php b/src/Urlbox.php index b15e6a1..dc2a50d 100644 --- a/src/Urlbox.php +++ b/src/Urlbox.php @@ -10,7 +10,7 @@ class Urlbox { - private string $baseUrl = 'https://api.urlbox.io/v1'; + private string $baseUrl = 'https://api.urlbox.com/v1'; private string $apiKey; private string $apiSecret; private ?string $webhookSecret; @@ -46,11 +46,11 @@ public function __construct( string $apiKey, string $apiSecret, ?string $webhook private function ensureIsValidCredentials( string $apiKey, string $apiSecret ) { if ( empty( $apiKey ) ) { - throw new InvalidArgumentException( 'Requires an api key - https://www.urlbox.io/dashboard/projects' ); + throw new InvalidArgumentException( 'Requires an api key - https://www.urlbox.com/dashboard/projects' ); } if ( empty( $apiSecret ) ) { - throw new InvalidArgumentException( 'Requires an api secret - https://www.urlbox.io/dashboard/projects' ); + throw new InvalidArgumentException( 'Requires an api secret - https://www.urlbox.com/dashboard/projects' ); } } @@ -210,7 +210,7 @@ private function encodeURIComponent( string $value ): string public function verifyWebhookSignature( string $header, string $content ): bool { if ( empty( $this->webhookSecret ) ) { - throw new Exception( 'Unable to verify signature as Webhook Secret is not set. You can find your webhook secret inside your project\'s settings - https://www.urlbox.io/dashboard/projects' ); + throw new Exception( 'Unable to verify signature as Webhook Secret is not set. You can find your webhook secret inside your project\'s settings - https://www.urlbox.com/dashboard/projects' ); } if ( empty( $header ) ) { diff --git a/tests/UrlboxTest.php b/tests/UrlboxTest.php index affcba0..e4556ed 100644 --- a/tests/UrlboxTest.php +++ b/tests/UrlboxTest.php @@ -69,7 +69,7 @@ public function testRenderReturnsJsonArrayOfApiResponse() [ 'renderUrl' => 'http://storage.foobar.com/urlbox/renders/123456.png', 'size' => 525949 ], $response ); - $this->assertEquals( 'https://api.urlbox.io/v1/render/sync', $url ); + $this->assertEquals( 'https://api.urlbox.com/v1/render/sync', $url ); $this->assertEquals( [ 'headers' => [ 'Authorization' => 'Bearer API_SECRET', @@ -123,7 +123,7 @@ public function testRenderSavesToDiskAndReturnsJsonArrayOfApiResponseWithLocalPa $result ); - $this->assertEquals( 'https://api.urlbox.io/v1/render/sync', $postUrl ); + $this->assertEquals( 'https://api.urlbox.com/v1/render/sync', $postUrl ); $this->assertEquals( [ 'headers' => [ 'Authorization' => 'Bearer API_SECRET', @@ -146,7 +146,7 @@ public function testRenderSyncReturnsJsonArrayOfApiResponse() $guzzleMock = Mockery::mock( Client::class ) ->shouldReceive( 'post' ) ->with( Mockery::capture( $url ), Mockery::capture( $requestOptions ) ) - ->andReturn( $this->getMockedGuzzleResponse( '{"status":"created","renderId":"00000000-0000-0000-0000-000000000000","statusUrl":"https://api.urlbox.io/render/00000000-0000-0000-0000-000000000000"}' ) ) + ->andReturn( $this->getMockedGuzzleResponse( '{"status":"created","renderId":"00000000-0000-0000-0000-000000000000","statusUrl":"https://api.urlbox.com/render/00000000-0000-0000-0000-000000000000"}' ) ) ->getMock(); $urlbox = new Urlbox( 'API_KEY', 'API_SECRET', 'WEBHOOK_SECRET', $guzzleMock ); @@ -160,11 +160,11 @@ public function testRenderSyncReturnsJsonArrayOfApiResponse() [ 'status' => 'created', 'renderId' => '00000000-0000-0000-0000-000000000000', - 'statusUrl' => 'https://api.urlbox.io/render/00000000-0000-0000-0000-000000000000' + 'statusUrl' => 'https://api.urlbox.com/render/00000000-0000-0000-0000-000000000000' ], $response ); - $this->assertEquals( 'https://api.urlbox.io/v1/render', $url ); + $this->assertEquals( 'https://api.urlbox.com/v1/render', $url ); $this->assertEquals( [ 'headers' => [ 'Authorization' => 'Bearer API_SECRET', @@ -180,7 +180,7 @@ public function testGenerateSignedUrlDefaultFormatToPng() { $urlbox = Urlbox::fromCredentials( 'API_KEY', 'API_SECRET', 'WEBHOOK_SECRET', Mockery::mock( Client::class ) ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/png?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/png?url=https%3A%2F%2Fexample.com', $urlbox->generateSignedUrl( [ 'url' => 'https://example.com' ] ) ); } @@ -195,7 +195,7 @@ public function testGenerateSignedUrlCanSetFormatToPng() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/png?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/png?url=https%3A%2F%2Fexample.com', $url ); } @@ -210,7 +210,7 @@ public function testGenerateSignedUrlCanSetFormatToJpg() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/jpg?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/jpg?url=https%3A%2F%2Fexample.com', $url ); } @@ -225,7 +225,7 @@ public function testGenerateSignedUrlCanSetFormatToJpeg() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/jpeg?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/jpeg?url=https%3A%2F%2Fexample.com', $url ); } @@ -240,7 +240,7 @@ public function testGenerateSignedUrlCanSetFormatToAvif() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/avif?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/avif?url=https%3A%2F%2Fexample.com', $url ); } @@ -255,7 +255,7 @@ public function testGenerateSignedUrlCanSetFormatToWebp() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/webp?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/webp?url=https%3A%2F%2Fexample.com', $url ); } @@ -270,7 +270,7 @@ public function testGenerateSignedUrlCanSetFormatToPdf() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/pdf?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/pdf?url=https%3A%2F%2Fexample.com', $url ); } @@ -285,7 +285,7 @@ public function testGenerateSignedUrlCanSetFormatToSvg() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/svg?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/svg?url=https%3A%2F%2Fexample.com', $url ); } @@ -300,7 +300,7 @@ public function testGenerateSignedUrlCanSetFormatToHtml() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/html?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/5eaae418596fb183174660503df908a3966f4ba5/html?url=https%3A%2F%2Fexample.com', $url ); } @@ -316,7 +316,7 @@ public function testGenerateSignedUrlEncodesOptionsCorrectly() ] ); $this->assertEquals( - "https://api.urlbox.io/v1/API_KEY/897c2361c52a5eb41b9128a2b7e70ffd5fefd662/png?url=https%3A%2F%2Fexample.com%2F~!%40%23%24%25%5E%26*()%7B%7D%5B%5D%3D%3A%2F%2C%3B%3F%2B'%22%5C&block_ads=true", + "https://api.urlbox.com/v1/API_KEY/897c2361c52a5eb41b9128a2b7e70ffd5fefd662/png?url=https%3A%2F%2Fexample.com%2F~!%40%23%24%25%5E%26*()%7B%7D%5B%5D%3D%3A%2F%2C%3B%3F%2B'%22%5C&block_ads=true", $url ); } @@ -357,7 +357,7 @@ public function testGenerateSignedUrlProducesCorrectUrlForTheKitchenSink() $url = $urlbox->generateSignedUrl( $options ); $this->assertEquals( - "https://api.urlbox.io/v1/API_KEY/5280bc0f0fa198eb6fcde9fd3f32280dec496ee3/png?url=https%3A%2F%2Fapp_staging.example.com%2Fmisc%2Ftemplate_preview.php%3Fdsfdsfsdf%26acc%3D79%26cb%3Dba86b4c1%26regions%3D%255B%257B%2522id%2522%253A%2522dsfds%2522%252C%2522data%2522%253A%257B%2522html%2522%253A%2522It%2520works!%2522%257D%252C%2522type%2522%253A%2522html%2522%257D%255D%26state%3Dpublished%26tid%3D7%26sig%3Da642316f7e0ac9d783c30ef30a89bed3204252000319a2789851bc3de65ea216&delay=5000&selector=%23trynow&full_page=true&width=1280&height=1024&cookie=ckplns%3D1&cookie=foo%3Dbar&user_agent=Mozilla%2F5.0%20(iPhone%3B%20CPU%20iPhone%20OS%2010_0%20like%20Mac%20OS%20X)%20AppleWebKit%2F602.1.32%20(KHTML%2C%20like%20Gecko)%20Version%2F10.0%20Mobile%2F14A5261v%20Safari%2F602.1&retina=true&thumb_width=400&crop_width=500&ttl=604800&force=true&headless=false&wait_for=.someel&click=%23tab-specs-trigger&hover=a%5Bhref%3D%22https%3A%2F%2Fgoogle.com%22%5D&bg_color=%23bbbddd&highlight=trump%7Cinauguration&highlightbg=%2311cc77&highlightfg=green&hide_selector=.modal-backdrop%2C%20%23email-roadblock-topographic-modal&flash=true&timeout=40000&s3_path=%2Fpath%2Fto%2Fimage%20with%20space&use_s3=true", + "https://api.urlbox.com/v1/API_KEY/5280bc0f0fa198eb6fcde9fd3f32280dec496ee3/png?url=https%3A%2F%2Fapp_staging.example.com%2Fmisc%2Ftemplate_preview.php%3Fdsfdsfsdf%26acc%3D79%26cb%3Dba86b4c1%26regions%3D%255B%257B%2522id%2522%253A%2522dsfds%2522%252C%2522data%2522%253A%257B%2522html%2522%253A%2522It%2520works!%2522%257D%252C%2522type%2522%253A%2522html%2522%257D%255D%26state%3Dpublished%26tid%3D7%26sig%3Da642316f7e0ac9d783c30ef30a89bed3204252000319a2789851bc3de65ea216&delay=5000&selector=%23trynow&full_page=true&width=1280&height=1024&cookie=ckplns%3D1&cookie=foo%3Dbar&user_agent=Mozilla%2F5.0%20(iPhone%3B%20CPU%20iPhone%20OS%2010_0%20like%20Mac%20OS%20X)%20AppleWebKit%2F602.1.32%20(KHTML%2C%20like%20Gecko)%20Version%2F10.0%20Mobile%2F14A5261v%20Safari%2F602.1&retina=true&thumb_width=400&crop_width=500&ttl=604800&force=true&headless=false&wait_for=.someel&click=%23tab-specs-trigger&hover=a%5Bhref%3D%22https%3A%2F%2Fgoogle.com%22%5D&bg_color=%23bbbddd&highlight=trump%7Cinauguration&highlightbg=%2311cc77&highlightfg=green&hide_selector=.modal-backdrop%2C%20%23email-roadblock-topographic-modal&flash=true&timeout=40000&s3_path=%2Fpath%2Fto%2Fimage%20with%20space&use_s3=true", $url ); } @@ -366,7 +366,7 @@ public function testGenerateUnsignedUrlDefaultFormatToPng() { $urlbox = Urlbox::fromCredentials( 'API_KEY', 'API_SECRET', 'WEBHOOK_SECRET', Mockery::mock( Client::class ) ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/png?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/png?url=https%3A%2F%2Fexample.com', $urlbox->generateUnsignedUrl( [ 'url' => 'https://example.com' ] ) ); } @@ -381,7 +381,7 @@ public function testGenerateUnsignedUrlCanSetFormatToPng() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/png?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/png?url=https%3A%2F%2Fexample.com', $url ); } @@ -396,7 +396,7 @@ public function testGenerateUnsignedUrlCanSetFormatToJpg() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/jpg?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/jpg?url=https%3A%2F%2Fexample.com', $url ); } @@ -411,7 +411,7 @@ public function testGenerateUnsignedUrlCanSetFormatToJpeg() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/jpeg?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/jpeg?url=https%3A%2F%2Fexample.com', $url ); } @@ -426,7 +426,7 @@ public function testGenerateUnsignedUrlCanSetFormatToAvif() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/avif?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/avif?url=https%3A%2F%2Fexample.com', $url ); } @@ -441,7 +441,7 @@ public function testGenerateUnsignedUrlCanSetFormatToWebp() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/webp?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/webp?url=https%3A%2F%2Fexample.com', $url ); } @@ -456,7 +456,7 @@ public function testGenerateUnsignedUrlCanSetFormatToPdf() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/pdf?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/pdf?url=https%3A%2F%2Fexample.com', $url ); } @@ -471,7 +471,7 @@ public function testGenerateUnsignedUrlCanSetFormatToSvg() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/svg?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/svg?url=https%3A%2F%2Fexample.com', $url ); } @@ -486,7 +486,7 @@ public function testGenerateUnsignedUrlCanSetFormatToHtml() ] ); $this->assertEquals( - 'https://api.urlbox.io/v1/API_KEY/html?url=https%3A%2F%2Fexample.com', + 'https://api.urlbox.com/v1/API_KEY/html?url=https%3A%2F%2Fexample.com', $url ); } @@ -502,7 +502,7 @@ public function testGenerateUnsignedUrlEncodesOptionsCorrectly() ] ); $this->assertEquals( - "https://api.urlbox.io/v1/API_KEY/png?url=https%3A%2F%2Fexample.com%2F~!%40%23%24%25%5E%26*()%7B%7D%5B%5D%3D%3A%2F%2C%3B%3F%2B'%22%5C&block_ads=true", + "https://api.urlbox.com/v1/API_KEY/png?url=https%3A%2F%2Fexample.com%2F~!%40%23%24%25%5E%26*()%7B%7D%5B%5D%3D%3A%2F%2C%3B%3F%2B'%22%5C&block_ads=true", $url ); } @@ -543,7 +543,7 @@ public function testGenerateUnsignedUrlProducesCorrectUrlForTheKitchenSink() $url = $urlbox->generateUnsignedUrl( $options ); $this->assertEquals( - "https://api.urlbox.io/v1/API_KEY/png?url=https%3A%2F%2Fapp_staging.example.com%2Fmisc%2Ftemplate_preview.php%3Fdsfdsfsdf%26acc%3D79%26cb%3Dba86b4c1%26regions%3D%255B%257B%2522id%2522%253A%2522dsfds%2522%252C%2522data%2522%253A%257B%2522html%2522%253A%2522It%2520works!%2522%257D%252C%2522type%2522%253A%2522html%2522%257D%255D%26state%3Dpublished%26tid%3D7%26sig%3Da642316f7e0ac9d783c30ef30a89bed3204252000319a2789851bc3de65ea216&delay=5000&selector=%23trynow&full_page=true&width=1280&height=1024&cookie=ckplns%3D1&cookie=foo%3Dbar&user_agent=Mozilla%2F5.0%20(iPhone%3B%20CPU%20iPhone%20OS%2010_0%20like%20Mac%20OS%20X)%20AppleWebKit%2F602.1.32%20(KHTML%2C%20like%20Gecko)%20Version%2F10.0%20Mobile%2F14A5261v%20Safari%2F602.1&retina=true&thumb_width=400&crop_width=500&ttl=604800&force=true&headless=false&wait_for=.someel&click=%23tab-specs-trigger&hover=a%5Bhref%3D%22https%3A%2F%2Fgoogle.com%22%5D&bg_color=%23bbbddd&highlight=trump%7Cinauguration&highlightbg=%2311cc77&highlightfg=green&hide_selector=.modal-backdrop%2C%20%23email-roadblock-topographic-modal&flash=true&timeout=40000&s3_path=%2Fpath%2Fto%2Fimage%20with%20space&use_s3=true", + "https://api.urlbox.com/v1/API_KEY/png?url=https%3A%2F%2Fapp_staging.example.com%2Fmisc%2Ftemplate_preview.php%3Fdsfdsfsdf%26acc%3D79%26cb%3Dba86b4c1%26regions%3D%255B%257B%2522id%2522%253A%2522dsfds%2522%252C%2522data%2522%253A%257B%2522html%2522%253A%2522It%2520works!%2522%257D%252C%2522type%2522%253A%2522html%2522%257D%255D%26state%3Dpublished%26tid%3D7%26sig%3Da642316f7e0ac9d783c30ef30a89bed3204252000319a2789851bc3de65ea216&delay=5000&selector=%23trynow&full_page=true&width=1280&height=1024&cookie=ckplns%3D1&cookie=foo%3Dbar&user_agent=Mozilla%2F5.0%20(iPhone%3B%20CPU%20iPhone%20OS%2010_0%20like%20Mac%20OS%20X)%20AppleWebKit%2F602.1.32%20(KHTML%2C%20like%20Gecko)%20Version%2F10.0%20Mobile%2F14A5261v%20Safari%2F602.1&retina=true&thumb_width=400&crop_width=500&ttl=604800&force=true&headless=false&wait_for=.someel&click=%23tab-specs-trigger&hover=a%5Bhref%3D%22https%3A%2F%2Fgoogle.com%22%5D&bg_color=%23bbbddd&highlight=trump%7Cinauguration&highlightbg=%2311cc77&highlightfg=green&hide_selector=.modal-backdrop%2C%20%23email-roadblock-topographic-modal&flash=true&timeout=40000&s3_path=%2Fpath%2Fto%2Fimage%20with%20space&use_s3=true", $url ); } @@ -557,7 +557,7 @@ public function testVerifyWebhookSignatureThrowsExceptionWhenWebhookSecretNotSet $this->fail( 'Expected Exception not thrown' ); } catch ( Exception $exception ) { $this->assertEquals( - 'Unable to verify signature as Webhook Secret is not set. You can find your webhook secret inside your project\'s settings - https://www.urlbox.io/dashboard/projects', + 'Unable to verify signature as Webhook Secret is not set. You can find your webhook secret inside your project\'s settings - https://www.urlbox.com/dashboard/projects', $exception->getMessage() ); } @@ -580,7 +580,7 @@ public function testVerifyWebhookSignatureThrowsExceptionWhenHeaderIsEmpty() public function testVerifyWebhookSignatureReturnsTrueWhenSignatureMatches() { - $content = '{"event": "render.succeeded","renderId": "19a59ab6-a5aa-4cde-86cb-d2b23302fd84","result": {"renderUrl": "https://renders.urlbox.io/urlbox1/renders/6215a3df94d7588f7d910513/2022/7/6/19a59ab6-a5aa-4cde-86cb-d2b23302fd84.png","size": 34097},"meta": {"startTime": "2022-07-06T17:49:18.593Z","endTime": "2022-07-06T17:49:21.103Z"}}'; + $content = '{"event": "render.succeeded","renderId": "19a59ab6-a5aa-4cde-86cb-d2b23302fd84","result": {"renderUrl": "https://renders.urlbox.com/urlbox1/renders/6215a3df94d7588f7d910513/2022/7/6/19a59ab6-a5aa-4cde-86cb-d2b23302fd84.png","size": 34097},"meta": {"startTime": "2022-07-06T17:49:18.593Z","endTime": "2022-07-06T17:49:21.103Z"}}'; $header = 't=1657129761,sha256=ddbceae3998704c0b264d8e8c1d486df9f1c0b6cdb77e6e13ce7de4a72fbd81d'; $urlbox = new Urlbox( 'API_KEY', 'API_SECRET', 'WEBHOOK_SECRET' ); @@ -590,7 +590,7 @@ public function testVerifyWebhookSignatureReturnsTrueWhenSignatureMatches() public function testVerifyWebhookSignatureReturnsFalseWhenSignatureDoNotMatch() { - $content = '{"event": "render.succeeded","renderId": "19a59ab6-a5aa-4cde-86cb-d2b23302fd84","result": {"renderUrl": "https://renders.urlbox.io/urlbox1/renders/6215a3df94d7588f7d910513/2022/7/6/19a59ab6-a5aa-4cde-86cb-d2b23302fd84.png","size": 34097},"meta": {"startTime": "2022-07-06T17:49:18.593Z","endTime": "2022-07-06T17:49:21.103Z"}}'; + $content = '{"event": "render.succeeded","renderId": "19a59ab6-a5aa-4cde-86cb-d2b23302fd84","result": {"renderUrl": "https://renders.urlbox.com/urlbox1/renders/6215a3df94d7588f7d910513/2022/7/6/19a59ab6-a5aa-4cde-86cb-d2b23302fd84.png","size": 34097},"meta": {"startTime": "2022-07-06T17:49:18.593Z","endTime": "2022-07-06T17:49:21.103Z"}}'; $header = 't=1657129761,sha256=foobare3998704c0b264d8e8c1d4foobar1c0b6cdb77e6e13ce7de4a72foobar'; $urlbox = new Urlbox( 'API_KEY', 'API_SECRET', 'WEBHOOK_SECRET' ); @@ -600,7 +600,7 @@ public function testVerifyWebhookSignatureReturnsFalseWhenSignatureDoNotMatch() public function testVerifyWebhookSignatureReturnsFalseWhenWebhookSecretIncorrect() { - $content = '{"event": "render.succeeded","renderId": "19a59ab6-a5aa-4cde-86cb-d2b23302fd84","result": {"renderUrl": "https://renders.urlbox.io/urlbox1/renders/6215a3df94d7588f7d910513/2022/7/6/19a59ab6-a5aa-4cde-86cb-d2b23302fd84.png","size": 34097},"meta": {"startTime": "2022-07-06T17:49:18.593Z","endTime": "2022-07-06T17:49:21.103Z"}}'; + $content = '{"event": "render.succeeded","renderId": "19a59ab6-a5aa-4cde-86cb-d2b23302fd84","result": {"renderUrl": "https://renders.urlbox.com/urlbox1/renders/6215a3df94d7588f7d910513/2022/7/6/19a59ab6-a5aa-4cde-86cb-d2b23302fd84.png","size": 34097},"meta": {"startTime": "2022-07-06T17:49:18.593Z","endTime": "2022-07-06T17:49:21.103Z"}}'; $header = 't=1657129761,sha256=ddbceae3998704c0b264d8e8c1d486df9f1c0b6cdb77e6e13ce7de4a72fbd81d'; $urlbox = new Urlbox( 'API_KEY', 'API_SECRET', 'INCORRECT_WEBHOOK_SECRET' ); From b756f714df8cfd348fd025b4456b3d9ae52758b4 Mon Sep 17 00:00:00 2001 From: Arnold Cubici-Jones Date: Tue, 27 Aug 2024 10:46:30 +0100 Subject: [PATCH 2/6] refactor(readme): add related SDK repositories to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c1703bd..7ac09b7 100755 --- a/README.md +++ b/README.md @@ -130,6 +130,8 @@ You can find the full list of available options within the [docs](https://urlbox ## Other implementations * [Node.js](https://github.com/urlbox-io/urlbox-screenshots-node) +* [Ruby](https://github.com/urlbox/urlbox-ruby) +* [Python](https://github.com/urlbox/urlbox-python) ## Contributing From c1a340ab12503594d372c16f3152c359b34e27b5 Mon Sep 17 00:00:00 2001 From: Arnold Cubici-Jones Date: Fri, 11 Oct 2024 10:44:49 +0100 Subject: [PATCH 3/6] feat(repo): Add more descriptive docblocks --- src/Urlbox.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Urlbox.php b/src/Urlbox.php index dc2a50d..c2c86af 100644 --- a/src/Urlbox.php +++ b/src/Urlbox.php @@ -36,6 +36,8 @@ public function __construct( string $apiKey, string $apiSecret, ?string $webhook } /** + * Ensure the user has passed an API key and secret. + * * @param string $apiKey * @param string $apiSecret * @@ -55,6 +57,8 @@ private function ensureIsValidCredentials( string $apiKey, string $apiSecret ) } /** + * Returns a new instance of Urlbox + * * @param string $apiKey * @param string $apiSecret * @param string|null $webhookSecret @@ -69,8 +73,9 @@ public static function fromCredentials( string $apiKey, string $apiSecret, ?stri } /** + * Calls the Urlbox /sync endpoint * @param array $options - * @param string|null $saveToDiskPath + * @param string|null $saveToDiskPath - A path to save the image to * * @return array{renderUrl: string, size: int, localPath: string} * @throws GuzzleException @@ -89,8 +94,9 @@ public function render( array $options, ?string $saveToDiskPath = null ): array } /** - * @param string $endpoint - * @param array $options + * Make a POST request to Urlbox + * @param string $endpoint - The endpoint EG /sync + * @param array $options - The render options * * @return array{renderUrl: string, size: int} * @throws GuzzleException From e2f72c47bafde8a1223824ee6b7a0d2a77c830f0 Mon Sep 17 00:00:00 2001 From: Arnold Cubici-Jones Date: Fri, 11 Oct 2024 11:11:15 +0100 Subject: [PATCH 4/6] fix(repo): fix readme link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ac09b7..52be90a 100755 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ You can find your API Credentials and Webhook Secret [here](https://www.urlbox.c ## Usage -You will need a [Urlbox](https:// account to use this package. Please signup [here](https://urlbox.com/pricing) and get your API Key and Secret from the Urlbox dashboard once you have logged in. +You will need a [Urlbox](https://urlbox.com) account to use this package. Please signup [here](https://urlbox.com/pricing) and get your API Key and Secret from the Urlbox dashboard once you have logged in. Here is a sample call to generate a Urlbox screenshot URL: From 7c957893dd744ec3edb190302794c0c44ccc0a51 Mon Sep 17 00:00:00 2001 From: Arnold Cubici-Jones Date: Fri, 11 Oct 2024 11:34:51 +0100 Subject: [PATCH 5/6] fix(tests): Update the hash in webhook tests to be from urlbox.com --- tests/UrlboxTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UrlboxTest.php b/tests/UrlboxTest.php index e4556ed..eaef598 100644 --- a/tests/UrlboxTest.php +++ b/tests/UrlboxTest.php @@ -581,7 +581,7 @@ public function testVerifyWebhookSignatureThrowsExceptionWhenHeaderIsEmpty() public function testVerifyWebhookSignatureReturnsTrueWhenSignatureMatches() { $content = '{"event": "render.succeeded","renderId": "19a59ab6-a5aa-4cde-86cb-d2b23302fd84","result": {"renderUrl": "https://renders.urlbox.com/urlbox1/renders/6215a3df94d7588f7d910513/2022/7/6/19a59ab6-a5aa-4cde-86cb-d2b23302fd84.png","size": 34097},"meta": {"startTime": "2022-07-06T17:49:18.593Z","endTime": "2022-07-06T17:49:21.103Z"}}'; - $header = 't=1657129761,sha256=ddbceae3998704c0b264d8e8c1d486df9f1c0b6cdb77e6e13ce7de4a72fbd81d'; + $header = 't=1657129761,sha256=294a474c8dea35399fdffb65ce0086c4a975bcdf788b57fdd25608d406b7abd9'; $urlbox = new Urlbox( 'API_KEY', 'API_SECRET', 'WEBHOOK_SECRET' ); From 56c4b29b726a2048b8e27cf91077a2b69215796c Mon Sep 17 00:00:00 2001 From: Arnold Cubici-Jones Date: Fri, 11 Oct 2024 11:42:55 +0100 Subject: [PATCH 6/6] feat(repo): add description to docblock of verifyWebhookSignature --- src/Urlbox.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Urlbox.php b/src/Urlbox.php index c2c86af..f6f1e1a 100644 --- a/src/Urlbox.php +++ b/src/Urlbox.php @@ -207,6 +207,7 @@ private function encodeURIComponent( string $value ): string } /** + * Verifies the signature of an incoming webhook request to ensure its authenticity. * @param string $header * @param string $content *