feat(deviceapi): POST /v1/devices for NH Installation upserts (PR-2.A)#40
Merged
Conversation
First Phase 2 PR. Registers iOS devices to the Notification Hub so PushDelivery (next PR) can fan out by tag. src/Notify.DeviceApi/ - Functions/RegisterDeviceFunction.cs — HTTP shim, AuthorizationLevel.Function (devices are user-owned, not project-scoped, so the npk_ project-key model doesn't fit; the iOS app will fetch the function key once via TestFlight build). - Devices/RegisterHandler.cs — pure logic; sha256(deviceToken) → installationId for idempotent CreateOrUpdate semantics. - Devices/DeviceRegistrationValidator.cs — local validator: hex token 64..256 chars, platform=apns only, ≤50 tags ≤120 chars each. - INotificationHub.cs — seam over NotificationHubClient so unit tests don't need a real hub. - Microsoft.Extensions.Caching.Memory pinned to 9.0.0 (NH SDK 4.2.0 pulls 6.0.1 transitively, which has GHSA-qj66-m88j-hmgj). Same dance as the OTel 1.15.3 pin in IngestionApi/Archive. infra/ - notificationhub.bicep: surface DefaultFullSharedAccessSignature connection string as a @secure() output so functions.bicep can plumb it. - main.bicep: wire NH outputs into functions module params; reorder so NH declaration sits right above functions for readability. - functions.bicep: new params NotificationHub{ConnectionString,Name}; add to the production Function App's appSettings. DeviceApiOptions binds them. Tests: 9 unit tests in Notify.DeviceApi.Tests covering the result-type matrix, validator branches, idempotent-id property, and case-sensitivity gotcha. Out of scope: APNs .p8 upload (manual via az/portal — Bicep can't accept the file contents). Real-NH integration tests + the sub-push EG subscription land in PR-2.B (Notify.PushDelivery), which auto-enables once src/Notify.PushDelivery/ exists per the path-presence flag in cd-deploy.yml.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First Phase 2 PR. Registers iOS devices to the Notification Hub so PushDelivery (PR-2.B) can fan out by tag.
```
POST /v1/devices (AuthorizationLevel.Function)
{ "deviceToken": "", "platform": "apns", "tags": ["source:home-pipeline"] }
→ 202 { "installationId": "<sha256(deviceToken)>" }
```
Design notes
Bicep
Dependency pin
`Microsoft.Azure.NotificationHubs 4.2.0` transitively pulls `Microsoft.Extensions.Caching.Memory 6.0.1` which has GHSA-qj66-m88j-hmgj (high). Pinning the package to `9.0.0` directly — same pattern as the OTel 1.15.3 pins in PR #21 / #33.
Test plan
Out of scope (follow-ups)