chore: Move common logic to shared package - #325
Conversation
…mon code Replace the duplicated shared utility/validation/crypto/geo/dynamic-LINQ/ ASP.NET code in Common/ with references to the published packages OpenShock.Internal.Common, OpenShock.Internal.AspNet and OpenShock.Internal.DynamicLinq (pinned at 0.0.1). - Delete 38 now-redundant files (exact duplicates + the PasswordHashingAlgorithm enum + the Cloudflare IP generation, now owned by the package). - Re-point ~150 consumers to the OpenShock.Internal.* namespaces. - OpenShockControllerBase now inherits the package base, keeping API-specific session/cookie/legacy-response helpers. - Split HardLimits: shared limits come from the package, API-specific extras move to a new local ApiHardLimits. - Split IQueryableExtensions: ApplyFilter/ApplyOrderBy from the package, WhereUserIdMatches/WhereIsUserOrPrivileged stay local. - Adapt to package surface changes: CryptoUtils.RandomString rename, OpenShockProblem.WriteAsJsonAsync / OpenShockExceptionHandler now take JsonSerializerOptions (registered JsonOptions.Default in DI), ApplyOrderBy is now static. - Bump BCrypt.Net-Next 4.2.0 -> 4.2.1 (required by OpenShock.Internal.Common). - Drop the 6 Common.Tests files now covered by the packages' own test projects.
|
Ready to review this PR? Stage has broken it down into 12 individual chapters for you: Chapters generated by Stage for commit cbfce0f on Jul 3, 2026 10:21am UTC. |
Add a Paired value to DeviceUpdateType and emit it to the device owner after a pair code is consumed, so clients are notified when a device pairs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
feat: emit DeviceUpdateType.Paired when a device consumes a pair code
Reconciles develop's email-outbox, user-audit-log, health-check and
pg-enum work with this branch's move onto the OpenShock.Internal.*
packages.
Conflict resolutions:
- Directory.Packages.props: kept develop's health-check packages and the
newer BCrypt 4.2.1; dropped the BCrypt reference entirely since
HashingUtils now ships in OpenShock.Internal.Common.
- AccountService: took develop's lazy token minting (the outbox delivery
job mints the real token at send time), dropping the eager
CryptoUtils calls this branch had only renamed.
- OpenShockServiceHelper: OpenShock.Internal.Common.ExceptionHandling
alongside develop's new HealthChecks.
- HardLimits/HashingUtils/HashingUtilsTests: stay deleted (provided by
OpenShock.Internal.Common). develop's new constants
(EmailOutbox{LastError,CoalesceKey}MaxLength, AuditReasonMaxLength)
moved into ApiHardLimits, and the API-specific references repointed.
Follow-up fixes so develop's new code builds against the packages:
- EmailOutboxList: OpenShock.Common.Query -> OpenShock.Internal.DynamicLinq.
- EmailOutboxDispatcher / Cron.IntegrationTests: CryptoUtils and
HashingUtils from OpenShock.Internal.Common,
RandomAlphaNumericString -> RandomString.
- Cron.IntegrationTests.csproj: GitHashAttribute from the package.
Also pins SSH.NET 2026.0.0 (transitive via Testcontainers) to clear
GHSA-q939-rpr3-3284, which was failing restore under NuGetAudit.
|
Important Review skippedToo many files! This PR contains 206 files, which is 106 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (206)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ocal 0.1.1 removed HashingUtils and PasswordHashingAlgorithm from OpenShock.Internal.Common, and no other OpenShock.Internal.* package picked them up. Everything else in the 0.0.1 -> 0.1.1 range is unchanged: AspNet and DynamicLinq are API-identical, and Common's only delta is those removals. So the ~38 HashingUtils call sites across API, Common, Cron, SeedE2E and both integration test projects (HashPassword/VerifyPassword/HashToken/VerifyToken/ HashSha256) move back onto a local copy, restored from develop along with its tests. BCrypt.Net-Next comes back with it; LatencyEmulator and PBKDF2PasswordHasher stay in the package, which still ships them. PasswordHashingAlgorithm likewise returns to OpenShock.Common.OpenShockDb, where it keeps the [PgEnum]/[PgName] labels the package copy never had. AdminUsersView drops the now-nonexistent OpenShock.Internal.Common.Enums import and resolves the enum from its own namespace. No EF model change. Adds AdminUsersViewTests: admin_users_view.password_hash_type is text derived from the "bcrypt:"/"pbkdf2:" prefix on users.password_hash, not the legacy password_encryption_type enum, so EF converts it by matching enum member names case-insensitively. That coupling had no coverage.
CryptoUtilsTests, LatencyEmulatorTests and MathUtilsTests only exercise OpenShock.Internal.Common.Utils types; they stayed behind when the utilities moved into the package. They now live in OpenShock/Internal.NET (Internal.Common.Tests/Utils), next to the code they cover. The rest of Common.Tests/Utils stays: GravatarUtils, DomainUtils, StringUtils and HashingUtils are all local types, as is UsernameValidator. 177 -> 147 tests here, 47 -> 77 there.
Brings in the Internal.Net package extraction (#325) plus the develop changes since the last sync (healthcheck endpoint, PeriodicTimer rework, share/publicshare token permissions, dependabot/action pins). Conflict resolutions: * Directory.Packages.props: keep the .NET 11 preview pins (Npgsql.EntityFrameworkCore.PostgreSQL, Microsoft.AspNetCore.Mvc.Testing), take develop's NRedisStack bump and the new OpenShock.Internal.* references. OneOf is dropped -- nothing references it since the union refactor. * Common/Results/Unions.cs: OpenShockProblem now lives in OpenShock.Internal.Common.Problems. * Common/Websocket/WebsockBaseController.cs: keep the union pattern match over develop's .AsT1.Value, with develop's new JsonOptions argument on WriteAsJsonAsync. * API/Controller/Account/_Turnstile.cs: drop the now-dead Common.Problems and Common.Results usings.
Uh oh!
There was an error while loading. Please reload this page.