Skip to content

Commit aff751d

Browse files
committed
docs(spec): push route with no app list, and the encoded percent refusal
Delta review round 4 prose should-fixes in push-delivery.zod.ts. - A shell with no app list hands route to the Console to resolve, or hosts it under the segment the Console would answer (resolveHostAppSegment: preferred, then first active app, then setup). It never re-implements the resolver and never opens route verbatim. - PushRouteSchema also refuses %25 in the path, which closes the double-encoded separators (%252F, %252E, %255C), pinned; a query or fragment keeps its own encoding. Claude-Session: https://claude.ai/code/session_01ADHkmT6K7dHh79Lej3sWr5 Co-authored-by: Claude <noreply@anthropic.com>
1 parent eb9b237 commit aff751d

4 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎.changeset/29067-push-device-registry-spec.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Nothing here is served or read yet. Every new or touched schema carries a `[PLAN
1212
- **`RegisterDeviceRequestSchema`** gains three optional members: `vendor` (`apns` | `fcm`; absent, the server derives it from `platform`, `ios` → `apns` and `android` → `fcm`, and a `web` registration names `apns` or `fcm`), `appId` and `locale` (a BCP 47 tag, the house `LocaleSchema`). `token`, `platform`, `deviceId` and `name` are unchanged, so every body a client sent before still parses as it did. The describes now say that re-registering a `deviceId` refreshes that device, and that a request without one gets a server-minted id the client keeps. A `vendor` outside `apns` / `fcm` is refused; since the member is new, no body sent before carries one. `RegisterDeviceResponseSchema` and `UnregisterDevice*` keep their members and gain only their description.
1313
- **`UserDeviceSchema`** (new, `system/push-device.zod.ts`) is the stored device: `deviceId`, `userId`, `vendor`, `token`, `platform`, `enabled`, and optional `appId`, `locale`, `name`, `invalidatedAt` and `lastSeenAt`. A device belongs to its user alone (no organization member), a token has one live row (the same user's registration without a `deviceId` refreshes the row that holds it, and a second user's registration takes it over), and a token the vendor reports dead keeps its row with `enabled: false` and `invalidatedAt`.
1414
- **`INotificationService`** gains four optional members: `registerDevice(userId, request)`, `unregisterDevice(userId, deviceId)`, `listDevices(userId)` and `invalidateDeviceToken(token)`. Their docs state the semantics an implementation owes. Absence means the capability is unavailable, so every existing implementation stays valid.
15-
- **`PushDeliveryDataSchema`** (new, `api/push-delivery.zod.ts`) is the data a push carries to the shell: `notificationId` and an optional `route`. `PushRouteSchema` admits only a same-server relative path (one leading `/`; no scheme, host, backslash, whitespace or control character; no dot segment and no percent-encoded `/`, `\` or `.` in its path). The route is derived, never authored: it is the notification's existing `actionUrl` (app-relative `/OBJECT/ID` or an `/apps/…` route) when that passes the schema, and absent otherwise. The shell resolves it on tap as the inbox does, never verbatim. FCM carries this data in `message.data`; APNs at the top level of the payload, beside `aps`. No `notify` key is added.
15+
- **`PushDeliveryDataSchema`** (new, `api/push-delivery.zod.ts`) is the data a push carries to the shell: `notificationId` and an optional `route`. `PushRouteSchema` admits only a same-server relative path (one leading `/`; no scheme, host, backslash, whitespace or control character; no dot segment and no percent-encoded `/`, `\`, `.` or `%` in its path). The route is derived, never authored: it is the notification's existing `actionUrl` (app-relative `/OBJECT/ID` or an `/apps/…` route) when that passes the schema, and absent otherwise. The shell resolves it on tap as the inbox does, never verbatim. FCM carries this data in `message.data`; APNs at the top level of the payload, beside `aps`. No `notify` key is added.
1616
- **`PushServiceConfigSchema`** (new, `system/push-config.zod.ts`, beside the email transport configuration): an `apns` block (token auth: `teamId`, `keyId`, `topic`, `environment: sandbox | production`, the `.p8` key by `credentialRef`) and an `fcm` block (HTTP v1: `projectId`, the service-account JSON by `credentialRef`). Secrets are references only (ADR-0143 D3). An inline secret is refused by name under the keys an operator would reach for, and refused as the content of a reference (a PEM block or a JSON document). `PushVendorSchema` names the two vendors. It is not a stack-definition key until its reader ships.

‎content/docs/references/api/push-delivery.mdx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ with its host app segment, which hosts an app-relative path under
4141
`/apps/APP/` and passes an `/apps/…` route through. One resolver, so a
4242
push and the inbox row open the same screen.
4343

44+
A shell with no app list of its own (a native shell that has not loaded
45+
the Console's catalog, say) does not guess either. It hands `route` to the
46+
Console to resolve, or hosts it under the segment the Console would answer
47+
(`resolveHostAppSegment` in the same file: the preferred app the user last
48+
had open, re-checked against the active apps, then the first active app,
49+
then `setup`). It never re-implements the resolver and never opens `route`
50+
verbatim.
51+
4452
Not to be confused with the `PushNotificationSchema` that `system/` once
4553
declared and then removed (ADR-0049): that was an authoring template shape;
4654
this is the wire data of a delivery, produced by the platform.

‎packages/spec/src/api/push-delivery.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('PushDeliveryDataSchema', () => {
2929
expect(PushRouteSchema.safeParse('/').success).toBe(true);
3030
});
3131

32-
it.each(['/apps/crm/.well-known', '/apps/crm/...', '/apps/crm/x?next=%2Fapps%2Fcrm', '/apps/crm/x#%2e%2e'])(
32+
it.each(['/apps/crm/.well-known', '/apps/crm/...', '/apps/crm/x?next=%2Fapps%2Fcrm', '/apps/crm/x#%2e%2e', '/apps/crm/x?q=100%25'])(
3333
'accepts %j: no dot segment, and a query or fragment keeps its own encoding',
3434
(route) => {
3535
expect(PushRouteSchema.safeParse(route).success).toBe(true);
@@ -63,6 +63,10 @@ describe('PushDeliveryDataSchema', () => {
6363
'/apps/crm/..',
6464
'/a%2Fb',
6565
'/apps/crm/./x?tab=notes',
66+
// Double-encoded: one decode leaves %2F / %2E / %5C for the next one.
67+
'/a%252Fb',
68+
'/%252e%252e/x',
69+
'/a%255cb',
6670
])('refuses route %j', (route) => {
6771
const parsed = PushDeliveryDataSchema.safeParse({ notificationId: 'ntf_1', route });
6872
expect(parsed.success).toBe(false);

‎packages/spec/src/api/push-delivery.zod.ts‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ import { lazySchema } from '../shared/lazy-schema';
3939
* `/apps/APP/` and passes an `/apps/…` route through. One resolver, so a
4040
* push and the inbox row open the same screen.
4141
*
42+
* A shell with no app list of its own (a native shell that has not loaded
43+
* the Console's catalog, say) does not guess either. It hands `route` to the
44+
* Console to resolve, or hosts it under the segment the Console would answer
45+
* (`resolveHostAppSegment` in the same file: the preferred app the user last
46+
* had open, re-checked against the active apps, then the first active app,
47+
* then `setup`). It never re-implements the resolver and never opens `route`
48+
* verbatim.
49+
*
4250
* Not to be confused with the `PushNotificationSchema` that `system/` once
4351
* declared and then removed (ADR-0049): that was an authoring template shape;
4452
* this is the wire data of a delivery, produced by the platform.
@@ -52,19 +60,23 @@ import { lazySchema } from '../shared/lazy-schema';
5260
* protocol-relative reference to another site.
5361
*
5462
* Its path (the part before any `?` or `#`) also carries no dot segment (`.`
55-
* or `..`) and no percent-encoded `/`, `\` or `.` (`%2F`, `%5C`, `%2E`, either
56-
* case): a router that normalises or decodes the path would move it somewhere
57-
* the notification did not point. Both rules are patterns, so the published
58-
* JSON Schema carries them too. A query or fragment keeps its own encoding.
63+
* or `..`), no percent-encoded `/`, `\` or `.` (`%2F`, `%5C`, `%2E`, either
64+
* case) and no encoded `%` (`%25`), which closes the double-encoded forms
65+
* (`%252F`, `%252E`, `%255C`): a router that normalises or decodes the path,
66+
* once or more, would move it somewhere the notification did not point. A
67+
* path that needs a literal `%` is refused with them, so its push carries no
68+
* `route` and the tap opens the shell's default screen. Both rules are
69+
* patterns, so the published JSON Schema carries them too. A query or
70+
* fragment keeps its own encoding.
5971
*/
6072
export const PushRouteSchema = z.string()
6173
.regex(/^\/(?![/\\])[^\s\\\x00-\x1f\x7f]*$/, {
6274
message: 'A push route is a same-server relative path: it starts with a single "/" and carries no scheme, host, '
6375
+ 'backslash, whitespace or control character.',
6476
})
65-
.regex(/^(?![^?#]*(?:\/\.\.?(?:[/?#]|$)|%(?:2[eEfF]|5[cC])))/, {
66-
message: 'A push route path carries no dot segment ("." or "..") and no percent-encoded "/", "\\" or "." '
67-
+ '(%2F, %5C, %2E): a router that normalises or decodes the path would open somewhere else.',
77+
.regex(/^(?![^?#]*(?:\/\.\.?(?:[/?#]|$)|%(?:2[eEfF]|5[cC]|25)))/, {
78+
message: 'A push route path carries no dot segment ("." or "..") and no percent-encoded "/", "\\", "." or "%" '
79+
+ '(%2F, %5C, %2E, %25): a router that normalises or decodes the path would open somewhere else.',
6880
})
6981
.describe(
7082
'The notification actionUrl as a same-server relative path: app-relative (/opportunity/123) or a Console route '

0 commit comments

Comments
 (0)