@segmentstream/ontology 0.128.1 → 0.129.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.129.0
4
+
5
+ A provider's secret for checking what it sends, such as a webhook signing secret, lives on its
6
+ connection. `ApiKeyConnection(verification={"webhook_signing_secret": Secret(...)})` declares it;
7
+ members set it on the connection's page, the backend never sends it, request signing and
8
+ workspace code never read it, and an unset value never stops requests. `StripeConnection` and
9
+ `ResendConnection` declare `webhook_signing_secret`. The connections manifest moves to schema 24.
10
+
11
+ A webhook that names its `connection` checks deliveries against such a value with
12
+ `signature: { scheme, input: "webhook_signing_secret" }`, and Meta's registration token with
13
+ `verification: { scheme: "meta", input }`. Naming a workspace secret with `secret` or
14
+ `verifyToken` is the older form.
15
+
3
16
  ## 0.128.1
4
17
 
5
18
  A `find` MCP tool's `where` reads `{ "$me": [] }` on a to-one relationship also when it is combined
package/dist/analyze.js CHANGED
@@ -29,7 +29,7 @@ import { entityQuerySchemas, findEntityManifest, queryFields, queryLinks, } from
29
29
  import { EARLIER_QUERY_METRICS_ROUTE, earlierNamesOf } from "./legacy.js";
30
30
  import { resolveModelMetrics } from "./model-metrics.js";
31
31
  import { cronNeverFires, cronProblem, isAsyncFunction, isWorkflow, isWorkflowTrigger, MAX_ACTION_TRIGGERS, MAX_WORKFLOWS, } from "./workflow.js";
32
- import { MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, webhookDelivery, webhookHeaderProblem, webhookSignatureManifest, webhookSignatureProblems, WORKSPACE_SECRET_NAME, } from "./webhooks.js";
32
+ import { MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, webhookDelivery, webhookHeaderProblem, CONNECTION_INPUT_KEY, webhookSignatureManifest, webhookSignatureProblems, WORKSPACE_SECRET_NAME, } from "./webhooks.js";
33
33
  import { actionInputToWire } from "./authoring-input.js";
34
34
  import { validate } from "./runtime/validation.js";
35
35
  import { fixedArgumentsConflict, isToolset, MAXIMUM_TOOLSET_TOOLS, MCP_TOOL_NAME, toolHints, ToolsetLock, withoutFixedArguments, } from "./toolset.js";
@@ -779,16 +779,33 @@ function resolveWebhookTrigger(trigger, at, scope) {
779
779
  valid = false;
780
780
  }
781
781
  }
782
+ // A connection's verification value is read from the connection the webhook names.
783
+ if (typeof signature === "object" &&
784
+ signature !== null &&
785
+ signature.input !== undefined &&
786
+ trigger.connection === undefined) {
787
+ report("workflow_webhook_signature_invalid", `${at}.signature.input`, "input names a verification value of the webhook's connection: set connection too.");
788
+ valid = false;
789
+ }
782
790
  const verification = trigger.verification;
783
791
  if (verification !== undefined) {
784
792
  const declared = verification;
793
+ const source = typeof declared === "object" && declared !== null
794
+ ? declared.input !== undefined
795
+ ? declared.verifyToken === undefined &&
796
+ typeof declared.input === "string" &&
797
+ CONNECTION_INPUT_KEY.test(declared.input) &&
798
+ trigger.connection !== undefined
799
+ : typeof declared.verifyToken === "string" &&
800
+ WORKSPACE_SECRET_NAME.test(declared.verifyToken)
801
+ : false;
785
802
  if (typeof declared !== "object" ||
786
803
  declared === null ||
787
804
  declared.scheme !== "meta" ||
788
- typeof declared.verifyToken !== "string" ||
789
- !WORKSPACE_SECRET_NAME.test(declared.verifyToken) ||
805
+ !source ||
790
806
  trigger.signature?.scheme !== "meta") {
791
- report("workflow_webhook_verification_invalid", `${at}.verification`, 'Use { scheme: "meta", verifyToken: <workspace secret name> } with a Meta signature.');
807
+ report("workflow_webhook_verification_invalid", `${at}.verification`, 'Use { scheme: "meta", input: <verification value of the webhook\'s connection> } ' +
808
+ "with a Meta signature.");
792
809
  valid = false;
793
810
  }
794
811
  }
