@abyss-project/tools 2.1.0 → 2.3.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 (152) hide show
  1. package/dist/api/index.d.ts +6 -0
  2. package/dist/api/index.js +6 -0
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/api/probe-scan.api.d.ts +15 -0
  5. package/dist/api/probe-scan.api.js +74 -0
  6. package/dist/api/probe-scan.api.js.map +1 -0
  7. package/dist/api/probe-scan.api.test.d.ts +1 -0
  8. package/dist/api/probe-scan.api.test.js +37 -0
  9. package/dist/api/probe-scan.api.test.js.map +1 -0
  10. package/dist/api/probe-scan.application.api.d.ts +7 -0
  11. package/dist/api/probe-scan.application.api.js +40 -0
  12. package/dist/api/probe-scan.application.api.js.map +1 -0
  13. package/dist/api/probe-scan.application.api.test.d.ts +1 -0
  14. package/dist/api/probe-scan.application.api.test.js +37 -0
  15. package/dist/api/probe-scan.application.api.test.js.map +1 -0
  16. package/dist/api/probe-usage.api.d.ts +2 -0
  17. package/dist/api/probe-usage.api.js +24 -0
  18. package/dist/api/probe-usage.api.js.map +1 -0
  19. package/dist/api/probe-usage.application.api.d.ts +2 -0
  20. package/dist/api/probe-usage.application.api.js +12 -0
  21. package/dist/api/probe-usage.application.api.js.map +1 -0
  22. package/dist/api/probe-webhook.api.d.ts +6 -0
  23. package/dist/api/probe-webhook.api.js +41 -0
  24. package/dist/api/probe-webhook.api.js.map +1 -0
  25. package/dist/api/probe-webhook.api.test.d.ts +1 -0
  26. package/dist/api/probe-webhook.api.test.js +33 -0
  27. package/dist/api/probe-webhook.api.test.js.map +1 -0
  28. package/dist/api/probe-webhook.application.api.d.ts +6 -0
  29. package/dist/api/probe-webhook.application.api.js +27 -0
  30. package/dist/api/probe-webhook.application.api.js.map +1 -0
  31. package/dist/api/probe-webhook.application.api.test.d.ts +1 -0
  32. package/dist/api/probe-webhook.application.api.test.js +33 -0
  33. package/dist/api/probe-webhook.application.api.test.js.map +1 -0
  34. package/dist/index.d.ts +43 -0
  35. package/dist/index.js +44 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/types/enum/api-error.enum.d.ts +1 -5
  38. package/dist/types/enum/api-error.enum.js +0 -4
  39. package/dist/types/enum/api-error.enum.js.map +1 -1
  40. package/dist/types/enum/index.d.ts +1 -1
  41. package/dist/types/enum/index.js +1 -1
  42. package/dist/types/enum/index.js.map +1 -1
  43. package/dist/types/enum/probe-scan.enum.d.ts +14 -0
  44. package/dist/types/enum/probe-scan.enum.js +21 -0
  45. package/dist/types/enum/probe-scan.enum.js.map +1 -0
  46. package/dist/types/interface/api/requests/index.d.ts +3 -0
  47. package/dist/types/interface/api/requests/index.js +3 -0
  48. package/dist/types/interface/api/requests/index.js.map +1 -1
  49. package/dist/types/interface/api/requests/probe-scan.request.d.ts +22 -0
  50. package/dist/types/interface/api/{responses/file-scan.response.js → requests/probe-scan.request.js} +1 -1
  51. package/dist/types/interface/api/requests/probe-scan.request.js.map +1 -0
  52. package/dist/types/interface/api/requests/probe-usage.request.d.ts +3 -0
  53. package/dist/types/{enum/file-scan-status.enum.js → interface/api/requests/probe-usage.request.js} +1 -1
  54. package/dist/types/interface/api/requests/probe-usage.request.js.map +1 -0
  55. package/dist/types/interface/api/requests/probe-webhook.request.d.ts +14 -0
  56. package/dist/types/interface/api/requests/probe-webhook.request.js +3 -0
  57. package/dist/types/interface/api/requests/probe-webhook.request.js.map +1 -0
  58. package/dist/types/interface/api/responses/beam.response.d.ts +1 -3
  59. package/dist/types/interface/api/responses/index.d.ts +3 -0
  60. package/dist/types/interface/api/responses/index.js +3 -0
  61. package/dist/types/interface/api/responses/index.js.map +1 -1
  62. package/dist/types/interface/api/responses/probe-scan.response.d.ts +19 -0
  63. package/dist/types/interface/api/responses/probe-scan.response.js +3 -0
  64. package/dist/types/interface/api/responses/probe-scan.response.js.map +1 -0
  65. package/dist/types/interface/api/responses/probe-usage.response.d.ts +7 -0
  66. package/dist/types/interface/api/responses/probe-usage.response.js +3 -0
  67. package/dist/types/interface/api/responses/probe-usage.response.js.map +1 -0
  68. package/dist/types/interface/api/responses/probe-webhook.response.d.ts +13 -0
  69. package/dist/types/interface/api/responses/probe-webhook.response.js +3 -0
  70. package/dist/types/interface/api/responses/probe-webhook.response.js.map +1 -0
  71. package/dist/types/interface/models/atlas-document.dto.d.ts +0 -3
  72. package/dist/types/interface/models/beam.dto.d.ts +0 -3
  73. package/dist/types/interface/models/board-card-document.dto.d.ts +0 -3
  74. package/dist/types/interface/models/extraction.dto.d.ts +0 -2
  75. package/dist/types/interface/models/extraction.dto.js.map +1 -1
  76. package/dist/types/interface/models/index.d.ts +3 -0
  77. package/dist/types/interface/models/index.js +3 -0
  78. package/dist/types/interface/models/index.js.map +1 -1
  79. package/dist/types/interface/models/probe-scan.dto.d.ts +30 -0
  80. package/dist/types/interface/models/{file-scan.dto.js → probe-scan.dto.js} +1 -1
  81. package/dist/types/interface/models/probe-scan.dto.js.map +1 -0
  82. package/dist/types/interface/models/probe-webhook-delivery.dto.d.ts +19 -0
  83. package/dist/types/interface/models/probe-webhook-delivery.dto.js +3 -0
  84. package/dist/types/interface/models/probe-webhook-delivery.dto.js.map +1 -0
  85. package/dist/types/interface/models/probe-webhook.dto.d.ts +8 -0
  86. package/dist/types/interface/{api/requests/file-scan.request.js → models/probe-webhook.dto.js} +1 -1
  87. package/dist/types/interface/models/probe-webhook.dto.js.map +1 -0
  88. package/dist/types/tests/probe.dto.test.d.ts +1 -0
  89. package/dist/types/tests/probe.dto.test.js +101 -0
  90. package/dist/types/tests/probe.dto.test.js.map +1 -0
  91. package/dist/utils/index.d.ts +2 -0
  92. package/dist/utils/index.js +2 -0
  93. package/dist/utils/index.js.map +1 -1
  94. package/dist/utils/probe-scan-cost.utils.d.ts +5 -0
  95. package/dist/utils/probe-scan-cost.utils.js +21 -0
  96. package/dist/utils/probe-scan-cost.utils.js.map +1 -0
  97. package/dist/utils/probe-webhook-signature.utils.d.ts +8 -0
  98. package/dist/utils/probe-webhook-signature.utils.js +22 -0
  99. package/dist/utils/probe-webhook-signature.utils.js.map +1 -0
  100. package/package.json +1 -1
  101. package/src/api/index.ts +8 -0
  102. package/src/api/probe-scan.api.test.ts +21 -0
  103. package/src/api/probe-scan.api.ts +191 -0
  104. package/src/api/probe-scan.application.api.test.ts +21 -0
  105. package/src/api/probe-scan.application.api.ts +157 -0
  106. package/src/api/probe-usage.api.ts +47 -0
  107. package/src/api/probe-usage.application.api.ts +25 -0
  108. package/src/api/probe-webhook.api.test.ts +17 -0
  109. package/src/api/probe-webhook.api.ts +119 -0
  110. package/src/api/probe-webhook.application.api.test.ts +18 -0
  111. package/src/api/probe-webhook.application.api.ts +141 -0
  112. package/src/index.ts +114 -0
  113. package/src/types/enum/api-error.enum.ts +0 -25
  114. package/src/types/enum/index.ts +1 -1
  115. package/src/types/enum/probe-scan.enum.ts +44 -0
  116. package/src/types/interface/api/requests/index.ts +3 -0
  117. package/src/types/interface/api/requests/probe-scan.request.ts +50 -0
  118. package/src/types/interface/api/requests/probe-usage.request.ts +7 -0
  119. package/src/types/interface/api/requests/probe-webhook.request.ts +33 -0
  120. package/src/types/interface/api/responses/beam.response.ts +1 -15
  121. package/src/types/interface/api/responses/index.ts +3 -0
  122. package/src/types/interface/api/responses/probe-scan.response.ts +45 -0
  123. package/src/types/interface/api/responses/probe-usage.response.ts +25 -0
  124. package/src/types/interface/api/responses/probe-webhook.response.ts +24 -0
  125. package/src/types/interface/models/atlas-document.dto.ts +0 -18
  126. package/src/types/interface/models/beam.dto.ts +0 -22
  127. package/src/types/interface/models/board-card-document.dto.ts +0 -18
  128. package/src/types/interface/models/extraction.dto.ts +0 -17
  129. package/src/types/interface/models/index.ts +3 -0
  130. package/src/types/interface/models/probe-scan.dto.ts +67 -0
  131. package/src/types/interface/models/probe-webhook-delivery.dto.ts +73 -0
  132. package/src/types/interface/models/probe-webhook.dto.ts +39 -0
  133. package/src/types/tests/beam.dto.spec.ts +0 -2
  134. package/src/types/tests/probe.dto.test.ts +159 -0
  135. package/src/utils/index.ts +2 -0
  136. package/src/utils/probe-scan-cost.utils.ts +101 -0
  137. package/src/utils/probe-webhook-signature.utils.ts +56 -0
  138. package/dist/api/file-scan.api.d.ts +0 -5
  139. package/dist/api/file-scan.api.js +0 -49
  140. package/dist/api/file-scan.api.js.map +0 -1
  141. package/dist/types/enum/analysis-status.enum.d.ts +0 -7
  142. package/dist/types/enum/analysis-status.enum.js +0 -12
  143. package/dist/types/enum/analysis-status.enum.js.map +0 -1
  144. package/dist/types/enum/file-scan-status.enum.d.ts +0 -1
  145. package/dist/types/enum/file-scan-status.enum.js.map +0 -1
  146. package/dist/types/interface/api/requests/file-scan.request.d.ts +0 -3
  147. package/dist/types/interface/api/requests/file-scan.request.js.map +0 -1
  148. package/dist/types/interface/api/responses/file-scan.response.d.ts +0 -7
  149. package/dist/types/interface/api/responses/file-scan.response.js.map +0 -1
  150. package/dist/types/interface/models/file-scan.dto.d.ts +0 -11
  151. package/dist/types/interface/models/file-scan.dto.js.map +0 -1
  152. package/src/types/enum/file-scan-status.enum.ts +0 -23
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-webhook-delivery.dto.js","sourceRoot":"","sources":["../../../../src/types/interface/models/probe-webhook-delivery.dto.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export interface IProbeWebhook {
2
+ id: string;
3
+ callbackUrl: string;
4
+ secret: string;
5
+ active: boolean;
6
+ createdAt: Date;
7
+ }
8
+ export type IProbeWebhookCreated = IProbeWebhook;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=file-scan.request.js.map
3
+ //# sourceMappingURL=probe-webhook.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-webhook.dto.js","sourceRoot":"","sources":["../../../../src/types/interface/models/probe-webhook.dto.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const __1 = require("..");
4
+ const utils_1 = require("../../utils");
5
+ const _verdicts = { clean: true, infected: true };
6
+ const _modes = { sync: true, async: true };
7
+ const _statuses = {
8
+ queued: true,
9
+ scanning: true,
10
+ done: true,
11
+ error: true,
12
+ };
13
+ const _scanDetail = {
14
+ scanId: 's1',
15
+ status: __1.ProbeScanStatus.DONE,
16
+ verdict: __1.ProbeScanVerdict.CLEAN,
17
+ viruses: [],
18
+ context: null,
19
+ fileName: 'invoice.pdf',
20
+ fileSize: 1024,
21
+ mimeType: 'application/pdf',
22
+ mode: __1.ProbeScanMode.SYNC,
23
+ startedAt: new Date(),
24
+ finishedAt: new Date(),
25
+ costUnits: 3,
26
+ };
27
+ const _historyItem = {
28
+ scanId: 's1',
29
+ fileName: 'invoice.pdf',
30
+ fileSize: 1024,
31
+ mimeType: 'application/pdf',
32
+ verdict: __1.ProbeScanVerdict.INFECTED,
33
+ viruses: ['Eicar-Test-Signature'],
34
+ mode: __1.ProbeScanMode.ASYNC,
35
+ status: __1.ProbeScanStatus.DONE,
36
+ context: { applicationFileId: 'af1' },
37
+ startedAt: new Date(),
38
+ finishedAt: new Date(),
39
+ costUnits: 1,
40
+ createdAt: new Date(),
41
+ };
42
+ const _scanSyncData = {
43
+ scanId: 's1',
44
+ verdict: __1.ProbeScanVerdict.CLEAN,
45
+ viruses: [],
46
+ costUnits: 3,
47
+ };
48
+ const _scanAsyncData = { scanId: 's1', status: __1.ProbeScanStatus.QUEUED };
49
+ const _webhook = {
50
+ id: 'w1',
51
+ callbackUrl: 'https://example.com/hook',
52
+ secret: 'shh',
53
+ active: true,
54
+ createdAt: new Date(),
55
+ };
56
+ const _webhookCreated = _webhook;
57
+ const _updateBody = { active: false };
58
+ const _updateBody2 = { callbackUrl: 'https://example.com/hook2' };
59
+ const _deliveryPayload = {
60
+ scanId: 's1',
61
+ context: null,
62
+ verdict: __1.ProbeScanVerdict.INFECTED,
63
+ viruses: ['Eicar-Test-Signature'],
64
+ costUnits: 5,
65
+ };
66
+ const _deliveryRecord = {
67
+ id: 'd1',
68
+ webhookId: 'w1',
69
+ scanId: 's1',
70
+ url: 'https://example.com/hook',
71
+ statusCode: 200,
72
+ success: true,
73
+ attemptedAt: new Date(),
74
+ error: null,
75
+ createdAt: new Date(),
76
+ };
77
+ const _deliveryRecordAdHoc = { ..._deliveryRecord, webhookId: null };
78
+ const _usage = { used: 10, limit: 1000, remaining: 990 };
79
+ const _usageUnlimited = { used: 10, limit: -1, remaining: -1 };
80
+ const _asyncCost = (0, utils_1.estimateProbeScanCost)(5 * 1024 * 1024, __1.ProbeScanMode.ASYNC);
81
+ const _syncCost = (0, utils_1.estimateProbeScanCost)(5 * 1024 * 1024, __1.ProbeScanMode.SYNC);
82
+ if (_asyncCost >= _syncCost) {
83
+ throw new Error('estimateProbeScanCost: ASYNC must cost strictly less than SYNC');
84
+ }
85
+ void _verdicts;
86
+ void _modes;
87
+ void _statuses;
88
+ void _scanDetail;
89
+ void _historyItem;
90
+ void _scanSyncData;
91
+ void _scanAsyncData;
92
+ void _webhook;
93
+ void _webhookCreated;
94
+ void _updateBody;
95
+ void _updateBody2;
96
+ void _deliveryPayload;
97
+ void _deliveryRecord;
98
+ void _deliveryRecordAdHoc;
99
+ void _usage;
100
+ void _usageUnlimited;
101
+ //# sourceMappingURL=probe.dto.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.dto.test.js","sourceRoot":"","sources":["../../../src/types/tests/probe.dto.test.ts"],"names":[],"mappings":"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"}
@@ -4,3 +4,5 @@ export * from './shape.utils';
4
4
  export * from './icons.utils';
