@secondlayer/shared 11.7.0 → 11.8.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/archive/copy-loader.d.ts +1 -1
- package/dist/src/archive/copy-loader.js +4 -20
- package/dist/src/archive/copy-loader.js.map +2 -2
- package/dist/src/archive/derived-stage-report.d.ts +1 -1
- package/dist/src/archive/derived-stage-report.js +3 -19
- package/dist/src/archive/derived-stage-report.js.map +2 -2
- package/dist/src/archive/disk-guard.d.ts +1 -1
- package/dist/src/archive/disk-guard.js +3 -19
- package/dist/src/archive/disk-guard.js.map +2 -2
- package/dist/src/archive/instance-diagnosis.d.ts +1 -1
- package/dist/src/archive/instance-diagnosis.js +6 -22
- package/dist/src/archive/instance-diagnosis.js.map +2 -2
- package/dist/src/archive/key-registry.d.ts +1 -1
- package/dist/src/archive/key-registry.js +12 -12
- package/dist/src/archive/key-registry.js.map +1 -1
- package/dist/src/archive/per-height-digest.d.ts +1 -1
- package/dist/src/archive/per-height-digest.js +3 -17
- package/dist/src/archive/per-height-digest.js.map +5 -5
- package/dist/src/archive/progress.d.ts +1 -1
- package/dist/src/archive/progress.js +4 -20
- package/dist/src/archive/progress.js.map +2 -2
- package/dist/src/archive/range-digest.d.ts +25 -30
- package/dist/src/archive/range-digest.js +4 -20
- package/dist/src/archive/range-digest.js.map +2 -2
- package/dist/src/archive/reference.d.ts +1 -1
- package/dist/src/archive/reference.js +14 -12
- package/dist/src/archive/reference.js.map +5 -5
- package/dist/src/archive/root-key.d.ts +1 -1
- package/dist/src/archive/root-key.js +3 -19
- package/dist/src/archive/root-key.js.map +2 -2
- package/dist/src/archive/semantic-digest-builder.d.ts +25 -30
- package/dist/src/archive/semantic-digest-builder.js +5 -19
- package/dist/src/archive/semantic-digest-builder.js.map +5 -5
- package/dist/src/archive/semantic-digest.d.ts +1 -1
- package/dist/src/archive/semantic-digest.js +4 -20
- package/dist/src/archive/semantic-digest.js.map +2 -2
- package/dist/src/archive/status.d.ts +1 -1
- package/dist/src/archive/status.js +4 -20
- package/dist/src/archive/status.js.map +2 -2
- package/dist/src/coverage/index.d.ts +24 -29
- package/dist/src/coverage/index.js +80 -96
- package/dist/src/coverage/index.js.map +2 -2
- package/dist/src/crypto/ed25519.d.ts +1 -1
- package/dist/src/crypto/ed25519.js +13 -13
- package/dist/src/crypto/ed25519.js.map +1 -1
- package/dist/src/crypto/hmac.d.ts +1 -1
- package/dist/src/crypto/hmac.js +9 -9
- package/dist/src/crypto/hmac.js.map +1 -1
- package/dist/src/crypto/secondlayer-webhook.d.ts +1 -1
- package/dist/src/crypto/secondlayer-webhook.js +14 -14
- package/dist/src/crypto/secondlayer-webhook.js.map +2 -2
- package/dist/src/crypto/secrets.d.ts +1 -1
- package/dist/src/crypto/secrets.js +15 -29
- package/dist/src/crypto/secrets.js.map +5 -5
- package/dist/src/crypto/standard-webhooks.d.ts +1 -1
- package/dist/src/crypto/standard-webhooks.js +3 -19
- package/dist/src/crypto/standard-webhooks.js.map +2 -2
- package/dist/src/db/index.d.ts +46 -57
- package/dist/src/db/index.js +42 -58
- package/dist/src/db/index.js.map +6 -6
- package/dist/src/db/jsonb.d.ts +1 -1
- package/dist/src/db/jsonb.js +3 -19
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/chain-reorgs.d.ts +24 -29
- package/dist/src/db/queries/chain-reorgs.js +29 -45
- package/dist/src/db/queries/chain-reorgs.js.map +6 -6
- package/dist/src/db/queries/contracts.d.ts +24 -29
- package/dist/src/db/queries/contracts.js +9 -23
- package/dist/src/db/queries/contracts.js.map +5 -5
- package/dist/src/db/queries/instance.d.ts +24 -29
- package/dist/src/db/queries/instance.js +7 -23
- package/dist/src/db/queries/instance.js.map +2 -2
- package/dist/src/db/queries/integrity.d.ts +25 -30
- package/dist/src/db/queries/integrity.js +8 -23
- package/dist/src/db/queries/integrity.js.map +3 -3
- package/dist/src/db/queries/subgraph-gaps.d.ts +24 -29
- package/dist/src/db/queries/subgraph-gaps.js +5 -21
- package/dist/src/db/queries/subgraph-gaps.js.map +2 -2
- package/dist/src/db/queries/subgraph-operations.d.ts +24 -29
- package/dist/src/db/queries/subgraph-operations.js +17 -33
- package/dist/src/db/queries/subgraph-operations.js.map +2 -2
- package/dist/src/db/queries/subgraphs.d.ts +23 -44
- package/dist/src/db/queries/subgraphs.js +15 -46
- package/dist/src/db/queries/subgraphs.js.map +5 -5
- package/dist/src/db/queries/sync-scope.d.ts +24 -29
- package/dist/src/db/queries/sync-scope.js +6 -22
- package/dist/src/db/queries/sync-scope.js.map +2 -2
- package/dist/src/db/queries/webhooks.d.ts +24 -29
- package/dist/src/db/queries/webhooks.js +54 -50
- package/dist/src/db/queries/webhooks.js.map +5 -5
- package/dist/src/db/schema.d.ts +27 -37
- package/dist/src/env.d.ts +1 -1
- package/dist/src/env.js +7 -23
- package/dist/src/env.js.map +2 -2
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/errors.js +15 -31
- package/dist/src/errors.js.map +2 -2
- package/dist/src/index-http.d.ts +1 -1
- package/dist/src/index-http.js +3 -19
- package/dist/src/index-http.js.map +2 -2
- package/dist/src/index-internal-auth.d.ts +1 -1
- package/dist/src/index-internal-auth.js +7 -23
- package/dist/src/index-internal-auth.js.map +2 -2
- package/dist/src/index.d.ts +164 -187
- package/dist/src/index.js +261 -316
- package/dist/src/index.js.map +13 -13
- package/dist/src/leader.d.ts +1 -1
- package/dist/src/leader.js +7 -21
- package/dist/src/leader.js.map +5 -5
- package/dist/src/logger.js +1 -17
- package/dist/src/logger.js.map +2 -2
- package/dist/src/mode.d.ts +1 -1
- package/dist/src/mode.js +5 -21
- package/dist/src/mode.js.map +2 -2
- package/dist/src/node/archive-client.d.ts +1 -1
- package/dist/src/node/archive-client.js +9 -23
- package/dist/src/node/archive-client.js.map +5 -5
- package/dist/src/node/client.d.ts +1 -1
- package/dist/src/node/client.js +4 -18
- package/dist/src/node/client.js.map +5 -5
- package/dist/src/node/consensus.d.ts +1 -1
- package/dist/src/node/consensus.js +5 -21
- package/dist/src/node/consensus.js.map +2 -2
- package/dist/src/node/hiro-client.d.ts +1 -1
- package/dist/src/node/hiro-client.js +1 -17
- package/dist/src/node/hiro-client.js.map +2 -2
- package/dist/src/node/hiro-pg-client.js +1 -17
- package/dist/src/node/hiro-pg-client.js.map +2 -2
- package/dist/src/node/local-client.d.ts +24 -29
- package/dist/src/node/local-client.js +3 -19
- package/dist/src/node/local-client.js.map +2 -2
- package/dist/src/node/nakamoto.d.ts +1 -1
- package/dist/src/node/nakamoto.js +12 -28
- package/dist/src/node/nakamoto.js.map +2 -2
- package/dist/src/queue/listener.d.ts +1 -1
- package/dist/src/queue/listener.js +4 -20
- package/dist/src/queue/listener.js.map +2 -2
- package/dist/src/runtime/index.d.ts +1 -1
- package/dist/src/runtime/index.js +51 -67
- package/dist/src/runtime/index.js.map +2 -2
- package/dist/src/schemas/index.d.ts +1 -4
- package/dist/src/schemas/index.js +19 -37
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subgraphs.d.ts +1 -4
- package/dist/src/schemas/subgraphs.js +1 -18
- package/dist/src/schemas/subgraphs.js.map +3 -3
- package/dist/src/schemas/webhooks.d.ts +1 -1
- package/dist/src/schemas/webhooks.js +21 -37
- package/dist/src/schemas/webhooks.js.map +2 -2
- package/dist/src/streams-bulk-manifest.d.ts +1 -1
- package/dist/src/streams-bulk-manifest.js +9 -9
- package/dist/src/streams-bulk-manifest.js.map +1 -1
- package/dist/src/streams-rows/index.d.ts +1 -1
- package/dist/src/streams-rows/index.js +32 -48
- package/dist/src/streams-rows/index.js.map +2 -2
- package/dist/src/subgraphs/spec.d.ts +1 -11
- package/dist/src/subgraphs/spec.js +27 -93
- package/dist/src/subgraphs/spec.js.map +3 -3
- package/dist/src/types.d.ts +1 -1
- package/migrations/0134_waitlists.ts +64 -0
- package/migrations/0135_drop_hosted_play_and_meters.ts +58 -0
- package/migrations/0136_drop_subgraph_visibility.ts +34 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Kysely } from \"kysely\";\nimport type { BootstrapSource, SyncScope } from \"../../coverage/evaluate.ts\";\nimport type { Database } from \"../types.ts\";\n\n/**\n * The instance's declared sync scope.\n *\n * An instance that starts at height N is not an instance missing the first N\n * blocks — but nothing in the schema said so, so every consumer had to guess\n * from `MIN(height)`. `sync_scopes` records the declaration; this module is the\n * only place that reads it, and it always answers in the `SyncScope` shape the\n * coverage evaluator consumes.\n *\n * `resolveSyncScope` never fails on an instance that predates the table: with\n * no row it derives a scope from what the database already shows, so an\n * existing install keeps working without a backfill dance.\n */\n\n/**\n * Declares a forward-only instance: history below this height is deliberately\n * absent, not lost. Read only when no `sync_scopes` row exists — a recorded\n * scope always wins, because it is the one an operator committed to.\n */\nexport const SYNC_START_HEIGHT_ENV = \"SECONDLAYER_SYNC_START_HEIGHT\";\n\nexport class InvalidSyncStartHeightError extends Error {\n\treadonly name = \"InvalidSyncStartHeightError\";\n\tconstructor(readonly value: string) {\n\t\tsuper(\n\t\t\t`${SYNC_START_HEIGHT_ENV} must be a non-negative integer (got ${value})`,\n\t\t);\n\t}\n}\n\n/**\n * Throws rather than ignoring a malformed value: a typo'd start height that\n * silently falls back to genesis would report a real forward-only instance as\n * an 8M-block gap, which is the exact confusion this table exists to end.\n */\nexport function syncStartHeightFromEnv(\n\tenv: NodeJS.ProcessEnv = process.env,\n): number | null {\n\tconst raw = env[SYNC_START_HEIGHT_ENV];\n\tif (raw === undefined || raw.trim() === \"\") return null;\n\tconst height = Number(raw.trim());\n\tif (!Number.isInteger(height) || height < 0) {\n\t\tthrow new InvalidSyncStartHeightError(raw);\n\t}\n\treturn height;\n}\n\nfunction toScope(row: {\n\tnetwork: string;\n\tstart_height: number | string;\n\ttarget_height: number | string | null;\n\tbootstrap_source: BootstrapSource;\n\tbootstrap_manifest_digest: string | null;\n\tgenesis_hash: string | null;\n}): SyncScope {\n\treturn {\n\t\tnetwork: row.network,\n\t\tstart_height: Number(row.start_height),\n\t\ttarget_height:\n\t\t\trow.target_height === null ? null : Number(row.target_height),\n\t\tbootstrap: {\n\t\t\tsource: row.bootstrap_source,\n\t\t\tmanifest_digest: row.bootstrap_manifest_digest,\n\t\t\tgenesis_hash: row.genesis_hash,\n\t\t},\n\t};\n}\n\nexport async function getSyncScope(\n\tdb: Kysely<Database>,\n\tnetwork: string,\n): Promise<SyncScope | null> {\n\tconst row = await db\n\t\t.selectFrom(\"sync_scopes\")\n\t\t.select([\n\t\t\t\"network\",\n\t\t\t\"start_height\",\n\t\t\t\"target_height\",\n\t\t\t\"bootstrap_source\",\n\t\t\t\"bootstrap_manifest_digest\",\n\t\t\t\"genesis_hash\",\n\t\t])\n\t\t.where(\"network\", \"=\", network)\n\t\t.executeTakeFirst();\n\treturn row ? toScope(row) : null;\n}\n\n/**\n * Record (or restate) the scope for a network. Bootstrap and re-bootstrap are\n * the writers; the upsert is idempotent so re-running a restore over the same\n * archive does not fork the declaration.\n */\nexport async function upsertSyncScope(\n\tdb: Kysely<Database>,\n\tscope: SyncScope,\n): Promise<SyncScope> {\n\tconst row = await db\n\t\t.insertInto(\"sync_scopes\")\n\t\t.values({\n\t\t\tnetwork: scope.network,\n\t\t\tstart_height: scope.start_height,\n\t\t\ttarget_height: scope.target_height,\n\t\t\tbootstrap_source: scope.bootstrap.source,\n\t\t\tbootstrap_manifest_digest: scope.bootstrap.manifest_digest,\n\t\t\tgenesis_hash: scope.bootstrap.genesis_hash,\n\t\t})\n\t\t.onConflict((oc) =>\n\t\t\toc.column(\"network\").doUpdateSet({\n\t\t\t\tstart_height: scope.start_height,\n\t\t\t\ttarget_height: scope.target_height,\n\t\t\t\tbootstrap_source: scope.bootstrap.source,\n\t\t\t\tbootstrap_manifest_digest: scope.bootstrap.manifest_digest,\n\t\t\t\tgenesis_hash: scope.bootstrap.genesis_hash,\n\t\t\t\tupdated_at: new Date(),\n\t\t\t}),\n\t\t)\n\t\t.returning([\n\t\t\t\"network\",\n\t\t\t\"start_height\",\n\t\t\t\"target_height\",\n\t\t\t\"bootstrap_source\",\n\t\t\t\"bootstrap_manifest_digest\",\n\t\t\t\"genesis_hash\",\n\t\t])\n\t\t.executeTakeFirstOrThrow();\n\treturn toScope(row);\n}\n\n/**\n * The persisted scope, or one derived from the database when none was ever\n * recorded.\n *\n * The derivation is deliberately conservative: it claims only what the data\n * already shows (the lowest canonical block, the genesis hash if genesis is\n * present) and never invents provenance — an instance whose history starts\n * above genesis with no recorded bootstrap is an `import`, not an archive\n * restore we can vouch for.\n */\nexport async function resolveSyncScope(\n\tdb: Kysely<Database>,\n\tnetwork: string,\n): Promise<SyncScope> {\n\tconst persisted = await getSyncScope(db, network);\n\tif (persisted) return persisted;\n\n\tconst declaredStart = syncStartHeightFromEnv();\n\tconst lowest = await db\n\t\t.selectFrom(\"blocks\")\n\t\t.select(({ fn }) => fn.min(\"height\").as(\"min\"))\n\t\t.where(\"canonical\", \"=\", true)\n\t\t.executeTakeFirst();\n\tconst lowestStored =\n\t\tlowest?.min === null || lowest?.min === undefined\n\t\t\t? null\n\t\t\t: Number(lowest.min);\n\tconst startHeight = declaredStart ?? lowestStored ?? 0;\n\n\tconst genesis =\n\t\tstartHeight === 0\n\t\t\t? await db\n\t\t\t\t\t.selectFrom(\"blocks\")\n\t\t\t\t\t.select(\"hash\")\n\t\t\t\t\t.where(\"canonical\", \"=\", true)\n\t\t\t\t\t.where(\"height\", \"=\", 0)\n\t\t\t\t\t.executeTakeFirst()\n\t\t\t: undefined;\n\n\treturn {\n\t\tnetwork,\n\t\tstart_height: startHeight,\n\t\ttarget_height: null,\n\t\tbootstrap: {\n\t\t\tsource: startHeight === 0 ? \"genesis\" : \"import\",\n\t\t\tmanifest_digest: null,\n\t\t\tgenesis_hash: genesis?.hash ?? null,\n\t\t},\n\t};\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAuB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,YAAY;AAAA,MACxC,iBAAiB;AAAA,MACjB,cAAc,SAAS,QAAQ;AAAA,IAChC;AAAA,EACD;AAAA;",
|
|
8
|
+
"debugId": "0BAF9C1F28590E5C64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -153,7 +153,6 @@ interface SubgraphsTable {
|
|
|
153
153
|
handler_code: string | null;
|
|
154
154
|
source_code: string | null;
|
|
155
155
|
project_id: string | null;
|
|
156
|
-
visibility: Generated<string>;
|
|
157
156
|
/** Paid (wallet-ghost) deploys expire unless renewed or claimed; NULL = no expiry. */
|
|
158
157
|
expires_at: Date | null;
|
|
159
158
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
@@ -284,21 +283,6 @@ interface MagicLinksTable {
|
|
|
284
283
|
failed_attempts: Generated<number>;
|
|
285
284
|
created_at: Generated<Date>;
|
|
286
285
|
}
|
|
287
|
-
/** One-shot hashed tokens that attach a play ghost to an email at claim. */
|
|
288
|
-
interface ClaimTokensTable {
|
|
289
|
-
id: Generated<string>;
|
|
290
|
-
account_id: string;
|
|
291
|
-
token_hash: string;
|
|
292
|
-
created_at: Generated<Date>;
|
|
293
|
-
expires_at: Date;
|
|
294
|
-
used_at: Date | null;
|
|
295
|
-
}
|
|
296
|
-
/** 3 play provisions per IP per UTC day. PK (ip_hash, day); `count` caps at 3. */
|
|
297
|
-
interface PlayProvisionsTable {
|
|
298
|
-
ip_hash: string;
|
|
299
|
-
day: string;
|
|
300
|
-
count: Generated<number>;
|
|
301
|
-
}
|
|
302
286
|
interface SubgraphProcessingStatsTable {
|
|
303
287
|
id: Generated<string>;
|
|
304
288
|
subgraph_name: string;
|
|
@@ -760,8 +744,6 @@ interface Database {
|
|
|
760
744
|
accounts: AccountsTable;
|
|
761
745
|
sessions: SessionsTable;
|
|
762
746
|
magic_links: MagicLinksTable;
|
|
763
|
-
claim_tokens: ClaimTokensTable;
|
|
764
|
-
play_provisions: PlayProvisionsTable;
|
|
765
747
|
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
766
748
|
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
767
749
|
subgraph_gaps: SubgraphGapsTable;
|
|
@@ -770,7 +752,6 @@ interface Database {
|
|
|
770
752
|
processed_stripe_events: ProcessedStripeEventsTable;
|
|
771
753
|
account_spend_caps: AccountSpendCapsTable;
|
|
772
754
|
account_credits: AccountCreditsTable;
|
|
773
|
-
hosted_meter_days: HostedMeterDaysTable;
|
|
774
755
|
webhooks: WebhooksTable;
|
|
775
756
|
webhook_outbox: WebhookOutboxTable;
|
|
776
757
|
webhook_deliveries: WebhookDeliveriesTable;
|
|
@@ -801,6 +782,8 @@ interface Database {
|
|
|
801
782
|
coverage_segments: CoverageSegmentsTable;
|
|
802
783
|
stage_failures: StageFailuresTable;
|
|
803
784
|
archive_fetches: ArchiveFetchesTable;
|
|
785
|
+
waitlists: WaitlistsTable;
|
|
786
|
+
waitlist_signups: WaitlistSignupsTable;
|
|
804
787
|
}
|
|
805
788
|
interface ServiceHeartbeatsTable {
|
|
806
789
|
name: string;
|
|
@@ -829,15 +812,6 @@ interface AccountCreditsTable {
|
|
|
829
812
|
refill_last_at: Date | null;
|
|
830
813
|
updated_at: Generated<Date>;
|
|
831
814
|
}
|
|
832
|
-
/** Daily idempotency ledger for hosted subgraph running + storage meters. */
|
|
833
|
-
interface HostedMeterDaysTable {
|
|
834
|
-
day: string;
|
|
835
|
-
account_id: string;
|
|
836
|
-
subgraph_name: string;
|
|
837
|
-
kind: string;
|
|
838
|
-
usd_micros: string | number | bigint;
|
|
839
|
-
billed_at: Generated<Date>;
|
|
840
|
-
}
|
|
841
815
|
/**
|
|
842
816
|
* Archive fetch charge log (design-f089 gate). Append-only: one row per
|
|
843
817
|
* priced attempt to fetch a partition object. `usd_micros` is 0 for
|
|
@@ -941,6 +915,27 @@ interface TriggerEvaluatorStateTable {
|
|
|
941
915
|
last_settlement_scan_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
|
|
942
916
|
updated_at: Generated<Date>;
|
|
943
917
|
}
|
|
918
|
+
/** A public waitlist page: what it is for and whether it takes signups. */
|
|
919
|
+
interface WaitlistsTable {
|
|
920
|
+
slug: string;
|
|
921
|
+
title: string;
|
|
922
|
+
description: string;
|
|
923
|
+
url: string;
|
|
924
|
+
opened_at: Generated<Date>;
|
|
925
|
+
/** Null while the list is open. */
|
|
926
|
+
closed_at: Date | null;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* One signup per (list, contact, token). `answers` holds the list's own
|
|
930
|
+
* questions, validated per list by the API before insert.
|
|
931
|
+
*/
|
|
932
|
+
interface WaitlistSignupsTable {
|
|
933
|
+
id: Generated<string>;
|
|
934
|
+
list: string;
|
|
935
|
+
contact: string;
|
|
936
|
+
answers: Record<string, unknown>;
|
|
937
|
+
created_at: Generated<Date>;
|
|
938
|
+
}
|
|
944
939
|
/**
|
|
945
940
|
* Webhook CRUD. `signing_secret_enc` is transparently encrypted via
|
|
946
941
|
* `encryptSecret`/`decryptSecret`. Plaintext secrets only leave via the
|
|
@@ -1008,4 +1003,4 @@ declare function rotateWebhookSecret(db: Kysely<Database>, accountId: string, id
|
|
|
1008
1003
|
declare function getWebhookSigningSecret(webhook: Webhook): string;
|
|
1009
1004
|
/** Fire `webhooks:changed` notify so the emitter hot-reloads its cache. */
|
|
1010
1005
|
declare function notifyWebhooksChanged(db: Kysely<Database>, accountId: string): Promise<void>;
|
|
1011
|
-
export {
|
|
1006
|
+
export { CreateWebhookInput, CreateWebhookResult, RotateSecretResult, UpdateWebhookInput, createWebhook, deleteWebhook, getWebhook, getWebhookByName, getWebhookSigningSecret, listActiveChainWebhooks, listWebhooks, notifyWebhooksChanged, rotateWebhookSecret, toggleWebhookStatus, updateWebhook };
|
|
@@ -14,49 +14,17 @@ var __export = (target, all) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
// src/
|
|
18
|
-
|
|
19
|
-
"oss",
|
|
20
|
-
"platform",
|
|
21
|
-
"archive"
|
|
22
|
-
];
|
|
23
|
-
function declaredMode() {
|
|
24
|
-
const raw = process.env.INSTANCE_MODE?.trim().toLowerCase();
|
|
25
|
-
if (raw && VALID_MODES.includes(raw)) {
|
|
26
|
-
return raw;
|
|
27
|
-
}
|
|
28
|
-
return "oss";
|
|
29
|
-
}
|
|
30
|
-
function getInstanceMode() {
|
|
31
|
-
const declared = declaredMode();
|
|
32
|
-
return declared === "archive" ? "platform" : declared;
|
|
33
|
-
}
|
|
34
|
-
function getDeclaredInstanceMode() {
|
|
35
|
-
return declaredMode();
|
|
36
|
-
}
|
|
37
|
-
function isMeteredReads() {
|
|
38
|
-
const override = process.env.METERED_READS?.trim().toLowerCase();
|
|
39
|
-
if (override === "true")
|
|
40
|
-
return true;
|
|
41
|
-
if (override === "false")
|
|
42
|
-
return false;
|
|
43
|
-
return getInstanceMode() === "platform";
|
|
44
|
-
}
|
|
45
|
-
function isPlatformMode() {
|
|
46
|
-
return getInstanceMode() === "platform";
|
|
47
|
-
}
|
|
48
|
-
function isOssMode() {
|
|
49
|
-
return getInstanceMode() === "oss";
|
|
50
|
-
}
|
|
17
|
+
// src/db/queries/webhooks.ts
|
|
18
|
+
import { sql } from "kysely";
|
|
51
19
|
|
|
52
20
|
// src/crypto/hmac.ts
|
|
53
21
|
var exports_hmac = {};
|
|
54
22
|
__export(exports_hmac, {
|
|
55
|
-
|
|
56
|
-
verifySignature: () => verifySignature,
|
|
57
|
-
signPayload: () => signPayload,
|
|
23
|
+
createSignatureHeader: () => createSignatureHeader,
|
|
58
24
|
generateSecret: () => generateSecret,
|
|
59
|
-
|
|
25
|
+
signPayload: () => signPayload,
|
|
26
|
+
verifySignature: () => verifySignature,
|
|
27
|
+
verifySignatureHeader: () => verifySignatureHeader
|
|
60
28
|
});
|
|
61
29
|
import { createHmac, randomBytes } from "node:crypto";
|
|
62
30
|
function generateSecret() {
|
|
@@ -114,6 +82,43 @@ import {
|
|
|
114
82
|
unlinkSync
|
|
115
83
|
} from "node:fs";
|
|
116
84
|
import { resolve } from "node:path";
|
|
85
|
+
|
|
86
|
+
// src/mode.ts
|
|
87
|
+
var VALID_MODES = [
|
|
88
|
+
"oss",
|
|
89
|
+
"platform",
|
|
90
|
+
"archive"
|
|
91
|
+
];
|
|
92
|
+
function declaredMode() {
|
|
93
|
+
const raw = process.env.INSTANCE_MODE?.trim().toLowerCase();
|
|
94
|
+
if (raw && VALID_MODES.includes(raw)) {
|
|
95
|
+
return raw;
|
|
96
|
+
}
|
|
97
|
+
return "oss";
|
|
98
|
+
}
|
|
99
|
+
function getInstanceMode() {
|
|
100
|
+
const declared = declaredMode();
|
|
101
|
+
return declared === "archive" ? "platform" : declared;
|
|
102
|
+
}
|
|
103
|
+
function getDeclaredInstanceMode() {
|
|
104
|
+
return declaredMode();
|
|
105
|
+
}
|
|
106
|
+
function isMeteredReads() {
|
|
107
|
+
const override = process.env.METERED_READS?.trim().toLowerCase();
|
|
108
|
+
if (override === "true")
|
|
109
|
+
return true;
|
|
110
|
+
if (override === "false")
|
|
111
|
+
return false;
|
|
112
|
+
return getInstanceMode() === "platform";
|
|
113
|
+
}
|
|
114
|
+
function isPlatformMode() {
|
|
115
|
+
return getInstanceMode() === "platform";
|
|
116
|
+
}
|
|
117
|
+
function isOssMode() {
|
|
118
|
+
return getInstanceMode() === "oss";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/crypto/secrets.ts
|
|
117
122
|
var KEY_ENV = "SECONDLAYER_SECRETS_KEY";
|
|
118
123
|
var IV_LEN = 12;
|
|
119
124
|
var TAG_LEN = 16;
|
|
@@ -228,7 +233,6 @@ function generateSecretsKey() {
|
|
|
228
233
|
}
|
|
229
234
|
|
|
230
235
|
// src/db/queries/webhooks.ts
|
|
231
|
-
import { sql } from "kysely";
|
|
232
236
|
async function createWebhook(db, input) {
|
|
233
237
|
const signingSecret = generateSecret();
|
|
234
238
|
const kind = input.kind ?? "subgraph";
|
|
@@ -344,18 +348,18 @@ async function notifyWebhooksChanged(db, accountId) {
|
|
|
344
348
|
await sql`SELECT pg_notify('webhooks:changed', ${accountId})`.execute(db);
|
|
345
349
|
}
|
|
346
350
|
export {
|
|
347
|
-
|
|
348
|
-
toggleWebhookStatus,
|
|
349
|
-
rotateWebhookSecret,
|
|
350
|
-
notifyWebhooksChanged,
|
|
351
|
-
listWebhooks,
|
|
352
|
-
listActiveChainWebhooks,
|
|
353
|
-
getWebhookSigningSecret,
|
|
354
|
-
getWebhookByName,
|
|
355
|
-
getWebhook,
|
|
351
|
+
createWebhook,
|
|
356
352
|
deleteWebhook,
|
|
357
|
-
|
|
353
|
+
getWebhook,
|
|
354
|
+
getWebhookByName,
|
|
355
|
+
getWebhookSigningSecret,
|
|
356
|
+
listActiveChainWebhooks,
|
|
357
|
+
listWebhooks,
|
|
358
|
+
notifyWebhooksChanged,
|
|
359
|
+
rotateWebhookSecret,
|
|
360
|
+
toggleWebhookStatus,
|
|
361
|
+
updateWebhook
|
|
358
362
|
};
|
|
359
363
|
|
|
360
|
-
//# debugId=
|
|
364
|
+
//# debugId=0300624A605962A764756E2164756E21
|
|
361
365
|
//# sourceMappingURL=webhooks.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/
|
|
3
|
+
"sources": ["../src/db/queries/webhooks.ts", "../src/crypto/hmac.ts", "../src/crypto/secrets.ts", "../src/mode.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"
|
|
5
|
+
"import { type Kysely, sql } from \"kysely\";\nimport { generateSecret } from \"../../crypto/hmac.ts\";\nimport { decryptSecret, encryptSecret } from \"../../crypto/secrets.ts\";\nimport { isPlatformMode } from \"../../mode.ts\";\nimport type {\n\tDatabase,\n\tInsertWebhook,\n\tUpdateWebhook,\n\tWebhook,\n\tWebhookFormat,\n\tWebhookKind,\n\tWebhookRuntime,\n\tWebhookStatus,\n} from \"../types.ts\";\n\n/**\n * Webhook 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 CreateWebhookInput {\n\taccountId: string;\n\tprojectId?: string | null;\n\tname: string;\n\t/** Defaults to \"subgraph\". Chain webhooks set kind=\"chain\" + triggers. */\n\tkind?: WebhookKind;\n\t/** Required for subgraph webhooks; omitted for chain. */\n\tsubgraphName?: string | null;\n\t/** Required for subgraph webhooks; omitted for chain. */\n\ttableName?: string | null;\n\t/** Chain-trigger filter array. Required for chain webhooks. */\n\ttriggers?: unknown;\n\tfilter?: unknown;\n\tformat?: WebhookFormat;\n\truntime?: WebhookRuntime | null;\n\turl: string;\n\tauthConfig?: unknown;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport interface CreateWebhookResult {\n\twebhook: Webhook;\n\t/** Plaintext signing secret — surfaced once, never stored decrypted. */\n\tsigningSecret: string;\n}\n\nexport async function createWebhook(\n\tdb: Kysely<Database>,\n\tinput: CreateWebhookInput,\n): Promise<CreateWebhookResult> {\n\tconst signingSecret = generateSecret();\n\tconst kind: WebhookKind = input.kind ?? \"subgraph\";\n\tconst row: InsertWebhook = {\n\t\taccount_id: isPlatformMode() ? 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 webhook = await db\n\t\t.insertInto(\"webhooks\")\n\t\t.values(row)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n\treturn { webhook, signingSecret };\n}\n\nexport async function listWebhooks(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\topts?: { limit?: number; offset?: number },\n): Promise<Webhook[]> {\n\tlet q = db.selectFrom(\"webhooks\").selectAll().orderBy(\"created_at\", \"desc\");\n\tif (isPlatformMode()) q = q.where(\"account_id\", \"=\", accountId);\n\tif (opts?.limit !== undefined) q = q.limit(opts.limit);\n\tif (opts?.offset !== undefined) q = q.offset(opts.offset);\n\treturn q.execute();\n}\n\n/**\n * All active chain webhooks across every account — the input to the global\n * trigger evaluator (one loop serves them all). Subgraph webhooks are\n * excluded; they emit via the subgraph flush path.\n */\nexport async function listActiveChainWebhooks(\n\tdb: Kysely<Database>,\n): Promise<Webhook[]> {\n\treturn db\n\t\t.selectFrom(\"webhooks\")\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 getWebhook(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n): Promise<Webhook | null> {\n\tlet q = db.selectFrom(\"webhooks\").selectAll().where(\"id\", \"=\", id);\n\tif (isPlatformMode()) q = q.where(\"account_id\", \"=\", accountId);\n\treturn (await q.executeTakeFirst()) ?? null;\n}\n\nexport async function getWebhookByName(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tname: string,\n): Promise<Webhook | null> {\n\tlet q = db.selectFrom(\"webhooks\").selectAll().where(\"name\", \"=\", name);\n\tif (isPlatformMode()) q = q.where(\"account_id\", \"=\", accountId);\n\treturn (await q.executeTakeFirst()) ?? null;\n}\n\nexport interface UpdateWebhookInput {\n\tname?: string;\n\tfilter?: unknown;\n\tformat?: WebhookFormat;\n\truntime?: WebhookRuntime | null;\n\turl?: string;\n\tauthConfig?: unknown;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport async function updateWebhook(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n\tpatch: UpdateWebhookInput,\n): Promise<Webhook | null> {\n\tconst update: UpdateWebhook = { 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\tlet q = db.updateTable(\"webhooks\").set(update).where(\"id\", \"=\", id);\n\tif (isPlatformMode()) q = q.where(\"account_id\", \"=\", accountId);\n\treturn (await q.returningAll().executeTakeFirst()) ?? null;\n}\n\nexport async function toggleWebhookStatus(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n\tstatus: WebhookStatus,\n): Promise<Webhook | null> {\n\tlet q = db\n\t\t.updateTable(\"webhooks\")\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(\"id\", \"=\", id);\n\tif (isPlatformMode()) q = q.where(\"account_id\", \"=\", accountId);\n\treturn (await q.returningAll().executeTakeFirst()) ?? null;\n}\n\nexport async function deleteWebhook(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n): Promise<boolean> {\n\tlet q = db.deleteFrom(\"webhooks\").where(\"id\", \"=\", id);\n\tif (isPlatformMode()) q = q.where(\"account_id\", \"=\", accountId);\n\tconst res = await q.executeTakeFirst();\n\treturn Number(res.numDeletedRows ?? 0) > 0;\n}\n\nexport interface RotateSecretResult {\n\twebhook: Webhook;\n\tsigningSecret: string;\n}\n\nexport async function rotateWebhookSecret(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tid: string,\n): Promise<RotateSecretResult | null> {\n\tconst signingSecret = generateSecret();\n\tlet q = db\n\t\t.updateTable(\"webhooks\")\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(\"id\", \"=\", id);\n\tif (isPlatformMode()) q = q.where(\"account_id\", \"=\", accountId);\n\tconst row = await q.returningAll().executeTakeFirst();\n\tif (!row) return null;\n\treturn { webhook: row, signingSecret };\n}\n\n/** Decrypt a webhook's signing secret for HMAC signing at emit time. */\nexport function getWebhookSigningSecret(webhook: Webhook): string {\n\treturn decryptSecret(webhook.signing_secret_enc);\n}\n\n/** Fire `webhooks:changed` notify so the emitter hot-reloads its cache. */\nexport async function notifyWebhooksChanged(\n\tdb: Kysely<Database>,\n\taccountId: string,\n): Promise<void> {\n\tawait sql`SELECT pg_notify('webhooks:changed', ${accountId})`.execute(db);\n}\n",
|
|
6
6
|
"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",
|
|
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 * webhook 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\n/**\n * Non-throwing check for whether a secrets key is currently resolvable —\n * same resolution order as {@link loadKey} (env var, then the OSS\n * `.env.local` fallback), but never bootstraps a new key (that would\n * generate+persist a key as a side effect of a mere existence check), never\n * throws, and never returns or logs the key itself. Used by callers that\n * need to fail loud on a missing key BEFORE attempting a decrypt (f072).\n */\nexport function secretsKeyAvailable(): boolean {\n\tif (process.env[KEY_ENV]) return true;\n\tif (getInstanceMode() === \"oss\") {\n\t\tconst envPath = resolve(process.cwd(), \".env.local\");\n\t\treturn readExistingKey(envPath) !== null;\n\t}\n\treturn false;\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
|
-
"
|
|
8
|
+
"/**\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`: the metered archive deployment. Magic-link auth, API keys,\n * accounts, credits, and metered `/v1` reads (Index + Streams + subgraphs)\n * against a single shared DB. No paid tier ladder — one metered `free`\n * tier plus first-party internal service credentials.\n */\n\nexport type InstanceMode = \"oss\" | \"platform\";\n\n/** What the operator wrote in the env — `archive` is the honest name for the\n * metered public-archive deployment and aliases `platform` behaviorally. */\nexport type DeclaredInstanceMode = InstanceMode | \"archive\";\n\nconst VALID_MODES: readonly DeclaredInstanceMode[] = [\n\t\"oss\",\n\t\"platform\",\n\t\"archive\",\n];\n\nfunction declaredMode(): DeclaredInstanceMode {\n\tconst raw = process.env.INSTANCE_MODE?.trim().toLowerCase();\n\tif (raw && (VALID_MODES as readonly string[]).includes(raw)) {\n\t\treturn raw as DeclaredInstanceMode;\n\t}\n\treturn \"oss\";\n}\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. `archive` normalizes to `platform` here so\n * every behavioral branch stays a two-way choice; use\n * `getDeclaredInstanceMode()` for display surfaces.\n */\nexport function getInstanceMode(): InstanceMode {\n\tconst declared = declaredMode();\n\treturn declared === \"archive\" ? \"platform\" : declared;\n}\n\n/** The mode as declared in the env, for status/identity surfaces. */\nexport function getDeclaredInstanceMode(): DeclaredInstanceMode {\n\treturn declaredMode();\n}\n\n/**\n * True when public reads are credit-metered (the free window, retention, and\n * credits gates arm). Platform/archive deployments meter by default;\n * self-host never does unless the operator explicitly sets\n * `METERED_READS=true`. `METERED_READS=false` disarms a metered deployment.\n */\nexport function isMeteredReads(): boolean {\n\tconst override = process.env.METERED_READS?.trim().toLowerCase();\n\tif (override === \"true\") return true;\n\tif (override === \"false\") return false;\n\treturn getInstanceMode() === \"platform\";\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"
|
|
9
9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ema.d.ts
CHANGED
|
@@ -152,7 +152,6 @@ interface SubgraphsTable {
|
|
|
152
152
|
handler_code: string | null;
|
|
153
153
|
source_code: string | null;
|
|
154
154
|
project_id: string | null;
|
|
155
|
-
visibility: Generated<string>;
|
|
156
155
|
/** Paid (wallet-ghost) deploys expire unless renewed or claimed; NULL = no expiry. */
|
|
157
156
|
expires_at: Date | null;
|
|
158
157
|
/** (event type, contract) probe pairs persisted at deploy for weight classification. */
|
|
@@ -283,21 +282,6 @@ interface MagicLinksTable {
|
|
|
283
282
|
failed_attempts: Generated<number>;
|
|
284
283
|
created_at: Generated<Date>;
|
|
285
284
|
}
|
|
286
|
-
/** One-shot hashed tokens that attach a play ghost to an email at claim. */
|
|
287
|
-
interface ClaimTokensTable {
|
|
288
|
-
id: Generated<string>;
|
|
289
|
-
account_id: string;
|
|
290
|
-
token_hash: string;
|
|
291
|
-
created_at: Generated<Date>;
|
|
292
|
-
expires_at: Date;
|
|
293
|
-
used_at: Date | null;
|
|
294
|
-
}
|
|
295
|
-
/** 3 play provisions per IP per UTC day. PK (ip_hash, day); `count` caps at 3. */
|
|
296
|
-
interface PlayProvisionsTable {
|
|
297
|
-
ip_hash: string;
|
|
298
|
-
day: string;
|
|
299
|
-
count: Generated<number>;
|
|
300
|
-
}
|
|
301
285
|
interface SubgraphProcessingStatsTable {
|
|
302
286
|
id: Generated<string>;
|
|
303
287
|
subgraph_name: string;
|
|
@@ -759,8 +743,6 @@ interface Database {
|
|
|
759
743
|
accounts: AccountsTable;
|
|
760
744
|
sessions: SessionsTable;
|
|
761
745
|
magic_links: MagicLinksTable;
|
|
762
|
-
claim_tokens: ClaimTokensTable;
|
|
763
|
-
play_provisions: PlayProvisionsTable;
|
|
764
746
|
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
765
747
|
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
766
748
|
subgraph_gaps: SubgraphGapsTable;
|
|
@@ -769,7 +751,6 @@ interface Database {
|
|
|
769
751
|
processed_stripe_events: ProcessedStripeEventsTable;
|
|
770
752
|
account_spend_caps: AccountSpendCapsTable;
|
|
771
753
|
account_credits: AccountCreditsTable;
|
|
772
|
-
hosted_meter_days: HostedMeterDaysTable;
|
|
773
754
|
webhooks: WebhooksTable;
|
|
774
755
|
webhook_outbox: WebhookOutboxTable;
|
|
775
756
|
webhook_deliveries: WebhookDeliveriesTable;
|
|
@@ -800,6 +781,8 @@ interface Database {
|
|
|
800
781
|
coverage_segments: CoverageSegmentsTable;
|
|
801
782
|
stage_failures: StageFailuresTable;
|
|
802
783
|
archive_fetches: ArchiveFetchesTable;
|
|
784
|
+
waitlists: WaitlistsTable;
|
|
785
|
+
waitlist_signups: WaitlistSignupsTable;
|
|
803
786
|
}
|
|
804
787
|
interface ServiceHeartbeatsTable {
|
|
805
788
|
name: string;
|
|
@@ -834,18 +817,6 @@ interface AccountCreditsTable {
|
|
|
834
817
|
type AccountCredits = Selectable<AccountCreditsTable>;
|
|
835
818
|
type InsertAccountCredits = Insertable<AccountCreditsTable>;
|
|
836
819
|
type UpdateAccountCredits = Updateable<AccountCreditsTable>;
|
|
837
|
-
/** Daily idempotency ledger for hosted subgraph running + storage meters. */
|
|
838
|
-
interface HostedMeterDaysTable {
|
|
839
|
-
day: string;
|
|
840
|
-
account_id: string;
|
|
841
|
-
subgraph_name: string;
|
|
842
|
-
kind: string;
|
|
843
|
-
usd_micros: string | number | bigint;
|
|
844
|
-
billed_at: Generated<Date>;
|
|
845
|
-
}
|
|
846
|
-
type HostedMeterDay = Selectable<HostedMeterDaysTable>;
|
|
847
|
-
type InsertHostedMeterDay = Insertable<HostedMeterDaysTable>;
|
|
848
|
-
type UpdateHostedMeterDay = Updateable<HostedMeterDaysTable>;
|
|
849
820
|
/**
|
|
850
821
|
* Archive fetch charge log (design-f089 gate). Append-only: one row per
|
|
851
822
|
* priced attempt to fetch a partition object. `usd_micros` is 0 for
|
|
@@ -896,11 +867,6 @@ type Account = Selectable<AccountsTable>;
|
|
|
896
867
|
type InsertAccount = Insertable<AccountsTable>;
|
|
897
868
|
type MagicLink = Selectable<MagicLinksTable>;
|
|
898
869
|
type InsertMagicLink = Insertable<MagicLinksTable>;
|
|
899
|
-
type ClaimToken = Selectable<ClaimTokensTable>;
|
|
900
|
-
type InsertClaimToken = Insertable<ClaimTokensTable>;
|
|
901
|
-
type UpdateClaimToken = Updateable<ClaimTokensTable>;
|
|
902
|
-
type PlayProvision = Selectable<PlayProvisionsTable>;
|
|
903
|
-
type InsertPlayProvision = Insertable<PlayProvisionsTable>;
|
|
904
870
|
type Session = Selectable<SessionsTable>;
|
|
905
871
|
type InsertSession = Insertable<SessionsTable>;
|
|
906
872
|
type SubgraphHealthSnapshot = Selectable<SubgraphHealthSnapshotsTable>;
|
|
@@ -1004,4 +970,28 @@ interface TriggerEvaluatorStateTable {
|
|
|
1004
970
|
updated_at: Generated<Date>;
|
|
1005
971
|
}
|
|
1006
972
|
type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
|
|
1007
|
-
|
|
973
|
+
/** A public waitlist page: what it is for and whether it takes signups. */
|
|
974
|
+
interface WaitlistsTable {
|
|
975
|
+
slug: string;
|
|
976
|
+
title: string;
|
|
977
|
+
description: string;
|
|
978
|
+
url: string;
|
|
979
|
+
opened_at: Generated<Date>;
|
|
980
|
+
/** Null while the list is open. */
|
|
981
|
+
closed_at: Date | null;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* One signup per (list, contact, token). `answers` holds the list's own
|
|
985
|
+
* questions, validated per list by the API before insert.
|
|
986
|
+
*/
|
|
987
|
+
interface WaitlistSignupsTable {
|
|
988
|
+
id: Generated<string>;
|
|
989
|
+
list: string;
|
|
990
|
+
contact: string;
|
|
991
|
+
answers: Record<string, unknown>;
|
|
992
|
+
created_at: Generated<Date>;
|
|
993
|
+
}
|
|
994
|
+
type Waitlist = Selectable<WaitlistsTable>;
|
|
995
|
+
type WaitlistSignup = Selectable<WaitlistSignupsTable>;
|
|
996
|
+
type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;
|
|
997
|
+
export { Account, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountCredits, InsertAccountSpendCap, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContract, InsertEvent, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, NativeClock, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RepairMode, RetryState, RunStatus, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, Subgraph, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookFormat, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookRuntime, WebhookStatus, WebhooksTable };
|
package/dist/src/env.d.ts
CHANGED
|
@@ -52,4 +52,4 @@ declare function isPox5DecoderEnabled(env?: EnvMap): boolean;
|
|
|
52
52
|
declare function isSbtcDecoderEnabled(env?: EnvMap): boolean;
|
|
53
53
|
/** Default OFF. Opt in with `BNS_DECODER_ENABLED=true`. */
|
|
54
54
|
declare function isBnsDecoderEnabled(env?: EnvMap): boolean;
|
|
55
|
-
export {
|
|
55
|
+
export { Env, envSchema, getEnv, isBnsDecoderEnabled, isPox4DecoderEnabled, isPox5DecoderEnabled, isProductionEnv, isSbtcDecoderEnabled };
|
package/dist/src/env.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
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
1
|
// src/env.ts
|
|
18
2
|
import { z } from "zod";
|
|
19
3
|
var networksSchema = z.string().transform((val) => {
|
|
@@ -73,14 +57,14 @@ function isBnsDecoderEnabled(env = process.env) {
|
|
|
73
57
|
return env.BNS_DECODER_ENABLED === "true";
|
|
74
58
|
}
|
|
75
59
|
export {
|
|
76
|
-
|
|
77
|
-
isProductionEnv,
|
|
78
|
-
isPox5DecoderEnabled,
|
|
79
|
-
isPox4DecoderEnabled,
|
|
80
|
-
isBnsDecoderEnabled,
|
|
60
|
+
envSchema,
|
|
81
61
|
getEnv,
|
|
82
|
-
|
|
62
|
+
isBnsDecoderEnabled,
|
|
63
|
+
isPox4DecoderEnabled,
|
|
64
|
+
isPox5DecoderEnabled,
|
|
65
|
+
isProductionEnv,
|
|
66
|
+
isSbtcDecoderEnabled
|
|
83
67
|
};
|
|
84
68
|
|
|
85
|
-
//# debugId=
|
|
69
|
+
//# debugId=09269FBBCC4C7B6B64756E2164756E21
|
|
86
70
|
//# sourceMappingURL=env.js.map
|
package/dist/src/env.js.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\ntype EnvMap = NodeJS.ProcessEnv;\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n/**\n * PoX-5 print-event decoder is ON by default (mirrors pox-4/sBTC policy).\n * No activation gating needed: pox-5 events cannot exist before the Epoch 4.0\n * hard fork (Bitcoin block 960,230), so pre-activation the decoder idles at\n * tip. Opt out with `POX5_DECODER_ENABLED=false`.\n */\nexport function isPox5DecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.POX5_DECODER_ENABLED !== \"false\";\n}\n\n/** Default ON. Opt out with `SBTC_DECODER_ENABLED=false`. */\nexport function isSbtcDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.SBTC_DECODER_ENABLED !== \"false\";\n}\n\n/** Default OFF. Opt in with `BNS_DECODER_ENABLED=true`. */\nexport function isBnsDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.BNS_DECODER_ENABLED === \"true\";\n}\n\n// Export for testing\nexport { envSchema };\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,CACP;AAsBD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACtD,cAAc,EAAE,WACf,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,SAAS,EAAE,KAAK,CAA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