@segmentstream/ontology 0.125.0 → 0.126.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 +10 -0
- package/dist/analyze.js +4 -17
- package/dist/index.d.ts +1 -1
- package/dist/manifest.d.ts +405 -9
- package/dist/manifest.js +29 -2
- package/dist/migrate/model.d.ts +230 -6
- package/dist/service/schemas.d.ts +56 -0
- package/dist/service/webhooks.d.ts +22 -6
- package/dist/service/webhooks.js +131 -50
- package/dist/service/workflows.js +8 -6
- package/dist/webhooks.d.ts +105 -2
- package/dist/webhooks.js +293 -2
- package/dist/workflow.d.ts +10 -5
- package/dist/workflows.d.ts +1 -1
- package/package.json +1 -1
package/dist/manifest.js
CHANGED
|
@@ -94,6 +94,9 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGue
|
|
|
94
94
|
* `roles` whose people's private chats the agent registers as `agent_chat` records of kind
|
|
95
95
|
* `private`, and in `takeover.channels` the channels whose chats staff may take over from the
|
|
96
96
|
* agent. Older readers ignore it, register none and let none be taken over.
|
|
97
|
+
* Within version 15, a webhook trigger's `signature` may have scheme `hmac` and carry the provider's
|
|
98
|
+
* format, written only when declared. Older readers present the scheme and ignore the format; an
|
|
99
|
+
* older publication check refuses the scheme.
|
|
97
100
|
*/
|
|
98
101
|
export const MANIFEST_VERSION = 15;
|
|
99
102
|
/** The first version whose documents use snake_case names on the wire. */
|
|
@@ -338,13 +341,37 @@ export const ActionTriggerManifest = Schema.Struct({
|
|
|
338
341
|
* scheme against the named workspace secret; without it, the URL ends in a derived token.
|
|
339
342
|
* `verification` opts into a registration handshake; `headers` lists the request headers the
|
|
340
343
|
* delivery carries; `connection` names the connection whose provider sends to it. Optional
|
|
341
|
-
* settings are written only when declared.
|
|
344
|
+
* settings are written only when declared. A signature of scheme `hmac` carries its format:
|
|
345
|
+
* `algorithm`, `encoding`, `key`, `signatures`, `timestamp` and `message`.
|
|
342
346
|
*/
|
|
343
347
|
export const WebhookTriggerManifest = Schema.Struct({
|
|
344
348
|
kind: Schema.Literal("webhook"),
|
|
345
349
|
name: Schema.String,
|
|
346
350
|
description: Schema.String,
|
|
347
|
-
signature: Schema.optionalKey(Schema.Struct({
|
|
351
|
+
signature: Schema.optionalKey(Schema.Struct({
|
|
352
|
+
scheme: Schema.String,
|
|
353
|
+
secret: Schema.String,
|
|
354
|
+
algorithm: Schema.optionalKey(Schema.String),
|
|
355
|
+
encoding: Schema.optionalKey(Schema.String),
|
|
356
|
+
key: Schema.optionalKey(Schema.Struct({ decode: Schema.String, prefix: Schema.optionalKey(Schema.String) })),
|
|
357
|
+
signatures: Schema.optionalKey(Schema.Struct({
|
|
358
|
+
header: Schema.String,
|
|
359
|
+
prefix: Schema.optionalKey(Schema.String),
|
|
360
|
+
entries: Schema.optionalKey(Schema.Struct({ separator: Schema.String, assign: Schema.String, name: Schema.String })),
|
|
361
|
+
})),
|
|
362
|
+
timestamp: Schema.optionalKey(Schema.Struct({
|
|
363
|
+
header: Schema.optionalKey(Schema.String),
|
|
364
|
+
entry: Schema.optionalKey(Schema.String),
|
|
365
|
+
unit: Schema.optionalKey(Schema.String),
|
|
366
|
+
tolerance: Schema.optionalKey(Schema.Number),
|
|
367
|
+
})),
|
|
368
|
+
message: Schema.optionalKey(Schema.Array(Schema.Union([
|
|
369
|
+
Schema.String,
|
|
370
|
+
Schema.Struct({ body: Schema.Literal(true) }),
|
|
371
|
+
Schema.Struct({ header: Schema.String }),
|
|
372
|
+
Schema.Struct({ timestamp: Schema.Literal(true) }),
|
|
373
|
+
]))),
|
|
374
|
+
})),
|
|
348
375
|
verification: Schema.optionalKey(Schema.Struct({ scheme: Schema.String, verifyToken: Schema.String })),
|
|
349
376
|
headers: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
350
377
|
/** The key of the connection whose provider sends to the webhook, when declared. */
|
package/dist/migrate/model.d.ts
CHANGED
|
@@ -416,8 +416,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
416
416
|
};
|
|
417
417
|
} | undefined;
|
|
418
418
|
readonly attribution?: {
|
|
419
|
-
readonly template?: string | undefined;
|
|
420
419
|
readonly separator?: string | undefined;
|
|
420
|
+
readonly template?: string | undefined;
|
|
421
421
|
} | undefined;
|
|
422
422
|
} | undefined;
|
|
423
423
|
readonly workflows?: readonly {
|
|
@@ -449,6 +449,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
449
449
|
readonly signature?: {
|
|
450
450
|
readonly scheme: string;
|
|
451
451
|
readonly secret: string;
|
|
452
|
+
readonly message?: readonly (string | {
|
|
453
|
+
readonly body: true;
|
|
454
|
+
} | {
|
|
455
|
+
readonly header: string;
|
|
456
|
+
} | {
|
|
457
|
+
readonly timestamp: true;
|
|
458
|
+
})[] | undefined;
|
|
459
|
+
readonly key?: {
|
|
460
|
+
readonly decode: string;
|
|
461
|
+
readonly prefix?: string | undefined;
|
|
462
|
+
} | undefined;
|
|
463
|
+
readonly timestamp?: {
|
|
464
|
+
readonly unit?: string | undefined;
|
|
465
|
+
readonly entry?: string | undefined;
|
|
466
|
+
readonly tolerance?: number | undefined;
|
|
467
|
+
readonly header?: string | undefined;
|
|
468
|
+
} | undefined;
|
|
469
|
+
readonly algorithm?: string | undefined;
|
|
470
|
+
readonly encoding?: string | undefined;
|
|
471
|
+
readonly signatures?: {
|
|
472
|
+
readonly header: string;
|
|
473
|
+
readonly entries?: {
|
|
474
|
+
readonly separator: string;
|
|
475
|
+
readonly assign: string;
|
|
476
|
+
readonly name: string;
|
|
477
|
+
} | undefined;
|
|
478
|
+
readonly prefix?: string | undefined;
|
|
479
|
+
} | undefined;
|
|
452
480
|
} | undefined;
|
|
453
481
|
readonly verification?: {
|
|
454
482
|
readonly scheme: string;
|
|
@@ -736,8 +764,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
736
764
|
};
|
|
737
765
|
} | undefined;
|
|
738
766
|
readonly attribution?: {
|
|
739
|
-
readonly template?: string | undefined;
|
|
740
767
|
readonly separator?: string | undefined;
|
|
768
|
+
readonly template?: string | undefined;
|
|
741
769
|
} | undefined;
|
|
742
770
|
} | undefined;
|
|
743
771
|
readonly workflows?: readonly {
|
|
@@ -769,6 +797,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
769
797
|
readonly signature?: {
|
|
770
798
|
readonly scheme: string;
|
|
771
799
|
readonly secret: string;
|
|
800
|
+
readonly message?: readonly (string | {
|
|
801
|
+
readonly body: true;
|
|
802
|
+
} | {
|
|
803
|
+
readonly header: string;
|
|
804
|
+
} | {
|
|
805
|
+
readonly timestamp: true;
|
|
806
|
+
})[] | undefined;
|
|
807
|
+
readonly key?: {
|
|
808
|
+
readonly decode: string;
|
|
809
|
+
readonly prefix?: string | undefined;
|
|
810
|
+
} | undefined;
|
|
811
|
+
readonly timestamp?: {
|
|
812
|
+
readonly unit?: string | undefined;
|
|
813
|
+
readonly entry?: string | undefined;
|
|
814
|
+
readonly tolerance?: number | undefined;
|
|
815
|
+
readonly header?: string | undefined;
|
|
816
|
+
} | undefined;
|
|
817
|
+
readonly algorithm?: string | undefined;
|
|
818
|
+
readonly encoding?: string | undefined;
|
|
819
|
+
readonly signatures?: {
|
|
820
|
+
readonly header: string;
|
|
821
|
+
readonly entries?: {
|
|
822
|
+
readonly separator: string;
|
|
823
|
+
readonly assign: string;
|
|
824
|
+
readonly name: string;
|
|
825
|
+
} | undefined;
|
|
826
|
+
readonly prefix?: string | undefined;
|
|
827
|
+
} | undefined;
|
|
772
828
|
} | undefined;
|
|
773
829
|
readonly verification?: {
|
|
774
830
|
readonly scheme: string;
|
|
@@ -1056,8 +1112,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1056
1112
|
};
|
|
1057
1113
|
} | undefined;
|
|
1058
1114
|
readonly attribution?: {
|
|
1059
|
-
readonly template?: string | undefined;
|
|
1060
1115
|
readonly separator?: string | undefined;
|
|
1116
|
+
readonly template?: string | undefined;
|
|
1061
1117
|
} | undefined;
|
|
1062
1118
|
} | undefined;
|
|
1063
1119
|
readonly workflows?: readonly {
|
|
@@ -1091,6 +1147,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1091
1147
|
readonly signature?: {
|
|
1092
1148
|
readonly scheme: string;
|
|
1093
1149
|
readonly secret: string;
|
|
1150
|
+
readonly message?: readonly (string | {
|
|
1151
|
+
readonly body: true;
|
|
1152
|
+
} | {
|
|
1153
|
+
readonly header: string;
|
|
1154
|
+
} | {
|
|
1155
|
+
readonly timestamp: true;
|
|
1156
|
+
})[] | undefined;
|
|
1157
|
+
readonly key?: {
|
|
1158
|
+
readonly decode: string;
|
|
1159
|
+
readonly prefix?: string | undefined;
|
|
1160
|
+
} | undefined;
|
|
1161
|
+
readonly timestamp?: {
|
|
1162
|
+
readonly unit?: string | undefined;
|
|
1163
|
+
readonly entry?: string | undefined;
|
|
1164
|
+
readonly tolerance?: number | undefined;
|
|
1165
|
+
readonly header?: string | undefined;
|
|
1166
|
+
} | undefined;
|
|
1167
|
+
readonly algorithm?: string | undefined;
|
|
1168
|
+
readonly encoding?: string | undefined;
|
|
1169
|
+
readonly signatures?: {
|
|
1170
|
+
readonly header: string;
|
|
1171
|
+
readonly entries?: {
|
|
1172
|
+
readonly separator: string;
|
|
1173
|
+
readonly assign: string;
|
|
1174
|
+
readonly name: string;
|
|
1175
|
+
} | undefined;
|
|
1176
|
+
readonly prefix?: string | undefined;
|
|
1177
|
+
} | undefined;
|
|
1094
1178
|
} | undefined;
|
|
1095
1179
|
readonly verification?: {
|
|
1096
1180
|
readonly scheme: string;
|
|
@@ -1376,8 +1460,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1376
1460
|
};
|
|
1377
1461
|
} | undefined;
|
|
1378
1462
|
readonly attribution?: {
|
|
1379
|
-
readonly template?: string | undefined;
|
|
1380
1463
|
readonly separator?: string | undefined;
|
|
1464
|
+
readonly template?: string | undefined;
|
|
1381
1465
|
} | undefined;
|
|
1382
1466
|
} | undefined;
|
|
1383
1467
|
readonly workflows?: readonly {
|
|
@@ -1411,6 +1495,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1411
1495
|
readonly signature?: {
|
|
1412
1496
|
readonly scheme: string;
|
|
1413
1497
|
readonly secret: string;
|
|
1498
|
+
readonly message?: readonly (string | {
|
|
1499
|
+
readonly body: true;
|
|
1500
|
+
} | {
|
|
1501
|
+
readonly header: string;
|
|
1502
|
+
} | {
|
|
1503
|
+
readonly timestamp: true;
|
|
1504
|
+
})[] | undefined;
|
|
1505
|
+
readonly key?: {
|
|
1506
|
+
readonly decode: string;
|
|
1507
|
+
readonly prefix?: string | undefined;
|
|
1508
|
+
} | undefined;
|
|
1509
|
+
readonly timestamp?: {
|
|
1510
|
+
readonly unit?: string | undefined;
|
|
1511
|
+
readonly entry?: string | undefined;
|
|
1512
|
+
readonly tolerance?: number | undefined;
|
|
1513
|
+
readonly header?: string | undefined;
|
|
1514
|
+
} | undefined;
|
|
1515
|
+
readonly algorithm?: string | undefined;
|
|
1516
|
+
readonly encoding?: string | undefined;
|
|
1517
|
+
readonly signatures?: {
|
|
1518
|
+
readonly header: string;
|
|
1519
|
+
readonly entries?: {
|
|
1520
|
+
readonly separator: string;
|
|
1521
|
+
readonly assign: string;
|
|
1522
|
+
readonly name: string;
|
|
1523
|
+
} | undefined;
|
|
1524
|
+
readonly prefix?: string | undefined;
|
|
1525
|
+
} | undefined;
|
|
1414
1526
|
} | undefined;
|
|
1415
1527
|
readonly verification?: {
|
|
1416
1528
|
readonly scheme: string;
|
|
@@ -1846,6 +1958,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1846
1958
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
1847
1959
|
readonly scheme: Schema.String;
|
|
1848
1960
|
readonly secret: Schema.String;
|
|
1961
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
1962
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
1963
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
1964
|
+
readonly decode: Schema.String;
|
|
1965
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
1966
|
+
}>>;
|
|
1967
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
1968
|
+
readonly header: Schema.String;
|
|
1969
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
1970
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
1971
|
+
readonly separator: Schema.String;
|
|
1972
|
+
readonly assign: Schema.String;
|
|
1973
|
+
readonly name: Schema.String;
|
|
1974
|
+
}>>;
|
|
1975
|
+
}>>;
|
|
1976
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
1977
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
1978
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
1979
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
1980
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
1981
|
+
}>>;
|
|
1982
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
1983
|
+
readonly body: Schema.Literal<true>;
|
|
1984
|
+
}>, Schema.Struct<{
|
|
1985
|
+
readonly header: Schema.String;
|
|
1986
|
+
}>, Schema.Struct<{
|
|
1987
|
+
readonly timestamp: Schema.Literal<true>;
|
|
1988
|
+
}>]>>>;
|
|
1849
1989
|
}>>;
|
|
1850
1990
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
1851
1991
|
readonly scheme: Schema.String;
|
|
@@ -2162,6 +2302,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2162
2302
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
2163
2303
|
readonly scheme: Schema.String;
|
|
2164
2304
|
readonly secret: Schema.String;
|
|
2305
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
2306
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
2307
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
2308
|
+
readonly decode: Schema.String;
|
|
2309
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
2310
|
+
}>>;
|
|
2311
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
2312
|
+
readonly header: Schema.String;
|
|
2313
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
2314
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
2315
|
+
readonly separator: Schema.String;
|
|
2316
|
+
readonly assign: Schema.String;
|
|
2317
|
+
readonly name: Schema.String;
|
|
2318
|
+
}>>;
|
|
2319
|
+
}>>;
|
|
2320
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
2321
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
2322
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
2323
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
2324
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
2325
|
+
}>>;
|
|
2326
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
2327
|
+
readonly body: Schema.Literal<true>;
|
|
2328
|
+
}>, Schema.Struct<{
|
|
2329
|
+
readonly header: Schema.String;
|
|
2330
|
+
}>, Schema.Struct<{
|
|
2331
|
+
readonly timestamp: Schema.Literal<true>;
|
|
2332
|
+
}>]>>>;
|
|
2165
2333
|
}>>;
|
|
2166
2334
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
2167
2335
|
readonly scheme: Schema.String;
|
|
@@ -2341,8 +2509,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2341
2509
|
};
|
|
2342
2510
|
} | undefined;
|
|
2343
2511
|
readonly attribution?: {
|
|
2344
|
-
readonly template?: string | undefined;
|
|
2345
2512
|
readonly separator?: string | undefined;
|
|
2513
|
+
readonly template?: string | undefined;
|
|
2346
2514
|
} | undefined;
|
|
2347
2515
|
} | undefined;
|
|
2348
2516
|
readonly workflows?: readonly {
|
|
@@ -2374,6 +2542,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2374
2542
|
readonly signature?: {
|
|
2375
2543
|
readonly scheme: string;
|
|
2376
2544
|
readonly secret: string;
|
|
2545
|
+
readonly message?: readonly (string | {
|
|
2546
|
+
readonly body: true;
|
|
2547
|
+
} | {
|
|
2548
|
+
readonly header: string;
|
|
2549
|
+
} | {
|
|
2550
|
+
readonly timestamp: true;
|
|
2551
|
+
})[] | undefined;
|
|
2552
|
+
readonly key?: {
|
|
2553
|
+
readonly decode: string;
|
|
2554
|
+
readonly prefix?: string | undefined;
|
|
2555
|
+
} | undefined;
|
|
2556
|
+
readonly timestamp?: {
|
|
2557
|
+
readonly unit?: string | undefined;
|
|
2558
|
+
readonly entry?: string | undefined;
|
|
2559
|
+
readonly tolerance?: number | undefined;
|
|
2560
|
+
readonly header?: string | undefined;
|
|
2561
|
+
} | undefined;
|
|
2562
|
+
readonly algorithm?: string | undefined;
|
|
2563
|
+
readonly encoding?: string | undefined;
|
|
2564
|
+
readonly signatures?: {
|
|
2565
|
+
readonly header: string;
|
|
2566
|
+
readonly entries?: {
|
|
2567
|
+
readonly separator: string;
|
|
2568
|
+
readonly assign: string;
|
|
2569
|
+
readonly name: string;
|
|
2570
|
+
} | undefined;
|
|
2571
|
+
readonly prefix?: string | undefined;
|
|
2572
|
+
} | undefined;
|
|
2377
2573
|
} | undefined;
|
|
2378
2574
|
readonly verification?: {
|
|
2379
2575
|
readonly scheme: string;
|
|
@@ -2661,8 +2857,8 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2661
2857
|
};
|
|
2662
2858
|
} | undefined;
|
|
2663
2859
|
readonly attribution?: {
|
|
2664
|
-
readonly template?: string | undefined;
|
|
2665
2860
|
readonly separator?: string | undefined;
|
|
2861
|
+
readonly template?: string | undefined;
|
|
2666
2862
|
} | undefined;
|
|
2667
2863
|
} | undefined;
|
|
2668
2864
|
readonly workflows?: readonly {
|
|
@@ -2694,6 +2890,34 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2694
2890
|
readonly signature?: {
|
|
2695
2891
|
readonly scheme: string;
|
|
2696
2892
|
readonly secret: string;
|
|
2893
|
+
readonly message?: readonly (string | {
|
|
2894
|
+
readonly body: true;
|
|
2895
|
+
} | {
|
|
2896
|
+
readonly header: string;
|
|
2897
|
+
} | {
|
|
2898
|
+
readonly timestamp: true;
|
|
2899
|
+
})[] | undefined;
|
|
2900
|
+
readonly key?: {
|
|
2901
|
+
readonly decode: string;
|
|
2902
|
+
readonly prefix?: string | undefined;
|
|
2903
|
+
} | undefined;
|
|
2904
|
+
readonly timestamp?: {
|
|
2905
|
+
readonly unit?: string | undefined;
|
|
2906
|
+
readonly entry?: string | undefined;
|
|
2907
|
+
readonly tolerance?: number | undefined;
|
|
2908
|
+
readonly header?: string | undefined;
|
|
2909
|
+
} | undefined;
|
|
2910
|
+
readonly algorithm?: string | undefined;
|
|
2911
|
+
readonly encoding?: string | undefined;
|
|
2912
|
+
readonly signatures?: {
|
|
2913
|
+
readonly header: string;
|
|
2914
|
+
readonly entries?: {
|
|
2915
|
+
readonly separator: string;
|
|
2916
|
+
readonly assign: string;
|
|
2917
|
+
readonly name: string;
|
|
2918
|
+
} | undefined;
|
|
2919
|
+
readonly prefix?: string | undefined;
|
|
2920
|
+
} | undefined;
|
|
2697
2921
|
} | undefined;
|
|
2698
2922
|
readonly verification?: {
|
|
2699
2923
|
readonly scheme: string;
|
|
@@ -586,6 +586,34 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
586
586
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
587
587
|
readonly scheme: Schema.String;
|
|
588
588
|
readonly secret: Schema.String;
|
|
589
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
590
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
591
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
592
|
+
readonly decode: Schema.String;
|
|
593
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
594
|
+
}>>;
|
|
595
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
596
|
+
readonly header: Schema.String;
|
|
597
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
598
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
599
|
+
readonly separator: Schema.String;
|
|
600
|
+
readonly assign: Schema.String;
|
|
601
|
+
readonly name: Schema.String;
|
|
602
|
+
}>>;
|
|
603
|
+
}>>;
|
|
604
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
605
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
606
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
607
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
608
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
609
|
+
}>>;
|
|
610
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
611
|
+
readonly body: Schema.Literal<true>;
|
|
612
|
+
}>, Schema.Struct<{
|
|
613
|
+
readonly header: Schema.String;
|
|
614
|
+
}>, Schema.Struct<{
|
|
615
|
+
readonly timestamp: Schema.Literal<true>;
|
|
616
|
+
}>]>>>;
|
|
589
617
|
}>>;
|
|
590
618
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
591
619
|
readonly scheme: Schema.String;
|
|
@@ -915,6 +943,34 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
915
943
|
readonly signature: Schema.optionalKey<Schema.Struct<{
|
|
916
944
|
readonly scheme: Schema.String;
|
|
917
945
|
readonly secret: Schema.String;
|
|
946
|
+
readonly algorithm: Schema.optionalKey<Schema.String>;
|
|
947
|
+
readonly encoding: Schema.optionalKey<Schema.String>;
|
|
948
|
+
readonly key: Schema.optionalKey<Schema.Struct<{
|
|
949
|
+
readonly decode: Schema.String;
|
|
950
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
951
|
+
}>>;
|
|
952
|
+
readonly signatures: Schema.optionalKey<Schema.Struct<{
|
|
953
|
+
readonly header: Schema.String;
|
|
954
|
+
readonly prefix: Schema.optionalKey<Schema.String>;
|
|
955
|
+
readonly entries: Schema.optionalKey<Schema.Struct<{
|
|
956
|
+
readonly separator: Schema.String;
|
|
957
|
+
readonly assign: Schema.String;
|
|
958
|
+
readonly name: Schema.String;
|
|
959
|
+
}>>;
|
|
960
|
+
}>>;
|
|
961
|
+
readonly timestamp: Schema.optionalKey<Schema.Struct<{
|
|
962
|
+
readonly header: Schema.optionalKey<Schema.String>;
|
|
963
|
+
readonly entry: Schema.optionalKey<Schema.String>;
|
|
964
|
+
readonly unit: Schema.optionalKey<Schema.String>;
|
|
965
|
+
readonly tolerance: Schema.optionalKey<Schema.Number>;
|
|
966
|
+
}>>;
|
|
967
|
+
readonly message: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
968
|
+
readonly body: Schema.Literal<true>;
|
|
969
|
+
}>, Schema.Struct<{
|
|
970
|
+
readonly header: Schema.String;
|
|
971
|
+
}>, Schema.Struct<{
|
|
972
|
+
readonly timestamp: Schema.Literal<true>;
|
|
973
|
+
}>]>>>;
|
|
918
974
|
}>>;
|
|
919
975
|
readonly verification: Schema.optionalKey<Schema.Struct<{
|
|
920
976
|
readonly scheme: Schema.String;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Redacted } from "effect";
|
|
2
2
|
import type { HttpServerRequest } from "effect/unstable/http";
|
|
3
|
-
import type
|
|
3
|
+
import { type WebhookHmacAlgorithm, type WebhookHmacFormat, type WebhookSignatureEncoding } from "../webhooks.js";
|
|
4
4
|
/**
|
|
5
5
|
* The pieces of the webhook route that do not need the router: reading the body, the signature
|
|
6
6
|
* schemes, the backend's verification and the throttle on refused signatures.
|
|
@@ -27,8 +27,10 @@ export type WebhookVerification = {
|
|
|
27
27
|
export interface WebhookVerifyRequest {
|
|
28
28
|
/** The workspace secret's name. */
|
|
29
29
|
readonly secret: string;
|
|
30
|
-
readonly algorithm:
|
|
31
|
-
readonly encoding:
|
|
30
|
+
readonly algorithm: WebhookHmacAlgorithm;
|
|
31
|
+
readonly encoding: WebhookSignatureEncoding;
|
|
32
|
+
/** How the secret's value becomes the key, when not as its UTF-8 bytes. */
|
|
33
|
+
readonly key?: WebhookHmacFormat["key"];
|
|
32
34
|
/** The bytes the provider signed. */
|
|
33
35
|
readonly message: Uint8Array;
|
|
34
36
|
/** The signatures the delivery carried; any that matches is enough. */
|
|
@@ -40,7 +42,7 @@ export interface WebhookVerifyRequest {
|
|
|
40
42
|
/** Checks webhook signatures. The service calls SegmentStream's backend by default. */
|
|
41
43
|
export type WebhookVerifier = (request: WebhookVerifyRequest) => Promise<WebhookVerification>;
|
|
42
44
|
/** Registration checks return only a match; the stored verify token never leaves the backend. */
|
|
43
|
-
export type WebhookTokenVerifyRequest = Omit<WebhookVerifyRequest, "algorithm" | "encoding" | "message" | "signatures"> & {
|
|
45
|
+
export type WebhookTokenVerifyRequest = Omit<WebhookVerifyRequest, "algorithm" | "encoding" | "key" | "message" | "signatures"> & {
|
|
44
46
|
readonly token: string;
|
|
45
47
|
};
|
|
46
48
|
export type WebhookTokenVerifier = (request: WebhookTokenVerifyRequest) => Promise<WebhookVerification>;
|
|
@@ -92,6 +94,12 @@ export type SignedContent = {
|
|
|
92
94
|
export type SignatureScheme = (headers: Readonly<Record<string, string | undefined>>, body: Uint8Array, receivedAt: Date) => SignedContent;
|
|
93
95
|
/** How far Stripe's `t` may be from the time the delivery arrived, in seconds. */
|
|
94
96
|
export declare const STRIPE_TOLERANCE_SECONDS = 300;
|
|
97
|
+
/**
|
|
98
|
+
* The scheme a format describes: it finds the candidate signatures and the timestamp in the
|
|
99
|
+
* delivery's headers, refuses a stale timestamp, and assembles the signed bytes. The HMAC itself
|
|
100
|
+
* is SegmentStream's, which holds the secret.
|
|
101
|
+
*/
|
|
102
|
+
export declare function hmacSignature(format: WebhookHmacFormat): SignatureScheme;
|
|
95
103
|
/**
|
|
96
104
|
* Stripe's `Stripe-Signature`: `t=<unix seconds>` and one or more `v1=<hex>`. The signed bytes are
|
|
97
105
|
* `<t>.` followed by the raw body; the HMAC is SHA-256 keyed with the whole `whsec_…` string.
|
|
@@ -99,8 +107,16 @@ export declare const STRIPE_TOLERANCE_SECONDS = 300;
|
|
|
99
107
|
export declare const stripeSignature: SignatureScheme;
|
|
100
108
|
/** Meta signs exactly the raw body; its app secret stays in the backend. */
|
|
101
109
|
export declare const metaSignature: SignatureScheme;
|
|
102
|
-
/**
|
|
103
|
-
|
|
110
|
+
/**
|
|
111
|
+
* What checks a manifest signature: its format and that format's scheme, or `undefined` for a
|
|
112
|
+
* scheme this SDK does not know.
|
|
113
|
+
*/
|
|
114
|
+
export declare function signatureCheck(signature: {
|
|
115
|
+
readonly scheme: string;
|
|
116
|
+
}): {
|
|
117
|
+
readonly format: WebhookHmacFormat;
|
|
118
|
+
readonly scheme: SignatureScheme;
|
|
119
|
+
} | undefined;
|
|
104
120
|
/**
|
|
105
121
|
* The request's body, read up to `limit` bytes: `too_large` without reading further, or
|
|
106
122
|
* `unreadable` when the client went away.
|