@secondlayer/shared 6.14.1 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/db/index.d.ts +28 -5
- package/dist/src/db/queries/chain-reorgs.d.ts +26 -4
- package/dist/src/db/queries/contracts.d.ts +26 -4
- package/dist/src/db/queries/integrity.d.ts +26 -4
- package/dist/src/db/queries/subgraph-gaps.d.ts +26 -4
- package/dist/src/db/queries/subgraph-operations.d.ts +26 -4
- package/dist/src/db/queries/subgraphs.d.ts +26 -4
- package/dist/src/db/queries/subscriptions.d.ts +41 -7
- package/dist/src/db/queries/subscriptions.js +10 -3
- package/dist/src/db/queries/subscriptions.js.map +3 -3
- package/dist/src/db/schema.d.ts +28 -5
- package/dist/src/index-http.d.ts +110 -0
- package/dist/src/index-http.js +93 -0
- package/dist/src/index-http.js.map +11 -0
- package/dist/src/index-internal-auth.d.ts +3 -0
- package/dist/src/index-internal-auth.js +29 -0
- package/dist/src/index-internal-auth.js.map +10 -0
- package/dist/src/index.d.ts +110 -10
- package/dist/src/index.js +177 -4
- package/dist/src/index.js.map +3 -3
- package/dist/src/node/local-client.d.ts +26 -4
- package/dist/src/schemas/index.d.ts +82 -5
- package/dist/src/schemas/index.js +177 -4
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subscriptions.d.ts +117 -6
- package/dist/src/schemas/subscriptions.js +182 -5
- package/dist/src/schemas/subscriptions.js.map +3 -3
- package/migrations/0088_chain_subscriptions.ts +86 -0
- package/package.json +9 -1
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"import { createHmac, randomBytes } from \"node:crypto\";\n\n/**\n * Generate a random secret for delivery signing\n * Returns 32 bytes as a 64-character hex string\n */\nexport function generateSecret(): string {\n\treturn randomBytes(32).toString(\"hex\");\n}\n\n/**\n * Sign a payload with HMAC-SHA256\n * Returns the signature as a hex string\n */\nexport function signPayload(payload: string, secret: string): string {\n\tconst hmac = createHmac(\"sha256\", secret);\n\thmac.update(payload);\n\treturn hmac.digest(\"hex\");\n}\n\n/**\n * Verify an HMAC signature\n * Uses constant-time comparison to prevent timing attacks\n */\nexport function verifySignature(\n\tpayload: string,\n\tsignature: string,\n\tsecret: string,\n): boolean {\n\tconst expectedSignature = signPayload(payload, secret);\n\n\t// Constant-time comparison\n\tif (signature.length !== expectedSignature.length) {\n\t\treturn false;\n\t}\n\n\tlet result = 0;\n\tfor (let i = 0; i < signature.length; i++) {\n\t\tresult |= signature.charCodeAt(i) ^ expectedSignature.charCodeAt(i);\n\t}\n\n\treturn result === 0;\n}\n\n/**\n * Create a Stripe-style signature header\n * Format: t=timestamp,v1=signature\n */\nexport function createSignatureHeader(\n\tpayload: string,\n\tsecret: string,\n\ttimestamp?: number,\n): string {\n\tconst ts = timestamp ?? Math.floor(Date.now() / 1000);\n\tconst signedPayload = `${ts}.${payload}`;\n\tconst signature = signPayload(signedPayload, secret);\n\n\treturn `t=${ts},v1=${signature}`;\n}\n\n/**\n * Parse and verify a Stripe-style signature header\n * Returns true if valid, false otherwise\n */\nexport function verifySignatureHeader(\n\tpayload: string,\n\theader: string,\n\tsecret: string,\n\ttoleranceSeconds = 300, // 5 minutes\n): boolean {\n\t// Parse header\n\tconst parts = header.split(\",\");\n\tconst timestamp = parts.find((p) => p.startsWith(\"t=\"))?.slice(2);\n\tconst signature = parts.find((p) => p.startsWith(\"v1=\"))?.slice(3);\n\n\tif (!timestamp || !signature) {\n\t\treturn false;\n\t}\n\n\tconst ts = Number.parseInt(timestamp, 10);\n\tif (Number.isNaN(ts)) {\n\t\treturn false;\n\t}\n\n\t// Check timestamp is within tolerance\n\tconst now = Math.floor(Date.now() / 1000);\n\tif (Math.abs(now - ts) > toleranceSeconds) {\n\t\treturn false;\n\t}\n\n\t// Verify signature\n\tconst signedPayload = `${ts}.${payload}`;\n\treturn verifySignature(signedPayload, signature, secret);\n}\n",
|
|
6
6
|
"/**\n * Instance modes for the Secondlayer platform.\n *\n * - `oss`: self-hosted, single-tenant. No auth middleware, no platform routes\n * (projects, admin). Everything runs against a single `DATABASE_URL`.\n * Intended for `docker compose up`.\n *\n * - `platform`: control-plane mode. Magic-link auth, API keys, projects,\n * admin. Serves the dashboard + CLI against a single shared DB. Post\n * 2026-05-14 shared-rip this also serves subgraphs + subscriptions.\n */\n\nexport type InstanceMode = \"oss\" | \"platform\";\n\nconst VALID_MODES: readonly InstanceMode[] = [\"oss\", \"platform\"];\n\n/**\n * Resolve the active instance mode from `process.env.INSTANCE_MODE`.\n * Defaults to `\"oss\"` — the safest default for self-hosters who deploy\n * without setting the variable.\n */\nexport function getInstanceMode(): InstanceMode {\n\tconst raw = process.env.INSTANCE_MODE?.trim().toLowerCase();\n\tif (raw && (VALID_MODES as readonly string[]).includes(raw)) {\n\t\treturn raw as InstanceMode;\n\t}\n\treturn \"oss\";\n}\n\n/** True when the active mode is `\"platform\"` (shared multi-tenant). */\nexport function isPlatformMode(): boolean {\n\treturn getInstanceMode() === \"platform\";\n}\n\n/** True when the active mode is `\"oss\"` (self-hosted). */\nexport function isOssMode(): boolean {\n\treturn getInstanceMode() === \"oss\";\n}\n",
|
|
7
7
|
"import { createCipheriv, createDecipheriv, randomBytes } from \"node:crypto\";\nimport {\n\tappendFileSync,\n\tcloseSync,\n\texistsSync,\n\topenSync,\n\treadFileSync,\n\tunlinkSync,\n} from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getInstanceMode } from \"../mode.ts\";\n\n/**\n * AES-256-GCM symmetric envelope for encrypted secrets at rest (tenant keys,\n * subscription signing secrets, etc.).\n *\n * Ciphertext layout: `iv (12 bytes) || authTag (16 bytes) || ciphertext`\n *\n * The key comes from `SECONDLAYER_SECRETS_KEY` — 32 bytes hex. In OSS mode,\n * if the env var is unset on first use we autogenerate a key and persist it\n * to `.env.local` in the current working directory so subsequent restarts\n * pick it up without user intervention. Dedicated/platform modes throw —\n * those runtimes must provision the key explicitly.\n *\n * Rotation strategy: re-encrypt all rows with the new key and swap the env\n * var. Not zero-downtime, but acceptable at v2 scale. For real KMS (AWS\n * KMS, Vault, GCP KMS), wrap the same byte layout behind an\n * `EncryptSecret`/`DecryptSecret` interface and swap at startup.\n */\n\nconst KEY_ENV = \"SECONDLAYER_SECRETS_KEY\";\nconst IV_LEN = 12;\nconst TAG_LEN = 16;\n\nfunction readExistingKey(envPath: string): string | null {\n\tif (!existsSync(envPath)) return null;\n\tconst contents = readFileSync(envPath, \"utf8\");\n\tconst match = contents.match(/^SECONDLAYER_SECRETS_KEY=([a-fA-F0-9]{64})/m);\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn match ? match[1]! : null;\n}\n\n/**\n * Atomic file lock via `openSync(..., \"wx\")` — O_CREAT | O_EXCL. If two\n * processes race on cold-compose start, exactly one creates the lock\n * file; the loser polls until the winner finishes writing `.env.local`,\n * then reads the winner's key. Stale locks (process crashed mid-write)\n * are cleaned after `STALE_LOCK_MS`.\n */\nconst STALE_LOCK_MS = 10_000;\nconst POLL_MS = 25;\n\nfunction bootstrapOssKey(): string {\n\tconst envPath = resolve(process.cwd(), \".env.local\");\n\n\t// Fast path — key already on disk from a prior run.\n\tconst existing = readExistingKey(envPath);\n\tif (existing) {\n\t\tprocess.env[KEY_ENV] = existing;\n\t\treturn existing;\n\t}\n\n\tconst lockPath = `${envPath}.secret-bootstrap.lock`;\n\tlet lockFd: number | null = null;\n\ttry {\n\t\tlockFd = openSync(lockPath, \"wx\", 0o600);\n\t} catch (err) {\n\t\tconst e = err as NodeJS.ErrnoException;\n\t\tif (e.code !== \"EEXIST\") throw err;\n\t}\n\n\tif (lockFd === null) {\n\t\t// Another process is bootstrapping. Poll for its result.\n\t\tconst deadline = Date.now() + STALE_LOCK_MS;\n\t\twhile (Date.now() < deadline) {\n\t\t\tconst key = readExistingKey(envPath);\n\t\t\tif (key) {\n\t\t\t\tprocess.env[KEY_ENV] = key;\n\t\t\t\treturn key;\n\t\t\t}\n\t\t\tBun.sleepSync(POLL_MS);\n\t\t}\n\t\t// Lock holder died mid-write — force-clean and retry once.\n\t\ttry {\n\t\t\tunlinkSync(lockPath);\n\t\t} catch {}\n\t\treturn bootstrapOssKey();\n\t}\n\n\ttry {\n\t\tconst hex = randomBytes(32).toString(\"hex\");\n\t\tconst line = `${existsSync(envPath) ? \"\\n\" : \"\"}${KEY_ENV}=${hex}\\n`;\n\t\tappendFileSync(envPath, line, { mode: 0o600 });\n\t\tprocess.env[KEY_ENV] = hex;\n\t\tconsole.log(\n\t\t\t`[secondlayer] generated ${KEY_ENV}; saved to ${envPath} (mode 0600)`,\n\t\t);\n\t\treturn hex;\n\t} finally {\n\t\tcloseSync(lockFd);\n\t\ttry {\n\t\t\tunlinkSync(lockPath);\n\t\t} catch {}\n\t}\n}\n\nfunction loadKey(): Buffer {\n\tlet hex = process.env[KEY_ENV];\n\tif (!hex) {\n\t\tif (getInstanceMode() === \"oss\") {\n\t\t\thex = bootstrapOssKey();\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`${KEY_ENV} not set. Generate one with: openssl rand -hex 32`,\n\t\t\t);\n\t\t}\n\t}\n\tconst key = Buffer.from(hex, \"hex\");\n\tif (key.length !== 32) {\n\t\tthrow new Error(`${KEY_ENV} must be 32 bytes hex (got ${key.length})`);\n\t}\n\treturn key;\n}\n\nlet _cachedKey: Buffer | null = null;\nfunction getKey(): Buffer {\n\tif (!_cachedKey) _cachedKey = loadKey();\n\treturn _cachedKey;\n}\n\nexport function encryptSecret(plaintext: string): Buffer {\n\tconst key = getKey();\n\tconst iv = randomBytes(IV_LEN);\n\tconst cipher = createCipheriv(\"aes-256-gcm\", key, iv);\n\tconst ciphertext = Buffer.concat([\n\t\tcipher.update(plaintext, \"utf8\"),\n\t\tcipher.final(),\n\t]);\n\tconst tag = cipher.getAuthTag();\n\treturn Buffer.concat([iv, tag, ciphertext]);\n}\n\nexport function decryptSecret(envelope: Buffer): string {\n\tconst key = getKey();\n\tconst iv = envelope.subarray(0, IV_LEN);\n\tconst tag = envelope.subarray(IV_LEN, IV_LEN + TAG_LEN);\n\tconst ciphertext = envelope.subarray(IV_LEN + TAG_LEN);\n\tconst decipher = createDecipheriv(\"aes-256-gcm\", key, iv);\n\tdecipher.setAuthTag(tag);\n\treturn decipher.update(ciphertext).toString(\"utf8\") + decipher.final(\"utf8\");\n}\n\n/** Generate a fresh 32-byte hex key suitable for `SECONDLAYER_SECRETS_KEY`. */\nexport function generateSecretsKey(): string {\n\treturn randomBytes(32).toString(\"hex\");\n}\n",
|
|
8
|
-
"import { type Kysely, sql } from \"kysely\";\nimport { generateSecret } from \"../../crypto/hmac.ts\";\nimport { decryptSecret, encryptSecret } from \"../../crypto/secrets.ts\";\nimport type {\n\tDatabase,\n\tInsertSubscription,\n\tSubscription,\n\tSubscriptionFormat,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tUpdateSubscription,\n} from \"../types.ts\";\n\n/**\n * Subscription CRUD. `signing_secret_enc` is transparently encrypted via\n * `encryptSecret`/`decryptSecret`. Plaintext secrets only leave via the\n * return value of `create` (one-time display) and `rotateSecret`.\n */\n\nexport interface CreateSubscriptionInput {\n\taccountId: string;\n\tprojectId?: string | null;\n\tname: string;\n\tsubgraphName
|
|
8
|
+
"import { type Kysely, sql } from \"kysely\";\nimport { generateSecret } from \"../../crypto/hmac.ts\";\nimport { decryptSecret, encryptSecret } from \"../../crypto/secrets.ts\";\nimport type {\n\tDatabase,\n\tInsertSubscription,\n\tSubscription,\n\tSubscriptionFormat,\n\tSubscriptionKind,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tUpdateSubscription,\n} from \"../types.ts\";\n\n/**\n * Subscription CRUD. `signing_secret_enc` is transparently encrypted via\n * `encryptSecret`/`decryptSecret`. Plaintext secrets only leave via the\n * return value of `create` (one-time display) and `rotateSecret`.\n */\n\nexport interface CreateSubscriptionInput {\n\taccountId: string;\n\tprojectId?: string | null;\n\tname: string;\n\t/** Defaults to \"subgraph\". Chain subscriptions set kind=\"chain\" + triggers. */\n\tkind?: SubscriptionKind;\n\t/** Required for subgraph subscriptions; omitted for chain. */\n\tsubgraphName?: string | null;\n\t/** Required for subgraph subscriptions; omitted for chain. */\n\ttableName?: string | null;\n\t/** Chain-trigger filter array. Required for chain subscriptions. */\n\ttriggers?: unknown;\n\tfilter?: unknown;\n\tformat?: SubscriptionFormat;\n\truntime?: SubscriptionRuntime | null;\n\turl: string;\n\tauthConfig?: unknown;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport interface CreateSubscriptionResult {\n\tsubscription: Subscription;\n\t/** Plaintext signing secret — surfaced once, never stored decrypted. */\n\tsigningSecret: string;\n}\n\nexport async function createSubscription(\n\tdb: Kysely<Database>,\n\tinput: CreateSubscriptionInput,\n): Promise<CreateSubscriptionResult> {\n\tconst signingSecret = generateSecret();\n\tconst kind: SubscriptionKind = input.kind ?? \"subgraph\";\n\tconst row: InsertSubscription = {\n\t\taccount_id: input.accountId,\n\t\tproject_id: input.projectId ?? null,\n\t\tname: input.name,\n\t\tstatus: \"active\",\n\t\tkind,\n\t\tsubgraph_name: input.subgraphName ?? null,\n\t\ttable_name: input.tableName ?? null,\n\t\ttriggers: kind === \"chain\" ? ((input.triggers ?? []) as unknown) : null,\n\t\tfilter: input.filter ?? {},\n\t\tformat: input.format ?? \"standard-webhooks\",\n\t\truntime: input.runtime ?? null,\n\t\turl: input.url,\n\t\tsigning_secret_enc: encryptSecret(signingSecret),\n\t\tauth_config: input.authConfig ?? {},\n\t\t...(input.maxRetries !== undefined\n\t\t\t? { max_retries: input.maxRetries }\n\t\t\t: {}),\n\t\t...(input.timeoutMs !== undefined ? { timeout_ms: input.timeoutMs } : {}),\n\t\t...(input.concurrency !== undefined\n\t\t\t? { concurrency: input.concurrency }\n\t\t\t: {}),\n\t};\n\tconst subscription = await db\n\t\t.insertInto(\"subscriptions\")\n\t\t.values(row)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n\treturn { subscription, signingSecret };\n}\n\nexport async function listSubscriptions(\n\tdb: Kysely<Database>,\n\taccountId: string,\n): Promise<Subscription[]> {\n\treturn db\n\t\t.selectFrom(\"subscriptions\")\n\t\t.selectAll()\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.orderBy(\"created_at\", \"desc\")\n\t\t.execute();\n}\n\n/**\n * All active chain subscriptions across every account — the input to the global\n * trigger evaluator (one loop serves them all). Subgraph subscriptions are\n * excluded; they emit via the subgraph flush path.\n */\nexport async function listActiveChainSubscriptions(\n\tdb: Kysely<Database>,\n): Promise<Subscription[]> {\n\treturn db\n\t\t.selectFrom(\"subscriptions\")\n\t\t.selectAll()\n\t\t.where(\"kind\", \"=\", \"chain\")\n\t\t.where(\"status\", \"=\", \"active\")\n\t\t.execute();\n}\n\nexport async function getSubscription(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n): Promise<Subscription | null> {\n\tconst row = await db\n\t\t.selectFrom(\"subscriptions\")\n\t\t.selectAll()\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"id\", \"=\", id)\n\t\t.executeTakeFirst();\n\treturn row ?? null;\n}\n\nexport async function getSubscriptionByName(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tname: string,\n): Promise<Subscription | null> {\n\tconst row = await db\n\t\t.selectFrom(\"subscriptions\")\n\t\t.selectAll()\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"name\", \"=\", name)\n\t\t.executeTakeFirst();\n\treturn row ?? null;\n}\n\nexport interface UpdateSubscriptionInput {\n\tname?: string;\n\tfilter?: unknown;\n\tformat?: SubscriptionFormat;\n\truntime?: SubscriptionRuntime | null;\n\turl?: string;\n\tauthConfig?: unknown;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport async function updateSubscription(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n\tpatch: UpdateSubscriptionInput,\n): Promise<Subscription | null> {\n\tconst update: UpdateSubscription = { updated_at: new Date() };\n\tif (patch.name !== undefined) update.name = patch.name;\n\tif (patch.filter !== undefined) update.filter = patch.filter;\n\tif (patch.format !== undefined) update.format = patch.format;\n\tif (patch.runtime !== undefined) update.runtime = patch.runtime;\n\tif (patch.url !== undefined) update.url = patch.url;\n\tif (patch.authConfig !== undefined) update.auth_config = patch.authConfig;\n\tif (patch.maxRetries !== undefined) update.max_retries = patch.maxRetries;\n\tif (patch.timeoutMs !== undefined) update.timeout_ms = patch.timeoutMs;\n\tif (patch.concurrency !== undefined) update.concurrency = patch.concurrency;\n\n\tconst row = await db\n\t\t.updateTable(\"subscriptions\")\n\t\t.set(update)\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"id\", \"=\", id)\n\t\t.returningAll()\n\t\t.executeTakeFirst();\n\treturn row ?? null;\n}\n\nexport async function toggleSubscriptionStatus(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n\tstatus: SubscriptionStatus,\n): Promise<Subscription | null> {\n\tconst row = await db\n\t\t.updateTable(\"subscriptions\")\n\t\t.set({\n\t\t\tstatus,\n\t\t\tupdated_at: new Date(),\n\t\t\t...(status === \"active\"\n\t\t\t\t? {\n\t\t\t\t\t\tcircuit_failures: 0,\n\t\t\t\t\t\tcircuit_opened_at: null,\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t})\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"id\", \"=\", id)\n\t\t.returningAll()\n\t\t.executeTakeFirst();\n\treturn row ?? null;\n}\n\nexport async function deleteSubscription(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n): Promise<boolean> {\n\tconst res = await db\n\t\t.deleteFrom(\"subscriptions\")\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"id\", \"=\", id)\n\t\t.executeTakeFirst();\n\treturn Number(res.numDeletedRows ?? 0) > 0;\n}\n\nexport interface RotateSecretResult {\n\tsubscription: Subscription;\n\tsigningSecret: string;\n}\n\nexport async function rotateSubscriptionSecret(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n): Promise<RotateSecretResult | null> {\n\tconst signingSecret = generateSecret();\n\tconst row = await db\n\t\t.updateTable(\"subscriptions\")\n\t\t.set({\n\t\t\tsigning_secret_enc: encryptSecret(signingSecret),\n\t\t\tupdated_at: new Date(),\n\t\t})\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"id\", \"=\", id)\n\t\t.returningAll()\n\t\t.executeTakeFirst();\n\tif (!row) return null;\n\treturn { subscription: row, signingSecret };\n}\n\n/** Decrypt a subscription's signing secret for HMAC signing at emit time. */\nexport function getSubscriptionSigningSecret(sub: Subscription): string {\n\treturn decryptSecret(sub.signing_secret_enc);\n}\n\n/** Fire `subscriptions:changed` notify so the emitter hot-reloads its cache. */\nexport async function notifySubscriptionsChanged(\n\tdb: Kysely<Database>,\n\taccountId: string,\n): Promise<void> {\n\tawait sql`SELECT pg_notify('subscriptions:changed', ${accountId})`.execute(\n\t\tdb,\n\t);\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAMO,SAAS,cAAc,GAAW;AAAA,EACxC,OAAO,YAAY,EAAE,EAAE,SAAS,KAAK;AAAA;AAO/B,SAAS,WAAW,CAAC,SAAiB,QAAwB;AAAA,EACpE,MAAM,OAAO,WAAW,UAAU,MAAM;AAAA,EACxC,KAAK,OAAO,OAAO;AAAA,EACnB,OAAO,KAAK,OAAO,KAAK;AAAA;AAOlB,SAAS,eAAe,CAC9B,SACA,WACA,QACU;AAAA,EACV,MAAM,oBAAoB,YAAY,SAAS,MAAM;AAAA,EAGrD,IAAI,UAAU,WAAW,kBAAkB,QAAQ;AAAA,IAClD,OAAO;AAAA,EACR;AAAA,EAEA,IAAI,SAAS;AAAA,EACb,SAAS,IAAI,EAAG,IAAI,UAAU,QAAQ,KAAK;AAAA,IAC1C,UAAU,UAAU,WAAW,CAA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sB,wBAAwB,CAC7C,IACA,WACA,IACqC;AAAA,EACrC,MAAM,gBAAgB,eAAe;AAAA,EACrC,MAAM,MAAM,MAAM,GAChB,YAAY,eAAe,EAC3B,IAAI;AAAA,IACJ,oBAAoB,cAAc,aAAa;AAAA,IAC/C,YAAY,IAAI;AAAA,EACjB,CAAC,EACA,MAAM,cAAc,KAAK,SAAS,EAClC,MAAM,MAAM,KAAK,EAAE,EACnB,aAAa,EACb,iBAAiB;AAAA,EACnB,IAAI,CAAC;AAAA,IAAK,OAAO;AAAA,EACjB,OAAO,EAAE,cAAc,KAAK,cAAc;AAAA;AAIpC,SAAS,4BAA4B,CAAC,KAA2B;AAAA,EACvE,OAAO,cAAc,IAAI,kBAAkB;AAAA;AAI5C,eAAsB,0BAA0B,CAC/C,IACA,WACgB;AAAA,EAChB,MAAM,gDAAgD,aAAa,QAClE,EACD;AAAA;",
|
|
11
|
+
"debugId": "DA0C831A6692C10B64756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -635,6 +635,7 @@ interface Database {
|
|
|
635
635
|
subscriptions: SubscriptionsTable;
|
|
636
636
|
subscription_outbox: SubscriptionOutboxTable;
|
|
637
637
|
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
638
|
+
trigger_evaluator_state: TriggerEvaluatorStateTable;
|
|
638
639
|
decoded_events: DecodedEventsTable;
|
|
639
640
|
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
640
641
|
chain_reorgs: ChainReorgsTable;
|
|
@@ -803,6 +804,10 @@ type UpdateChatSession = Updateable<ChatSessionsTable>;
|
|
|
803
804
|
type ChatMessage = Selectable<ChatMessagesTable>;
|
|
804
805
|
type InsertChatMessage = Insertable<ChatMessagesTable>;
|
|
805
806
|
type SubscriptionStatus = "active" | "paused" | "error";
|
|
807
|
+
/** Polymorphic subscription mode: `subgraph` reacts to processed table rows;
|
|
808
|
+
* `chain` reacts to raw chain events matched directly off the Index/Streams
|
|
809
|
+
* clock (no subgraph). See migration 0088. */
|
|
810
|
+
type SubscriptionKind = "subgraph" | "chain";
|
|
806
811
|
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
807
812
|
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
808
813
|
interface SubscriptionsTable {
|
|
@@ -811,8 +816,15 @@ interface SubscriptionsTable {
|
|
|
811
816
|
project_id: string | null;
|
|
812
817
|
name: string;
|
|
813
818
|
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
814
|
-
|
|
815
|
-
|
|
819
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
820
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
821
|
+
subgraph_name: string | null;
|
|
822
|
+
/** Null for chain subscriptions (CHECK subscriptions_kind_shape). */
|
|
823
|
+
table_name: string | null;
|
|
824
|
+
/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Null for
|
|
825
|
+
* subgraph subscriptions. Typed loosely here to avoid a shared→subgraphs
|
|
826
|
+
* import cycle; the Zod schema in schemas/subscriptions.ts owns the shape. */
|
|
827
|
+
triggers: unknown | null;
|
|
816
828
|
filter: Generated<unknown>;
|
|
817
829
|
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
818
830
|
runtime: SubscriptionRuntime | null;
|
|
@@ -837,8 +849,11 @@ type OutboxStatus = "pending" | "delivered" | "dead";
|
|
|
837
849
|
interface SubscriptionOutboxTable {
|
|
838
850
|
id: Generated<string>;
|
|
839
851
|
subscription_id: string;
|
|
840
|
-
|
|
841
|
-
|
|
852
|
+
kind: ColumnType<SubscriptionKind, SubscriptionKind | undefined, SubscriptionKind>;
|
|
853
|
+
/** Null for chain-subscription rows. */
|
|
854
|
+
subgraph_name: string | null;
|
|
855
|
+
/** Null for chain-subscription rows. */
|
|
856
|
+
table_name: string | null;
|
|
842
857
|
block_height: number | bigint;
|
|
843
858
|
tx_id: string | null;
|
|
844
859
|
row_pk: unknown;
|
|
@@ -874,4 +889,12 @@ interface SubscriptionDeliveriesTable {
|
|
|
874
889
|
}
|
|
875
890
|
type SubscriptionDelivery = Selectable<SubscriptionDeliveriesTable>;
|
|
876
891
|
type InsertSubscriptionDelivery = Insertable<SubscriptionDeliveriesTable>;
|
|
877
|
-
|
|
892
|
+
/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.
|
|
893
|
+
* One loop serves all chain subscriptions, so the cursor is global. */
|
|
894
|
+
interface TriggerEvaluatorStateTable {
|
|
895
|
+
id: Generated<boolean>;
|
|
896
|
+
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
897
|
+
updated_at: Generated<Date>;
|
|
898
|
+
}
|
|
899
|
+
type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
|
|
900
|
+
export { UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcEventsTable, SbtcEventTopic, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, OutboxStatus, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, L2DecoderCheckpointsTable, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertChatSession, InsertChatMessage, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, EventsTable, EventsArchiveTable, Event, DecodedEventsTable, DeadLetterEventsTable, Database, ContractsTable, Contract, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, ChainReorgsTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
type IndexBlockRow = {
|
|
2
|
+
block_height: number
|
|
3
|
+
block_hash: string
|
|
4
|
+
parent_hash: string
|
|
5
|
+
burn_block_height: number
|
|
6
|
+
burn_block_hash: string | null
|
|
7
|
+
block_time: string | null
|
|
8
|
+
};
|
|
9
|
+
type IndexEventCommon = {
|
|
10
|
+
block_height: number
|
|
11
|
+
tx_id: string
|
|
12
|
+
event_index: number
|
|
13
|
+
contract_id: string | null
|
|
14
|
+
};
|
|
15
|
+
type IndexEventRow = IndexEventCommon & ({
|
|
16
|
+
event_type: "ft_transfer" | "ft_mint" | "ft_burn"
|
|
17
|
+
asset_identifier: string
|
|
18
|
+
sender?: string
|
|
19
|
+
recipient?: string
|
|
20
|
+
amount: string
|
|
21
|
+
} | {
|
|
22
|
+
event_type: "nft_transfer" | "nft_mint" | "nft_burn"
|
|
23
|
+
asset_identifier: string
|
|
24
|
+
sender?: string
|
|
25
|
+
recipient?: string
|
|
26
|
+
value: string
|
|
27
|
+
} | {
|
|
28
|
+
event_type: "stx_transfer" | "stx_mint" | "stx_burn"
|
|
29
|
+
sender?: string
|
|
30
|
+
recipient?: string
|
|
31
|
+
amount: string
|
|
32
|
+
memo?: string | null
|
|
33
|
+
} | {
|
|
34
|
+
event_type: "stx_lock"
|
|
35
|
+
sender: string
|
|
36
|
+
amount: string
|
|
37
|
+
payload: {
|
|
38
|
+
unlock_height: string | null
|
|
39
|
+
}
|
|
40
|
+
} | {
|
|
41
|
+
event_type: "print"
|
|
42
|
+
payload: {
|
|
43
|
+
topic: string | null
|
|
44
|
+
value: unknown
|
|
45
|
+
raw_value: string | null
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
type IndexTransactionRow = {
|
|
49
|
+
tx_id: string
|
|
50
|
+
block_height: number
|
|
51
|
+
tx_index: number
|
|
52
|
+
tx_type: string
|
|
53
|
+
sender: string
|
|
54
|
+
status: string
|
|
55
|
+
contract_call?: {
|
|
56
|
+
contract_id: string
|
|
57
|
+
function_name: string
|
|
58
|
+
function_args_hex?: string[] | null
|
|
59
|
+
result_hex?: string | null
|
|
60
|
+
} | null
|
|
61
|
+
smart_contract?: {
|
|
62
|
+
contract_id: string | null
|
|
63
|
+
} | null
|
|
64
|
+
};
|
|
65
|
+
type StreamsReorgRow = {
|
|
66
|
+
detected_at: string
|
|
67
|
+
fork_point_height: number
|
|
68
|
+
orphaned_range: {
|
|
69
|
+
from: string
|
|
70
|
+
to: string
|
|
71
|
+
}
|
|
72
|
+
new_canonical_tip: string
|
|
73
|
+
};
|
|
74
|
+
type IndexHttpOptions = {
|
|
75
|
+
/** Base URL for /v1/index (the decoded data plane). */
|
|
76
|
+
indexBaseUrl: string
|
|
77
|
+
/** Bearer for /v1/index. Defaults to the internal enterprise key. */
|
|
78
|
+
indexApiKey?: string
|
|
79
|
+
/** Base URL for /v1/streams (the canonical clock). */
|
|
80
|
+
streamsBaseUrl: string
|
|
81
|
+
/** Bearer for /v1/streams (internal enterprise key). */
|
|
82
|
+
streamsApiKey: string
|
|
83
|
+
};
|
|
84
|
+
declare class IndexHttpClient {
|
|
85
|
+
private readonly indexBaseUrl;
|
|
86
|
+
private readonly indexApiKey;
|
|
87
|
+
private readonly streamsBaseUrl;
|
|
88
|
+
private readonly streamsApiKey;
|
|
89
|
+
constructor(opts: IndexHttpOptions);
|
|
90
|
+
private get;
|
|
91
|
+
/** Drain a cursor-paginated Index collection over [fromHeight, toHeight]. */
|
|
92
|
+
private walk;
|
|
93
|
+
walkBlocks(fromHeight: number, toHeight: number): Promise<IndexBlockRow[]>;
|
|
94
|
+
walkEvents(eventType: string, fromHeight: number, toHeight: number): Promise<IndexEventRow[]>;
|
|
95
|
+
walkTransactions(fromHeight: number, toHeight: number): Promise<IndexTransactionRow[]>;
|
|
96
|
+
/** Canonical tip height from the Streams clock. */
|
|
97
|
+
getStreamsTip(): Promise<number>;
|
|
98
|
+
/**
|
|
99
|
+
* Highest block height the Index data plane can serve (tip is inline in every
|
|
100
|
+
* envelope). This is the data-availability bound — a consumer must not
|
|
101
|
+
* process past it, even if the Streams clock is ahead.
|
|
102
|
+
*/
|
|
103
|
+
getIndexTip(): Promise<number>;
|
|
104
|
+
/** Reorgs since a resume token (wall-clock `detected_at`-keyed). */
|
|
105
|
+
listReorgs(since: string): Promise<{
|
|
106
|
+
reorgs: StreamsReorgRow[]
|
|
107
|
+
next_since: string | null
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
110
|
+
export { StreamsReorgRow, IndexTransactionRow, IndexHttpOptions, IndexHttpClient, IndexEventRow, IndexBlockRow };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/index-internal-auth.ts
|
|
18
|
+
var INDEX_INTERNAL_TENANT_ID = "tenant_index_internal";
|
|
19
|
+
var DEFAULT_INDEX_INTERNAL_API_KEY = "sk-sl_index_internal";
|
|
20
|
+
function defaultInternalIndexApiKey() {
|
|
21
|
+
return process.env.INDEX_INTERNAL_API_KEY || DEFAULT_INDEX_INTERNAL_API_KEY;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/index-http.ts
|
|
25
|
+
var PAGE_LIMIT = 1000;
|
|
26
|
+
|
|
27
|
+
class IndexHttpClient {
|
|
28
|
+
indexBaseUrl;
|
|
29
|
+
indexApiKey;
|
|
30
|
+
streamsBaseUrl;
|
|
31
|
+
streamsApiKey;
|
|
32
|
+
constructor(opts) {
|
|
33
|
+
this.indexBaseUrl = opts.indexBaseUrl.replace(/\/+$/, "");
|
|
34
|
+
this.indexApiKey = opts.indexApiKey ?? defaultInternalIndexApiKey();
|
|
35
|
+
this.streamsBaseUrl = opts.streamsBaseUrl.replace(/\/+$/, "");
|
|
36
|
+
this.streamsApiKey = opts.streamsApiKey;
|
|
37
|
+
}
|
|
38
|
+
async get(url, apiKey) {
|
|
39
|
+
const res = await fetch(url, {
|
|
40
|
+
headers: apiKey ? { authorization: `Bearer ${apiKey}` } : {}
|
|
41
|
+
});
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
throw new Error(`GET ${url} → ${res.status} ${await res.text()}`);
|
|
44
|
+
}
|
|
45
|
+
return await res.json();
|
|
46
|
+
}
|
|
47
|
+
async walk(path, key, fromHeight, toHeight, extraParams = {}) {
|
|
48
|
+
const out = [];
|
|
49
|
+
let cursor = null;
|
|
50
|
+
do {
|
|
51
|
+
const params = new URLSearchParams({
|
|
52
|
+
to_height: String(toHeight),
|
|
53
|
+
limit: String(PAGE_LIMIT),
|
|
54
|
+
...extraParams
|
|
55
|
+
});
|
|
56
|
+
if (cursor)
|
|
57
|
+
params.set("cursor", cursor);
|
|
58
|
+
else
|
|
59
|
+
params.set("from_height", String(fromHeight));
|
|
60
|
+
const env = await this.get(`${this.indexBaseUrl}${path}?${params}`, this.indexApiKey);
|
|
61
|
+
out.push(...env[key]);
|
|
62
|
+
cursor = env.next_cursor;
|
|
63
|
+
} while (cursor);
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
walkBlocks(fromHeight, toHeight) {
|
|
67
|
+
return this.walk("/v1/index/blocks", "blocks", fromHeight, toHeight);
|
|
68
|
+
}
|
|
69
|
+
walkEvents(eventType, fromHeight, toHeight) {
|
|
70
|
+
return this.walk("/v1/index/events", "events", fromHeight, toHeight, { event_type: eventType });
|
|
71
|
+
}
|
|
72
|
+
walkTransactions(fromHeight, toHeight) {
|
|
73
|
+
return this.walk("/v1/index/transactions", "transactions", fromHeight, toHeight);
|
|
74
|
+
}
|
|
75
|
+
async getStreamsTip() {
|
|
76
|
+
const tip = await this.get(`${this.streamsBaseUrl}/v1/streams/tip`, this.streamsApiKey);
|
|
77
|
+
return Number(tip.block_height) || 0;
|
|
78
|
+
}
|
|
79
|
+
async getIndexTip() {
|
|
80
|
+
const env = await this.get(`${this.indexBaseUrl}/v1/index/blocks?limit=1`, this.indexApiKey);
|
|
81
|
+
return Number(env.tip?.block_height) || 0;
|
|
82
|
+
}
|
|
83
|
+
async listReorgs(since) {
|
|
84
|
+
const params = new URLSearchParams({ since });
|
|
85
|
+
return this.get(`${this.streamsBaseUrl}/v1/streams/reorgs?${params}`, this.streamsApiKey);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
IndexHttpClient
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
//# debugId=E1C3D9E21DD5904564756E2164756E21
|
|
93
|
+
//# sourceMappingURL=index-http.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index-internal-auth.ts", "../src/index-http.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// Internal service credential for first-party consumers of /v1/index over HTTP\n// (e.g. the subgraph processor's PublicApiBlockSource). Seeded into the Index\n// token store as an enterprise tenant with NO account_id, so these reads are\n// unmetered (Index metering gates on account_id). Mirrors the Streams internal\n// key (packages/indexer/src/l2/internal-auth.ts). Lives in shared so both the\n// API (seed) and the subgraph processor (consumer) import it without a cycle.\nexport const INDEX_INTERNAL_TENANT_ID = \"tenant_index_internal\";\n\nconst DEFAULT_INDEX_INTERNAL_API_KEY = \"sk-sl_index_internal\";\n\nexport function defaultInternalIndexApiKey(): string {\n\treturn process.env.INDEX_INTERNAL_API_KEY || DEFAULT_INDEX_INTERNAL_API_KEY;\n}\n",
|
|
6
|
+
"import { defaultInternalIndexApiKey } from \"./index-internal-auth.ts\";\n\n/**\n * Low-level transport for the public Index (`/v1/index`) + Streams clock\n * (`/v1/streams`) HTTP APIs: cursor-paginated reads, tip, reorgs. Lives in\n * `shared` (a leaf both the SDK and the subgraph runtime depend on) so the wire\n * format has one home and no package cycle. The SDK's ergonomic client should\n * eventually consume these row types too (see the plan's convergence task).\n *\n * This is intentionally minimal — just the GETs the subgraph runtime's\n * PublicApiBlockSource needs. It is NOT the SDK's full client (walk/consume/\n * retries/auth resolution).\n */\n\nconst PAGE_LIMIT = 1000;\n\ntype Envelope<K extends string, T> = {\n\t[P in K]: T[];\n} & { next_cursor: string | null };\n\n// ── Index API wire shapes (single source of truth) ─────────────────────────\nexport type IndexBlockRow = {\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n\tblock_time: string | null;\n};\n\ntype IndexEventCommon = {\n\tblock_height: number;\n\ttx_id: string;\n\tevent_index: number;\n\tcontract_id: string | null;\n};\n\nexport type IndexEventRow = IndexEventCommon &\n\t(\n\t\t| {\n\t\t\t\tevent_type: \"ft_transfer\" | \"ft_mint\" | \"ft_burn\";\n\t\t\t\tasset_identifier: string;\n\t\t\t\tsender?: string;\n\t\t\t\trecipient?: string;\n\t\t\t\tamount: string;\n\t\t }\n\t\t| {\n\t\t\t\tevent_type: \"nft_transfer\" | \"nft_mint\" | \"nft_burn\";\n\t\t\t\tasset_identifier: string;\n\t\t\t\tsender?: string;\n\t\t\t\trecipient?: string;\n\t\t\t\tvalue: string;\n\t\t }\n\t\t| {\n\t\t\t\tevent_type: \"stx_transfer\" | \"stx_mint\" | \"stx_burn\";\n\t\t\t\tsender?: string;\n\t\t\t\trecipient?: string;\n\t\t\t\tamount: string;\n\t\t\t\tmemo?: string | null;\n\t\t }\n\t\t| {\n\t\t\t\tevent_type: \"stx_lock\";\n\t\t\t\tsender: string;\n\t\t\t\tamount: string;\n\t\t\t\tpayload: { unlock_height: string | null };\n\t\t }\n\t\t| {\n\t\t\t\tevent_type: \"print\";\n\t\t\t\tpayload: {\n\t\t\t\t\ttopic: string | null;\n\t\t\t\t\tvalue: unknown;\n\t\t\t\t\traw_value: string | null;\n\t\t\t\t};\n\t\t }\n\t);\n\nexport type IndexTransactionRow = {\n\ttx_id: string;\n\tblock_height: number;\n\ttx_index: number;\n\ttx_type: string;\n\tsender: string;\n\tstatus: string;\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args_hex?: string[] | null;\n\t\tresult_hex?: string | null;\n\t} | null;\n\tsmart_contract?: { contract_id: string | null } | null;\n};\n\nexport type StreamsReorgRow = {\n\tdetected_at: string;\n\tfork_point_height: number;\n\torphaned_range: { from: string; to: string };\n\tnew_canonical_tip: string;\n};\n\nexport type IndexHttpOptions = {\n\t/** Base URL for /v1/index (the decoded data plane). */\n\tindexBaseUrl: string;\n\t/** Bearer for /v1/index. Defaults to the internal enterprise key. */\n\tindexApiKey?: string;\n\t/** Base URL for /v1/streams (the canonical clock). */\n\tstreamsBaseUrl: string;\n\t/** Bearer for /v1/streams (internal enterprise key). */\n\tstreamsApiKey: string;\n};\n\nexport class IndexHttpClient {\n\tprivate readonly indexBaseUrl: string;\n\tprivate readonly indexApiKey: string;\n\tprivate readonly streamsBaseUrl: string;\n\tprivate readonly streamsApiKey: string;\n\n\tconstructor(opts: IndexHttpOptions) {\n\t\tthis.indexBaseUrl = opts.indexBaseUrl.replace(/\\/+$/, \"\");\n\t\tthis.indexApiKey = opts.indexApiKey ?? defaultInternalIndexApiKey();\n\t\tthis.streamsBaseUrl = opts.streamsBaseUrl.replace(/\\/+$/, \"\");\n\t\tthis.streamsApiKey = opts.streamsApiKey;\n\t}\n\n\tprivate async get<T>(url: string, apiKey: string): Promise<T> {\n\t\t// Index reads are anon — omit the header entirely when no key is set, so\n\t\t// an empty key reads anonymously rather than 401-ing as an invalid bearer.\n\t\tconst res = await fetch(url, {\n\t\t\theaders: apiKey ? { authorization: `Bearer ${apiKey}` } : {},\n\t\t});\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`GET ${url} → ${res.status} ${await res.text()}`);\n\t\t}\n\t\treturn (await res.json()) as T;\n\t}\n\n\t/** Drain a cursor-paginated Index collection over [fromHeight, toHeight]. */\n\tprivate async walk<K extends string, T>(\n\t\tpath: string,\n\t\tkey: K,\n\t\tfromHeight: number,\n\t\ttoHeight: number,\n\t\textraParams: Record<string, string> = {},\n\t): Promise<T[]> {\n\t\tconst out: T[] = [];\n\t\tlet cursor: string | null = null;\n\t\tdo {\n\t\t\tconst params = new URLSearchParams({\n\t\t\t\tto_height: String(toHeight),\n\t\t\t\tlimit: String(PAGE_LIMIT),\n\t\t\t\t...extraParams,\n\t\t\t});\n\t\t\t// from_height and cursor are mutually exclusive — anchor the first page\n\t\t\t// by height, then page forward by cursor only.\n\t\t\tif (cursor) params.set(\"cursor\", cursor);\n\t\t\telse params.set(\"from_height\", String(fromHeight));\n\t\t\tconst env: Envelope<K, T> = await this.get(\n\t\t\t\t`${this.indexBaseUrl}${path}?${params}`,\n\t\t\t\tthis.indexApiKey,\n\t\t\t);\n\t\t\tout.push(...env[key]);\n\t\t\tcursor = env.next_cursor;\n\t\t} while (cursor);\n\t\treturn out;\n\t}\n\n\twalkBlocks(fromHeight: number, toHeight: number): Promise<IndexBlockRow[]> {\n\t\treturn this.walk<\"blocks\", IndexBlockRow>(\n\t\t\t\"/v1/index/blocks\",\n\t\t\t\"blocks\",\n\t\t\tfromHeight,\n\t\t\ttoHeight,\n\t\t);\n\t}\n\n\twalkEvents(\n\t\teventType: string,\n\t\tfromHeight: number,\n\t\ttoHeight: number,\n\t): Promise<IndexEventRow[]> {\n\t\treturn this.walk<\"events\", IndexEventRow>(\n\t\t\t\"/v1/index/events\",\n\t\t\t\"events\",\n\t\t\tfromHeight,\n\t\t\ttoHeight,\n\t\t\t{ event_type: eventType },\n\t\t);\n\t}\n\n\twalkTransactions(\n\t\tfromHeight: number,\n\t\ttoHeight: number,\n\t): Promise<IndexTransactionRow[]> {\n\t\treturn this.walk<\"transactions\", IndexTransactionRow>(\n\t\t\t\"/v1/index/transactions\",\n\t\t\t\"transactions\",\n\t\t\tfromHeight,\n\t\t\ttoHeight,\n\t\t);\n\t}\n\n\t/** Canonical tip height from the Streams clock. */\n\tasync getStreamsTip(): Promise<number> {\n\t\tconst tip = await this.get<{ block_height: number }>(\n\t\t\t`${this.streamsBaseUrl}/v1/streams/tip`,\n\t\t\tthis.streamsApiKey,\n\t\t);\n\t\treturn Number(tip.block_height) || 0;\n\t}\n\n\t/**\n\t * Highest block height the Index data plane can serve (tip is inline in every\n\t * envelope). This is the data-availability bound — a consumer must not\n\t * process past it, even if the Streams clock is ahead.\n\t */\n\tasync getIndexTip(): Promise<number> {\n\t\tconst env = await this.get<{ tip: { block_height: number } }>(\n\t\t\t`${this.indexBaseUrl}/v1/index/blocks?limit=1`,\n\t\t\tthis.indexApiKey,\n\t\t);\n\t\treturn Number(env.tip?.block_height) || 0;\n\t}\n\n\t/** Reorgs since a resume token (wall-clock `detected_at`-keyed). */\n\tasync listReorgs(\n\t\tsince: string,\n\t): Promise<{ reorgs: StreamsReorgRow[]; next_since: string | null }> {\n\t\tconst params = new URLSearchParams({ since });\n\t\treturn this.get(\n\t\t\t`${this.streamsBaseUrl}/v1/streams/reorgs?${params}`,\n\t\t\tthis.streamsApiKey,\n\t\t);\n\t}\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAMO,IAAM,2BAA2B;AAExC,IAAM,iCAAiC;AAEhC,SAAS,0BAA0B,GAAW;AAAA,EACpD,OAAO,QAAQ,IAAI,0BAA0B;AAAA;;;ACG9C,IAAM,aAAa;AAAA;AAgGZ,MAAM,gBAAgB;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,WAAW,CAAC,MAAwB;AAAA,IACnC,KAAK,eAAe,KAAK,aAAa,QAAQ,QAAQ,EAAE;AAAA,IACxD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,CACzB;AAAA;AAAA,EAGD,gBAAgB,CACf,YACA,UACiC;AAAA,IACjC,OAAO,KAAK,KACX,0BACA,gBACA,YACA,QACD;AAAA;AAAA,OAIK,cAAa,GAAoB;AAAA,IACtC,MAAM,MAAM,MAAM,KAAK,IACtB,GAAG,KAAK,iCACR,KAAK,aACN;AAAA,IACA,OAAO,OAAO,IAAI,YAAY,KAAK;AAAA;AAAA,OAQ9B,YAAW,GAAoB;AAAA,IACpC,MAAM,MAAM,MAAM,KAAK,IACtB,GAAG,KAAK,wCACR,KAAK,WACN;AAAA,IACA,OAAO,OAAO,IAAI,KAAK,YAAY,KAAK;AAAA;AAAA,OAInC,WAAU,CACf,OACoE;AAAA,IACpE,MAAM,SAAS,IAAI,gBAAgB,EAAE,MAAM,CAAC;AAAA,IAC5C,OAAO,KAAK,IACX,GAAG,KAAK,oCAAoC,UAC5C,KAAK,aACN;AAAA;AAEF;",
|
|
9
|
+
"debugId": "E1C3D9E21DD5904564756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/index-internal-auth.ts
|
|
18
|
+
var INDEX_INTERNAL_TENANT_ID = "tenant_index_internal";
|
|
19
|
+
var DEFAULT_INDEX_INTERNAL_API_KEY = "sk-sl_index_internal";
|
|
20
|
+
function defaultInternalIndexApiKey() {
|
|
21
|
+
return process.env.INDEX_INTERNAL_API_KEY || DEFAULT_INDEX_INTERNAL_API_KEY;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
defaultInternalIndexApiKey,
|
|
25
|
+
INDEX_INTERNAL_TENANT_ID
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# debugId=27171696725F807764756E2164756E21
|
|
29
|
+
//# sourceMappingURL=index-internal-auth.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index-internal-auth.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// Internal service credential for first-party consumers of /v1/index over HTTP\n// (e.g. the subgraph processor's PublicApiBlockSource). Seeded into the Index\n// token store as an enterprise tenant with NO account_id, so these reads are\n// unmetered (Index metering gates on account_id). Mirrors the Streams internal\n// key (packages/indexer/src/l2/internal-auth.ts). Lives in shared so both the\n// API (seed) and the subgraph processor (consumer) import it without a cycle.\nexport const INDEX_INTERNAL_TENANT_ID = \"tenant_index_internal\";\n\nconst DEFAULT_INDEX_INTERNAL_API_KEY = \"sk-sl_index_internal\";\n\nexport function defaultInternalIndexApiKey(): string {\n\treturn process.env.INDEX_INTERNAL_API_KEY || DEFAULT_INDEX_INTERNAL_API_KEY;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAMO,IAAM,2BAA2B;AAExC,IAAM,iCAAiC;AAEhC,SAAS,0BAA0B,GAAW;AAAA,EACpD,OAAO,QAAQ,IAAI,0BAA0B;AAAA;",
|
|
8
|
+
"debugId": "27171696725F807764756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|