@censys/platform-sdk 0.4.3 → 0.5.1

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 (177) hide show
  1. package/FUNCTIONS.md +0 -1
  2. package/README.md +17 -2
  3. package/docs/sdks/collections/README.md +12 -6
  4. package/docs/sdks/globaldata/README.md +260 -6
  5. package/docs/sdks/threathunting/README.md +335 -0
  6. package/examples/globalDataSearch.example.ts +0 -1
  7. package/examples/package-lock.json +5 -6
  8. package/funcs/globalDataCreateTrackedScan.d.ts +18 -0
  9. package/funcs/globalDataCreateTrackedScan.d.ts.map +1 -0
  10. package/funcs/globalDataCreateTrackedScan.js +132 -0
  11. package/funcs/globalDataCreateTrackedScan.js.map +1 -0
  12. package/funcs/globalDataGetTrackedScan.d.ts +19 -0
  13. package/funcs/globalDataGetTrackedScan.d.ts.map +1 -0
  14. package/funcs/globalDataGetTrackedScan.js +137 -0
  15. package/funcs/globalDataGetTrackedScan.js.map +1 -0
  16. package/funcs/globalDataGetTrackedScanThreatHunting.d.ts +19 -0
  17. package/funcs/globalDataGetTrackedScanThreatHunting.d.ts.map +1 -0
  18. package/funcs/globalDataGetTrackedScanThreatHunting.js +137 -0
  19. package/funcs/globalDataGetTrackedScanThreatHunting.js.map +1 -0
  20. package/funcs/threatHuntingCreateTrackedScan.d.ts +18 -0
  21. package/funcs/threatHuntingCreateTrackedScan.d.ts.map +1 -0
  22. package/funcs/threatHuntingCreateTrackedScan.js +129 -0
  23. package/funcs/threatHuntingCreateTrackedScan.js.map +1 -0
  24. package/funcs/threatHuntingGetHostObservationsWithCertificate.d.ts +18 -0
  25. package/funcs/threatHuntingGetHostObservationsWithCertificate.d.ts.map +1 -0
  26. package/funcs/threatHuntingGetHostObservationsWithCertificate.js +141 -0
  27. package/funcs/threatHuntingGetHostObservationsWithCertificate.js.map +1 -0
  28. package/jsr.json +1 -1
  29. package/lib/config.d.ts +4 -4
  30. package/lib/config.js +4 -4
  31. package/models/components/elasticsearch.d.ts +3 -0
  32. package/models/components/elasticsearch.d.ts.map +1 -1
  33. package/models/components/elasticsearch.js +5 -0
  34. package/models/components/elasticsearch.js.map +1 -1
  35. package/models/components/elasticsearcherrormessage.d.ts +33 -0
  36. package/models/components/elasticsearcherrormessage.d.ts.map +1 -0
  37. package/models/components/elasticsearcherrormessage.js +73 -0
  38. package/models/components/elasticsearcherrormessage.js.map +1 -0
  39. package/models/components/hostobservationrange.d.ts +39 -0
  40. package/models/components/hostobservationrange.d.ts.map +1 -0
  41. package/models/components/hostobservationrange.js +92 -0
  42. package/models/components/hostobservationrange.js.map +1 -0
  43. package/models/components/hostobservationresponse.d.ts +34 -0
  44. package/models/components/hostobservationresponse.d.ts.map +1 -0
  45. package/models/components/hostobservationresponse.js +85 -0
  46. package/models/components/hostobservationresponse.js.map +1 -0
  47. package/models/components/httpfavicon.d.ts +5 -0
  48. package/models/components/httpfavicon.d.ts.map +1 -1
  49. package/models/components/httpfavicon.js +4 -0
  50. package/models/components/httpfavicon.js.map +1 -1
  51. package/models/components/index.d.ts +14 -0
  52. package/models/components/index.d.ts.map +1 -1
  53. package/models/components/index.js +14 -0
  54. package/models/components/index.js.map +1 -1
  55. package/models/components/responseenvelopehostobservationresponse.d.ts +30 -0
  56. package/models/components/responseenvelopehostobservationresponse.d.ts.map +1 -0
  57. package/models/components/responseenvelopehostobservationresponse.js +70 -0
  58. package/models/components/responseenvelopehostobservationresponse.js.map +1 -0
  59. package/models/components/responseenvelopetrackedscan.d.ts +30 -0
  60. package/models/components/responseenvelopetrackedscan.d.ts.map +1 -0
  61. package/models/components/responseenvelopetrackedscan.js +70 -0
  62. package/models/components/responseenvelopetrackedscan.js.map +1 -0
  63. package/models/components/scansdiscoveryinputbody.d.ts +172 -0
  64. package/models/components/scansdiscoveryinputbody.d.ts.map +1 -0
  65. package/models/components/scansdiscoveryinputbody.js +233 -0
  66. package/models/components/scansdiscoveryinputbody.js.map +1 -0
  67. package/models/components/scansrescaninputbody.d.ts +214 -0
  68. package/models/components/scansrescaninputbody.d.ts.map +1 -0
  69. package/models/components/scansrescaninputbody.js +268 -0
  70. package/models/components/scansrescaninputbody.js.map +1 -0
  71. package/models/components/screenshot.d.ts +2 -0
  72. package/models/components/screenshot.d.ts.map +1 -1
  73. package/models/components/screenshot.js +11 -0
  74. package/models/components/screenshot.js.map +1 -1
  75. package/models/components/searchaggregateinputbody.d.ts +5 -0
  76. package/models/components/searchaggregateinputbody.d.ts.map +1 -1
  77. package/models/components/searchaggregateinputbody.js +4 -0
  78. package/models/components/searchaggregateinputbody.js.map +1 -1
  79. package/models/components/searchvaluecountsinputbody.d.ts +5 -0
  80. package/models/components/searchvaluecountsinputbody.d.ts.map +1 -1
  81. package/models/components/searchvaluecountsinputbody.js +2 -0
  82. package/models/components/searchvaluecountsinputbody.js.map +1 -1
  83. package/models/components/serviceid.d.ts +70 -0
  84. package/models/components/serviceid.d.ts.map +1 -0
  85. package/models/components/serviceid.js +106 -0
  86. package/models/components/serviceid.js.map +1 -0
  87. package/models/components/trackedscan.d.ts +39 -0
  88. package/models/components/trackedscan.d.ts.map +1 -0
  89. package/models/components/trackedscan.js +90 -0
  90. package/models/components/trackedscan.js.map +1 -0
  91. package/models/components/trackedscanscantarget.d.ts +39 -0
  92. package/models/components/trackedscanscantarget.d.ts.map +1 -0
  93. package/models/components/trackedscanscantarget.js +94 -0
  94. package/models/components/trackedscanscantarget.js.map +1 -0
  95. package/models/components/trackedscanscantargethostnameport.d.ts +31 -0
  96. package/models/components/trackedscanscantargethostnameport.d.ts.map +1 -0
  97. package/models/components/trackedscanscantargethostnameport.js +71 -0
  98. package/models/components/trackedscanscantargethostnameport.js.map +1 -0
  99. package/models/components/trackedscanscantargethostport.d.ts +31 -0
  100. package/models/components/trackedscanscantargethostport.d.ts.map +1 -0
  101. package/models/components/trackedscanscantargethostport.js +71 -0
  102. package/models/components/trackedscanscantargethostport.js.map +1 -0
  103. package/models/components/trackedscantask.d.ts +74 -0
  104. package/models/components/trackedscantask.d.ts.map +1 -0
  105. package/models/components/trackedscantask.js +106 -0
  106. package/models/components/trackedscantask.js.map +1 -0
  107. package/models/components/weborigin.d.ts +31 -0
  108. package/models/components/weborigin.d.ts.map +1 -0
  109. package/models/components/weborigin.js +71 -0
  110. package/models/components/weborigin.js.map +1 -0
  111. package/models/operations/index.d.ts +5 -0
  112. package/models/operations/index.d.ts.map +1 -1
  113. package/models/operations/index.js +5 -0
  114. package/models/operations/index.js.map +1 -1
  115. package/models/operations/v3globaldatascansget.d.ts +94 -0
  116. package/models/operations/v3globaldatascansget.d.ts.map +1 -0
  117. package/models/operations/v3globaldatascansget.js +157 -0
  118. package/models/operations/v3globaldatascansget.js.map +1 -0
  119. package/models/operations/v3globaldatascansrescan.d.ts +91 -0
  120. package/models/operations/v3globaldatascansrescan.d.ts.map +1 -0
  121. package/models/operations/v3globaldatascansrescan.js +157 -0
  122. package/models/operations/v3globaldatascansrescan.js.map +1 -0
  123. package/models/operations/v3threathuntinggethostobservationswithcertificate.d.ts +124 -0
  124. package/models/operations/v3threathuntinggethostobservationswithcertificate.d.ts.map +1 -0
  125. package/models/operations/v3threathuntinggethostobservationswithcertificate.js +183 -0
  126. package/models/operations/v3threathuntinggethostobservationswithcertificate.js.map +1 -0
  127. package/models/operations/v3threathuntingscansdiscovery.d.ts +91 -0
  128. package/models/operations/v3threathuntingscansdiscovery.d.ts.map +1 -0
  129. package/models/operations/v3threathuntingscansdiscovery.js +157 -0
  130. package/models/operations/v3threathuntingscansdiscovery.js.map +1 -0
  131. package/models/operations/v3threathuntingscansget.d.ts +94 -0
  132. package/models/operations/v3threathuntingscansget.d.ts.map +1 -0
  133. package/models/operations/v3threathuntingscansget.js +157 -0
  134. package/models/operations/v3threathuntingscansget.js.map +1 -0
  135. package/package.json +4 -5
  136. package/sdk/globaldata.d.ts +23 -0
  137. package/sdk/globaldata.d.ts.map +1 -1
  138. package/sdk/globaldata.js +32 -0
  139. package/sdk/globaldata.js.map +1 -1
  140. package/sdk/threathunting.d.ts +30 -0
  141. package/sdk/threathunting.d.ts.map +1 -1
  142. package/sdk/threathunting.js +42 -0
  143. package/sdk/threathunting.js.map +1 -1
  144. package/src/funcs/globalDataCreateTrackedScan.ts +185 -0
  145. package/src/funcs/globalDataGetTrackedScan.ts +191 -0
  146. package/src/funcs/globalDataGetTrackedScanThreatHunting.ts +191 -0
  147. package/src/funcs/threatHuntingCreateTrackedScan.ts +188 -0
  148. package/src/funcs/threatHuntingGetHostObservationsWithCertificate.ts +201 -0
  149. package/src/lib/config.ts +4 -4
  150. package/src/models/components/elasticsearch.ts +12 -0
  151. package/src/models/components/elasticsearcherrormessage.ts +74 -0
  152. package/src/models/components/hostobservationrange.ts +99 -0
  153. package/src/models/components/hostobservationresponse.ts +91 -0
  154. package/src/models/components/httpfavicon.ts +9 -0
  155. package/src/models/components/index.ts +14 -0
  156. package/src/models/components/responseenvelopehostobservationresponse.ts +83 -0
  157. package/src/models/components/responseenvelopetrackedscan.ts +74 -0
  158. package/src/models/components/scansdiscoveryinputbody.ts +385 -0
  159. package/src/models/components/scansrescaninputbody.ts +428 -0
  160. package/src/models/components/screenshot.ts +13 -0
  161. package/src/models/components/searchaggregateinputbody.ts +9 -0
  162. package/src/models/components/searchvaluecountsinputbody.ts +7 -0
  163. package/src/models/components/serviceid.ts +116 -0
  164. package/src/models/components/trackedscan.ts +101 -0
  165. package/src/models/components/trackedscanscantarget.ts +117 -0
  166. package/src/models/components/trackedscanscantargethostnameport.ts +73 -0
  167. package/src/models/components/trackedscanscantargethostport.ts +72 -0
  168. package/src/models/components/trackedscantask.ts +114 -0
  169. package/src/models/components/weborigin.ts +66 -0
  170. package/src/models/operations/index.ts +5 -0
  171. package/src/models/operations/v3globaldatascansget.ts +232 -0
  172. package/src/models/operations/v3globaldatascansrescan.ts +229 -0
  173. package/src/models/operations/v3threathuntinggethostobservationswithcertificate.ts +315 -0
  174. package/src/models/operations/v3threathuntingscansdiscovery.ts +238 -0
  175. package/src/models/operations/v3threathuntingscansget.ts +232 -0
  176. package/src/sdk/globaldata.ts +56 -0
  177. package/src/sdk/threathunting.ts +77 -0
