diff --git a/URLsigner/01-CurrentSecret.png b/URLsigner/01-CurrentSecret.png new file mode 100644 index 0000000..87e5d8c Binary files /dev/null and b/URLsigner/01-CurrentSecret.png differ diff --git a/URLsigner/02-Import-Module.png b/URLsigner/02-Import-Module.png new file mode 100644 index 0000000..cfea026 Binary files /dev/null and b/URLsigner/02-Import-Module.png differ diff --git a/URLsigner/03-Set-SecretKey.png b/URLsigner/03-Set-SecretKey.png new file mode 100644 index 0000000..e653c4a Binary files /dev/null and b/URLsigner/03-Set-SecretKey.png differ diff --git a/URLsigner/04-url1.png b/URLsigner/04-url1.png new file mode 100644 index 0000000..ac1742c Binary files /dev/null and b/URLsigner/04-url1.png differ diff --git a/URLsigner/05-signStaticUrl.png b/URLsigner/05-signStaticUrl.png new file mode 100644 index 0000000..d4498ed Binary files /dev/null and b/URLsigner/05-signStaticUrl.png differ diff --git a/URLsigner/06-Protect-StaticUrl.png b/URLsigner/06-Protect-StaticUrl.png new file mode 100644 index 0000000..70be975 Binary files /dev/null and b/URLsigner/06-Protect-StaticUrl.png differ diff --git a/URLsigner/07-ProtectUrl.png b/URLsigner/07-ProtectUrl.png new file mode 100644 index 0000000..81a80df Binary files /dev/null and b/URLsigner/07-ProtectUrl.png differ diff --git a/URLsigner/08-badUrl.png b/URLsigner/08-badUrl.png new file mode 100644 index 0000000..a47ec2e Binary files /dev/null and b/URLsigner/08-badUrl.png differ diff --git a/URLsigner/09-TestUrl.png b/URLsigner/09-TestUrl.png new file mode 100644 index 0000000..fe37112 Binary files /dev/null and b/URLsigner/09-TestUrl.png differ diff --git a/URLsigner/10-unsignedUrls.txt.png b/URLsigner/10-unsignedUrls.txt.png new file mode 100644 index 0000000..30c2f82 Binary files /dev/null and b/URLsigner/10-unsignedUrls.txt.png differ diff --git a/URLsigner/11-Get-Content.png b/URLsigner/11-Get-Content.png new file mode 100644 index 0000000..61de160 Binary files /dev/null and b/URLsigner/11-Get-Content.png differ diff --git a/URLsigner/README.md b/URLsigner/README.md new file mode 100644 index 0000000..f8aa221 --- /dev/null +++ b/URLsigner/README.md @@ -0,0 +1,131 @@ +# URLsigner +### a PowerShell module to add digital signatures +### to Google Static Maps and Static Street View URLs +--- +## Installation +Copy the URLsigner folder containing the staticSigner.psm1 file to your PowerShell user module path +* On Windows systems, copy the URLsigner folder to ```$HOME\Documents\PowerShell\Modules``` +* On non-Windows systems, copy URLsigner to ```$HOME/.local/share/powershell/Modules``` +--- +## Set default URL Signing Secret (optional) +To add a digital signature to a Google Static Maps or Static Street View URL, +you need to use the **URL Signing Secret** from your Google API project. + +The staticSigner.psm1 file has a dummy URL Signing Secret set as the default: +```$script:secretKey = "aBcDeFgHiJkLmNoPqRsTuVwXyZ-="``` +This is the correct format for a Signing Secret and can be used to generate a sample signed URL, +but the signed URL will not be valid. + +You can specify a valid URL Signing Secret each time you import the module, +or you can edit staticSigner.psm1 to include your URL Signing Secret as the default. + +#### **To set the default URL Signing Secret to the one from your Google Cloud project:** +1. Go to the [Maps APIs Credentials](https://console.cloud.google.com/google/maps-apis/credentials) page of your API project. +2. Select the Maps Static API or Static Street View API from the list at the top marked "All Google Maps Platform APIs" +3. Copy the 28-character Current Secret (including the "=" sign at the end) +![URL Signing Secret in API project](./01-CurrentSecret.png) +4. Open the URLsigner/URLsigner.psm1 file in a code editor +5. Find the line starting with +```$script:secretKey = ``` +and replace the dummy signing secret with the one from your project +6. Save the URLsigner.psm1 file +--- +## Importing the module and preparing to sign URLs +After you've saved the ```URLsigner``` folder containing the ```URLsigner.psm1``` file to your PowerShell profile path, you can import the module from a PowerShell command line: +**```PS> Import-Module URLsigner```** +![Import-Module command](./02-Import-Module.png) +Before signing a Static Maps or Static Street View URL, you need to run the ```Set-SecretKey``` command: +**```PS> Set-SecretKey "jdW0fdx88bGYVwTCxIjWSpBJMoo="```** +![Set-SecretKey command](./03-Set-SecretKey.png) +(this secret key has already been regenerated -- get your actual URL Signing Secret from the [Maps-APIs Credentials](https://console.cloud.google.com/google/maps-apis/credentials) page of your project) +If you've already edited URLsigner.psm1 to replace the dummy default key with your actual URL Signing Secret, you can use: +**```PS> Set-SecretKey```** +to use the default you've set. + +--- + +## Signing a URL +After you've imported the module and run Set-SecretKey, you can use the ```signStaticUrl``` function to add a digital signature to a Static Maps or Static Street View URL: +**```PS> $url_1 = "https://maps.googleapis.com/maps/api/staticmap?center=Royal+Greenwich+Observatory,London,England&zoom=14&size=640x640&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U"```** +![Set a variable $url equal to a URL string](./04-url1.png) +(note: this API key AIza...C1MMU has already been regenerated and is expired) + +**```PS> signStaticUrl $url_1```** +```https://maps.googleapis.com/maps/api/staticmap?center=Royal+Greenwich+Observatory,London,England&zoom=14&size=640x640&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U&signature=omVx1LZnFWT2kmnBXdwaUiDMNxE=``` +![run the signStaticUrl function on $url1](./05-signStaticUrl.png) + +The URLsignermodule creates two aliases, ```Protect-StaticUrl``` and ```Protect-Url```, for the ```signStaticUrl``` function: + +**```PS> Protect-StaticUrl $url_1```** +```https://maps.googleapis.com/maps/api/staticmap?center=Royal+Greenwich+Observatory,London,England&zoom=14&size=640x640&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U&signature=omVx1LZnFWT2kmnBXdwaUiDMNxE=``` +![use the Protect-StaticUrl alias on $url1](./06-Protect-StaticUrl.png) + +You can see that both ```signStaticUrl``` and ```Protect-StaticUrl``` generate the same signature ```omVx1LZnFWT2kmnBXdwaUiDMNxE=``` for $url_1 + +**```PS> $url_2 = "https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris,France&zoom=14&size=640x640&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U"```** + +**```PS> Protect-Url $url_2```** +```https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris,France&zoom=14&size=640x640&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U&signature=BhiRbuHKA-9TBW1kmeitFN1ObuA=``` + +![use the Protect-Url alias instead of signStaticUrl](./07-ProtectUrl.png) +--- + +## Re-signing a previously signed URL + +If the URL was already signed using a different URL Signing Secret, the ```signStaticUrl``` function (and its aliases) will remove the old signature before creating a new signature and adding it to the URL: +**```PS> Set-SecretKey```** +```$secretKey set to default value (edit URLsigner.psm1 to change default value)``` +**```PS> $signed_url = Protect-StaticUrl $url_2```** +**```PS> $signed_url```** +```https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris,France&zoom=14&size=640x640&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U&signature=JR7YxKgwk7gQjqhYWu3NFhydsW8=``` +**```PS> Set-SecretKey "jdW0fdx88bGYVwTCxIjWSpBJMoo="```*** +```$secretKey has been set``` +**```PS> $signed_url = Protect-StaticUrl $signed_url```** +**```PS> $signed_url```** +```https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris,France&zoom=14&size=640x640&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U&signature=BhiRbuHKA-9TBW1kmeitFN1ObuA=``` + +--- + +## Test-StaticUrl +If the URL is missing a required Static Maps parameter, such as the &size= parameter, the signStaticUrl function will return an error: +**```PS> $badUrl = "https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris,France&zoom=14&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U"```** + +**```PS> signStaticUrl $badUrl```** +```signStaticUrl: Invalid Static URL:``` +```signStaticUrl: >> https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris,France&zoom=14&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9UsignStaticUrl: use: 'Test-StaticUrl -Verbose' for more information``` +![run signStaticUrl on a URL missing a required parameter creates an error](./08-badUrl.png) + +As the error message notes, you can use ```Test-StaticUrl``` with the ```-Verbose``` parameter for more information: +**```PS> Test-StaticUrl $badUrl```** +```VERBOSE: URL being tested:VERBOSE: https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris,France&zoom=14&scale=2&language=en-EN&key=AIzaSyAY4gcXw6gp_mlQ8qKisL5sE23LMC1MM9U``` +```VERBOSE: URL must include a size parameter like "&size=640x400``` +![use Test-StaticUrl $badUrl -Verbose to get an idea of the problem](./09-TestUrl.png) + +--- + +## Using signStaticUrl and Test-StaticUrl in pipelines +The ```signStaticUrl``` function, its aliases, and the ```Test-StaticUrl``` function can be used in a PowerShell pipeline. + +For example, if you have a list of Static Maps URLs in a text file: +![list the URLs in unsignedUrls.txt.png](./10-unsignedUrls.txt.png) +You can use: +**```Get-Content ./unsignedURLs.txt | Protect-StaticUrl```** +to sign each URL +![Get the URLs and run Protect-StaticUrl in a PowerShell pipeline](./11-Get-Content.png) + +Of course, you can redirect the signed URLs to a new file: +**```Get-Content ./unsignedURLs.txt | Protect-StaticUrl >signedURLs.txt```** + +--- + +## Using signStaticUrl on objects in a pipeline +If you have a .CSV file containing lines of data about a number of locations (including a URL field in each row), you can use PowerShell's ```ForEach-Object```, ```Import-CSV``` and ```Export-CSV``` commands with ```signStaticUrl``` to create a new .CSV file with signed URLs. + +For example, if you have a ```locations.csv``` file with a list of retail locations, each with a store_number and a map_URL field, you can create ```locations_with_signature.csv``` using: + +**```PS > Import-Csv ./locations.csv | ```** +**```>> ForEach-Object {```** +**```>> $_.map_url = signStaticUrl $_.map_url; $_```** +**```>> } | Export-Csv ./locations_with_signature.csv```** + +--- \ No newline at end of file diff --git a/URLsigner/URLsigner.psm1 b/URLsigner/URLsigner.psm1 new file mode 100644 index 0000000..f163035 --- /dev/null +++ b/URLsigner/URLsigner.psm1 @@ -0,0 +1,296 @@ +# This Powershell module creates a function, signStaticUrl, that can be used to digitally sign Google Static Maps or Street View Static URLs +# To use this module from a PowerShell command prompt, +# save ths module file (URLsigner.psm1) to your PowerShell module path, then run: +# PS > Import-Module URLsigner +# +# or save the module file to any local directory, cd to that directory, and run: +# PS > Import-Module ./URLsigner +# +# After importing the module, you can use +# PS > Get-Help Set-SecretKey +# or +# PS > Get-Help signStaticUrl +# for more information on these functions +# +# Once the module has been imported, use Set-SecretKey to set the URL Signing Secret before signing any URLs: +# PS > Set-SecretKey "[URL Signing Secret from your Google API project]" +# +# After importing the module and using Set-SecretKey, you can sign one or more URLs using the signStaticUrl function: +# PS > signStaticUrl "https://maps.googleapis.com/maps/api/staticmap?center=Royal+Observatory+Greenwich,London&size=640x640&zoom=18&key=[YOUR API KEY]" +# PS > signStaticUrl "https://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower,Paris&size=500x500&zoom=19&maptype=satellite&key=[YOUR API KEY]" +# ... +# +# If you have a file 'unsignedURLs.txt" containing Static Maps URLs, you can create a file 'signedURLs.txt' by: +# PS > Set-SecretKey "[URL Signing Secret from your Google API project]" +# PS > Get-Content ./unsignedURLs.txt | signStaticUrl | Out-File signedURLs.txt +# +# +# If you have a .CSV file containing lines of data about a number of locations, including a field for mapUrl, +# you can add a signature to the mapUrl field for each line and create a new .CSV file using: +# PS > Set-SecretKey "[URL Signing Secret from your Google API project]" +# PS > Import-Csv ./locations.csv | ForEach-Object {$_.mapUrl = signStaticUrl $_.mapUrl; $_} | Export-Csv ./locations_with_signature.csv +############################# + + +# create a PowerShell multiline string variable $code that contains the C# code needed to create a _SignUrl .NET class +# (adapted from https://developers.google.com/maps/documentation/maps-static/get-api-key#c ) +$code = @" +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; +using System.Web; + +public class _SignUrl + +{ + public string Sign(string url, string secretKey ) { + ASCIIEncoding encoding = new ASCIIEncoding(); + + // converting key to bytes will throw an exception, + // need to replace '-' and '_' characters first. + string usableSecretKey = secretKey.Replace("-", "+").Replace("_", "/"); + byte[] secretKeyBytes = Convert.FromBase64String(usableSecretKey); + + Uri uri = new Uri(url); + byte[] encodedPathAndQueryBytes = encoding.GetBytes(uri.LocalPath + uri.Query); + + // compute the hash + HMACSHA1 algorithm = new HMACSHA1(secretKeyBytes); + byte[] hash = algorithm.ComputeHash(encodedPathAndQueryBytes); + + // convert the bytes to string and make url-safe + // by replacing '+' and '/' characters + string signature = Convert.ToBase64String(hash).Replace("+", "-").Replace("/", "_"); + + // Add the signature to the existing URI. + return uri.Scheme+"://"+uri.Host+uri.LocalPath + uri.Query +"&signature=" + signature; + } +} +"@ + +# add the .NET class _SignUrl to this PowerShell session +Add-Type -TypeDefinition $code + +# define the $secretKey variable at script-level +$secretKey = "" + +function Set-SecretKey { +<# +.SYNOPSIS +Sets the Google Maps URL Signing Secret needed by signStaticUrl() +.DESCRIPTION +This function sets the "URL Signing Secret" that is needed by signStaticUrl() + +The URL Signing Secret is an alphanumeric code ending in "=", +like "AbCdEfGhIjKlMnOpQrStUvWxYz9=" + +You can retrieve the URL Signing Secret from your Google API project +by visiting https://console.cloud.google.com/google/maps-apis/credentials, +and selecting the Maps Static API or Street View Static API from the list labeled "All Google Maps Platform APIs" + +To set the Signing Secret to a default value (listed below): +Set-SecretKey + +To set the Signing Secret to a different value: +Set-SecretKey [URL Signing Secret from your Google API project] + +.LINK +https://developers.google.com/maps/documentation/maps-static/get-api-key#gen-sig +.LINK +https://console.cloud.google.com/google/maps-apis/credentials +#> + [cmdletBinding()] + Param( [string]$secret ) + + # set the script-level $secretKey to the supplied value if one has been supplied as a parameter to this function + if($secret){ + if($secret -match "^[\w-]{27}=$") { + $script:secretKey = $secret + '$secretKey has been set' + } else { + "$secret is not an expected value for a Static Maps URL Signing Secret" + "" + 'A Static Maps URL Signing Secret is a 28-character alphanumeric string ending in "=", like "AbCdEfGhIjKlMnOpQrStUvWxYz3=" ' + "" + 'You can retrieve the URL Signing Secret from your Google API project' + 'by visiting https://console.cloud.google.com/google/maps-apis/credentials,' + 'and selecting the Maps Static API or Street View Static API from the list labeled "All Google Maps Platform APIs"' + } + } else { + # you can edit the following line to set the URL Signing Secret to the one from your project + # this is the default (dummy) secretKey line: + # $script:secretKey = "" + # + # this was the correct Secret Key from this project (ID esp-0001) as of March 21, 2023: srY1TIV5taqb0NcpenkJVZOKsjo= + # + $script:secretKey = "aBcDeFgHiJkLmNoPqRsTuVwXyZ-=" + '$secretKey set to default value (edit URLsigner.psm1 to change default value)' + } +} + +# display the current $secretKey +function Get-SecretKey { $secretKey } + +function Test-StaticUrl { +<# +.SYNOPSIS +Boolean function to check Static Map or Static Street View URL for validity +.DESCRIPTION +Function returns PowerShell $true if passed URL string is valid, $false if not. +This is not a definitive check - for example, +the function checks to see that the URL contains an API key or client ID parameter in the correct format, +but does not verify that the API key or client ID is still active and has billing enabled. + +.EXAMPLE +Test a single URL: +PS > $landmark = "https://maps.googleapis.com/maps/api/staticmap?center=Tour+Eiffel,Paris&zoom=17&size=400x400&key=AIzaSy_ABCDEFGHIJKLMNOPQRSTUVXYZ123456" +PS > Test-StaticUrl $landmark +.EXAMPLE +Use the -Verbose option to +PS > $landmark = "https://maps.googleapis.com/maps/api/staticmap?center=Tour+Eiffel,Paris&zoom=17&size=400x400&key=bogus_API_key_too_short" +PS > Test-StaticUrl $landmark -Verbose +.EXAMPLE +Import from a .CSV file (with "store number" and "url" properties), select the lines with valid URLs, sign those URLs, then export to a new file: +PS > Set-SecretKey "AbCdEfGhIjKlMnOpQrStUvWxYz9=" +PS > Import-Csv ./unsignedStores.csv | Where-Object {Test-StaticUrl $_.url} | ForEach-Object {$_.url = signStaticUrl $_.url; $_} | Export-Csv ./signedStores.csv + +.LINK +https://developers.google.com/maps/documentation/maps-static/start +.LINK +https://developers.google.com/maps/documentation/streetview/overview +#> + [cmdletBinding()] + Param( + [Parameter( + Mandatory=$true, + Position=0, + ValueFromPipeline=$true + )] + [string]$url + ) + # assume URL is good until proven otherwise + $validURL = $true + + Write-Verbose "URL being tested:" + Write-Verbose "$url" + + # start by checking to see whether the URL includes an API key or client ID parameter + # current Google API keys are 39-character Base64 strings that start with AI + # Google Maps client IDs are IDs like "gme-samplecompany" from Google Maps Premium Plan projects + # They are NOT the same as the "OAuth 2.0 Client IDs" found on the Credentials page of your Google Cloud API project + if ( $url -notmatch "[?&]client=gme-[A-Za-z0-9]+|[?&]key=AI[\w-]{37}[^\w-]|[?&]key=AI[\w-]{37}$" ) { + Write-Verbose 'URL does not contain a valid Premium Plan Client ID (like "gme-abcd...") or 39-character API key (like "&key=AIza...") parameter' + $validURL = $false + } + + # now see if the first part of the URL could be a valid Static Map or Street View URL + if ( $url -notmatch "^https://maps.googleapis.com/maps/api/[staticmap|streetview]?") { + Write-Verbose 'URL must start with "https://maps.googleapis.com/maps/api/staticmap?" or "https://maps.googleapis.com/maps/api/streetview?"' + $validURL = $false + } + + # size=###x### is a required parameter for both Static Street View and Static Maps + if ( $url -notmatch "[?&]size=\d+x\d+") { + Write-Verbose 'URL must include a size parameter like "&size=640x400" ' + $validURL = $false + } + + # check for other required parameters for Static Maps - need both center and zoom unless markers are specified + if ( $url -match "^https://maps.googleapis.com/maps/api/staticmap\?") { + if ( $url -notmatch "[?&]markers=") { + if (( $url -notmatch "[?&]center=" ) -or ( $url -notmatch "[?&]zoom=\d+" ) ) { + Write-Verbose 'Each Static Maps URL must include both "¢er=..." and "&zoom=" parameters, unless markers have been specified' + $validUrl = $false + } + } + } + # check for the other required parameters for Static Street View - need either location or pano + if ( $url -match "^https://maps.googleapis.com/maps/api/streetview\?" ) { + if ( ( $url -notmatch "[?&]location=" ) -and ( $url -notmatch "[?&]pano=" ) ) { + Write-Verbose 'Each Static Street View URL must include either "&location=..." or "&pano=..." parameters ' + $validURL = $false + } + } + if($validURL) {Write-Verbose "No problems found with URL"} + return $validURL +} + +Set-Alias -Name Test-Url -Value Test-StaticUrl + +function signStaticUrl { +<# +.SYNOPSIS +Function to digitally sign Google Static Maps / Static Street View URLS + +.DESCRIPTION +signStaticUrl is a PowerShell function to compute a digital signature for a Google Static Map or Static Street View URL, +add the digital signature to the URL, then return the signed URL. + +signStaticurl uses Test-StaticUrl to verify that the $url is valid. You can use + -ErrorAction SilentlyContinue +to suppress the error message when piping in a file of URLs in a pipeline + +If the input URL has already been signed (that is, it has a "&signature=..." parameter at the end), the function removes the +previous signature parameter, signs the remaining URL, and appends the new signature in place of the old signature + +signStaticUrl can be used as a command-line function, or in a PowerShell pipeline - see EXAMPLEs for more + +NOTE: before signing the first URL, you must use 'Set-SecretKey' to set the URL Signing Secret +Use 'Get-Help Set-SecretKey' for more information + +.EXAMPLE +PS > Set-SecretKey "ThIsNoTaVaLiDsEcReTkEy-3579=" +PS > signStaticUrl "https://maps.googleapis.com/maps/api/staticmap?center=51.47,0.0&zoom=14&size=500x400..." + +returns: +https://maps.googleapis.com/maps/api/staticmap?center=51.47,0.0&zoom=14&size=500x400...&signature=... + +.EXAMPLE +PS > Set-SecretKey "AbCdEfGhIjKlMnOpQrStUvWxYz3=" +PS > Get-Content ./unsignedUrls.txt | signStaticUrl -ErrorAction SilentlyContinue | Out-File ./signedUrls.txt + +This uses signStaticUrl in a PowerShell pipeline to sign one or more URLs from a text file +and save the signed URLs to a new file (overwrites the signedUrls.txt file if it exists) +The '-ErrorAction SilentlyContinue' suppresses the error message for invalid URLs + +.LINK +https://developers.google.com/maps/documentation/maps-static/get-api-key#gen-sig + +#> + [cmdletBinding()] + Param( + [Parameter( + Mandatory=$true, + Position=0, + ValueFromPipeline=$true, + ValueFromPipelineByPropertyName=$true + )] + [string]$url + ) + + begin { + if ( $secretKey.Length -eq 0) { + Write-Error 'You must use Set-SecretKey to set the $secretkey before signing URLs' -ErrorAction Stop + } + $script:signer = New-Object _SignUrl + } + process { + if ( -not(Test-StaticUrl $url)){ + Write-Error "Invalid Static URL:" + Write-Error ">> $url" + Write-Error "use: 'Test-StaticUrl -Verbose' for more information" + } else { + # if the URL has been signed previously, remove the signature parameter before signing with the current key + $url = $url -replace '&signature=.*$', '' + $script:signer.Sign($url, $secretKey) + } + } + end {} +} + +Set-Alias -Name Protect-StaticUrl -Value signStaticUrl +Set-Alias -Name Protect-Url -Value signStaticUrl + +"", "Run Set-SecretKey before using signStaticUrl() function for the first time", "Use 'Get-Help signStaticUrl' to learn more", "" | Write-Host \ No newline at end of file