@@ -481,10 +481,12 @@ export declare const WebhookTriggerManifest: Schema.Struct<{
481
481
  readonly description: Schema.String;
482
482
  readonly signature: Schema.optionalKey<Schema.Struct<{
483
483
  readonly scheme: Schema.String;
484
- /** The workspace secret's name; absent when the secret is `generated`. */
484
+ /** The workspace secret's name; absent when the secret is `generated` or an `input`. */
485
485
  readonly secret: Schema.optionalKey<Schema.String>;
486
486
  /** The platform derives the secret for the webhook; workspace code registers it. */
487
487
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
488
+ /** The verification value of the webhook's `connection` that holds the secret. */
489
+ readonly input: Schema.optionalKey<Schema.String>;
488
490
  readonly algorithm: Schema.optionalKey<Schema.String>;
489
491
  readonly encoding: Schema.optionalKey<Schema.String>;
490
492
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -516,7 +518,10 @@ export declare const WebhookTriggerManifest: Schema.Struct<{
516
518
  }>>;
517
519
  readonly verification: Schema.optionalKey<Schema.Struct<{
518
520
  readonly scheme: Schema.String;
519
- readonly verifyToken: Schema.String;
521
+ /** The workspace secret holding the token; absent when the token is an `input`. */
522
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
523
+ /** The verification value of the webhook's `connection` that holds the token. */
524
+ readonly input: Schema.optionalKey<Schema.String>;
520
525
  }>>;
521
526
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
522
527
  /** The key of the connection whose provider sends to the webhook, when declared. */
@@ -552,10 +557,12 @@ export declare const WorkflowTriggerManifest: Schema.Union<readonly [Schema.Stru
552
557
  readonly description: Schema.String;
553
558
  readonly signature: Schema.optionalKey<Schema.Struct<{
554
559
  readonly scheme: Schema.String;
555
- /** The workspace secret's name; absent when the secret is `generated`. */
560
+ /** The workspace secret's name; absent when the secret is `generated` or an `input`. */
556
561
  readonly secret: Schema.optionalKey<Schema.String>;
557
562
  /** The platform derives the secret for the webhook; workspace code registers it. */
558
563
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
564
+ /** The verification value of the webhook's `connection` that holds the secret. */
565
+ readonly input: Schema.optionalKey<Schema.String>;
559
566
  readonly algorithm: Schema.optionalKey<Schema.String>;
560
567
  readonly encoding: Schema.optionalKey<Schema.String>;
561
568
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -587,7 +594,10 @@ export declare const WorkflowTriggerManifest: Schema.Union<readonly [Schema.Stru
587
594
  }>>;
588
595
  readonly verification: Schema.optionalKey<Schema.Struct<{
589
596
  readonly scheme: Schema.String;
590
- readonly verifyToken: Schema.String;
597
+ /** The workspace secret holding the token; absent when the token is an `input`. */
598
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
599
+ /** The verification value of the webhook's `connection` that holds the token. */
600
+ readonly input: Schema.optionalKey<Schema.String>;
591
601
  }>>;
592
602
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
593
603
  /** The key of the connection whose provider sends to the webhook, when declared. */
@@ -630,10 +640,12 @@ export declare const WorkflowManifest: Schema.Struct<{
630
640
  readonly description: Schema.String;
631
641
  readonly signature: Schema.optionalKey<Schema.Struct<{
632
642
  readonly scheme: Schema.String;
633
- /** The workspace secret's name; absent when the secret is `generated`. */
643
+ /** The workspace secret's name; absent when the secret is `generated` or an `input`. */
634
644
  readonly secret: Schema.optionalKey<Schema.String>;
635
645
  /** The platform derives the secret for the webhook; workspace code registers it. */
636
646
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
647
+ /** The verification value of the webhook's `connection` that holds the secret. */
648
+ readonly input: Schema.optionalKey<Schema.String>;
637
649
  readonly algorithm: Schema.optionalKey<Schema.String>;
638
650
  readonly encoding: Schema.optionalKey<Schema.String>;
639
651
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -665,7 +677,10 @@ export declare const WorkflowManifest: Schema.Struct<{
665
677
  }>>;
666
678
  readonly verification: Schema.optionalKey<Schema.Struct<{
667
679
  readonly scheme: Schema.String;
668
- readonly verifyToken: Schema.String;
680
+ /** The workspace secret holding the token; absent when the token is an `input`. */
681
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
682
+ /** The verification value of the webhook's `connection` that holds the token. */
683
+ readonly input: Schema.optionalKey<Schema.String>;
669
684
  }>>;
670
685
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
671
686
  /** The key of the connection whose provider sends to the webhook, when declared. */
@@ -1337,10 +1352,12 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1337
1352
  readonly description: Schema.String;
1338
1353
  readonly signature: Schema.optionalKey<Schema.Struct<{
1339
1354
  readonly scheme: Schema.String;
1340
- /** The workspace secret's name; absent when the secret is `generated`. */
1355
+ /** The workspace secret's name; absent when the secret is `generated` or an `input`. */
1341
1356
  readonly secret: Schema.optionalKey<Schema.String>;
1342
1357
  /** The platform derives the secret for the webhook; workspace code registers it. */
1343
1358
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
1359
+ /** The verification value of the webhook's `connection` that holds the secret. */
1360
+ readonly input: Schema.optionalKey<Schema.String>;
1344
1361
  readonly algorithm: Schema.optionalKey<Schema.String>;
1345
1362
  readonly encoding: Schema.optionalKey<Schema.String>;
1346
1363
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -1372,7 +1389,10 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1372
1389
  }>>;
1373
1390
  readonly verification: Schema.optionalKey<Schema.Struct<{
1374
1391
  readonly scheme: Schema.String;
1375
- readonly verifyToken: Schema.String;
1392
+ /** The workspace secret holding the token; absent when the token is an `input`. */
1393
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
1394
+ /** The verification value of the webhook's `connection` that holds the token. */
1395
+ readonly input: Schema.optionalKey<Schema.String>;
1376
1396
  }>>;
1377
1397
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
1378
1398
  /** The key of the connection whose provider sends to the webhook, when declared. */
@@ -1634,6 +1654,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1634
1654
  readonly tolerance?: number | undefined;
1635
1655
  readonly header?: string | undefined;
1636
1656
  } | undefined;
1657
+ readonly input?: string | undefined;
1637
1658
  readonly generated?: true | undefined;
1638
1659
  readonly algorithm?: string | undefined;
1639
1660
  readonly encoding?: string | undefined;
@@ -1650,7 +1671,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1650
1671
  } | undefined;
1651
1672
  readonly verification?: {
1652
1673
  readonly scheme: string;
1653
- readonly verifyToken: string;
1674
+ readonly input?: string | undefined;
1675
+ readonly verifyToken?: string | undefined;
1654
1676
  } | undefined;
1655
1677
  } | {
1656
1678
  readonly [x: string]: Schema.Json;
@@ -1983,6 +2005,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1983
2005
  readonly tolerance?: number | undefined;
1984
2006
  readonly header?: string | undefined;
1985
2007
  } | undefined;
2008
+ readonly input?: string | undefined;
1986
2009
  readonly generated?: true | undefined;
1987
2010
  readonly algorithm?: string | undefined;
1988
2011
  readonly encoding?: string | undefined;
@@ -1999,7 +2022,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1999
2022
  } | undefined;
2000
2023
  readonly verification?: {
2001
2024
  readonly scheme: string;
2002
- readonly verifyToken: string;
2025
+ readonly input?: string | undefined;
2026
+ readonly verifyToken?: string | undefined;
2003
2027
  } | undefined;
2004
2028
  } | {
2005
2029
  readonly [x: string]: Schema.Json;
@@ -2334,6 +2358,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2334
2358
  readonly tolerance?: number | undefined;
2335
2359
  readonly header?: string | undefined;
2336
2360
  } | undefined;
2361
+ readonly input?: string | undefined;
2337
2362
  readonly generated?: true | undefined;
2338
2363
  readonly algorithm?: string | undefined;
2339
2364
  readonly encoding?: string | undefined;
@@ -2350,7 +2375,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2350
2375
  } | undefined;
