{"_id":"@daeuk1011/google-news-url-decoder","_rev":"3-9a32284da2e5430cecbe45e8f9e80dcb","name":"@daeuk1011/google-news-url-decoder","dist-tags":{"latest":"0.2.2"},"versions":{"0.2.0":{"name":"@daeuk1011/google-news-url-decoder","version":"0.2.0","license":"MIT","_id":"@daeuk1011/google-news-url-decoder@0.2.0","maintainers":[{"name":"daeuk1011","email":"skfvkfl1011@gmail.com"}],"homepage":"https://github.com/daeuk1011/google-news-url-decoder-rs#readme","bugs":{"url":"https://github.com/daeuk1011/google-news-url-decoder-rs/issues"},"dist":{"shasum":"009e2aeeb6a2c26f758744a544893dc1366e8741","tarball":"https://registry.npmjs.org/@daeuk1011/google-news-url-decoder/-/google-news-url-decoder-0.2.0.tgz","fileCount":15,"integrity":"sha512-RRriJ1fVqAIUQcLlJXblMOUoI4jdTRa76/FxJkvvxHA6TDh6uQsdYXBFkZhxqxehUPS8z7Su4lU/sSwI90kk4Q==","signatures":[{"sig":"MEYCIQCqNRT2miiVuKJp0ztWIIevh3GqQrOQ8lFZ++WoTU4VzAIhAL0CDimGNsh68wJfdcTd3BjMpfuuYAXmufWyMP4Bc/u+","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":651402},"main":"./index.mjs","type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./index.d.ts","default":"./index.mjs","workerd":"./index.workerd.mjs"}},"gitHead":"88610c7376c5021de2dd94351e2cbed9f0551dad","scripts":{"test":"npm run test:unit && npm run build && npm run test:int","build":"npm run build:bundler && npm run build:node","test:e2e":"RUN_E2E=1 node --test test/e2e.test.mjs","test:int":"node --test test/decode.test.mjs test/batch.test.mjs","test:unit":"cargo test","build:node":"wasm-pack build --target nodejs --release --out-dir pkg-node","build:bundler":"wasm-pack build --target bundler --release --out-dir pkg"},"_npmUser":{"name":"daeuk1011","email":"skfvkfl1011@gmail.com"},"repository":{"url":"git+https://github.com/daeuk1011/google-news-url-decoder-rs.git","type":"git"},"_npmVersion":"11.6.2","description":"Decode Google News article share URLs to their original article URL.","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/google-news-url-decoder_0.2.0_1780050206590_0.4154846099050655","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@daeuk1011/google-news-url-decoder","version":"0.2.1","license":"MIT","_id":"@daeuk1011/google-news-url-decoder@0.2.1","maintainers":[{"name":"daeuk1011","email":"skfvkfl1011@gmail.com"}],"homepage":"https://github.com/daeuk1011/google-news-url-decoder-rs#readme","bugs":{"url":"https://github.com/daeuk1011/google-news-url-decoder-rs/issues"},"dist":{"shasum":"64e31e8459be90b807bbd560e0eec83fbbf1c03a","tarball":"https://registry.npmjs.org/@daeuk1011/google-news-url-decoder/-/google-news-url-decoder-0.2.1.tgz","fileCount":15,"integrity":"sha512-QP8La6U4VwWvzJHSzByP465asBRKtF9mnhO6YAIYmhgOAiTWlu1AOt1gJAa6vABB0wkbQ44J0NvIFflL8OH/VA==","signatures":[{"sig":"MEUCIQDL0k8n1p0qOc8SNxm+mciptonGUqHWk9YCGdmdyW38HgIgHnZxVcbf/ehTx5c7fUDZkJp3+SnzH3nL2NchUpGSiNc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":278940},"main":"./index.mjs","type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./index.d.ts","default":"./index.mjs","workerd":"./index.workerd.mjs"}},"gitHead":"e0c8b4bb30961ffb2307b459d334ad5f032c5e76","scripts":{"test":"npm run test:unit && npm run build && npm run test:int","build":"npm run build:bundler && npm run build:node","test:e2e":"RUN_E2E=1 node --test test/e2e.test.mjs","test:int":"node --test test/decode.test.mjs test/batch.test.mjs","test:unit":"cargo test","build:node":"wasm-pack build --target nodejs --release --out-dir pkg-node","build:bundler":"wasm-pack build --target bundler --release --out-dir pkg"},"_npmUser":{"name":"daeuk1011","email":"skfvkfl1011@gmail.com"},"repository":{"url":"git+https://github.com/daeuk1011/google-news-url-decoder-rs.git","type":"git"},"_npmVersion":"11.6.2","description":"Decode Google News article share URLs to their original article URL.","directories":{},"_nodeVersion":"24.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/google-news-url-decoder_0.2.1_1780051656750_0.2054732940499262","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@daeuk1011/google-news-url-decoder","version":"0.2.2","publishConfig":{"access":"public"},"description":"Decode Google News article share URLs to their original article URL.","type":"module","main":"./index.mjs","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","workerd":"./index.workerd.mjs","default":"./index.mjs"}},"scripts":{"build:bundler":"wasm-pack build --target bundler --release --out-dir pkg","build:node":"wasm-pack build --target nodejs --release --out-dir pkg-node","build":"npm run build:bundler && npm run build:node","test:unit":"cargo test","test:int":"node --test test/decode.test.mjs test/batch.test.mjs","test:e2e":"RUN_E2E=1 node --test test/e2e.test.mjs","test":"npm run test:unit && npm run build && npm run test:int"},"engines":{"node":">=18"},"repository":{"type":"git","url":"git+https://github.com/daeuk1011/google-news-url-decoder-rs.git"},"license":"MIT","gitHead":"bb288354b3dc6215d08f304802964301e34c1b28","_id":"@daeuk1011/google-news-url-decoder@0.2.2","bugs":{"url":"https://github.com/daeuk1011/google-news-url-decoder-rs/issues"},"homepage":"https://github.com/daeuk1011/google-news-url-decoder-rs#readme","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-7uV7KpNA49DixgQlv3N26IhXikQPlW7yx/YcWbGY4/MA88yDtJU4Bokoiw/cnmWj08pQPSb0k1DLE4PL/cdVBQ==","shasum":"9a0cc307c183c2dcd079baa0e9cfe19f4d1b9a81","tarball":"https://registry.npmjs.org/@daeuk1011/google-news-url-decoder/-/google-news-url-decoder-0.2.2.tgz","fileCount":17,"unpackedSize":281825,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCID1wzjCdv+zt9R+GRKlHBaHucaH+Ha75IVxWUdCsgZ0FAiEA9MKtr4ea4Y08D+v0Wf6pqiD6gfks+jgnwBD3bAcRnPQ="}]},"_npmUser":{"name":"daeuk1011","email":"skfvkfl1011@gmail.com"},"directories":{},"maintainers":[{"name":"daeuk1011","email":"skfvkfl1011@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/google-news-url-decoder_0.2.2_1780059253346_0.20489289551356138"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-29T10:23:26.392Z","modified":"2026-05-29T12:54:13.707Z","0.2.0":"2026-05-29T10:23:26.795Z","0.2.1":"2026-05-29T10:47:36.917Z","0.2.2":"2026-05-29T12:54:13.511Z"},"bugs":{"url":"https://github.com/daeuk1011/google-news-url-decoder-rs/issues"},"license":"MIT","homepage":"https://github.com/daeuk1011/google-news-url-decoder-rs#readme","repository":{"type":"git","url":"git+https://github.com/daeuk1011/google-news-url-decoder-rs.git"},"description":"Decode Google News article share URLs to their original article URL.","maintainers":[{"name":"daeuk1011","email":"skfvkfl1011@gmail.com"}],"readme":"# google-news-url-decoder\n\nDecode Google News article share URLs to their original article URL. Rust core, WebAssembly distribution.\n\nPorted from [SSujitX/google-news-url-decoder](https://github.com/SSujitX/google-news-url-decoder) (Python).\n\n## Install\n\n```sh\nnpm install @daeuk1011/google-news-url-decoder\n```\n\nRequires a JS runtime with global `fetch`: Node.js 18+, Cloudflare Workers, Deno, Bun.\n\n> **Browser is not supported.** `news.google.com` does not return CORS headers to third-party origins. Use this library from a server, Worker, or extension context instead.\n\n## Usage\n\n```js\nimport { decode, DecodeError } from \"@daeuk1011/google-news-url-decoder\";\n\ntry {\n  const url = await decode(\"https://news.google.com/articles/CBMi...\");\n  console.log(url);\n} catch (err) {\n  if (err instanceof DecodeError) {\n    console.error(err.kind, err.message);\n  }\n}\n```\n\n## Decoding many URLs\n\n`decodeBatch` decodes a list of URLs and collapses the final decode step into batched\n`batchexecute` POSTs — one request per `batchSize` URLs instead of one per URL. This\nsharply cuts the request volume on the rate-limited endpoint. Per-URL failures are\nisolated: results are returned in input order, each either `{ url, decoded }` or\n`{ url, error }`.\n\n```js\nimport { decodeBatch } from \"@daeuk1011/google-news-url-decoder\";\n\nconst results = await decodeBatch(urls, { batchSize: 50, concurrency: 20 });\n\nfor (const r of results) {\n  if (r.decoded) console.log(r.decoded);\n  else console.error(r.url, r.error.kind);\n}\n```\n\n> A per-article params GET is still required for each URL (the signature is per-article),\n> so at scale you still want a rotating proxy pool — batching only reduces the POST volume.\n\n## Options\n\n```ts\ndecode(url, {\n  fetch,    // custom fetch implementation (default: globalThis.fetch)\n  headers,  // extra headers (merged over default User-Agent)\n  signal,   // AbortSignal forwarded to every fetch call\n});\n\ndecodeBatch(urls, {\n  fetch, headers, signal,  // same as decode\n  batchSize,  // URLs per batchexecute POST (default 50; server tolerates 150+)\n  concurrency, // max concurrent param GETs in flight (default 20)\n});\n```\n\n### Using a proxy (Node.js)\n\n```js\nimport { fetch as undiciFetch, ProxyAgent } from \"undici\";\nconst dispatcher = new ProxyAgent(\"http://user:pass@host:8080\");\nconst fetch = (url, init) => undiciFetch(url, { ...init, dispatcher });\n\nconst decoded = await decode(googleUrl, { fetch });\n```\n\n## Error model\n\nAll failures throw `DecodeError`. Branch on `err.kind`:\n\n| `kind` | Cause |\n|---|---|\n| `invalid-url` | Input is not a recognized Google News article URL. |\n| `fetch-failed` | A `fetch` call rejected, returned a non-2xx status, or its body could not be read. |\n| `rate-limited` | Google throttled the request (HTTP 429 or a redirect to its `/sorry/` abuse page). Back off and retry, ideally from a different IP. |\n| `params-missing` | Google returned HTML without the expected `data-n-a-sg` / `data-n-a-ts` attributes. |\n| `parse-failed` | The `batchexecute` response did not match the expected nested-JSON shape (likely an upstream format change). |\n\n## Runtime support\n\n| Runtime | Supported | Notes |\n|---|---|---|\n| Node.js 18+ | ✅ | Uses global `fetch`. |\n| Cloudflare Workers | ✅ | See `examples/workers.ts`. |\n| Deno | ✅ | |\n| Bun | ✅ | |\n| Browser | ❌ | CORS blocks direct calls to `news.google.com`. |\n\n## License\n\nMIT.\n","readmeFilename":"README.md"}