{"_id":"@emergentinteractive/esports-sdk","name":"@emergentinteractive/esports-sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@emergentinteractive/esports-sdk","version":"0.1.0","description":"Typed client and webhook utilities for the Emergent Interactive eSports API.","license":"MIT","homepage":"https://esports.emergentinteractive.com/developers/sdk","repository":{"type":"git","url":"git+https://github.com/emergentinteractive/esports-sdk.git"},"bugs":{"url":"https://github.com/emergentinteractive/esports-sdk/issues"},"type":"module","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./webhooks":{"types":"./dist/webhooks.d.ts","import":"./dist/webhooks.js"}},"scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc -p tsconfig.json --noEmit","test":"vitest run --config vitest.config.ts","prepack":"npm run build && npm test"},"engines":{"node":">=20"},"publishConfig":{"access":"public"},"devDependencies":{"typescript":"^5.7.2","vitest":"^4.0.0"},"_id":"@emergentinteractive/esports-sdk@0.1.0","gitHead":"649fae3590244b5f7bc616f361f5ed5d08403185","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-ZBQheYH/moUErrVDSmhRXcMRFOACgV/uIg3lLYwwrt+LHEpc1lTlXC5wO1/OekPSBAftqOEurw7z2qYqTr/Z0w==","shasum":"d7934f2ec9ab3f4460af6f5fb0965b33b654290c","tarball":"https://registry.npmjs.org/@emergentinteractive/esports-sdk/-/esports-sdk-0.1.0.tgz","fileCount":19,"unpackedSize":112239,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCewDXSlSIAJ7gbOFR4NNRZCAP9rcotMr+18Zj8DnWfDQIhAKnNQS7VRBiL3Xll47LFKwYP8dfmatWBb0OVwyrd/iGd"}]},"_npmUser":{"name":"emergent-interactive","email":"general@emergentinteractive.com"},"directories":{},"maintainers":[{"name":"emergent-interactive","email":"general@emergentinteractive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/esports-sdk_0.1.0_1786123574005_0.0011732036223295328"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-07T17:26:13.864Z","0.1.0":"2026-08-07T17:26:14.163Z","modified":"2026-08-07T17:26:14.444Z"},"maintainers":[{"name":"emergent-interactive","email":"general@emergentinteractive.com"}],"description":"Typed client and webhook utilities for the Emergent Interactive eSports API.","homepage":"https://esports.emergentinteractive.com/developers/sdk","repository":{"type":"git","url":"git+https://github.com/emergentinteractive/esports-sdk.git"},"bugs":{"url":"https://github.com/emergentinteractive/esports-sdk/issues"},"license":"MIT","readme":"# `@emergentinteractive/esports-sdk`\n\nTyped, dependency-free helpers for Emergent Interactive eSports. Browser flows require a player-approved redirect token; long-lived developer credentials must remain on a trusted server.\n\n```ts\nimport {\n    EsportsClient,\n    verifyWebhookSignature,\n} from '@emergentinteractive/esports-sdk';\n\nconst esports = new EsportsClient({\n    csrfToken: document.querySelector('meta[name=\"csrf-token\"]')?.content,\n});\nconst games = await esports.listGames();\n\nconst verified = await verifyWebhookSignature(\n    rawBody,\n    signatureHeader,\n    webhookSecret,\n);\n```\n\nBrowser mutations use the Emergent Accounts session cookie and a CSRF token. Approved server integrations can additionally supply their scoped API credential when production access is provisioned. Mutating API calls require an `idempotencyKey`. Verify webhooks against the exact raw request bytes before parsing JSON, reject signatures outside the replay window, and persist each event ID before processing it.\n\nTournament-control helpers require an authenticated Emergent Accounts cookie plus `csrfToken`; a developer `apiKey` is deliberately ignored for those calls and cannot impersonate an organiser, referee, broadcaster, or player. Invitation creation never enrols the target. A player may instead approve a five-minute enrolment token for one reviewed game and competition; server redemption then performs the same canonical eligibility, team, registration, and capacity checks and returns the resulting entry ID/status. Omitting `competition_id` keeps the token authorization-only. Public competition retrieval uses `listCompetitions`, `getCompetition`, and `watchCompetition`. Server credentials are limited to enrolment redemption, fixtures, match-token issuance, and authoritative match results.\n\n## Browser tournament lifecycle\n\nEach call acts as the person currently signed in through Accounts. Keep organiser and player actions in their respective sessions; the example IDs come from the canonical competition snapshot.\n\n```ts\nconst browserEsports = new EsportsClient({\n    csrfToken: document.querySelector<HTMLMetaElement>(\n        'meta[name=\"csrf-token\"]',\n    )?.content,\n});\n\nawait browserEsports.openCompetitionRegistration('community-cup');\nawait browserEsports.updateCompetitionAutomation('community-cup', {\n    enabled: true,\n    open_registration: false,\n    open_check_in: true,\n    finalize_check_in: true,\n    send_reminders: true,\n    create_review_tasks: true,\n});\nawait browserEsports.approveCompetitionEntry(entryId);\nawait browserEsports.openCompetitionCheckIn('community-cup');\nawait browserEsports.finalizeCompetitionCheckIn('community-cup');\nawait browserEsports.defineCompetitionSeeding(stageId, orderedEntryIds, {\n    idempotencyKey: 'community-cup-seeding-v1',\n});\nawait browserEsports.generateCompetitionStage(stageId);\n\nawait browserEsports.scheduleCompetitionMatch(matchId, {\n    scheduled_at: '2026-09-01T19:00:00Z',\n});\nawait browserEsports.createCompetitionLivestream('community-cup', {\n    source: 'https://www.twitch.tv/videos/123456789',\n    label: 'Final replay',\n    is_primary: true,\n});\n```\n\nPlayers use `createEntry`, `checkInCompetitionEntry`, `submitMatchLineup`, `submitMatchResult`, and `confirmMatchResult`. Independent staff can use `resolveMatchDispute`, `uploadMatchEvidence`, `extractMatchEvidence`, and `approveMatchEvidenceExtraction`; extraction is advisory and cannot finalise a result. Presentation helpers create and remove structured sponsors, Twitch channels or videos, and notices. The OpenAPI contract identifies the mutations that require `Idempotency-Key`; the SDK requires that key only for those operations.\n\nApproved production games are merged into the public game-capability catalogue and become selectable for tournament creation. Sandbox and pending/rejected games remain excluded. Match-token requests may select a lifetime from 60 through 900 seconds; the service preserves that requested lifetime. Sandbox fixtures, their nested match/result/webhook examples, and sandbox match tokens all carry `authoritative: false`. Sandbox result receipts are simulations with no submission ID. Production match tokens and receipts are authoritative only after the reviewed game server creates a real tournament submission.\n\n`reconcileChessComMatch` lets authorised tournament staff compare a canonical Chess.com live or daily game URL with the cached PubAPI monthly archive. It records `provider_advisory` evidence only: the method never advances, finalises, or decides a match.\n\n`watchCompetition` provides the version-aware fallback subscription. It conditionally refetches the canonical ETag-backed snapshot, ignores duplicate versions, and marks version gaps so consumers never reconstruct missed state from partial events. Applications using Reverb can trigger an immediate canonical refetch when a public-version event arrives; polling remains available when WebSockets are blocked.\n\nEvery public stage snapshot includes its own immutable `game_slug` and stage-specific `best_of`. Version 1 still creates exactly one stage and keeps the parent competition’s `game` as its primary discovery field. Integrations should bind match tokens, results, and provider events to the stage game so they remain correct when multi-stage circuits are enabled later.\n\nThe initial `0.1.0` package is token-published without forced provenance. Enable npm trusted publishing and provenance only after the public GitLab project has a GitLab.com shared-runner publish job with an OIDC `id_tokens` block and npm’s trusted-publisher mapping.\n\n## Development\n\n```sh\nnpm run typecheck\nnpm test\nnpm run build\n```\n\nLicensed under MIT.\n","readmeFilename":"README.md","_rev":"1-328ea33d4d99d6129cf7522a0da491ac"}