@storylinkpro/instagram-stories-api 0.1.1 → 0.1.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+
5
+ - The client sends the access token in the `Authorization` header, not in the URL. Proxy and server logs no longer record it. The client also removes the token from the `paging.next` URLs that Meta returns.
6
+ - The timeout now works on Node 20.0 to 20.2 when you pass your own `signal`.
7
+ - The publish workflow runs the dev dependencies in a job that cannot get an npm token.
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  - The package description, keywords and README make the package easier to find.
package/dist/client.js CHANGED
@@ -67,11 +67,23 @@ function metricValues(body) {
67
67
  }
68
68
  return out;
69
69
  }
70
+ /** Aborts when either signal aborts. `AbortSignal.any` needs Node 20.3+, so
71
+ * older runtimes link the two by hand and keep the timeout. */
70
72
  function combineSignals(a, b) {
71
73
  if (!a)
72
74
  return b;
73
75
  const any = AbortSignal.any;
74
- return any ? any([a, b]) : a;
76
+ if (any)
77
+ return any([a, b]);
78
+ const ctrl = new AbortController();
79
+ for (const s of [a, b]) {
80
+ if (s.aborted) {
81
+ ctrl.abort(s.reason);
82
+ return ctrl.signal;
83
+ }
84
+ s.addEventListener("abort", () => ctrl.abort(s.reason), { once: true });
85
+ }
86
+ return ctrl.signal;
75
87
  }
76
88
  export function createClient(options) {
77
89
  if (!options || typeof options.accessToken !== "string" || options.accessToken.length === 0) {
@@ -91,13 +103,15 @@ export function createClient(options) {
91
103
  let lastUsage = null;
92
104
  const userId = (o) => checkId(o?.igUserId ?? options.igUserId, "igUserId");
93
105
  async function call(url, signal) {
94
- url.searchParams.set("access_token", token);
106
+ // The token goes in a header, not the query string, so it stays out of
107
+ // proxy and server logs. Meta adds it to `paging.next` URLs: remove it.
108
+ url.searchParams.delete("access_token");
95
109
  const path = url.pathname;
96
110
  let res;
97
111
  try {
98
112
  res = await doFetch(url.toString(), {
99
113
  method: "GET",
100
- headers: { accept: "application/json" },
114
+ headers: { accept: "application/json", authorization: `Bearer ${token}` },
101
115
  signal: combineSignals(signal, AbortSignal.timeout(timeoutMs)),
102
116
  });
103
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storylinkpro/instagram-stories-api",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Instagram Graph API client and CLI for Node.js and TypeScript: read Instagram Stories, posts, reels and their insights (views, reach, replies, likes, saves, shares). Typed, zero dependencies.",
5
5
  "keywords": [
6
6
  "instagram",