From dc31d63619abe96f91b009a838210f214680d4ef Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:04:52 -0600 Subject: [PATCH 01/13] Update npm package versions --- BlazorSodium/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BlazorSodium/package.json b/BlazorSodium/package.json index 56ba535..335ee72 100644 --- a/BlazorSodium/package.json +++ b/BlazorSodium/package.json @@ -11,13 +11,13 @@ }, "devDependencies": { "path": "^0.12.7", - "vite": "^4.4.9", - "vite-plugin-compression2": "^0.10.3" + "vite": "^6.0.5", + "vite-plugin-compression2": "^1.3.3" }, "dependencies": { "buffer": "^6.0.3", - "crypto-browserify": "^3.12.0", - "libsodium-wrappers-sumo": "^0.7.11", + "crypto-browserify": "^3.12.1", + "libsodium-wrappers-sumo": "^0.7.15", "stream-browserify": "^3.0.0" } } From 96f9e0549d34bc4ac8ab0f71cd766bb76e5af1e5 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:05:41 -0600 Subject: [PATCH 02/13] Target .NET 8.0 and .NET 9.0 --- BlazorSodium.Demo/BlazorSodium.Demo.csproj | 5 +++-- BlazorSodium/BlazorSodium.csproj | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/BlazorSodium.Demo/BlazorSodium.Demo.csproj b/BlazorSodium.Demo/BlazorSodium.Demo.csproj index dd2f02b..0e40220 100644 --- a/BlazorSodium.Demo/BlazorSodium.Demo.csproj +++ b/BlazorSodium.Demo/BlazorSodium.Demo.csproj @@ -8,8 +8,9 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" /> - <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" /> + <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.11" /> + <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.11" PrivateAssets="all" /> + <PackageReference Include="Microsoft.NET.Sdk.WebAssembly.Pack" Version="9.0.0" /> </ItemGroup> <ItemGroup> diff --git a/BlazorSodium/BlazorSodium.csproj b/BlazorSodium/BlazorSodium.csproj index 6fe3b1e..0c0c4cc 100644 --- a/BlazorSodium/BlazorSodium.csproj +++ b/BlazorSodium/BlazorSodium.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk.Razor"> <PropertyGroup> - <TargetFramework>net8.0</TargetFramework> + <TargetFrameworks>net8.0;net9.0</TargetFrameworks> <Nullable>enable</Nullable> <ImplicitUsings>disable</ImplicitUsings> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> @@ -16,8 +16,8 @@ <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance> <IncludeSymbols>True</IncludeSymbols> <SymbolPackageFormat>snupkg</SymbolPackageFormat> - <Version>1.3.2</Version> - <PackageVersion>1.3.2</PackageVersion> + <Version>1.4.0</Version> + <PackageVersion>1.4.0</PackageVersion> <LangVersion>12</LangVersion> </PropertyGroup> @@ -26,7 +26,8 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" /> + <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" /> + <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" Condition="'$(TargetFramework)' == 'net9.0'" /> </ItemGroup> <ItemGroup> From cdf9723fd014dddc557d7a773d02eb27bf2673a8 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:05:50 -0600 Subject: [PATCH 03/13] Add link in README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index df4b901..4768e39 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,7 @@ Now use the static wrapper methods from anywhere in your application. When a Sodium methods returns `byte[]` data, you often need to use `Array.CopyTo(Array array, int index)` to copy the data to an initialized array if you intend to use the data outside of the current scope. Otherwise the `byte[]` may be garbage collected and your variable will be `null`. + +## Useful developer documentation + +[Supported JSInterop types](https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/import-export-interop) \ No newline at end of file From abe524c1e5b64d6da8883ab33921c5b4e565b0a3 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:06:00 -0600 Subject: [PATCH 04/13] publish.yml --- .github/workflows/publish.yml | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ca7e19d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,58 @@ +name: publish +on: + release: + types: + - published # Run the workflow when a new GitHub release is published + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + NuGetDirectory: ${{ github.workspace }}/nuget + +defaults: + run: + shell: pwsh + +jobs: + pack: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 # Get all history to allow automatic versioning using MinVer + + - name: Install pnpm + uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d #v3 + with: + version: 8 + + - name: Setup .NET + uses: actions/setup-dotnet@e4c228a8417679d13c6a1e7131e3e8d82dff4cd3 #v4 + with: + dotnet-version: 9.0.x + + - name: Install wasm-tools + run: dotnet workload install wasm-tools + + - run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} + + push: + if: github.event_name == 'release' + runs-on: ubuntu-latest + steps: + # Download the NuGet package created in the previous job + - uses: actions/download-artifact@d0ce8fd1167ed839810201de977912a090ab10a7 #v4 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + + - name: Setup .NET + uses: actions/setup-dotnet@e4c228a8417679d13c6a1e7131e3e8d82dff4cd3 #v4 + with: + dotnet-version: 9.0.x + + - name: Publish NuGet package + run: | + foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { + dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + } \ No newline at end of file From fc9cce1e8fdd29563d32305f60d6cb74f0a5b2ce Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:08:21 -0600 Subject: [PATCH 05/13] Add manual workflow --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ca7e19d..9637c20 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,6 @@ name: publish on: + workflow_dispatch: # Allow running the workflow manually from the GitHub UI release: types: - published # Run the workflow when a new GitHub release is published From f256cdc7a1929d22646fc4d8324ee4325333e9dc Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:10:14 -0600 Subject: [PATCH 06/13] Use pnpm v9 --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9637c20..826d074 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,7 +25,7 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d #v3 with: - version: 8 + version: 9 - name: Setup .NET uses: actions/setup-dotnet@e4c228a8417679d13c6a1e7131e3e8d82dff4cd3 #v4 From 76c21dc6ac9f5dd09826641c16b0d471b365e4c6 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:22:06 -0600 Subject: [PATCH 07/13] Update dependabot.yml --- .github/dependabot.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a372eb1..8f405e5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,12 @@ version: 2 updates: - - package-ecosystem: "" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: "nuget" + directory: "/" schedule: - interval: "weekly" - + interval: "monthly" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" From e1ebe3bfc87ab6504459681be7e502ac22356800 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:46:32 -0600 Subject: [PATCH 08/13] GenericHash_Init key should be optional --- BlazorSodium/Sodium/GenericHash.Interop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlazorSodium/Sodium/GenericHash.Interop.cs b/BlazorSodium/Sodium/GenericHash.Interop.cs index 4496d48..d2aac6d 100644 --- a/BlazorSodium/Sodium/GenericHash.Interop.cs +++ b/BlazorSodium/Sodium/GenericHash.Interop.cs @@ -58,7 +58,7 @@ public static partial class GenericHash /// <returns></returns> /// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_generichash_init.json"/> [JSImport("sodium.crypto_generichash_init", "blazorSodium")] - internal static partial int Crypto_GenericHash_Init_Interop(byte[] key, [JSMarshalAs<JSType.Number>] long hashLength); + internal static partial int Crypto_GenericHash_Init_Interop(byte[]? key, [JSMarshalAs<JSType.Number>] long hashLength); /// <summary> /// Internal method. From a49c6c560d2ddd49cce64a13eabbc6f5bd6ea4ff Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:46:58 -0600 Subject: [PATCH 09/13] Fix and suppress XML warnings --- BlazorSodium/BlazorSodium.csproj | 8 ++++++++ BlazorSodium/Sodium/PublicKeySignature.Interop.cs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/BlazorSodium/BlazorSodium.csproj b/BlazorSodium/BlazorSodium.csproj index 0c0c4cc..bed984b 100644 --- a/BlazorSodium/BlazorSodium.csproj +++ b/BlazorSodium/BlazorSodium.csproj @@ -21,6 +21,14 @@ <LangVersion>12</LangVersion> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> + <NoWarn>1701;1702;NU5105;CS1591;NU5105;NU5105;CS1584</NoWarn> + </PropertyGroup> + + <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> + <NoWarn>1701;1702;NU5105;CS1591;NU5105;NU5105;CS1584</NoWarn> + </PropertyGroup> + <ItemGroup> <SupportedPlatform Include="browser" /> </ItemGroup> diff --git a/BlazorSodium/Sodium/PublicKeySignature.Interop.cs b/BlazorSodium/Sodium/PublicKeySignature.Interop.cs index 257141e..c901149 100644 --- a/BlazorSodium/Sodium/PublicKeySignature.Interop.cs +++ b/BlazorSodium/Sodium/PublicKeySignature.Interop.cs @@ -91,7 +91,7 @@ public static partial class PublicKeySignature /// <returns></returns> /// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_sign_init.json"/> /// <remarks> - /// Switching the return type to 'long' and applying a [return: JSMarshalAs<JSType.Number>] + /// Switching the return type to 'long' and applying a [return: JSMarshalAs<JSType.Number>] /// attribute does not work any better than simply returning an 'int'. /// /// A 'System.Runtime.InteropServices.JavaScript.JSException' exception is thrown when From 477beacc88022ea5f9c49fdb8d2e6e8ca69b3518 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 12:47:16 -0600 Subject: [PATCH 10/13] Install minver --- BlazorSodium/BlazorSodium.csproj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BlazorSodium/BlazorSodium.csproj b/BlazorSodium/BlazorSodium.csproj index bed984b..e5f4936 100644 --- a/BlazorSodium/BlazorSodium.csproj +++ b/BlazorSodium/BlazorSodium.csproj @@ -16,8 +16,6 @@ <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance> <IncludeSymbols>True</IncludeSymbols> <SymbolPackageFormat>snupkg</SymbolPackageFormat> - <Version>1.4.0</Version> - <PackageVersion>1.4.0</PackageVersion> <LangVersion>12</LangVersion> </PropertyGroup> @@ -36,6 +34,10 @@ <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" /> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" Condition="'$(TargetFramework)' == 'net9.0'" /> + <PackageReference Include="MinVer" Version="6.0.0"> + <PrivateAssets>all</PrivateAssets> + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> + </PackageReference> </ItemGroup> <ItemGroup> From 2556b9db429befea47774b5b7959e7affbcaafbf Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 14:26:52 -0600 Subject: [PATCH 11/13] Get multi-target builds working --- BlazorSodium/BlazorSodium.csproj | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/BlazorSodium/BlazorSodium.csproj b/BlazorSodium/BlazorSodium.csproj index e5f4936..7e86fcc 100644 --- a/BlazorSodium/BlazorSodium.csproj +++ b/BlazorSodium/BlazorSodium.csproj @@ -17,6 +17,7 @@ <IncludeSymbols>True</IncludeSymbols> <SymbolPackageFormat>snupkg</SymbolPackageFormat> <LangVersion>12</LangVersion> + <DisableBuildCompression>true</DisableBuildCompression> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> @@ -46,9 +47,15 @@ </None> </ItemGroup> - <Target Name="PreBuild" BeforeTargets="PreBuildEvent"> + <Target Name="PreBuild" BeforeTargets="DispatchToInnerBuilds"> <Exec Command="pnpm install" /> <Exec Command="pnpm run build" /> </Target> + <Target Name="AfterClean" AfterTargets="Clean"> + <Delete Files="wwwroot\blazorSodium.bundle.js" ContinueOnError="true" /> + <Delete Files="wwwroot\blazorSodium.bundle.js.gz" ContinueOnError="true" /> + <Delete Files="wwwroot\blazorSodium.bundle.js.br" ContinueOnError="true" /> + </Target> + </Project> From 7776ee2a0ee53f44aa541b61834537631ca81021 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 14:30:05 -0600 Subject: [PATCH 12/13] Add MinVer config --- BlazorSodium/BlazorSodium.csproj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/BlazorSodium/BlazorSodium.csproj b/BlazorSodium/BlazorSodium.csproj index 7e86fcc..0c6194f 100644 --- a/BlazorSodium/BlazorSodium.csproj +++ b/BlazorSodium/BlazorSodium.csproj @@ -6,7 +6,7 @@ <ImplicitUsings>disable</ImplicitUsings> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <GenerateDocumentationFile>true</GenerateDocumentationFile> - <GeneratePackageOnBuild>True</GeneratePackageOnBuild> + <IsPackable>true</IsPackable> <Title>BlazorSodium</Title> <Authors>Jack Edwards</Authors> <Description>Simple wrapper over libsodium.js to use in Blazor WASM projects</Description> @@ -57,5 +57,11 @@ <Delete Files="wwwroot\blazorSodium.bundle.js.gz" ContinueOnError="true" /> <Delete Files="wwwroot\blazorSodium.bundle.js.br" ContinueOnError="true" /> </Target> + + <PropertyGroup Label="MinVer"> + <MinVerAutoIncrement>minor</MinVerAutoIncrement> + <MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers> + <MinVerTagPrefix>v</MinVerTagPrefix> + </PropertyGroup> </Project> From 849e8484ba7b371fc2d7dd239e10c5554fe5a738 Mon Sep 17 00:00:00 2001 From: Jack Edwards <jackedwards@protonmail.com> Date: Sat, 21 Dec 2024 14:37:51 -0600 Subject: [PATCH 13/13] Update publish.yml --- .github/workflows/publish.yml | 38 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 826d074..ec1ca49 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,7 +15,7 @@ defaults: shell: pwsh jobs: - pack: + release: runs-on: ubuntu-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -34,26 +34,18 @@ jobs: - name: Install wasm-tools run: dotnet workload install wasm-tools + + - name: Restore + run: dotnet restore + + - name: Build + run: dotnet build -c Release --no-restore - - run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} - - push: - if: github.event_name == 'release' - runs-on: ubuntu-latest - steps: - # Download the NuGet package created in the previous job - - uses: actions/download-artifact@d0ce8fd1167ed839810201de977912a090ab10a7 #v4 - with: - name: nuget - path: ${{ env.NuGetDirectory }} - - - name: Setup .NET - uses: actions/setup-dotnet@e4c228a8417679d13c6a1e7131e3e8d82dff4cd3 #v4 - with: - dotnet-version: 9.0.x - - - name: Publish NuGet package - run: | - foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { - dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate - } \ No newline at end of file + - name: Pack + run: dotnet pack -c Release --no-build --output ${{ env.NuGetDirectory }} + + - name: Push nupkg + run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + + - name: Push snupkg + run: dotnet nuget push ${{ env.NuGetDirectory }}/*.snupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate