@secondlayer/sdk 10.3.1 → 10.4.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/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,43 @@ 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, WebhookFormat, WebhookKind, WebhookRuntime, WebhookStatus, 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 as WebhookFormat2, WebhookKind as WebhookKind2, WebhookRuntime as WebhookRuntime2, WebhookStatus as WebhookStatus2, WebhookSummary as WebhookSummary2, WebhookTestResult as WebhookTestResult2, UpdateWebhookRequest as UpdateWebhookRequest2 } from "@secondlayer/shared/schemas/webhooks";
2569
+ import { trigger } from "@secondlayer/shared/schemas/webhooks";
2570
+ /** @deprecated Use webhook type. Removed next minor. */
2571
+ type CreateSubscriptionRequest = CreateWebhookRequest;
2572
+ /** @deprecated Use webhook type. Removed next minor. */
2573
+ type CreateSubscriptionResponse = CreateWebhookResponse;
2574
+ /** @deprecated Use webhook type. Removed next minor. */
2575
+ type UpdateSubscriptionRequest = UpdateWebhookRequest;
2576
+ /** @deprecated Use webhook type. Removed next minor. */
2577
+ type SubscriptionDetail = WebhookDetail;
2578
+ /** @deprecated Use webhook type. Removed next minor. */
2579
+ type SubscriptionSummary = WebhookSummary;
2580
+ /** @deprecated Use webhook type. Removed next minor. */
2581
+ type SubscriptionFormat = WebhookFormat;
2582
+ /** @deprecated Use webhook type. Removed next minor. */
2583
+ type SubscriptionKind = WebhookKind;
2584
+ /** @deprecated Use webhook type. Removed next minor. */
2585
+ type SubscriptionRuntime = WebhookRuntime;
2586
+ /** @deprecated Use webhook type. Removed next minor. */
2587
+ type SubscriptionStatus = WebhookStatus;
2588
+ declare class Webhooks extends BaseClient {
2571
2589
  list(): Promise<{
2572
- data: SubscriptionSummary[];
2590
+ data: WebhookSummary[];
2573
2591
  }>;
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>;
2592
+ get(id: string): Promise<WebhookDetail>;
2593
+ create(input: CreateWebhookRequest): Promise<CreateWebhookResponse>;
2594
+ update(id: string, patch: UpdateWebhookRequest): Promise<WebhookDetail>;
2595
+ pause(id: string): Promise<WebhookDetail>;
2596
+ resume(id: string): Promise<WebhookDetail>;
2579
2597
  delete(id: string): Promise<{
2580
2598
  ok: true;
2581
2599
  }>;
2582
2600
  rotateSecret(id: string): Promise<RotateSecretResponse>;
2583
- /** Send a one-off test webhook to the subscription's URL (built for its
2601
+ /** Send a one-off test webhook to the webhook's URL (built for its
2584
2602
  * format, SSRF-guarded). Logged as a delivery row, visible via deliveries. */
2585
- test(id: string): Promise<SubscriptionTestResult>;
2603
+ test(id: string): Promise<WebhookTestResult>;
2586
2604
  /** The last 100 delivery attempts, newest first. The server caps the window;
2587
2605
  * there is nothing to page. */
2588
2606
  deliveries(id: string): Promise<{
@@ -2602,6 +2620,10 @@ declare class Subscriptions extends BaseClient {
2602
2620
  ok: true;
2603
2621
  }>;
2604
2622
  }
2623
+ /** @deprecated Use {@link Webhooks}. Removed in the next minor. */
2624
+ declare const Subscriptions: typeof Webhooks;
2625
+ /** @deprecated Use {@link Webhooks}. Removed in the next minor. */
2626
+ type Subscriptions = Webhooks;
2605
2627
  interface ContextAccount {
2606
2628
  email: string;
2607
2629
  }
@@ -2643,6 +2665,11 @@ interface ContextSnapshot {
2643
2665
  streamsTip: ContextField<StreamsTip>;
2644
2666
  indexTip: ContextField<IndexTip>;
2645
2667
  subgraphs: ContextField<SubgraphSummary2[]>;
2668
+ webhooks: ContextField<{
2669
+ count: number;
2670
+ byStatus: Record<string, number>;
2671
+ }>;
2672
+ /** @deprecated Use {@link ContextSnapshot.webhooks}. Removed next minor. */
2646
2673
  subscriptions: ContextField<{
2647
2674
  count: number;
2648
2675
  byStatus: Record<string, number>;
@@ -2661,9 +2688,11 @@ declare class SecondLayer extends BaseClient {
2661
2688
  readonly index: Index;
2662
2689
  readonly contracts: Contracts;
2663
2690
  readonly subgraphs: Subgraphs;
2664
- readonly subscriptions: Subscriptions;
2691
+ readonly webhooks: Webhooks;
2665
2692
  readonly archive: SecondLayerArchive;
2666
2693
  readonly instance: InstanceClient;
2694
+ /** @deprecated Use `webhooks`. Removed next minor. */
2695
+ get subscriptions(): Webhooks;
2667
2696
  constructor(options?: Partial<SecondLayerOptions>);
2668
2697
  /**
2669
2698
  * Up to 10 public reads in one round trip (`POST /v1/batch`). Each item
@@ -2989,7 +3018,7 @@ type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string
2989
3018
  /**
2990
3019
  * Verify a Secondlayer webhook delivery signature.
2991
3020
  *
2992
- * Every delivery whose subscription `format` is `"standard-webhooks"` (the
3021
+ * Every delivery whose webhook `format` is `"standard-webhooks"` (the
2993
3022
  * default) carries three Standard Webhooks headers:
2994
3023
  *
2995
3024
  * webhook-id — UUID for the delivery (stable across retries; use as
@@ -2998,7 +3027,7 @@ type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string
2998
3027
  * webhook-signature — space-separated list of `v1,<base64-hmac>` tuples
2999
3028
  *
3000
3029
  * The signed content is `${id}.${timestamp}.${rawBody}` HMAC-SHA256 with the
3001
- * signing secret. Secrets returned by `sl subscriptions create` (or
3030
+ * signing secret. Secrets returned by `secondlayer webhooks create` (or
3002
3031
  * `rotate-secret`) are a bare 64-character hex string used directly as the
3003
3032
  * HMAC key (its UTF-8 bytes) — this helper handles that. A `whsec_`-prefixed
3004
3033
  * base64 secret (the Svix convention) is also accepted and base64-decoded after
@@ -3019,7 +3048,7 @@ type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string
3019
3048
  * a header value by name. Header name matching is
3020
3049
  * case-insensitive.
3021
3050
  * @param secret The signing secret returned by
3022
- * `sl subscriptions create` / `rotateSecret` (a bare
3051
+ * `secondlayer webhooks create` / `rotateSecret` (a bare
3023
3052
  * 64-char hex string). Pass it through verbatim — the
3024
3053
  * helper accepts both bare hex and `whsec_`-prefixed
3025
3054
  * base64 secrets.
@@ -3069,7 +3098,7 @@ declare function verifyWebhookSignature(rawBody: string, headers: WebhookHeaderI
3069
3098
  * Verify the universal Secondlayer authenticity signature that every delivery
3070
3099
  * carries, regardless of body format (`raw`, `cloudevents`, `standard-webhooks`,
3071
3100
  * …). This is the format-agnostic alternative to {@link verifyWebhookSignature}:
3072
- * instead of a per-subscription HMAC secret, it checks an ed25519 signature over
3101
+ * instead of a per-webhook HMAC secret, it checks an ed25519 signature over
3073
3102
  * `${webhook-id}.${rawBody}` against Secondlayer's published public key — so one
3074
3103
  * key proves authenticity for any format.
3075
3104
  *
@@ -3096,18 +3125,18 @@ declare function verifyWebhookSignature(rawBody: string, headers: WebhookHeaderI
3096
3125
  */
3097
3126
  declare function verifySecondlayerSignature(rawBody: string, headers: WebhookHeaderInput, publicKeyPem: string): boolean;
3098
3127
  /**
3099
- * Decode + narrow a chain-subscription webhook delivery body into a typed
3128
+ * Decode + narrow a chain webhook delivery body into a typed
3100
3129
  * {@link ChainWebhookDelivery}. Verify the signature first with
3101
3130
  * {@link verifyWebhookSignature} (or {@link verifySecondlayerSignature}), then
3102
3131
  * decode the same raw body — this does not check authenticity, only shape.
3103
3132
  *
3104
3133
  * Only understands the `format: "standard-webhooks"` envelope (`{ type,
3105
- * timestamp, data }`) — the subscription default, and the only format
3134
+ * timestamp, data }`) — the webhook default, and the only format
3106
3135
  * `verifyWebhookSignature` covers. Other formats (`raw`, `cloudevents`, …)
3107
3136
  * carry the same `data` value under a different envelope; see the "Chain
3108
- * subscription webhook payloads" doc for how to unwrap those.
3137
+ * webhook payloads" doc for how to unwrap those.
3109
3138
  *
3110
- * A chain-subscription delivery is NOT a Streams/Index event — do not run this
3139
+ * A chain webhook delivery is NOT a Streams/Index event — do not run this
3111
3140
  * over a `StreamsEvent` body (`{ event_type, payload }`) or vice versa.
3112
3141
  *
3113
3142
  * @param rawBody The raw request body string (same bytes passed to
@@ -3136,4 +3165,4 @@ declare function verifySecondlayerSignature(rawBody: string, headers: WebhookHea
3136
3165
  declare function decodeChainWebhook(rawBody: string): ChainWebhookDelivery;
3137
3166
  import { RewardSet as RewardSet2 } from "@secondlayer/shared/node/consensus";
3138
3167
  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 };
3168
+ 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, WebhookStatus2 as WebhookStatus, WebhookRuntime2 as WebhookRuntime, WebhookKind2 as WebhookKind, WebhookHeaderInput, WebhookFormat2 as WebhookFormat, WebhookDetail2 as WebhookDetail, WalkOptions, ValidationError, UpdateWebhookRequest2 as UpdateWebhookRequest, UpdateSubscriptionRequest, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, 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, CreateWebhookResponse2 as CreateWebhookResponse, CreateWebhookRequest2 as CreateWebhookRequest, CreateSubscriptionResponse, 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 };
package/dist/index.js CHANGED
@@ -2448,50 +2448,51 @@ 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
+ var Subscriptions = Webhooks;
2495
2496
 
2496
2497
  // src/client.ts
2497
2498
  async function contextField(read) {
@@ -2524,9 +2525,12 @@ class SecondLayer extends BaseClient {
2524
2525
  index;
2525
2526
  contracts;
2526
2527
  subgraphs;
2527
- subscriptions;
2528
+ webhooks;
2528
2529
  archive;
2529
2530
  instance;
2531
+ get subscriptions() {
2532
+ return this.webhooks;
2533
+ }
2530
2534
  constructor(options = {}) {
2531
2535
  super(options);
2532
2536
  this.streams = createStreamsClient({
@@ -2541,7 +2545,7 @@ class SecondLayer extends BaseClient {
2541
2545
  this.index = new Index(options);
2542
2546
  this.contracts = new Contracts(options);
2543
2547
  this.subgraphs = new Subgraphs(options);
2544
- this.subscriptions = new Subscriptions(options);
2548
+ this.webhooks = new Webhooks(options);
2545
2549
  const request = (method, path, body) => this.request(method, path, body);
2546
2550
  this.archive = {
2547
2551
  ...createArchiveClient({
@@ -2558,36 +2562,29 @@ class SecondLayer extends BaseClient {
2558
2562
  return this.request("POST", "/v1/batch", { requests });
2559
2563
  }
2560
2564
  async context() {
2561
- const [
2562
- account,
2563
- streamsTip,
2564
- indexEnv,
2565
- subgraphsRes,
2566
- subscriptionsRes,
2567
- instance
2568
- ] = await Promise.all([
2565
+ const [account, streamsTip, indexEnv, subgraphsRes, webhooksRes, instance] = await Promise.all([
2569
2566
  contextField(this.request("GET", "/api/accounts/me")),
2570
2567
  contextField(this.streams.tip()),
2571
2568
  contextField(this.index.canonical.list({ limit: 1 })),
2572
2569
  contextField(this.subgraphs.list()),
2573
- contextField(this.subscriptions.list()),
2570
+ contextField(this.webhooks.list()),
2574
2571
  contextField(this.instance.diagnose())
2575
2572
  ]);
2576
2573
  const subgraphs = {
2577
2574
  value: subgraphsRes.value?.data ?? null,
2578
2575
  ...subgraphsRes.error ? { error: subgraphsRes.error } : {}
2579
2576
  };
2580
- const subscriptions = {
2577
+ const webhooks = {
2581
2578
  value: null,
2582
- ...subscriptionsRes.error ? { error: subscriptionsRes.error } : {}
2579
+ ...webhooksRes.error ? { error: webhooksRes.error } : {}
2583
2580
  };
2584
- if (subscriptionsRes.value) {
2581
+ if (webhooksRes.value) {
2585
2582
  const byStatus = {};
2586
- for (const s of subscriptionsRes.value.data) {
2583
+ for (const s of webhooksRes.value.data) {
2587
2584
  byStatus[s.status] = (byStatus[s.status] ?? 0) + 1;
2588
2585
  }
2589
- subscriptions.value = {
2590
- count: subscriptionsRes.value.data.length,
2586
+ webhooks.value = {
2587
+ count: webhooksRes.value.data.length,
2591
2588
  byStatus
2592
2589
  };
2593
2590
  }
@@ -2622,7 +2619,8 @@ class SecondLayer extends BaseClient {
2622
2619
  ...indexEnv.error ? { error: indexEnv.error } : {}
2623
2620
  },
2624
2621
  subgraphs,
2625
- subscriptions,
2622
+ webhooks,
2623
+ subscriptions: webhooks,
2626
2624
  activeOperations,
2627
2625
  instance
2628
2626
  };
@@ -2710,7 +2708,7 @@ function shutdownSignal(options = {}) {
2710
2708
  }
2711
2709
  return controller.signal;
2712
2710
  }
2713
- // src/webhooks.ts
2711
+ // src/webhooks/verify.ts
2714
2712
  import { verifySecondlayerSignatureValues } from "@secondlayer/shared/crypto/secondlayer-webhook";
2715
2713
  import {
2716
2714
  verify
@@ -2762,10 +2760,10 @@ function verifySecondlayerSignature(rawBody, headers, publicKeyPem) {
2762
2760
  function decodeChainWebhook(rawBody) {
2763
2761
  const parsed = JSON.parse(rawBody);
2764
2762
  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 }");
2763
+ throw new Error("decodeChainWebhook: not a chain webhook delivery — expected { type, timestamp, data }");
2766
2764
  }
2767
2765
  if (!parsed.type.startsWith("chain.")) {
2768
- throw new Error(`decodeChainWebhook: not a chain-subscription delivery (type "${parsed.type}")`);
2766
+ throw new Error(`decodeChainWebhook: not a chain webhook delivery (type "${parsed.type}")`);
2769
2767
  }
2770
2768
  const data = parsed.data;
2771
2769
  if (parsed.type === "chain.test.apply") {
@@ -2911,6 +2909,7 @@ export {
2911
2909
  contextField,
2912
2910
  consumerHealth,
2913
2911
  consumeIndexFeed,
2912
+ Webhooks,
2914
2913
  ValidationError,
2915
2914
  Subscriptions,
2916
2915
  Subgraphs,
@@ -2935,5 +2934,5 @@ export {
2935
2934
  ACCOUNT_KEY_ENV
2936
2935
  };
2937
2936
 
2938
- //# debugId=18BFA99012559AFD64756E2164756E21
2937
+ //# debugId=6F925903665843A164756E2164756E21
2939
2938
  //# sourceMappingURL=index.js.map