@abyss-project/probe 2.0.1 → 3.0.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.
Files changed (58) hide show
  1. package/dist/api/index.d.ts +2 -1
  2. package/dist/api/index.js +2 -1
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/api/probe-delivery-subscription.api.d.ts +11 -0
  5. package/dist/api/probe-delivery-subscription.api.js +42 -0
  6. package/dist/api/probe-delivery-subscription.api.js.map +1 -0
  7. package/dist/api/probe-delivery-subscription.application.api.d.ts +11 -0
  8. package/dist/api/probe-delivery-subscription.application.api.js +38 -0
  9. package/dist/api/probe-delivery-subscription.application.api.js.map +1 -0
  10. package/dist/api/probe-webhook.application.api.d.ts +1 -1
  11. package/dist/api/probe-webhook.application.api.js.map +1 -1
  12. package/dist/index.d.ts +29 -7
  13. package/dist/index.js +29 -7
  14. package/dist/index.js.map +1 -1
  15. package/dist/types/enum/api-error.enum.d.ts +2 -1
  16. package/dist/types/enum/api-error.enum.js +1 -0
  17. package/dist/types/enum/api-error.enum.js.map +1 -1
  18. package/dist/types/enum/probe-scan.enum.js.map +1 -1
  19. package/dist/types/interface/api/requests/index.d.ts +1 -0
  20. package/dist/types/interface/api/requests/index.js +1 -0
  21. package/dist/types/interface/api/requests/index.js.map +1 -1
  22. package/dist/types/interface/api/requests/probe-delivery-subscription.request.d.ts +23 -0
  23. package/dist/types/interface/api/requests/probe-delivery-subscription.request.js +3 -0
  24. package/dist/types/interface/api/requests/probe-delivery-subscription.request.js.map +1 -0
  25. package/dist/types/interface/api/requests/probe-webhook.request.d.ts +1 -4
  26. package/dist/types/interface/api/responses/index.d.ts +1 -0
  27. package/dist/types/interface/api/responses/index.js +1 -0
  28. package/dist/types/interface/api/responses/index.js.map +1 -1
  29. package/dist/types/interface/api/responses/probe-delivery-subscription.response.d.ts +10 -0
  30. package/dist/types/interface/api/responses/probe-delivery-subscription.response.js +3 -0
  31. package/dist/types/interface/api/responses/probe-delivery-subscription.response.js.map +1 -0
  32. package/dist/types/tests/probe.dto.test.js +22 -0
  33. package/dist/types/tests/probe.dto.test.js.map +1 -1
  34. package/dist/utils/probe-webhook-signature.utils.js.map +1 -1
  35. package/package.json +10 -1
  36. package/src/api/index.ts +7 -6
  37. package/src/api/probe-delivery-subscription.api.ts +183 -0
  38. package/src/api/probe-delivery-subscription.application.api.ts +186 -0
  39. package/src/api/probe-webhook.application.api.ts +128 -141
  40. package/src/index.ts +262 -205
  41. package/src/types/enum/api-error.enum.ts +35 -33
  42. package/src/types/enum/probe-scan.enum.ts +45 -44
  43. package/src/types/interface/api/requests/index.ts +4 -3
  44. package/src/types/interface/api/requests/probe-delivery-subscription.request.ts +42 -0
  45. package/src/types/interface/api/requests/probe-webhook.request.ts +31 -33
  46. package/src/types/interface/api/responses/index.ts +4 -3
  47. package/src/types/interface/api/responses/probe-delivery-subscription.response.ts +27 -0
  48. package/src/types/interface/models/probe-webhook-delivery.dto.ts +70 -73
  49. package/src/types/tests/probe.dto.test.ts +192 -156
  50. package/src/utils/probe-webhook-signature.utils.ts +57 -56
  51. package/dist/api/probe-webhook.api.d.ts +0 -6
  52. package/dist/api/probe-webhook.api.js +0 -41
  53. package/dist/api/probe-webhook.api.js.map +0 -1
  54. package/dist/api/probe-webhook.api.test.d.ts +0 -1
  55. package/dist/api/probe-webhook.api.test.js +0 -43
  56. package/dist/api/probe-webhook.api.test.js.map +0 -1
  57. package/src/api/probe-webhook.api.test.ts +0 -17
  58. package/src/api/probe-webhook.api.ts +0 -119
