@molecule/app-push 1.0.2 → 1.1.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/LICENSE +111 -24
- package/README.md +306 -155
- package/dist/device-toggle.d.ts +114 -0
- package/dist/device-toggle.d.ts.map +1 -0
- package/dist/device-toggle.js +174 -0
- package/dist/device-toggle.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
Apache License
|
|
2
3
|
Version 2.0, January 2004
|
|
3
4
|
http://www.apache.org/licenses/
|
|
@@ -34,21 +35,33 @@
|
|
|
34
35
|
|
|
35
36
|
"Work" shall mean the work of authorship, whether in Source or
|
|
36
37
|
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
38
40
|
|
|
39
41
|
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
42
|
form, that is based on (or derived from) the Work and for which the
|
|
41
43
|
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
-
represent, as a whole, an original work of authorship.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
49
62
|
|
|
50
63
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
-
on behalf of whom a Contribution has been received by
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
52
65
|
subsequently incorporated within the Work.
|
|
53
66
|
|
|
54
67
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
@@ -61,8 +74,18 @@
|
|
|
61
74
|
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
75
|
this License, each Contributor hereby grants to You a perpetual,
|
|
63
76
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
-
|
|
65
|
-
and otherwise transfer the Work
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
66
89
|
|
|
67
90
|
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
91
|
Work or Derivative Works thereof in any medium, with or without
|
|
@@ -84,23 +107,87 @@
|
|
|
84
107
|
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
108
|
distribution, then any Derivative Works that You distribute must
|
|
86
109
|
include a readable copy of the attribution notices contained
|
|
87
|
-
within such NOTICE file
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
90
138
|
|
|
91
139
|
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
-
names, trademarks, service marks, or product names of the Licensor
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
93
143
|
|
|
94
144
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
-
agreed to in writing, Licensor provides the Work
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
104
191
|
|
|
105
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
193
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-11-14T12:30:32.256Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-push
|
|
10
10
|
|
|
11
|
-
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
-
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
-
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
-
|
|
15
11
|
Client-side push notifications interface for molecule.dev.
|
|
16
12
|
|
|
17
13
|
Provides a unified API for push notifications across platforms (web,
|
|
@@ -22,6 +18,10 @@ notifications (`scheduleLocal`), and badges (`setBadge`, `clearBadge`).
|
|
|
22
18
|
The device token is what your API's `@molecule/api-push-notifications`
|
|
23
19
|
bond sends to.
|
|
24
20
|
|
|
21
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
22
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
23
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
24
|
+
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
@@ -54,16 +54,50 @@ npm install @molecule/app-push @molecule/app-bond @molecule/app-i18n
|
|
|
54
54
|
|
|
55
55
|
### Interfaces
|
|
56
56
|
|
|
57
|
-
#### `
|
|
57
|
+
#### `PushToggleHttp`
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Minimal structural slice of `@molecule/app-http`'s HttpClient used here.
|
|
60
60
|
|
|
61
61
|
```typescript
|
|
62
|
-
interface
|
|
62
|
+
interface PushToggleHttp {
|
|
63
|
+
get<T = unknown>(url: string): Promise<{ data: T }>
|
|
64
|
+
patch<T = unknown>(url: string, data?: unknown): Promise<{ data: T }>
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### `PushToggleDevice`
|
|
69
|
+
|
|
70
|
+
Device row slice returned by `GET /api/devices`.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
interface PushToggleDevice {
|
|
74
|
+
id: string
|
|
75
|
+
isCurrent?: boolean
|
|
76
|
+
hasPushSubscription?: boolean
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### `PushToggleToken`
|
|
81
|
+
|
|
82
|
+
Push token slice returned by `@molecule/app-push` `register()`.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
interface PushToggleToken {
|
|
86
|
+
value: string
|
|
87
|
+
platform: 'web' | 'ios' | 'android'
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### `PushNotification`
|
|
92
|
+
|
|
93
|
+
Push notification payload.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
interface PushNotification {
|
|
63
97
|
/**
|
|
64
98
|
* Notification ID.
|
|
65
99
|
*/
|
|
66
|
-
id
|
|
100
|
+
id: string
|
|
67
101
|
|
|
68
102
|
/**
|
|
69
103
|
* Notification title.
|
|
@@ -71,62 +105,105 @@ interface LocalNotificationOptions {
|
|
|
71
105
|
title: string
|
|
72
106
|
|
|
73
107
|
/**
|
|
74
|
-
* Notification body.
|
|
108
|
+
* Notification body/message.
|
|
75
109
|
*/
|
|
76
110
|
body?: string
|
|
77
111
|
|
|
78
112
|
/**
|
|
79
|
-
*
|
|
113
|
+
* Notification data payload.
|
|
80
114
|
*/
|
|
81
|
-
|
|
115
|
+
data?: Record<string, unknown>
|
|
82
116
|
|
|
83
117
|
/**
|
|
84
|
-
*
|
|
118
|
+
* Badge count.
|
|
85
119
|
*/
|
|
86
|
-
|
|
120
|
+
badge?: number
|
|
87
121
|
|
|
88
122
|
/**
|
|
89
|
-
*
|
|
123
|
+
* Sound to play.
|
|
90
124
|
*/
|
|
91
|
-
|
|
125
|
+
sound?: string
|
|
92
126
|
|
|
93
127
|
/**
|
|
94
|
-
*
|
|
128
|
+
* Icon URL.
|
|
95
129
|
*/
|
|
96
|
-
|
|
130
|
+
icon?: string
|
|
97
131
|
|
|
98
132
|
/**
|
|
99
|
-
*
|
|
133
|
+
* Image URL.
|
|
100
134
|
*/
|
|
101
|
-
|
|
135
|
+
image?: string
|
|
102
136
|
|
|
103
137
|
/**
|
|
104
|
-
*
|
|
138
|
+
* Click action/URL.
|
|
105
139
|
*/
|
|
106
|
-
|
|
140
|
+
clickAction?: string
|
|
107
141
|
|
|
108
142
|
/**
|
|
109
|
-
*
|
|
143
|
+
* Notification tag (for grouping).
|
|
144
|
+
*/
|
|
145
|
+
tag?: string
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Whether the notification requires interaction.
|
|
149
|
+
*/
|
|
150
|
+
requireInteraction?: boolean
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Notification timestamp.
|
|
154
|
+
*/
|
|
155
|
+
timestamp?: number
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Notification actions (buttons).
|
|
110
159
|
*/
|
|
111
160
|
actions?: PushNotificationAction[]
|
|
112
161
|
}
|
|
113
162
|
```
|
|
114
163
|
|
|
115
|
-
#### `
|
|
164
|
+
#### `PushNotificationAction`
|
|
116
165
|
|
|
117
|
-
Notification action
|
|
166
|
+
Notification action button.
|
|
118
167
|
|
|
119
168
|
```typescript
|
|
120
|
-
interface
|
|
169
|
+
interface PushNotificationAction {
|
|
121
170
|
/**
|
|
122
|
-
*
|
|
171
|
+
* Action ID.
|
|
123
172
|
*/
|
|
124
|
-
|
|
173
|
+
id: string
|
|
125
174
|
|
|
126
175
|
/**
|
|
127
|
-
* Action
|
|
176
|
+
* Action title.
|
|
128
177
|
*/
|
|
129
|
-
|
|
178
|
+
title: string
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Action icon.
|
|
182
|
+
*/
|
|
183
|
+
icon?: string
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### `PushToken`
|
|
188
|
+
|
|
189
|
+
Push token info.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
interface PushToken {
|
|
193
|
+
/**
|
|
194
|
+
* Token value.
|
|
195
|
+
*/
|
|
196
|
+
value: string
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Platform the token is for.
|
|
200
|
+
*/
|
|
201
|
+
platform: 'web' | 'ios' | 'android'
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* When the token was obtained.
|
|
205
|
+
*/
|
|
206
|
+
timestamp: number
|
|
130
207
|
}
|
|
131
208
|
```
|
|
132
209
|
|
|
@@ -148,99 +225,97 @@ interface NotificationReceivedEvent {
|
|
|
148
225
|
}
|
|
149
226
|
```
|
|
150
227
|
|
|
151
|
-
#### `
|
|
228
|
+
#### `NotificationActionEvent`
|
|
152
229
|
|
|
153
|
-
|
|
230
|
+
Notification action event.
|
|
154
231
|
|
|
155
232
|
```typescript
|
|
156
|
-
interface
|
|
233
|
+
interface NotificationActionEvent {
|
|
157
234
|
/**
|
|
158
|
-
*
|
|
235
|
+
* The notification.
|
|
159
236
|
*/
|
|
160
|
-
|
|
237
|
+
notification: PushNotification
|
|
161
238
|
|
|
162
239
|
/**
|
|
163
|
-
*
|
|
240
|
+
* Action that was triggered.
|
|
164
241
|
*/
|
|
165
|
-
|
|
242
|
+
actionId?: string
|
|
243
|
+
}
|
|
244
|
+
```
|
|
166
245
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
body?: string
|
|
246
|
+
#### `LocalNotificationOptions`
|
|
247
|
+
|
|
248
|
+
Options for scheduling a local notification.
|
|
171
249
|
|
|
250
|
+
```typescript
|
|
251
|
+
interface LocalNotificationOptions {
|
|
172
252
|
/**
|
|
173
|
-
* Notification
|
|
253
|
+
* Notification ID.
|
|
174
254
|
*/
|
|
175
|
-
|
|
255
|
+
id?: string
|
|
176
256
|
|
|
177
257
|
/**
|
|
178
|
-
*
|
|
258
|
+
* Notification title.
|
|
179
259
|
*/
|
|
180
|
-
|
|
260
|
+
title: string
|
|
181
261
|
|
|
182
262
|
/**
|
|
183
|
-
*
|
|
263
|
+
* Notification body.
|
|
184
264
|
*/
|
|
185
|
-
|
|
265
|
+
body?: string
|
|
186
266
|
|
|
187
267
|
/**
|
|
188
|
-
*
|
|
268
|
+
* Schedule at a specific time.
|
|
189
269
|
*/
|
|
190
|
-
|
|
270
|
+
at?: Date
|
|
191
271
|
|
|
192
272
|
/**
|
|
193
|
-
*
|
|
273
|
+
* Repeat interval.
|
|
194
274
|
*/
|
|
195
|
-
|
|
275
|
+
repeat?: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'
|
|
196
276
|
|
|
197
277
|
/**
|
|
198
|
-
*
|
|
278
|
+
* Extra data.
|
|
199
279
|
*/
|
|
200
|
-
|
|
280
|
+
extra?: Record<string, unknown>
|
|
201
281
|
|
|
202
282
|
/**
|
|
203
|
-
*
|
|
283
|
+
* Sound to play.
|
|
204
284
|
*/
|
|
205
|
-
|
|
285
|
+
sound?: string
|
|
206
286
|
|
|
207
287
|
/**
|
|
208
|
-
*
|
|
288
|
+
* Badge count.
|
|
209
289
|
*/
|
|
210
|
-
|
|
290
|
+
badge?: number
|
|
211
291
|
|
|
212
292
|
/**
|
|
213
|
-
* Notification
|
|
293
|
+
* Notification channel (Android).
|
|
214
294
|
*/
|
|
215
|
-
|
|
295
|
+
channelId?: string
|
|
216
296
|
|
|
217
297
|
/**
|
|
218
|
-
*
|
|
298
|
+
* Actions/buttons.
|
|
219
299
|
*/
|
|
220
300
|
actions?: PushNotificationAction[]
|
|
221
301
|
}
|
|
222
302
|
```
|
|
223
303
|
|
|
224
|
-
#### `
|
|
304
|
+
#### `PushRegisterOptions`
|
|
225
305
|
|
|
226
|
-
|
|
306
|
+
Options for {@link PushProvider.register}.
|
|
227
307
|
|
|
228
308
|
```typescript
|
|
229
|
-
interface
|
|
230
|
-
/**
|
|
231
|
-
* Action ID.
|
|
232
|
-
*/
|
|
233
|
-
id: string
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Action title.
|
|
237
|
-
*/
|
|
238
|
-
title: string
|
|
239
|
-
|
|
309
|
+
interface PushRegisterOptions {
|
|
240
310
|
/**
|
|
241
|
-
*
|
|
311
|
+
* VAPID public key (URL-safe base64) used as the `applicationServerKey`
|
|
312
|
+
* when subscribing on the web. Chromium rejects keyless subscriptions, so
|
|
313
|
+
* web apps should deliver the server's key at runtime (e.g. from
|
|
314
|
+
* `GET /api/devices/push/public-key`) and pass it here. Takes precedence
|
|
315
|
+
* over any key the provider was constructed with. Ignored by providers
|
|
316
|
+
* whose platform does not use VAPID (e.g. FCM/APNs native providers).
|
|
242
317
|
*/
|
|
243
|
-
|
|
318
|
+
vapidPublicKey?: string
|
|
244
319
|
}
|
|
245
320
|
```
|
|
246
321
|
|
|
@@ -353,55 +428,32 @@ interface PushProvider {
|
|
|
353
428
|
}
|
|
354
429
|
```
|
|
355
430
|
|
|
356
|
-
|
|
431
|
+
### Types
|
|
357
432
|
|
|
358
|
-
|
|
433
|
+
#### `PushToggleFailureReason`
|
|
434
|
+
|
|
435
|
+
Why an enable/disable attempt failed (mapped to i18n by the component).
|
|
359
436
|
|
|
360
437
|
```typescript
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
* VAPID public key (URL-safe base64) used as the `applicationServerKey`
|
|
364
|
-
* when subscribing on the web. Chromium rejects keyless subscriptions, so
|
|
365
|
-
* web apps should deliver the server's key at runtime (e.g. from
|
|
366
|
-
* `GET /api/devices/push/public-key`) and pass it here. Takes precedence
|
|
367
|
-
* over any key the provider was constructed with. Ignored by providers
|
|
368
|
-
* whose platform does not use VAPID (e.g. FCM/APNs native providers).
|
|
369
|
-
*/
|
|
370
|
-
vapidPublicKey?: string
|
|
371
|
-
}
|
|
438
|
+
type PushToggleFailureReason =
|
|
439
|
+
'permission-denied' | 'server-unconfigured' | 'register-failed' | 'persist-failed'
|
|
372
440
|
```
|
|
373
441
|
|
|
374
|
-
#### `
|
|
442
|
+
#### `PushToggleResult`
|
|
375
443
|
|
|
376
|
-
|
|
444
|
+
Result of an enable/disable attempt.
|
|
377
445
|
|
|
378
446
|
```typescript
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
* Token value.
|
|
382
|
-
*/
|
|
383
|
-
value: string
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Platform the token is for.
|
|
387
|
-
*/
|
|
388
|
-
platform: 'web' | 'ios' | 'android'
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* When the token was obtained.
|
|
392
|
-
*/
|
|
393
|
-
timestamp: number
|
|
394
|
-
}
|
|
447
|
+
type PushToggleResult =
|
|
448
|
+
{ ok: true } | { ok: false; reason: PushToggleFailureReason; message?: string }
|
|
395
449
|
```
|
|
396
450
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
#### `NotificationActionListener`
|
|
451
|
+
#### `PermissionStatus`
|
|
400
452
|
|
|
401
|
-
|
|
453
|
+
Push notification permission status.
|
|
402
454
|
|
|
403
455
|
```typescript
|
|
404
|
-
type
|
|
456
|
+
type PermissionStatus = 'granted' | 'denied' | 'default' | 'prompt'
|
|
405
457
|
```
|
|
406
458
|
|
|
407
459
|
#### `NotificationReceivedListener`
|
|
@@ -412,12 +464,14 @@ Listener invoked when a push notification is received.
|
|
|
412
464
|
type NotificationReceivedListener = (event: NotificationReceivedEvent) => void
|
|
413
465
|
```
|
|
414
466
|
|
|
415
|
-
|
|
467
|
+
- `event` — The received notification and foreground state.
|
|
416
468
|
|
|
417
|
-
|
|
469
|
+
#### `NotificationActionListener`
|
|
470
|
+
|
|
471
|
+
Notification Action Listener type.
|
|
418
472
|
|
|
419
473
|
```typescript
|
|
420
|
-
type
|
|
474
|
+
type NotificationActionListener = (event: NotificationActionEvent) => void
|
|
421
475
|
```
|
|
422
476
|
|
|
423
477
|
#### `TokenChangeListener`
|
|
@@ -430,57 +484,108 @@ type TokenChangeListener = (token: PushToken) => void
|
|
|
430
484
|
|
|
431
485
|
### Functions
|
|
432
486
|
|
|
433
|
-
#### `
|
|
487
|
+
#### `findCurrentDevice(devices)`
|
|
434
488
|
|
|
435
|
-
|
|
489
|
+
Picks the caller's own device row: the api flags the session device
|
|
490
|
+
`isCurrent`; fall back to the first row for sessions predating the flag.
|
|
436
491
|
|
|
437
492
|
```typescript
|
|
438
|
-
function
|
|
493
|
+
function findCurrentDevice(devices: PushToggleDevice[] | undefined): PushToggleDevice | undefined
|
|
439
494
|
```
|
|
440
495
|
|
|
441
|
-
|
|
496
|
+
- `devices` — Rows from `GET /api/devices`.
|
|
442
497
|
|
|
443
|
-
|
|
498
|
+
**Returns:** The current device row, or `undefined` when the user has none.
|
|
444
499
|
|
|
445
|
-
|
|
500
|
+
#### `subscriptionFromToken(token)`
|
|
501
|
+
|
|
502
|
+
Converts an `@molecule/app-push` token into the device resource's
|
|
503
|
+
`pushSubscription` shape (web PushSubscription JSON, FCM registration for
|
|
504
|
+
Android, APNs registration for iOS).
|
|
446
505
|
|
|
447
506
|
```typescript
|
|
448
|
-
function
|
|
507
|
+
function subscriptionFromToken(token: PushToggleToken): unknown
|
|
449
508
|
```
|
|
450
509
|
|
|
451
|
-
|
|
510
|
+
- `token` — The push token returned by `register()`.
|
|
452
511
|
|
|
453
|
-
|
|
512
|
+
**Returns:** The `pushSubscription` value to PATCH onto the device row.
|
|
454
513
|
|
|
455
|
-
|
|
514
|
+
#### `enablePushOnCurrentDevice(deps)`
|
|
515
|
+
|
|
516
|
+
Runs the full enable chain: browser permission → runtime VAPID public key
|
|
517
|
+
(`GET /api/devices/push/public-key`) → `register({ vapidPublicKey })` →
|
|
518
|
+
persist the subscription on the current device row.
|
|
519
|
+
|
|
520
|
+
Every failure is returned as a typed reason (never thrown) so the UI can
|
|
521
|
+
show an honest, specific message instead of hanging or silently reverting.
|
|
456
522
|
|
|
457
523
|
```typescript
|
|
458
|
-
function
|
|
524
|
+
function enablePushOnCurrentDevice(deps: {
|
|
525
|
+
http: PushToggleHttp
|
|
526
|
+
requestPermission: () => Promise<string>
|
|
527
|
+
register: (options?: { vapidPublicKey?: string }) => Promise<PushToggleToken>
|
|
528
|
+
}): Promise<PushToggleResult>
|
|
459
529
|
```
|
|
460
530
|
|
|
461
|
-
- `
|
|
531
|
+
- `deps` — The http client + push actions from `usePush()`.
|
|
532
|
+
- `deps.http` — Authenticated http client (`useHttpClient()`).
|
|
533
|
+
- `deps.requestPermission` — `usePush().requestPermission`.
|
|
534
|
+
- `deps.register` — `usePush().register`.
|
|
462
535
|
|
|
463
|
-
**Returns:**
|
|
536
|
+
**Returns:** `{ ok: true }` or a typed failure.
|
|
464
537
|
|
|
465
|
-
#### `
|
|
538
|
+
#### `disablePushOnCurrentDevice(deps)`
|
|
466
539
|
|
|
467
|
-
|
|
540
|
+
Disables push: unsubscribes the browser (best-effort — a dev build without
|
|
541
|
+
a service worker has nothing to unsubscribe) and ALWAYS clears the server
|
|
542
|
+
state so no further pushes target this device.
|
|
468
543
|
|
|
469
544
|
```typescript
|
|
470
|
-
function
|
|
545
|
+
function disablePushOnCurrentDevice(deps: {
|
|
546
|
+
http: PushToggleHttp
|
|
547
|
+
unregister: () => Promise<void>
|
|
548
|
+
}): Promise<PushToggleResult>
|
|
471
549
|
```
|
|
472
550
|
|
|
473
|
-
|
|
551
|
+
- `deps` — The http client + push action from `usePush()`.
|
|
552
|
+
- `deps.http` — Authenticated http client (`useHttpClient()`).
|
|
553
|
+
- `deps.unregister` — `usePush().unregister`.
|
|
474
554
|
|
|
475
|
-
|
|
555
|
+
**Returns:** `{ ok: true }` or a typed failure (server state not cleared).
|
|
476
556
|
|
|
477
|
-
|
|
557
|
+
#### `readCurrentDevicePushEnabled(http)`
|
|
558
|
+
|
|
559
|
+
Reads whether push is currently enabled for THIS device (server truth:
|
|
560
|
+
the current device row's `hasPushSubscription`).
|
|
478
561
|
|
|
479
562
|
```typescript
|
|
480
|
-
function
|
|
563
|
+
function readCurrentDevicePushEnabled(http: PushToggleHttp): Promise<boolean>
|
|
481
564
|
```
|
|
482
565
|
|
|
483
|
-
|
|
566
|
+
- `http` — Authenticated http client (`useHttpClient()`).
|
|
567
|
+
|
|
568
|
+
**Returns:** `true` when the current device has a stored subscription.
|
|
569
|
+
|
|
570
|
+
#### `setProvider(provider)`
|
|
571
|
+
|
|
572
|
+
Sets the push provider implementation.
|
|
573
|
+
|
|
574
|
+
```typescript
|
|
575
|
+
function setProvider(provider: PushProvider): void
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
- `provider` — The push provider to bond as the active implementation.
|
|
579
|
+
|
|
580
|
+
#### `getProvider()`
|
|
581
|
+
|
|
582
|
+
Gets the current push provider, creating a default web provider if none is bonded.
|
|
583
|
+
|
|
584
|
+
```typescript
|
|
585
|
+
function getProvider(): PushProvider
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
**Returns:** The active push provider instance.
|
|
484
589
|
|
|
485
590
|
#### `hasProvider()`
|
|
486
591
|
|
|
@@ -492,29 +597,25 @@ function hasProvider(): boolean
|
|
|
492
597
|
|
|
493
598
|
**Returns:** Whether a push provider is currently registered.
|
|
494
599
|
|
|
495
|
-
#### `
|
|
600
|
+
#### `checkPermission()`
|
|
496
601
|
|
|
497
|
-
|
|
602
|
+
Checks the current notification permission status.
|
|
498
603
|
|
|
499
604
|
```typescript
|
|
500
|
-
function
|
|
605
|
+
function checkPermission(): Promise<PermissionStatus>
|
|
501
606
|
```
|
|
502
607
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
**Returns:** An unsubscribe function to remove the listener.
|
|
608
|
+
**Returns:** The current permission status (granted, denied, default, or prompt).
|
|
506
609
|
|
|
507
|
-
#### `
|
|
610
|
+
#### `requestPermission()`
|
|
508
611
|
|
|
509
|
-
|
|
612
|
+
Requests notification permission from the user.
|
|
510
613
|
|
|
511
614
|
```typescript
|
|
512
|
-
function
|
|
615
|
+
function requestPermission(): Promise<PermissionStatus>
|
|
513
616
|
```
|
|
514
617
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
**Returns:** An unsubscribe function to remove the listener.
|
|
618
|
+
**Returns:** The resulting permission status after the user responds.
|
|
518
619
|
|
|
519
620
|
#### `register(options)`
|
|
520
621
|
|
|
@@ -528,15 +629,39 @@ function register(options?: PushRegisterOptions): Promise<PushToken>
|
|
|
528
629
|
|
|
529
630
|
**Returns:** The push token for this device.
|
|
530
631
|
|
|
531
|
-
#### `
|
|
632
|
+
#### `getToken()`
|
|
532
633
|
|
|
533
|
-
|
|
634
|
+
Gets the current push token.
|
|
534
635
|
|
|
535
636
|
```typescript
|
|
536
|
-
function
|
|
637
|
+
function getToken(): Promise<PushToken | null>
|
|
537
638
|
```
|
|
538
639
|
|
|
539
|
-
**Returns:** The
|
|
640
|
+
**Returns:** The current token, or `null` if not registered.
|
|
641
|
+
|
|
642
|
+
#### `onNotificationReceived(listener)`
|
|
643
|
+
|
|
644
|
+
Subscribes to notification received events.
|
|
645
|
+
|
|
646
|
+
```typescript
|
|
647
|
+
function onNotificationReceived(listener: NotificationReceivedListener): () => void
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
- `listener` — Callback invoked when a notification is received.
|
|
651
|
+
|
|
652
|
+
**Returns:** An unsubscribe function to remove the listener.
|
|
653
|
+
|
|
654
|
+
#### `onNotificationAction(listener)`
|
|
655
|
+
|
|
656
|
+
Subscribes to notification action events (taps, button clicks).
|
|
657
|
+
|
|
658
|
+
```typescript
|
|
659
|
+
function onNotificationAction(listener: NotificationActionListener): () => void
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
- `listener` — Callback invoked when a notification action is triggered.
|
|
663
|
+
|
|
664
|
+
**Returns:** An unsubscribe function to remove the listener.
|
|
540
665
|
|
|
541
666
|
#### `scheduleLocal(options)`
|
|
542
667
|
|
|
@@ -562,15 +687,33 @@ function setBadge(count: number): Promise<void>
|
|
|
562
687
|
|
|
563
688
|
**Returns:** A promise that resolves when the badge count is set.
|
|
564
689
|
|
|
565
|
-
#### `
|
|
690
|
+
#### `clearBadge()`
|
|
566
691
|
|
|
567
|
-
|
|
692
|
+
Clears the app icon badge count.
|
|
568
693
|
|
|
569
694
|
```typescript
|
|
570
|
-
function
|
|
695
|
+
function clearBadge(): Promise<void>
|
|
571
696
|
```
|
|
572
697
|
|
|
573
|
-
|
|
698
|
+
**Returns:** A promise that resolves when the badge count is cleared.
|
|
699
|
+
|
|
700
|
+
#### `createWebPushProvider(vapidPublicKey)`
|
|
701
|
+
|
|
702
|
+
Creates a web push provider using the browser Push API and Notification API.
|
|
703
|
+
|
|
704
|
+
```typescript
|
|
705
|
+
function createWebPushProvider(vapidPublicKey?: string): PushProvider
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
- `vapidPublicKey` — Optional VAPID public key for server-authenticated subscriptions.
|
|
709
|
+
|
|
710
|
+
**Returns:** A {@link PushProvider} backed by the Web Push API.
|
|
711
|
+
|
|
712
|
+
## Available Providers
|
|
713
|
+
|
|
714
|
+
| Provider | Package |
|
|
715
|
+
| ----------------- | --------------------------------- |
|
|
716
|
+
| React Native Push | `@molecule/app-push-react-native` |
|
|
574
717
|
|
|
575
718
|
## Injection Notes
|
|
576
719
|
|
|
@@ -606,6 +749,14 @@ Peer dependencies:
|
|
|
606
749
|
delivery send a real push from the server.
|
|
607
750
|
- `token.value` on web is a JSON-serialized PushSubscription (not an FCM
|
|
608
751
|
token) — store it opaquely; platform is in `token.platform`.
|
|
752
|
+
- **A settings toggle for the current device** needs no code of its own:
|
|
753
|
+
`enablePushOnCurrentDevice({ http, requestPermission, register })`,
|
|
754
|
+
`disablePushOnCurrentDevice({ http, unregister })` and
|
|
755
|
+
`readCurrentDevicePushEnabled(http)` run the whole chain against the
|
|
756
|
+
molecule device API (`GET /api/devices/push/public-key`,
|
|
757
|
+
`GET /api/devices`, `PATCH /api/devices/:id`) and return a typed result
|
|
758
|
+
instead of throwing. Every framework's settings panel package re-exports
|
|
759
|
+
them.
|
|
609
760
|
|
|
610
761
|
## Translations
|
|
611
762
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The push-notifications toggle for the signed-in user's current device: the
|
|
3
|
+
* full enable/disable chain — permission → runtime VAPID key fetch →
|
|
4
|
+
* subscribe → persist on the device row — as plain functions over an HTTP
|
|
5
|
+
* client and this package's `requestPermission` / `register` /
|
|
6
|
+
* `unregister`. Every framework's settings panel
|
|
7
|
+
* (`@molecule/app-settings-panel-react`, `-vue`, `-solid`, `-svelte`,
|
|
8
|
+
* `-angular`) re-exports these, so the chain is the same everywhere.
|
|
9
|
+
*
|
|
10
|
+
* The server contract (shared by every molecule api):
|
|
11
|
+
*
|
|
12
|
+
* - `GET /api/devices/push/public-key` → `{ publicKey }` — the VAPID public
|
|
13
|
+
* key the browser must pass as `applicationServerKey` (Chromium rejects
|
|
14
|
+
* keyless subscriptions). 404/503 when push is not configured server-side.
|
|
15
|
+
* - `GET /api/devices` → the caller's device rows; the session's own device
|
|
16
|
+
* is flagged `isCurrent: true`.
|
|
17
|
+
* - `PATCH /api/devices/:id { pushSubscription, hasPushSubscription }` —
|
|
18
|
+
* persists the browser subscription where the api-side push fan-outs read
|
|
19
|
+
* it. Without this PATCH the server never knows the subscription exists
|
|
20
|
+
* and no push can ever reach the user.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
/** Minimal structural slice of `@molecule/app-http`'s HttpClient used here. */
|
|
25
|
+
export interface PushToggleHttp {
|
|
26
|
+
get<T = unknown>(url: string): Promise<{
|
|
27
|
+
data: T;
|
|
28
|
+
}>;
|
|
29
|
+
patch<T = unknown>(url: string, data?: unknown): Promise<{
|
|
30
|
+
data: T;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
/** Device row slice returned by `GET /api/devices`. */
|
|
34
|
+
export interface PushToggleDevice {
|
|
35
|
+
id: string;
|
|
36
|
+
isCurrent?: boolean;
|
|
37
|
+
hasPushSubscription?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Push token slice returned by `@molecule/app-push` `register()`. */
|
|
40
|
+
export interface PushToggleToken {
|
|
41
|
+
value: string;
|
|
42
|
+
platform: 'web' | 'ios' | 'android';
|
|
43
|
+
}
|
|
44
|
+
/** Why an enable/disable attempt failed (mapped to i18n by the component). */
|
|
45
|
+
export type PushToggleFailureReason = 'permission-denied' | 'server-unconfigured' | 'register-failed' | 'persist-failed';
|
|
46
|
+
/** Result of an enable/disable attempt. */
|
|
47
|
+
export type PushToggleResult = {
|
|
48
|
+
ok: true;
|
|
49
|
+
} | {
|
|
50
|
+
ok: false;
|
|
51
|
+
reason: PushToggleFailureReason;
|
|
52
|
+
message?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Picks the caller's own device row: the api flags the session device
|
|
56
|
+
* `isCurrent`; fall back to the first row for sessions predating the flag.
|
|
57
|
+
*
|
|
58
|
+
* @param devices - Rows from `GET /api/devices`.
|
|
59
|
+
* @returns The current device row, or `undefined` when the user has none.
|
|
60
|
+
*/
|
|
61
|
+
export declare const findCurrentDevice: (devices: PushToggleDevice[] | undefined) => PushToggleDevice | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Converts an `@molecule/app-push` token into the device resource's
|
|
64
|
+
* `pushSubscription` shape (web PushSubscription JSON, FCM registration for
|
|
65
|
+
* Android, APNs registration for iOS).
|
|
66
|
+
*
|
|
67
|
+
* @param token - The push token returned by `register()`.
|
|
68
|
+
* @returns The `pushSubscription` value to PATCH onto the device row.
|
|
69
|
+
*/
|
|
70
|
+
export declare const subscriptionFromToken: (token: PushToggleToken) => unknown;
|
|
71
|
+
/**
|
|
72
|
+
* Runs the full enable chain: browser permission → runtime VAPID public key
|
|
73
|
+
* (`GET /api/devices/push/public-key`) → `register({ vapidPublicKey })` →
|
|
74
|
+
* persist the subscription on the current device row.
|
|
75
|
+
*
|
|
76
|
+
* Every failure is returned as a typed reason (never thrown) so the UI can
|
|
77
|
+
* show an honest, specific message instead of hanging or silently reverting.
|
|
78
|
+
*
|
|
79
|
+
* @param deps - The http client + push actions from `usePush()`.
|
|
80
|
+
* @param deps.http - Authenticated http client (`useHttpClient()`).
|
|
81
|
+
* @param deps.requestPermission - `usePush().requestPermission`.
|
|
82
|
+
* @param deps.register - `usePush().register`.
|
|
83
|
+
* @returns `{ ok: true }` or a typed failure.
|
|
84
|
+
*/
|
|
85
|
+
export declare const enablePushOnCurrentDevice: (deps: {
|
|
86
|
+
http: PushToggleHttp;
|
|
87
|
+
requestPermission: () => Promise<string>;
|
|
88
|
+
register: (options?: {
|
|
89
|
+
vapidPublicKey?: string;
|
|
90
|
+
}) => Promise<PushToggleToken>;
|
|
91
|
+
}) => Promise<PushToggleResult>;
|
|
92
|
+
/**
|
|
93
|
+
* Disables push: unsubscribes the browser (best-effort — a dev build without
|
|
94
|
+
* a service worker has nothing to unsubscribe) and ALWAYS clears the server
|
|
95
|
+
* state so no further pushes target this device.
|
|
96
|
+
*
|
|
97
|
+
* @param deps - The http client + push action from `usePush()`.
|
|
98
|
+
* @param deps.http - Authenticated http client (`useHttpClient()`).
|
|
99
|
+
* @param deps.unregister - `usePush().unregister`.
|
|
100
|
+
* @returns `{ ok: true }` or a typed failure (server state not cleared).
|
|
101
|
+
*/
|
|
102
|
+
export declare const disablePushOnCurrentDevice: (deps: {
|
|
103
|
+
http: PushToggleHttp;
|
|
104
|
+
unregister: () => Promise<void>;
|
|
105
|
+
}) => Promise<PushToggleResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Reads whether push is currently enabled for THIS device (server truth:
|
|
108
|
+
* the current device row's `hasPushSubscription`).
|
|
109
|
+
*
|
|
110
|
+
* @param http - Authenticated http client (`useHttpClient()`).
|
|
111
|
+
* @returns `true` when the current device has a stored subscription.
|
|
112
|
+
*/
|
|
113
|
+
export declare const readCurrentDevicePushEnabled: (http: PushToggleHttp) => Promise<boolean>;
|
|
114
|
+
//# sourceMappingURL=device-toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-toggle.d.ts","sourceRoot":"","sources":["../src/device-toggle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAA;IACnD,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAA;CACtE;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAAA;CACpC;AAED,8EAA8E;AAC9E,MAAM,MAAM,uBAAuB,GACjC,mBAAmB,GAAG,qBAAqB,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;AAEpF,2CAA2C;AAC3C,MAAM,MAAM,gBAAgB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,gBAAgB,EAAE,GAAG,SAAS,KACtC,gBAAgB,GAAG,SAGrB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,eAAe,KAAG,OAS9D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM;IACpD,IAAI,EAAE,cAAc,CAAA;IACpB,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACxC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;CAC9E,KAAG,OAAO,CAAC,gBAAgB,CAmD3B,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GAAU,MAAM;IACrD,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAChC,KAAG,OAAO,CAAC,gBAAgB,CA0B3B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAU,MAAM,cAAc,KAAG,OAAO,CAAC,OAAO,CASxF,CAAA"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The push-notifications toggle for the signed-in user's current device: the
|
|
3
|
+
* full enable/disable chain — permission → runtime VAPID key fetch →
|
|
4
|
+
* subscribe → persist on the device row — as plain functions over an HTTP
|
|
5
|
+
* client and this package's `requestPermission` / `register` /
|
|
6
|
+
* `unregister`. Every framework's settings panel
|
|
7
|
+
* (`@molecule/app-settings-panel-react`, `-vue`, `-solid`, `-svelte`,
|
|
8
|
+
* `-angular`) re-exports these, so the chain is the same everywhere.
|
|
9
|
+
*
|
|
10
|
+
* The server contract (shared by every molecule api):
|
|
11
|
+
*
|
|
12
|
+
* - `GET /api/devices/push/public-key` → `{ publicKey }` — the VAPID public
|
|
13
|
+
* key the browser must pass as `applicationServerKey` (Chromium rejects
|
|
14
|
+
* keyless subscriptions). 404/503 when push is not configured server-side.
|
|
15
|
+
* - `GET /api/devices` → the caller's device rows; the session's own device
|
|
16
|
+
* is flagged `isCurrent: true`.
|
|
17
|
+
* - `PATCH /api/devices/:id { pushSubscription, hasPushSubscription }` —
|
|
18
|
+
* persists the browser subscription where the api-side push fan-outs read
|
|
19
|
+
* it. Without this PATCH the server never knows the subscription exists
|
|
20
|
+
* and no push can ever reach the user.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Picks the caller's own device row: the api flags the session device
|
|
26
|
+
* `isCurrent`; fall back to the first row for sessions predating the flag.
|
|
27
|
+
*
|
|
28
|
+
* @param devices - Rows from `GET /api/devices`.
|
|
29
|
+
* @returns The current device row, or `undefined` when the user has none.
|
|
30
|
+
*/
|
|
31
|
+
export const findCurrentDevice = (devices) => {
|
|
32
|
+
if (!Array.isArray(devices) || devices.length === 0)
|
|
33
|
+
return undefined;
|
|
34
|
+
return devices.find((device) => device.isCurrent) ?? devices[0];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Converts an `@molecule/app-push` token into the device resource's
|
|
38
|
+
* `pushSubscription` shape (web PushSubscription JSON, FCM registration for
|
|
39
|
+
* Android, APNs registration for iOS).
|
|
40
|
+
*
|
|
41
|
+
* @param token - The push token returned by `register()`.
|
|
42
|
+
* @returns The `pushSubscription` value to PATCH onto the device row.
|
|
43
|
+
*/
|
|
44
|
+
export const subscriptionFromToken = (token) => {
|
|
45
|
+
if (token.platform === 'android') {
|
|
46
|
+
return { registrationId: token.value, registrationType: 'FCM' };
|
|
47
|
+
}
|
|
48
|
+
if (token.platform === 'ios') {
|
|
49
|
+
return { registrationId: token.value };
|
|
50
|
+
}
|
|
51
|
+
// Web: register() serializes `subscription.toJSON()` — endpoint + keys.
|
|
52
|
+
return JSON.parse(token.value);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Runs the full enable chain: browser permission → runtime VAPID public key
|
|
56
|
+
* (`GET /api/devices/push/public-key`) → `register({ vapidPublicKey })` →
|
|
57
|
+
* persist the subscription on the current device row.
|
|
58
|
+
*
|
|
59
|
+
* Every failure is returned as a typed reason (never thrown) so the UI can
|
|
60
|
+
* show an honest, specific message instead of hanging or silently reverting.
|
|
61
|
+
*
|
|
62
|
+
* @param deps - The http client + push actions from `usePush()`.
|
|
63
|
+
* @param deps.http - Authenticated http client (`useHttpClient()`).
|
|
64
|
+
* @param deps.requestPermission - `usePush().requestPermission`.
|
|
65
|
+
* @param deps.register - `usePush().register`.
|
|
66
|
+
* @returns `{ ok: true }` or a typed failure.
|
|
67
|
+
*/
|
|
68
|
+
export const enablePushOnCurrentDevice = async (deps) => {
|
|
69
|
+
const permission = await deps.requestPermission();
|
|
70
|
+
if (permission !== 'granted') {
|
|
71
|
+
return { ok: false, reason: 'permission-denied' };
|
|
72
|
+
}
|
|
73
|
+
let publicKey;
|
|
74
|
+
try {
|
|
75
|
+
const response = await deps.http.get('/api/devices/push/public-key');
|
|
76
|
+
publicKey = response.data?.publicKey;
|
|
77
|
+
}
|
|
78
|
+
catch (_error) {
|
|
79
|
+
// 404/503 from the bond-gated route — push is not configured server-side.
|
|
80
|
+
// Reported to the user as 'server-unconfigured'; nothing else to log here.
|
|
81
|
+
publicKey = undefined;
|
|
82
|
+
}
|
|
83
|
+
if (!publicKey) {
|
|
84
|
+
return { ok: false, reason: 'server-unconfigured' };
|
|
85
|
+
}
|
|
86
|
+
let token;
|
|
87
|
+
try {
|
|
88
|
+
token = await deps.register({ vapidPublicKey: publicKey });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
// The provider throws already-localized messages (not supported / no
|
|
92
|
+
// service worker in dev builds / push-service rejection) — surface them.
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
reason: 'register-failed',
|
|
96
|
+
message: error instanceof Error ? error.message : String(error),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const devices = await deps.http.get('/api/devices');
|
|
101
|
+
const device = findCurrentDevice(devices.data);
|
|
102
|
+
if (!device) {
|
|
103
|
+
return { ok: false, reason: 'persist-failed' };
|
|
104
|
+
}
|
|
105
|
+
await deps.http.patch(`/api/devices/${device.id}`, {
|
|
106
|
+
pushSubscription: subscriptionFromToken(token),
|
|
107
|
+
hasPushSubscription: true,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
reason: 'persist-failed',
|
|
114
|
+
message: error instanceof Error ? error.message : String(error),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return { ok: true };
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Disables push: unsubscribes the browser (best-effort — a dev build without
|
|
121
|
+
* a service worker has nothing to unsubscribe) and ALWAYS clears the server
|
|
122
|
+
* state so no further pushes target this device.
|
|
123
|
+
*
|
|
124
|
+
* @param deps - The http client + push action from `usePush()`.
|
|
125
|
+
* @param deps.http - Authenticated http client (`useHttpClient()`).
|
|
126
|
+
* @param deps.unregister - `usePush().unregister`.
|
|
127
|
+
* @returns `{ ok: true }` or a typed failure (server state not cleared).
|
|
128
|
+
*/
|
|
129
|
+
export const disablePushOnCurrentDevice = async (deps) => {
|
|
130
|
+
try {
|
|
131
|
+
await deps.unregister();
|
|
132
|
+
}
|
|
133
|
+
catch (_error) {
|
|
134
|
+
// Best-effort: browser-side unsubscribe can fail (no service worker in a
|
|
135
|
+
// dev build); the server-side clear below is what stops future sends.
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const devices = await deps.http.get('/api/devices');
|
|
139
|
+
const device = findCurrentDevice(devices.data);
|
|
140
|
+
if (device) {
|
|
141
|
+
await deps.http.patch(`/api/devices/${device.id}`, {
|
|
142
|
+
pushSubscription: null,
|
|
143
|
+
hasPushSubscription: false,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return {
|
|
149
|
+
ok: false,
|
|
150
|
+
reason: 'persist-failed',
|
|
151
|
+
message: error instanceof Error ? error.message : String(error),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return { ok: true };
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Reads whether push is currently enabled for THIS device (server truth:
|
|
158
|
+
* the current device row's `hasPushSubscription`).
|
|
159
|
+
*
|
|
160
|
+
* @param http - Authenticated http client (`useHttpClient()`).
|
|
161
|
+
* @returns `true` when the current device has a stored subscription.
|
|
162
|
+
*/
|
|
163
|
+
export const readCurrentDevicePushEnabled = async (http) => {
|
|
164
|
+
try {
|
|
165
|
+
const devices = await http.get('/api/devices');
|
|
166
|
+
return findCurrentDevice(devices.data)?.hasPushSubscription === true;
|
|
167
|
+
}
|
|
168
|
+
catch (_error) {
|
|
169
|
+
// Devices endpoint unavailable (e.g. unauthenticated preview) — render
|
|
170
|
+
// the toggle off rather than failing the whole settings panel.
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=device-toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-toggle.js","sourceRoot":"","sources":["../src/device-toggle.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -52,9 +52,18 @@
|
|
|
52
52
|
* delivery send a real push from the server.
|
|
53
53
|
* - `token.value` on web is a JSON-serialized PushSubscription (not an FCM
|
|
54
54
|
* token) — store it opaquely; platform is in `token.platform`.
|
|
55
|
+
* - **A settings toggle for the current device** needs no code of its own:
|
|
56
|
+
* `enablePushOnCurrentDevice({ http, requestPermission, register })`,
|
|
57
|
+
* `disablePushOnCurrentDevice({ http, unregister })` and
|
|
58
|
+
* `readCurrentDevicePushEnabled(http)` run the whole chain against the
|
|
59
|
+
* molecule device API (`GET /api/devices/push/public-key`,
|
|
60
|
+
* `GET /api/devices`, `PATCH /api/devices/:id`) and return a typed result
|
|
61
|
+
* instead of throwing. Every framework's settings panel package re-exports
|
|
62
|
+
* them.
|
|
55
63
|
*
|
|
56
64
|
* @module
|
|
57
65
|
*/
|
|
66
|
+
export * from './device-toggle.js';
|
|
58
67
|
export * from './provider.js';
|
|
59
68
|
export * from './types.js';
|
|
60
69
|
export * from './web-provider.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -52,9 +52,18 @@
|
|
|
52
52
|
* delivery send a real push from the server.
|
|
53
53
|
* - `token.value` on web is a JSON-serialized PushSubscription (not an FCM
|
|
54
54
|
* token) — store it opaquely; platform is in `token.platform`.
|
|
55
|
+
* - **A settings toggle for the current device** needs no code of its own:
|
|
56
|
+
* `enablePushOnCurrentDevice({ http, requestPermission, register })`,
|
|
57
|
+
* `disablePushOnCurrentDevice({ http, unregister })` and
|
|
58
|
+
* `readCurrentDevicePushEnabled(http)` run the whole chain against the
|
|
59
|
+
* molecule device API (`GET /api/devices/push/public-key`,
|
|
60
|
+
* `GET /api/devices`, `PATCH /api/devices/:id`) and return a typed result
|
|
61
|
+
* instead of throwing. Every framework's settings panel package re-exports
|
|
62
|
+
* them.
|
|
55
63
|
*
|
|
56
64
|
* @module
|
|
57
65
|
*/
|
|
66
|
+
export * from './device-toggle.js';
|
|
58
67
|
export * from './provider.js';
|
|
59
68
|
export * from './types.js';
|
|
60
69
|
export * from './web-provider.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-push",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Client-side push notifications interface for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"@molecule/app-i18n": "^1.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@molecule/app-bond": "1.0.
|
|
36
|
-
"@molecule/app-i18n": "1.
|
|
37
|
-
"@types/node": "26.
|
|
35
|
+
"@molecule/app-bond": "1.0.5",
|
|
36
|
+
"@molecule/app-i18n": "1.2.1",
|
|
37
|
+
"@types/node": "26.6.5",
|
|
38
38
|
"typescript": "6.0.3",
|
|
39
|
-
"vitest": "4.1.
|
|
39
|
+
"vitest": "4.1.12"
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|