{"_id":"@cogcoin/indexer","_rev":"3-72f135e0cdc27af38b3046d1ff8d1797","name":"@cogcoin/indexer","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@cogcoin/indexer","version":"1.0.0","keywords":["cogcoin","coglex","cogtoshi","bitcoin","indexer","state-machine","history","protocol"],"license":"MIT","_id":"@cogcoin/indexer@1.0.0","maintainers":[{"name":"cogcoindev","email":"dev@cogcoin.org"}],"homepage":"https://cogcoin.org","bugs":{"url":"https://github.com/cogcoin/indexer/issues"},"dist":{"shasum":"f3993b35d0b7c1f08a0dbeab3946aef2e153620b","tarball":"https://registry.npmjs.org/@cogcoin/indexer/-/indexer-1.0.0.tgz","fileCount":123,"integrity":"sha512-CZ2jeMR1KMquOyc/YBrnYewLMyDZLC+waa2bYums3Ib3/ofxGo+/ahWqk1Fh//KSdtNkoCgk/57bxtfwYxr4Ng==","signatures":[{"sig":"MEUCIDqQvoxC9Cwotl1p9enciAqCyx4zEjsv17p7JYyvvcSgAiEA5nMj6E9r1zQH2296gzDYu7dEjfl/562VoyqAWnFQDVA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":193661},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./types":{"types":"./dist/public-types.d.ts","import":"./dist/public-types.js"},"./queries":{"types":"./dist/queries.d.ts","import":"./dist/queries.js"}},"gitHead":"13db503d7a2ef9729576deb7d753a5f7198f75aa","scripts":{"test":"rm -rf .test-dist && node ./node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test .test-dist/test/*.test.js","build":"rm -rf dist && node ./node_modules/typescript/bin/tsc -p tsconfig.json"},"_npmUser":{"name":"cogcoindev","email":"dev@cogcoin.org"},"repository":{"url":"git+https://github.com/cogcoin/indexer.git","type":"git"},"_npmVersion":"11.8.0","description":"Pure-function Cogcoin indexer kernel with canonical state transitions, rewind support, and historical queries.","directories":{},"_nodeVersion":"25.6.0","dependencies":{"@cogcoin/genesis":"1.0.0","@cogcoin/scoring":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2","@types/node":"^25.5.0"},"_npmOperationalInternal":{"tmp":"tmp/indexer_1.0.0_1775851005734_0.9026178653875623","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@cogcoin/indexer","version":"1.0.1","keywords":["cogcoin","coglex","cogtoshi","bitcoin","indexer","state-machine","history","protocol"],"license":"MIT","_id":"@cogcoin/indexer@1.0.1","maintainers":[{"name":"cogcoindev","email":"dev@cogcoin.org"}],"homepage":"https://cogcoin.org","bugs":{"url":"https://github.com/cogcoin/indexer/issues"},"dist":{"shasum":"4086a885f76d071580581428b24ad3e88d7f3111","tarball":"https://registry.npmjs.org/@cogcoin/indexer/-/indexer-1.0.1.tgz","fileCount":123,"integrity":"sha512-LtFG6JGy9tnBhf1v8YW0ktWvWLts7gXfUy330FDrfkTD8v9U2IVKXU8sym5X6CAVU40bF3SzPhBbqUjU/Jn2AQ==","signatures":[{"sig":"MEUCIEuHaev+a6TyegkXOmrPJ1QNgcsTGIGPGMHTrVJCjKk4AiEAlBDLLQsJ3wbuTnljw6JdguZtZrOxqZiXDfFmXBfaSWI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":194164},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./types":{"types":"./dist/public-types.d.ts","import":"./dist/public-types.js"},"./queries":{"types":"./dist/queries.d.ts","import":"./dist/queries.js"}},"gitHead":"7b20a81a140cdae4b90ff87898592243c58c5b8f","scripts":{"test":"rm -rf .test-dist && node ./node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test .test-dist/test/*.test.js","build":"rm -rf dist && node ./node_modules/typescript/bin/tsc -p tsconfig.json"},"_npmUser":{"name":"cogcoindev","email":"dev@cogcoin.org"},"repository":{"url":"git+https://github.com/cogcoin/indexer.git","type":"git"},"_npmVersion":"11.9.0","description":"Pure-function Cogcoin indexer kernel with canonical state transitions, rewind support, and historical queries.","directories":{},"_nodeVersion":"24.14.0","dependencies":{"@cogcoin/genesis":"1.0.0","@cogcoin/scoring":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.2","@types/node":"^25.5.0"},"_npmOperationalInternal":{"tmp":"tmp/indexer_1.0.1_1776460466568_0.3386477169357913","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@cogcoin/indexer","version":"1.0.2","description":"Pure-function Cogcoin indexer kernel with canonical state transitions, rewind support, and historical queries.","license":"MIT","type":"module","engines":{"node":">=18"},"homepage":"https://cogcoin.org","repository":{"type":"git","url":"git+https://github.com/cogcoin/indexer.git"},"bugs":{"url":"https://github.com/cogcoin/indexer/issues"},"keywords":["cogcoin","coglex","cogtoshi","bitcoin","indexer","state-machine","history","protocol"],"publishConfig":{"access":"public"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./queries":{"types":"./dist/queries.d.ts","import":"./dist/queries.js"},"./types":{"types":"./dist/public-types.d.ts","import":"./dist/public-types.js"}},"scripts":{"build":"rm -rf dist && node ./node_modules/typescript/bin/tsc -p tsconfig.json","test":"rm -rf .test-dist && node ./node_modules/typescript/bin/tsc -p tsconfig.test.json && node --test .test-dist/test/*.test.js"},"dependencies":{"@cogcoin/genesis":"1.0.0","@cogcoin/scoring":"1.0.0"},"devDependencies":{"@types/node":"^25.5.0","typescript":"^6.0.2"},"gitHead":"490d46d86b9a5b7a97c11678c42043faf735794d","_id":"@cogcoin/indexer@1.0.2","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-VLHtPzwhfUvhPdJdcrFtQL6OvyUsbJGXPp9cQDF4KNnsrTWl5wAYPzionbrgbkgMMrUsqzkwMJYd+tURuXm6Gg==","shasum":"ee0f4ffa333dbe078683dffb84dc56c35301a9ed","tarball":"https://registry.npmjs.org/@cogcoin/indexer/-/indexer-1.0.2.tgz","fileCount":123,"unpackedSize":202543,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEFzAvuCn1IZZV5VZvyDheprTusKkXBKuEB2s8kE3xZ5AiB8LMNLEpzPGbzmenSwpogrMKkTemX2IHCvWamCbNI+NQ=="}]},"_npmUser":{"name":"cogcoindev","email":"dev@cogcoin.org"},"directories":{},"maintainers":[{"name":"cogcoindev","email":"dev@cogcoin.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/indexer_1.0.2_1778169198310_0.8739311230934805"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-10T19:56:45.570Z","modified":"2026-05-07T15:53:18.592Z","1.0.0":"2026-04-10T19:56:45.894Z","1.0.1":"2026-04-17T21:14:26.721Z","1.0.2":"2026-05-07T15:53:18.456Z"},"bugs":{"url":"https://github.com/cogcoin/indexer/issues"},"license":"MIT","homepage":"https://cogcoin.org","keywords":["cogcoin","coglex","cogtoshi","bitcoin","indexer","state-machine","history","protocol"],"repository":{"type":"git","url":"git+https://github.com/cogcoin/indexer.git"},"description":"Pure-function Cogcoin indexer kernel with canonical state transitions, rewind support, and historical queries.","maintainers":[{"name":"cogcoindev","email":"dev@cogcoin.org"}],"readme":"# `@cogcoin/indexer`\n\n`@cogcoin/indexer@1.0.2` is the pure-function Cogcoin indexer kernel for developers building clients, sync engines, explorers, and other protocol tooling. It exposes deterministic block transition APIs, rewindable block records, state hashing, and explicit query/type subpaths while delegating canonical mining settlement to `@cogcoin/scoring`.\n\nUse Node 18 or newer.\n\n## Links\n\n- Website: [cogcoin.org](https://cogcoin.org)\n- Whitepaper: [cogcoin.org/whitepaper.md](https://cogcoin.org/whitepaper.md)\n- Source: [github.com/cogcoin/indexer](https://github.com/cogcoin/indexer)\n- Genesis package: [npmjs.com/package/@cogcoin/genesis](https://www.npmjs.com/package/@cogcoin/genesis)\n- Scoring package: [npmjs.com/package/@cogcoin/scoring](https://www.npmjs.com/package/@cogcoin/scoring)\n\n## Quick Start\n\nInstall the package:\n\n```bash\nnpm install @cogcoin/indexer\n```\n\nThen, from your project root, run:\n\n```bash\nnode node_modules/@cogcoin/genesis/verify.mjs\n```\n\nVerify the installed genesis artifacts before using the indexer in a production implementation.\n\n## Dependency Surface\n\nThe published package keeps its runtime dependency surface intentionally small:\n\n- `@cogcoin/genesis@1.0.0`\n- `@cogcoin/scoring@1.0.0`\n\nThe package does not ship a store, sync loop, transport, database adapter, or CLI. Applications are expected to own persistence and orchestration around the pure state machine.\n\n## API\n\nState lifecycle:\n\n- `loadBundledGenesisParameters()`\n- `createInitialState(genesisParameters)`\n- `prepareBlock(state, block, genesisParameters)`\n- `finalizePreparedBlock(preparedBlock, miningSettlementResult)`\n- `applyBlockWithScoring(state, block, genesisParameters)`\n- `rewindBlock(state, blockRecord)`\n\nState hashing and serialization:\n\n- `computeStateHash(consensusState, blockHeight)`\n- `computeStateHashHex(consensusState, blockHeight)`\n- `serializeConsensusState(...)`\n- `deserializeConsensusState(...)`\n- `serializeHistoryState(...)`\n- `deserializeHistoryState(...)`\n- `serializeIndexerState(...)`\n- `deserializeIndexerState(...)`\n- `serializeBlockRecord(...)`\n- `deserializeBlockRecord(...)`\n\nQuery subpath:\n\n- `@cogcoin/indexer/queries`\n\nType subpath:\n\n- `@cogcoin/indexer/types`\n\n## Apply a Block\n\n```ts\nimport {\n  applyBlockWithScoring,\n  createInitialState,\n  loadBundledGenesisParameters,\n} from \"@cogcoin/indexer\";\nimport { getBlockWinners, lookupDomain } from \"@cogcoin/indexer/queries\";\n\nconst genesis = await loadBundledGenesisParameters();\nlet state = createInitialState(genesis);\n\nconst bitcoinBlock = {\n  height: 937338,\n  // Block hashes use Bitcoin internal byte order, not JSON-RPC display hex.\n  hash: new Uint8Array(32),\n  previousHash: new Uint8Array(32),\n  transactions: [],\n};\n\nconst applied = await applyBlockWithScoring(state, bitcoinBlock, genesis);\nstate = applied.state;\n\nconst domain = lookupDomain(state, \"alpha\");\nconst winners = getBlockWinners(state, bitcoinBlock.height);\n```\n\nThe package never mutates the input state. Every block application returns a new state plus a reversible block record.\n\n## Historical Query Support\n\nThe kernel stores the whitepaper's non-consensus query data directly in `history`:\n\n- founding messages from `DOMAIN_ANCHOR`\n- reviews from `REP_COMMIT` and `REP_REVOKE`\n- mining winner history by block height\n- resolved lock history by recipient domain\n- field write and clear history\n- chronological domain event logs\n- Cogcoin explorer block and transaction result history\n\nThese values are rewinded exactly with the same journal mechanism as consensus state, but they do not participate in the state hash.\n\n## Critical Clarifications\n\n- `BitcoinBlock.hash` and `BitcoinBlock.previousHash` must use Bitcoin internal byte order, not JSON-RPC display-order hex.\n- Sender identity is always the prevout `scriptPubKey` of input `0`.\n- Transactions are processed strictly in block order, and mining settlement runs after the transaction loop for the block.\n- The package uses `@cogcoin/scoring` for canonical mining settlement. Conforming implementations **must not** use the scoring WASM export `settle_block_wasm` as an indexer shortcut.\n- Founding messages, reviews, winner history, resolved lock history, domain event logs, and explorer history are protocol-level stored data, but they do not affect validation or any state hash field.\n\n## Published Contents\n\n- `dist/index.js`: public package entrypoint\n- `dist/index.d.ts`: bundled type declarations\n- `dist/queries.js`: selector subpath entrypoint\n- `dist/public-types.d.ts`: public type subpath declarations\n- `dist/*`: compiled ESM implementation\n- `README.md`: package guide\n- `LICENSE`: MIT license text\n","readmeFilename":"README.md"}