@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.
Files changed (37) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/components/ui/data-table.d.ts +2 -0
  3. package/dist/components/ui/data-table.js +6 -2
  4. package/dist/components/ui/item.d.ts +22 -0
  5. package/dist/components/ui/trace.d.ts +18 -0
  6. package/dist/services/agent/client/index.js +584 -434
  7. package/dist/services/agent/client/widget.d.ts +1 -0
  8. package/dist/services/events/browser.js +29 -3
  9. package/dist/services/events/client/audit-log-table.js +6 -2
  10. package/dist/services/events/client/tracking-notice.js +2 -1
  11. package/dist/services/events/index.d.ts +26 -56
  12. package/dist/services/events/index.js +118 -7
  13. package/dist/services/events/schema.d.ts +66 -24
  14. package/dist/services/events/schema.js +34 -3
  15. package/dist/services/opentelemetry/api.js +2 -1
  16. package/dist/services/opentelemetry/browser.d.ts +1 -1
  17. package/dist/services/opentelemetry/browser.js +2 -1
  18. package/dist/services/opentelemetry/events.d.ts +1 -1
  19. package/dist/services/opentelemetry/index.d.ts +1 -1
  20. package/dist/services/opentelemetry/index.js +2 -1
  21. package/dist/services/opentelemetry/schema.d.ts +3 -1
  22. package/dist/services/opentelemetry/web-vitals.js +2 -1
  23. package/dist/services/webhooks/client/delivery-table.d.ts +62 -0
  24. package/dist/services/webhooks/client/delivery-table.js +4698 -0
  25. package/dist/services/webhooks/http-client.d.ts +8 -0
  26. package/dist/services/webhooks/http-client.js +69 -0
  27. package/dist/services/webhooks/index.d.ts +343 -0
  28. package/dist/services/webhooks/index.js +872 -0
  29. package/dist/services/webhooks/migrations.d.ts +8 -0
  30. package/dist/services/webhooks/migrations.js +63 -0
  31. package/dist/services/webhooks/receiver.d.ts +41 -0
  32. package/dist/services/webhooks/schema.d.ts +251 -0
  33. package/dist/services/webhooks/schema.js +353 -0
  34. package/dist/services/webhooks/url.d.ts +8 -0
  35. package/dist/services/webhooks/url.js +48 -0
  36. package/package.json +29 -1
  37. package/dist/components/ui/marker.d.ts +0 -10
