@ix-xs/twitch.api 1.0.5 → 2.0.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,76 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@ix-xs/twitch.api` are documented here. This project
4
+ adheres to [Semantic Versioning](https://semver.org).
5
+
6
+ ## 2.0.1
7
+
8
+ ### Changed
9
+
10
+ - The package description, so that the npm page says the same thing as the
11
+ repository. No change to the code.
12
+
13
+ ## 2.0.0
14
+
15
+ A rewrite from scratch, in TypeScript. Version 1 covered 12 endpoints with an
16
+ app token. Version 2 covers the whole Twitch API, user tokens and EventSub.
17
+
18
+ ### Breaking
19
+
20
+ - The client is the named export `Twitch` and takes `clientId` and
21
+ `clientSecret`. Version 1 documented those names but read `client_id` and
22
+ `client_secret`.
23
+ - `initialize()` is gone. Tokens are requested when a call needs them.
24
+ - Methods throw typed errors (`TwitchApiError`, `TwitchAuthError`...) instead
25
+ of returning `{ ok, result }`.
26
+ - Methods are grouped (`twitch.users.get`, `twitch.streams.get`...) and take
27
+ IDs, like the Twitch API. The README has the full mapping from version 1.
28
+ - Node.js 22 or later is required.
29
+
30
+ ### Added
31
+
32
+ - **Every Helix endpoint**: 149 endpoints in 30 groups, with typed parameters
33
+ and responses, an example and a link to the official reference on each method.
34
+ - **Every EventSub subscription type**: 83 typed conditions and events, with
35
+ discriminated unions for the events that come in several shapes
36
+ (`channel.chat.notification`, `channel.moderate`, `channel.bits.use`...).
37
+ - **EventSub listeners** for WebSocket, webhooks and conduits behind one typed
38
+ `on()`: automatic reconnection and resubscription, Twitch's reconnect
39
+ handover, keepalive watchdog, signature verification, replay and duplicate
40
+ protection. Webhooks plug into Fetch API runtimes and Node.js servers.
41
+ - **User tokens**: authorization code flow, device code flow, automatic
42
+ refresh, hourly validation, revocation, and a pluggable `TokenStore`
43
+ (`FileTokenStore` in `@ix-xs/twitch.api/node`).
44
+ - **Automatic choice of token**: each endpoint knows whether it needs the app
45
+ token or a user's, and whose. The acting user (`moderator_id`,
46
+ `broadcaster_id`, `sender_id`...) defaults to the owner of the token. `{ as }`
47
+ and `twitch.as()` choose a user explicitly, and `"app"` asks for the app
48
+ token.
49
+ - **Scope checks before the request**, with the missing scope in the error.
50
+ - **Pagination helpers**: `await` for a page, `for await` for every item,
51
+ `all()`, `take()`, `first()`, `total()`.
52
+ - **Batching**: ID lists longer than Twitch's cap are split and fetched in
53
+ parallel, and single lookups made at the same moment are merged into one
54
+ request.
55
+ - **Rate limit handling**: per token buckets followed from the response
56
+ headers, waiting instead of failing, retries with backoff for what is safe
57
+ to retry, timeouts and `AbortSignal` support.
58
+ - **Typed errors**: `TwitchApiError`, `TwitchRateLimitError`,
59
+ `TwitchAuthError`, `TwitchScopeError`, `TwitchTimeoutError`,
60
+ `TwitchNetworkError` and `TwitchEventSubError`, all extending `TwitchError`.
61
+ - `twitch.request()` and `twitch.paginate()` for endpoints newer than the
62
+ library, and `request`, `response`, `rateLimit`, `tokenRefresh` and
63
+ `tokenInvalid` events.
64
+ - ESM and CommonJS builds with type declarations for both.
65
+
66
+ ### Fixed
67
+
68
+ - The token is no longer written inside `node_modules`, which broke on
69
+ read-only file systems, with pnpm, in monorepos and on every reinstall.
70
+ - The client secret is sent in the request body, not in the URL.
71
+ - Query values are URL encoded.
72
+ - The validation timer no longer keeps the process alive.
73
+
74
+ ### Removed
75
+
76
+ - Dependencies: there are none.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ix-xs.dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.