@krak-stack/registry 0.1.59 → 0.1.61
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 +13 -1
- package/dist/components/ui/data-table.d.ts +2 -0
- package/dist/components/ui/data-table.js +6 -2
- package/dist/components/ui/item.d.ts +22 -0
- package/dist/components/ui/trace.d.ts +18 -0
- package/dist/services/agent/client/index.js +584 -434
- package/dist/services/agent/client/widget.d.ts +1 -0
- package/dist/services/events/browser.js +29 -3
- package/dist/services/events/client/audit-log-table.js +6 -2
- package/dist/services/events/client/tracking-notice.js +2 -1
- package/dist/services/events/index.d.ts +26 -56
- package/dist/services/events/index.js +118 -7
- package/dist/services/events/schema.d.ts +66 -24
- package/dist/services/events/schema.js +34 -3
- package/dist/services/opentelemetry/api.js +2 -1
- package/dist/services/opentelemetry/browser.d.ts +1 -1
- package/dist/services/opentelemetry/browser.js +2 -1
- package/dist/services/opentelemetry/events.d.ts +1 -1
- package/dist/services/opentelemetry/index.d.ts +1 -1
- package/dist/services/opentelemetry/index.js +2 -1
- package/dist/services/opentelemetry/schema.d.ts +3 -1
- package/dist/services/opentelemetry/web-vitals.js +2 -1
- package/dist/services/webhooks/client/delivery-table.d.ts +62 -0
- package/dist/services/webhooks/client/delivery-table.js +4698 -0
- package/dist/services/webhooks/http-client.d.ts +8 -0
- package/dist/services/webhooks/http-client.js +69 -0
- package/dist/services/webhooks/index.d.ts +343 -0
- package/dist/services/webhooks/index.js +872 -0
- package/dist/services/webhooks/migrations.d.ts +8 -0
- package/dist/services/webhooks/migrations.js +63 -0
- package/dist/services/webhooks/receiver.d.ts +41 -0
- package/dist/services/webhooks/schema.d.ts +251 -0
- package/dist/services/webhooks/schema.js +353 -0
- package/dist/services/webhooks/url.d.ts +8 -0
- package/dist/services/webhooks/url.js +48 -0
- package/package.json +29 -1
- package/dist/components/ui/marker.d.ts +0 -10
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
// ../../src/services/webhooks/schema.ts
|
|
2
|
+
import { Schema as Schema2 } from "effect";
|
|
3
|
+
|
|
4
|
+
// ../../src/services/webhooks/url.ts
|
|
5
|
+
import { Context } from "effect";
|
|
6
|
+
var hostname = (value) => value.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
7
|
+
var isPublicIpAddress = (value) => {
|
|
8
|
+
const address = hostname(value);
|
|
9
|
+
const octets = address.split(".");
|
|
10
|
+
if (octets.length === 4 && octets.every((part) => /^\d{1,3}$/.test(part) && Number(part) <= 255)) {
|
|
11
|
+
const [a = 0, b = 0, c = 0] = octets.map(Number);
|
|
12
|
+
return !(a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && (b === 0 || b === 168 || b === 88 && c === 99) || a === 198 && (b === 18 || b === 19 || b === 51) || a === 203 && b === 0 || a >= 224);
|
|
13
|
+
}
|
|
14
|
+
const first = Number.parseInt(address.split(":")[0] ?? "", 16);
|
|
15
|
+
return address.includes(":") && first >= 8192 && first <= 16383 && !address.startsWith("2001:") && !address.startsWith("2002:") && !address.startsWith("3fff:");
|
|
16
|
+
};
|
|
17
|
+
var isPublicWebhookUrl = (url) => {
|
|
18
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password)
|
|
19
|
+
return false;
|
|
20
|
+
const host = hostname(url.hostname);
|
|
21
|
+
if (!host || host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local"))
|
|
22
|
+
return false;
|
|
23
|
+
return !(host.includes(":") || /^\d+(?:\.\d+){3}$/.test(host)) || isPublicIpAddress(host);
|
|
24
|
+
};
|
|
25
|
+
var isPublicWebhookUrlString = (value) => {
|
|
26
|
+
try {
|
|
27
|
+
return isPublicWebhookUrl(new URL(value));
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var isAllowedWebhookUrlString = (value, allowLoopback) => {
|
|
33
|
+
try {
|
|
34
|
+
const url = new URL(value);
|
|
35
|
+
return isPublicWebhookUrl(url) || allowLoopback && isLoopbackWebhookUrl(url);
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var WebhookAllowLoopback = Context.Reference("Webhooks/AllowLoopback", {
|
|
41
|
+
defaultValue: () => false
|
|
42
|
+
});
|
|
43
|
+
var isLoopbackWebhookUrl = (url) => ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
44
|
+
|
|
45
|
+
// ../../src/lib/query.ts
|
|
46
|
+
import {
|
|
47
|
+
DateTime,
|
|
48
|
+
Effect,
|
|
49
|
+
Option,
|
|
50
|
+
Schema,
|
|
51
|
+
SchemaGetter,
|
|
52
|
+
SchemaIssue,
|
|
53
|
+
SchemaTransformation
|
|
54
|
+
} from "effect";
|
|
55
|
+
var parseSortParam = (sort) => {
|
|
56
|
+
const id = sort.startsWith("-") ? sort.slice(1) : sort;
|
|
57
|
+
if (!id || id.includes(",") || id.includes(":")) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
61
|
+
};
|
|
62
|
+
var SortDirection = Schema.Union([
|
|
63
|
+
Schema.Literal("asc"),
|
|
64
|
+
Schema.Literal("desc")
|
|
65
|
+
]).pipe(Schema.annotate({
|
|
66
|
+
identifier: "SortDirection",
|
|
67
|
+
title: "Sort Direction",
|
|
68
|
+
description: "Sort direction for list query results.",
|
|
69
|
+
examples: ["asc", "desc"]
|
|
70
|
+
}));
|
|
71
|
+
var SortParam = Schema.Struct({
|
|
72
|
+
id: Schema.NonEmptyString,
|
|
73
|
+
direction: SortDirection
|
|
74
|
+
}).pipe(Schema.annotate({
|
|
75
|
+
identifier: "SortParam",
|
|
76
|
+
title: "Sort Parameter",
|
|
77
|
+
description: "Decoded sort parameter with a field id and direction.",
|
|
78
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
79
|
+
}));
|
|
80
|
+
var SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam, SchemaTransformation.transformEffect({
|
|
81
|
+
decode: (sort) => {
|
|
82
|
+
const sortParam = parseSortParam(sort);
|
|
83
|
+
if (!sortParam) {
|
|
84
|
+
return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field" or "-field"' }, sort));
|
|
85
|
+
}
|
|
86
|
+
return Effect.succeed(sortParam);
|
|
87
|
+
},
|
|
88
|
+
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
89
|
+
})), Schema.annotate({
|
|
90
|
+
identifier: "SortParamFromString",
|
|
91
|
+
title: "Sort Parameter From String",
|
|
92
|
+
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
93
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
94
|
+
}));
|
|
95
|
+
var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortParam), SchemaTransformation.transformEffect({
|
|
96
|
+
decode: (sort) => {
|
|
97
|
+
if (sort === "")
|
|
98
|
+
return Effect.succeed([]);
|
|
99
|
+
const parts = sort.split(",");
|
|
100
|
+
const sortParams = [];
|
|
101
|
+
for (const part of parts) {
|
|
102
|
+
const sortParam = parseSortParam(part);
|
|
103
|
+
if (!sortParam) {
|
|
104
|
+
return Effect.fail(new SchemaIssue.InvalidValue({ message: 'Expected sort in the format "field,-otherField"' }, sort));
|
|
105
|
+
}
|
|
106
|
+
sortParams.push(sortParam);
|
|
107
|
+
}
|
|
108
|
+
return Effect.succeed(sortParams);
|
|
109
|
+
},
|
|
110
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema.encodeSync(SortParamFromString)(part)).join(","))
|
|
111
|
+
})), Schema.annotate({
|
|
112
|
+
identifier: "SortParamsFromString",
|
|
113
|
+
title: "Sort Parameters From String",
|
|
114
|
+
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
115
|
+
examples: [
|
|
116
|
+
[
|
|
117
|
+
{ id: "name", direction: "desc" },
|
|
118
|
+
{ id: "age", direction: "asc" }
|
|
119
|
+
]
|
|
120
|
+
]
|
|
121
|
+
}));
|
|
122
|
+
var SortParamsArray = Schema.Array(SortParam);
|
|
123
|
+
var SortParams = Schema.declare(Schema.is(SortParamsArray), {
|
|
124
|
+
identifier: "SortParams",
|
|
125
|
+
toCodec: () => Schema.link()(SortParamsArray, SchemaTransformation.passthrough()),
|
|
126
|
+
toCodecStringTree: () => Schema.link()(SortParamsFromString, SchemaTransformation.passthrough())
|
|
127
|
+
});
|
|
128
|
+
var TextFilterOperator = Schema.Literals([
|
|
129
|
+
"contains",
|
|
130
|
+
"equals",
|
|
131
|
+
"startsWith",
|
|
132
|
+
"endsWith"
|
|
133
|
+
]).annotate({ identifier: "TextFilterOperator" });
|
|
134
|
+
var FilterCalendarDate = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/), Schema.makeFilter((value) => Option.exists(DateTime.make(value), (date) => DateTime.formatIsoDateUtc(date) === value))).annotate({ identifier: "FilterCalendarDate" });
|
|
135
|
+
var ColumnFilter = Schema.Union([
|
|
136
|
+
Schema.Struct({
|
|
137
|
+
id: Schema.NonEmptyString,
|
|
138
|
+
kind: Schema.Literal("text"),
|
|
139
|
+
operator: TextFilterOperator,
|
|
140
|
+
value: Schema.NonEmptyString
|
|
141
|
+
}),
|
|
142
|
+
Schema.Struct({
|
|
143
|
+
id: Schema.NonEmptyString,
|
|
144
|
+
kind: Schema.Literal("number"),
|
|
145
|
+
min: Schema.optional(Schema.Finite),
|
|
146
|
+
max: Schema.optional(Schema.Finite)
|
|
147
|
+
}).check(Schema.makeFilter((range) => (range.min !== undefined || range.max !== undefined) && (range.min === undefined || range.max === undefined || range.min <= range.max))),
|
|
148
|
+
Schema.Struct({
|
|
149
|
+
id: Schema.NonEmptyString,
|
|
150
|
+
kind: Schema.Literal("date"),
|
|
151
|
+
from: Schema.optional(FilterCalendarDate),
|
|
152
|
+
to: Schema.optional(FilterCalendarDate)
|
|
153
|
+
}).check(Schema.makeFilter((range) => (range.from !== undefined || range.to !== undefined) && (range.from === undefined || range.to === undefined || range.from <= range.to))),
|
|
154
|
+
Schema.Struct({
|
|
155
|
+
id: Schema.NonEmptyString,
|
|
156
|
+
kind: Schema.Literal("boolean"),
|
|
157
|
+
value: Schema.Boolean
|
|
158
|
+
}),
|
|
159
|
+
Schema.Struct({
|
|
160
|
+
id: Schema.NonEmptyString,
|
|
161
|
+
kind: Schema.Literal("values"),
|
|
162
|
+
values: Schema.NonEmptyArray(Schema.String)
|
|
163
|
+
})
|
|
164
|
+
]).annotate({ identifier: "ColumnFilter" });
|
|
165
|
+
var ColumnFiltersArray = Schema.Array(ColumnFilter);
|
|
166
|
+
var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
|
|
167
|
+
identifier: "ColumnFilters",
|
|
168
|
+
toCodec: () => Schema.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
169
|
+
toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
170
|
+
});
|
|
171
|
+
var Query = Schema.Struct({
|
|
172
|
+
page: Schema.optional(Schema.Union([Schema.Number, Schema.NumberFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
|
|
173
|
+
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
174
|
+
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
175
|
+
})),
|
|
176
|
+
pageSize: Schema.optional(Schema.Union([Schema.Number, Schema.NumberFromString]).check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })), {
|
|
177
|
+
decode: SchemaGetter.withDefault(Effect.succeed(20)),
|
|
178
|
+
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
179
|
+
})),
|
|
180
|
+
globalFilter: Schema.optional(Schema.String),
|
|
181
|
+
sort: Schema.optional(SortParams),
|
|
182
|
+
filters: Schema.optional(ColumnFilters)
|
|
183
|
+
}).annotate({
|
|
184
|
+
identifier: "Query",
|
|
185
|
+
title: "Query",
|
|
186
|
+
description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
|
|
187
|
+
examples: [
|
|
188
|
+
{
|
|
189
|
+
page: 0,
|
|
190
|
+
pageSize: 20,
|
|
191
|
+
globalFilter: "housing",
|
|
192
|
+
sort: [
|
|
193
|
+
{ id: "publicName", direction: "desc" },
|
|
194
|
+
{ id: "createdAt", direction: "asc" }
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
var QueryStandard = Schema.toStandardSchemaV1(Query);
|
|
200
|
+
var PaginationMeta = Schema.Struct({
|
|
201
|
+
page: Schema.Int,
|
|
202
|
+
pageSize: Schema.Int,
|
|
203
|
+
total: Schema.Int,
|
|
204
|
+
pageCount: Schema.Int
|
|
205
|
+
}).pipe(Schema.annotate({
|
|
206
|
+
identifier: "PaginationMeta",
|
|
207
|
+
title: "Pagination Metadata",
|
|
208
|
+
description: "Pagination metadata returned with a paginated list response.",
|
|
209
|
+
examples: [{ page: 0, pageSize: 20, total: 125, pageCount: 7 }]
|
|
210
|
+
}));
|
|
211
|
+
var PaginatedResponse = (items) => Schema.Struct({
|
|
212
|
+
data: Schema.Array(items),
|
|
213
|
+
meta: PaginationMeta
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// ../../src/services/webhooks/schema.ts
|
|
217
|
+
var webhookColumns = 'id, organization_id AS "organizationId", COALESCE(name, url) AS name, url, description, headers, events, secret, enabled, created_at AS "createdAt", updated_at AS "updatedAt"';
|
|
218
|
+
var deliveryColumns = 'd.id, d.webhook_id AS "webhookId", d.event, d.data, d.status, d.error, d.completed_at AS "completedAt", d.retry_at AS "retryAt", d.retries, d.created_at AS "createdAt", d.updated_at AS "updatedAt"';
|
|
219
|
+
var WebhookScope = Schema2.Struct({
|
|
220
|
+
organizationId: Schema2.NonEmptyString
|
|
221
|
+
}).annotate({ identifier: "WebhookScope" });
|
|
222
|
+
var WebhookRequest = Schema2.Struct({
|
|
223
|
+
organizationId: Schema2.NonEmptyString,
|
|
224
|
+
id: Schema2.NonEmptyString
|
|
225
|
+
}).annotate({ identifier: "WebhookRequest" });
|
|
226
|
+
var WebhookStatisticsInterval = Schema2.Literals([
|
|
227
|
+
"hour",
|
|
228
|
+
"day"
|
|
229
|
+
]).annotate({ identifier: "WebhookStatisticsInterval" });
|
|
230
|
+
var WebhookStatisticsRequest = Schema2.Struct({
|
|
231
|
+
...WebhookRequest.fields,
|
|
232
|
+
interval: WebhookStatisticsInterval
|
|
233
|
+
}).annotate({ identifier: "WebhookStatisticsRequest" });
|
|
234
|
+
var WebhookDeliveryCounts = Schema2.Struct({
|
|
235
|
+
total: Schema2.Int,
|
|
236
|
+
success: Schema2.Int,
|
|
237
|
+
failed: Schema2.Int
|
|
238
|
+
}).annotate({ identifier: "WebhookDeliveryCounts" });
|
|
239
|
+
var WebhookEventCount = Schema2.Struct({
|
|
240
|
+
event: Schema2.String,
|
|
241
|
+
total: Schema2.Int
|
|
242
|
+
}).annotate({ identifier: "WebhookEventCount" });
|
|
243
|
+
var WebhookDeliveryBucket = Schema2.Struct({
|
|
244
|
+
...WebhookDeliveryCounts.fields,
|
|
245
|
+
bucket: Schema2.Date,
|
|
246
|
+
events: Schema2.Array(WebhookEventCount)
|
|
247
|
+
}).annotate({ identifier: "WebhookDeliveryBucket" });
|
|
248
|
+
var WebhookStatistics = Schema2.Struct({
|
|
249
|
+
...WebhookDeliveryCounts.fields,
|
|
250
|
+
buckets: Schema2.Array(WebhookDeliveryBucket)
|
|
251
|
+
}).annotate({ identifier: "WebhookStatistics" });
|
|
252
|
+
var WebhookName = Schema2.Trim.check(Schema2.isMinLength(1), Schema2.isMaxLength(200)).annotate({ identifier: "WebhookName" });
|
|
253
|
+
var WebhookPayload = Schema2.Struct({
|
|
254
|
+
name: Schema2.optional(WebhookName),
|
|
255
|
+
url: Schema2.String.check(Schema2.makeFilter(isPublicWebhookUrlString, {
|
|
256
|
+
expected: "a public HTTP or HTTPS URL without credentials"
|
|
257
|
+
})),
|
|
258
|
+
description: Schema2.NullOr(Schema2.String),
|
|
259
|
+
enabled: Schema2.Boolean,
|
|
260
|
+
events: Schema2.NullOr(Schema2.Array(Schema2.NonEmptyString)),
|
|
261
|
+
customHeaders: Schema2.NullOr(Schema2.Record(Schema2.String, Schema2.String)).check(Schema2.makeFilter((headers) => Object.keys(headers ?? {}).every((name) => ![
|
|
262
|
+
"content-type",
|
|
263
|
+
"webhook-id",
|
|
264
|
+
"webhook-timestamp",
|
|
265
|
+
"webhook-signature"
|
|
266
|
+
].includes(name.toLowerCase())), { expected: "headers that do not override webhook protocol headers" }))
|
|
267
|
+
}).annotate({ identifier: "WebhookPayload" });
|
|
268
|
+
var webhookPayloadSchema = (allowLoopback) => Schema2.Struct({
|
|
269
|
+
...WebhookPayload.fields,
|
|
270
|
+
url: Schema2.String.check(Schema2.makeFilter((value) => isAllowedWebhookUrlString(value, allowLoopback), {
|
|
271
|
+
expected: "a public HTTP(S) URL, or an explicitly enabled development loopback URL"
|
|
272
|
+
}))
|
|
273
|
+
}).annotate({ identifier: "ConfiguredWebhookPayload" });
|
|
274
|
+
var Webhook = Schema2.Struct({
|
|
275
|
+
id: Schema2.String,
|
|
276
|
+
name: Schema2.String,
|
|
277
|
+
organizationId: Schema2.String,
|
|
278
|
+
url: Schema2.String,
|
|
279
|
+
description: Schema2.NullOr(Schema2.String),
|
|
280
|
+
headers: Schema2.NullOr(Schema2.Record(Schema2.String, Schema2.String)),
|
|
281
|
+
events: Schema2.NullOr(Schema2.Array(Schema2.String)),
|
|
282
|
+
secret: Schema2.String,
|
|
283
|
+
enabled: Schema2.Boolean,
|
|
284
|
+
createdAt: Schema2.Date,
|
|
285
|
+
updatedAt: Schema2.Date
|
|
286
|
+
}).annotate({ identifier: "Webhook" });
|
|
287
|
+
var WebhookDelivery = Schema2.Struct({
|
|
288
|
+
id: Schema2.String,
|
|
289
|
+
webhookId: Schema2.String,
|
|
290
|
+
event: Schema2.String,
|
|
291
|
+
data: Schema2.Json,
|
|
292
|
+
status: Schema2.Literals(["pending", "success", "failed"]),
|
|
293
|
+
error: Schema2.NullOr(Schema2.String),
|
|
294
|
+
completedAt: Schema2.NullOr(Schema2.Date),
|
|
295
|
+
retryAt: Schema2.Date,
|
|
296
|
+
retries: Schema2.Int,
|
|
297
|
+
createdAt: Schema2.Date,
|
|
298
|
+
updatedAt: Schema2.Date
|
|
299
|
+
}).annotate({ identifier: "WebhookDelivery" });
|
|
300
|
+
var WebhookDeliverySortId = Schema2.Literals([
|
|
301
|
+
"id",
|
|
302
|
+
"event",
|
|
303
|
+
"status",
|
|
304
|
+
"createdAt",
|
|
305
|
+
"completedAt"
|
|
306
|
+
]).annotate({ identifier: "WebhookDeliverySortId" });
|
|
307
|
+
var DeliveryFilter = ColumnFilter.check(Schema2.makeFilter((filter) => filter.id === "id" ? filter.kind === "text" : filter.id === "event" ? filter.kind === "values" : filter.id === "status" ? filter.kind === "values" && filter.values.every((value) => ["pending", "success", "failed"].includes(value)) : ["createdAt", "completedAt"].includes(filter.id) && filter.kind === "date")).annotate({ identifier: "WebhookDeliveryFilter" });
|
|
308
|
+
var WebhookDeliveriesQuery = Schema2.Struct({
|
|
309
|
+
...Query.fields,
|
|
310
|
+
filters: Schema2.optional(ColumnFilters.check(Schema2.makeFilter((filters) => filters.every(Schema2.is(DeliveryFilter))))),
|
|
311
|
+
sort: Schema2.optional(SortParams.check(Schema2.makeFilter((sort) => sort.every((part) => Schema2.is(WebhookDeliverySortId)(part.id)))))
|
|
312
|
+
}).annotate({ identifier: "WebhookDeliveriesQuery" });
|
|
313
|
+
var ListWebhookDeliveries = Schema2.Struct({
|
|
314
|
+
...WebhookRequest.fields,
|
|
315
|
+
...WebhookDeliveriesQuery.fields
|
|
316
|
+
}).annotate({ identifier: "ListWebhookDeliveries" });
|
|
317
|
+
var WebhookDeliveries = PaginatedResponse(WebhookDelivery).annotate({
|
|
318
|
+
identifier: "WebhookDeliveries"
|
|
319
|
+
});
|
|
320
|
+
var PublishWebhook = Schema2.Struct({
|
|
321
|
+
organizationId: Schema2.NonEmptyString,
|
|
322
|
+
eventId: Schema2.NonEmptyString,
|
|
323
|
+
event: Schema2.NonEmptyString,
|
|
324
|
+
data: Schema2.Json
|
|
325
|
+
}).annotate({ identifier: "PublishWebhook" });
|
|
326
|
+
|
|
327
|
+
class WebhookError extends Schema2.TaggedError()("WebhookError", {
|
|
328
|
+
message: Schema2.String
|
|
329
|
+
}) {
|
|
330
|
+
}
|
|
331
|
+
export {
|
|
332
|
+
ListWebhookDeliveries,
|
|
333
|
+
PublishWebhook,
|
|
334
|
+
Webhook,
|
|
335
|
+
WebhookDeliveries,
|
|
336
|
+
WebhookDeliveriesQuery,
|
|
337
|
+
WebhookDelivery,
|
|
338
|
+
WebhookDeliveryBucket,
|
|
339
|
+
WebhookDeliveryCounts,
|
|
340
|
+
WebhookDeliverySortId,
|
|
341
|
+
WebhookError,
|
|
342
|
+
WebhookEventCount,
|
|
343
|
+
WebhookName,
|
|
344
|
+
WebhookPayload,
|
|
345
|
+
WebhookRequest,
|
|
346
|
+
WebhookScope,
|
|
347
|
+
WebhookStatistics,
|
|
348
|
+
WebhookStatisticsInterval,
|
|
349
|
+
WebhookStatisticsRequest,
|
|
350
|
+
deliveryColumns,
|
|
351
|
+
webhookColumns,
|
|
352
|
+
webhookPayloadSchema
|
|
353
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const isPublicIpAddress: (value: string) => boolean;
|
|
2
|
+
export declare const isPublicWebhookUrl: (url: URL) => boolean;
|
|
3
|
+
export declare const isPublicWebhookUrlString: (value: string) => boolean;
|
|
4
|
+
export declare const isAllowedWebhookUrlString: (value: string, allowLoopback: boolean) => boolean;
|
|
5
|
+
import { Context } from "effect";
|
|
6
|
+
/** Opt in only in a local development composition root, never from a request. */
|
|
7
|
+
export declare const WebhookAllowLoopback: Context.Reference<boolean>;
|
|
8
|
+
export declare const isLoopbackWebhookUrl: (url: URL) => boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// ../../src/services/webhooks/url.ts
|
|
2
|
+
import { Context } from "effect";
|
|
3
|
+
var hostname = (value) => value.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
4
|
+
var isPublicIpAddress = (value) => {
|
|
5
|
+
const address = hostname(value);
|
|
6
|
+
const octets = address.split(".");
|
|
7
|
+
if (octets.length === 4 && octets.every((part) => /^\d{1,3}$/.test(part) && Number(part) <= 255)) {
|
|
8
|
+
const [a = 0, b = 0, c = 0] = octets.map(Number);
|
|
9
|
+
return !(a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && (b === 0 || b === 168 || b === 88 && c === 99) || a === 198 && (b === 18 || b === 19 || b === 51) || a === 203 && b === 0 || a >= 224);
|
|
10
|
+
}
|
|
11
|
+
const first = Number.parseInt(address.split(":")[0] ?? "", 16);
|
|
12
|
+
return address.includes(":") && first >= 8192 && first <= 16383 && !address.startsWith("2001:") && !address.startsWith("2002:") && !address.startsWith("3fff:");
|
|
13
|
+
};
|
|
14
|
+
var isPublicWebhookUrl = (url) => {
|
|
15
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password)
|
|
16
|
+
return false;
|
|
17
|
+
const host = hostname(url.hostname);
|
|
18
|
+
if (!host || host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local"))
|
|
19
|
+
return false;
|
|
20
|
+
return !(host.includes(":") || /^\d+(?:\.\d+){3}$/.test(host)) || isPublicIpAddress(host);
|
|
21
|
+
};
|
|
22
|
+
var isPublicWebhookUrlString = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
return isPublicWebhookUrl(new URL(value));
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var isAllowedWebhookUrlString = (value, allowLoopback) => {
|
|
30
|
+
try {
|
|
31
|
+
const url = new URL(value);
|
|
32
|
+
return isPublicWebhookUrl(url) || allowLoopback && isLoopbackWebhookUrl(url);
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var WebhookAllowLoopback = Context.Reference("Webhooks/AllowLoopback", {
|
|
38
|
+
defaultValue: () => false
|
|
39
|
+
});
|
|
40
|
+
var isLoopbackWebhookUrl = (url) => ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
41
|
+
export {
|
|
42
|
+
WebhookAllowLoopback,
|
|
43
|
+
isAllowedWebhookUrlString,
|
|
44
|
+
isLoopbackWebhookUrl,
|
|
45
|
+
isPublicIpAddress,
|
|
46
|
+
isPublicWebhookUrl,
|
|
47
|
+
isPublicWebhookUrlString
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,30 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
+
"./webhooks/client": {
|
|
21
|
+
"types": "./dist/services/webhooks/client/delivery-table.d.ts",
|
|
22
|
+
"import": "./dist/services/webhooks/client/delivery-table.js"
|
|
23
|
+
},
|
|
24
|
+
"./webhooks/http-client": {
|
|
25
|
+
"types": "./dist/services/webhooks/http-client.d.ts",
|
|
26
|
+
"import": "./dist/services/webhooks/http-client.js"
|
|
27
|
+
},
|
|
28
|
+
"./webhooks/url": {
|
|
29
|
+
"types": "./dist/services/webhooks/url.d.ts",
|
|
30
|
+
"import": "./dist/services/webhooks/url.js"
|
|
31
|
+
},
|
|
32
|
+
"./webhooks": {
|
|
33
|
+
"types": "./dist/services/webhooks/index.d.ts",
|
|
34
|
+
"import": "./dist/services/webhooks/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./webhooks/schema": {
|
|
37
|
+
"types": "./dist/services/webhooks/schema.d.ts",
|
|
38
|
+
"import": "./dist/services/webhooks/schema.js"
|
|
39
|
+
},
|
|
40
|
+
"./webhooks/migrations": {
|
|
41
|
+
"types": "./dist/services/webhooks/migrations.d.ts",
|
|
42
|
+
"import": "./dist/services/webhooks/migrations.js"
|
|
43
|
+
},
|
|
20
44
|
"./speech": {
|
|
21
45
|
"types": "./dist/services/speech/index.d.ts",
|
|
22
46
|
"import": "./dist/services/speech/index.js"
|
|
@@ -285,6 +309,7 @@
|
|
|
285
309
|
"@base-ui/react": "^1.5.0",
|
|
286
310
|
"@effect/atom-react": "^4.1.0",
|
|
287
311
|
"@effect/platform-browser": "^4.1.0",
|
|
312
|
+
"@effect/sql-pg": "^4.1.0",
|
|
288
313
|
"@iconify/react": "^6.0.2",
|
|
289
314
|
"@inlang/paraglide-js": "^2.19.0",
|
|
290
315
|
"@lucas-barake/effect-form": "1.1.0",
|
|
@@ -304,6 +329,9 @@
|
|
|
304
329
|
"react-dom": "^19.2.0"
|
|
305
330
|
},
|
|
306
331
|
"peerDependenciesMeta": {
|
|
332
|
+
"@effect/sql-pg": {
|
|
333
|
+
"optional": true
|
|
334
|
+
},
|
|
307
335
|
"@aws-sdk/client-sesv2": {
|
|
308
336
|
"optional": true
|
|
309
337
|
},
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
-
import { type VariantProps } from "class-variance-authority";
|
|
4
|
-
declare const markerVariants: (props?: ({
|
|
5
|
-
variant?: "border" | "default" | "separator" | null | undefined;
|
|
6
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
-
declare function Marker({ className, variant, render, ...props }: useRender.ComponentProps<"div"> & VariantProps<typeof markerVariants>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
8
|
-
declare function MarkerIcon({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
9
|
-
declare function MarkerContent({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
10
|
-
export { Marker, MarkerIcon, MarkerContent, markerVariants };
|