@meshwhisper/service-worker 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +29 -0
  2. package/package.json +8 -3
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @meshwhisper/service-worker
2
+
3
+ Web Push service worker for [MeshWhisper](https://github.com/twotwoonethree/meshwhisper) PWAs. Receives the content-free wake signal sent by [`@meshwhisper/push-service`](https://www.npmjs.com/package/@meshwhisper/push-service), shows a notification, and routes clicks back into your app — where the SDK pulls and decrypts the actual message.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @meshwhisper/service-worker
9
+ cp node_modules/@meshwhisper/service-worker/dist/meshwhisper-sw.js public/
10
+ ```
11
+
12
+ The worker must be served from your domain **root** (`https://myapp.com/meshwhisper-sw.js`). Register it and subscribe before initializing the SDK:
13
+
14
+ ```ts
15
+ const registration = await navigator.serviceWorker.register('/meshwhisper-sw.js');
16
+ const subscription = await registration.pushManager.subscribe({
17
+ userVisibleOnly: true,
18
+ applicationServerKey: vapidPublicKeyBytes,
19
+ });
20
+
21
+ await MeshWhisper.init({
22
+ // ...
23
+ push: { platform: 'webpush', subscription: subscription.toJSON() },
24
+ });
25
+ ```
26
+
27
+ The full wiring is generated for you by `npx @meshwhisper/cli init` (browser/PWA option) and walked through in the [getting-started guide](https://github.com/twotwoonethree/meshwhisper/blob/main/docs/getting-started.md).
28
+
29
+ MIT
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@meshwhisper/service-worker",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MeshWhisper service worker — handles Web Push wake events for PWAs",
5
5
  "type": "module",
6
6
  "main": "dist/meshwhisper-sw.js",
7
- "files": ["dist", "src"],
8
- "publishConfig": { "access": "public" },
7
+ "files": [
8
+ "dist",
9
+ "src"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
9
14
  "scripts": {
10
15
  "prepublishOnly": "npm run build",
11
16
  "build": "esbuild src/index.ts --bundle --platform=browser --outfile=dist/meshwhisper-sw.js --format=iife"