@secondlayer/sdk 10.3.1 → 10.4.1

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/README.md CHANGED
@@ -21,7 +21,7 @@ const sl = new SecondLayer({
21
21
 
22
22
  Auth, once: `sl.index`, `sl.streams`, `sl.subgraphs.rows`, and the typed
23
23
  `subscribe` read `/v1`, which is open on loopback and needs `INSTANCE_TOKEN`
24
- once the API is bound beyond it. Everything under `sl.subgraphs.*` and `sl.subscriptions.*` calls
24
+ once the API is bound beyond it. Everything under `sl.subgraphs.*` and `sl.webhooks.*` calls
25
25
  `/api`, which needs `INSTANCE_TOKEN` as soon as one is configured, loopback
26
26
  included, and `secondlayer init` always configures one. Every client, including
27
27
  `createStreamsClient`, reads `INSTANCE_TOKEN` from the env when `apiKey` is
@@ -412,7 +412,7 @@ Exported types: `TransactionProof`, `TransactionProofVerifyResult`, `RewardSet`.
412
412
 
413
413
  Deploy and query app-specific tables.
414
414
 
415
- Subgraphs and subscriptions live on the instance API alongside Streams and Index. Everything here except `rows` and the typed `subscribe` calls `/api`, which needs `INSTANCE_TOKEN` once one is configured (init always configures one), loopback included.
415
+ Subgraphs and webhooks live on the instance API alongside Streams and Index. Everything here except `rows` and the typed `subscribe` calls `/api`, which needs `INSTANCE_TOKEN` once one is configured (init always configures one), loopback included.
416
416
 
417
417
  ```typescript
418
418
  // List
@@ -482,9 +482,11 @@ tail only. A dropped connection reconnects from the last delivered row's
482
482
  `_block_height`, so rows at that height can arrive twice: key durable writes
483
483
  by `_id`.
484
484
 
485
- ## Subscriptions
485
+ ## Webhooks
486
486
 
487
- Signed HTTP webhooks. Subscriptions are polymorphic — pick one kind:
487
+ Deprecated aliases (`sl.subscriptions`, `Subscriptions`) keep working for one release cycle.
488
+
489
+ Signed HTTP POSTs. Webhooks are polymorphic — pick one kind:
488
490
 
489
491
  - **subgraph** — fires on rows written to a deployed subgraph table.
490
492
  - **chain** — fires on raw chain events with no subgraph. Forward-looking: it
@@ -493,12 +495,12 @@ Signed HTTP webhooks. Subscriptions are polymorphic — pick one kind:
493
495
 
494
496
  ```typescript
495
497
  // List / get
496
- const { data } = await sl.subscriptions.list();
497
- const sub = await sl.subscriptions.get(id);
498
+ const { data } = await sl.webhooks.list();
499
+ const hook = await sl.webhooks.get(id);
498
500
 
499
- // Create a SUBGRAPH subscription — sink a subgraph table to a signed endpoint.
501
+ // Create a SUBGRAPH webhook — sink a subgraph table to a signed endpoint.
500
502
  // `signingSecret` is returned ONCE; store it in the receiver's env.
501
- const { subscription, signingSecret } = await sl.subscriptions.create({
503
+ const { webhook, signingSecret } = await sl.webhooks.create({
502
504
  name: "whale-alerts",
503
505
  subgraphName: "transfers",
504
506
  tableName: "events",
@@ -507,7 +509,7 @@ const { subscription, signingSecret } = await sl.subscriptions.create({
507
509
  });
508
510
  ```
509
511
 
510
- ### Chain subscriptions
512
+ ### Chain webhooks
511
513
 
512
514
  Pass `triggers` instead of `subgraphName`/`tableName`. The `trigger.*` builders
513
515
  are optional sugar — you can also pass raw objects (e.g.
@@ -521,7 +523,7 @@ import { SecondLayer, trigger } from "@secondlayer/sdk";
521
523
 
522
524
  const sl = new SecondLayer({ apiKey: process.env.INSTANCE_TOKEN });
523
525
 
524
- const { subscription, signingSecret } = await sl.subscriptions.create({
526
+ const { webhook, signingSecret } = await sl.webhooks.create({
525
527
  name: "amm-swaps",
526
528
  url: "https://my-app.com/webhook",
527
529
  triggers: [
@@ -542,29 +544,29 @@ body `{ action: "apply", block_hash, block_height, tx_id, canonical, trigger,
542
544
  event }`. On reorg you get `chain.reorg.rollback` with `{ action: "rollback",
543
545
  fork_point_height, orphaned: [{ tx_id, event }] }`. Delivery is at-least-once: a
544
546
  tx surviving a reorg re-delivers an apply under its new `block_hash`, so key
545
- consumer state on `(tx_id, block_hash)`. Per-subscription HMAC signing (Standard
547
+ consumer state on `(tx_id, block_hash)`. Per-webhook HMAC signing (Standard
546
548
  Webhooks) is unchanged for both kinds.
547
549
 
548
550
  ```typescript
549
551
  // Lifecycle (both kinds)
550
- await sl.subscriptions.update(id, { filter: { amount: { gte: "1000000" } } });
551
- await sl.subscriptions.pause(id);
552
- await sl.subscriptions.resume(id);
553
- await sl.subscriptions.rotateSecret(id); // returns new signing secret once
554
- const { data: deliveries } = await sl.subscriptions.deliveries(id);
552
+ await sl.webhooks.update(id, { filter: { amount: { gte: "1000000" } } });
553
+ await sl.webhooks.pause(id);
554
+ await sl.webhooks.resume(id);
555
+ await sl.webhooks.rotateSecret(id); // returns new signing secret once
556
+ const { data: deliveries } = await sl.webhooks.deliveries(id);
555
557
 
556
558
  // Replay historical block range
557
- await sl.subscriptions.replay(id, { fromBlock: 180000, toBlock: 181000 });
559
+ await sl.webhooks.replay(id, { fromBlock: 180000, toBlock: 181000 });
558
560
 
559
561
  // Dead-letter inspection + requeue
560
- const { data: dead } = await sl.subscriptions.dead(id);
561
- await sl.subscriptions.requeue(id, outboxId);
562
+ const { data: dead } = await sl.webhooks.dead(id);
563
+ await sl.webhooks.requeue(id, outboxId);
562
564
  ```
563
565
 
564
566
  ### Verifying deliveries
565
567
 
566
568
  Every delivery — any kind, any `format` — also carries a universal authenticity
567
- signature you can verify with one published key, no per-subscription secret. The
569
+ signature you can verify with one published key, no per-webhook secret. The
568
570
  headers are `webhook-id`, `x-secondlayer-signature`, and
569
571
  `x-secondlayer-signature-keyid`; the signed content is `` `${webhook-id}.${rawBody}` ``
570
572
  (ed25519). Fetch the public key from `GET /public/streams/signing-key`.
@@ -590,7 +592,7 @@ verifySecondlayerSignature(
590
592
  ): boolean;
591
593
  ```
592
594
 
593
- Prefer the per-subscription HMAC (Standard Webhooks) secret instead? Use
595
+ Prefer the per-webhook HMAC (Standard Webhooks) secret instead? Use
594
596
  `verifyWebhookSignature(rawBody, headers, secret)` — raw body first.
595
597
 
596
598
  ## x402 pay-per-call (accountless)
package/dist/index.d.ts CHANGED
@@ -2564,25 +2564,25 @@ declare class Index extends BaseClient {
2564
2564
  private walkPoxCycles;
2565
2565
  private getPoxCycle;
2566
2566
  }
2567
- import { CreateSubscriptionRequest, CreateSubscriptionResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, SubscriptionDetail, SubscriptionSummary, SubscriptionTestResult, UpdateSubscriptionRequest } from "@secondlayer/shared/schemas/subscriptions";
2568
- import { ChainTrigger, ChainTriggerType, CreateSubscriptionRequest as CreateSubscriptionRequest2, CreateSubscriptionResponse as CreateSubscriptionResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, SubscriptionDetail as SubscriptionDetail2, SubscriptionFormat, SubscriptionKind, SubscriptionRuntime, SubscriptionStatus, SubscriptionSummary as SubscriptionSummary2, UpdateSubscriptionRequest as UpdateSubscriptionRequest2 } from "@secondlayer/shared/schemas/subscriptions";
2569
- import { trigger } from "@secondlayer/shared/schemas/subscriptions";
2570
- declare class Subscriptions extends BaseClient {
2567
+ import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, UpdateWebhookRequest, WebhookDetail, WebhookSummary, WebhookTestResult } from "@secondlayer/shared/schemas/webhooks";
2568
+ import { ChainTrigger, ChainTriggerType, CreateWebhookRequest as CreateWebhookRequest2, CreateWebhookResponse as CreateWebhookResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, WebhookDetail as WebhookDetail2, WebhookFormat, WebhookKind, WebhookRuntime, WebhookStatus, WebhookSummary as WebhookSummary2, WebhookTestResult as WebhookTestResult2, UpdateWebhookRequest as UpdateWebhookRequest2 } from "@secondlayer/shared/schemas/webhooks";
2569
+ import { trigger } from "@secondlayer/shared/schemas/webhooks";
2570
+ declare class Webhooks extends BaseClient {
2571
2571
  list(): Promise<{
2572
- data: SubscriptionSummary[];
2572
+ data: WebhookSummary[];
2573
2573
  }>;
2574
- get(id: string): Promise<SubscriptionDetail>;
2575
- create(input: CreateSubscriptionRequest): Promise<CreateSubscriptionResponse>;
2576
- update(id: string, patch: UpdateSubscriptionRequest): Promise<SubscriptionDetail>;
2577
- pause(id: string): Promise<SubscriptionDetail>;
2578
- resume(id: string): Promise<SubscriptionDetail>;
2574
+ get(id: string): Promise<WebhookDetail>;
2575
+ create(input: CreateWebhookRequest): Promise<CreateWebhookResponse>;
2576
+ update(id: string, patch: UpdateWebhookRequest): Promise<WebhookDetail>;
2577
+ pause(id: string): Promise<WebhookDetail>;
2578
+ resume(id: string): Promise<WebhookDetail>;
2579
2579
  delete(id: string): Promise<{
2580
2580
  ok: true;
2581
2581
  }>;
2582
2582
  rotateSecret(id: string): Promise<RotateSecretResponse>;
2583
- /** Send a one-off test webhook to the subscription's URL (built for its
2583
+ /** Send a one-off test webhook to the webhook's URL (built for its
2584
2584
  * format, SSRF-guarded). Logged as a delivery row, visible via deliveries. */
2585
- test(id: string): Promise<SubscriptionTestResult>;
2585
+ test(id: string): Promise<WebhookTestResult>;
2586
2586
  /** The last 100 delivery attempts, newest first. The server caps the window;
2587
2587
  * there is nothing to page. */
2588
2588
  deliveries(id: string): Promise<{
@@ -2643,7 +2643,7 @@ interface ContextSnapshot {
2643
2643
  streamsTip: ContextField<StreamsTip>;
2644
2644
  indexTip: ContextField<IndexTip>;
2645
2645
  subgraphs: ContextField<SubgraphSummary2[]>;
2646
- subscriptions: ContextField<{
2646
+ webhooks: ContextField<{
2647
2647
  count: number;
2648
2648
  byStatus: Record<string, number>;
2649
2649
  }>;
@@ -2661,7 +2661,7 @@ declare class SecondLayer extends BaseClient {
2661
2661
  readonly index: Index;
2662
2662
  readonly contracts: Contracts;
2663
2663
  readonly subgraphs: Subgraphs;
2664
- readonly subscriptions: Subscriptions;
2664
+ readonly webhooks: Webhooks;
2665
2665
  readonly archive: SecondLayerArchive;
2666
2666
  readonly instance: InstanceClient;
2667
2667
  constructor(options?: Partial<SecondLayerOptions>);
@@ -2989,7 +2989,7 @@ type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string
2989
2989
  /**
2990
2990
  * Verify a Secondlayer webhook delivery signature.
2991
2991
  *
2992
- * Every delivery whose subscription `format` is `"standard-webhooks"` (the
2992
+ * Every delivery whose webhook `format` is `"standard-webhooks"` (the
2993
2993
  * default) carries three Standard Webhooks headers:
2994
2994
  *
2995
2995
  * webhook-id — UUID for the delivery (stable across retries; use as
@@ -2998,7 +2998,7 @@ type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string
2998
2998
  * webhook-signature — space-separated list of `v1,<base64-hmac>` tuples
2999
2999
  *
3000
3000
  * The signed content is `${id}.${timestamp}.${rawBody}` HMAC-SHA256 with the
3001
- * signing secret. Secrets returned by `sl subscriptions create` (or
3001
+ * signing secret. Secrets returned by `secondlayer webhooks create` (or
3002
3002
  * `rotate-secret`) are a bare 64-character hex string used directly as the
3003
3003
  * HMAC key (its UTF-8 bytes) — this helper handles that. A `whsec_`-prefixed
3004
3004
  * base64 secret (the Svix convention) is also accepted and base64-decoded after
@@ -3019,7 +3019,7 @@ type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string
3019
3019
  * a header value by name. Header name matching is
3020
3020
  * case-insensitive.
3021
3021
  * @param secret The signing secret returned by
3022
- * `sl subscriptions create` / `rotateSecret` (a bare
3022
+ * `secondlayer webhooks create` / `rotateSecret` (a bare
3023
3023
  * 64-char hex string). Pass it through verbatim — the
3024
3024
  * helper accepts both bare hex and `whsec_`-prefixed
3025
3025
  * base64 secrets.
@@ -3069,7 +3069,7 @@ declare function verifyWebhookSignature(rawBody: string, headers: WebhookHeaderI
3069
3069
  * Verify the universal Secondlayer authenticity signature that every delivery
3070
3070
  * carries, regardless of body format (`raw`, `cloudevents`, `standard-webhooks`,
3071
3071
  * …). This is the format-agnostic alternative to {@link verifyWebhookSignature}:
3072
- * instead of a per-subscription HMAC secret, it checks an ed25519 signature over
3072
+ * instead of a per-webhook HMAC secret, it checks an ed25519 signature over
3073
3073
  * `${webhook-id}.${rawBody}` against Secondlayer's published public key — so one
3074
3074
  * key proves authenticity for any format.
3075
3075
  *
@@ -3096,18 +3096,18 @@ declare function verifyWebhookSignature(rawBody: string, headers: WebhookHeaderI
3096
3096
  */
3097
3097
  declare function verifySecondlayerSignature(rawBody: string, headers: WebhookHeaderInput, publicKeyPem: string): boolean;
3098
3098
  /**
3099
- * Decode + narrow a chain-subscription webhook delivery body into a typed
3099
+ * Decode + narrow a chain webhook delivery body into a typed
3100
3100
  * {@link ChainWebhookDelivery}. Verify the signature first with
3101
3101
  * {@link verifyWebhookSignature} (or {@link verifySecondlayerSignature}), then
3102
3102
  * decode the same raw body — this does not check authenticity, only shape.
3103
3103
  *
3104
3104
  * Only understands the `format: "standard-webhooks"` envelope (`{ type,
3105
- * timestamp, data }`) — the subscription default, and the only format
3105
+ * timestamp, data }`) — the webhook default, and the only format
3106
3106
  * `verifyWebhookSignature` covers. Other formats (`raw`, `cloudevents`, …)
3107
3107
  * carry the same `data` value under a different envelope; see the "Chain
3108
- * subscription webhook payloads" doc for how to unwrap those.
3108
+ * webhook payloads" doc for how to unwrap those.
3109
3109
  *
3110
- * A chain-subscription delivery is NOT a Streams/Index event — do not run this
3110
+ * A chain webhook delivery is NOT a Streams/Index event — do not run this
3111
3111
  * over a `StreamsEvent` body (`{ event_type, payload }`) or vice versa.
3112
3112
  *
3113
3113
  * @param rawBody The raw request body string (same bytes passed to
@@ -3136,4 +3136,4 @@ declare function verifySecondlayerSignature(rawBody: string, headers: WebhookHea
3136
3136
  declare function decodeChainWebhook(rawBody: string): ChainWebhookDelivery;
3137
3137
  import { RewardSet as RewardSet2 } from "@secondlayer/shared/node/consensus";
3138
3138
  import { decodeClarityValue, toJsonSafe } from "@secondlayer/shared/streams-rows";
3139
- export { verifyWebhookSignature, verifyTransactionProof, verify as verifyStandardWebhooksHeaders, verifySecondlayerSignature, trigger, toJsonSafe, shutdownSignal, resolveBaseUrl, resolveApiKey, resolveAccountKey, parseRetryAfter, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, decodeChainWebhook, decode, createStreamsClient, createArchiveClient, contextField, consumerHealth, consumeIndexFeed, WithSinkTx, WebhookHeaderInput, WalkOptions, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsSubscription, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StackingWalkParams, StackingListParams, StackingEnvelope, SinkTx, SecondLayerOptions, SecondLayerErrorOptions, SecondLayerError, SecondLayerArchive, SecondLayer, SbtcWithdrawalsWalkParams, SbtcWithdrawalsListParams, SbtcWithdrawalsEnvelope, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalStatus, SbtcWithdrawalEvent, SbtcWithdrawalEnvelope, SbtcSummaryEnvelope, SbtcResource, SbtcEventsWalkParams, SbtcEventsListParams, SbtcEventsEnvelope, SbtcEventsConsumeParams, SbtcEventTopic2 as SbtcEventTopic, SbtcDepositsWalkParams, SbtcDepositsListParams, SbtcDepositsEnvelope, SbtcDepositsConsumeParams, SbtcDepositEvent, SbtcDepositEnvelope, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, RequestOptions, ReplayResult2 as ReplayResult, RateLimitError, PublicStatus2 as PublicStatus, PrintSchemaResponse, PoxResource, PoxCyclesWalkParams, PoxCyclesListParams, PoxCyclesEnvelope, PoxCycleEnvelope, Pox5Resource, Pox5EventsWalkParams, Pox5EventsListParams, Pox5EventsEnvelope, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload2 as NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, LoadedArchive, LOCAL_API_URL, InsufficientArchiveCreditsError, InstanceStatus, InstanceState, InstanceIssue, InstanceDiagnosis3 as InstanceDiagnosis, InstanceClient, IndexTransaction, IndexTip, IndexStxTransfer, IndexStxMint, IndexStxLock, IndexStxBurn, IndexStackingAction, IndexSbtcWithdrawalPhase, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawal, IndexSbtcSummary, IndexSbtcEvent, IndexSbtcDepositDetail, IndexSbtcDeposit, IndexReorg, IndexPrint, IndexPoxFunctionCount, IndexPoxCycle, IndexPox5EventTopic, IndexPox5Event, IndexPostCondition, IndexNftTransfer, IndexNftMint, IndexNftBurn, IndexMempoolTransaction, IndexFtTransfer, IndexFtMint, IndexFtBurn, IndexFeedItem, IndexFeedFetcher, IndexFeedEnvelope, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEventOf, IndexEventFields, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, IndexAlwaysFields, Index, INSTANCE_TOKEN_ENV, INDEX_MAX_PAGE_SIZE, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload2 as FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, DEFAULT_REQUEST_TIMEOUT_MS, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, CreateArchiveClientOptions, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextFieldError, ContextField, ContextAccount, ConsumerSink, ConsumerHealth, ConsumerBatchContext, ChainWebhookEnvelope, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainTxLevelEvent, ChainTriggerType, ChainTrigger, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ArchiveVerifyResult, ArchiveVerifyRangeStatus, ArchiveVerifyInput, ArchiveStatus, ArchiveSignatureError, ArchiveQuote, ArchivePartition, ArchiveManifest, ArchiveLoadOptions, ArchiveGateNotConfiguredError, ArchiveFlow, ArchiveFetchResult, ArchiveFetchItem, ArchiveDataset, ArchiveCreditsBalance, ArchiveClient, ArchiveAuthError, ApiError, ActiveSubgraphOperation, ACCOUNT_KEY_ENV };
3139
+ export { verifyWebhookSignature, verifyTransactionProof, verify as verifyStandardWebhooksHeaders, verifySecondlayerSignature, trigger, toJsonSafe, shutdownSignal, resolveBaseUrl, resolveApiKey, resolveAccountKey, parseRetryAfter, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, decodeChainWebhook, decode, createStreamsClient, createArchiveClient, contextField, consumerHealth, consumeIndexFeed, WithSinkTx, Webhooks, WebhookTestResult2 as WebhookTestResult, WebhookSummary2 as WebhookSummary, WebhookStatus, WebhookRuntime, WebhookKind, WebhookHeaderInput, WebhookFormat, WebhookDetail2 as WebhookDetail, WalkOptions, ValidationError, UpdateWebhookRequest2 as UpdateWebhookRequest, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsSubscription, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StackingWalkParams, StackingListParams, StackingEnvelope, SinkTx, SecondLayerOptions, SecondLayerErrorOptions, SecondLayerError, SecondLayerArchive, SecondLayer, SbtcWithdrawalsWalkParams, SbtcWithdrawalsListParams, SbtcWithdrawalsEnvelope, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalStatus, SbtcWithdrawalEvent, SbtcWithdrawalEnvelope, SbtcSummaryEnvelope, SbtcResource, SbtcEventsWalkParams, SbtcEventsListParams, SbtcEventsEnvelope, SbtcEventsConsumeParams, SbtcEventTopic2 as SbtcEventTopic, SbtcDepositsWalkParams, SbtcDepositsListParams, SbtcDepositsEnvelope, SbtcDepositsConsumeParams, SbtcDepositEvent, SbtcDepositEnvelope, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, RequestOptions, ReplayResult2 as ReplayResult, RateLimitError, PublicStatus2 as PublicStatus, PrintSchemaResponse, PoxResource, PoxCyclesWalkParams, PoxCyclesListParams, PoxCyclesEnvelope, PoxCycleEnvelope, Pox5Resource, Pox5EventsWalkParams, Pox5EventsListParams, Pox5EventsEnvelope, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload2 as NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, LoadedArchive, LOCAL_API_URL, InsufficientArchiveCreditsError, InstanceStatus, InstanceState, InstanceIssue, InstanceDiagnosis3 as InstanceDiagnosis, InstanceClient, IndexTransaction, IndexTip, IndexStxTransfer, IndexStxMint, IndexStxLock, IndexStxBurn, IndexStackingAction, IndexSbtcWithdrawalPhase, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawal, IndexSbtcSummary, IndexSbtcEvent, IndexSbtcDepositDetail, IndexSbtcDeposit, IndexReorg, IndexPrint, IndexPoxFunctionCount, IndexPoxCycle, IndexPox5EventTopic, IndexPox5Event, IndexPostCondition, IndexNftTransfer, IndexNftMint, IndexNftBurn, IndexMempoolTransaction, IndexFtTransfer, IndexFtMint, IndexFtBurn, IndexFeedItem, IndexFeedFetcher, IndexFeedEnvelope, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEventOf, IndexEventFields, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, IndexAlwaysFields, Index, INSTANCE_TOKEN_ENV, INDEX_MAX_PAGE_SIZE, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload2 as FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, DEFAULT_REQUEST_TIMEOUT_MS, Cursor, CreateWebhookResponse2 as CreateWebhookResponse, CreateWebhookRequest2 as CreateWebhookRequest, CreateArchiveClientOptions, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextFieldError, ContextField, ContextAccount, ConsumerSink, ConsumerHealth, ConsumerBatchContext, ChainWebhookEnvelope, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainTxLevelEvent, ChainTriggerType, ChainTrigger, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ArchiveVerifyResult, ArchiveVerifyRangeStatus, ArchiveVerifyInput, ArchiveStatus, ArchiveSignatureError, ArchiveQuote, ArchivePartition, ArchiveManifest, ArchiveLoadOptions, ArchiveGateNotConfiguredError, ArchiveFlow, ArchiveFetchResult, ArchiveFetchItem, ArchiveDataset, ArchiveCreditsBalance, ArchiveClient, ArchiveAuthError, ApiError, ActiveSubgraphOperation, ACCOUNT_KEY_ENV };
package/dist/index.js CHANGED
@@ -2448,48 +2448,48 @@ function createStreamsClient(options) {
2448
2448
  };
2449
2449
  }
2450
2450
 
2451
- // src/subscriptions/client.ts
2452
- import { trigger } from "@secondlayer/shared/schemas/subscriptions";
2451
+ // src/webhooks/client.ts
2452
+ import { trigger } from "@secondlayer/shared/schemas/webhooks";
2453
2453
 
2454
- class Subscriptions extends BaseClient {
2454
+ class Webhooks extends BaseClient {
2455
2455
  async list() {
2456
- return this.request("GET", "/api/subscriptions");
2456
+ return this.request("GET", "/api/webhooks");
2457
2457
  }
2458
2458
  async get(id) {
2459
- return this.request("GET", `/api/subscriptions/${seg(id)}`);
2459
+ return this.request("GET", `/api/webhooks/${seg(id)}`);
2460
2460
  }
2461
2461
  async create(input) {
2462
- return this.request("POST", "/api/subscriptions", input);
2462
+ return this.request("POST", "/api/webhooks", input);
2463
2463
  }
2464
2464
  async update(id, patch) {
2465
- return this.request("PATCH", `/api/subscriptions/${seg(id)}`, patch);
2465
+ return this.request("PATCH", `/api/webhooks/${seg(id)}`, patch);
2466
2466
  }
2467
2467
  async pause(id) {
2468
- return this.request("POST", `/api/subscriptions/${seg(id)}/pause`);
2468
+ return this.request("POST", `/api/webhooks/${seg(id)}/pause`);
2469
2469
  }
2470
2470
  async resume(id) {
2471
- return this.request("POST", `/api/subscriptions/${seg(id)}/resume`);
2471
+ return this.request("POST", `/api/webhooks/${seg(id)}/resume`);
2472
2472
  }
2473
2473
  async delete(id) {
2474
- return this.request("DELETE", `/api/subscriptions/${seg(id)}`);
2474
+ return this.request("DELETE", `/api/webhooks/${seg(id)}`);
2475
2475
  }
2476
2476
  async rotateSecret(id) {
2477
- return this.request("POST", `/api/subscriptions/${seg(id)}/rotate-secret`);
2477
+ return this.request("POST", `/api/webhooks/${seg(id)}/rotate-secret`);
2478
2478
  }
2479
2479
  async test(id) {
2480
- return this.request("POST", `/api/subscriptions/${seg(id)}/test`);
2480
+ return this.request("POST", `/api/webhooks/${seg(id)}/test`);
2481
2481
  }
2482
2482
  async deliveries(id) {
2483
- return this.request("GET", `/api/subscriptions/${seg(id)}/deliveries`);
2483
+ return this.request("GET", `/api/webhooks/${seg(id)}/deliveries`);
2484
2484
  }
2485
2485
  async replay(id, range) {
2486
- return this.request("POST", `/api/subscriptions/${seg(id)}/replay`, range);
2486
+ return this.request("POST", `/api/webhooks/${seg(id)}/replay`, range);
2487
2487
  }
2488
2488
  async dead(id) {
2489
- return this.request("GET", `/api/subscriptions/${seg(id)}/dead`);
2489
+ return this.request("GET", `/api/webhooks/${seg(id)}/dead`);
2490
2490
  }
2491
2491
  async requeue(id, outboxId) {
2492
- return this.request("POST", `/api/subscriptions/${seg(id)}/dead/${seg(outboxId)}/requeue`);
2492
+ return this.request("POST", `/api/webhooks/${seg(id)}/dead/${seg(outboxId)}/requeue`);
2493
2493
  }
2494
2494
  }
2495
2495
 
@@ -2524,7 +2524,7 @@ class SecondLayer extends BaseClient {
2524
2524
  index;
2525
2525
  contracts;
2526
2526
  subgraphs;
2527
- subscriptions;
2527
+ webhooks;
2528
2528
  archive;
2529
2529
  instance;
2530
2530
  constructor(options = {}) {
@@ -2541,7 +2541,7 @@ class SecondLayer extends BaseClient {
2541
2541
  this.index = new Index(options);
2542
2542
  this.contracts = new Contracts(options);
2543
2543
  this.subgraphs = new Subgraphs(options);
2544
- this.subscriptions = new Subscriptions(options);
2544
+ this.webhooks = new Webhooks(options);
2545
2545
  const request = (method, path, body) => this.request(method, path, body);
2546
2546
  this.archive = {
2547
2547
  ...createArchiveClient({
@@ -2558,36 +2558,29 @@ class SecondLayer extends BaseClient {
2558
2558
  return this.request("POST", "/v1/batch", { requests });
2559
2559
  }
2560
2560
  async context() {
2561
- const [
2562
- account,
2563
- streamsTip,
2564
- indexEnv,
2565
- subgraphsRes,
2566
- subscriptionsRes,
2567
- instance
2568
- ] = await Promise.all([
2561
+ const [account, streamsTip, indexEnv, subgraphsRes, webhooksRes, instance] = await Promise.all([
2569
2562
  contextField(this.request("GET", "/api/accounts/me")),
2570
2563
  contextField(this.streams.tip()),
2571
2564
  contextField(this.index.canonical.list({ limit: 1 })),
2572
2565
  contextField(this.subgraphs.list()),
2573
- contextField(this.subscriptions.list()),
2566
+ contextField(this.webhooks.list()),
2574
2567
  contextField(this.instance.diagnose())
2575
2568
  ]);
2576
2569
  const subgraphs = {
2577
2570
  value: subgraphsRes.value?.data ?? null,
2578
2571
  ...subgraphsRes.error ? { error: subgraphsRes.error } : {}
2579
2572
  };
2580
- const subscriptions = {
2573
+ const webhooks = {
2581
2574
  value: null,
2582
- ...subscriptionsRes.error ? { error: subscriptionsRes.error } : {}
2575
+ ...webhooksRes.error ? { error: webhooksRes.error } : {}
2583
2576
  };
2584
- if (subscriptionsRes.value) {
2577
+ if (webhooksRes.value) {
2585
2578
  const byStatus = {};
2586
- for (const s of subscriptionsRes.value.data) {
2579
+ for (const s of webhooksRes.value.data) {
2587
2580
  byStatus[s.status] = (byStatus[s.status] ?? 0) + 1;
2588
2581
  }
2589
- subscriptions.value = {
2590
- count: subscriptionsRes.value.data.length,
2582
+ webhooks.value = {
2583
+ count: webhooksRes.value.data.length,
2591
2584
  byStatus
2592
2585
  };
2593
2586
  }
@@ -2622,7 +2615,7 @@ class SecondLayer extends BaseClient {
2622
2615
  ...indexEnv.error ? { error: indexEnv.error } : {}
2623
2616
  },
2624
2617
  subgraphs,
2625
- subscriptions,
2618
+ webhooks,
2626
2619
  activeOperations,
2627
2620
  instance
2628
2621
  };
@@ -2710,7 +2703,7 @@ function shutdownSignal(options = {}) {
2710
2703
  }
2711
2704
  return controller.signal;
2712
2705
  }
2713
- // src/webhooks.ts
2706
+ // src/webhooks/verify.ts
2714
2707
  import { verifySecondlayerSignatureValues } from "@secondlayer/shared/crypto/secondlayer-webhook";
2715
2708
  import {
2716
2709
  verify
@@ -2762,10 +2755,10 @@ function verifySecondlayerSignature(rawBody, headers, publicKeyPem) {
2762
2755
  function decodeChainWebhook(rawBody) {
2763
2756
  const parsed = JSON.parse(rawBody);
2764
2757
  if (typeof parsed.type !== "string" || typeof parsed.timestamp !== "string" || typeof parsed.data !== "object" || parsed.data === null) {
2765
- throw new Error("decodeChainWebhook: not a chain-subscription delivery — expected { type, timestamp, data }");
2758
+ throw new Error("decodeChainWebhook: not a chain webhook delivery — expected { type, timestamp, data }");
2766
2759
  }
2767
2760
  if (!parsed.type.startsWith("chain.")) {
2768
- throw new Error(`decodeChainWebhook: not a chain-subscription delivery (type "${parsed.type}")`);
2761
+ throw new Error(`decodeChainWebhook: not a chain webhook delivery (type "${parsed.type}")`);
2769
2762
  }
2770
2763
  const data = parsed.data;
2771
2764
  if (parsed.type === "chain.test.apply") {
@@ -2911,8 +2904,8 @@ export {
2911
2904
  contextField,
2912
2905
  consumerHealth,
2913
2906
  consumeIndexFeed,
2907
+ Webhooks,
2914
2908
  ValidationError,
2915
- Subscriptions,
2916
2909
  Subgraphs,
2917
2910
  StreamsSignatureError,
2918
2911
  StreamsServerError,
@@ -2935,5 +2928,5 @@ export {
2935
2928
  ACCOUNT_KEY_ENV
2936
2929
  };
2937
2930
 
2938
- //# debugId=18BFA99012559AFD64756E2164756E21
2931
+ //# debugId=139DE2F111FF826D64756E2164756E21
2939
2932
  //# sourceMappingURL=index.js.map