Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@secondlayer/subgraphs

Latest version: v8.1.22

Overview

Last scanned
28 Nov 2026
Published
28 Nov 2026
npm package Publisher: ryanwaits
8 Stars
3 Forks
89 Versions
7.2K Downloads
TypeScript Repo language

Scan summary

@secondlayer/subgraphs was last scanned on 28 Nov 2026 at version 8.1.22. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 89 versions; the latest 5 were published within 5 days (24–28 Nov 2026).
  • Findings: No rules fired in version 8.1.22.
  • Downloads: 7,154 downloads.

Versions

89 versions published
Versions and the rules that fired in each
VersionPublishedStatus
8.1.22 LATEST 28 Nov 2026 No rules fired
8.1.21 27 Nov 2026 No rules fired
8.1.20 26 Nov 2026 No rules fired
8.1.19 25 Nov 2026 Not shown
8.1.18 24 Nov 2026 Not shown

No rules fired in 8.1.22

Findings

Findings for v8.1.22. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 8.1.22; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@secondlayer/subgraphs

Typed on-chain indexing for Stacks. Declare event filters + column schema with defineSubgraph(); the runtime decodes blocks, matches filters, runs your handlers inside a transactional context, and exposes the result as a Postgres schema you query over REST or SQL.

Run subgraphs on your own instance, or hosted on api.secondlayer.tools with secondlayer subgraphs deploy and your account key (SECONDLAYER_API_KEY). Hosted subgraphs are private to your account and limited to event filters and contract_call/contract_deploy sources (422 SOURCE_NOT_HOSTABLE otherwise); set startBlock.

Chain events fan out to HTTP subscribers through an outbox emitter: signed Standard Webhooks POSTs with retries, circuit breaker, and replay. To react to your subgraph rows, watch the table from your own Postgres or poll the subgraph API; see React to your rows.

Install

bun add @secondlayer/subgraphs

Quick Start

import { defineSubgraph } from "@secondlayer/subgraphs";

export default defineSubgraph({
  name: "token-transfers",
  sources: {
    // Named event sources — the key becomes the handler name.
    transfer: {
      type: "ft_transfer",
      assetIdentifier: "SP2X0TZ59D5SZ8ACQ6YMCHHNR2ZN51Z32E2CJ173.stx-token::stx",
    },
  },
  schema: {
    transfers: {
      columns: {
        sender: { type: "principal" },
        recipient: { type: "principal" },
        amount: { type: "uint" },
      },
      // Auto-added: _block_height, _tx_id, _created_at
    },
  },
  handlers: {
    async transfer(event, ctx) {
      ctx.insert("transfers", {
        sender: event.sender,
        recipient: event.recipient,
        amount: event.amount,
      });
    },
  },
});

Deploy via CLI (secondlayer subgraphs deploy path/to/definition.ts), SDK (sl.subgraphs.deploy({...})), or MCP (subgraphs_deploy). The CLI can also scaffold from a deployed contract with secondlayer subgraphs scaffold <contract> -o subgraphs/name.ts; scaffold writes or amends package.json and runs bun install unless --no-install is passed. secondlayer subgraphs create <name> --from-contract <id> writes a definition with one ctx.insert handler per print topic.

Every source needs a handler of the same name. Handlers write with ctx.insert, update, upsert, delete and increment, and read with ctx.findOne / findMany. A contract_call source with functionName gets its abi fetched at deploy by the CLI; pass it yourself for wildcard, multi-contract or trait sources, or a local deploy.

Exports

Subpath Description
. defineSubgraph, defineSchema, InferContext / TypedSubgraphContext, readContractAt, validateSubgraphDefinition, ORM generators (generatePrismaSchema, generateDrizzleSchema, generateKyselySchema), deploySchema, diffSchema, generateSubgraphSQL, pgSchemaName
./schema Generator + deployer internals
./validate Shape + filter validation for deploys
./testing runSubgraphTest, createTestContext, buildEvent: run handlers against real or built events before deploying
./runtime/replay replayWebhook({ accountId, webhookId, fromBlock, toBlock }): re-enqueue a historical block range as outbox entries
./runtime/emitter Webhook egress checks used by the API (checkEgressAllowed)
./verify replaySubgraph, compareRows, checkPin: recompute a state subgraph from blocks proven with @secondlayer/verify and compare the served rows (powers secondlayer verify subgraph --replay)