2351
2376
  readonly verification?: {
2352
2377
  readonly scheme: string;
2353
- readonly verifyToken: string;
2378
+ readonly input?: string | undefined;
2379
+ readonly verifyToken?: string | undefined;
2354
2380
  } | undefined;
2355
2381
  })[];
2356
2382
  readonly action?: {
@@ -2683,6 +2709,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2683
2709
  readonly tolerance?: number | undefined;
2684
2710
  readonly header?: string | undefined;
2685
2711
  } | undefined;
2712
+ readonly input?: string | undefined;
2686
2713
  readonly generated?: true | undefined;
2687
2714
  readonly algorithm?: string | undefined;
2688
2715
  readonly encoding?: string | undefined;
@@ -2699,7 +2726,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2699
2726
  } | undefined;
2700
2727
  readonly verification?: {
2701
2728
  readonly scheme: string;
2702
- readonly verifyToken: string;
2729
+ readonly input?: string | undefined;
2730
+ readonly verifyToken?: string | undefined;
2703
2731
  } | undefined;
2704
2732
  })[];
2705
2733
  readonly action?: {
@@ -3213,10 +3241,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3213
3241
  readonly description: Schema.String;
3214
3242
  readonly signature: Schema.optionalKey<Schema.Struct<{
3215
3243
  readonly scheme: Schema.String;
3216
- /** The workspace secret's name; absent when the secret is `generated`. */
3244
+ /** The workspace secret's name; absent when the secret is `generated` or an `input`. */
3217
3245
  readonly secret: Schema.optionalKey<Schema.String>;
3218
3246
  /** The platform derives the secret for the webhook; workspace code registers it. */
3219
3247
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
3248
+ /** The verification value of the webhook's `connection` that holds the secret. */
3249
+ readonly input: Schema.optionalKey<Schema.String>;
3220
3250
  readonly algorithm: Schema.optionalKey<Schema.String>;
3221
3251
  readonly encoding: Schema.optionalKey<Schema.String>;
3222
3252
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -3248,7 +3278,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3248
3278
  }>>;
3249
3279
  readonly verification: Schema.optionalKey<Schema.Struct<{
3250
3280
  readonly scheme: Schema.String;
3251
- readonly verifyToken: Schema.String;
3281
+ /** The workspace secret holding the token; absent when the token is an `input`. */
3282
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
3283
+ /** The verification value of the webhook's `connection` that holds the token. */
3284
+ readonly input: Schema.optionalKey<Schema.String>;
3252
3285
  }>>;
3253
3286
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
3254
3287
  /** The key of the connection whose provider sends to the webhook, when declared. */
@@ -3680,10 +3713,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3680
3713
  readonly description: Schema.String;
3681
3714
  readonly signature: Schema.optionalKey<Schema.Struct<{
3682
3715
  readonly scheme: Schema.String;
3683
- /** The workspace secret's name; absent when the secret is `generated`. */
3716
+ /** The workspace secret's name; absent when the secret is `generated` or an `input`. */
3684
3717
  readonly secret: Schema.optionalKey<Schema.String>;
3685
3718
  /** The platform derives the secret for the webhook; workspace code registers it. */
3686
3719
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
3720
+ /** The verification value of the webhook's `connection` that holds the secret. */
3721
+ readonly input: Schema.optionalKey<Schema.String>;
3687
3722
  readonly algorithm: Schema.optionalKey<Schema.String>;
3688
3723
  readonly encoding: Schema.optionalKey<Schema.String>;
3689
3724
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -3715,7 +3750,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3715
3750
  }>>;
3716
3751
  readonly verification: Schema.optionalKey<Schema.Struct<{
3717
3752
  readonly scheme: Schema.String;
3718
- readonly verifyToken: Schema.String;
3753
+ /** The workspace secret holding the token; absent when the token is an `input`. */
3754
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
3755
+ /** The verification value of the webhook's `connection` that holds the token. */
3756
+ readonly input: Schema.optionalKey<Schema.String>;
3719
3757
  }>>;
3720
3758
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
3721
3759
  /** The key of the connection whose provider sends to the webhook, when declared. */
@@ -3969,6 +4007,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3969
4007
  readonly tolerance?: number | undefined;
3970
4008
  readonly header?: string | undefined;
3971
4009
  } | undefined;
4010
+ readonly input?: string | undefined;
3972
4011
  readonly generated?: true | undefined;
3973
4012
  readonly algorithm?: string | undefined;
3974
4013
  readonly encoding?: string | undefined;
@@ -3985,7 +4024,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3985
4024
  } | undefined;
3986
4025
  readonly verification?: {
3987
4026
  readonly scheme: string;
3988
- readonly verifyToken: string;
4027
+ readonly input?: string | undefined;
4028
+ readonly verifyToken?: string | undefined;
3989
4029
  } | undefined;
3990
4030
  } | {
3991
4031
  readonly [x: string]: Schema.Json;
@@ -4318,6 +4358,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
4318
4358
  readonly tolerance?: number | undefined;
4319
4359
  readonly header?: string | undefined;
4320
4360
  } | undefined;
4361
+ readonly input?: string | undefined;
4321
4362
  readonly generated?: true | undefined;
4322
4363
  readonly algorithm?: string | undefined;
4323
4364
  readonly encoding?: string | undefined;
@@ -4334,7 +4375,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
4334
4375
  } | undefined;
4335
4376
  readonly verification?: {
4336
4377
  readonly scheme: string;
4337
- readonly verifyToken: string;
4378
+ readonly input?: string | undefined;
4379
+ readonly verifyToken?: string | undefined;
4338
4380
  } | undefined;
4339
4381
  } | {
4340
4382
  readonly [x: string]: Schema.Json;
@@ -4673,6 +4715,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4673
4715
  readonly tolerance?: number | undefined;
4674
4716
  readonly header?: string | undefined;
4675
4717
  } | undefined;
4718
+ readonly input?: string | undefined;
4676
4719
  readonly generated?: true | undefined;
4677
4720
  readonly algorithm?: string | undefined;
4678
4721
  readonly encoding?: string | undefined;