@@ -4,10 +4,52 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ThreatHunting = void 0;
7
+ const globalDataGetTrackedScan_js_1 = require("../funcs/globalDataGetTrackedScan.js");
8
+ const globalDataGetTrackedScanThreatHunting_js_1 = require("../funcs/globalDataGetTrackedScanThreatHunting.js");
9
+ const threatHuntingCreateTrackedScan_js_1 = require("../funcs/threatHuntingCreateTrackedScan.js");
10
+ const threatHuntingGetHostObservationsWithCertificate_js_1 = require("../funcs/threatHuntingGetHostObservationsWithCertificate.js");
7
11
  const threatHuntingValueCounts_js_1 = require("../funcs/threatHuntingValueCounts.js");
8
12
  const sdks_js_1 = require("../lib/sdks.js");
9
13
  const fp_js_1 = require("../types/fp.js");
10
14
  class ThreatHunting extends sdks_js_1.ClientSDK {
15
+ /**
16
+ * Get tracked scan details
17
+ *
18
+ * @remarks
19
+ * Retrieve the current status and results of a tracked scan by its ID.
20
+ * This endpoint works for both discovery scans and rescans.
21
+ */
22
+ async getTrackedScan(request, options) {
23
+ return (0, fp_js_1.unwrapAsync)((0, globalDataGetTrackedScan_js_1.globalDataGetTrackedScan)(this, request, options));
24
+ }
25
+ /**
26
+ * Get Host Observations With Certificate
27
+ *
28
+ * @remarks
29
+ * Retrieve historical observations of hosts associated with a certificate fingerprint. Useful for threat hunting, detection engineering, and timeline generation.
30
+ */
31
+ async getHostObservationsWithCertificate(request, options) {
32
+ return (0, fp_js_1.unwrapAsync)((0, threatHuntingGetHostObservationsWithCertificate_js_1.threatHuntingGetHostObservationsWithCertificate)(this, request, options));
33
+ }
34
+ /**
35
+ * Create a tracked discovery scan
36
+ *
37
+ * @remarks
38
+ * Create a new tracked discovery scan for a specified target. Discovery scans are used to scan new targets that have not been previously identified. The scan will be queued. The response will contain a scan ID that you can use with the [get tracked scan details endpoint](https://docs.censys.com/reference/v3-globaldata-scans-get#/) to monitor its status and results.<br><br>This endpoint is available to organizations that have access to the Threat Hunting module.
39
+ */
40
+ async createTrackedScan(request, options) {
41
+ return (0, fp_js_1.unwrapAsync)((0, threatHuntingCreateTrackedScan_js_1.threatHuntingCreateTrackedScan)(this, request, options));
42
+ }
43
+ /**
44
+ * Get tracked scan details
45
+ *
46
+ * @remarks
47
+ * Retrieve the current status and results of a tracked scan by its ID.
48
+ * This endpoint works for both discovery scans and rescans.
49
+ */
50
+ async getTrackedScanThreatHunting(request, options) {
51
+ return (0, fp_js_1.unwrapAsync)((0, globalDataGetTrackedScanThreatHunting_js_1.globalDataGetTrackedScanThreatHunting)(this, request, options));
52
+ }
11
53
  /**
12
54
  * CensEye: Retrieve value counts to discover pivots
13
55
  *
@@ -1 +1 @@
1
- {"version":3,"file":"threathunting.js","sourceRoot":"","sources":["../src/sdk/threathunting.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sFAAgF;AAChF,4CAA2D;AAE3D,0CAA6C;AAE7C,MAAa,aAAc,SAAQ,mBAAS;IAC1C;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CACf,OAAqD,EACrD,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,sDAAwB,EACzC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF;AAjBD,sCAiBC"}
1
+ {"version":3,"file":"threathunting.js","sourceRoot":"","sources":["../src/sdk/threathunting.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sFAAgF;AAChF,gHAA0G;AAC1G,kGAA4F;AAC5F,oIAA8H;AAC9H,sFAAgF;AAChF,4CAA2D;AAE3D,0CAA6C;AAE7C,MAAa,aAAc,SAAQ,mBAAS;IAC1C;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAClB,OAA+C,EAC/C,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,sDAAwB,EACzC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kCAAkC,CACtC,OACqE,EACrE,OAAwB;QAIxB,OAAO,IAAA,mBAAW,EAAC,IAAA,oGAA+C,EAChE,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,iBAAiB,CACrB,OAAwD,EACxD,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,kEAA8B,EAC/C,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,2BAA2B,CAC/B,OAAkD,EAClD,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,gFAAqC,EACtD,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CACf,OAAqD,EACrD,OAAwB;QAExB,OAAO,IAAA,mBAAW,EAAC,IAAA,sDAAwB,EACzC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF;AA1FD,sCA0FC"}
@@ -0,0 +1,185 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { SDKCore } from "../core.js";
6
+ import { encodeFormQuery, encodeJSON } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ ConnectionError,
15
+ InvalidRequestError,
16
+ RequestAbortedError,
17
+ RequestTimeoutError,
18
+ UnexpectedClientError,
19
+ } from "../models/errors/httpclienterrors.js";
20
+ import * as errors from "../models/errors/index.js";
21
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
22
+ import { SDKBaseError } from "../models/errors/sdkbaseerror.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Create a tracked rescan
30
+ *
31
+ * @remarks
32
+ * Create a new tracked rescan for a known service or web property. Rescans are used to update information for previously discovered targets. The scan will be queued. The response will contain a scan ID that you can use with the [get tracked scan details endpoint](https://docs.censys.com/reference/v3-globaldata-scans-get#/) to monitor its status and results.<br><br>This endpoint is available to all Enterprise customers.
33
+ */
34
+ export function globalDataCreateTrackedScan(
35
+ client: SDKCore,
36
+ request: operations.V3GlobaldataScansRescanRequest,
37
+ options?: RequestOptions,
38
+ ): APIPromise<
39
+ Result<
40
+ operations.V3GlobaldataScansRescanResponse,
41
+ | errors.ErrorModel
42
+ | SDKBaseError
43
+ | ResponseValidationError
44
+ | ConnectionError
45
+ | RequestAbortedError
46
+ | RequestTimeoutError
47
+ | InvalidRequestError
48
+ | UnexpectedClientError
49
+ | SDKValidationError
50
+ >
51
+ > {
52
+ return new APIPromise($do(
53
+ client,
54
+ request,
55
+ options,
56
+ ));
57
+ }
58
+
59
+ async function $do(
60
+ client: SDKCore,
61
+ request: operations.V3GlobaldataScansRescanRequest,
62
+ options?: RequestOptions,
63
+ ): Promise<
64
+ [
65
+ Result<
66
+ operations.V3GlobaldataScansRescanResponse,
67
+ | errors.ErrorModel
68
+ | SDKBaseError
69
+ | ResponseValidationError
70
+ | ConnectionError
71
+ | RequestAbortedError
72
+ | RequestTimeoutError
73
+ | InvalidRequestError
74
+ | UnexpectedClientError
75
+ | SDKValidationError
76
+ >,
77
+ APICall,
78
+ ]
79
+ > {
80
+ const parsed = safeParse(
81
+ request,
82
+ (value) =>
83
+ operations.V3GlobaldataScansRescanRequest$outboundSchema.parse(value),
84
+ "Input validation failed",
85
+ );
86
+ if (!parsed.ok) {
87
+ return [parsed, { status: "invalid" }];
88
+ }
89
+ const payload = parsed.value;
90
+ const body = encodeJSON("body", payload.ScansRescanInputBody, {
91
+ explode: true,
92
+ });
93
+
94
+ const path = pathToFunc("/v3/global/scans/rescan")();
95
+
96
+ const query = encodeFormQuery({
97
+ "organization_id": payload.organization_id
98
+ ?? client._options.organizationId,
99
+ }, { explode: false });
100
+
101
+ const headers = new Headers(compactMap({
102
+ "Content-Type": "application/json",
103
+ Accept: "application/json",
104
+ }));
105
+
106
+ const secConfig = await extractSecurity(client._options.personalAccessToken);
107
+ const securityInput = secConfig == null
108
+ ? {}
109
+ : { personalAccessToken: secConfig };
110
+ const requestSecurity = resolveGlobalSecurity(securityInput);
111
+
112
+ const context = {
113
+ options: client._options,
114
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
115
+ operationID: "v3-globaldata-scans-rescan",
116
+ oAuth2Scopes: [],
117
+
118
+ resolvedSecurity: requestSecurity,
119
+
120
+ securitySource: client._options.personalAccessToken,
121
+ retryConfig: options?.retries
122
+ || client._options.retryConfig
123
+ || { strategy: "none" },
124
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
125
+ };
126
+
127
+ const requestRes = client._createRequest(context, {
128
+ security: requestSecurity,
129
+ method: "POST",
130
+ baseURL: options?.serverURL,
131
+ path: path,
132
+ headers: headers,
133
+ query: query,
134
+ body: body,
135
+ userAgent: client._options.userAgent,
136
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
137
+ }, options);
138
+ if (!requestRes.ok) {
139
+ return [requestRes, { status: "invalid" }];
140
+ }
141
+ const req = requestRes.value;
142
+
143
+ const doResult = await client._do(req, {
144
+ context,
145
+ errorCodes: ["401", "403", "4XX", "5XX"],
146
+ retryConfig: context.retryConfig,
147
+ retryCodes: context.retryCodes,
148
+ });
149
+ if (!doResult.ok) {
150
+ return [doResult, { status: "request-error", request: req }];
151
+ }
152
+ const response = doResult.value;
153
+
154
+ const responseFields = {
155
+ HttpMeta: { Response: response, Request: req },
156
+ };
157
+
158
+ const [result] = await M.match<
159
+ operations.V3GlobaldataScansRescanResponse,
160
+ | errors.ErrorModel
161
+ | SDKBaseError
162
+ | ResponseValidationError
163
+ | ConnectionError
164
+ | RequestAbortedError
165
+ | RequestTimeoutError
166
+ | InvalidRequestError
167
+ | UnexpectedClientError
168
+ | SDKValidationError
169
+ >(
170
+ M.json(200, operations.V3GlobaldataScansRescanResponse$inboundSchema, {
171
+ hdrs: true,
172
+ key: "Result",
173
+ }),
174
+ M.jsonErr([401, 403], errors.ErrorModel$inboundSchema, {
175
+ ctype: "application/problem+json",
176
+ }),
177
+ M.fail("4XX"),
178
+ M.fail("5XX"),
179
+ )(response, req, { extraFields: responseFields });
180
+ if (!result.ok) {
181
+ return [result, { status: "complete", request: req, response }];
182
+ }
183
+
184
+ return [result, { status: "complete", request: req, response }];
185
+ }
@@ -0,0 +1,191 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { SDKCore } from "../core.js";
6
+ import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ ConnectionError,
15
+ InvalidRequestError,
16
+ RequestAbortedError,
17
+ RequestTimeoutError,
18
+ UnexpectedClientError,
19
+ } from "../models/errors/httpclienterrors.js";
20
+ import * as errors from "../models/errors/index.js";
21
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
22
+ import { SDKBaseError } from "../models/errors/sdkbaseerror.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Get tracked scan details
30
+ *
31
+ * @remarks
32
+ * Retrieve the current status and results of a tracked scan by its ID.
33
+ * This endpoint works for both discovery scans and rescans.
34
+ */
35
+ export function globalDataGetTrackedScan(
36
+ client: SDKCore,
37
+ request: operations.V3GlobaldataScansGetRequest,
38
+ options?: RequestOptions,
39
+ ): APIPromise<
40
+ Result<
41
+ operations.V3GlobaldataScansGetResponse,
42
+ | errors.ErrorModel
43
+ | SDKBaseError
44
+ | ResponseValidationError
45
+ | ConnectionError
46
+ | RequestAbortedError
47
+ | RequestTimeoutError
48
+ | InvalidRequestError
49
+ | UnexpectedClientError
50
+ | SDKValidationError
51
+ >
52
+ > {
53
+ return new APIPromise($do(
54
+ client,
55
+ request,
56
+ options,
57
+ ));
58
+ }
59
+
60
+ async function $do(
61
+ client: SDKCore,
62
+ request: operations.V3GlobaldataScansGetRequest,
63
+ options?: RequestOptions,
64
+ ): Promise<
65
+ [
66
+ Result<
67
+ operations.V3GlobaldataScansGetResponse,
68
+ | errors.ErrorModel
69
+ | SDKBaseError
70
+ | ResponseValidationError
71
+ | ConnectionError
72
+ | RequestAbortedError
73
+ | RequestTimeoutError
74
+ | InvalidRequestError
75
+ | UnexpectedClientError
76
+ | SDKValidationError
77
+ >,
78
+ APICall,
79
+ ]
80
+ > {
81
+ const parsed = safeParse(
82
+ request,
83
+ (value) =>
84
+ operations.V3GlobaldataScansGetRequest$outboundSchema.parse(value),
85
+ "Input validation failed",
86
+ );
87
+ if (!parsed.ok) {
88
+ return [parsed, { status: "invalid" }];
89
+ }
90
+ const payload = parsed.value;
91
+ const body = null;
92
+
93
+ const pathParams = {
94
+ scan_id: encodeSimple("scan_id", payload.scan_id, {
95
+ explode: false,
96
+ charEncoding: "percent",
97
+ }),
98
+ };
99
+
100
+ const path = pathToFunc("/v3/global/scans/{scan_id}")(pathParams);
101
+
102
+ const query = encodeFormQuery({
103
+ "organization_id": payload.organization_id
104
+ ?? client._options.organizationId,
105
+ }, { explode: false });
106
+
107
+ const headers = new Headers(compactMap({
108
+ Accept: "application/vnd.censys.api.v3.trackedscan.v1+json",
109
+ }));
110
+
111
+ const secConfig = await extractSecurity(client._options.personalAccessToken);
112
+ const securityInput = secConfig == null
113
+ ? {}
114
+ : { personalAccessToken: secConfig };
115
+ const requestSecurity = resolveGlobalSecurity(securityInput);
116
+
117
+ const context = {
118
+ options: client._options,
119
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
120
+ operationID: "v3-globaldata-scans-get",
121
+ oAuth2Scopes: [],
122
+
123
+ resolvedSecurity: requestSecurity,
124
+
125
+ securitySource: client._options.personalAccessToken,
126
+ retryConfig: options?.retries
127
+ || client._options.retryConfig
128
+ || { strategy: "none" },
129
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
130
+ };
131
+
132
+ const requestRes = client._createRequest(context, {
133
+ security: requestSecurity,
134
+ method: "GET",
135
+ baseURL: options?.serverURL,
136
+ path: path,
137
+ headers: headers,
138
+ query: query,
139
+ body: body,
140
+ userAgent: client._options.userAgent,
141
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
142
+ }, options);
143
+ if (!requestRes.ok) {
144
+ return [requestRes, { status: "invalid" }];
145
+ }
146
+ const req = requestRes.value;
147
+
148
+ const doResult = await client._do(req, {
149
+ context,
150
+ errorCodes: ["401", "403", "4XX", "5XX"],
151
+ retryConfig: context.retryConfig,
152
+ retryCodes: context.retryCodes,
153
+ });
154
+ if (!doResult.ok) {
155
+ return [doResult, { status: "request-error", request: req }];
156
+ }
157
+ const response = doResult.value;
158
+
159
+ const responseFields = {
160
+ HttpMeta: { Response: response, Request: req },
161
+ };
162
+
163
+ const [result] = await M.match<
164
+ operations.V3GlobaldataScansGetResponse,
165
+ | errors.ErrorModel
166
+ | SDKBaseError
167
+ | ResponseValidationError
168
+ | ConnectionError
169
+ | RequestAbortedError
170
+ | RequestTimeoutError
171
+ | InvalidRequestError
172
+ | UnexpectedClientError
173
+ | SDKValidationError
174
+ >(
175
+ M.json(200, operations.V3GlobaldataScansGetResponse$inboundSchema, {
176
+ ctype: "application/vnd.censys.api.v3.trackedscan.v1+json",
177
+ hdrs: true,
178
+ key: "Result",
179
+ }),
180
+ M.jsonErr([401, 403], errors.ErrorModel$inboundSchema, {
181
+ ctype: "application/problem+json",
182
+ }),
183
+ M.fail("4XX"),
184
+ M.fail("5XX"),
185
+ )(response, req, { extraFields: responseFields });
186
+ if (!result.ok) {
187
+ return [result, { status: "complete", request: req, response }];
188
+ }
189
+
190
+ return [result, { status: "complete", request: req, response }];
191
+ }
@@ -0,0 +1,191 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { SDKCore } from "../core.js";
6
+ import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ ConnectionError,
15
+ InvalidRequestError,
16
+ RequestAbortedError,
17
+ RequestTimeoutError,
18
+ UnexpectedClientError,
19
+ } from "../models/errors/httpclienterrors.js";
20
+ import * as errors from "../models/errors/index.js";
21
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
22
+ import { SDKBaseError } from "../models/errors/sdkbaseerror.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Get tracked scan details
30
+ *
31
+ * @remarks
32
+ * Retrieve the current status and results of a tracked scan by its ID.
33
+ * This endpoint works for both discovery scans and rescans.
34
+ */
35
+ export function globalDataGetTrackedScanThreatHunting(
36
+ client: SDKCore,
37
+ request: operations.V3ThreathuntingScansGetRequest,
38
+ options?: RequestOptions,
39
+ ): APIPromise<
40
+ Result<
41
+ operations.V3ThreathuntingScansGetResponse,
42
+ | errors.ErrorModel
43
+ | SDKBaseError
44
+ | ResponseValidationError
45
+ | ConnectionError
46
+ | RequestAbortedError
47
+ | RequestTimeoutError
48
+ | InvalidRequestError
49
+ | UnexpectedClientError
50
+ | SDKValidationError
51
+ >
52
+ > {
53
+ return new APIPromise($do(
54
+ client,
55
+ request,
56
+ options,
57
+ ));
58
+ }
59
+
60
+ async function $do(
61
+ client: SDKCore,
62
+ request: operations.V3ThreathuntingScansGetRequest,
63
+ options?: RequestOptions,
64
+ ): Promise<
65
+ [
66
+ Result<
67
+ operations.V3ThreathuntingScansGetResponse,
68
+ | errors.ErrorModel
69
+ | SDKBaseError
70
+ | ResponseValidationError
71
+ | ConnectionError
72
+ | RequestAbortedError
73
+ | RequestTimeoutError
74
+ | InvalidRequestError
75
+ | UnexpectedClientError
76
+ | SDKValidationError
77
+ >,
78
+ APICall,
79
+ ]
80
+ > {
81
+ const parsed = safeParse(
82
+ request,
83
+ (value) =>
84
+ operations.V3ThreathuntingScansGetRequest$outboundSchema.parse(value),
85
+ "Input validation failed",
86
+ );
87
+ if (!parsed.ok) {
88
+ return [parsed, { status: "invalid" }];
89
+ }
90
+ const payload = parsed.value;
91
+ const body = null;
92
+
93
+ const pathParams = {
94
+ scan_id: encodeSimple("scan_id", payload.scan_id, {
95
+ explode: false,
96
+ charEncoding: "percent",
97
+ }),
98
+ };
99
+
100
+ const path = pathToFunc("/v3/threat-hunting/scans/{scan_id}")(pathParams);
101
+
102
+ const query = encodeFormQuery({
103
+ "organization_id": payload.organization_id
104
+ ?? client._options.organizationId,
105
+ }, { explode: false });
106
+
107
+ const headers = new Headers(compactMap({
108
+ Accept: "application/vnd.censys.api.v3.trackedscan.v1+json",
109
+ }));
110
+
111
+ const secConfig = await extractSecurity(client._options.personalAccessToken);
112
+ const securityInput = secConfig == null
113
+ ? {}
114
+ : { personalAccessToken: secConfig };
115
+ const requestSecurity = resolveGlobalSecurity(securityInput);
116
+
117
+ const context = {
118
+ options: client._options,
119
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
120
+ operationID: "v3-threathunting-scans-get",
121
+ oAuth2Scopes: [],
122
+
123
+ resolvedSecurity: requestSecurity,
124
+
125
+ securitySource: client._options.personalAccessToken,
126
+ retryConfig: options?.retries
127
+ || client._options.retryConfig
128
+ || { strategy: "none" },
129
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
130
+ };
131
+
132
+ const requestRes = client._createRequest(context, {
133
+ security: requestSecurity,
134
+ method: "GET",
135
+ baseURL: options?.serverURL,
136
+ path: path,
137
+ headers: headers,
138
+ query: query,
139
+ body: body,
140
+ userAgent: client._options.userAgent,
141
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
142
+ }, options);
143
+ if (!requestRes.ok) {
144
+ return [requestRes, { status: "invalid" }];
145
+ }
146
+ const req = requestRes.value;
147
+
148
+ const doResult = await client._do(req, {
149
+ context,
150
+ errorCodes: ["401", "403", "4XX", "5XX"],
151
+ retryConfig: context.retryConfig,
152
+ retryCodes: context.retryCodes,
153
+ });
154
+ if (!doResult.ok) {
155
+ return [doResult, { status: "request-error", request: req }];
156
+ }
157
+ const response = doResult.value;
158
+
159
+ const responseFields = {
160
+ HttpMeta: { Response: response, Request: req },
161
+ };
162
+
163
+ const [result] = await M.match<
164
+ operations.V3ThreathuntingScansGetResponse,
165
+ | errors.ErrorModel
166
+ | SDKBaseError
167
+ | ResponseValidationError
168
+ | ConnectionError
169
+ | RequestAbortedError
170
+ | RequestTimeoutError
171
+ | InvalidRequestError
172
+ | UnexpectedClientError
173
+ | SDKValidationError
174
+ >(
175
+ M.json(200, operations.V3ThreathuntingScansGetResponse$inboundSchema, {
176
+ ctype: "application/vnd.censys.api.v3.trackedscan.v1+json",
177
+ hdrs: true,
178
+ key: "Result",
179
+ }),
180
+ M.jsonErr([401, 403], errors.ErrorModel$inboundSchema, {
181
+ ctype: "application/problem+json",
182
+ }),
183
+ M.fail("4XX"),
184
+ M.fail("5XX"),
185
+ )(response, req, { extraFields: responseFields });
186
+ if (!result.ok) {
187
+ return [result, { status: "complete", request: req, response }];
188
+ }
189
+
190
+ return [result, { status: "complete", request: req, response }];
191
+ }