diff --git a/components/securitytrails/actions/get-domain-details/get-domain-details.mjs b/components/securitytrails/actions/get-domain-details/get-domain-details.mjs new file mode 100644 index 0000000000000..3edce98284643 --- /dev/null +++ b/components/securitytrails/actions/get-domain-details/get-domain-details.mjs @@ -0,0 +1,41 @@ +import app from "../../securitytrails.app.mjs"; + +export default { + key: "securitytrails-get-domain-details", + name: "Get Domain Details", + description: "Returns the current data about the given hostname. [See the documentation](https://docs.securitytrails.com/reference/domain-details)", + version: "0.0.1", + type: "action", + props: { + app, + hostname: { + propDefinition: [ + app, + "hostname", + ], + }, + }, + methods: { + getDomainDetails({ + hostname, ...args + } = {}) { + return this.app._makeRequest({ + path: `/domain/${hostname}`, + ...args, + }); + }, + }, + async run({ $ }) { + const { + getDomainDetails, + hostname, + } = this; + + const response = await getDomainDetails({ + $, + hostname, + }); + $.export("$summary", `Successfully retrieved details for hostname \`${response.hostname}\`.`); + return response; + }, +}; diff --git a/components/securitytrails/actions/get-history-dns/get-history-dns.mjs b/components/securitytrails/actions/get-history-dns/get-history-dns.mjs new file mode 100644 index 0000000000000..caf797cfd7c9b --- /dev/null +++ b/components/securitytrails/actions/get-history-dns/get-history-dns.mjs @@ -0,0 +1,74 @@ +import app from "../../securitytrails.app.mjs"; + +export default { + key: "securitytrails-get-history-dns", + name: "Get Historical DNS", + description: "Lists out specific historical information about the given hostname parameter. [See the documentation](https://docs.securitytrails.com/reference/history-dns)", + version: "0.0.1", + type: "action", + props: { + app, + hostname: { + propDefinition: [ + app, + "hostname", + ], + }, + type: { + type: "string", + label: "Record Type", + description: "Select the DNS record type to query historical data for.", + options: [ + { + label: "A", + value: "a", + }, + { + label: "AAAA", + value: "aaaa", + }, + { + label: "MX", + value: "mx", + }, + { + label: "NS", + value: "ns", + }, + { + label: "SOA", + value: "soa", + }, + { + label: "TXT", + value: "txt", + }, + ], + }, + }, + methods: { + getHistoryDns({ + hostname, type, ...args + } = {}) { + return this.app._makeRequest({ + path: `/history/${hostname}/dns/${type}`, + ...args, + }); + }, + }, + async run({ $ }) { + const { + getHistoryDns, + hostname, + type, + } = this; + + const response = await getHistoryDns({ + $, + hostname, + type, + }); + $.export("$summary", `Successfully retrieved historical DNS data for type \`${response.type}\`.`); + return response; + }, +}; diff --git a/components/securitytrails/actions/get-ips-neighbors/get-ips-neighbors.mjs b/components/securitytrails/actions/get-ips-neighbors/get-ips-neighbors.mjs new file mode 100644 index 0000000000000..4a256d5a26297 --- /dev/null +++ b/components/securitytrails/actions/get-ips-neighbors/get-ips-neighbors.mjs @@ -0,0 +1,41 @@ +import app from "../../securitytrails.app.mjs"; + +export default { + key: "securitytrails-get-ips-neighbors", + name: "Get IPs Neighbors", + description: "Returns the neighbors in any given IP level range and essentially allows you to explore closeby IP addresses.", + version: "0.0.1", + type: "action", + props: { + app, + ipaddress: { + type: "string", + label: "IP Address", + description: "Enter the IP address to find neighbors for. Eg. `8.8.8.8`.", + }, + }, + methods: { + getIpNeighbors({ + ipaddress, ...args + }) { + return this.app._makeRequest({ + path: `/ips/nearby/${ipaddress}`, + ...args, + }); + }, + }, + async run({ $ }) { + const { + getIpNeighbors, + ipaddress, + } = this; + + const response = await getIpNeighbors({ + $, + ipaddress, + }); + + $.export("$summary", `Successfully retrieved \`${response?.blocks.length}\` neighbor(s).`); + return response; + }, +}; diff --git a/components/securitytrails/common/constants.mjs b/components/securitytrails/common/constants.mjs new file mode 100644 index 0000000000000..ee0b63dfedf6b --- /dev/null +++ b/components/securitytrails/common/constants.mjs @@ -0,0 +1,7 @@ +const BASE_URL = "https://api.securitytrails.com"; +const VERSION_PATH = "/v1"; + +export default { + BASE_URL, + VERSION_PATH, +}; diff --git a/components/securitytrails/package.json b/components/securitytrails/package.json index 4f69d879b9e1d..a891515dfa2d0 100644 --- a/components/securitytrails/package.json +++ b/components/securitytrails/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/securitytrails", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream SecurityTrails Components", "main": "securitytrails.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "3.0.1" } -} \ No newline at end of file +} diff --git a/components/securitytrails/securitytrails.app.mjs b/components/securitytrails/securitytrails.app.mjs index 0c7ca018bc4ec..c88964fd8cf19 100644 --- a/components/securitytrails/securitytrails.app.mjs +++ b/components/securitytrails/securitytrails.app.mjs @@ -1,11 +1,34 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "securitytrails", - propDefinitions: {}, + propDefinitions: { + hostname: { + type: "string", + label: "Hostname", + description: "Enter the hostname to query information for. Eg. `oracle.com`", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`; + }, + getHeaders(headers = {}) { + return { + ...headers, + APIKEY: this.$auth.api_key, + }; + }, + _makeRequest({ + $ = this, path, headers, ...args + } = {}) { + return axios($, { + ...args, + url: this.getUrl(path), + headers: this.getHeaders(headers), + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 763cfe65baf14..3180d32eda68f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8293,7 +8293,10 @@ importers: specifiers: {} components/securitytrails: - specifiers: {} + specifiers: + '@pipedream/platform': 3.0.1 + dependencies: + '@pipedream/platform': 3.0.1 components/segment: specifiers: @@ -17461,9 +17464,9 @@ packages: /@pipedream/platform/3.0.1: resolution: {integrity: sha512-xja1ZHUR/DpOQZZJY39daml8q1ZMzg8wKYwYbyxVPs7MiMqneHM7Bz+Lgj/QrjbNissIKsRSGXmkXbT+Y10L0w==} dependencies: - axios: 1.7.4 - fp-ts: 2.16.1 - io-ts: 2.2.20_fp-ts@2.16.1 + axios: 1.7.5 + fp-ts: 2.16.9 + io-ts: 2.2.21_fp-ts@2.16.9 querystring: 0.2.1 transitivePeerDependencies: - debug