@@ -4689,7 +4732,8 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4689
4732
  } | undefined;
4690
4733
  readonly verification?: {
4691
4734
  readonly scheme: string;
4692
- readonly verifyToken: string;
4735
+ readonly input?: string | undefined;
4736
+ readonly verifyToken?: string | undefined;
4693
4737
  } | undefined;
4694
4738
  } | {
4695
4739
  readonly [x: string]: Schema.Json;
@@ -5022,6 +5066,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
5022
5066
  readonly tolerance?: number | undefined;
5023
5067
  readonly header?: string | undefined;
5024
5068
  } | undefined;
5069
+ readonly input?: string | undefined;
5025
5070
  readonly generated?: true | undefined;
5026
5071
  readonly algorithm?: string | undefined;
5027
5072
  readonly encoding?: string | undefined;
@@ -5038,7 +5083,8 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
5038
5083
  } | undefined;
5039
5084
  readonly verification?: {
5040
5085
  readonly scheme: string;
5041
- readonly verifyToken: string;
5086
+ readonly input?: string | undefined;
5087
+ readonly verifyToken?: string | undefined;
5042
5088
  } | undefined;
5043
5089
  } | {
5044
5090
  readonly [x: string]: Schema.Json;
package/dist/manifest.js CHANGED
@@ -352,10 +352,12 @@ export const WebhookTriggerManifest = Schema.Struct({
352
352
  description: Schema.String,
353
353
  signature: Schema.optionalKey(Schema.Struct({
354
354
  scheme: Schema.String,
355
- /** The workspace secret's name; absent when the secret is `generated`. */
355
+ /** The workspace secret's name; absent when the secret is `generated` or an `input`. */
356
356
  secret: Schema.optionalKey(Schema.String),
357
357
  /** The platform derives the secret for the webhook; workspace code registers it. */
358
358
  generated: Schema.optionalKey(Schema.Literal(true)),
359
+ /** The verification value of the webhook's `connection` that holds the secret. */
360
+ input: Schema.optionalKey(Schema.String),
359
361
  algorithm: Schema.optionalKey(Schema.String),
360
362
  encoding: Schema.optionalKey(Schema.String),
361
363
  key: Schema.optionalKey(Schema.Struct({ decode: Schema.String, prefix: Schema.optionalKey(Schema.String) })),
@@ -377,7 +379,13 @@ export const WebhookTriggerManifest = Schema.Struct({
377
379
  Schema.Struct({ timestamp: Schema.Literal(true) }),
378
380
  ]))),
379
381
  })),
380
- verification: Schema.optionalKey(Schema.Struct({ scheme: Schema.String, verifyToken: Schema.String })),
382
+ verification: Schema.optionalKey(Schema.Struct({
383
+ scheme: Schema.String,
384
+ /** The workspace secret holding the token; absent when the token is an `input`. */
385
+ verifyToken: Schema.optionalKey(Schema.String),
386
+ /** The verification value of the webhook's `connection` that holds the token. */
387
+ input: Schema.optionalKey(Schema.String),
388
+ })),
381
389
  headers: Schema.optionalKey(Schema.Array(Schema.String)),
382
390
  /** The key of the connection whose provider sends to the webhook, when declared. */
383
391
  connection: Schema.optionalKey(Schema.String),
@@ -465,6 +465,7 @@ export declare const MigrationPlan: Schema.Struct<{
465
465
  readonly tolerance?: number | undefined;
466
466
  readonly header?: string | undefined;
467
467
  } | undefined;
468
+ readonly input?: string | undefined;
468
469
  readonly generated?: true | undefined;
469
470
  readonly algorithm?: string | undefined;
470
471
  readonly encoding?: string | undefined;
@@ -481,7 +482,8 @@ export declare const MigrationPlan: Schema.Struct<{
481
482
  } | undefined;
482
483
  readonly verification?: {
483
484
  readonly scheme: string;
484
- readonly verifyToken: string;
485
+ readonly input?: string | undefined;
486
+ readonly verifyToken?: string | undefined;
485
487
  } | undefined;
486
488
  } | {
487
489
  readonly [x: string]: Schema.Json;
@@ -814,6 +816,7 @@ export declare const MigrationPlan: Schema.Struct<{
814
816
  readonly tolerance?: number | undefined;
815
817
  readonly header?: string | undefined;
816
818
  } | undefined;
819
+ readonly input?: string | undefined;
817
820
  readonly generated?: true | undefined;
818
821
  readonly algorithm?: string | undefined;
819
822
  readonly encoding?: string | undefined;
@@ -830,7 +833,8 @@ export declare const MigrationPlan: Schema.Struct<{
830
833
  } | undefined;
831
834
  readonly verification?: {
832
835
  readonly scheme: string;
833
- readonly verifyToken: string;
836
+ readonly input?: string | undefined;
837
+ readonly verifyToken?: string | undefined;
834
838
  } | undefined;
835
839
  } | {
836
840
  readonly [x: string]: Schema.Json;
@@ -1165,6 +1169,7 @@ export declare const MigrationPlan: Schema.Struct<{
1165
1169
  readonly tolerance?: number | undefined;
1166
1170
  readonly header?: string | undefined;
1167
1171
  } | undefined;
1172
+ readonly input?: string | undefined;
1168
1173
  readonly generated?: true | undefined;
1169
1174
  readonly algorithm?: string | undefined;
1170
1175
  readonly encoding?: string | undefined;
@@ -1181,7 +1186,8 @@ export declare const MigrationPlan: Schema.Struct<{
1181
1186
  } | undefined;
1182
1187
  readonly verification?: {
1183
1188
  readonly scheme: string;
1184
- readonly verifyToken: string;
1189
+ readonly input?: string | undefined;
1190
+ readonly verifyToken?: string | undefined;
1185
1191
  } | undefined;
1186
1192
  })[];