5
5
  export * from './enum.utils';
6
6
  export * from './extraction-webhook.utils';
7
+ export * from './probe-webhook-signature.utils';
8
+ export * from './probe-scan-cost.utils';
@@ -20,4 +20,6 @@ __exportStar(require("./shape.utils"), exports);
20
20
  __exportStar(require("./icons.utils"), exports);
21
21
  __exportStar(require("./enum.utils"), exports);
22
22
  __exportStar(require("./extraction-webhook.utils"), exports);
23
+ __exportStar(require("./probe-webhook-signature.utils"), exports);
24
+ __exportStar(require("./probe-scan-cost.utils"), exports);
23
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,6DAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,6DAA2C;AAC3C,kEAAgD;AAChD,0DAAwC"}
@@ -0,0 +1,5 @@
1
+ import { ProbeScanMode } from '../types';
2
+ export declare const PROBE_SCAN_COST_BASE = 1;
3
+ export declare const PROBE_SCAN_COST_K_MB = 1;
4
+ export declare const PROBE_SCAN_COST_MODE_WEIGHT: Record<ProbeScanMode, number>;
5
+ export declare const estimateProbeScanCost: (sizeOctet: number, mode: ProbeScanMode | 'sync' | 'async') => number;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.estimateProbeScanCost = exports.PROBE_SCAN_COST_MODE_WEIGHT = exports.PROBE_SCAN_COST_K_MB = exports.PROBE_SCAN_COST_BASE = void 0;
4
+ const types_1 = require("../types");
5
+ exports.PROBE_SCAN_COST_BASE = 1;
6
+ exports.PROBE_SCAN_COST_K_MB = 1;
7
+ exports.PROBE_SCAN_COST_MODE_WEIGHT = {
8
+ [types_1.ProbeScanMode.ASYNC]: 1,
9
+ [types_1.ProbeScanMode.SYNC]: 3,
10
+ };
11
+ const ONE_MB = 1024 * 1024;
12
+ const estimateProbeScanCost = (sizeOctet, mode) => {
13
+ if (!Number.isFinite(sizeOctet) || sizeOctet <= 0) {
14
+ return 0;
15
+ }
16
+ const megabytes = Math.ceil(sizeOctet / ONE_MB);
17
+ const weight = exports.PROBE_SCAN_COST_MODE_WEIGHT[mode] ?? exports.PROBE_SCAN_COST_MODE_WEIGHT[types_1.ProbeScanMode.ASYNC];
18
+ return Math.round((exports.PROBE_SCAN_COST_BASE + exports.PROBE_SCAN_COST_K_MB * megabytes) * weight);
19
+ };
20
+ exports.estimateProbeScanCost = estimateProbeScanCost;
21
+ //# sourceMappingURL=probe-scan-cost.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-scan-cost.utils.js","sourceRoot":"","sources":["../../src/utils/probe-scan-cost.utils.ts"],"names":[],"mappings":";;;AAuCA,oCAAyC;AAG5B,QAAA,oBAAoB,GAAG,CAAC,CAAC;AAGzB,QAAA,oBAAoB,GAAG,CAAC,CAAC;AAUzB,QAAA,2BAA2B,GAAkC;IACxE,CAAC,qBAAa,CAAC,KAAK,CAAC,EAAE,CAAC;IACxB,CAAC,qBAAa,CAAC,IAAI,CAAC,EAAE,CAAC;CACxB,CAAC;AAGF,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AA4BpB,MAAM,qBAAqB,GAAG,CACnC,SAAiB,EACjB,IAAsC,EAC9B,EAAE;IACV,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAClD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;IAChD,MAAM,MAAM,GACV,mCAA2B,CAAC,IAAI,CAAC,IAAI,mCAA2B,CAAC,qBAAa,CAAC,KAAK,CAAC,CAAC;IACxF,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,4BAAoB,GAAG,4BAAoB,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC;AACxF,CAAC,CAAC;AAXW,QAAA,qBAAqB,yBAWhC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ export interface VerifyProbeWebhookSignatureInput {
4
+ rawBody: string | Buffer;
5
+ signatureHeader: string | undefined;
6
+ secret: string;
7
+ }
8
+ export declare function verifyProbeWebhookSignature(input: VerifyProbeWebhookSignatureInput): boolean;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyProbeWebhookSignature = void 0;
4
+ function verifyProbeWebhookSignature(input) {
5
+ if (!input.signatureHeader || !input.secret)
6
+ return false;
7
+ const crypto = require('crypto');
8
+ const computed = crypto
9
+ .createHmac('sha256', input.secret)
10
+ .update(input.rawBody)
11
+ .digest('hex');
12
+ if (input.signatureHeader.length !== computed.length)
13
+ return false;
14
+ try {
15
+ return crypto.timingSafeEqual(Buffer.from(input.signatureHeader, 'hex'), Buffer.from(computed, 'hex'));
16
+ }
17
+ catch {
18
+ return false;
19
+ }
20
+ }
21
+ exports.verifyProbeWebhookSignature = verifyProbeWebhookSignature;
22
+ //# sourceMappingURL=probe-webhook-signature.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-webhook-signature.utils.js","sourceRoot":"","sources":["../../src/utils/probe-webhook-signature.utils.ts"],"names":[],"mappings":";;;AAiCA,SAAgB,2BAA2B,CAAC,KAAuC;IACjF,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAG1D,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAW,MAAM;SAC5B,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC;SAClC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;SACrB,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjB,IAAI,KAAK,CAAC,eAAe,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAEnE,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,eAAe,CAC3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,EACzC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAC7B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QAGP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAtBD,kEAsBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/tools",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Core package to interact with Abyss-Project Tools",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api/index.ts CHANGED
@@ -54,3 +54,11 @@ export * from './extraction-plan-preset.api';
54
54
 