@@ -1,3 +1,4 @@
1
- export * from './probe-scan.request';
2
- export * from './probe-usage.request';
3
- export * from './probe-webhook.request';
1
+ export * from './probe-scan.request';
2
+ export * from './probe-usage.request';
3
+ export * from './probe-webhook.request';
4
+ export * from './probe-delivery-subscription.request';
@@ -0,0 +1,42 @@
1
+ import type { DeliveryStatus } from '@abyss-project/flow';
2
+
3
+ // Mirrors apps/api/src/api/validators/probe-delivery-subscription.validator.ts. A client's
4
+ // subscriptions to the verdict of its scans live in Flow; AbyssProbe checks who may manage them
5
+ // and calls Flow for the scope (the caller, an organisation, or an application).
6
+
7
+ /** Personal scope (default) or an organization, for the personal/org client. */
8
+ export interface IProbeDeliverySubscriptionScopeQuery {
9
+ organizationId?: string;
10
+ }
11
+
12
+ export interface IPaginateProbeDeliverySubscriptionQuery
13
+ extends IProbeDeliverySubscriptionScopeQuery {
14
+ /** @default 1 */
15
+ page?: number;
16
+ /** @default 20 */
17
+ limit?: number;
18
+ isEnabled?: boolean;
19
+ }
20
+
21
+ export interface ICreateProbeDeliverySubscriptionBody {
22
+ /** Only `PROBE_SCAN_COMPLETED` (`DeliveryEventType.PROBE_SCAN_COMPLETED` of `@abyss-project/flow`). */
23
+ eventTypes: string[];
24
+ /** HTTPS endpoint the verdict is POSTed to. */
25
+ url: string;
26
+ }
27
+
28
+ /** At least one field is required. */
29
+ export interface IUpdateProbeDeliverySubscriptionBody {
30
+ eventTypes?: string[];
31
+ url?: string;
32
+ isEnabled?: boolean;
33
+ }
34
+
35
+ /** Deliveries of one subscription, or of every subscription of the scope. */
36
+ export interface IPaginateProbeDeliveryQuery extends IProbeDeliverySubscriptionScopeQuery {
37
+ /** @default 1 */
38
+ page?: number;
39
+ /** @default 20 */
40
+ limit?: number;
41
+ status?: DeliveryStatus;
42
+ }
@@ -1,33 +1,31 @@
1
- // Mirrors apps/api/src/api/controllers/probe-webhook.controller.ts's
2
- // ScopeQuery/CreateBody/UpdateBody and probe-webhook.validator.ts's Joi
3
- // schemas.
4
-
5
- /** Shared by create/list/delete/update — personal scope (default) or an organization. */
6
- export interface IProbeWebhookScopeQuery {
7
- organizationId?: string;
8
- }
9
-
10
- export interface ICreateProbeWebhookBody {
11
- /** HTTPS endpoint the verdict is POSTed to. Required, `https://` only. */
12
- callbackUrl: string;
13
- }
14
-
15
- /**
16
- * `PATCH /webhook/:webhookId` body (WS5-5) — at least one field required
17
- * (mirrors probe-webhook.validator.ts#updateBody's `.min(1)`); omitted
18
- * fields are left unchanged.
19
- */
20
- export interface IUpdateProbeWebhookBody {
21
- /** HTTPS endpoint the verdict is POSTed to, `https://` only. */
22
- callbackUrl?: string;
23
- /** Disabled webhooks are skipped by dispatch (soft-off, not deleted). */
24
- active?: boolean;
25
- }
26
-
27
- /** `GET /webhook/:webhookId/deliveries` query (WS5-6) — paginated. */
28
- export interface IListProbeWebhookDeliveriesQuery extends IProbeWebhookScopeQuery {
29
- /** @default 1 */
30
- page?: number;
31
- /** @default 20 */
32
- limit?: number;
33
- }
1
+ // Mirrors apps/api/src/api/controllers/probe-webhook-application.controller.ts's
2
+ // CreateBody/UpdateBody and probe-webhook.validator.ts's Joi schemas.
3
+ //
4
+ // INTERNAL (P5 #792): the application webhooks serve AbyssStorage's antivirus subscription until
5
+ // its client subscriptions move to Flow (L2). A client's own subscriptions are the Flow
6
+ // delivery subscriptions (probe-delivery-subscription.request.ts).
7
+
8
+ export interface ICreateProbeWebhookBody {
9
+ /** HTTPS endpoint the verdict is POSTed to. Required, `https://` only. */
10
+ callbackUrl: string;
11
+ }
12
+
13
+ /**
14
+ * `PATCH /application/:applicationId/webhook/:webhookId` body (WS5-5) — at least one field required
15
+ * (mirrors probe-webhook.validator.ts#updateBody's `.min(1)`); omitted
16
+ * fields are left unchanged.
17
+ */
18
+ export interface IUpdateProbeWebhookBody {
19
+ /** HTTPS endpoint the verdict is POSTed to, `https://` only. */
20
+ callbackUrl?: string;
21
+ /** Disabled webhooks are skipped by dispatch (soft-off, not deleted). */
22
+ active?: boolean;
23
+ }
24
+
25
+ /** `GET /application/:applicationId/webhook/:webhookId/deliveries` query (WS5-6) — paginated. */
26
+ export interface IListProbeWebhookDeliveriesQuery {
27
+ /** @default 1 */
28
+ page?: number;
29
+ /** @default 20 */
30
+ limit?: number;
31
+ }
@@ -1,3 +1,4 @@
1
- export * from './probe-scan.response';
2
- export * from './probe-usage.response';
3
- export * from './probe-webhook.response';
1
+ export * from './probe-scan.response';
2
+ export * from './probe-usage.response';
3
+ export * from './probe-webhook.response';
4
+ export * from './probe-delivery-subscription.response';
@@ -0,0 +1,27 @@
1
+ import type {
2
+ ICreateDeliverySubscriptionResponse,
3
+ IDeleteDeliverySubscriptionResponse,
4
+ IGetDeliveryResponse,
5
+ IGetDeliverySubscriptionResponse,
6
+ IPaginateDeliveryResponse,
7
+ IPaginateDeliverySubscriptionResponse,
8
+ IReplayDeliveryResponse,
9
+ IResetSecretDeliverySubscriptionResponse,
10
+ IUpdateDeliverySubscriptionResponse,
11
+ } from '@abyss-project/flow';
12
+
13
+ // The answers are Flow's own, passed through: the subscription and delivery models of
14
+ // `@abyss-project/flow`. The secret leaves only with a creation and a reset.
15
+
16
+ export type IPaginateProbeDeliverySubscriptionResponse = IPaginateDeliverySubscriptionResponse;
17
+ export type IGetProbeDeliverySubscriptionResponse = IGetDeliverySubscriptionResponse;
18
+ /** `secret` is returned here once. */
19
+ export type ICreateProbeDeliverySubscriptionResponse = ICreateDeliverySubscriptionResponse;
20
+ export type IUpdateProbeDeliverySubscriptionResponse = IUpdateDeliverySubscriptionResponse;
21
+ export type IDeleteProbeDeliverySubscriptionResponse = IDeleteDeliverySubscriptionResponse;
22
+ /** The new `secret` is returned here once; the previous one stops signing. */
23
+ export type IResetSecretProbeDeliverySubscriptionResponse =
24
+ IResetSecretDeliverySubscriptionResponse;
25
+ export type IPaginateProbeDeliveryResponse = IPaginateDeliveryResponse;
26
+ export type IGetProbeDeliveryResponse = IGetDeliveryResponse;
27
+ export type IReplayProbeDeliveryResponse = IReplayDeliveryResponse;
@@ -1,73 +1,70 @@
1
- import { ProbeScanVerdict } from '../../enum';
2
-
3
- // Mirrors apps/api/src/services/probe-webhook-delivery.service.ts's
4
- // ProbeWebhookPayload EXACTLY (same field set, same JSON.stringify'd body a
5
- // receiver's raw request body will deserialize into) — this is the payload
6
- // AbyssProbe POSTs to every registered webhook's `callbackUrl` (and to a
7
- // scan's own per-request `callbackUrl`, see probe-scan docs) once an ASYNC
8
- // scan reaches a verdict (`status: DONE`).
9
- //
10
- // `verdict` is typed as the concrete enum here (not `string` like the
11
- // server's internal type) because delivery only ever happens on a DONE scan,
12
- // where the verdict is always set — see dispatchProbeScanWebhooks's guard.
13
-
14
- /**
15
- * Body of a webhook delivery, signed via HMAC-SHA256 of
16
- * `JSON.stringify(payload)` — see {@link PROBE_WEBHOOK_SIGNATURE_HEADER} and
17
- * {@link verifyProbeWebhookSignature} (this package's root / utils).
18
- */
19
- export interface IProbeWebhookDeliveryPayload {
20
- scanId: string;
21
- /** Free-form caller reference, echoed back verbatim (see IProbeScanHistoryItem#context). */
22
- context: Record<string, unknown> | null;
23
- verdict: ProbeScanVerdict;
24
- /** [] when clean. */
25
- viruses: string[];
26
- /**
27
- * `ACCOUNT_AV_SCAN_UNITS` this scan consumed (WS5-1). Delivery only ever
28
- * happens on a DONE scan, where the cost is always already computed and
29
- * billed — see {@link IProbeScanHistoryItem#costUnits}.
30
- */
31
- costUnits: number | null;
32
- }
33
-
34
- // ─── Delivery HISTORY (WS5-6) ────────────────
35
- //
36
- // The interface above is the PAYLOAD a webhook receiver gets POSTed. This
37
- // section is a DIFFERENT concept: the persisted AUDIT ROW AbyssProbe keeps
38
- // of its OWN delivery attempts (one row per attempt — mirrors
39
- // apps/api/src/database/models/probe-webhook-delivery.model.ts EXACTLY,
40
- // itself modelled after this package's own extraction-webhook
41
- // delivery-history shape, trimmed to AbyssProbe's simpler
42
- // one-attempt-per-row reality — see that model's header comment). Read via
43
- // `GET /webhook/:webhookId/deliveries` (`sdk.probe.webhook.listDeliveries`).
44
-
45
- /**
46
- * One persisted delivery-attempt row, as returned (paginated) by
47
- * `GET /webhook/:webhookId/deliveries`.
48
- */
49
- export interface IProbeWebhookDelivery {
50
- id: string;
51
- /**
52
- * The registered webhook this delivery targeted. null for a delivery to a
53
- * scan's own ad-hoc per-request `callbackUrl` that matched no registered
54
- * webhook (see the server model's own doc comment) — such a row is never
55
- * reachable via this webhook-scoped endpoint in practice (there is no
56
- * webhookId to query it under), but the field stays nullable to mirror the
57
- * server column's real type.
58
- */
59
- webhookId: string | null;
60
- /** The scan whose verdict this delivery carried. */
61
- scanId: string;
62
- /** The exact URL this attempt POSTed to. */
63
- url: string;
64
- /** HTTP status code received. null when the request never got a response (network error / timeout / abort). */
65
- statusCode: number | null;
66
- /** true only for a 2xx response. */
67
- success: boolean;
68
- /** When this attempt was made. */
69
- attemptedAt: Date;
70
- /** Failure reason (HTTP non-2xx status, or the caught network/timeout error's message). null on success. */
71
- error: string | null;
72
- createdAt: Date;
73
- }
1
+ import { ProbeScanVerdict } from '../../enum';
2
+
3
+ // What AbyssProbe announces once a scan reaches a verdict (`status: DONE`): the `data` of the
4
+ // `PROBE_SCAN_COMPLETED` event that Flow delivers to a client's delivery subscription (Flow's
5
+ // envelope `{ deliveryId, eventType, source, occurredAt, data }`), and the JSON body of the
6
+ // internal webhook AbyssStorage still receives until L2. Mirrors
7
+ // apps/api/src/services/probe-webhook-delivery.service.ts's ProbeWebhookPayload EXACTLY.
8
+ //
9
+ // `verdict` is typed as the concrete enum here (not `string` like the
10
+ // server's internal type) because delivery only ever happens on a DONE scan,
11
+ // where the verdict is always set — see dispatchProbeScanWebhooks's guard.
12
+
13
+ /**
14
+ * Payload of a finished scan. Flow signs the deliveries of a client's subscription (see
15
+ * `@abyss-project/flow`); the internal webhook is signed via HMAC-SHA256 of
16
+ * `JSON.stringify(payload)` — {@link PROBE_WEBHOOK_SIGNATURE_HEADER} and
17
+ * {@link verifyProbeWebhookSignature} (this package's root / utils).
18
+ */
19
+ export interface IProbeWebhookDeliveryPayload {
20
+ scanId: string;
21
+ /** Free-form caller reference, echoed back verbatim (see IProbeScanHistoryItem#context). */
22
+ context: Record<string, unknown> | null;
23
+ verdict: ProbeScanVerdict;
24
+ /** [] when clean. */
25
+ viruses: string[];
26
+ /**
27
+ * `ACCOUNT_AV_SCAN_UNITS` this scan consumed (WS5-1). Delivery only ever
28
+ * happens on a DONE scan, where the cost is always already computed and
29
+ * billed — see {@link IProbeScanHistoryItem#costUnits}.
30
+ */
31
+ costUnits: number | null;
32
+ }
33
+
34
+ // ─── Delivery HISTORY (WS5-6) ────────────────
35
+ //
36
+ // The interface above is the PAYLOAD a webhook receiver gets POSTed. This
37
+ // section is a DIFFERENT concept: the persisted AUDIT ROW AbyssProbe keeps
38
+ // of its OWN delivery attempts (one row per attempt — mirrors
39
+ // apps/api/src/database/models/probe-webhook-delivery.model.ts EXACTLY,
40
+ // itself modelled after this package's own extraction-webhook
41
+ // delivery-history shape, trimmed to AbyssProbe's simpler
42
+ // one-attempt-per-row reality — see that model's header comment). Read via
43
+ // `GET /webhook/:webhookId/deliveries` (`sdk.probe.webhook.listDeliveries`).
44
+
45
+ /**
46
+ * One persisted delivery-attempt row, as returned (paginated) by
47
+ * `GET /webhook/:webhookId/deliveries`.
48
+ */
49
+ export interface IProbeWebhookDelivery {
50
+ id: string;
51
+ /**
52
+ * The registered webhook this delivery targeted. Always set today (a scan's
53
+ * `callbackUrl` is delivered by Flow, not by this history); the field stays
54
+ * nullable to mirror the server column's real type.
55
+ */
56
+ webhookId: string | null;
57
+ /** The scan whose verdict this delivery carried. */
58
+ scanId: string;
59
+ /** The exact URL this attempt POSTed to. */
60
+ url: string;
61
+ /** HTTP status code received. null when the request never got a response (network error / timeout / abort). */
62
+ statusCode: number | null;
63
+ /** true only for a 2xx response. */
64
+ success: boolean;
65
+ /** When this attempt was made. */
66
+ attemptedAt: Date;
67
+ /** Failure reason (HTTP non-2xx status, or the caught network/timeout error's message). null on success. */
68
+ error: string | null;
69
+ createdAt: Date;
70
+ }