@molecule/api-push-notifications-molecule 0.0.0-stage → 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 +202 -0
- package/README.md +182 -2
- package/dist/browser-guard.d.ts +2 -0
- package/dist/browser-guard.d.ts.map +1 -0
- package/dist/browser-guard.js +18 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/provider.d.ts +127 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +287 -0
- package/dist/secrets.d.ts +17 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +25 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/package.json +49 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
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."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
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.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
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.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
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.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
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]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,183 @@
|
|
|
1
|
-
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-10-08T03:25:11.137Z
|
|
7
|
+
-->
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
# @molecule/api-push-notifications-molecule
|
|
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
|
+
molecule.dev hosted push notifications provider — web push delivered through your molecule project, VAPID handled for you
|
|
16
|
+
|
|
17
|
+
## Type
|
|
18
|
+
|
|
19
|
+
`provider`
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @molecule/api-push-notifications-molecule @molecule/api-push-notifications @molecule/api-secrets
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
### Interfaces
|
|
30
|
+
|
|
31
|
+
#### `MoleculePushConfig`
|
|
32
|
+
|
|
33
|
+
Options for {@link createProvider}. Every field falls back to an env var,
|
|
34
|
+
so the zero-argument `provider` export works from `.env` alone.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
interface MoleculePushConfig {
|
|
38
|
+
/**
|
|
39
|
+
* The molecule project API key (`mk_…`), or the sandbox token molecule.dev
|
|
40
|
+
* writes for in-IDE apps (`mbk_…`). Defaults to `MOLECULE_API_KEY`.
|
|
41
|
+
*/
|
|
42
|
+
apiKey?: string
|
|
43
|
+
/**
|
|
44
|
+
* The hosted services base URL, without a trailing slash. Defaults to
|
|
45
|
+
* `MOLECULE_SERVICES_URL`, then `https://api.molecule.dev/api/v1/services`.
|
|
46
|
+
*/
|
|
47
|
+
servicesUrl?: string
|
|
48
|
+
/** Per-request timeout in milliseconds. Default 15000. */
|
|
49
|
+
timeoutMs?: number
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### `ProcessEnv`
|
|
54
|
+
|
|
55
|
+
Environment variables this provider reads.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface ProcessEnv {
|
|
59
|
+
MOLECULE_API_KEY?: string
|
|
60
|
+
MOLECULE_SERVICES_URL?: string
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Classes
|
|
65
|
+
|
|
66
|
+
#### `MoleculePushProvider`
|
|
67
|
+
|
|
68
|
+
Push provider backed by molecule.dev's hosted service.
|
|
69
|
+
|
|
70
|
+
#### `MoleculeServiceError`
|
|
71
|
+
|
|
72
|
+
Error thrown for a refused or failed hosted-service call.
|
|
73
|
+
|
|
74
|
+
### Functions
|
|
75
|
+
|
|
76
|
+
#### `createProvider(config)`
|
|
77
|
+
|
|
78
|
+
Create a hosted push notifications provider.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
function createProvider(config?: MoleculePushConfig): PushNotificationProvider
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- `config` — Options; each falls back to its env var.
|
|
85
|
+
|
|
86
|
+
**Returns:** A `PushNotificationProvider` backed by molecule.dev.
|
|
87
|
+
|
|
88
|
+
### Constants
|
|
89
|
+
|
|
90
|
+
#### `DEFAULT_SERVICES_URL`
|
|
91
|
+
|
|
92
|
+
Default hosted services base URL.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const DEFAULT_SERVICES_URL: 'https://api.molecule.dev/api/v1/services'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### `provider`
|
|
99
|
+
|
|
100
|
+
The provider implementation (wire with `setProvider`).
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const provider: PushNotificationProvider
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### `PUSH_SERVICE_LIMITS`
|
|
107
|
+
|
|
108
|
+
Per-request limits of the hosted service.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
const PUSH_SERVICE_LIMITS: {
|
|
112
|
+
readonly maxPayloadChars: 3072
|
|
113
|
+
readonly maxKeyChars: 512
|
|
114
|
+
readonly maxEndpointChars: 2048
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### `pushNotificationsMoleculeSecretDefinitions`
|
|
119
|
+
|
|
120
|
+
Secret definitions required by the molecule.dev hosted push bond.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const pushNotificationsMoleculeSecretDefinitions: SecretDefinition[]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Core Interface
|
|
127
|
+
|
|
128
|
+
Implements `@molecule/api-push-notifications` interface.
|
|
129
|
+
|
|
130
|
+
## Bond Wiring
|
|
131
|
+
|
|
132
|
+
Setup function to register this provider with the core interface:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { setProvider } from '@molecule/api-push-notifications'
|
|
136
|
+
import { provider } from '@molecule/api-push-notifications-molecule'
|
|
137
|
+
|
|
138
|
+
export function setupPushNotificationsMolecule(): void {
|
|
139
|
+
setProvider(provider)
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Injection Notes
|
|
144
|
+
|
|
145
|
+
### Requirements
|
|
146
|
+
|
|
147
|
+
Peer dependencies:
|
|
148
|
+
|
|
149
|
+
- `@molecule/api-push-notifications` >=1.0.2
|
|
150
|
+
- `@molecule/api-secrets` ^1.0.1
|
|
151
|
+
|
|
152
|
+
### Environment Variables
|
|
153
|
+
|
|
154
|
+
- `MOLECULE_API_KEY` _(required)_ — molecule.dev project API key
|
|
155
|
+
- Setup: Create one for your project with `mlcl apikey create --project <id> --name <name>` (keys start with mk_).
|
|
156
|
+
- Get it here: [https://www.molecule.dev](https://www.molecule.dev)
|
|
157
|
+
- Example: `mk_...`
|
|
158
|
+
|
|
159
|
+
### Runtime Dependencies
|
|
160
|
+
|
|
161
|
+
- `@molecule/api-push-notifications`
|
|
162
|
+
- `@molecule/api-secrets`
|
|
163
|
+
|
|
164
|
+
## E2E Tests
|
|
165
|
+
|
|
166
|
+
Integration checklist — drive the real UI (live preview, no mocks), adapt
|
|
167
|
+
each item to this app's actual screens/flows, and check every box off one
|
|
168
|
+
by one. A box you can't check is an integration bug to fix — not a skip:
|
|
169
|
+
|
|
170
|
+
- [ ] The UI offers an enable-notifications control; activating it triggers
|
|
171
|
+
the browser permission prompt and, once granted, the subscription is
|
|
172
|
+
stored (the UI still shows "enabled" after a full reload).
|
|
173
|
+
- [ ] An event this app notifies about actually delivers a push to the
|
|
174
|
+
subscribed session, with a readable title/body (not raw JSON). The sandbox
|
|
175
|
+
CAPTURES outbound pushes instead of delivering — read the captured message
|
|
176
|
+
with the `read_activity` tool (filter type 'push'); never mock the flow or
|
|
177
|
+
modify production code to expose it.
|
|
178
|
+
- [ ] Clicking the delivered notification opens/focuses the relevant screen
|
|
179
|
+
(when the app claims deep-linking).
|
|
180
|
+
- [ ] Denying the permission leaves the app fully usable and truthful about
|
|
181
|
+
the state (no crash, no false "enabled").
|
|
182
|
+
- [ ] Disabling/unsubscribing stops deliveries, and the disabled state
|
|
183
|
+
persists across a reload.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-guard.d.ts","sourceRoot":"","sources":["../src/browser-guard.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser guard — `@molecule/api-push-notifications-molecule` is SERVER-ONLY.
|
|
3
|
+
*
|
|
4
|
+
* Generated by scripts/gen-browser-guards.mjs (workspace root) — edit THAT, not this.
|
|
5
|
+
* Evaluating a server package in a browser bundle is always an import-graph mistake
|
|
6
|
+
* (node APIs, secrets); without this guard it surfaces as a cryptic downstream crash
|
|
7
|
+
* ("Buffer is not defined") far from the culprit. Throwing here names the package and
|
|
8
|
+
* the fix at the exact moment the client bundle evaluates it. jsdom tests and SSR are
|
|
9
|
+
* unaffected: the throw requires browser globals AND the absence of a node runtime.
|
|
10
|
+
*/
|
|
11
|
+
const g = globalThis;
|
|
12
|
+
if (g.window !== undefined && g.document !== undefined && !g.process?.versions?.node) {
|
|
13
|
+
throw new Error('@molecule/api-push-notifications-molecule is SERVER-ONLY: it was bundled into browser/client code. Import it only ' +
|
|
14
|
+
'from server code (a server route/function or your API), or dynamic-import it inside ' +
|
|
15
|
+
'the server handler — never from components or shared client modules, and never ' +
|
|
16
|
+
'polyfill Buffer/process to silence this.');
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* molecule.dev hosted push notifications provider for `@molecule/api-push-notifications`.
|
|
3
|
+
*
|
|
4
|
+
* Delivers web push notifications through molecule.dev and bills the sends to
|
|
5
|
+
* your molecule project, so the app needs no push-service vendor account and
|
|
6
|
+
* never holds a VAPID private key. It is an ordinary bond: swap it for
|
|
7
|
+
* `@molecule/api-push-notifications-web-push` (your own VAPID keys, self-hosted)
|
|
8
|
+
* without changing code that calls the core.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { setProvider, send } from '@molecule/api-push-notifications'
|
|
13
|
+
* import { provider as push } from '@molecule/api-push-notifications-molecule'
|
|
14
|
+
*
|
|
15
|
+
* setProvider(push) // reads MOLECULE_API_KEY from the environment
|
|
16
|
+
*
|
|
17
|
+
* // One-time: give the browser molecule.dev's public key to subscribe with.
|
|
18
|
+
* const applicationServerKey = await push.fetchPublicKey()
|
|
19
|
+
*
|
|
20
|
+
* await send(subscription, { title: 'Order shipped', options: { body: 'Track it here.' } })
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - Config: `MOLECULE_API_KEY` (SERVER-side only) — a molecule project API key
|
|
25
|
+
* (`mk_…`) or the in-sandbox token (`mbk_…`) with scope `broker` or
|
|
26
|
+
* `broker:push-notifications`. Optional `MOLECULE_SERVICES_URL` (default
|
|
27
|
+
* `https://api.molecule.dev/api/v1/services`; https required — plain-http is
|
|
28
|
+
* refused unless the host is loopback or a private-network endpoint such as
|
|
29
|
+
* the sandbox gateway `host.docker.internal` (RFC 1918 / *.docker.internal)).
|
|
30
|
+
* - **Subscriptions are bound to the VAPID key they were created with.** A
|
|
31
|
+
* browser subscribes with the `applicationServerKey` returned by
|
|
32
|
+
* `fetchPublicKey()` — molecule.dev's public key — and only molecule.dev can
|
|
33
|
+
* then send to those subscriptions. Moving to your own VAPID identity (the
|
|
34
|
+
* web-push bond) means your users re-subscribe.
|
|
35
|
+
* - `getPublicKey()` is the core's SYNCHRONOUS method, so it returns the
|
|
36
|
+
* cache: `undefined` until `fetchPublicKey()` has run. `configure()` is a
|
|
37
|
+
* no-op (the service holds the keys), and `generateVapidKeys()` throws —
|
|
38
|
+
* generating your own keys is a self-hosted concern (`@molecule/api-push-notifications-web-push`).
|
|
39
|
+
* - Payloads are bounded at 3072 characters of serialized JSON (the Web Push
|
|
40
|
+
* protocol caps the ENCRYPTED payload at 4096 bytes and encryption adds
|
|
41
|
+
* overhead); subscriptions need the exact `endpoint` + `keys.p256dh` +
|
|
42
|
+
* `keys.auth` values `pushManager.subscribe()` returned. Bad calls are
|
|
43
|
+
* refused locally with 400/413 and never leave the process.
|
|
44
|
+
* - Every push-service answer arrives as a resolved `SendResult`: `statusCode`
|
|
45
|
+
* 201 means delivered; 404/410 mean the subscription is dead — prune it.
|
|
46
|
+
* `sendMany()` never aborts the batch on one dead subscription.
|
|
47
|
+
* - Metered per send and billed to the project; the upstream push services
|
|
48
|
+
* (FCM, Mozilla autopush, Apple) are free, so the real upstream cost is 0 —
|
|
49
|
+
* the send still counts against the project's rate limit and free-tier
|
|
50
|
+
* allowance.
|
|
51
|
+
* - Errors are `MoleculeServiceError` with `status` and `errorKey` (401 bad key,
|
|
52
|
+
* 402 allowance used up, 429 / 503 retry later). Nothing is retried.
|
|
53
|
+
*/
|
|
54
|
+
export * from './browser-guard.js';
|
|
55
|
+
export * from './provider.js';
|
|
56
|
+
export * from './secrets.js';
|
|
57
|
+
export * from './types.js';
|
|
58
|
+
import type { PushNotificationProvider } from '@molecule/api-push-notifications';
|
|
59
|
+
/**
|
|
60
|
+
* The provider implementation (wire with `setProvider`).
|
|
61
|
+
*/
|
|
62
|
+
export declare const provider: PushNotificationProvider;
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAE1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAOhF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,wBASrB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* molecule.dev hosted push notifications provider for `@molecule/api-push-notifications`.
|
|
3
|
+
*
|
|
4
|
+
* Delivers web push notifications through molecule.dev and bills the sends to
|
|
5
|
+
* your molecule project, so the app needs no push-service vendor account and
|
|
6
|
+
* never holds a VAPID private key. It is an ordinary bond: swap it for
|
|
7
|
+
* `@molecule/api-push-notifications-web-push` (your own VAPID keys, self-hosted)
|
|
8
|
+
* without changing code that calls the core.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { setProvider, send } from '@molecule/api-push-notifications'
|
|
13
|
+
* import { provider as push } from '@molecule/api-push-notifications-molecule'
|
|
14
|
+
*
|
|
15
|
+
* setProvider(push) // reads MOLECULE_API_KEY from the environment
|
|
16
|
+
*
|
|
17
|
+
* // One-time: give the browser molecule.dev's public key to subscribe with.
|
|
18
|
+
* const applicationServerKey = await push.fetchPublicKey()
|
|
19
|
+
*
|
|
20
|
+
* await send(subscription, { title: 'Order shipped', options: { body: 'Track it here.' } })
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - Config: `MOLECULE_API_KEY` (SERVER-side only) — a molecule project API key
|
|
25
|
+
* (`mk_…`) or the in-sandbox token (`mbk_…`) with scope `broker` or
|
|
26
|
+
* `broker:push-notifications`. Optional `MOLECULE_SERVICES_URL` (default
|
|
27
|
+
* `https://api.molecule.dev/api/v1/services`; https required — plain-http is
|
|
28
|
+
* refused unless the host is loopback or a private-network endpoint such as
|
|
29
|
+
* the sandbox gateway `host.docker.internal` (RFC 1918 / *.docker.internal)).
|
|
30
|
+
* - **Subscriptions are bound to the VAPID key they were created with.** A
|
|
31
|
+
* browser subscribes with the `applicationServerKey` returned by
|
|
32
|
+
* `fetchPublicKey()` — molecule.dev's public key — and only molecule.dev can
|
|
33
|
+
* then send to those subscriptions. Moving to your own VAPID identity (the
|
|
34
|
+
* web-push bond) means your users re-subscribe.
|
|
35
|
+
* - `getPublicKey()` is the core's SYNCHRONOUS method, so it returns the
|
|
36
|
+
* cache: `undefined` until `fetchPublicKey()` has run. `configure()` is a
|
|
37
|
+
* no-op (the service holds the keys), and `generateVapidKeys()` throws —
|
|
38
|
+
* generating your own keys is a self-hosted concern (`@molecule/api-push-notifications-web-push`).
|
|
39
|
+
* - Payloads are bounded at 3072 characters of serialized JSON (the Web Push
|
|
40
|
+
* protocol caps the ENCRYPTED payload at 4096 bytes and encryption adds
|
|
41
|
+
* overhead); subscriptions need the exact `endpoint` + `keys.p256dh` +
|
|
42
|
+
* `keys.auth` values `pushManager.subscribe()` returned. Bad calls are
|
|
43
|
+
* refused locally with 400/413 and never leave the process.
|
|
44
|
+
* - Every push-service answer arrives as a resolved `SendResult`: `statusCode`
|
|
45
|
+
* 201 means delivered; 404/410 mean the subscription is dead — prune it.
|
|
46
|
+
* `sendMany()` never aborts the batch on one dead subscription.
|
|
47
|
+
* - Metered per send and billed to the project; the upstream push services
|
|
48
|
+
* (FCM, Mozilla autopush, Apple) are free, so the real upstream cost is 0 —
|
|
49
|
+
* the send still counts against the project's rate limit and free-tier
|
|
50
|
+
* allowance.
|
|
51
|
+
* - Errors are `MoleculeServiceError` with `status` and `errorKey` (401 bad key,
|
|
52
|
+
* 402 allowance used up, 429 / 503 retry later). Nothing is retried.
|
|
53
|
+
*/
|
|
54
|
+
export * from './browser-guard.js';
|
|
55
|
+
export * from './provider.js';
|
|
56
|
+
export * from './secrets.js';
|
|
57
|
+
export * from './types.js';
|
|
58
|
+
import { createProvider } from './provider.js';
|
|
59
|
+
/** Lazily-initialized provider. Defers creation until first use so env vars are resolved. */
|
|
60
|
+
let _provider = null;
|
|
61
|
+
/**
|
|
62
|
+
* The provider implementation (wire with `setProvider`).
|
|
63
|
+
*/
|
|
64
|
+
export const provider = new Proxy({}, {
|
|
65
|
+
get(_, prop, receiver) {
|
|
66
|
+
if (!_provider)
|
|
67
|
+
_provider = createProvider();
|
|
68
|
+
return Reflect.get(_provider, prop, receiver);
|
|
69
|
+
},
|
|
70
|
+
set(_, prop, value) {
|
|
71
|
+
if (!_provider)
|
|
72
|
+
_provider = createProvider();
|
|
73
|
+
return Reflect.set(_provider, prop, value);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* molecule.dev hosted push notifications.
|
|
3
|
+
*
|
|
4
|
+
* `send` calls `POST <servicesUrl>/push/send` and `getPublicKey` calls
|
|
5
|
+
* `POST <servicesUrl>/push/vapid-key` with the project's API key. VAPID is
|
|
6
|
+
* handled by molecule.dev — the app never sees a private key.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { NotificationPayload, PushNotificationProvider, PushSubscription, SendManyResult, SendResult, VapidConfig } from '@molecule/api-push-notifications';
|
|
11
|
+
import type { MoleculePushConfig } from './types.js';
|
|
12
|
+
/** Default hosted services base URL. */
|
|
13
|
+
export declare const DEFAULT_SERVICES_URL = "https://api.molecule.dev/api/v1/services";
|
|
14
|
+
/** Per-request limits of the hosted service. */
|
|
15
|
+
export declare const PUSH_SERVICE_LIMITS: {
|
|
16
|
+
/** Serialized JSON payload cap — the Web Push spec allows 4096 bytes ENCRYPTED; encryption adds overhead on top of the JSON. */
|
|
17
|
+
readonly maxPayloadChars: 3072;
|
|
18
|
+
/** Subscription key string cap (the browser values are ~88 and ~24 base64url chars). */
|
|
19
|
+
readonly maxKeyChars: 512;
|
|
20
|
+
/** Endpoint URL cap. */
|
|
21
|
+
readonly maxEndpointChars: 2048;
|
|
22
|
+
};
|
|
23
|
+
/** Error thrown for a refused or failed hosted-service call. */
|
|
24
|
+
export declare class MoleculeServiceError extends Error {
|
|
25
|
+
/** HTTP status from molecule.dev. */
|
|
26
|
+
readonly status: number;
|
|
27
|
+
/** Stable error key from molecule.dev, e.g. `broker.error.budgetExceeded`. */
|
|
28
|
+
readonly errorKey: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Create the error.
|
|
31
|
+
*
|
|
32
|
+
* @param message - Human-readable message.
|
|
33
|
+
* @param status - HTTP status.
|
|
34
|
+
* @param errorKey - Stable error key, when the service sent one.
|
|
35
|
+
* @param cause - The underlying error, if any.
|
|
36
|
+
*/
|
|
37
|
+
constructor(message: string, status: number, errorKey?: string, cause?: unknown);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Push provider backed by molecule.dev's hosted service.
|
|
41
|
+
*/
|
|
42
|
+
export declare class MoleculePushProvider implements PushNotificationProvider {
|
|
43
|
+
readonly name = "molecule";
|
|
44
|
+
private readonly apiKey;
|
|
45
|
+
private readonly servicesUrl;
|
|
46
|
+
private readonly timeoutMs;
|
|
47
|
+
private cachedPublicKey;
|
|
48
|
+
/**
|
|
49
|
+
* Create the provider.
|
|
50
|
+
*
|
|
51
|
+
* @param config - Options; each falls back to its env var.
|
|
52
|
+
*/
|
|
53
|
+
constructor(config?: MoleculePushConfig);
|
|
54
|
+
/**
|
|
55
|
+
* Nothing to configure locally — molecule.dev holds the VAPID keys and
|
|
56
|
+
* signs every send. The parameter is accepted so the provider satisfies
|
|
57
|
+
* the core interface; a self-hosted setup should use
|
|
58
|
+
* `@molecule/api-push-notifications-web-push` instead.
|
|
59
|
+
*
|
|
60
|
+
* @param _config - Ignored.
|
|
61
|
+
*/
|
|
62
|
+
configure(_config?: VapidConfig): void;
|
|
63
|
+
/**
|
|
64
|
+
* Sends a push notification to a subscription endpoint.
|
|
65
|
+
*
|
|
66
|
+
* @param subscription - The push subscription (endpoint + keys).
|
|
67
|
+
* @param payload - The notification payload (title + display options).
|
|
68
|
+
* @returns The push service's answer: `statusCode` 201 means delivered;
|
|
69
|
+
* 404/410 mean the subscription is dead and should be pruned.
|
|
70
|
+
*/
|
|
71
|
+
send(subscription: PushSubscription, payload: NotificationPayload): Promise<SendResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Sends a push notification to multiple subscriptions. One refused or
|
|
74
|
+
* failed subscription never aborts the batch — each entry carries either
|
|
75
|
+
* `result` or `error` (a dead subscription arrives as a `result` whose
|
|
76
|
+
* `statusCode` is 404/410; prune on it).
|
|
77
|
+
*
|
|
78
|
+
* @param subscriptions - The push subscriptions to send to.
|
|
79
|
+
* @param payload - The notification payload with title and optional display options.
|
|
80
|
+
* @returns One result entry per subscription.
|
|
81
|
+
*/
|
|
82
|
+
sendMany(subscriptions: PushSubscription[], payload: NotificationPayload): Promise<SendManyResult[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns molecule.dev's public VAPID key — the `applicationServerKey` a
|
|
85
|
+
* browser's `pushManager.subscribe()` must be given for the resulting
|
|
86
|
+
* subscriptions to be sendable through molecule.dev.
|
|
87
|
+
*
|
|
88
|
+
* The core's method is SYNCHRONOUS while the key lives behind a service
|
|
89
|
+
* call, so this returns the cache: `undefined` until {@link fetchPublicKey}
|
|
90
|
+
* has run (or a send cached it). Await the fetch first:
|
|
91
|
+
*
|
|
92
|
+
* ```typescript
|
|
93
|
+
* await provider.fetchPublicKey() // once, e.g. at startup
|
|
94
|
+
* const applicationServerKey = provider.getPublicKey()
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @returns The cached public key, or `undefined` before the first fetch.
|
|
98
|
+
*/
|
|
99
|
+
getPublicKey(): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Fetches molecule.dev's public VAPID key from the hosted service and
|
|
102
|
+
* caches it for {@link getPublicKey}.
|
|
103
|
+
*
|
|
104
|
+
* @returns The public key string.
|
|
105
|
+
*/
|
|
106
|
+
fetchPublicKey(): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Not supported on the hosted path: sends are signed with molecule.dev's
|
|
109
|
+
* VAPID identity, and subscriptions are bound to the key they were created
|
|
110
|
+
* with — a locally generated pair could never receive a hosted send. Use
|
|
111
|
+
* `@molecule/api-push-notifications-web-push` (which serves your own keys)
|
|
112
|
+
* when you need your own identity.
|
|
113
|
+
*
|
|
114
|
+
* @throws {MoleculeServiceError} Always, with the self-hosted pointer.
|
|
115
|
+
*/
|
|
116
|
+
generateVapidKeys(): never;
|
|
117
|
+
/** One POST to the hosted service. */
|
|
118
|
+
private request;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create a hosted push notifications provider.
|
|
122
|
+
*
|
|
123
|
+
* @param config - Options; each falls back to its env var.
|
|
124
|
+
* @returns A `PushNotificationProvider` backed by molecule.dev.
|
|
125
|
+
*/
|
|
126
|
+
export declare function createProvider(config?: MoleculePushConfig): PushNotificationProvider;
|
|
127
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACZ,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,wCAAwC;AACxC,eAAO,MAAM,oBAAoB,6CAA6C,CAAA;AAkE9E,gDAAgD;AAChD,eAAO,MAAM,mBAAmB;IAC9B,gIAAgI;;IAEhI,wFAAwF;;IAExF,wBAAwB;;CAEhB,CAAA;AAEV,gEAAgE;AAChE,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAErC;;;;;;;OAOG;gBACS,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAMhF;AAoFD;;GAEG;AACH,qBAAa,oBAAqB,YAAW,wBAAwB;IACnE,QAAQ,CAAC,IAAI,cAAa;IAE1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,eAAe,CAAoB;IAE3C;;;;OAIG;gBACS,MAAM,GAAE,kBAAuB;IAQ3C;;;;;;;OAOG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;IAEtC;;;;;;;OAOG;IACG,IAAI,CAAC,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAM7F;;;;;;;;;OASG;IACG,QAAQ,CACZ,aAAa,EAAE,gBAAgB,EAAE,EACjC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC;IAW5B;;;;;;;;;;;;;;;OAeG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC;;;;;OAKG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAMvC;;;;;;;;OAQG;IACH,iBAAiB,IAAI,KAAK;IAQ1B,sCAAsC;YACxB,OAAO;CAyCtB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,wBAAwB,CAEpF"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* molecule.dev hosted push notifications.
|
|
3
|
+
*
|
|
4
|
+
* `send` calls `POST <servicesUrl>/push/send` and `getPublicKey` calls
|
|
5
|
+
* `POST <servicesUrl>/push/vapid-key` with the project's API key. VAPID is
|
|
6
|
+
* handled by molecule.dev — the app never sees a private key.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/** Default hosted services base URL. */
|
|
11
|
+
export const DEFAULT_SERVICES_URL = 'https://api.molecule.dev/api/v1/services';
|
|
12
|
+
/**
|
|
13
|
+
* Validates the hosted-services base URL and strips trailing slashes.
|
|
14
|
+
*
|
|
15
|
+
* The project API key rides as a Bearer token on every call, so a plain-http
|
|
16
|
+
* base URL must never send it across the PUBLIC internet in cleartext.
|
|
17
|
+
* Mirroring the docker sandbox bond's plain-TCP production refusal, non-https
|
|
18
|
+
* URLs are refused unless the host is loopback (a self-hosted services
|
|
19
|
+
* instance for local development) or a PRIVATE-network endpoint — RFC 1918
|
|
20
|
+
* addresses and `*.docker.internal` — which is how an in-sandbox app reaches
|
|
21
|
+
* its platform's hosted-services gateway (`http://host.docker.internal:…`),
|
|
22
|
+
* traffic that never leaves the host's virtual network. Public cleartext is
|
|
23
|
+
* still refused. Duplicated across the molecule service bonds on purpose:
|
|
24
|
+
* they are independent published packages with no shared runtime dependency.
|
|
25
|
+
*
|
|
26
|
+
* @param raw - The configured or defaulted base URL.
|
|
27
|
+
* @returns The validated base URL, without trailing slashes.
|
|
28
|
+
* @throws {Error} When the URL is not https and not loopback/private http.
|
|
29
|
+
*/
|
|
30
|
+
function resolveServicesUrl(raw) {
|
|
31
|
+
const trimmed = raw.replace(/\/+$/, '');
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = new URL(trimmed);
|
|
35
|
+
}
|
|
36
|
+
catch (_error) {
|
|
37
|
+
// Not a URL at all (e.g. a bare hostname) — refuse it with the fix spelled out.
|
|
38
|
+
throw new Error(`Invalid MOLECULE_SERVICES_URL "${raw}" — it must be an absolute https URL (default ${DEFAULT_SERVICES_URL}).`, { cause: _error });
|
|
39
|
+
}
|
|
40
|
+
const host = parsed.hostname.toLowerCase();
|
|
41
|
+
if (parsed.protocol === 'https:' || (parsed.protocol === 'http:' && isPrivateHttpHost(host))) {
|
|
42
|
+
return trimmed;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`MOLECULE_SERVICES_URL "${raw}" must use https: the project API key is sent as a Bearer token on every request and must not cross the public internet in cleartext. ` +
|
|
45
|
+
`Point it at ${DEFAULT_SERVICES_URL} or a private https endpoint; only loopback and private-network (RFC 1918 / *.docker.internal) http is allowed, for a local services instance or an in-sandbox app reaching its own platform.`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether a plain-http URL to this host never leaves a trusted network: the
|
|
49
|
+
* loopback addresses, the RFC 1918 private ranges (each octet range-checked —
|
|
50
|
+
* a public address must not parse its way past this guard), and the docker
|
|
51
|
+
* host-gateway names an in-sandbox app uses to reach its own platform.
|
|
52
|
+
*
|
|
53
|
+
* @param host - Lowercased URL hostname.
|
|
54
|
+
* @returns True when plain http to this host is a private-network hop.
|
|
55
|
+
*/
|
|
56
|
+
function isPrivateHttpHost(host) {
|
|
57
|
+
if (host === 'localhost' || host === '[::1]' || host === '::1' || host.startsWith('127.')) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (host === 'host.docker.internal' || host.endsWith('.docker.internal'))
|
|
61
|
+
return true;
|
|
62
|
+
const octets = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
|
|
63
|
+
if (!octets)
|
|
64
|
+
return false;
|
|
65
|
+
const [a, b, c, d] = octets.slice(1).map(Number);
|
|
66
|
+
if ([a, b, c, d].some((n) => n > 255))
|
|
67
|
+
return false;
|
|
68
|
+
if (a === 10)
|
|
69
|
+
return true;
|
|
70
|
+
if (a === 172)
|
|
71
|
+
return b >= 16 && b <= 31;
|
|
72
|
+
if (a === 192)
|
|
73
|
+
return b === 168;
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
/** Per-request limits of the hosted service. */
|
|
77
|
+
export const PUSH_SERVICE_LIMITS = {
|
|
78
|
+
/** Serialized JSON payload cap — the Web Push spec allows 4096 bytes ENCRYPTED; encryption adds overhead on top of the JSON. */
|
|
79
|
+
maxPayloadChars: 3072,
|
|
80
|
+
/** Subscription key string cap (the browser values are ~88 and ~24 base64url chars). */
|
|
81
|
+
maxKeyChars: 512,
|
|
82
|
+
/** Endpoint URL cap. */
|
|
83
|
+
maxEndpointChars: 2048,
|
|
84
|
+
};
|
|
85
|
+
/** Error thrown for a refused or failed hosted-service call. */
|
|
86
|
+
export class MoleculeServiceError extends Error {
|
|
87
|
+
/** HTTP status from molecule.dev. */
|
|
88
|
+
status;
|
|
89
|
+
/** Stable error key from molecule.dev, e.g. `broker.error.budgetExceeded`. */
|
|
90
|
+
errorKey;
|
|
91
|
+
/**
|
|
92
|
+
* Create the error.
|
|
93
|
+
*
|
|
94
|
+
* @param message - Human-readable message.
|
|
95
|
+
* @param status - HTTP status.
|
|
96
|
+
* @param errorKey - Stable error key, when the service sent one.
|
|
97
|
+
* @param cause - The underlying error, if any.
|
|
98
|
+
*/
|
|
99
|
+
constructor(message, status, errorKey, cause) {
|
|
100
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
101
|
+
this.name = 'MoleculeServiceError';
|
|
102
|
+
this.status = status;
|
|
103
|
+
this.errorKey = errorKey;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** What to tell the developer for each refusal the service can return. */
|
|
107
|
+
const HINTS = {
|
|
108
|
+
400: 'The subscription or payload was refused — check that `keys.p256dh`/`keys.auth` are the exact base64url values pushManager.subscribe() returned and that the endpoint URL is unchanged.',
|
|
109
|
+
401: 'Check MOLECULE_API_KEY: it must be a molecule project API key with the "broker" or "broker:push-notifications" scope, and not revoked.',
|
|
110
|
+
402: "The molecule project's owner has used the included allowance. Enable usage billing on molecule.dev, or bond another push provider.",
|
|
111
|
+
413: 'The serialized payload is too large (the limit is 3072 characters of JSON).',
|
|
112
|
+
429: 'Too many requests for this project right now. Slow down and retry.',
|
|
113
|
+
503: 'molecule.dev has paused this service briefly. Retry after the Retry-After delay.',
|
|
114
|
+
};
|
|
115
|
+
/** Validates a subscription locally, throwing before any request leaves the process. */
|
|
116
|
+
function assertValidSubscription(subscription) {
|
|
117
|
+
if (!subscription ||
|
|
118
|
+
typeof subscription !== 'object' ||
|
|
119
|
+
typeof subscription.endpoint !== 'string' ||
|
|
120
|
+
subscription.endpoint.length === 0) {
|
|
121
|
+
throw new MoleculeServiceError('The subscription needs an "endpoint" URL string (from pushManager.subscribe()).', 400, 'hostedServices.error.invalidInput');
|
|
122
|
+
}
|
|
123
|
+
if (subscription.endpoint.length > PUSH_SERVICE_LIMITS.maxEndpointChars) {
|
|
124
|
+
throw new MoleculeServiceError(`The subscription endpoint is ${subscription.endpoint.length} characters; the limit is ${PUSH_SERVICE_LIMITS.maxEndpointChars}.`, 413, 'hostedServices.error.inputTooLarge');
|
|
125
|
+
}
|
|
126
|
+
const keys = subscription.keys;
|
|
127
|
+
if (!keys ||
|
|
128
|
+
typeof keys.p256dh !== 'string' ||
|
|
129
|
+
keys.p256dh.length === 0 ||
|
|
130
|
+
typeof keys.auth !== 'string' ||
|
|
131
|
+
keys.auth.length === 0) {
|
|
132
|
+
throw new MoleculeServiceError('The subscription needs "keys.p256dh" and "keys.auth" (the base64url values pushManager.subscribe() returned).', 400, 'hostedServices.error.invalidInput');
|
|
133
|
+
}
|
|
134
|
+
if (keys.p256dh.length > PUSH_SERVICE_LIMITS.maxKeyChars ||
|
|
135
|
+
keys.auth.length > PUSH_SERVICE_LIMITS.maxKeyChars) {
|
|
136
|
+
throw new MoleculeServiceError(`The subscription keys are too long; the limit is ${PUSH_SERVICE_LIMITS.maxKeyChars} characters each.`, 413, 'hostedServices.error.inputTooLarge');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Validates a payload locally, throwing before any request leaves the process. */
|
|
140
|
+
function assertValidPayload(payload) {
|
|
141
|
+
if (!payload ||
|
|
142
|
+
typeof payload !== 'object' ||
|
|
143
|
+
typeof payload.title !== 'string' ||
|
|
144
|
+
payload.title.length === 0) {
|
|
145
|
+
throw new MoleculeServiceError('The payload needs a non-empty "title" string.', 400, 'hostedServices.error.invalidInput');
|
|
146
|
+
}
|
|
147
|
+
const serialized = JSON.stringify(payload);
|
|
148
|
+
if (serialized.length > PUSH_SERVICE_LIMITS.maxPayloadChars) {
|
|
149
|
+
throw new MoleculeServiceError(`The payload is ${serialized.length} characters serialized; the limit is ${PUSH_SERVICE_LIMITS.maxPayloadChars} (the Web Push protocol caps the encrypted payload at 4096 bytes).`, 413, 'hostedServices.error.inputTooLarge');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Push provider backed by molecule.dev's hosted service.
|
|
154
|
+
*/
|
|
155
|
+
export class MoleculePushProvider {
|
|
156
|
+
name = 'molecule';
|
|
157
|
+
apiKey;
|
|
158
|
+
servicesUrl;
|
|
159
|
+
timeoutMs;
|
|
160
|
+
cachedPublicKey;
|
|
161
|
+
/**
|
|
162
|
+
* Create the provider.
|
|
163
|
+
*
|
|
164
|
+
* @param config - Options; each falls back to its env var.
|
|
165
|
+
*/
|
|
166
|
+
constructor(config = {}) {
|
|
167
|
+
this.apiKey = config.apiKey ?? process.env.MOLECULE_API_KEY ?? '';
|
|
168
|
+
this.servicesUrl = resolveServicesUrl(config.servicesUrl ?? process.env.MOLECULE_SERVICES_URL ?? DEFAULT_SERVICES_URL);
|
|
169
|
+
this.timeoutMs = config.timeoutMs ?? 15_000;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Nothing to configure locally — molecule.dev holds the VAPID keys and
|
|
173
|
+
* signs every send. The parameter is accepted so the provider satisfies
|
|
174
|
+
* the core interface; a self-hosted setup should use
|
|
175
|
+
* `@molecule/api-push-notifications-web-push` instead.
|
|
176
|
+
*
|
|
177
|
+
* @param _config - Ignored.
|
|
178
|
+
*/
|
|
179
|
+
configure(_config) { }
|
|
180
|
+
/**
|
|
181
|
+
* Sends a push notification to a subscription endpoint.
|
|
182
|
+
*
|
|
183
|
+
* @param subscription - The push subscription (endpoint + keys).
|
|
184
|
+
* @param payload - The notification payload (title + display options).
|
|
185
|
+
* @returns The push service's answer: `statusCode` 201 means delivered;
|
|
186
|
+
* 404/410 mean the subscription is dead and should be pruned.
|
|
187
|
+
*/
|
|
188
|
+
async send(subscription, payload) {
|
|
189
|
+
assertValidSubscription(subscription);
|
|
190
|
+
assertValidPayload(payload);
|
|
191
|
+
return this.request('send', { subscription, payload });
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Sends a push notification to multiple subscriptions. One refused or
|
|
195
|
+
* failed subscription never aborts the batch — each entry carries either
|
|
196
|
+
* `result` or `error` (a dead subscription arrives as a `result` whose
|
|
197
|
+
* `statusCode` is 404/410; prune on it).
|
|
198
|
+
*
|
|
199
|
+
* @param subscriptions - The push subscriptions to send to.
|
|
200
|
+
* @param payload - The notification payload with title and optional display options.
|
|
201
|
+
* @returns One result entry per subscription.
|
|
202
|
+
*/
|
|
203
|
+
async sendMany(subscriptions, payload) {
|
|
204
|
+
const settled = await Promise.allSettled((subscriptions ?? []).map((subscription) => this.send(subscription, payload)));
|
|
205
|
+
return settled.map((outcome, i) => outcome.status === 'fulfilled'
|
|
206
|
+
? { subscription: subscriptions[i], result: outcome.value }
|
|
207
|
+
: { subscription: subscriptions[i], error: outcome.reason });
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Returns molecule.dev's public VAPID key — the `applicationServerKey` a
|
|
211
|
+
* browser's `pushManager.subscribe()` must be given for the resulting
|
|
212
|
+
* subscriptions to be sendable through molecule.dev.
|
|
213
|
+
*
|
|
214
|
+
* The core's method is SYNCHRONOUS while the key lives behind a service
|
|
215
|
+
* call, so this returns the cache: `undefined` until {@link fetchPublicKey}
|
|
216
|
+
* has run (or a send cached it). Await the fetch first:
|
|
217
|
+
*
|
|
218
|
+
* ```typescript
|
|
219
|
+
* await provider.fetchPublicKey() // once, e.g. at startup
|
|
220
|
+
* const applicationServerKey = provider.getPublicKey()
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @returns The cached public key, or `undefined` before the first fetch.
|
|
224
|
+
*/
|
|
225
|
+
getPublicKey() {
|
|
226
|
+
return this.cachedPublicKey;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Fetches molecule.dev's public VAPID key from the hosted service and
|
|
230
|
+
* caches it for {@link getPublicKey}.
|
|
231
|
+
*
|
|
232
|
+
* @returns The public key string.
|
|
233
|
+
*/
|
|
234
|
+
async fetchPublicKey() {
|
|
235
|
+
const { publicKey } = await this.request('vapid-key', {});
|
|
236
|
+
this.cachedPublicKey = publicKey;
|
|
237
|
+
return publicKey;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Not supported on the hosted path: sends are signed with molecule.dev's
|
|
241
|
+
* VAPID identity, and subscriptions are bound to the key they were created
|
|
242
|
+
* with — a locally generated pair could never receive a hosted send. Use
|
|
243
|
+
* `@molecule/api-push-notifications-web-push` (which serves your own keys)
|
|
244
|
+
* when you need your own identity.
|
|
245
|
+
*
|
|
246
|
+
* @throws {MoleculeServiceError} Always, with the self-hosted pointer.
|
|
247
|
+
*/
|
|
248
|
+
generateVapidKeys() {
|
|
249
|
+
throw new MoleculeServiceError("generateVapidKeys() is a self-hosted concern: the hosted service signs sends with molecule.dev's VAPID identity. Use @molecule/api-push-notifications-web-push to serve your own keys.", 400, 'hostedServices.error.invalidInput');
|
|
250
|
+
}
|
|
251
|
+
/** One POST to the hosted service. */
|
|
252
|
+
async request(operation, body) {
|
|
253
|
+
if (!this.apiKey) {
|
|
254
|
+
throw new MoleculeServiceError('MOLECULE_API_KEY is not set. Create a project API key on molecule.dev (or with `mlcl apikey create`) and put it in the API .env.', 401, 'hostedServices.error.tokenInvalid');
|
|
255
|
+
}
|
|
256
|
+
const response = await fetch(`${this.servicesUrl}/push/${operation}`, {
|
|
257
|
+
method: 'POST',
|
|
258
|
+
headers: { authorization: `Bearer ${this.apiKey}`, 'content-type': 'application/json' },
|
|
259
|
+
body: JSON.stringify(body),
|
|
260
|
+
signal: AbortSignal.timeout(this.timeoutMs),
|
|
261
|
+
});
|
|
262
|
+
const text = await response.text();
|
|
263
|
+
let data;
|
|
264
|
+
try {
|
|
265
|
+
data = text ? JSON.parse(text) : {};
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
// A proxy/gateway error page, not the service: report the status only.
|
|
269
|
+
throw new MoleculeServiceError(`molecule.dev returned ${response.status} with a non-JSON body.`, response.status, undefined, error);
|
|
270
|
+
}
|
|
271
|
+
if (!response.ok) {
|
|
272
|
+
const err = data;
|
|
273
|
+
const hint = HINTS[response.status];
|
|
274
|
+
throw new MoleculeServiceError(`molecule.dev push/${operation} failed (${response.status}): ${err.error ?? 'error'}${hint ? ` ${hint}` : ''}`, response.status, err.errorKey);
|
|
275
|
+
}
|
|
276
|
+
return data;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Create a hosted push notifications provider.
|
|
281
|
+
*
|
|
282
|
+
* @param config - Options; each falls back to its env var.
|
|
283
|
+
* @returns A `PushNotificationProvider` backed by molecule.dev.
|
|
284
|
+
*/
|
|
285
|
+
export function createProvider(config) {
|
|
286
|
+
return new MoleculePushProvider(config);
|
|
287
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* molecule.dev hosted push notifications secret definitions — self-registered
|
|
3
|
+
* at import time so the runtime secrets registry (`@molecule/api-secrets`) can
|
|
4
|
+
* drive boot-time configuration reports and actionable "not configured"
|
|
5
|
+
* errors.
|
|
6
|
+
*
|
|
7
|
+
* Content is derived MECHANICALLY from this package's mlcl registry secrets
|
|
8
|
+
* entry (label/instructions/setupUrl/example) via the fleet formula, so
|
|
9
|
+
* packages sharing a key register byte-identical definitions and
|
|
10
|
+
* registration order never matters.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { SecretDefinition } from '@molecule/api-secrets';
|
|
15
|
+
/** Secret definitions required by the molecule.dev hosted push bond. */
|
|
16
|
+
export declare const pushNotificationsMoleculeSecretDefinitions: SecretDefinition[];
|
|
17
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,wEAAwE;AACxE,eAAO,MAAM,0CAA0C,EAAE,gBAAgB,EASxE,CAAA"}
|
package/dist/secrets.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* molecule.dev hosted push notifications secret definitions — self-registered
|
|
3
|
+
* at import time so the runtime secrets registry (`@molecule/api-secrets`) can
|
|
4
|
+
* drive boot-time configuration reports and actionable "not configured"
|
|
5
|
+
* errors.
|
|
6
|
+
*
|
|
7
|
+
* Content is derived MECHANICALLY from this package's mlcl registry secrets
|
|
8
|
+
* entry (label/instructions/setupUrl/example) via the fleet formula, so
|
|
9
|
+
* packages sharing a key register byte-identical definitions and
|
|
10
|
+
* registration order never matters.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { registerSecrets } from '@molecule/api-secrets';
|
|
15
|
+
/** Secret definitions required by the molecule.dev hosted push bond. */
|
|
16
|
+
export const pushNotificationsMoleculeSecretDefinitions = [
|
|
17
|
+
{
|
|
18
|
+
key: 'MOLECULE_API_KEY',
|
|
19
|
+
description: 'molecule.dev project API key — Create one for your project with `mlcl apikey create --project <id> --name <name>` (keys start with mk_).',
|
|
20
|
+
helpUrl: 'https://www.molecule.dev',
|
|
21
|
+
required: true,
|
|
22
|
+
example: 'mk_...',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
registerSecrets(pushNotificationsMoleculeSecretDefinitions);
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for the molecule.dev hosted push notifications provider.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for {@link createProvider}. Every field falls back to an env var,
|
|
8
|
+
* so the zero-argument `provider` export works from `.env` alone.
|
|
9
|
+
*/
|
|
10
|
+
export interface MoleculePushConfig {
|
|
11
|
+
/**
|
|
12
|
+
* The molecule project API key (`mk_…`), or the sandbox token molecule.dev
|
|
13
|
+
* writes for in-IDE apps (`mbk_…`). Defaults to `MOLECULE_API_KEY`.
|
|
14
|
+
*/
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The hosted services base URL, without a trailing slash. Defaults to
|
|
18
|
+
* `MOLECULE_SERVICES_URL`, then `https://api.molecule.dev/api/v1/services`.
|
|
19
|
+
*/
|
|
20
|
+
servicesUrl?: string;
|
|
21
|
+
/** Per-request timeout in milliseconds. Default 15000. */
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}
|
|
24
|
+
/** Environment variables this provider reads. */
|
|
25
|
+
export interface ProcessEnv {
|
|
26
|
+
MOLECULE_API_KEY?: string;
|
|
27
|
+
MOLECULE_SERVICES_URL?: string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,iDAAiD;AACjD,MAAM,WAAW,UAAU;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B"}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-push-notifications-molecule",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "molecule.dev hosted push notifications provider — web push delivery through your molecule project, VAPID handled for you",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/api-push-notifications-molecule",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"test:watch": "vitest"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"molecule",
|
|
26
|
+
"push",
|
|
27
|
+
"notifications",
|
|
28
|
+
"web-push",
|
|
29
|
+
"hosted"
|
|
30
|
+
],
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
35
|
+
"directory": "packages/api/bonds/push-notifications/molecule"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@molecule/api-push-notifications": ">=1.0.2",
|
|
39
|
+
"@molecule/api-secrets": "^1.0.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@molecule/api-push-notifications": "1.0.2",
|
|
43
|
+
"@types/node": "26.1.2",
|
|
44
|
+
"typescript": "6.0.3",
|
|
45
|
+
"vitest": "4.1.11"
|
|
46
|
+
},
|
|
47
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|