@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.
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +2 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/probe-delivery-subscription.api.d.ts +11 -0
- package/dist/api/probe-delivery-subscription.api.js +42 -0
- package/dist/api/probe-delivery-subscription.api.js.map +1 -0
- package/dist/api/probe-delivery-subscription.application.api.d.ts +11 -0
- package/dist/api/probe-delivery-subscription.application.api.js +38 -0
- package/dist/api/probe-delivery-subscription.application.api.js.map +1 -0
- package/dist/api/probe-webhook.application.api.d.ts +1 -1
- package/dist/api/probe-webhook.application.api.js.map +1 -1
- package/dist/index.d.ts +29 -7
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/dist/types/enum/api-error.enum.d.ts +2 -1
- package/dist/types/enum/api-error.enum.js +1 -0
- package/dist/types/enum/api-error.enum.js.map +1 -1
- package/dist/types/enum/probe-scan.enum.js.map +1 -1
- package/dist/types/interface/api/requests/index.d.ts +1 -0
- package/dist/types/interface/api/requests/index.js +1 -0
- package/dist/types/interface/api/requests/index.js.map +1 -1
- package/dist/types/interface/api/requests/probe-delivery-subscription.request.d.ts +23 -0
- package/dist/types/interface/api/requests/probe-delivery-subscription.request.js +3 -0
- package/dist/types/interface/api/requests/probe-delivery-subscription.request.js.map +1 -0
- package/dist/types/interface/api/requests/probe-webhook.request.d.ts +1 -4
- package/dist/types/interface/api/responses/index.d.ts +1 -0
- package/dist/types/interface/api/responses/index.js +1 -0
- package/dist/types/interface/api/responses/index.js.map +1 -1
- package/dist/types/interface/api/responses/probe-delivery-subscription.response.d.ts +10 -0
- package/dist/types/interface/api/responses/probe-delivery-subscription.response.js +3 -0
- package/dist/types/interface/api/responses/probe-delivery-subscription.response.js.map +1 -0
- package/dist/types/tests/probe.dto.test.js +22 -0
- package/dist/types/tests/probe.dto.test.js.map +1 -1
- package/dist/utils/probe-webhook-signature.utils.js.map +1 -1
- package/package.json +10 -1
- package/src/api/index.ts +7 -6
- package/src/api/probe-delivery-subscription.api.ts +183 -0
- package/src/api/probe-delivery-subscription.application.api.ts +186 -0
- package/src/api/probe-webhook.application.api.ts +128 -141
- package/src/index.ts +262 -205
- package/src/types/enum/api-error.enum.ts +35 -33
- package/src/types/enum/probe-scan.enum.ts +45 -44
- package/src/types/interface/api/requests/index.ts +4 -3
- package/src/types/interface/api/requests/probe-delivery-subscription.request.ts +42 -0
- package/src/types/interface/api/requests/probe-webhook.request.ts +31 -33
- package/src/types/interface/api/responses/index.ts +4 -3
- package/src/types/interface/api/responses/probe-delivery-subscription.response.ts +27 -0
- package/src/types/interface/models/probe-webhook-delivery.dto.ts +70 -73
- package/src/types/tests/probe.dto.test.ts +192 -156
- package/src/utils/probe-webhook-signature.utils.ts +57 -56
- package/dist/api/probe-webhook.api.d.ts +0 -6
- package/dist/api/probe-webhook.api.js +0 -41
- package/dist/api/probe-webhook.api.js.map +0 -1
- package/dist/api/probe-webhook.api.test.d.ts +0 -1
- package/dist/api/probe-webhook.api.test.js +0 -43
- package/dist/api/probe-webhook.api.test.js.map +0 -1
- package/src/api/probe-webhook.api.test.ts +0 -17
- 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
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/** @default
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* `JSON.stringify(payload)` —
|
|
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.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
success
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
}
|