xnotif 0.1.0 → 0.1.1-beta.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.
Files changed (2) hide show
  1. package/README.md +91 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # xnotif
2
+
3
+ [![npm](https://img.shields.io/npm/v/xnotif)](https://www.npmjs.com/package/xnotif)
4
+ [![CI](https://github.com/yutakobayashidev/xnotif/actions/workflows/ci.yml/badge.svg)](https://github.com/yutakobayashidev/xnotif/actions/workflows/ci.yml)
5
+
6
+ Receive Twitter/X notifications in real-time. No API key, no scraping — just Web Push.
7
+
8
+ ```typescript
9
+ import { createClient } from "xnotif";
10
+
11
+ const client = createClient({
12
+ cookies: { auth_token: "...", ct0: "..." },
13
+ });
14
+
15
+ client.on("notification", (n) => {
16
+ console.log(`${n.title}: ${n.body}`);
17
+ });
18
+
19
+ await client.start();
20
+ ```
21
+
22
+ ## How It Works
23
+
24
+ ```
25
+ Twitter ──▶ Mozilla Autopush (WebSocket) ──▶ AESGCM decrypt ──▶ EventEmitter
26
+ ```
27
+
28
+ xnotif generates an ECDH key pair, registers it with Twitter's push endpoint using your session cookies, then listens on Mozilla's Autopush WebSocket. Incoming notifications are decrypted and emitted as typed events.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ bun add xnotif
34
+ ```
35
+
36
+ > Requires Bun >= 1.0.0
37
+
38
+ ## Getting Cookies
39
+
40
+ 1. Log in to [x.com](https://x.com)
41
+ 2. DevTools → Application → Cookies
42
+ 3. Copy `auth_token` and `ct0`
43
+
44
+ ## State Persistence
45
+
46
+ Save the `ClientState` from the `connected` event to skip key generation on restart:
47
+
48
+ ```typescript
49
+ import { createClient, type ClientState } from "xnotif";
50
+
51
+ let state: ClientState | undefined = loadFromDisk(); // your persistence
52
+
53
+ const client = createClient({ cookies: { auth_token: "...", ct0: "..." }, state });
54
+
55
+ client.on("connected", (s) => saveToDisk(s));
56
+
57
+ await client.start();
58
+ ```
59
+
60
+ ## API
61
+
62
+ ### `createClient(options)`
63
+
64
+ | Option | Type | Required | Description |
65
+ | --------- | ------------------------------------- | -------- | ---------------------- |
66
+ | `cookies` | `{ auth_token: string; ct0: string }` | Yes | Session cookies |
67
+ | `state` | `ClientState` | No | Restore previous state |
68
+
69
+ ### Events
70
+
71
+ | Event | Payload | Description |
72
+ | -------------- | --------------------- | ------------------------------ |
73
+ | `notification` | `TwitterNotification` | Decrypted notification |
74
+ | `connected` | `ClientState` | Connected — persist this state |
75
+ | `error` | `Error` | Error (connection continues) |
76
+ | `disconnected` | — | WebSocket closed |
77
+ | `reconnecting` | `number` | Reconnecting in N ms |
78
+
79
+ ### Methods
80
+
81
+ - **`client.start()`** — Connect and begin receiving notifications
82
+ - **`client.stop()`** — Disconnect
83
+
84
+ ### Low-level Exports
85
+
86
+ - `Decryptor` — AESGCM Web Push decryption (ECDH + HKDF + AES-128-GCM)
87
+ - `AutopushClient` — Mozilla Autopush WebSocket client
88
+
89
+ ## License
90
+
91
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xnotif",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-beta.0",
4
4
  "description": "Receive Twitter/X push notifications programmatically via Mozilla Autopush",
5
5
  "keywords": [
6
6
  "autopush",
@@ -19,7 +19,8 @@
19
19
  "url": "https://github.com/yutakobayashidev/xnotif"
20
20
  },
21
21
  "files": [
22
- "dist"
22
+ "dist",
23
+ "README.md"
23
24
  ],
24
25
  "type": "module",
25
26
  "types": "./dist/index.d.ts",