55
55
  // Monitor (liveness)
56
56
  export * from './monitor.api';
57
+
58
+ // Probe (antivirus scanning)
59
+ export * from './probe-scan.api';
60
+ export * from './probe-webhook.api';
61
+ export * from './probe-scan.application.api';
62
+ export * from './probe-webhook.application.api';
63
+ export * from './probe-usage.api';
64
+ export * from './probe-usage.application.api';
@@ -0,0 +1,21 @@
1
+ // Type-level compile test for the probe-scan api surface.
2
+ // No jest runner in this SDK package; compile guard only (mirrors this
3
+ // package's own extraction-plan-preset.api.test.ts).
4
+ // Run: npx tsc --noEmit (from packages/abyss_tools_core), or `npm run build`.
5
+
6
+ import * as api from './probe-scan.api';
7
+
8
+ // All five functions must be exported with these exact signatures.
9
+ const _scan: typeof api.scan = api.scan;
10
+ const _scanSync: typeof api.scanSync = api.scanSync;
11
+ const _scanAsync: typeof api.scanAsync = api.scanAsync;
12
+ const _getScan: typeof api.getScan = api.getScan;
13
+ const _listScans: typeof api.listScans = api.listScans;
14
+
15
+ void _scan;
16
+ void _scanSync;
17
+ void _scanAsync;
18
+ void _getScan;
19
+ void _listScans;
20
+
21
+ export {};
@@ -0,0 +1,191 @@
1
+ // ──────────────────────────────────────────────
2
+ // AbyssProbe scan API — POST /scan (sync + async), GET /scan/:scanId (poll),
3
+ // GET /scan (history/search). Mirrors
4
+ // apps/api/src/api/controllers/probe-scan.controller.ts EXACTLY (see that
5
+ // file for the full contract this client targets). AbyssProbe's controllers
6
+ // add no extra path segment (`@Controller({ prefixPath: '/scan' })`), so
7
+ // these calls hit `scan`/`scan/:id` directly — no `probe/` prefix.
8
+ //
9
+ // File-upload dual environment handling (browser `FormData`/`Blob` vs Node
10
+ // `Buffer`/stream + the `form-data` package) mirrors this package's own
11
+ // extraction.api.ts (`detect`/`postExtract`): AbyssProbe is meant to be
12
+ // called from the abyss-main UI (a browser) as well as from Node services
13
+ // (abyss-storage, external integrators). `form-data` is lazy-`require`d
14
+ // (never statically imported) so a browser bundle never tries to resolve
15
+ // the Node-only package.
16
+ //
17
+ // `authHeader`/`serializeProbeQuery` are kept LOCAL and unexported (not a
18
+ // shared utils file) — same convention as every other extract/*.api.ts file
19
+ // in this package (each redefines its own tiny per-call apiKey helper; see
20
+ // extraction.api.ts / extraction-settings.api.ts / extraction-plan-preset.api.ts).
21
+ //
22
+ // See probe-scan.application.api.ts for the application/API-key-auth
23
+ // counterpart of this client (`/application/:applicationId/scan...`, Phase
24
+ // 3a) — it reuses this file's `buildScanForm` and every request/response
25
+ // type verbatim; only the URL prefix, the extra `applicationId` argument,
26
+ // and the auth header differ.
27
+ // ──────────────────────────────────────────────
28
+
29
+ import { AbyssToolsCore } from '..';
30
+ import { ProbeScanMode } from '../types';
31
+ import type {
32
+ IScanOptions,
33
+ IListScansQuery,
34
+ IScanResponse,
35
+ IScanSyncResponse,
36
+ IScanAsyncResponse,
37
+ IGetScanResponse,
38
+ IPaginateScanResponse,
39
+ } from '../types';
40
+
41
+ const DEFAULT_API_KEY_HEADER = 'abyss-api-key';
42
+
43
+ function authHeader(apiKey?: string): Record<string, string> {
44
+ return apiKey ? { [DEFAULT_API_KEY_HEADER]: apiKey } : {};
45
+ }
46
+
47
+ /**
48
+ * Turn a request/query options object into axios `params`: drops
49
+ * undefined/null, ISO-stringifies `Date`s, and renames `organizationId` to
50
+ * the wire's `organization_id` (the one snake_case key AbyssProbe's own
51
+ * controllers actually expect — see probe-scope.helper.ts#readOrganizationId
52
+ * — every other field name is already camelCase on both sides).
53
+ */
54
+ function serializeProbeQuery<T extends object>(query: T): Record<string, unknown> {
55
+ const out: Record<string, unknown> = {};
56
+ for (const [key, value] of Object.entries(query as Record<string, unknown>)) {
57
+ if (value === undefined || value === null) continue;
58
+ const wireKey = key === 'organizationId' ? 'organization_id' : key;
59
+ out[wireKey] = value instanceof Date ? value.toISOString() : value;
60
+ }
61
+ return out;
62
+ }
63
+
64
+ /** Anything `sdk.probe.scan` accepts as the file to submit. */
65
+ export type ProbeScanFileInput = Buffer | Uint8Array | NodeJS.ReadableStream | Blob;
66
+
67
+ function isBrowserEnv(): boolean {
68
+ return typeof window !== 'undefined' && typeof FormData !== 'undefined';
69
+ }
70
+
71
+ async function loadNodeFormData(): Promise<any> {
72
+ // Indirect eval so bundlers (esbuild/vite/webpack) do not try to resolve
73
+ // the Node-only "form-data" package when this file is included in a
74
+ // browser bundle. The require only ever runs at runtime on Node.
75
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
76
+ const nodeRequire: NodeRequire = new Function('return require')();
77
+ return nodeRequire('form-data');
78
+ }
79
+
80
+ export interface BuiltScanForm {
81
+ form: unknown;
82
+ headers: Record<string, string>;
83
+ }
84
+
85
+ /**
86
+ * Exported (not just this file's own `scan` internals) so
87
+ * probe-scan.application.api.ts reuses this EXACT multipart-building logic
88
+ * (browser `FormData`/`Blob` vs Node `Buffer`/stream + lazy-required
89
+ * `form-data`) rather than duplicating it — the file-upload contract is
90
+ * identical for a personal/org caller and an application caller; only the
91
+ * URL/auth differ (see that file's header comment).
92
+ */
93
+ export async function buildScanForm(
94
+ file: ProbeScanFileInput,
95
+ options: IScanOptions,
96
+ ): Promise<BuiltScanForm> {
97
+ const filename = options.filename ?? 'file';
98
+
99
+ if (isBrowserEnv()) {
100
+ const form = new FormData();
101
+ const blob =
102
+ file instanceof Blob ? file : new Blob([file as BlobPart], { type: options.mimeType });
103
+ form.append('file', blob, filename);
104
+ if (options.context) form.append('context', JSON.stringify(options.context));
105
+ if (options.callbackUrl) form.append('callbackUrl', options.callbackUrl);
106
+ return { form, headers: {} };
107
+ }
108
+
109
+ const FormDataCtor = await loadNodeFormData();
110
+ const form = new FormDataCtor();
111
+ const filePart =
112
+ Buffer.isBuffer(file) || file instanceof Uint8Array ? Buffer.from(file as Uint8Array) : file;
113
+ form.append('file', filePart, { filename, contentType: options.mimeType });
114
+ if (options.context) form.append('context', JSON.stringify(options.context));
115
+ if (options.callbackUrl) form.append('callbackUrl', options.callbackUrl);
116
+ const headers = typeof form.getHeaders === 'function' ? form.getHeaders() : {};
117
+ return { form, headers };
118
+ }
119
+
120
+ /**
121
+ * `POST /scan` — SYNC by default, ASYNC when `options.mode = ProbeScanMode.ASYNC`
122
+ * (same endpoint, query-param-selected — see the controller's doc comment).
123
+ * `mode` and `organizationId` travel as query params; `context`
124
+ * (JSON-encoded) and `callbackUrl` travel as multipart text fields alongside
125
+ * the file.
126
+ *
127
+ * Returns the SYNC (200, verdict inline) or ASYNC (202, `{ scanId, status:
128
+ * 'queued' }`) shape depending on `options.mode` — see {@link IScanResponse}.
129
+ * Prefer {@link scanSync} / {@link scanAsync} for a precisely-typed return
130
+ * instead of the union.
131
+ */
132
+ export const scan = async (
133
+ file: ProbeScanFileInput,
134
+ options: IScanOptions = {},
135
+ apiKey?: string,
136
+ ): Promise<IScanResponse> => {
137
+ const { form, headers } = await buildScanForm(file, options);
138
+ return (
139
+ await AbyssToolsCore.axios.post<IScanResponse>('scan', form, {
140
+ params: serializeProbeQuery({ mode: options.mode, organizationId: options.organizationId }),
141
+ headers: { ...headers, ...authHeader(apiKey) },
142
+ maxBodyLength: Infinity,
143
+ maxContentLength: Infinity,
144
+ })
145
+ ).data;
146
+ };
147
+
148
+ /** {@link scan}, forced to `mode: sync` — HTTP 200, verdict returned inline. */
149
+ export const scanSync = async (
150
+ file: ProbeScanFileInput,
151
+ options: Omit<IScanOptions, 'mode' | 'callbackUrl'> = {},
152
+ apiKey?: string,
153
+ ): Promise<IScanSyncResponse> =>
154
+ scan(file, { ...options, mode: ProbeScanMode.SYNC }, apiKey) as Promise<IScanSyncResponse>;
155
+
156
+ /** {@link scan}, forced to `mode: async` — HTTP 202, job queued. */
157
+ export const scanAsync = async (
158
+ file: ProbeScanFileInput,
159
+ options: Omit<IScanOptions, 'mode'> = {},
160
+ apiKey?: string,
161
+ ): Promise<IScanAsyncResponse> =>
162
+ scan(file, { ...options, mode: ProbeScanMode.ASYNC }, apiKey) as Promise<IScanAsyncResponse>;
163
+
164
+ /**
165
+ * `GET /scan/:scanId` — poll the queued -> scanning -> done/error
166
+ * progression of an ASYNC scan (also answers for a SYNC scan's row). Cross-
167
+ * tenant guarded server-side (404, never 403) — needs no scope query param,
168
+ * the scanId alone determines it.
169
+ */
170
+ export const getScan = async (scanId: string, apiKey?: string): Promise<IGetScanResponse> =>
171
+ (
172
+ await AbyssToolsCore.axios.get<IGetScanResponse>(`scan/${scanId}`, {
173
+ headers: authHeader(apiKey),
174
+ })
175
+ ).data;
176
+
177
+ /**
178
+ * `GET /scan` — paginated scan history/search for the caller's scope
179
+ * (personal by default, `organizationId` for an organization scope), newest
180
+ * first. See {@link IListScansQuery} for the available filters.
181
+ */
182
+ export const listScans = async (
183
+ query: IListScansQuery = {},
184
+ apiKey?: string,
185
+ ): Promise<IPaginateScanResponse> =>
186
+ (
187
+ await AbyssToolsCore.axios.get<IPaginateScanResponse>('scan', {
188
+ params: serializeProbeQuery(query),
189
+ headers: authHeader(apiKey),
190
+ })
191
+ ).data;
@@ -0,0 +1,21 @@
1
+ // Type-level compile test for the probe-scan APPLICATION api surface.
2
+ // No jest runner in this SDK package; compile guard only (mirrors
3
+ // probe-scan.api.test.ts).
4
+ // Run: npx tsc --noEmit (from packages/abyss_tools_core), or `npm run build`.
5
+
6
+ import * as api from './probe-scan.application.api';
7
+
8
+ // All five functions must be exported with these exact signatures.
9
+ const _scan: typeof api.scanApplication = api.scanApplication;
10
+ const _scanSync: typeof api.scanSyncApplication = api.scanSyncApplication;
11
+ const _scanAsync: typeof api.scanAsyncApplication = api.scanAsyncApplication;
12
+ const _getScan: typeof api.getScanApplication = api.getScanApplication;
13
+ const _listScans: typeof api.listScansApplication = api.listScansApplication;
14
+
15
+ void _scan;
16
+ void _scanSync;
17
+ void _scanAsync;
18
+ void _getScan;
19
+ void _listScans;
20
+
21
+ export {};
@@ -0,0 +1,157 @@
1
+ // ──────────────────────────────────────────────
2
+ // AbyssProbe APPLICATION scan API — POST /application/:applicationId/scan
3
+ // (sync + async), GET /application/:applicationId/scan/:scanId (poll),
4
+ // GET /application/:applicationId/scan (history/search). Mirrors
5
+ // apps/api/src/api/controllers/probe-scan-application.controller.ts EXACTLY
6
+ // (see that file for the full contract this client targets) — the
7
+ // application counterpart of probe-scan.api.ts, for inter-service callers
8
+ // (abyss-storage, external integrations) authenticating with a project API
9
+ // key instead of a personal/org session.
10
+ //
11
+ // Reuses probe-scan.api.ts's `buildScanForm` (same dual-environment
12
+ // multipart handling — browser `FormData`/`Blob` vs Node `Buffer`/stream +
13
+ // lazy-required `form-data`) and every request/response TYPE verbatim
14
+ // (`IScanOptions`, `IListScansQuery`, `IScanResponse`, `IScanSyncResponse`,
15
+ // `IScanAsyncResponse`, `IGetScanResponse`, `IPaginateScanResponse`) — never
16
+ // redefined here. `organizationId` is `Omit`'d from every option/query type
17
+ // below: unlike the personal/org route's `?organization_id=` override, an
18
+ // application caller's scope is entirely its `:applicationId` URL segment,
19
+ // resolved server-side by ProbeApplicationMiddleware (round-trips to
20
+ // abyss-main) — there is no scope query param to send.
21
+ //
22
+ // `authHeaderApplication` is kept LOCAL and unexported, same convention as
23
+ // the personal/org client's own `authHeader` (see probe-scan.api.ts's header
24
+ // comment) — it sends `API_KEY_APPLICATION_HEADER` (`abyss-api-key-
25
+ // application`, imported from this package's root) instead of the personal
26
+ // `abyss-api-key` header.
27
+ // ──────────────────────────────────────────────
28
+
29
+ import { AbyssToolsCore, API_KEY_APPLICATION_HEADER } from '..';
30
+ import { ProbeScanMode } from '../types';
31
+ import type {
32
+ IScanOptions,
33
+ IListScansQuery,
34
+ IScanResponse,
35
+ IScanSyncResponse,
36
+ IScanAsyncResponse,
37
+ IGetScanResponse,
38
+ IPaginateScanResponse,
39
+ } from '../types';
40
+ import { buildScanForm } from './probe-scan.api';
41
+ import type { ProbeScanFileInput } from './probe-scan.api';
42
+
43
+ function authHeaderApplication(applicationApiKey?: string): Record<string, string> {
44
+ return applicationApiKey ? { [API_KEY_APPLICATION_HEADER]: applicationApiKey } : {};
45
+ }
46
+
47
+ /**
48
+ * Turn a request/query options object into axios `params`: drops
49
+ * undefined/null and ISO-stringifies `Date`s. No key-renaming here (unlike
50
+ * probe-scan.api.ts#serializeProbeQuery's `organizationId` -> `organization_id`
51
+ * rename) — an application call never carries `organizationId` (`Omit`'d
52
+ * from every option/query type in this file), so there is nothing to rename.
53
+ */
54
+ function serializeProbeQuery<T extends object>(query: T): Record<string, unknown> {
55
+ const out: Record<string, unknown> = {};
56
+ for (const [key, value] of Object.entries(query as Record<string, unknown>)) {
57
+ if (value === undefined || value === null) continue;
58
+ out[key] = value instanceof Date ? value.toISOString() : value;
59
+ }
60
+ return out;
61
+ }
62
+
63
+ /**
64
+ * `POST /application/:applicationId/scan` — SYNC by default, ASYNC when
65
+ * `options.mode = ProbeScanMode.ASYNC` (identical contract to {@link
66
+ * ../probe-scan.api.scan | the personal/org `scan`} — see that function's
67
+ * doc comment for the full sequence). `mode` travels as a query param;
68
+ * `context` (JSON-encoded) and `callbackUrl` travel as multipart text fields
69
+ * alongside the file.
70
+ *
71
+ * Returns the SYNC (200, verdict inline) or ASYNC (202, `{ scanId, status:
72
+ * 'queued' }`) shape depending on `options.mode` — see {@link IScanResponse}.
73
+ * Prefer {@link scanSyncApplication} / {@link scanAsyncApplication} for a
74
+ * precisely-typed return instead of the union.
75
+ */
76
+ export const scanApplication = async (
77
+ applicationId: string,
78
+ file: ProbeScanFileInput,
79
+ options: Omit<IScanOptions, 'organizationId'> = {},
80
+ applicationApiKey?: string,
81
+ ): Promise<IScanResponse> => {
82
+ const { form, headers } = await buildScanForm(file, options);
83
+ return (
84
+ await AbyssToolsCore.axios.post<IScanResponse>(`application/${applicationId}/scan`, form, {
85
+ params: serializeProbeQuery({ mode: options.mode }),
86
+ headers: { ...headers, ...authHeaderApplication(applicationApiKey) },
87
+ maxBodyLength: Infinity,
88
+ maxContentLength: Infinity,
89
+ })
90
+ ).data;
91
+ };
92
+
93
+ /** {@link scanApplication}, forced to `mode: sync` — HTTP 200, verdict returned inline. */
94
+ export const scanSyncApplication = async (
95
+ applicationId: string,
96
+ file: ProbeScanFileInput,
97
+ options: Omit<IScanOptions, 'organizationId' | 'mode' | 'callbackUrl'> = {},
98
+ applicationApiKey?: string,
99
+ ): Promise<IScanSyncResponse> =>
100
+ scanApplication(
101
+ applicationId,
102
+ file,
103
+ { ...options, mode: ProbeScanMode.SYNC },
104
+ applicationApiKey,
105
+ ) as Promise<IScanSyncResponse>;
106
+
107
+ /** {@link scanApplication}, forced to `mode: async` — HTTP 202, job queued. */
108
+ export const scanAsyncApplication = async (
109
+ applicationId: string,
110
+ file: ProbeScanFileInput,
111
+ options: Omit<IScanOptions, 'organizationId' | 'mode'> = {},
112
+ applicationApiKey?: string,
113
+ ): Promise<IScanAsyncResponse> =>
114
+ scanApplication(
115
+ applicationId,
116
+ file,
117
+ { ...options, mode: ProbeScanMode.ASYNC },
118
+ applicationApiKey,
119
+ ) as Promise<IScanAsyncResponse>;
120
+
121
+ /**
122
+ * `GET /application/:applicationId/scan/:scanId` — poll the queued ->
123
+ * scanning -> done/error progression of an ASYNC scan (also answers for a
124
+ * SYNC scan's row). Cross-tenant guarded server-side by a direct
125
+ * `applicationId` column comparison (404, never 403) — needs no scope
126
+ * argument beyond `applicationId` itself, the scanId alone determines the
127
+ * rest.
128
+ */
129
+ export const getScanApplication = async (
130
+ applicationId: string,
131
+ scanId: string,
132
+ applicationApiKey?: string,
133
+ ): Promise<IGetScanResponse> =>
134
+ (
135
+ await AbyssToolsCore.axios.get<IGetScanResponse>(
136
+ `application/${applicationId}/scan/${scanId}`,
137
+ { headers: authHeaderApplication(applicationApiKey) },
138
+ )
139
+ ).data;
140
+
141
+ /**
142
+ * `GET /application/:applicationId/scan` — paginated scan history/search for
143
+ * the calling application, newest first. Same filters as the personal/org
144
+ * `GET /scan` minus `organizationId` (see {@link IListScansQuery}) — the
145
+ * `:applicationId` URL segment is already the entire scope.
146
+ */
147
+ export const listScansApplication = async (
148
+ applicationId: string,
149
+ query: Omit<IListScansQuery, 'organizationId'> = {},
150
+ applicationApiKey?: string,
151
+ ): Promise<IPaginateScanResponse> =>
152
+ (
153
+ await AbyssToolsCore.axios.get<IPaginateScanResponse>(`application/${applicationId}/scan`, {
154
+ params: serializeProbeQuery(query),
155
+ headers: authHeaderApplication(applicationApiKey),
156
+ })
157
+ ).data;