@dancing-ninjas/project-euler-helper-kit
v1.2.0
Published
Dancing Ninjas Project Euler helpers + constrained telemetry strategies compatible with npmjs.org-only egress.
Maintainers
Readme
@dancing-ninjas/project-euler-helper-kit
Math helpers & a tiny CLI for Project Euler–style problems, tailored for Dancing Ninjas, plus telemetry strategies that work under npmjs.org‑only egress.
⚠️ Exact per‑download timestamps from the public npm registry are only available from logs at the network boundary (e.g., your corporate proxy/firewall) because package code runs after download. This kit includes a parser to extract those timestamps from your own logs. A secondary (install‑time) signal uses a single GET to
registry.npmjs.orgso it also complies with your constraint.
Quick start (helpers & CLI)
npm i
npm run build
npx ./bin/euler-cli.js list
npx ./bin/euler-cli.js prime 1000003
npx ./bin/euler-cli.js nCr 40 20Telemetry under npmjs.org‑only constraint
You have two complementary strategies:
1) Primary (recommended): parse your proxy logs → exact download timestamps
Your proxy/egress firewall already logs requests to registry.npmjs.org. Every tarball download
hits a path like:
/@dancing-ninjas%2Fproject-euler-helper-kit/-/project-euler-helper-kit-1.0.0.tgzUse the included script to convert those log lines into normalized NDJSON events.
Example (Nginx‑style access logs):
node scripts/npmjs-proxy-logs-to-events.mjs --in /var/log/proxy/access.log --out telemetry/events.ndjson --pkg @dancing-ninjas/project-euler-helper-kitEach event:
{{"kind":"download","at":"2025-09-04T12:34:56Z","pkg":"@dancing-ninjas/project-euler-helper-kit","http":{{"path":"/@dancing-ninjas%2Fproject-euler-helper-kit/-/project-euler-helper-kit-1.0.0.tgz","status":200,"ua":"npm/10 node/v20 ..."}}}}2) Optional (install‑time) signal to npmjs.org
Enable a small postinstall script that performs one GET to
https://registry.npmjs.org/-/ping?dn_sig=<base64url> and also appends the
same signal to the User‑Agent. Your proxy logs will capture the timestamp.
Enable by setting:
export DN_TELEMETRY_MODE=npm-ping # off by default
npm i @dancing-ninjas/[email protected]The signal is compact and includes: {{ pkg, version, at, node, platform, arch, projectHash }}.
No external endpoints other than npmjs.org are contacted. Network errors are ignored and
the install never fails because of telemetry.
This captures install time (very close to download in practice), not the exact download moment.
Library API (snapshot)
import {{
isPrime, primesUpTo, primeFactors,
gcd, lcm, modPow, modInverse,
factorialBig, nCrBig,
divisors, properDivisors,
permutations, combinations,
fibonacciBig, sumDigits, digits, isPalindrome, collatzLength
}} from '@dancing-ninjas/project-euler-helper-kit';Security & privacy
- Telemetry is off by default. Opt in by setting
DN_TELEMETRY_MODE=npm-ping. - No PII is sent; only a hash of the project path (
projectHash) is included. - The request goes to
registry.npmjs.organd is intended purely for your own proxy logs. - For exact download times, rely on your proxy logs (strategy 1).
License
MIT © Dancing Ninjas
