@tidelight/sdk 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +31 -3
- package/dist/index.d.ts +49 -1
- package/dist/index.js +116 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
- Add synchronous AgentKey research with tool and source provenance and no automatic retry.
|
|
6
|
+
- Add unauthenticated public Decision Capsule retrieval and local SHA-256 verification.
|
|
7
|
+
- Add a read-only public capsule method to the authenticated client.
|
|
8
|
+
- Preserve public capsule server error messages and make the package build self-contained with its Node type dependency.
|
|
9
|
+
|
|
3
10
|
## 0.1.2
|
|
4
11
|
|
|
5
12
|
- Publish the current tested client with registry-facing documentation aligned to the supported API and release path.
|
package/README.md
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
<img src="https://tidelight.app/tidelight-mark.svg" alt="Tidelight" width="56" height="56" />
|
|
3
3
|
<h1>Tidelight TypeScript SDK</h1>
|
|
4
4
|
<p><strong>Typed access to Tidelight Intelligence Cloud API v1.</strong></p>
|
|
5
|
-
<p><a href="https://tidelight.app">Product</a> · <a href="https://dev.tidelight.app/api">API guide</a> · <a href="https://github.com/TidelightOrg/tidelight">
|
|
5
|
+
<p><a href="https://tidelight.app">Product</a> · <a href="https://dev.tidelight.app/api">API guide</a> · <a href="https://github.com/TidelightOrg/tidelight">canonical repository</a></p>
|
|
6
|
+
<p><a href="README.zh-CN.md">简体中文版本 / Chinese README</a></p>
|
|
6
7
|
</div>
|
|
7
8
|
|
|
8
9
|
---
|
|
9
10
|
|
|
10
|
-
The official TypeScript / JavaScript client supports tokenized-equity market listings, asynchronous company research jobs,
|
|
11
|
+
The official TypeScript / JavaScript client supports tokenized-equity market listings, asynchronous company research jobs, synchronous AgentKey research, research webhooks, and read-only public Decision Capsule verification. It preserves provider provenance and API error context, with bounded polling, timeouts, and retries.
|
|
12
|
+
|
|
13
|
+
The npm release `0.1.2` predates `researchWithAgentKey` and public Decision Capsule verification. Use the [source build](#build-and-test-from-source) for these methods or call the [hosted AgentKey API](https://dev.tidelight.app/#agentkey) with a scoped key.
|
|
11
14
|
|
|
12
15
|
## Install
|
|
13
16
|
|
|
@@ -39,14 +42,39 @@ for (const instrument of page.data) {
|
|
|
39
42
|
| --- | --- | --- |
|
|
40
43
|
| Tokenized-equity spot listings and pagination | `market:read` | `listTokenizedEquities`, `tokenizedEquities` |
|
|
41
44
|
| Company research snapshots | `research:run` | `startCompanyResearch`, `getResearchJob`, `cancelResearchJob`, `waitForResearchJob` |
|
|
45
|
+
| AgentKey research across discovered read-only tools | `research:run` | `researchWithAgentKey` |
|
|
42
46
|
| Research webhooks and delivery history | `alerts:manage` | `createWebhook`, `updateWebhook`, `listWebhooks`, `listWebhookDeliveries` |
|
|
47
|
+
| Public Decision Capsule copies | Public bearer link | `getPublicDecisionCapsule`, `verifyPublicDecisionCapsule` |
|
|
43
48
|
|
|
44
49
|
A tokenized-equity spot instrument is not a direct share or a stock perpetual. Market data availability follows the service's provider terms gate. The client returns that decision without inventing substitute data.
|
|
45
50
|
|
|
51
|
+
AgentKey research example (the query is synchronous and is never automatically retried because upstream tools may consume credits):
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const result = await client.researchWithAgentKey(
|
|
55
|
+
"Explain NVIDIA's stock reaction to its latest earnings using Yahoo Finance and Google News.",
|
|
56
|
+
{ ticker: "NVDA" },
|
|
57
|
+
);
|
|
58
|
+
console.log(result.tools, result.sources);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The server selects and describes up to two relevant read-only AgentKey tools and returns cost and source provenance. Treat AgentKey tool data as untrusted external input. Your project key needs `research:run`; the AgentKey master key remains server-side.
|
|
62
|
+
|
|
46
63
|
## Reliability and security
|
|
47
64
|
|
|
48
65
|
Requests have a 10-second default timeout. Network errors, `429`, and transient `5xx` responses receive at most two bounded retries by default. Webhook mutations are not automatically retried because the API does not accept webhook idempotency keys. Errors retain the HTTP status, stable API code, and request ID; raw provider bodies and API keys are not returned.
|
|
49
66
|
|
|
67
|
+
Public capsule links are fetched from `tidelight.app` without an API key and are verified locally against the disclosed snapshot's SHA-256 digest. Pass `publicBaseUrl` only for a trusted HTTPS origin or local development. Digest verification detects changed bytes relative to the supplied digest; it does not prove authorship, source authenticity, or research quality.
|
|
68
|
+
|
|
69
|
+
Use the standalone helper to verify a shared capsule without constructing an authenticated client:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { getPublicDecisionCapsule } from "@tidelight/sdk";
|
|
73
|
+
|
|
74
|
+
const capsule = await getPublicDecisionCapsule(process.env.TIDELIGHT_PUBLIC_CAPSULE_TOKEN!);
|
|
75
|
+
console.log(capsule.integrityHash, capsule.snapshot);
|
|
76
|
+
```
|
|
77
|
+
|
|
50
78
|
Webhook creation and secret rotation return a one-time signing secret. **TODO: Persist** it in your approved secret manager immediately. Do not print it; it cannot be recovered by listing the endpoint.
|
|
51
79
|
|
|
52
80
|
## Build and test from source
|
|
@@ -56,7 +84,7 @@ npm ci
|
|
|
56
84
|
npm test
|
|
57
85
|
```
|
|
58
86
|
|
|
59
|
-
The SDK source is maintained in [`sdk/typescript`](https://github.com/TidelightOrg/tidelight/tree/main/sdk/typescript) in the
|
|
87
|
+
The SDK source is maintained in [`sdk/typescript`](https://github.com/TidelightOrg/tidelight/tree/main/sdk/typescript) in the canonical repository. The standalone [TypeScript repository](https://github.com/TidelightOrg/tidelight-sdk) is a synchronized source mirror. Make source changes in the canonical repository.
|
|
60
88
|
|
|
61
89
|
## Further reading
|
|
62
90
|
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,28 @@ export type ResearchJob = {
|
|
|
34
34
|
retry_at: string | null;
|
|
35
35
|
request_id: string;
|
|
36
36
|
};
|
|
37
|
+
export type AgentKeyResearchResponse = {
|
|
38
|
+
provider: "agentkey";
|
|
39
|
+
query: string;
|
|
40
|
+
status: "complete";
|
|
41
|
+
tools: Array<{
|
|
42
|
+
name: string;
|
|
43
|
+
provider: string;
|
|
44
|
+
cost_credits: number;
|
|
45
|
+
data: unknown;
|
|
46
|
+
}>;
|
|
47
|
+
sources: Array<{
|
|
48
|
+
title: string;
|
|
49
|
+
url: string;
|
|
50
|
+
publisher: string;
|
|
51
|
+
publishedAt: string | null;
|
|
52
|
+
snippet: string;
|
|
53
|
+
via: "AgentKey";
|
|
54
|
+
tool: string;
|
|
55
|
+
}>;
|
|
56
|
+
limitations: string[];
|
|
57
|
+
request_id: string;
|
|
58
|
+
};
|
|
37
59
|
export type WebhookEvent = "research.job.completed" | "research.job.failed";
|
|
38
60
|
export type WebhookEndpoint = {
|
|
39
61
|
id: string;
|
|
@@ -86,16 +108,33 @@ export type WebhookEndpointUpdate = {
|
|
|
86
108
|
enabled?: boolean;
|
|
87
109
|
rotate_secret?: true;
|
|
88
110
|
};
|
|
111
|
+
export type PublicDecisionCapsule = {
|
|
112
|
+
schemaVersion: 1;
|
|
113
|
+
publishedAt: string;
|
|
114
|
+
snapshot: Record<string, unknown>;
|
|
115
|
+
integrityHash: string;
|
|
116
|
+
hashAlgorithm: "sha256";
|
|
117
|
+
integrity: "valid";
|
|
118
|
+
};
|
|
119
|
+
type Fetch = typeof fetch;
|
|
120
|
+
export declare function verifyPublicDecisionCapsule(publication: Pick<PublicDecisionCapsule, "snapshot" | "integrityHash" | "hashAlgorithm">): boolean;
|
|
121
|
+
export declare function getPublicDecisionCapsule(token: string, options?: {
|
|
122
|
+
publicBaseUrl?: string;
|
|
123
|
+
timeoutMs?: number;
|
|
124
|
+
maxRetries?: number;
|
|
125
|
+
signal?: AbortSignal;
|
|
126
|
+
fetch?: Fetch;
|
|
127
|
+
}): Promise<PublicDecisionCapsule>;
|
|
89
128
|
export declare class TidelightApiError extends Error {
|
|
90
129
|
readonly status: number;
|
|
91
130
|
readonly code: string;
|
|
92
131
|
readonly requestId: string | null;
|
|
93
132
|
constructor(status: number, code: string, message: string, requestId: string | null);
|
|
94
133
|
}
|
|
95
|
-
type Fetch = typeof fetch;
|
|
96
134
|
export type TidelightClientOptions = {
|
|
97
135
|
apiKey: string;
|
|
98
136
|
baseUrl?: string;
|
|
137
|
+
publicBaseUrl?: string;
|
|
99
138
|
timeoutMs?: number;
|
|
100
139
|
maxRetries?: number;
|
|
101
140
|
fetch?: Fetch;
|
|
@@ -103,6 +142,7 @@ export type TidelightClientOptions = {
|
|
|
103
142
|
export declare class TidelightClient {
|
|
104
143
|
private readonly apiKey;
|
|
105
144
|
private readonly baseUrl;
|
|
145
|
+
private readonly publicBaseUrl;
|
|
106
146
|
private readonly timeoutMs;
|
|
107
147
|
private readonly maxRetries;
|
|
108
148
|
private readonly transport;
|
|
@@ -113,6 +153,9 @@ export declare class TidelightClient {
|
|
|
113
153
|
underlyingTicker?: string;
|
|
114
154
|
signal?: AbortSignal;
|
|
115
155
|
}): Promise<InstrumentPage>;
|
|
156
|
+
getPublicDecisionCapsule(token: string, options?: {
|
|
157
|
+
signal?: AbortSignal;
|
|
158
|
+
}): Promise<PublicDecisionCapsule>;
|
|
116
159
|
startCompanyResearch(ticker: string, idempotencyKey: string, options?: {
|
|
117
160
|
signal?: AbortSignal;
|
|
118
161
|
}): Promise<{
|
|
@@ -121,6 +164,11 @@ export declare class TidelightClient {
|
|
|
121
164
|
duplicate: boolean;
|
|
122
165
|
request_id: string;
|
|
123
166
|
}>;
|
|
167
|
+
researchWithAgentKey(query: string, options?: {
|
|
168
|
+
ticker?: string;
|
|
169
|
+
timeoutMs?: number;
|
|
170
|
+
signal?: AbortSignal;
|
|
171
|
+
}): Promise<AgentKeyResearchResponse>;
|
|
124
172
|
getResearchJob(jobId: string, options?: {
|
|
125
173
|
signal?: AbortSignal;
|
|
126
174
|
}): Promise<ResearchJob>;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,96 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
function canonicalJson(value) {
|
|
3
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
4
|
+
return JSON.stringify(value);
|
|
5
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
6
|
+
return JSON.stringify(value);
|
|
7
|
+
if (Array.isArray(value))
|
|
8
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
9
|
+
if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
10
|
+
return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
|
|
11
|
+
}
|
|
12
|
+
throw new TypeError("Public capsule snapshots must contain JSON values only.");
|
|
13
|
+
}
|
|
14
|
+
export function verifyPublicDecisionCapsule(publication) {
|
|
15
|
+
if (publication.hashAlgorithm !== "sha256" || !/^[a-f0-9]{64}$/.test(publication.integrityHash))
|
|
16
|
+
return false;
|
|
17
|
+
try {
|
|
18
|
+
return createHash("sha256").update(canonicalJson(publication.snapshot), "utf8").digest("hex") === publication.integrityHash;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function getPublicDecisionCapsule(token, options = {}) {
|
|
25
|
+
if (!/^[A-Za-z0-9_-]{43}$/.test(token))
|
|
26
|
+
throw new TypeError("Invalid public capsule token.");
|
|
27
|
+
if (options.signal?.aborted)
|
|
28
|
+
throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
29
|
+
const base = new URL(options.publicBaseUrl ?? "https://tidelight.app");
|
|
30
|
+
if ((base.protocol !== "https:" && !(base.protocol === "http:" && ["localhost", "127.0.0.1"].includes(base.hostname))) || base.username || base.password || base.search || base.hash || base.pathname !== "/")
|
|
31
|
+
throw new TypeError("publicBaseUrl must be a trusted HTTPS origin without a path, credentials, query, or fragment.");
|
|
32
|
+
const timeoutMs = options.timeoutMs ?? 10000, maxRetries = options.maxRetries ?? 2, transport = options.fetch ?? fetch;
|
|
33
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 100 || timeoutMs > 120000 || !Number.isInteger(maxRetries) || maxRetries < 0 || maxRetries > 5)
|
|
34
|
+
throw new RangeError("Public capsule timeout or retry limit is out of range.");
|
|
35
|
+
const url = `${base.origin}/api/decision-capsules/public/${token}`;
|
|
36
|
+
const pause = (attempt, retryAfter) => new Promise((resolve, reject) => {
|
|
37
|
+
const seconds = retryAfter && /^\d+$/.test(retryAfter) ? Number(retryAfter) : null;
|
|
38
|
+
const timer = setTimeout(done, seconds === null ? Math.min(2000, 250 * 2 ** attempt) : Math.min(5000, seconds * 1000));
|
|
39
|
+
function done() { options.signal?.removeEventListener("abort", abort); resolve(); }
|
|
40
|
+
function abort() { clearTimeout(timer); options.signal?.removeEventListener("abort", abort); reject(options.signal?.reason); }
|
|
41
|
+
if (options.signal?.aborted)
|
|
42
|
+
abort();
|
|
43
|
+
else
|
|
44
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
45
|
+
});
|
|
46
|
+
for (let attempt = 0;; attempt++) {
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
const onAbort = () => controller.abort(options.signal?.reason);
|
|
49
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
50
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
51
|
+
let response;
|
|
52
|
+
let payload;
|
|
53
|
+
try {
|
|
54
|
+
response = await transport(url, { headers: { Accept: "application/json" }, signal: controller.signal, redirect: "error" });
|
|
55
|
+
try {
|
|
56
|
+
payload = await response.json();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error instanceof SyntaxError)
|
|
60
|
+
payload = null;
|
|
61
|
+
else
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (options.signal?.aborted)
|
|
67
|
+
throw error;
|
|
68
|
+
if (attempt >= maxRetries)
|
|
69
|
+
throw new TidelightApiError(0, "network_error", "The public capsule could not be reached.", null);
|
|
70
|
+
await pause(attempt);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
76
|
+
}
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const rawError = payload && typeof payload === "object" && "error" in payload ? payload.error : null;
|
|
79
|
+
const detail = typeof rawError === "string" ? { message: rawError } : rawError && typeof rawError === "object" ? rawError : {};
|
|
80
|
+
if ([429, 502, 503, 504].includes(response.status) && attempt < maxRetries) {
|
|
81
|
+
await pause(attempt, response.headers.get("retry-after"));
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
throw new TidelightApiError(response.status, typeof detail.code === "string" ? detail.code : "public_capsule_error", typeof detail.message === "string" ? detail.message : "Public capsule request failed.", typeof detail.request_id === "string" ? detail.request_id : response.headers.get("x-request-id"));
|
|
85
|
+
}
|
|
86
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
87
|
+
throw new TidelightApiError(response.status, "invalid_response", "The public capsule response is invalid.", response.headers.get("x-request-id"));
|
|
88
|
+
const publication = payload;
|
|
89
|
+
if (publication.schemaVersion !== 1 || !publication.snapshot || typeof publication.snapshot !== "object" || publication.integrity !== "valid" || !verifyPublicDecisionCapsule(publication))
|
|
90
|
+
throw new TidelightApiError(409, "integrity_verification_failed", "Public capsule integrity verification failed.", response.headers.get("x-request-id"));
|
|
91
|
+
return publication;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
1
94
|
export class TidelightApiError extends Error {
|
|
2
95
|
status;
|
|
3
96
|
code;
|
|
@@ -14,6 +107,7 @@ const DEFAULT_URL = "https://api.tidelight.app/v1";
|
|
|
14
107
|
export class TidelightClient {
|
|
15
108
|
apiKey;
|
|
16
109
|
baseUrl;
|
|
110
|
+
publicBaseUrl;
|
|
17
111
|
timeoutMs;
|
|
18
112
|
maxRetries;
|
|
19
113
|
transport;
|
|
@@ -31,6 +125,10 @@ export class TidelightClient {
|
|
|
31
125
|
throw new TypeError("maxRetries must be 0 to 5.");
|
|
32
126
|
this.apiKey = options.apiKey;
|
|
33
127
|
this.baseUrl = base.toString().replace(/\/$/, "");
|
|
128
|
+
const publicBase = new URL(options.publicBaseUrl ?? (base.hostname === "api.tidelight.app" ? "https://tidelight.app" : base.origin));
|
|
129
|
+
if ((publicBase.protocol !== "https:" && !(publicBase.protocol === "http:" && ["localhost", "127.0.0.1"].includes(publicBase.hostname))) || publicBase.username || publicBase.password || publicBase.search || publicBase.hash || publicBase.pathname !== "/")
|
|
130
|
+
throw new TypeError("publicBaseUrl must be a trusted HTTPS origin without a path, credentials, query, or fragment.");
|
|
131
|
+
this.publicBaseUrl = publicBase.origin;
|
|
34
132
|
this.timeoutMs = options.timeoutMs ?? 10000;
|
|
35
133
|
this.maxRetries = options.maxRetries ?? 2;
|
|
36
134
|
this.transport = options.fetch ?? fetch;
|
|
@@ -92,6 +190,9 @@ export class TidelightClient {
|
|
|
92
190
|
throw new TidelightApiError(response.status, typeof detail.code === "string" ? detail.code : "api_error", typeof detail.message === "string" ? detail.message : "Tidelight API request failed.", typeof detail.request_id === "string" ? detail.request_id : response.headers.get("x-request-id"));
|
|
93
191
|
}
|
|
94
192
|
}
|
|
193
|
+
async getPublicDecisionCapsule(token, options = {}) {
|
|
194
|
+
return getPublicDecisionCapsule(token, { publicBaseUrl: this.publicBaseUrl, timeoutMs: this.timeoutMs, maxRetries: this.maxRetries, signal: options.signal, fetch: this.transport });
|
|
195
|
+
}
|
|
95
196
|
async startCompanyResearch(ticker, idempotencyKey, options = {}) {
|
|
96
197
|
if (!/^[A-Za-z][A-Za-z0-9.]{0,9}$/.test(ticker))
|
|
97
198
|
throw new TypeError("ticker must be a supported stock symbol.");
|
|
@@ -99,6 +200,17 @@ export class TidelightClient {
|
|
|
99
200
|
throw new TypeError("idempotencyKey must be 8 to 128 valid characters.");
|
|
100
201
|
return this.jobRequest("/research/jobs", "POST", { ticker }, idempotencyKey, options.signal);
|
|
101
202
|
}
|
|
203
|
+
async researchWithAgentKey(query, options = {}) {
|
|
204
|
+
const normalized = query.trim().replace(/\s+/g, " ");
|
|
205
|
+
if (normalized.length < 5 || normalized.length > 500)
|
|
206
|
+
throw new TypeError("query must be 5 to 500 characters.");
|
|
207
|
+
if (options.ticker !== undefined && !/^[A-Za-z][A-Za-z0-9.]{0,9}$/.test(options.ticker))
|
|
208
|
+
throw new TypeError("ticker must be a valid stock symbol.");
|
|
209
|
+
const timeoutMs = options.timeoutMs ?? 45_000;
|
|
210
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 1_000 || timeoutMs > 120_000)
|
|
211
|
+
throw new RangeError("timeoutMs must be 1000 to 120000.");
|
|
212
|
+
return this.jobRequest("/research/agentkey", "POST", { query: normalized, ...(options.ticker ? { ticker: options.ticker.toUpperCase() } : {}) }, undefined, options.signal, false, timeoutMs);
|
|
213
|
+
}
|
|
102
214
|
async getResearchJob(jobId, options = {}) {
|
|
103
215
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(jobId))
|
|
104
216
|
throw new TypeError("Invalid research job ID.");
|
|
@@ -188,13 +300,15 @@ export class TidelightClient {
|
|
|
188
300
|
if (input.rotate_secret !== undefined && input.rotate_secret !== true)
|
|
189
301
|
throw new TypeError("rotate_secret can only be true.");
|
|
190
302
|
}
|
|
191
|
-
async jobRequest(path, method, body, idempotencyKey, signal, retrySafe = true) {
|
|
303
|
+
async jobRequest(path, method, body, idempotencyKey, signal, retrySafe = true, timeoutMs = this.timeoutMs) {
|
|
192
304
|
const url = `${this.baseUrl}${path}`;
|
|
193
305
|
const retryLimit = retrySafe ? this.maxRetries : 0;
|
|
194
306
|
for (let attempt = 0;; attempt++) {
|
|
307
|
+
if (signal?.aborted)
|
|
308
|
+
throw signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
195
309
|
const controller = new AbortController();
|
|
196
310
|
const abort = () => controller.abort(signal?.reason);
|
|
197
|
-
const timer = setTimeout(() => controller.abort(),
|
|
311
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
198
312
|
signal?.addEventListener("abort", abort, { once: true });
|
|
199
313
|
let response;
|
|
200
314
|
let payload;
|
package/package.json
CHANGED