@ultimat3/pwa 30.9.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/README.md +9 -15
- package/package.json +7 -6
- package/src/adapter.ts +9 -0
- package/src/errors.ts +4 -2
- package/src/index.ts +4 -43
- package/src/push-store-pg.ts +2 -0
- package/src/push-store.ts +22 -0
- package/src/push.ts +6 -1
package/CLAUDE.md
CHANGED
|
@@ -8,7 +8,7 @@ Tier 4. May import tiers 0–3: `core`, `schema`, `i18n`, `money`, `time`, `cach
|
|
|
8
8
|
`notify` (sideways), never `ui`/`cli` (upward). Tier 4 is its FLOOR since 26.1.0 — `pushSubscribe`
|
|
9
9
|
builds an `action` — so it has no `FLOOR_ABOVE` row; `render` keeps one and holds the pair level.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Four entry points: `.` (server), `./adapter` (`adapter.ts` — the `pushSubscriptionStore` port's TYPES, no installer: cli reads `runtime.ts`'s store), `./client` (`client.ts` — THE browser entry: install prompt,
|
|
12
12
|
skew, the browser half of push; its graph is `install.ts`, `skew.ts`, `push-client.ts` and
|
|
13
13
|
`@ultimat3/core/page`, held by `client-bundle.test.ts` — never import `@ultimat3/core`'s barrel or
|
|
14
14
|
`errors.ts` from those three) and `./schema` (`push-schema.ts` — the one DDL leaf every
|
package/README.md
CHANGED
|
@@ -169,6 +169,11 @@ export const channel = pushChannel<{ postId: string }>({
|
|
|
169
169
|
| Endpoints | dialled only on a push service: `https:`, and a host that is one of `PUSH_SERVICE_HOSTS` (FCM, Mozilla, Apple, WNS) or `pwa.vapid.pushHosts`, or a subdomain of one on a dot boundary — checked when stored and before every send (`assertPushEndpoint`), never by where the name resolves, since the endpoint came from a request body (`X_PWA_PUSH_HOST_UNLISTED`; a stored one is deleted unsent). One POST waits at most `PUSH_SEND_TIMEOUT_MS` (30 s); a caller's abort is rethrown as is, never the retryable class |
|
|
170
170
|
| `renotify` | dropped, with a warning, without a `tag` — at both ends |
|
|
171
171
|
|
|
172
|
+
A store of your own implements `PushSubscriptionStore` from `@ultimat3/pwa/adapter` (types only,
|
|
173
|
+
with `PushSubscriptionRecord`) and is handed to the boot as `pushSubscriptionStore: myStore()` in
|
|
174
|
+
`apps/web/runtime.ts`; the suite is `@ultimat3/testing/conformance`'s
|
|
175
|
+
`pushSubscriptionStoreConformance`.
|
|
176
|
+
|
|
172
177
|
## Error classes
|
|
173
178
|
|
|
174
179
|
Every error class `src/index.ts` exports, for `instanceof` inside one process. Across a wire or
|
|
@@ -176,19 +181,8 @@ a job boundary the class is gone and the `code` is what survives — match on th
|
|
|
176
181
|
|
|
177
182
|
| Class | Code | Declared in |
|
|
178
183
|
|---|---|---|
|
|
179
|
-
| `BuildIdMissingError` | `X_BUILD_ID_MISSING` | `src/errors.ts` |
|
|
180
184
|
| `PwaIconMissingError` | `X_PWA_ICON_MISSING` | `src/errors.ts` |
|
|
181
|
-
| `PwaManifestInvalidError` | `X_PWA_MANIFEST_INVALID` | `src/errors.ts` |
|
|
182
|
-
| `PwaNoOfflineFallbackError` | `X_PWA_NO_OFFLINE_FALLBACK` | `src/errors.ts` |
|
|
183
|
-
| `PwaPushFailedError` | `X_PWA_PUSH_FAILED` | `src/errors.ts` |
|
|
184
|
-
| `PwaPushPayloadTooLargeError` | `X_PWA_PUSH_PAYLOAD_TOO_LARGE` | `src/errors.ts` |
|
|
185
|
-
| `PwaPushRejectedError` | `X_PWA_PUSH_REJECTED` | `src/errors.ts` |
|
|
186
|
-
| `PwaPushSubscriptionInvalidError` | `X_PWA_PUSH_SUBSCRIPTION_INVALID` | `src/errors.ts` |
|
|
187
|
-
| `PwaPushUnconfiguredError` | `X_PWA_PUSH_UNCONFIGURED` | `src/errors.ts` |
|
|
188
185
|
| `PwaStrategyExhaustedError` | `X_PWA_STRATEGY_EXHAUSTED` | `src/errors.ts` |
|
|
189
|
-
| `PwaVapidKeyInvalidError` | `X_PWA_VAPID_KEY_INVALID` | `src/errors.ts` |
|
|
190
|
-
| `PwaVapidKeyMissingError` | `X_PWA_VAPID_KEY_MISSING` | `src/errors.ts` |
|
|
191
|
-
| `SwScopeInvalidError` | `X_SW_SCOPE_INVALID` | `src/errors.ts` |
|
|
192
186
|
|
|
193
187
|
## Public API
|
|
194
188
|
|
|
@@ -197,24 +191,24 @@ a job boundary the class is gone and the `code` is what survives — match on th
|
|
|
197
191
|
| `generateServiceWorker` | `sw.js` from the route table; deterministic for identical input |
|
|
198
192
|
| `strategyFor`, `MODE_STRATEGY`, `cacheFirst`, … | the four strategies + the mapping table; a `personal` route is `network-only`. Each answers what its emitted `sw.js` twin answers: the cache copy goes to `env.wait` and is never awaited (a failed copy costs the copy, not the response), and an exhausted strategy with no fallback rejects — `staleWhileRevalidate` with `X_PWA_STRATEGY_EXHAUSTED` |
|
|
199
193
|
| `routeRules`, `assetRules` | the worker's rule list: routes most specific first, runtime asset prefixes (`/islands/`) ahead of them. `routeRules(routes, personalPages)` — `'last-member'` gives a personal page a `pages` rule; a pattern matches the browser's percent-encoded pathname, and a catch-all its bare prefix |
|
|
200
|
-
| `CLEAR_PAGES_MESSAGE
|
|
194
|
+
| `CLEAR_PAGES_MESSAGE` | `{ type: 'clear-pages' }` — post it to the worker on sign-out; it empties every pages cache and answers `{ type: 'pages-cleared' }` |
|
|
201
195
|
| `buildPrecacheManifest` | precache entries (url + content-hash revision), size warnings |
|
|
202
196
|
| `buildId`, `detectSkew` | version skew (`detectSkew` also on `./client`) |
|
|
203
197
|
| `generateWebManifest` | the manifest + `theme-color` metas for both schemes, from a `WebManifestInput`. Called by `@ultimat3/cli` (`pwa-artifacts.ts`) `As of 2026-08-27`, so `x dev`, the container and the static export all emit `manifest.webmanifest` |
|
|
204
|
-
| `planIcons`, `requireSourceIcon
|
|
198
|
+
| `planIcons`, `requireSourceIcon` | icons and splashes from one source |
|
|
205
199
|
| `BuiltinImagePipeline` | renders that plan: one square PNG per entry, deterministic |
|
|
206
200
|
| `requireOfflineFallback` | the mandatory offline route |
|
|
207
201
|
| `backgroundSyncSource`, `registerBackgroundSyncSource` | the Background Sync trigger. No retry policy: the handler rejects and the PLATFORM reschedules it |
|
|
208
202
|
| `renderPushPayload`, `pushSource`, `subscribeSource` | Web Push, per-locale bodies |
|
|
209
203
|
| `pushSubscribe`, `pushUnsubscribe` | factories over `action`: store / forget this browser's subscription for `ctx.actor` |
|
|
210
204
|
| `webPush`, `pushToActor` | one notification to every device of one person — `webPush()` is notify's `Pusher` |
|
|
211
|
-
| `sendPushMessage`, `encryptPushMessage`, `vapidAuthorization` | one message to one subscription; RFC 8291; RFC 8292 |
|
|
212
205
|
| `installWebPush`, `installedVapid`, `webPushRuntime`, `resetWebPush` | the runtime the boot installs (store, signer, transport, translator) |
|
|
213
206
|
| `memoryPushSubscriptionStore`, `postgresPushSubscriptionStore` | where subscriptions live; `x_push_subscriptions` DDL is `@ultimat3/pwa/schema` |
|
|
214
207
|
| `resolveVapidKeys`, `generateVapidKeys`, `assertVapidPair`, `DEV_VAPID_KEYS` | the key pair: from env, minted, checked, and the published development one |
|
|
215
208
|
| `@ultimat3/pwa/client` | THE browser entry — [Browser entry](#browser-entry-ultimat3pwaclient) |
|
|
216
209
|
| `installController`, `iosInstallGuidance`, `MIN_ENGAGEMENT_MS` | install prompt, never on first paint (also on `./client`) |
|
|
217
|
-
| `PwaStrategyExhaustedError`
|
|
210
|
+
| `PwaStrategyExhaustedError`, `PwaIconMissingError` | the two classes an app's own code can catch; every other code is matched by `code` |
|
|
211
|
+
| `@ultimat3/pwa/adapter` | the `pushSubscriptionStore` port: `PushSubscriptionStore`, `PushSubscriptionRecord`, `PushSubscriptionKeys`, `PostgresPushSubscriptionStoreOptions`, `VapidSigner` |
|
|
218
212
|
|
|
219
213
|
## Notes
|
|
220
214
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/pwa",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "Generated service worker, web manifest, icons, push and version-skew handling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": "./src/index.ts",
|
|
28
|
+
"./adapter": "./src/adapter.ts",
|
|
28
29
|
"./client": "./src/client.ts",
|
|
29
30
|
"./schema": "./src/push-schema.ts"
|
|
30
31
|
},
|
|
@@ -44,10 +45,10 @@
|
|
|
44
45
|
"test": "bun test"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@ultimat3/action": "
|
|
48
|
-
"@ultimat3/core": "
|
|
49
|
-
"@ultimat3/i18n": "
|
|
50
|
-
"@ultimat3/policy": "
|
|
51
|
-
"@ultimat3/schema": "
|
|
48
|
+
"@ultimat3/action": "31.0.0",
|
|
49
|
+
"@ultimat3/core": "31.0.0",
|
|
50
|
+
"@ultimat3/i18n": "31.0.0",
|
|
51
|
+
"@ultimat3/policy": "31.0.0",
|
|
52
|
+
"@ultimat3/schema": "31.0.0"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/src/adapter.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// `@ultimat3/pwa/adapter`: the `pushSubscriptionStore` port (`ADAPTER_PORTS`) as an adapter author
|
|
2
|
+
// needs it — `PushSubscriptionStore` and the record it keeps. A store raises no error of its own (a
|
|
3
|
+
// refused write is its driver's). No installer: the boot READS `runtime.ts`'s
|
|
4
|
+
// `pushSubscriptionStore` while `pwa.vapid` is set (`@ultimat3/cli`'s `runtime-push.ts`). Types only.
|
|
5
|
+
|
|
6
|
+
export type { PushSubscriptionKeys, PushSubscriptionRecord } from './push';
|
|
7
|
+
export type { VapidSigner } from './push-send';
|
|
8
|
+
export type { PushSubscriptionStore } from './push-store';
|
|
9
|
+
export type { PostgresPushSubscriptionStoreOptions } from './push-store-pg';
|
package/src/errors.ts
CHANGED
|
@@ -259,11 +259,13 @@ export class PwaPushPayloadTooLargeError extends UltimateError {
|
|
|
259
259
|
/** A subscription no browser produced: a non-https endpoint, or keys of the wrong size. */
|
|
260
260
|
export class PwaPushSubscriptionInvalidError extends UltimateError {
|
|
261
261
|
static readonly code = 'X_PWA_PUSH_SUBSCRIPTION_INVALID' as const;
|
|
262
|
-
constructor(input: { field: string; reason: string }) {
|
|
262
|
+
constructor(input: { field: string; reason: string; fix?: string | undefined }) {
|
|
263
263
|
super({
|
|
264
264
|
code: PwaPushSubscriptionInvalidError.code,
|
|
265
265
|
cause: `${input.field} ${input.reason}`,
|
|
266
|
-
fix:
|
|
266
|
+
fix:
|
|
267
|
+
input.fix ??
|
|
268
|
+
"import { subscribeToPush } from '@ultimat3/pwa/client'; // it sends PushSubscription.toJSON() unchanged",
|
|
267
269
|
meta: { field: input.field },
|
|
268
270
|
});
|
|
269
271
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,37 +9,18 @@ export type { OfflineStrategy, RenderMode } from '@ultimat3/core';
|
|
|
9
9
|
export {
|
|
10
10
|
backgroundSyncSource,
|
|
11
11
|
registerBackgroundSyncSource,
|
|
12
|
-
SYNC_TAG,
|
|
13
12
|
} from './background-sync';
|
|
14
13
|
export type { Capability, CapabilityFlags, ResolvedCapabilities } from './capabilities';
|
|
15
14
|
export {
|
|
16
15
|
CAPABILITIES,
|
|
17
16
|
CAPABILITY_SW_MARKERS,
|
|
18
|
-
enabledCapabilities,
|
|
19
17
|
hasCapability,
|
|
20
18
|
resolveCapabilities,
|
|
21
19
|
} from './capabilities';
|
|
22
20
|
export type { PwaErrorCode } from './errors';
|
|
23
21
|
export {
|
|
24
|
-
BuildIdMissingError,
|
|
25
|
-
PWA_ERROR_CODES,
|
|
26
|
-
PWA_ERROR_TITLES,
|
|
27
22
|
PwaIconMissingError,
|
|
28
|
-
PwaManifestInvalidError,
|
|
29
|
-
PwaNoOfflineFallbackError,
|
|
30
|
-
// `staleWhileRevalidate` is public and throws this, so an app that catches it can name it. The
|
|
31
|
-
// two X_PWA_SYNC_* classes are not here on purpose: the emitted `sw.js` builds its own local
|
|
32
|
-
// class in a realm with no bundler, so no instance of theirs can ever reach an app.
|
|
33
|
-
PwaPushFailedError,
|
|
34
|
-
PwaPushHostUnlistedError,
|
|
35
|
-
PwaPushPayloadTooLargeError,
|
|
36
|
-
PwaPushRejectedError,
|
|
37
|
-
PwaPushSubscriptionInvalidError,
|
|
38
|
-
PwaPushUnconfiguredError,
|
|
39
23
|
PwaStrategyExhaustedError,
|
|
40
|
-
PwaVapidKeyInvalidError,
|
|
41
|
-
PwaVapidKeyMissingError,
|
|
42
|
-
SwScopeInvalidError,
|
|
43
24
|
} from './errors';
|
|
44
25
|
export type {
|
|
45
26
|
IconPlan,
|
|
@@ -49,7 +30,6 @@ export type {
|
|
|
49
30
|
IconSpec,
|
|
50
31
|
ImagePipeline,
|
|
51
32
|
ImageTransform,
|
|
52
|
-
SafeZone,
|
|
53
33
|
SplashSpec,
|
|
54
34
|
} from './icons';
|
|
55
35
|
export {
|
|
@@ -57,7 +37,6 @@ export {
|
|
|
57
37
|
BuiltinImagePipeline,
|
|
58
38
|
ICON_MATRIX,
|
|
59
39
|
MASKABLE_PADDING,
|
|
60
|
-
maskableSafeZone,
|
|
61
40
|
planIcons,
|
|
62
41
|
requireSourceIcon,
|
|
63
42
|
} from './icons';
|
|
@@ -89,7 +68,7 @@ export { generateWebManifest, renderThemeColorMeta, serializeWebManifest } from
|
|
|
89
68
|
export type { OfflineConfig, OfflineFallback } from './offline-fallback';
|
|
90
69
|
export { offlineFallbackSource, requireOfflineFallback } from './offline-fallback';
|
|
91
70
|
export type { PersonalPages } from './pages-cache-source';
|
|
92
|
-
export { CLEAR_PAGES_MESSAGE
|
|
71
|
+
export { CLEAR_PAGES_MESSAGE } from './pages-cache-source';
|
|
93
72
|
export type { PrecacheAsset, PrecacheEntry, PrecacheInput, PrecacheManifest } from './precache';
|
|
94
73
|
export {
|
|
95
74
|
buildPrecacheManifest,
|
|
@@ -98,7 +77,6 @@ export {
|
|
|
98
77
|
export type {
|
|
99
78
|
PushPayload,
|
|
100
79
|
PushSourceOptions,
|
|
101
|
-
PushSubscriptionKeys,
|
|
102
80
|
PushSubscriptionRecord,
|
|
103
81
|
RenderedNotification,
|
|
104
82
|
SubscriptionState,
|
|
@@ -119,30 +97,16 @@ export { pushSubscribe, pushUnsubscribe } from './push-actions';
|
|
|
119
97
|
export { PUSH_KEY_META } from './push-client';
|
|
120
98
|
export type { PushReceiverKeys } from './push-decrypt';
|
|
121
99
|
export { decryptPushMessage } from './push-decrypt';
|
|
122
|
-
export
|
|
123
|
-
export { encryptPushMessage, PUSH_RECORD_SIZE, pushMessageCapacity } from './push-encrypt';
|
|
124
|
-
export { PUSH_SERVICE_HOSTS, pushHostAllowed } from './push-hosts';
|
|
100
|
+
export { PUSH_SERVICE_HOSTS } from './push-hosts';
|
|
125
101
|
export type { WebPushOptions, WebPushRuntime } from './push-runtime';
|
|
126
102
|
export { installedVapid, installWebPush, resetWebPush, webPushRuntime } from './push-runtime';
|
|
127
103
|
export type {
|
|
128
104
|
PushDelivery,
|
|
129
|
-
PushSendInput,
|
|
130
|
-
PushSendOutcome,
|
|
131
|
-
PushTarget,
|
|
132
105
|
PushUrgency,
|
|
133
|
-
VapidSigner,
|
|
134
|
-
} from './push-send';
|
|
135
|
-
export {
|
|
136
|
-
assertPushEndpoint,
|
|
137
|
-
DEFAULT_PUSH_TTL_SECONDS,
|
|
138
|
-
PUSH_SEND_TIMEOUT_MS,
|
|
139
|
-
PUSH_URGENCIES,
|
|
140
|
-
pushEndpointProblem,
|
|
141
|
-
sendPushMessage,
|
|
142
106
|
} from './push-send';
|
|
107
|
+
export { DEFAULT_PUSH_TTL_SECONDS } from './push-send';
|
|
143
108
|
export type { PushSubscriptionStore } from './push-store';
|
|
144
109
|
export { memoryPushSubscriptionStore } from './push-store';
|
|
145
|
-
export type { PostgresPushSubscriptionStoreOptions } from './push-store-pg';
|
|
146
110
|
export { postgresPushSubscriptionStore } from './push-store-pg';
|
|
147
111
|
export type { RouteRule } from './route-rules';
|
|
148
112
|
export { assetRules, routeRules } from './route-rules';
|
|
@@ -168,19 +132,16 @@ export {
|
|
|
168
132
|
MODE_STRATEGY,
|
|
169
133
|
networkFirst,
|
|
170
134
|
networkOnly,
|
|
171
|
-
STRATEGY_NAMES,
|
|
172
135
|
staleWhileRevalidate,
|
|
173
136
|
strategyFor,
|
|
174
137
|
} from './strategies';
|
|
175
|
-
export type { VapidKeyPair
|
|
138
|
+
export type { VapidKeyPair } from './vapid';
|
|
176
139
|
export {
|
|
177
140
|
assertVapidPair,
|
|
178
141
|
generateVapidKeys,
|
|
179
142
|
importVapidKeys,
|
|
180
143
|
VAPID_PRIVATE_KEY_ENV,
|
|
181
144
|
VAPID_PUBLIC_KEY_ENV,
|
|
182
|
-
VAPID_TOKEN_TTL_SECONDS,
|
|
183
|
-
vapidAuthorization,
|
|
184
145
|
} from './vapid';
|
|
185
146
|
export type { ResolvedVapidKeys } from './vapid-keys';
|
|
186
147
|
export { DEV_VAPID_KEYS, resolveVapidKeys, usesDevVapidKeys } from './vapid-keys';
|
package/src/push-store-pg.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { PgExecutor } from '@ultimat3/core';
|
|
7
7
|
import type { PushSubscriptionRecord } from './push';
|
|
8
8
|
import type { PushSubscriptionStore } from './push-store';
|
|
9
|
+
import { assertSubscriber } from './push-store';
|
|
9
10
|
|
|
10
11
|
/** A re-subscribe moves the endpoint to this actor and its new keys; `created_at` stays first. */
|
|
11
12
|
const SQL_PUSH_SAVE = `
|
|
@@ -64,6 +65,7 @@ export function postgresPushSubscriptionStore(
|
|
|
64
65
|
const { executor } = options;
|
|
65
66
|
return {
|
|
66
67
|
async save(record) {
|
|
68
|
+
assertSubscriber(record);
|
|
67
69
|
await executor.query(SQL_PUSH_SAVE, [
|
|
68
70
|
record.endpoint,
|
|
69
71
|
record.actorId,
|
package/src/push-store.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// subscription is theirs now. Keyed by the pair, the first person would go on receiving the second
|
|
7
7
|
// person's notifications on a device they no longer use.
|
|
8
8
|
|
|
9
|
+
import { PwaPushSubscriptionInvalidError } from './errors';
|
|
9
10
|
import type { PushSubscriptionRecord } from './push';
|
|
10
11
|
|
|
11
12
|
export interface PushSubscriptionStore {
|
|
@@ -21,6 +22,21 @@ export interface PushSubscriptionStore {
|
|
|
21
22
|
remove(endpoint: string, actorId?: string): Promise<boolean>;
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A subscription belongs to a person. Screened in BOTH stores before anything is written, so a
|
|
27
|
+
* record built outside `pushSubscribe` (untyped JS, a cast) is refused with one code in dev and in
|
|
28
|
+
* production — not accepted by the memory store and a not-null violation from Postgres.
|
|
29
|
+
*/
|
|
30
|
+
export function assertSubscriber(record: PushSubscriptionRecord): void {
|
|
31
|
+
const actorId: unknown = record.actorId;
|
|
32
|
+
if (typeof actorId === 'string' && actorId !== '') return;
|
|
33
|
+
throw new PwaPushSubscriptionInvalidError({
|
|
34
|
+
field: 'actorId',
|
|
35
|
+
reason: 'is not an actor id: a push subscription is stored for the person who subscribed',
|
|
36
|
+
fix: 'await store.save({ ...record, actorId: ctx.actor.id }) // what pushSubscribe() stores; an anonymous visitor has no push subscription',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
24
40
|
const byEndpoint = (a: PushSubscriptionRecord, b: PushSubscriptionRecord): number =>
|
|
25
41
|
a.endpoint < b.endpoint ? -1 : a.endpoint > b.endpoint ? 1 : 0;
|
|
26
42
|
|
|
@@ -29,6 +45,12 @@ export function memoryPushSubscriptionStore(): PushSubscriptionStore {
|
|
|
29
45
|
const rows = new Map<string, PushSubscriptionRecord>();
|
|
30
46
|
return {
|
|
31
47
|
save(record) {
|
|
48
|
+
// Rejected rather than thrown, as the Postgres store's `async save` rejects.
|
|
49
|
+
try {
|
|
50
|
+
assertSubscriber(record);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return Promise.reject(error);
|
|
53
|
+
}
|
|
32
54
|
const existing = rows.get(record.endpoint);
|
|
33
55
|
// The first `createdAt` survives a re-subscribe, as `on conflict do update` leaves it.
|
|
34
56
|
rows.set(
|
package/src/push.ts
CHANGED
|
@@ -26,7 +26,12 @@ export interface PushSubscriptionRecord {
|
|
|
26
26
|
/** BCP-47, captured at subscribe time. */
|
|
27
27
|
readonly locale: string;
|
|
28
28
|
readonly timeZone: string;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Whose device this is — never `null`: a push is for a person, `pushSubscribe` stores
|
|
31
|
+
* `ctx.actor.id`, and `x_push_subscriptions.actor_id` is `not null`. Both stores refuse a missing
|
|
32
|
+
* one with `X_PWA_PUSH_SUBSCRIPTION_INVALID` (`assertSubscriber`).
|
|
33
|
+
*/
|
|
34
|
+
readonly actorId: string;
|
|
30
35
|
readonly createdAt: number;
|
|
31
36
|
readonly expirationTime: number | null;
|
|
32
37
|
}
|