Runtime

The processor runs as a service, not a library import: bun run packages/subgraphs/src/service.ts (the subgraph-processor container in docker/). It LISTENs on indexer:new_block, matches sources, runs handlers, and flushes writes inside a transaction. Breaking schema changes trigger a reindex on deploy.

Webhook emitter

The trigger evaluator matches chain events against each active webhook's triggers and enqueues them to webhook_outbox.

The emitter drains the outbox via LISTEN webhooks:new_outbox and FOR UPDATE SKIP LOCKED batch claims. Live deliveries win a 90/10 split over replays. Each row dispatches through the format builder matching the webhook's format column (standard-webhooks, inngest, trigger, cloudflare, cloudevents, raw). Retries follow 30s → 2m → 10m → 1h → 6h → 24h → 72h. Twenty consecutive failures trips the per-sub circuit breaker and pauses the webhook.

Delivery bodies and response previews land in webhook_deliveries. Rows whose retries exhaust mark status = 'dead' in the outbox; list them with secondlayer webhooks dead <id> and send one again with secondlayer webhooks requeue.

Environment

Variable Default Description
SECONDLAYER_ALLOW_PRIVATE_EGRESS false Allow the emitter to deliver to private IP ranges (localhost, 10/8, 172.16/12, 192.168/16, link-local, v6 mapped). Leave off in production.
SECONDLAYER_SECRETS_KEY — 32-byte hex key for the AES-GCM envelope around webhook signing secrets. OSS mode auto-generates + persists to .env.local.
DATABASE_MAX_POOLS 25 Max cached connection pools; the least-recently-used pool is evicted past this cap. The source/target pools are never evicted.
DATABASE_IDLE_TIMEOUT 300 Seconds before idle connections are closed (0 = never).

ORM codegen

Once rows land in your DB, generate a typed schema for your ORM:

secondlayer codegen subgraph subgraphs/my.ts                      # Kysely (default)
secondlayer codegen subgraph subgraphs/my.ts --target prisma  -o prisma/schema.prisma
secondlayer codegen subgraph subgraphs/my.ts --target drizzle -o db/schema.ts

The generators are exported too (generateKyselySchema, generatePrismaSchema, generateDrizzleSchema). No foreign keys or relation fields are generated. Output mirrors the deployed DDL — prisma db pull should be a no-op; treat the tables as read-only (the processor owns them) and never migrate/push. uint→Decimal/numeric and the BigInt id need .toString() for JSON.

Trait-scoped sources

A source can target a SIP standard instead of a fixed contract — it indexes every contract the registry classifies as that standard (incl. ones deployed later):

sources: {
  tokens: { type: "ft_transfer", trait: "sip-010" }, // all SIP-010 tokens
}

trait (sip-009 | sip-010 | sip-013) is supported on FT/NFT/contract_call/ print_event filters and composes (AND) with other fields. Token filters match the asset-identifier's contract; contract_call/print match contract_id. Resolution is as-of-block, so a reindex backfills a contract's full history even if it was classified after deploy. Requires the contract registry to be populated. Discover the set via GET /v1/contracts?trait=sip-010.

Postgres + pool mode

The emitter holds a persistent LISTEN on webhooks:new_outbox and webhooks:changed, so it MUST connect through a session-mode pool. pgbouncer in transaction mode silently breaks it. Run the emitter against a session-mode port (pool_mode = session), or connect directly to Postgres as the default docker-compose setup does.

License

MIT

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @secondlayer/subgraphs

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Plug and Pray: Your AI Agents Are Taking Orders From Strangers
Research

Plug and Pray: Your AI Agents Are Taking Orders From Strangers

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Frame 2085668439 (1)
Group 1261154229