@hasna/events 0.1.2 → 0.1.4

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
@@ -111,11 +111,15 @@ sha256=<hex digest>
111
111
  Consumers can verify with:
112
112
 
113
113
  ```ts
114
- import { verifyPayloadSignature } from "@hasna/events/signing";
114
+ import { verifyWebhookSignature } from "@hasna/events/signing";
115
115
 
116
- const ok = verifyPayloadSignature(secret, timestamp, body, signature);
116
+ const ok = verifyWebhookSignature(secret, timestamp, body, signature);
117
117
  ```
118
118
 
119
+ `verifyWebhookSignature` rejects timestamps outside a five-minute window by default.
120
+ Pass an explicit `toleranceMs` when a consumer needs a tighter or wider replay
121
+ window.
122
+
119
123
  ## Command Transport
120
124
 
121
125
  Command channels run a local process and pass the event on stdin and environment variables.
@@ -150,6 +154,14 @@ The transport type union already reserves `email`, `sse`, and `mcp-relay` for la
150
154
 
151
155
  ## Redaction
152
156
 
157
+ Events scrub obvious sensitive keys such as `secret`, `token`, `password`,
158
+ `apiKey`, and `authorization` before local storage and delivery by default.
159
+ Callers that intentionally need raw local payloads can pass:
160
+
161
+ ```ts
162
+ await events.emit(input, { redactSensitiveData: false });
163
+ ```
164
+
153
165
  Use channel-level paths for config-only redaction:
154
166
 
155
167
  ```ts
package/dist/cli/index.js CHANGED
@@ -646,6 +646,46 @@ Usage:
646
646
  Environment:
647
647
  HASNA_EVENTS_DIR or HASNA_EVENTS_HOME overrides the default ${getEventsDataDir()}`);
648
648
  }
649
+ function printWebhooksHelp() {
650
+ console.log(`events webhooks
651
+
652
+ Usage:
653
+ events [--dir <path>] [--json] webhooks add <url|command> [options]
654
+ events [--dir <path>] [--json] webhooks list
655
+ events [--dir <path>] [--json] webhooks remove <id>
656
+ events [--dir <path>] [--json] webhooks test <id>
657
+
658
+ Options:
659
+ --id <id> Channel id for add
660
+ --type <pattern> Event type filter, supports wildcards
661
+ --source <source> Event source filter
662
+ --subject <subject> Event subject filter
663
+ --severity <severity> Event severity filter
664
+ --transport <kind> webhook or command
665
+ --secret <secret> Webhook signing secret
666
+ --header <name=value> Webhook header, repeatable
667
+ --redact <path> Redaction path, repeatable
668
+ --no-deliver Available on events emit`);
669
+ }
670
+ function printEventsHelp() {
671
+ console.log(`events events
672
+
673
+ Usage:
674
+ events [--dir <path>] [--json] events emit <type> --source <source> [options]
675
+ events [--dir <path>] [--json] events list [--limit <n>]
676
+ events [--dir <path>] [--json] events replay [--id <event-id>] [--dry-run]
677
+
678
+ Options:
679
+ --source <source> Event source
680
+ --subject <subject> Event subject
681
+ --severity <severity> Event severity
682
+ --message <message> Human-readable event message
683
+ --dedupe-key <key> Deduplicate repeated events
684
+ --data <json> JSON object payload
685
+ --metadata <json> JSON object metadata
686
+ --no-deliver Record without delivering webhooks
687
+ --dry-run Preview replay matches without delivery`);
688
+ }
649
689
  async function main(argv = process.argv.slice(2)) {
650
690
  const parsed = parseGlobalArgs(argv);
651
691
  const [group, command, ...tail] = parsed.rest;
@@ -660,10 +700,18 @@ async function main(argv = process.argv.slice(2)) {
660
700
  const store = new JsonEventsStore(parsed.dir);
661
701
  const client = new EventsClient({ store });
662
702
  if (group === "webhooks") {
703
+ if (!command || command === "--help" || command === "-h") {
704
+ printWebhooksHelp();
705
+ return;
706
+ }
663
707
  await handleWebhooks(client, command, tail, parsed);
664
708
  return;
665
709
  }
666
710
  if (group === "events") {
711
+ if (!command || command === "--help" || command === "-h") {
712
+ printEventsHelp();
713
+ return;
714
+ }
667
715
  await handleEvents(client, command, tail, parsed);
668
716
  return;
669
717
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/events",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Shared event envelopes, local subscriptions, and webhook delivery for Hasna open-source apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",