1187
1193
  readonly action?: {
@@ -1514,6 +1520,7 @@ export declare const MigrationPlan: Schema.Struct<{
1514
1520
  readonly tolerance?: number | undefined;
1515
1521
  readonly header?: string | undefined;
1516
1522
  } | undefined;
1523
+ readonly input?: string | undefined;
1517
1524
  readonly generated?: true | undefined;
1518
1525
  readonly algorithm?: string | undefined;
1519
1526
  readonly encoding?: string | undefined;
@@ -1530,7 +1537,8 @@ export declare const MigrationPlan: Schema.Struct<{
1530
1537
  } | undefined;
1531
1538
  readonly verification?: {
1532
1539
  readonly scheme: string;
1533
- readonly verifyToken: string;
1540
+ readonly input?: string | undefined;
1541
+ readonly verifyToken?: string | undefined;
1534
1542
  } | undefined;
1535
1543
  })[];
1536
1544
  readonly action?: {
@@ -1963,6 +1971,7 @@ export declare const MigrationPlan: Schema.Struct<{
1963
1971
  readonly scheme: Schema.String;
1964
1972
  readonly secret: Schema.optionalKey<Schema.String>;
1965
1973
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
1974
+ readonly input: Schema.optionalKey<Schema.String>;
1966
1975
  readonly algorithm: Schema.optionalKey<Schema.String>;
1967
1976
  readonly encoding: Schema.optionalKey<Schema.String>;
1968
1977
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -1994,7 +2003,8 @@ export declare const MigrationPlan: Schema.Struct<{
1994
2003
  }>>;
1995
2004
  readonly verification: Schema.optionalKey<Schema.Struct<{
1996
2005
  readonly scheme: Schema.String;
1997
- readonly verifyToken: Schema.String;
2006
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
2007
+ readonly input: Schema.optionalKey<Schema.String>;
1998
2008
  }>>;
1999
2009
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
2000
2010
  readonly connection: Schema.optionalKey<Schema.String>;
@@ -2308,6 +2318,7 @@ export declare const MigrationPlan: Schema.Struct<{
2308
2318
  readonly scheme: Schema.String;
2309
2319
  readonly secret: Schema.optionalKey<Schema.String>;
2310
2320
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
2321
+ readonly input: Schema.optionalKey<Schema.String>;
2311
2322
  readonly algorithm: Schema.optionalKey<Schema.String>;
2312
2323
  readonly encoding: Schema.optionalKey<Schema.String>;
2313
2324
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -2339,7 +2350,8 @@ export declare const MigrationPlan: Schema.Struct<{
2339
2350
  }>>;
2340
2351
  readonly verification: Schema.optionalKey<Schema.Struct<{
2341
2352
  readonly scheme: Schema.String;
2342
- readonly verifyToken: Schema.String;
2353
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
2354
+ readonly input: Schema.optionalKey<Schema.String>;
2343
2355
  }>>;
2344
2356
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
2345
2357
  readonly connection: Schema.optionalKey<Schema.String>;
@@ -2564,6 +2576,7 @@ export declare const MigrationPlan: Schema.Struct<{
2564
2576
  readonly tolerance?: number | undefined;
2565
2577
  readonly header?: string | undefined;
2566
2578
  } | undefined;
2579
+ readonly input?: string | undefined;
2567
2580
  readonly generated?: true | undefined;
2568
2581
  readonly algorithm?: string | undefined;
2569
2582
  readonly encoding?: string | undefined;
@@ -2580,7 +2593,8 @@ export declare const MigrationPlan: Schema.Struct<{
2580
2593
  } | undefined;
2581
2594
  readonly verification?: {
2582
2595
  readonly scheme: string;
2583
- readonly verifyToken: string;
2596
+ readonly input?: string | undefined;
2597
+ readonly verifyToken?: string | undefined;
2584
2598
  } | undefined;
2585
2599
  } | {
2586
2600
  readonly [x: string]: Schema.Json;
@@ -2913,6 +2927,7 @@ export declare const MigrationPlan: Schema.Struct<{
2913
2927
  readonly tolerance?: number | undefined;
2914
2928
  readonly header?: string | undefined;
2915
2929
  } | undefined;
2930
+ readonly input?: string | undefined;
2916
2931
  readonly generated?: true | undefined;
2917
2932
  readonly algorithm?: string | undefined;
2918
2933
  readonly encoding?: string | undefined;
@@ -2929,7 +2944,8 @@ export declare const MigrationPlan: Schema.Struct<{
2929
2944
  } | undefined;
2930
2945
  readonly verification?: {
2931
2946
  readonly scheme: string;
2932
- readonly verifyToken: string;
2947
+ readonly input?: string | undefined;
2948
+ readonly verifyToken?: string | undefined;
2933
2949
  } | undefined;
2934
2950
  } | {
2935
2951
  readonly [x: string]: Schema.Json;
@@ -587,6 +587,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
587
587
  readonly scheme: Schema.String;
588
588
  readonly secret: Schema.optionalKey<Schema.String>;
589
589
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
590
+ readonly input: Schema.optionalKey<Schema.String>;
590
591
  readonly algorithm: Schema.optionalKey<Schema.String>;
591
592
  readonly encoding: Schema.optionalKey<Schema.String>;
592
593
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -618,7 +619,8 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
618
619
  }>>;
619
620
  readonly verification: Schema.optionalKey<Schema.Struct<{
620
621
  readonly scheme: Schema.String;
621
- readonly verifyToken: Schema.String;
622
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
623
+ readonly input: Schema.optionalKey<Schema.String>;
622
624
  }>>;
623
625
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
624
626
  readonly connection: Schema.optionalKey<Schema.String>;
@@ -945,6 +947,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
945
947
  readonly scheme: Schema.String;
946
948
  readonly secret: Schema.optionalKey<Schema.String>;
947
949
  readonly generated: Schema.optionalKey<Schema.Literal<true>>;
950
+ readonly input: Schema.optionalKey<Schema.String>;
948
951
  readonly algorithm: Schema.optionalKey<Schema.String>;
949
952
  readonly encoding: Schema.optionalKey<Schema.String>;
950
953
  readonly key: Schema.optionalKey<Schema.Struct<{
@@ -976,7 +979,8 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
976
979
  }>>;
977
980
  readonly verification: Schema.optionalKey<Schema.Struct<{
978
981
  readonly scheme: Schema.String;
979
- readonly verifyToken: Schema.String;
982
+ readonly verifyToken: Schema.optionalKey<Schema.String>;
983
+ readonly input: Schema.optionalKey<Schema.String>;
980
984
  }>>;
981
985
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
982
986
  readonly connection: Schema.optionalKey<Schema.String>;
@@ -13,7 +13,7 @@ export type WebhookVerification = {
13
13
  } | {
14
14
  readonly outcome: "invalid";
15
15
  }
16
- /** The workspace secret the webhook names does not exist. */
16
+ /** The secret the webhook names does not exist, or its connection's value is unset. */
17
17
  | {
18
18
  readonly outcome: "secret_missing";
19
19
  }
@@ -25,8 +25,13 @@ export type WebhookVerification = {
25
25
  };
26
26
  /** A signature check the ontology service asks the backend for: the secret never leaves it. */
27
27
  export interface WebhookVerifyRequest {
28
- /** The workspace secret's name. */
28
+ /** The workspace secret's name, when the secret is no connection's verification value. */
29
29
  readonly secret: string;
30
+ /** The verification value of the webhook's connection that holds the secret, when declared. */
31
+ readonly input?: {
32
+ readonly connection: string;
33
+ readonly field: string;
34
+ } | undefined;
30
35
  readonly algorithm: WebhookHmacAlgorithm;
31
36
  readonly encoding: WebhookSignatureEncoding;
32
37
  /** How the secret's value becomes the key, when not as its UTF-8 bytes. */
@@ -50,8 +55,10 @@ export type WebhookTokenVerifier = (request: WebhookTokenVerifyRequest) => Promi
50
55
  export declare const WEBHOOK_VERIFY_TIMEOUT_MS = 3000;
51
56
  /**
52
57
  * The verifier of a deployed ontology service: `POST
53
- * /api/internal/v1/workspaces/{id}/secrets/{name}/verify-hmac` on SegmentStream with the request's
54
- * Vercel OIDC token, admitted only for the secrets the deployed ontology's webhooks name.
58
+ * /api/internal/v1/workspaces/{id}/secrets/{name}/verify-hmac`, or
59
+ * `.../connections/{key}/inputs/{field}/verify-hmac` for a connection's verification value, on
60
+ * SegmentStream with the request's Vercel OIDC token, admitted only for the secrets the deployed
61
+ * ontology's webhooks name.
55
62
  */
56
63
  export declare function deployedWebhookVerifier(environment: {
57
64
  readonly segmentstreamUrl: string;
@@ -80,7 +87,7 @@ export declare function deployedSecretVerifier(environment: {
80
87
  readonly organizationId: string;
81
88
  readonly deploymentId?: string | undefined;
82
89
  readonly previewCredential?: Redacted.Redacted<string> | undefined;
83
- }, operation: "verify-hmac" | "verify-token" | "verify-challenge", fetchImpl: typeof fetch): (request: Pick<WebhookVerifyRequest, "secret" | "identityToken" | "requestId">, payload: unknown) => Promise<WebhookVerification>;
90
+ }, operation: "verify-hmac" | "verify-token" | "verify-challenge", fetchImpl: typeof fetch): (request: Pick<WebhookVerifyRequest, "secret" | "input" | "identityToken" | "requestId">, payload: unknown) => Promise<WebhookVerification>;
84
91
  /** The bytes a scheme's signatures cover and the signatures to compare, or why it refused. */
85
92
  export type SignedContent = {
86
93
  readonly ok: true;
@@ -7,8 +7,10 @@ import { fixedWindowLimiter } from "./rate-limit.js";
7
7
  export const WEBHOOK_VERIFY_TIMEOUT_MS = 3_000;
8
8
  /**
9
9
  * The verifier of a deployed ontology service: `POST
10
- * /api/internal/v1/workspaces/{id}/secrets/{name}/verify-hmac` on SegmentStream with the request's
11
- * Vercel OIDC token, admitted only for the secrets the deployed ontology's webhooks name.
10
+ * /api/internal/v1/workspaces/{id}/secrets/{name}/verify-hmac`, or
11
+ * `.../connections/{key}/inputs/{field}/verify-hmac` for a connection's verification value, on
12
+ * SegmentStream with the request's Vercel OIDC token, admitted only for the secrets the deployed
13
+ * ontology's webhooks name.
12
14
  */
13
15
  export function deployedWebhookVerifier(environment, fetchImpl = fetch) {
14
16
  const verify = deployedSecretVerifier(environment, "verify-hmac", fetchImpl);
@@ -40,7 +42,11 @@ export function deployedWebhookTokenVerifier(environment, fetchImpl = fetch) {
40
42
  */
41
43
  export function deployedSecretVerifier(environment, operation, fetchImpl) {
42
44
  const base = `${environment.segmentstreamUrl}/api/internal/v1/workspaces/` +
43
- `${encodeURIComponent(environment.workspaceId)}/secrets/`;
45
+ `${encodeURIComponent(environment.workspaceId)}/`;
46
+ const target = (request) => request.input === undefined
47
+ ? `secrets/${encodeURIComponent(request.secret)}`
48
+ : `connections/${encodeURIComponent(request.input.connection)}/inputs/` +
49
+ encodeURIComponent(request.input.field);
44
50
  return async (request, payload) => {
45
51
  if (request.identityToken === undefined || request.identityToken === "") {
46
52
  return {
@@ -49,7 +55,7 @@ export function deployedSecretVerifier(environment, operation, fetchImpl) {
49
55
  };
50
56
  }
51
57
  try {
52
- const response = await fetchImpl(`${base}${encodeURIComponent(request.secret)}/${operation}`, {
58
+ const response = await fetchImpl(`${base}${target(request)}/${operation}`, {
53
59
  method: "POST",
54
60
  headers: {
55
61
  "content-type": "application/json",
@@ -1318,7 +1318,10 @@ export function workflowsLayer(options) {
1318
1318
  return yield* refuse("verification_query", 403);
1319
1319
  }
1320
1320
  const verified = yield* Effect.promise(() => verifier({
1321
- secret: verification.verifyToken,
1321
+ secret: verification.verifyToken ?? "",
1322
+ ...(verification.input === undefined || trigger.connection === undefined
1323
+ ? {}
1324
+ : { input: { connection: trigger.connection, field: verification.input } }),
1322
1325
  token,
1323
1326
  identityToken: requestIdentityToken(request),
1324
1327
  requestId,
@@ -1382,6 +1385,9 @@ export function workflowsLayer(options) {
1382
1385
  const verifier = options.webhookVerifier;
1383
1386
  const verified = yield* Effect.promise(() => verifier({
1384
1387
  secret: signature.secret ?? "",
1388
+ ...(signature.input === undefined || trigger.connection === undefined
1389
+ ? {}
1390
+ : { input: { connection: trigger.connection, field: signature.input } }),
1385
1391
  algorithm: format.algorithm,
1386
1392
  encoding: format.encoding,
1387
1393
  ...(format.key === undefined ? {} : { key: format.key }),
@@ -89,25 +89,30 @@ export declare function webhookHmacFormat(signature: {
89
89
  readonly scheme: string;
90
90
  }): WebhookHmacFormat | undefined;
91
91
  /**
92
- * Where a signature's secret comes from: a workspace secret by `secret` name, or with
93
- * `generated: true` the secret the platform derives for the webhook, which workspace code reads
94
- * with `webhookSigningSecret(trigger)` to register it.
92
+ * Where a signature's secret comes from: a verification value of the webhook's connection by
93
+ * `input`, with `generated: true` the secret the platform derives for the webhook, which workspace
94
+ * code reads with `webhookSigningSecret(trigger)` to register it, or a workspace secret by
95
+ * `secret` name.
95
96
  */
96
97
  export interface WebhookSignatureSource {
97
98
  readonly scheme: string;
98
99
  readonly secret?: string | undefined;
99
100
  readonly generated?: true | undefined;
101
+ readonly input?: string | undefined;
100
102
  }
101
103
  /**
102
- * A signature as listings present it: its scheme and the secret's name, which reads `generated`
103
- * with `generated: true` for a secret the platform derives, so readers that know only names still
104
- * show something true.
104
+ * A signature as listings present it: its scheme and where its secret is. `secret` reads
105
+ * `generated` for a secret the platform derives and the value's key for a connection's
106
+ * verification value, so readers that know only names still show something true.
105
107
  */
106
108
  export declare function presentedWebhookSignature(signature: WebhookSignatureSource): {
107
109
  readonly scheme: string;
108
110
  readonly secret: string;
109
111
  readonly generated?: true;
112
+ readonly input?: string;
110
113
  };
114
+ /** A verification value's key on its connection, as connections name fields: `webhook_signing_secret`. */
115
+ export declare const CONNECTION_INPUT_KEY: RegExp;
111
116
  /** A problem with a signature declaration: the key it concerns, under `signature`, and why. */
112
117
  export interface WebhookSignatureProblem {
113
118
  readonly path: string;
@@ -115,8 +120,9 @@ export interface WebhookSignatureProblem {
115
120
  }
116
121
  /**
117
122
  * Every problem of a webhook trigger's `signature`, as `check` and SegmentStream's publication
118
- * check report them: a known scheme and a workspace secret's name, and for `hmac` a complete
119
- * format. Empty when the declaration is valid.
123
+ * check report them: a known scheme, one source of the secret, and for `hmac` a complete format.
124
+ * Empty when the declaration is valid. That an `input` has a connection to read it from is the
125
+ * trigger's check.
120
126
  */
121
127
  export declare function webhookSignatureProblems(signature: unknown): ReadonlyArray<WebhookSignatureProblem>;
122
128
  /**
package/dist/webhooks.js CHANGED
@@ -62,15 +62,20 @@ export function webhookHmacFormat(signature) {
62
62
  }
63
63
  }
64
64
  /**
65
- * A signature as listings present it: its scheme and the secret's name, which reads `generated`
66
- * with `generated: true` for a secret the platform derives, so readers that know only names still
67
- * show something true.
65
+ * A signature as listings present it: its scheme and where its secret is. `secret` reads
66
+ * `generated` for a secret the platform derives and the value's key for a connection's
67
+ * verification value, so readers that know only names still show something true.
68
68
  */
69
69
  export function presentedWebhookSignature(signature) {
70
- return signature.generated === true
71
- ? { scheme: signature.scheme, secret: "generated", generated: true }
70
+ if (signature.generated === true) {
71
+ return { scheme: signature.scheme, secret: "generated", generated: true };
72
+ }
73
+ return signature.input !== undefined
74
+ ? { scheme: signature.scheme, secret: signature.input, input: signature.input }
72
75
  : { scheme: signature.scheme, secret: signature.secret ?? "" };
73
76
  }
77
+ /** A verification value's key on its connection, as connections name fields: `webhook_signing_secret`. */
78
+ export const CONNECTION_INPUT_KEY = /^[a-z][a-z0-9_]{0,31}$/;
74
79
  const FORMAT_KEYS = ["algorithm", "encoding", "key", "signatures", "timestamp", "message"];
75
80
  const PRINTABLE = /^[\x21-\x7e]{1,16}$/;
76
81
  const ENTRY_NAME = /^[A-Za-z0-9_.-]{1,16}$/;
@@ -82,23 +87,34 @@ function unknownKeys(value, known) {
82
87
  }
83
88
  /**
84
89
  * Every problem of a webhook trigger's `signature`, as `check` and SegmentStream's publication
85
- * check report them: a known scheme and a workspace secret's name, and for `hmac` a complete
86
- * format. Empty when the declaration is valid.
90
+ * check report them: a known scheme, one source of the secret, and for `hmac` a complete format.
91
+ * Empty when the declaration is valid. That an `input` has a connection to read it from is the
92
+ * trigger's check.
87
93
  */
88
94
  export function webhookSignatureProblems(signature) {
89
95
  const problems = [];
90
96
  const report = (path, message) => problems.push({ path, message });
91
97
  if (!isRecord(signature)) {
92
- report("", "signature is { scheme, secret }, or omitted for a provider that signs nothing.");
98
+ report("", "signature is { scheme, input }, or omitted for a provider that signs nothing.");
93
99
  return problems;
94
100
  }
95
- const { scheme, secret, generated } = signature;
101
+ const { scheme, secret, generated, input } = signature;
96
102
  if (!WEBHOOK_SIGNATURE_SCHEMES.includes(scheme)) {
97
103
  report("scheme", `${JSON.stringify(scheme) ?? "undefined"} is not a signature scheme; use one of ` +
98
104
  `${WEBHOOK_SIGNATURE_SCHEMES.join(", ")}, or omit signature for a provider that signs ` +
99
105
  "nothing.");
100
106
  }
101
- if (generated !== undefined) {
107
+ if (input !== undefined) {
108
+ if (typeof input !== "string" || !CONNECTION_INPUT_KEY.test(input)) {
109
+ report("input", `${JSON.stringify(input) ?? "undefined"} is not a connection's verification value; name ` +
110
+ "the value of the webhook's connection that holds the provider's signing secret, such " +
111
+ "as webhook_signing_secret.");
112
+ }
113
+ if (secret !== undefined || generated !== undefined) {
114
+ report("input", "A signature's secret is an input, generated or a named secret: one of them.");
115
+ }
116
+ }
117
+ else if (generated !== undefined) {
102
118
  if (generated !== true) {
103
119
  report("generated", "generated is true, or omitted with a secret named instead.");
104
120
  }
@@ -110,11 +126,12 @@ export function webhookSignatureProblems(signature) {
110
126
  }
111
127
  }
112
128
  else if (typeof secret !== "string" || !WORKSPACE_SECRET_NAME.test(secret)) {
113
- report("secret", `${JSON.stringify(secret) ?? "undefined"} is not a workspace secret name; name the ` +
114
- "secret that holds the provider's signing secret, such as stripe-webhook-signing-secret, " +
115
- "or set generated: true for a secret workspace code registers.");
129
+ report("secret", `${JSON.stringify(secret) ?? "undefined"} is not a workspace secret name; set input to ` +
130
+ "the verification value of the webhook's connection that holds the provider's signing " +
131
+ "secret, such as webhook_signing_secret, or generated: true for a secret workspace code " +
132
+ "registers.");
116
133
  }
117
- const named = ["scheme", "secret", "generated"];
134
+ const named = ["scheme", "secret", "generated", "input"];
118
135
  if (scheme !== "hmac") {
119
136
  for (const key of unknownKeys(signature, named)) {
120
137
  report(key, FORMAT_KEYS.includes(key)
@@ -271,7 +288,11 @@ function signedHeaderProblem(name) {
271
288
  * scheme, and for `hmac` its format's settings, each written only when declared.
272
289
  */
273
290
  export function webhookSignatureManifest(signature) {
274
- const source = signature.generated === true ? { generated: true } : { secret: signature.secret };
291
+ const source = signature.generated === true
292
+ ? { generated: true }
293
+ : signature.input !== undefined
294
+ ? { input: signature.input }
295
+ : { secret: signature.secret };
275
296
  if (signature.scheme !== "hmac") {
276
297
  return { scheme: signature.scheme, ...source };
277
298
  }
@@ -122,9 +122,9 @@ export interface ActionTrigger<Name extends string = string, Input = unknown> {
122
122
  readonly role?: string | undefined;
123
123
  }
124
124
  /**
125
- * Where a webhook's deliveries are checked: a provider's signature format and the workspace secret
126
- * that holds its signing secret. Without one, the webhook's URL ends in a token. `stripe` and `meta`
127
- * name published formats; `hmac` declares any other HMAC format with the trigger.
125
+ * Where a webhook's deliveries are checked: a provider's signature format and where its signing
126
+ * secret is held. Without one, the webhook's URL ends in a token. `stripe` and `meta` name
127
+ * published formats; `hmac` declares any other HMAC format with the trigger.
128
128
  */
129
129
  export type WebhookSignature = ({
130
130
  readonly scheme: Exclude<WebhookSignatureScheme, "hmac">;
@@ -132,23 +132,42 @@ export type WebhookSignature = ({
132
132
  readonly scheme: "hmac";
133
133
  } & WebhookSignatureSecret & WebhookHmacFormat);
134
134
  /**
135
- * The secret a signature is checked with: a workspace secret by name, whose value stays in the
136
- * platform, or `generated: true`, the secret the platform derives for the webhook, which workspace
137
- * code reads with `webhookSigningSecret(trigger)` to register it with the provider.
135
+ * The secret a signature is checked with. `input` names a verification value of the webhook's
136
+ * `connection`, such as the `webhook_signing_secret` Stripe's connection declares: members paste
137
+ * the provider's secret on that connection, and it never leaves the platform. `generated: true` is
138
+ * the secret the platform derives for the webhook, which workspace code reads with
139
+ * `webhookSigningSecret(trigger)` to register it with the provider. `secret` names a workspace
140
+ * secret, the older form.
138
141
  */
139
142
  export type WebhookSignatureSecret = {
140
- /** A workspace secret's name, such as `stripe-webhook-signing-secret`. */
141
- readonly secret: string;
143
+ /** A verification value of the webhook's `connection`, such as `webhook_signing_secret`. */
144
+ readonly input: string;
145
+ readonly secret?: undefined;
142
146
  readonly generated?: undefined;
143
147
  } | {
144
148
  readonly generated: true;
145
149
  readonly secret?: undefined;
150
+ readonly input?: undefined;
151
+ } | {
152
+ /** A workspace secret's name, such as `stripe-webhook-signing-secret`. */
153
+ readonly secret: string;
154
+ readonly generated?: undefined;
155
+ readonly input?: undefined;
146
156
  };
147
- /** Meta's registration handshake; the verify token is a workspace secret, separate from the app secret. */
148
- export interface WebhookVerification {
157
+ /**
158
+ * Meta's registration handshake. The verify token is a verification value of the webhook's
159
+ * `connection` (`input`), or a workspace secret (`verifyToken`, the older form), separate from the
160
+ * app secret either way.
161
+ */
162
+ export type WebhookVerification = {
163
+ readonly scheme: "meta";
164
+ readonly input: string;
165
+ readonly verifyToken?: undefined;
166
+ } | {
149
167
  readonly scheme: "meta";
150
168
  readonly verifyToken: string;
151
- }
169
+ readonly input?: undefined;
170
+ };
152
171
  /**
153
172
  * A webhook trigger, `webhook(name, { description, signature, headers })`: the ontology service
154
173
  * starts the workflow for each genuine delivery to `/api/webhooks/<name>`, with the delivery as its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.128.1",
3
+ "version": "0.129.0",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",