@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
package/src/index.ts
CHANGED
|
@@ -1,205 +1,262 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import axiosRetry, { IAxiosRetryConfig, isNetworkOrIdempotentRequestError } from 'axios-retry';
|
|
3
|
-
import * as probeScanApi from './api/probe-scan.api';
|
|
4
|
-
import * as
|
|
5
|
-
import * as probeScanApplicationApi from './api/probe-scan.application.api';
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import axiosRetry, { IAxiosRetryConfig, isNetworkOrIdempotentRequestError } from 'axios-retry';
|
|
3
|
+
import * as probeScanApi from './api/probe-scan.api';
|
|
4
|
+
import * as probeDeliverySubscriptionApi from './api/probe-delivery-subscription.api';
|
|
5
|
+
import * as probeScanApplicationApi from './api/probe-scan.application.api';
|
|
6
|
+
import * as probeDeliverySubscriptionApplicationApi from './api/probe-delivery-subscription.application.api';
|
|
7
|
+
import * as probeWebhookApplicationApi from './api/probe-webhook.application.api';
|
|
8
|
+
import * as probeUsageApi from './api/probe-usage.api';
|
|
9
|
+
import * as probeUsageApplicationApi from './api/probe-usage.application.api';
|
|
10
|
+
|
|
11
|
+
export * from './api';
|
|
12
|
+
export * from './types';
|
|
13
|
+
export * from './utils';
|
|
14
|
+
export * from './constants';
|
|
15
|
+
|
|
16
|
+
const DEFAULT_BASE_URL = 'https://probe-api.abyss-project.fr/api/';
|
|
17
|
+
|
|
18
|
+
export const API_KEY_HEADER = 'abyss-api-key';
|
|
19
|
+
/**
|
|
20
|
+
* Application-level API key header (AbyssProbe application/API-key
|
|
21
|
+
* authentication). Same literal value every other Abyss service's own core
|
|
22
|
+
* package independently declares for its `ApplicationMiddleware`.
|
|
23
|
+
*/
|
|
24
|
+
export const API_KEY_APPLICATION_HEADER = 'abyss-api-key-application';
|
|
25
|
+
export const ADMIN_TOKEN_HEADER = 'abyss-admin-token';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Header carrying the HMAC-SHA256 signature of a probe webhook delivery's
|
|
29
|
+
* raw JSON body. Verify it with {@link verifyProbeWebhookSignature}
|
|
30
|
+
* (re-exported from './utils'). INTERNAL (P5 #792): AbyssStorage's antivirus
|
|
31
|
+
* subscription is the only receiver until L2 — the deliveries of a client's
|
|
32
|
+
* subscription are signed by Flow.
|
|
33
|
+
*/
|
|
34
|
+
export const PROBE_WEBHOOK_SIGNATURE_HEADER = 'x-probe-signature';
|
|
35
|
+
export const PROBE_WEBHOOK_SIGNATURE_ALGORITHM = 'sha256';
|
|
36
|
+
|
|
37
|
+
const NUMBER_RETRY_API = 10;
|
|
38
|
+
const BASE_DELAY_BETWEEN_RETRY = 5000;
|
|
39
|
+
const RETRY_CODES = [
|
|
40
|
+
502, // Bad Gateway
|
|
41
|
+
503, // Service Unavailable
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
type CoreConfig = {
|
|
45
|
+
token?: string;
|
|
46
|
+
apiKey?: string;
|
|
47
|
+
adminToken?: string;
|
|
48
|
+
baseURL?: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type AbyssProbeCoreSDK = {
|
|
52
|
+
probe: {
|
|
53
|
+
/** `POST /scan` — sync (default) or async depending on `options.mode`. */
|
|
54
|
+
scan: typeof probeScanApi.scan;
|
|
55
|
+
/** `POST /scan` forced to `mode: sync` — precisely-typed 200 response. */
|
|
56
|
+
scanSync: typeof probeScanApi.scanSync;
|
|
57
|
+
/** `POST /scan?mode=async` — precisely-typed 202 response. */
|
|
58
|
+
scanAsync: typeof probeScanApi.scanAsync;
|
|
59
|
+
/** `GET /scan/:scanId` — poll a scan's status/verdict. */
|
|
60
|
+
getScan: typeof probeScanApi.getScan;
|
|
61
|
+
/** `GET /scan` — paginated history/search. */
|
|
62
|
+
listScans: typeof probeScanApi.listScans;
|
|
63
|
+
/** `GET /usage` — current ACCOUNT_AV_SCAN_UNITS used/limit/remaining for the caller's scope. */
|
|
64
|
+
usage: {
|
|
65
|
+
get: typeof probeUsageApi.getProbeUsage;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* The subscriptions to the verdict of the caller's scans (`PROBE_SCAN_COMPLETED`), kept in
|
|
69
|
+
* Flow: personal scope, or an organization with `organizationId`. The deliveries are signed
|
|
70
|
+
* by Flow; the secret leaves with `create` and `resetSecret` only.
|
|
71
|
+
*/
|
|
72
|
+
deliverySubscription: {
|
|
73
|
+
paginate: typeof probeDeliverySubscriptionApi.paginateProbeDeliverySubscription;
|
|
74
|
+
get: typeof probeDeliverySubscriptionApi.getProbeDeliverySubscription;
|
|
75
|
+
create: typeof probeDeliverySubscriptionApi.createProbeDeliverySubscription;
|
|
76
|
+
update: typeof probeDeliverySubscriptionApi.updateProbeDeliverySubscription;
|
|
77
|
+
delete: typeof probeDeliverySubscriptionApi.deleteProbeDeliverySubscription;
|
|
78
|
+
resetSecret: typeof probeDeliverySubscriptionApi.resetSecretProbeDeliverySubscription;
|
|
79
|
+
delivery: {
|
|
80
|
+
/** Deliveries of every subscription of the scope. */
|
|
81
|
+
paginateByScope: typeof probeDeliverySubscriptionApi.paginateProbeScopeDelivery;
|
|
82
|
+
paginate: typeof probeDeliverySubscriptionApi.paginateProbeDelivery;
|
|
83
|
+
get: typeof probeDeliverySubscriptionApi.getProbeDelivery;
|
|
84
|
+
replay: typeof probeDeliverySubscriptionApi.replayProbeDelivery;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Application/API-key-auth counterpart (Phase 3a) — for inter-service
|
|
89
|
+
* callers (abyss-storage, external integrations) instead of a
|
|
90
|
+
* personal/org session. Same request/response contracts as the methods
|
|
91
|
+
* above, hitting `/application/:applicationId/...` and authenticated
|
|
92
|
+
* with the `abyss-api-key-application` header ({@link
|
|
93
|
+
* API_KEY_APPLICATION_HEADER}) instead of the personal `abyss-api-key`.
|
|
94
|
+
*/
|
|
95
|
+
application: {
|
|
96
|
+
/** `POST /application/:applicationId/scan` — sync (default) or async depending on `options.mode`. */
|
|
97
|
+
scan: typeof probeScanApplicationApi.scanApplication;
|
|
98
|
+
/** `POST /application/:applicationId/scan` forced to `mode: sync` — precisely-typed 200 response. */
|
|
99
|
+
scanSync: typeof probeScanApplicationApi.scanSyncApplication;
|
|
100
|
+
/** `POST /application/:applicationId/scan?mode=async` — precisely-typed 202 response. */
|
|
101
|
+
scanAsync: typeof probeScanApplicationApi.scanAsyncApplication;
|
|
102
|
+
/** `GET /application/:applicationId/scan/:scanId` — poll a scan's status/verdict. */
|
|
103
|
+
getScan: typeof probeScanApplicationApi.getScanApplication;
|
|
104
|
+
/** `GET /application/:applicationId/scan` — paginated history/search. */
|
|
105
|
+
listScans: typeof probeScanApplicationApi.listScansApplication;
|
|
106
|
+
/** `GET /application/:applicationId/usage` — current ACCOUNT_AV_SCAN_UNITS used/limit/remaining for the calling application. */
|
|
107
|
+
usage: {
|
|
108
|
+
get: typeof probeUsageApplicationApi.getProbeUsageApplication;
|
|
109
|
+
};
|
|
110
|
+
/** Same as `probe.deliverySubscription`, for the application (`FULL_ACCESS`). */
|
|
111
|
+
deliverySubscription: {
|
|
112
|
+
paginate: typeof probeDeliverySubscriptionApplicationApi.paginateProbeDeliverySubscriptionApplication;
|
|
113
|
+
get: typeof probeDeliverySubscriptionApplicationApi.getProbeDeliverySubscriptionApplication;
|
|
114
|
+
create: typeof probeDeliverySubscriptionApplicationApi.createProbeDeliverySubscriptionApplication;
|
|
115
|
+
update: typeof probeDeliverySubscriptionApplicationApi.updateProbeDeliverySubscriptionApplication;
|
|
116
|
+
delete: typeof probeDeliverySubscriptionApplicationApi.deleteProbeDeliverySubscriptionApplication;
|
|
117
|
+
resetSecret: typeof probeDeliverySubscriptionApplicationApi.resetSecretProbeDeliverySubscriptionApplication;
|
|
118
|
+
delivery: {
|
|
119
|
+
paginateByScope: typeof probeDeliverySubscriptionApplicationApi.paginateProbeScopeDeliveryApplication;
|
|
120
|
+
paginate: typeof probeDeliverySubscriptionApplicationApi.paginateProbeDeliveryApplication;
|
|
121
|
+
get: typeof probeDeliverySubscriptionApplicationApi.getProbeDeliveryApplication;
|
|
122
|
+
replay: typeof probeDeliverySubscriptionApplicationApi.replayProbeDeliveryApplication;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/** INTERNAL (P5 #792): AbyssStorage's antivirus subscription, until L2. */
|
|
126
|
+
webhook: {
|
|
127
|
+
create: typeof probeWebhookApplicationApi.createProbeWebhookApplication;
|
|
128
|
+
list: typeof probeWebhookApplicationApi.listProbeWebhookApplication;
|
|
129
|
+
delete: typeof probeWebhookApplicationApi.deleteProbeWebhookApplication;
|
|
130
|
+
/** `PATCH /application/:applicationId/webhook/:webhookId` — edit callbackUrl and/or active. */
|
|
131
|
+
update: typeof probeWebhookApplicationApi.updateProbeWebhookApplication;
|
|
132
|
+
/** `GET /application/:applicationId/webhook/:webhookId/deliveries` — paginated delivery-attempt history. */
|
|
133
|
+
listDeliveries: typeof probeWebhookApplicationApi.listProbeWebhookDeliveriesApplication;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export class AbyssProbeCore {
|
|
140
|
+
private static config = {
|
|
141
|
+
token: '',
|
|
142
|
+
apiKey: '',
|
|
143
|
+
adminToken: '',
|
|
144
|
+
baseURL: DEFAULT_BASE_URL,
|
|
145
|
+
};
|
|
146
|
+
static axios = axios.create({
|
|
147
|
+
baseURL: this.config.baseURL,
|
|
148
|
+
withCredentials: true,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
private static _sdk: AbyssProbeCoreSDK | null = null;
|
|
152
|
+
|
|
153
|
+
public static get sdk(): AbyssProbeCoreSDK {
|
|
154
|
+
if (!AbyssProbeCore._sdk) {
|
|
155
|
+
AbyssProbeCore._sdk = AbyssProbeCore.buildSDK();
|
|
156
|
+
}
|
|
157
|
+
return AbyssProbeCore._sdk;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private static buildSDK(): AbyssProbeCoreSDK {
|
|
161
|
+
return {
|
|
162
|
+
probe: {
|
|
163
|
+
scan: probeScanApi.scan,
|
|
164
|
+
scanSync: probeScanApi.scanSync,
|
|
165
|
+
scanAsync: probeScanApi.scanAsync,
|
|
166
|
+
getScan: probeScanApi.getScan,
|
|
167
|
+
listScans: probeScanApi.listScans,
|
|
168
|
+
usage: {
|
|
169
|
+
get: probeUsageApi.getProbeUsage,
|
|
170
|
+
},
|
|
171
|
+
deliverySubscription: {
|
|
172
|
+
paginate: probeDeliverySubscriptionApi.paginateProbeDeliverySubscription,
|
|
173
|
+
get: probeDeliverySubscriptionApi.getProbeDeliverySubscription,
|
|
174
|
+
create: probeDeliverySubscriptionApi.createProbeDeliverySubscription,
|
|
175
|
+
update: probeDeliverySubscriptionApi.updateProbeDeliverySubscription,
|
|
176
|
+
delete: probeDeliverySubscriptionApi.deleteProbeDeliverySubscription,
|
|
177
|
+
resetSecret: probeDeliverySubscriptionApi.resetSecretProbeDeliverySubscription,
|
|
178
|
+
delivery: {
|
|
179
|
+
paginateByScope: probeDeliverySubscriptionApi.paginateProbeScopeDelivery,
|
|
180
|
+
paginate: probeDeliverySubscriptionApi.paginateProbeDelivery,
|
|
181
|
+
get: probeDeliverySubscriptionApi.getProbeDelivery,
|
|
182
|
+
replay: probeDeliverySubscriptionApi.replayProbeDelivery,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
application: {
|
|
186
|
+
scan: probeScanApplicationApi.scanApplication,
|
|
187
|
+
scanSync: probeScanApplicationApi.scanSyncApplication,
|
|
188
|
+
scanAsync: probeScanApplicationApi.scanAsyncApplication,
|
|
189
|
+
getScan: probeScanApplicationApi.getScanApplication,
|
|
190
|
+
listScans: probeScanApplicationApi.listScansApplication,
|
|
191
|
+
usage: {
|
|
192
|
+
get: probeUsageApplicationApi.getProbeUsageApplication,
|
|
193
|
+
},
|
|
194
|
+
deliverySubscription: {
|
|
195
|
+
paginate:
|
|
196
|
+
probeDeliverySubscriptionApplicationApi.paginateProbeDeliverySubscriptionApplication,
|
|
197
|
+
get: probeDeliverySubscriptionApplicationApi.getProbeDeliverySubscriptionApplication,
|
|
198
|
+
create:
|
|
199
|
+
probeDeliverySubscriptionApplicationApi.createProbeDeliverySubscriptionApplication,
|
|
200
|
+
update:
|
|
201
|
+
probeDeliverySubscriptionApplicationApi.updateProbeDeliverySubscriptionApplication,
|
|
202
|
+
delete:
|
|
203
|
+
probeDeliverySubscriptionApplicationApi.deleteProbeDeliverySubscriptionApplication,
|
|
204
|
+
resetSecret:
|
|
205
|
+
probeDeliverySubscriptionApplicationApi.resetSecretProbeDeliverySubscriptionApplication,
|
|
206
|
+
delivery: {
|
|
207
|
+
paginateByScope:
|
|
208
|
+
probeDeliverySubscriptionApplicationApi.paginateProbeScopeDeliveryApplication,
|
|
209
|
+
paginate: probeDeliverySubscriptionApplicationApi.paginateProbeDeliveryApplication,
|
|
210
|
+
get: probeDeliverySubscriptionApplicationApi.getProbeDeliveryApplication,
|
|
211
|
+
replay: probeDeliverySubscriptionApplicationApi.replayProbeDeliveryApplication,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
webhook: {
|
|
215
|
+
create: probeWebhookApplicationApi.createProbeWebhookApplication,
|
|
216
|
+
list: probeWebhookApplicationApi.listProbeWebhookApplication,
|
|
217
|
+
delete: probeWebhookApplicationApi.deleteProbeWebhookApplication,
|
|
218
|
+
update: probeWebhookApplicationApi.updateProbeWebhookApplication,
|
|
219
|
+
listDeliveries: probeWebhookApplicationApi.listProbeWebhookDeliveriesApplication,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public static enableAxiosRetry(axiosRetryConfig?: IAxiosRetryConfig): void {
|
|
227
|
+
axiosRetry(AbyssProbeCore.axios, {
|
|
228
|
+
retries: NUMBER_RETRY_API,
|
|
229
|
+
retryDelay: (retryCount) => retryCount * BASE_DELAY_BETWEEN_RETRY,
|
|
230
|
+
retryCondition: (error) =>
|
|
231
|
+
isNetworkOrIdempotentRequestError(error) ||
|
|
232
|
+
RETRY_CODES.includes(error.response?.status || 502),
|
|
233
|
+
...axiosRetryConfig,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public static setConfig(config: CoreConfig): void {
|
|
238
|
+
AbyssProbeCore._sdk = null;
|
|
239
|
+
|
|
240
|
+
AbyssProbeCore.config = { ...AbyssProbeCore.config, ...config };
|
|
241
|
+
|
|
242
|
+
if (config.baseURL) {
|
|
243
|
+
AbyssProbeCore.axios.defaults.baseURL = config.baseURL;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (config.token) {
|
|
247
|
+
AbyssProbeCore.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (config.apiKey) {
|
|
251
|
+
AbyssProbeCore.axios.defaults.headers.common[API_KEY_HEADER] = `${config.apiKey}`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (config.adminToken) {
|
|
255
|
+
AbyssProbeCore.axios.defaults.headers.common[ADMIN_TOKEN_HEADER] = `${config.adminToken}`;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
public static getConfig(): CoreConfig {
|
|
260
|
+
return AbyssProbeCore.config;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
export enum ErrorType {
|
|
2
|
-
apiError = 'api_error',
|
|
3
|
-
authError = 'authentication_error',
|
|
4
|
-
resourceError = 'resource_error',
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export enum Code {
|
|
8
|
-
// HTTP Error
|
|
9
|
-
tokenFailure = 'token_authentication_failure',
|
|
10
|
-
authenticationFailure = 'authentication_credentials_failure',
|
|
11
|
-
accessNotAllowed = 'access_not_allowed',
|
|
12
|
-
notFound = 'not_found',
|
|
13
|
-
validationError = 'resource_validation_error',
|
|
14
|
-
constraintError = 'resource_constraint_error',
|
|
15
|
-
internalServerError = 'internal_server_error',
|
|
16
|
-
serviceUnavailable = 'service_unavailable',
|
|
17
|
-
invalidData = 'invalid_data',
|
|
18
|
-
notImplemented = 'not_implemented',
|
|
19
|
-
retrospectiveCannotBeModifiedWhenCompleted = 'retrospective_cannot_be_modified_when_completed',
|
|
20
|
-
retrospectiveActionNotAllowedInPhase = 'retrospective_action_not_allowed_in_phase',
|
|
21
|
-
retrospectiveVoteBudgetExhausted = 'retrospective_vote_budget_exhausted',
|
|
22
|
-
retrospectiveActionLimitReached = 'retrospective_action_limit_reached',
|
|
23
|
-
atlasDocumentLimitReached = 'atlas_document_limit_reached',
|
|
24
|
-
boardCardDocumentLimitReached = 'board_card_document_limit_reached',
|
|
25
|
-
boardCardMoveInvalidDestination = 'board_card_move_invalid_destination',
|
|
26
|
-
boardCardLinkLimitReached = 'board_card_link_limit_reached',
|
|
27
|
-
boardCardLinkAlreadyExists = 'board_card_link_already_exists',
|
|
28
|
-
boardCardLinkToSelf = 'board_card_link_to_self',
|
|
29
|
-
shortLinkProtected = 'short_link_protected',
|
|
30
|
-
drawImageLimitReached = 'draw_image_limit_reached',
|
|
31
|
-
drawImageOwnerRequired = 'draw_image_owner_required',
|
|
32
|
-
drawImageNotInDraw = 'draw_image_not_in_draw',
|
|
33
|
-
|
|
1
|
+
export enum ErrorType {
|
|
2
|
+
apiError = 'api_error',
|
|
3
|
+
authError = 'authentication_error',
|
|
4
|
+
resourceError = 'resource_error',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum Code {
|
|
8
|
+
// HTTP Error
|
|
9
|
+
tokenFailure = 'token_authentication_failure',
|
|
10
|
+
authenticationFailure = 'authentication_credentials_failure',
|
|
11
|
+
accessNotAllowed = 'access_not_allowed',
|
|
12
|
+
notFound = 'not_found',
|
|
13
|
+
validationError = 'resource_validation_error',
|
|
14
|
+
constraintError = 'resource_constraint_error',
|
|
15
|
+
internalServerError = 'internal_server_error',
|
|
16
|
+
serviceUnavailable = 'service_unavailable',
|
|
17
|
+
invalidData = 'invalid_data',
|
|
18
|
+
notImplemented = 'not_implemented',
|
|
19
|
+
retrospectiveCannotBeModifiedWhenCompleted = 'retrospective_cannot_be_modified_when_completed',
|
|
20
|
+
retrospectiveActionNotAllowedInPhase = 'retrospective_action_not_allowed_in_phase',
|
|
21
|
+
retrospectiveVoteBudgetExhausted = 'retrospective_vote_budget_exhausted',
|
|
22
|
+
retrospectiveActionLimitReached = 'retrospective_action_limit_reached',
|
|
23
|
+
atlasDocumentLimitReached = 'atlas_document_limit_reached',
|
|
24
|
+
boardCardDocumentLimitReached = 'board_card_document_limit_reached',
|
|
25
|
+
boardCardMoveInvalidDestination = 'board_card_move_invalid_destination',
|
|
26
|
+
boardCardLinkLimitReached = 'board_card_link_limit_reached',
|
|
27
|
+
boardCardLinkAlreadyExists = 'board_card_link_already_exists',
|
|
28
|
+
boardCardLinkToSelf = 'board_card_link_to_self',
|
|
29
|
+
shortLinkProtected = 'short_link_protected',
|
|
30
|
+
drawImageLimitReached = 'draw_image_limit_reached',
|
|
31
|
+
drawImageOwnerRequired = 'draw_image_owner_required',
|
|
32
|
+
drawImageNotInDraw = 'draw_image_not_in_draw',
|
|
33
|
+
/** A scan `callbackUrl` in a scope with no enabled delivery subscription to sign it with (422). */
|
|
34
|
+
probeCallbackRequiresSubscription = 'probe_callback_requires_subscription',
|
|
35
|
+
}
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
// Mirrors apps/api/src/database/probe-scan.enum.ts EXACTLY (same string
|
|
2
|
-
// values — this SDK talks to that API over the wire, so the values must
|
|
3
|
-
// match byte-for-byte). Kept as a single file here too, on purpose: the
|
|
4
|
-
// server groups all three enums in one file for the same reason (they are
|
|
5
|
-
// one cohesive scan vocabulary), see that file's header comment.
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Antivirus scan verdict. `null` on the wire while the scan has not reached
|
|
9
|
-
* `DONE` yet (see {@link ProbeScanStatus}) — a scan that never completes
|
|
10
|
-
* (e.g. the engine throws) is left at its last real status with no
|
|
11
|
-
* fabricated verdict.
|
|
12
|
-
*/
|
|
13
|
-
export enum ProbeScanVerdict {
|
|
14
|
-
CLEAN = 'clean',
|
|
15
|
-
INFECTED = 'infected',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* How the scan was (or will be) run: `SYNC` blocks the request until the
|
|
20
|
-
* engine returns the verdict inline; `ASYNC` queues the job and delivers the
|
|
21
|
-
* verdict later
|
|
22
|
-
* `callbackUrl
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
// Mirrors apps/api/src/database/probe-scan.enum.ts EXACTLY (same string
|
|
2
|
+
// values — this SDK talks to that API over the wire, so the values must
|
|
3
|
+
// match byte-for-byte). Kept as a single file here too, on purpose: the
|
|
4
|
+
// server groups all three enums in one file for the same reason (they are
|
|
5
|
+
// one cohesive scan vocabulary), see that file's header comment.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Antivirus scan verdict. `null` on the wire while the scan has not reached
|
|
9
|
+
* `DONE` yet (see {@link ProbeScanStatus}) — a scan that never completes
|
|
10
|
+
* (e.g. the engine throws) is left at its last real status with no
|
|
11
|
+
* fabricated verdict.
|
|
12
|
+
*/
|
|
13
|
+
export enum ProbeScanVerdict {
|
|
14
|
+
CLEAN = 'clean',
|
|
15
|
+
INFECTED = 'infected',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* How the scan was (or will be) run: `SYNC` blocks the request until the
|
|
20
|
+
* engine returns the verdict inline; `ASYNC` queues the job and delivers the
|
|
21
|
+
* verdict later through the scope's delivery subscriptions (Flow) and/or the
|
|
22
|
+
* per-request `callbackUrl` (delivered once through such a subscription), and/or by
|
|
23
|
+
* polling `GET /scan/:scanId`.
|
|
24
|
+
*/
|
|
25
|
+
export enum ProbeScanMode {
|
|
26
|
+
SYNC = 'sync',
|
|
27
|
+
ASYNC = 'async',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Scan lifecycle. A SYNC scan skips `QUEUED` entirely (created directly at
|
|
32
|
+
* `SCANNING`). An ASYNC scan is created at `QUEUED`, flipped to `SCANNING`
|
|
33
|
+
* once a worker picks the job off the queue, then to `DONE` or `ERROR`.
|
|
34
|
+
*
|
|
35
|
+
* `ERROR` (async-only) is a TERMINAL, no-verdict state — there is no
|
|
36
|
+
* automatic requeue/retry (the uploaded bytes are deleted the moment the job
|
|
37
|
+
* ends, success or failure). A caller that wants to retry submits a brand
|
|
38
|
+
* new `POST /scan?mode=async`.
|
|
39
|
+
*/
|
|
40
|
+
export enum ProbeScanStatus {
|
|
41
|
+
QUEUED = 'queued',
|
|
42
|
+
SCANNING = 'scanning',
|
|
43
|
+
DONE = 'done',
|
|
44
|
+
ERROR = 'error',
|
|
45
|
+
}
|