@synthient/synthient 1.0.0 → 2.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.
@@ -0,0 +1,328 @@
1
+ import { setTimeout as sleep } from "node:timers/promises";
2
+ import { APIConnectionError, APIError, APITimeoutError, SynthientError, apiError, isObject, parseRetryAfter, } from "./errors.js";
3
+ const MAX_RESPONSE_SIZE = 16 << 20;
4
+ const MAX_ERROR_SIZE = 64 << 10;
5
+ const MAX_BACKOFF = 30_000;
6
+ const MAX_RETRY_AFTER = 60_000;
7
+ const MAX_STORAGE_REDIRECTS = 10;
8
+ // Transport failures retried on account and feed requests, matched anywhere in the
9
+ // error's cause chain, including errors from a custom fetch. Anything else, such as a
10
+ // TLS certificate error, is not retried.
11
+ const TRANSIENT_CODES = new Set([
12
+ "ECONNRESET",
13
+ "ECONNREFUSED",
14
+ "EPIPE",
15
+ "ETIMEDOUT",
16
+ "ENOTFOUND",
17
+ "EAI_AGAIN",
18
+ "ENETUNREACH",
19
+ "EHOSTUNREACH",
20
+ "UND_ERR_SOCKET",
21
+ "UND_ERR_CONNECT_TIMEOUT",
22
+ ]);
23
+ const RETRY_STATUSES = new Set([500, 502, 503, 504]);
24
+ // Tests replace the backoff wait through this key in the client options.
25
+ export const kWait = Symbol("synthient.wait");
26
+ /**
27
+ * Its signal follows the caller's signal and an idle timer that runs only while the
28
+ * attempt waits on the network.
29
+ */
30
+ export class Attempt {
31
+ caller;
32
+ signal;
33
+ #timer = new AbortController();
34
+ #timeout;
35
+ #surface;
36
+ constructor(caller, timeout, surface = "api") {
37
+ this.caller = caller;
38
+ this.#timeout = timeout;
39
+ this.#surface = surface;
40
+ this.signal = caller ? AbortSignal.any([caller, this.#timer.signal]) : this.#timer.signal;
41
+ }
42
+ /**
43
+ * Storage failures are rebuilt without their message or cause, either of which can
44
+ * contain the presigned URL.
45
+ */
46
+ async watch(work) {
47
+ const timer = setTimeout(() => {
48
+ this.#timer.abort();
49
+ }, this.#timeout);
50
+ try {
51
+ const result = await work;
52
+ this.caller?.throwIfAborted();
53
+ return result;
54
+ }
55
+ catch (error) {
56
+ if (this.caller?.aborted) {
57
+ throw this.caller.reason;
58
+ }
59
+ if (this.#timer.signal.aborted ||
60
+ (this.#surface === "storage" && error instanceof APITimeoutError)) {
61
+ throw new APITimeoutError("request timed out");
62
+ }
63
+ if (this.#surface === "storage") {
64
+ throw new APIConnectionError("connection failed");
65
+ }
66
+ if (error instanceof SynthientError) {
67
+ throw error;
68
+ }
69
+ throw new APIConnectionError("connection failed", { cause: error });
70
+ }
71
+ finally {
72
+ clearTimeout(timer);
73
+ }
74
+ }
75
+ }
76
+ export class Transport {
77
+ #config;
78
+ #base;
79
+ #headers;
80
+ constructor(config) {
81
+ this.#config = config;
82
+ this.#base = (config.baseURL.origin + config.baseURL.pathname).replace(/\/+$/, "");
83
+ this.#headers = new Headers({ "x-api-key": config.apiKey, "user-agent": config.userAgent });
84
+ }
85
+ url(request) {
86
+ const search = new URLSearchParams(request.query).toString();
87
+ return search ? `${this.#base}${request.path}?${search}` : this.#base + request.path;
88
+ }
89
+ /** The caller must read or cancel the returned response's body. */
90
+ send(request, signal) {
91
+ return this.#request(request, signal, (response, attempt) => [
92
+ response,
93
+ attempt,
94
+ ]);
95
+ }
96
+ async #request(request, signal, consume) {
97
+ const url = this.url(request);
98
+ const headers = new Headers(this.#headers);
99
+ headers.set("accept", request.accept ?? "application/json");
100
+ if (request.body !== undefined) {
101
+ headers.set("content-type", "application/json");
102
+ }
103
+ for (let attempt = 0;; attempt++) {
104
+ signal?.throwIfAborted();
105
+ const canRetry = attempt < this.#config.maxRetries;
106
+ const current = new Attempt(signal, this.#config.timeout);
107
+ let delay = backoff(attempt);
108
+ try {
109
+ const response = await current.watch(this.#fetch(url, {
110
+ method: request.method ?? "GET",
111
+ headers,
112
+ body: request.body ?? null,
113
+ redirect: "manual",
114
+ signal: current.signal,
115
+ }));
116
+ this.#notify(response);
117
+ // A 429 without Retry-After is a spent monthly budget or concurrent stream
118
+ // limit, which a retry cannot fix.
119
+ const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
120
+ const retryStatus = (response.status === 429 && retryAfter !== undefined) ||
121
+ (request.policy === "transient" && RETRY_STATUSES.has(response.status));
122
+ if (!canRetry || !retryStatus || (retryAfter ?? 0) > MAX_RETRY_AFTER) {
123
+ return await consume(response, current);
124
+ }
125
+ await drain(response, current);
126
+ delay = Math.max(delay, retryAfter ?? 0);
127
+ }
128
+ catch (error) {
129
+ if (!canRetry || request.policy !== "transient" || !transient(error, signal)) {
130
+ throw error;
131
+ }
132
+ }
133
+ await this.#config.wait(delay, signal);
134
+ }
135
+ }
136
+ json(request, signal) {
137
+ return this.#request(request, signal, async (response, attempt) => {
138
+ if (!response.ok) {
139
+ throw await this.error(response, attempt);
140
+ }
141
+ const [body, complete] = await read(response, attempt, MAX_RESPONSE_SIZE);
142
+ if (!complete) {
143
+ throw new SynthientError(`response body exceeds ${MAX_RESPONSE_SIZE} bytes`);
144
+ }
145
+ let value;
146
+ try {
147
+ value = JSON.parse(new TextDecoder().decode(body));
148
+ }
149
+ catch (error) {
150
+ throw new SynthientError("invalid JSON in response", { cause: error });
151
+ }
152
+ if (!isObject(value)) {
153
+ throw new SynthientError("response is not a JSON object");
154
+ }
155
+ // The client trusts the API's schema; only protocol control data is validated.
156
+ return value;
157
+ });
158
+ }
159
+ async stream(request, signal) {
160
+ const [response, attempt] = await this.send(request, signal);
161
+ if (response.status !== 200) {
162
+ throw await this.error(response, attempt);
163
+ }
164
+ return watchedBody(response, attempt);
165
+ }
166
+ async error(response, attempt) {
167
+ try {
168
+ const [body] = await read(response, attempt, MAX_ERROR_SIZE);
169
+ return apiError(response, body);
170
+ }
171
+ catch (error) {
172
+ if (attempt.caller?.aborted) {
173
+ throw error;
174
+ }
175
+ return apiError(response, new Uint8Array(), error);
176
+ }
177
+ }
178
+ /**
179
+ * The API key is never sent to the storage host. Errors never include the presigned
180
+ * URL, and storage error bodies are discarded.
181
+ */
182
+ async download(start, signal) {
183
+ let url = start;
184
+ for (let redirects = 0;; redirects++) {
185
+ signal?.throwIfAborted();
186
+ const attempt = new Attempt(signal, this.#config.timeout, "storage");
187
+ const response = await attempt.watch(this.#fetch(url.href, {
188
+ headers: { "user-agent": this.#config.userAgent },
189
+ redirect: "manual",
190
+ signal: attempt.signal,
191
+ }));
192
+ if (response.status === 200) {
193
+ return watchedBody(response, attempt);
194
+ }
195
+ await drain(response, attempt);
196
+ if (response.status < 300 || response.status > 399) {
197
+ throw new APIError({
198
+ status: response.status,
199
+ retryAfter: parseRetryAfter(response.headers.get("retry-after")),
200
+ });
201
+ }
202
+ if (redirects === MAX_STORAGE_REDIRECTS) {
203
+ throw new SynthientError("too many export redirects");
204
+ }
205
+ url = redirectTarget(url, response);
206
+ }
207
+ }
208
+ // A custom fetch that throws synchronously still rejects, so watch() wraps its error.
209
+ async #fetch(url, init) {
210
+ return this.#config.fetch(url, init);
211
+ }
212
+ #notify(response) {
213
+ const hook = this.#config.onResponse;
214
+ if (!hook) {
215
+ return;
216
+ }
217
+ try {
218
+ hook({
219
+ status: response.status,
220
+ requestID: response.headers.get("x-request-id") ?? "",
221
+ headers: new Headers(response.headers),
222
+ });
223
+ }
224
+ catch (error) {
225
+ process.emitWarning(error instanceof Error ? error : String(error));
226
+ }
227
+ }
228
+ }
229
+ export function isHTTP(url) {
230
+ return url?.protocol === "https:" || url?.protocol === "http:";
231
+ }
232
+ export function redirectTarget(from, response) {
233
+ const location = response.headers.get("location");
234
+ const target = location === null ? null : URL.parse(location, from.href);
235
+ if (!isHTTP(target) || target.username || target.password) {
236
+ throw new SynthientError("export redirect has no valid location");
237
+ }
238
+ if (from.protocol === "https:" && target.protocol !== "https:") {
239
+ throw new SynthientError("export redirect does not use https");
240
+ }
241
+ return target;
242
+ }
243
+ export async function wait(ms, signal) {
244
+ try {
245
+ await sleep(ms, undefined, { signal });
246
+ }
247
+ catch (error) {
248
+ // timers/promises rejects with an AbortError, not the signal's reason.
249
+ throw signal?.aborted ? signal.reason : error;
250
+ }
251
+ }
252
+ export function backoff(attempt) {
253
+ return Math.min(1000 * 2 ** Math.min(attempt, 5), MAX_BACKOFF) * (0.75 + Math.random() / 2);
254
+ }
255
+ function transient(error, signal) {
256
+ if (signal?.aborted) {
257
+ return false;
258
+ }
259
+ if (error instanceof APITimeoutError) {
260
+ return true;
261
+ }
262
+ if (!(error instanceof APIConnectionError)) {
263
+ return false;
264
+ }
265
+ let cause = error.cause;
266
+ for (let depth = 0; depth < 8 && typeof cause === "object" && cause !== null; depth++) {
267
+ if ("code" in cause && TRANSIENT_CODES.has(String(cause.code))) {
268
+ return true;
269
+ }
270
+ cause = "cause" in cause ? cause.cause : undefined;
271
+ }
272
+ return false;
273
+ }
274
+ function watchedBody(response, attempt) {
275
+ if (!response.body) {
276
+ return new ReadableStream({
277
+ start(controller) {
278
+ controller.close();
279
+ },
280
+ });
281
+ }
282
+ const reader = response.body.getReader();
283
+ return new ReadableStream({
284
+ async pull(controller) {
285
+ const { done, value } = await attempt.watch(reader.read());
286
+ if (done) {
287
+ controller.close();
288
+ }
289
+ else {
290
+ controller.enqueue(value);
291
+ }
292
+ },
293
+ cancel(reason) {
294
+ return reader.cancel(reason).catch(() => undefined);
295
+ },
296
+ }, { highWaterMark: 0 });
297
+ }
298
+ /** Returns false with the first `limit` bytes when the body is longer than `limit`. */
299
+ async function read(response, attempt, limit) {
300
+ if (!response.body) {
301
+ return [new Uint8Array(), true];
302
+ }
303
+ const reader = response.body.getReader();
304
+ const chunks = [];
305
+ let size = 0;
306
+ try {
307
+ for (;;) {
308
+ const { done, value } = await attempt.watch(reader.read());
309
+ if (done) {
310
+ return [Buffer.concat(chunks, size), true];
311
+ }
312
+ if (size + value.byteLength > limit) {
313
+ chunks.push(value.subarray(0, limit - size));
314
+ return [Buffer.concat(chunks, limit), false];
315
+ }
316
+ chunks.push(value);
317
+ size += value.byteLength;
318
+ }
319
+ }
320
+ finally {
321
+ reader.cancel().catch(() => undefined);
322
+ }
323
+ }
324
+ /** Discards a body so its connection can be reused. */
325
+ export async function drain(response, attempt) {
326
+ await read(response, attempt, MAX_ERROR_SIZE).catch(() => undefined);
327
+ attempt.caller?.throwIfAborted();
328
+ }
@@ -0,0 +1,248 @@
1
+ /**
2
+ * A Unix time as sent by the API. It is in seconds, except the `timestamp` of anonymizer
3
+ * and Helios HTTP, HTTPS, and DNS stream events, which is in milliseconds. Convert
4
+ * either with {@link toDate}.
5
+ */
6
+ export type UnixTime = number;
7
+ /** New values may be added. */
8
+ export type NetworkType = "MOBILE" | "SATELLITE" | "IN_FLIGHT_WIFI" | "RESIDENTIAL" | "CORPORATE" | "ACADEMIC" | "DATACENTER" | "GOVERNMENT" | (string & {});
9
+ /** New values may be added. */
10
+ export type DeviceOS = "Android" | "Chrome OS" | "FreeBSD" | "iOS" | "Linux" | "Mac OS X" | "Windows" | (string & {});
11
+ /** New values may be added. */
12
+ export type Scope = "BASIC" | "PROXY_FEEDS" | "PROXY_FIREHOSE" | "ANONYMIZERS_FEED" | "ANONYMIZERS_STREAM" | "JA3_FEED" | "JA3_STREAM" | "TORRENTS_FEED" | "TORRENTS_STREAM" | "HONEYPOT_HTTP_FEED" | "HONEYPOT_HTTP_STREAM" | "HONEYPOT_HTTPS_FEED" | "HONEYPOT_HTTPS_STREAM" | "HONEYPOT_ADB_FEED" | "HONEYPOT_ADB_STREAM" | "HONEYPOT_DNS_FEED" | "HONEYPOT_DNS_STREAM" | "JA4_FEED" | "JA4_STREAM" | "JA4T_FEED" | "JA4T_STREAM" | "ADMIN_PROXIES" | (string & {});
13
+ /** The API always sends one of these sentences. */
14
+ export type ActivityCadence = "No activity in the last 30 days." | "Activity is evenly distributed across the day." | "Activity follows a weekday business-hours pattern." | "Activity follows a weekend pattern." | "Activity is burst-driven with significant peaks.";
15
+ /** New values may be added. */
16
+ export type ParquetType = "string" | "int64" | "uint32" | "uint64" | "bool" | "bytes" | (string & {});
17
+ /** Converts a {@link UnixTime} to a Date, reading values of 1e12 or more as milliseconds. */
18
+ export declare function toDate(timestamp: UnixTime): Date;
19
+ /** `network`, `location`, and `intelligence` are absent when the API has no data for them. */
20
+ export interface IPInfo {
21
+ ip: string;
22
+ network?: Network;
23
+ location?: Location;
24
+ intelligence?: Intelligence;
25
+ }
26
+ /** The network that announces an address. */
27
+ export interface Network {
28
+ /** The autonomous system number, or 0 if the address is not routed. */
29
+ asn: number;
30
+ isp: string;
31
+ type: NetworkType;
32
+ /** The organization the address is registered to. */
33
+ org?: string;
34
+ domain?: string;
35
+ abuse_email?: string;
36
+ abuse_phone?: string;
37
+ }
38
+ export interface Location {
39
+ /** The ISO 3166-1 alpha-2 country code. */
40
+ country: string;
41
+ /** The state or region. */
42
+ state: string;
43
+ city: string;
44
+ /** The IANA time zone name. */
45
+ timezone: string;
46
+ /** The latitude in degrees. */
47
+ latitude: number;
48
+ /** The longitude in degrees. */
49
+ longitude: number;
50
+ geo_hash: string;
51
+ }
52
+ export interface Intelligence {
53
+ /** The risk of the address, from 0 to 100. */
54
+ risk_score: number;
55
+ /** The kinds of services seen on the address, such as "RESIDENTIAL_PROXY". New values may be added. */
56
+ categories: string[];
57
+ /** New values may be added. */
58
+ behavior: string[];
59
+ /**
60
+ * The proxy, VPN, and anonymizer services seen using the address. An empty list does
61
+ * not mean the address is clean.
62
+ */
63
+ providers: Provider[];
64
+ devices: Device[];
65
+ }
66
+ /** A proxy, VPN, or anonymizer service seen using an address. */
67
+ export interface Provider {
68
+ /** The service tag, such as "BRIGHTDATA". */
69
+ provider: string;
70
+ /** The service category. */
71
+ type: string;
72
+ last_seen: UnixTime;
73
+ }
74
+ export interface Device {
75
+ os: DeviceOS;
76
+ /** The operating system version. */
77
+ version: string;
78
+ last_seen: UnixTime;
79
+ }
80
+ /** The honeypot traffic Synthient has observed for a domain. */
81
+ export interface DomainInfo {
82
+ domain: string;
83
+ /**
84
+ * "active" when the domain had events in the last 24 hours. A domain that was never
85
+ * observed is "inactive" with zeroed stats.
86
+ */
87
+ status: "active" | "inactive";
88
+ stats: DomainStats;
89
+ unique_ips: UniqueIPs;
90
+ /** Daily event counts. */
91
+ time_series: TimeSeriesPoint[];
92
+ /** The network that sent the most events, absent when there are none. */
93
+ top_asn?: ASNCount;
94
+ top_subdomains: SubdomainCount[];
95
+ top_ports: PortCount[];
96
+ /** Event counts by source country. */
97
+ geo_distribution: CountryCount[];
98
+ /**
99
+ * Event counts over the last 30 days as 7 rows, Monday first, of 24 hourly columns,
100
+ * all in UTC.
101
+ */
102
+ hour_dow_heatmap: number[][];
103
+ activity_stats: ActivityStats;
104
+ /** The most recent events, capped by the `limit` passed to `lookupDomain`. */
105
+ recent_events: DomainEvent[];
106
+ }
107
+ export interface DomainStats {
108
+ events_24h: number;
109
+ total_events_30d: number;
110
+ }
111
+ /** Counts of the distinct source addresses seen for a domain. */
112
+ export interface UniqueIPs {
113
+ value_24h: number;
114
+ value_30d: number;
115
+ /** Hourly counts for the last 24 hours. */
116
+ sparkline_24h: number[];
117
+ }
118
+ /** The event counts for one day. */
119
+ export interface TimeSeriesPoint {
120
+ /** The start of the UTC day. */
121
+ date: UnixTime;
122
+ events: number;
123
+ unique_ips: number;
124
+ }
125
+ export interface ASNCount {
126
+ asn: number;
127
+ events: number;
128
+ }
129
+ export interface SubdomainCount {
130
+ subdomain: string;
131
+ count: number;
132
+ }
133
+ export interface PortCount {
134
+ /** The targeted port. */
135
+ port: number;
136
+ count: number;
137
+ }
138
+ export interface CountryCount {
139
+ /** The ISO 3166-1 alpha-2 country code. */
140
+ country_code: string;
141
+ events: number;
142
+ unique_ips: number;
143
+ }
144
+ export interface ActivityStats {
145
+ cadence: ActivityCadence;
146
+ median_per_hour: number;
147
+ p95_per_hour: number;
148
+ /** The busiest UTC hour, from 0 to 23, over the last 30 days. */
149
+ peak_hour: number;
150
+ /** The quietest UTC hour, from 0 to 23, over the last 30 days. */
151
+ quiet_hour: number;
152
+ }
153
+ export interface DomainEvent {
154
+ timestamp: UnixTime;
155
+ /** The full proxy exit address that carried the event. Despite the name, it is not masked. */
156
+ source_ip_masked: string;
157
+ target_subdomain: string;
158
+ /** The source country. */
159
+ country_code: string;
160
+ /** The targeted port. */
161
+ port: number;
162
+ }
163
+ export interface Account {
164
+ email: string;
165
+ first_name: string;
166
+ last_name: string;
167
+ organization: Organization;
168
+ /** The permissions granted to the key. */
169
+ scopes: Scope[];
170
+ lookup_quota: LookupQuota;
171
+ /** The API key used for the request. */
172
+ api_key?: AccountAPIKey;
173
+ }
174
+ export interface Organization {
175
+ id: string;
176
+ name: string;
177
+ /** The account's role in the organization. */
178
+ relation: "OWNER" | "ADMIN" | "MEMBER";
179
+ }
180
+ export interface LookupQuota {
181
+ credits: number;
182
+ /** Seconds until the credits reset. */
183
+ resets_in: number;
184
+ }
185
+ export interface AccountAPIKey {
186
+ /** The key ID. It is not the secret key. */
187
+ id: string;
188
+ name: string;
189
+ /** When the key was created, as an RFC 3339 string. */
190
+ created_at: string;
191
+ }
192
+ /** One page of a feed's exports, newest first. */
193
+ export interface ExportPage {
194
+ /** The feed's stream identifier, such as "proxies". */
195
+ stream: string;
196
+ /** The exports on this page. */
197
+ feeds: Export[];
198
+ /** Pass it as `cursor` to fetch the next page. It is absent, null, or "" on the last page. */
199
+ next_cursor?: string | null;
200
+ }
201
+ /** A parquet export of a feed. */
202
+ export interface Export {
203
+ /**
204
+ * Identifies the export: "YYYY-MM-DD" for a daily export, "YYYY-MM-DD/H" with an
205
+ * unpadded hour for an hourly one, or "latest" for the newest hourly export on the
206
+ * first page. Pass it to `download`.
207
+ */
208
+ id: string;
209
+ /** Whether the export covers a UTC day or a UTC hour. */
210
+ kind: "hourly" | "daily";
211
+ /** The UTC day of the export as "YYYY-MM-DD". */
212
+ date: string;
213
+ /** The UTC hour of an hourly export, absent or null for a daily export. */
214
+ hour?: number | null;
215
+ size_bytes: number;
216
+ row_count: number;
217
+ /** The hex-encoded SHA-256 of the parquet file. */
218
+ checksum: string;
219
+ created_at: UnixTime;
220
+ /** The API path of the export's download, including the version prefix. */
221
+ download_path: string;
222
+ }
223
+ export interface ExportMeta {
224
+ id: string;
225
+ stream: string;
226
+ /** Whether the export covers a UTC day or a UTC hour. */
227
+ kind: "hourly" | "daily";
228
+ format: "parquet";
229
+ /** The start of the export: midnight UTC for a daily export, the hour for an hourly one. */
230
+ date: UnixTime;
231
+ /** The UTC hour of an hourly export, absent or null for a daily export. */
232
+ hour?: number | null;
233
+ rows: number;
234
+ /** The size of the parquet file in bytes. */
235
+ size: number;
236
+ /** The hex-encoded SHA-256 of the parquet file. */
237
+ checksum: string;
238
+ created_at: UnixTime;
239
+ schema: ParquetSchema;
240
+ }
241
+ export interface ParquetSchema {
242
+ /** The columns in file order. */
243
+ fields: ParquetColumn[];
244
+ }
245
+ export interface ParquetColumn {
246
+ name: string;
247
+ type: ParquetType;
248
+ }
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ /** Converts a {@link UnixTime} to a Date, reading values of 1e12 or more as milliseconds. */
2
+ export function toDate(timestamp) {
3
+ return new Date(timestamp >= 1e12 ? timestamp : timestamp * 1000);
4
+ }
@@ -0,0 +1,2 @@
1
+ /** The client sends it in the User-Agent header. */
2
+ export declare const VERSION = "2.0.0";
@@ -0,0 +1,2 @@
1
+ /** The client sends it in the User-Agent header. */
2
+ export const VERSION = "2.0.0";
package/package.json CHANGED
@@ -1,19 +1,77 @@
1
1
  {
2
2
  "name": "@synthient/synthient",
3
- "version": "1.0.0",
4
- "main": "dist/index.js",
3
+ "version": "2.0.0",
4
+ "description": "The official Node.js client for the Synthient API.",
5
+ "keywords": [
6
+ "synthient",
7
+ "ip intelligence",
8
+ "proxy detection",
9
+ "vpn detection",
10
+ "threat intelligence"
11
+ ],
12
+ "homepage": "https://synthient.com",
13
+ "bugs": "https://github.com/synthient/synthient-node/issues",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/synthient/synthient-node.git"
17
+ },
18
+ "license": "Apache-2.0",
19
+ "author": "Synthient",
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./grpcschema": {
27
+ "types": "./dist/grpcschema.d.ts",
28
+ "default": "./dist/grpcschema.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "sideEffects": false,
36
+ "engines": {
37
+ "node": ">=22.12.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
5
42
  "scripts": {
6
- "build": "tsc"
43
+ "build": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
44
+ "typecheck": "tsc",
45
+ "test": "node --test \"test/*.test.ts\"",
46
+ "lint": "eslint . && prettier --check .",
47
+ "format": "prettier --write .",
48
+ "check:package": "sh scripts/check-package.sh",
49
+ "prepack": "npm run build"
7
50
  },
8
- "dependencies": {
9
- "axios": "^0.24.0"
51
+ "peerDependencies": {
52
+ "@bufbuild/protobuf": "^2.2.0",
53
+ "@grpc/grpc-js": "^1.10.0"
10
54
  },
11
- "devDependencies": {
12
- "typescript": "^4.5.4",
13
- "@types/node": "^16.11.7"
55
+ "peerDependenciesMeta": {
56
+ "@bufbuild/protobuf": {
57
+ "optional": true
58
+ },
59
+ "@grpc/grpc-js": {
60
+ "optional": true
61
+ }
14
62
  },
15
- "types": "./dist/index.d.ts",
16
- "description": "Node.js client for the Synthient API.",
17
- "author": "",
18
- "license": "ISC"
63
+ "devDependencies": {
64
+ "@arethetypeswrong/cli": "^0.18.5",
65
+ "@bufbuild/protobuf": "^2.16.0",
66
+ "@eslint/js": "^10.0.1",
67
+ "@grpc/grpc-js": "^1.14.5",
68
+ "@grpc/proto-loader": "^0.8.1",
69
+ "@grpc/reflection": "^1.0.4",
70
+ "@types/node": "^22.20.4",
71
+ "eslint": "^10.11.0",
72
+ "prettier": "^3.9.9",
73
+ "publint": "^0.3.24",
74
+ "typescript": "~6.0.3",
75
+ "typescript-eslint": "^8.71.0"
76
+ }
19
77
  }
@@ -1,2 +0,0 @@
1
- export declare const API_URL = "https://api.synthient.com/api/v1/";
2
- export declare const DEFAULT_TIMEOUT = 5000;
package/dist/constants.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_TIMEOUT = exports.API_URL = void 0;
4
- exports.API_URL = "https://api.synthient.com/api/v1/";
5
- exports.DEFAULT_TIMEOUT = 5000;