@@ -0,0 +1,8 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { Dns } from "effect/net";
3
+ import { HttpClient } from "effect/http";
4
+ /** DNS preflight. Network egress rules must also prevent DNS rebinding. */
5
+ export declare const isPublicWebhookDestination: (url: URL) => Effect.Effect<boolean, never, Dns.Dns>;
6
+ export declare const isAllowedWebhookDestination: (url: URL) => Effect.Effect<boolean, never, Dns.Dns>;
7
+ /** Built-in fetch client with public-destination checks and no redirects. */
8
+ export declare const layer: Layer.Layer<HttpClient.HttpClient, never, Dns.Dns>;
@@ -0,0 +1,69 @@
1
+ // ../../src/services/webhooks/http-client.ts
2
+ import { Effect, Layer, Result } from "effect";
3
+ import { Dns, NetAddress } from "effect/net";
4
+ import { FetchHttpClient, HttpClient, HttpClientError } from "effect/http";
5
+
6
+ // ../../src/services/webhooks/url.ts
7
+ import { Context } from "effect";
8
+ var hostname = (value) => value.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
9
+ var isPublicIpAddress = (value) => {
10
+ const address = hostname(value);
11
+ const octets = address.split(".");
12
+ if (octets.length === 4 && octets.every((part) => /^\d{1,3}$/.test(part) && Number(part) <= 255)) {
13
+ const [a = 0, b = 0, c = 0] = octets.map(Number);
14
+ 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);
15
+ }
16
+ const first = Number.parseInt(address.split(":")[0] ?? "", 16);
17
+ return address.includes(":") && first >= 8192 && first <= 16383 && !address.startsWith("2001:") && !address.startsWith("2002:") && !address.startsWith("3fff:");
18
+ };
19
+ var isPublicWebhookUrl = (url) => {
20
+ if (!["https:", "http:"].includes(url.protocol) || url.username || url.password)
21
+ return false;
22
+ const host = hostname(url.hostname);
23
+ if (!host || host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local"))
24
+ return false;
25
+ return !(host.includes(":") || /^\d+(?:\.\d+){3}$/.test(host)) || isPublicIpAddress(host);
26
+ };
27
+ var WebhookAllowLoopback = Context.Reference("Webhooks/AllowLoopback", {
28
+ defaultValue: () => false
29
+ });
30
+ var isLoopbackWebhookUrl = (url) => ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
31
+
32
+ // ../../src/services/webhooks/http-client.ts
33
+ var isPublicWebhookDestination = Effect.fn("Webhooks.isPublicDestination")(function* (url) {
34
+ if (!isPublicWebhookUrl(url))
35
+ return false;
36
+ const hostname = url.hostname.replace(/^\[|\]$/g, "");
37
+ if (Result.isSuccess(NetAddress.ipFromString(hostname)))
38
+ return true;
39
+ const dns = yield* Dns.Dns;
40
+ return yield* dns.lookup(hostname).pipe(Effect.map((addresses) => addresses.every((address) => isPublicIpAddress(NetAddress.formatIp(address)))), Effect.catch(() => Effect.succeed(false)));
41
+ });
42
+ var isAllowedWebhookDestination = Effect.fn("Webhooks.isAllowedDestination")(function* (url) {
43
+ if ((yield* WebhookAllowLoopback) && isLoopbackWebhookUrl(url))
44
+ return true;
45
+ return yield* isPublicWebhookDestination(url);
46
+ });
47
+ var layer = Layer.effect(HttpClient.HttpClient, Effect.gen(function* () {
48
+ const client = yield* HttpClient.HttpClient;
49
+ const dns = yield* Dns.Dns;
50
+ const allowLoopback = yield* WebhookAllowLoopback;
51
+ return client.pipe(HttpClient.transform((response, request) => Effect.gen(function* () {
52
+ if (!(yield* isAllowedWebhookDestination(new URL(request.url)).pipe(Effect.provideService(Dns.Dns, dns), Effect.provideService(WebhookAllowLoopback, allowLoopback)))) {
53
+ return yield* new HttpClientError.HttpClientError({
54
+ reason: new HttpClientError.TransportError({
55
+ request,
56
+ description: "Webhook destination is not public"
57
+ })
58
+ });
59
+ }
60
+ return yield* response.pipe(Effect.provideService(FetchHttpClient.RequestInit, {
61
+ redirect: "error"
62
+ }));
63
+ })));
64
+ })).pipe(Layer.provide(FetchHttpClient.layer));
65
+ export {
66
+ isAllowedWebhookDestination,
67
+ isPublicWebhookDestination,
68
+ layer
69
+ };
@@ -0,0 +1,343 @@
1
+ import { Cause, Context, Effect, Layer, Schema } from "effect";
2
+ import { HttpClient } from "effect/http";
3
+ import { Workflow } from "effect/workflow";
4
+ import { SqlClient } from "effect/sql";
5
+ export { WebhookAllowLoopback } from "./url.js";
6
+ import { WebhookError, WebhookPayload } from "./schema.js";
7
+ export * from "./schema.js";
8
+ export { WebhooksReceiver, WebhookVerificationError, WebhookReceiptConflict, } from "./receiver.js";
9
+ export declare const DeliverWebhookV1: Workflow.Workflow<"KrakstackDeliverWebhookV1", Schema.Struct<{
10
+ organizationId: Schema.String;
11
+ id: Schema.String;
12
+ }>, Schema.Void, typeof WebhookError>;
13
+ declare const Webhooks_base: Context.ServiceClass<Webhooks, "krakstack/webhooks/Webhooks", {
14
+ list: (request: {
15
+ readonly organizationId: string;
16
+ }) => Effect.Effect<{
17
+ readonly id: string;
18
+ readonly name: string;
19
+ readonly organizationId: string;
20
+ readonly url: string;
21
+ readonly description: string | null;
22
+ readonly headers: {
23
+ readonly [x: string]: string;
24
+ } | null;
25
+ readonly events: readonly string[] | null;
26
+ readonly secret: string;
27
+ readonly enabled: boolean;
28
+ readonly createdAt: Date;
29
+ readonly updatedAt: Date;
30
+ }[], Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
31
+ get: (input: {
32
+ readonly organizationId: string;
33
+ readonly id: string;
34
+ }) => Effect.Effect<{
35
+ id: string;
36
+ name: string;
37
+ organizationId: string;
38
+ url: string;
39
+ description: string | null;
40
+ headers: {
41
+ readonly [x: string]: string;
42
+ } | null;
43
+ events: readonly string[] | null;
44
+ secret: string;
45
+ enabled: boolean;
46
+ createdAt: Date;
47
+ updatedAt: Date;
48
+ deliveries: {
49
+ readonly id: string;
50
+ readonly webhookId: string;
51
+ readonly event: string;
52
+ readonly data: Schema.Json;
53
+ readonly status: "failed" | "pending" | "success";
54
+ readonly error: string | null;
55
+ readonly completedAt: Date | null;
56
+ readonly retryAt: Date;
57
+ readonly retries: number;
58
+ readonly createdAt: Date;
59
+ readonly updatedAt: Date;
60
+ }[];
61
+ } | undefined, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
62
+ listDeliveries: (input: {
63
+ readonly page?: string | number | undefined;
64
+ readonly pageSize?: string | number | undefined;
65
+ readonly globalFilter?: string | undefined;
66
+ readonly organizationId: string;
67
+ readonly id: string;
68
+ readonly filters?: readonly ({
69
+ readonly id: string;
70
+ readonly kind: "number";
71
+ readonly min?: number | undefined;
72
+ readonly max?: number | undefined;
73
+ } | {
74
+ readonly id: string;
75
+ readonly kind: "date";
76
+ readonly from?: string | undefined;
77
+ readonly to?: string | undefined;
78
+ } | {
79
+ readonly id: string;
80
+ readonly kind: "text";
81
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
82
+ readonly value: string;
83
+ } | {
84
+ readonly id: string;
85
+ readonly kind: "boolean";
86
+ readonly value: boolean;
87
+ } | {
88
+ readonly id: string;
89
+ readonly kind: "values";
90
+ readonly values: readonly [string, ...string[]];
91
+ })[] | undefined;
92
+ readonly sort?: readonly {
93
+ readonly id: string;
94
+ readonly direction: "asc" | "desc";
95
+ }[] | undefined;
96
+ }) => Effect.Effect<{
97
+ data: {
98
+ readonly id: string;
99
+ readonly webhookId: string;
100
+ readonly event: string;
101
+ readonly data: Schema.Json;
102
+ readonly status: "failed" | "pending" | "success";
103
+ readonly error: string | null;
104
+ readonly completedAt: Date | null;
105
+ readonly retryAt: Date;
106
+ readonly retries: number;
107
+ readonly createdAt: Date;
108
+ readonly updatedAt: Date;
109
+ }[];
110
+ meta: {
111
+ page: number;
112
+ pageSize: number;
113
+ total: number;
114
+ pageCount: number;
115
+ };
116
+ } | undefined, Cause.NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
117
+ statistics: (input: {
118
+ readonly organizationId: string;
119
+ readonly id: string;
120
+ readonly interval: "day" | "hour";
121
+ }) => Effect.Effect<{
122
+ total: number;
123
+ success: number;
124
+ failed: number;
125
+ buckets: {
126
+ readonly total: number;
127
+ readonly success: number;
128
+ readonly failed: number;
129
+ readonly bucket: Date;
130
+ readonly events: readonly {
131
+ readonly event: string;
132
+ readonly total: number;
133
+ }[];
134
+ }[];
135
+ } | undefined, Cause.NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
136
+ create: (input: {
137
+ organizationId: string;
138
+ payload: WebhookPayload;
139
+ }) => Effect.Effect<{
140
+ id: string;
141
+ }, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
142
+ update: (input: {
143
+ readonly organizationId: string;
144
+ readonly id: string;
145
+ } & {
146
+ payload: WebhookPayload;
147
+ }) => Effect.Effect<{
148
+ readonly id: string;
149
+ readonly name: string;
150
+ readonly organizationId: string;
151
+ readonly url: string;
152
+ readonly description: string | null;
153
+ readonly headers: {
154
+ readonly [x: string]: string;
155
+ } | null;
156
+ readonly events: readonly string[] | null;
157
+ readonly secret: string;
158
+ readonly enabled: boolean;
159
+ readonly createdAt: Date;
160
+ readonly updatedAt: Date;
161
+ } | null, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
162
+ delete: (input: {
163
+ readonly organizationId: string;
164
+ readonly id: string;
165
+ }) => Effect.Effect<{
166
+ success: boolean;
167
+ } | null, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
168
+ publish: (input: {
169
+ readonly organizationId: string;
170
+ readonly eventId: string;
171
+ readonly event: string;
172
+ readonly data: Schema.Json;
173
+ }) => Effect.Effect<undefined, Schema.SchemaError | import("effect/sql/SqlError").SqlError | WebhookError, never>;
174
+ cleanup: () => Effect.Effect<void, import("effect/sql/SqlError").SqlError, never>;
175
+ }> & {
176
+ readonly make: Effect.Effect<{
177
+ list: (request: {
178
+ readonly organizationId: string;
179
+ }) => Effect.Effect<{
180
+ readonly id: string;
181
+ readonly name: string;
182
+ readonly organizationId: string;
183
+ readonly url: string;
184
+ readonly description: string | null;
185
+ readonly headers: {
186
+ readonly [x: string]: string;
187
+ } | null;
188
+ readonly events: readonly string[] | null;
189
+ readonly secret: string;
190
+ readonly enabled: boolean;
191
+ readonly createdAt: Date;
192
+ readonly updatedAt: Date;
193
+ }[], Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
194
+ get: (input: {
195
+ readonly organizationId: string;
196
+ readonly id: string;
197
+ }) => Effect.Effect<{
198
+ id: string;
199
+ name: string;
200
+ organizationId: string;
201
+ url: string;
202
+ description: string | null;
203
+ headers: {
204
+ readonly [x: string]: string;
205
+ } | null;
206
+ events: readonly string[] | null;
207
+ secret: string;
208
+ enabled: boolean;
209
+ createdAt: Date;
210
+ updatedAt: Date;
211
+ deliveries: {
212
+ readonly id: string;
213
+ readonly webhookId: string;
214
+ readonly event: string;
215
+ readonly data: Schema.Json;
216
+ readonly status: "failed" | "pending" | "success";
217
+ readonly error: string | null;
218
+ readonly completedAt: Date | null;
219
+ readonly retryAt: Date;
220
+ readonly retries: number;
221
+ readonly createdAt: Date;
222
+ readonly updatedAt: Date;
223
+ }[];
224
+ } | undefined, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
225
+ listDeliveries: (input: {
226
+ readonly page?: string | number | undefined;
227
+ readonly pageSize?: string | number | undefined;
228
+ readonly globalFilter?: string | undefined;
229
+ readonly organizationId: string;
230
+ readonly id: string;
231
+ readonly filters?: readonly ({
232
+ readonly id: string;
233
+ readonly kind: "number";
234
+ readonly min?: number | undefined;
235
+ readonly max?: number | undefined;
236
+ } | {
237
+ readonly id: string;
238
+ readonly kind: "date";
239
+ readonly from?: string | undefined;
240
+ readonly to?: string | undefined;
241
+ } | {
242
+ readonly id: string;
243
+ readonly kind: "text";
244
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
245
+ readonly value: string;
246
+ } | {
247
+ readonly id: string;
248
+ readonly kind: "boolean";
249
+ readonly value: boolean;
250
+ } | {
251
+ readonly id: string;
252
+ readonly kind: "values";
253
+ readonly values: readonly [string, ...string[]];
254
+ })[] | undefined;
255
+ readonly sort?: readonly {
256
+ readonly id: string;
257
+ readonly direction: "asc" | "desc";
258
+ }[] | undefined;
259
+ }) => Effect.Effect<{
260
+ data: {
261
+ readonly id: string;
262
+ readonly webhookId: string;
263
+ readonly event: string;
264
+ readonly data: Schema.Json;
265
+ readonly status: "failed" | "pending" | "success";
266
+ readonly error: string | null;
267
+ readonly completedAt: Date | null;
268
+ readonly retryAt: Date;
269
+ readonly retries: number;
270
+ readonly createdAt: Date;
271
+ readonly updatedAt: Date;
272
+ }[];
273
+ meta: {
274
+ page: number;
275
+ pageSize: number;
276
+ total: number;
277
+ pageCount: number;
278
+ };
279
+ } | undefined, Cause.NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
280
+ statistics: (input: {
281
+ readonly organizationId: string;
282
+ readonly id: string;
283
+ readonly interval: "day" | "hour";
284
+ }) => Effect.Effect<{
285
+ total: number;
286
+ success: number;
287
+ failed: number;
288
+ buckets: {
289
+ readonly total: number;
290
+ readonly success: number;
291
+ readonly failed: number;
292
+ readonly bucket: Date;
293
+ readonly events: readonly {
294
+ readonly event: string;
295
+ readonly total: number;
296
+ }[];
297
+ }[];
298
+ } | undefined, Cause.NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
299
+ create: (input: {
300
+ organizationId: string;
301
+ payload: WebhookPayload;
302
+ }) => Effect.Effect<{
303
+ id: string;
304
+ }, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
305
+ update: (input: {
306
+ readonly organizationId: string;
307
+ readonly id: string;
308
+ } & {
309
+ payload: WebhookPayload;
310
+ }) => Effect.Effect<{
311
+ readonly id: string;
312
+ readonly name: string;
313
+ readonly organizationId: string;
314
+ readonly url: string;
315
+ readonly description: string | null;
316
+ readonly headers: {
317
+ readonly [x: string]: string;
318
+ } | null;
319
+ readonly events: readonly string[] | null;
320
+ readonly secret: string;
321
+ readonly enabled: boolean;
322
+ readonly createdAt: Date;
323
+ readonly updatedAt: Date;
324
+ } | null, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
325
+ delete: (input: {
326
+ readonly organizationId: string;
327
+ readonly id: string;
328
+ }) => Effect.Effect<{
329
+ success: boolean;
330
+ } | null, Schema.SchemaError | import("effect/sql/SqlError").SqlError, never>;
331
+ publish: (input: {
332
+ readonly organizationId: string;
333
+ readonly eventId: string;
334
+ readonly event: string;
335
+ readonly data: Schema.Json;
336
+ }) => Effect.Effect<undefined, Schema.SchemaError | import("effect/sql/SqlError").SqlError | WebhookError, never>;
337
+ cleanup: () => Effect.Effect<void, import("effect/sql/SqlError").SqlError, never>;
338
+ }, never, SqlClient.SqlClient>;
339
+ };
340
+ export declare class Webhooks extends Webhooks_base {
341
+ static readonly layerWithoutMigrations: Layer.Layer<Webhooks, never, HttpClient.HttpClient | SqlClient.SqlClient | import("effect/workflow/WorkflowEngine").WorkflowEngine>;
342
+ static readonly layer: Layer.Layer<Webhooks, import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, import("effect/net/Dns").Dns | SqlClient.SqlClient | import("effect/workflow/WorkflowEngine").WorkflowEngine>;
343
+ }