@superdurable/connectors-sdk 0.1.0 → 0.1.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.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Connector TypeScript SDK
|
|
2
2
|
|
|
3
|
-
`@superdurable/connectors-sdk` is the provider-neutral TypeScript SDK for Dex connectors. It provides stable value contracts, typed Query and Mutation operations, Dex Step factories, credential refresh, OAuth token exchanges, HTTP safety helpers, project configuration loading, scripted mocks, and single-dispatch marker decisions. The package is at version `0.1.
|
|
3
|
+
`@superdurable/connectors-sdk` is the provider-neutral TypeScript SDK for Dex connectors. It provides stable value contracts, typed Query and Mutation operations, Dex Step factories, credential refresh, OAuth token exchanges, HTTP safety helpers, project configuration loading, scripted mocks, and single-dispatch marker decisions. The package is at version `0.1.1`, requires Node 22 or 24, and uses `@superdurable/dex` 1.28.0 or newer. It is ESM-only, matching Dex: use `import`; direct `require()` fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
|
|
4
4
|
|
|
5
5
|
Install dependencies and verify the package from this directory:
|
|
6
6
|
|
|
@@ -99,7 +99,7 @@ if (result.kind !== 'branch' || retryPolicy.totalDurationMs !== 3600000 || crede
|
|
|
99
99
|
|
|
100
100
|
## Provider HTTP
|
|
101
101
|
|
|
102
|
-
The [complete runnable HTTP example](examples/providerhttp.mjs) sends one bounded request to a local server. `sendProviderRequest` resolves every address before connecting, pins the chosen address, and returns redirects without following them. `ProviderTransportError.isProvablyNotSent` is true
|
|
102
|
+
The [complete runnable HTTP example](examples/providerhttp.mjs) sends one bounded request to a local server. `sendProviderRequest` resolves every address before connecting, pins the chosen address for IP literals and hostnames, and returns redirects without following them. `ProviderTransportError.isProvablyNotSent` is true for DNS, TCP connect, or TLS handshake failures before a usable connection could send HTTP bytes. Failures after connection or request writing have an unknown dispatch outcome, matching the Go connectors' DNS, connect, TLS, and obtained-connection trace.
|
|
103
103
|
`BodyTooLargeError` preserves the response `status` and `headers`, so a caller can classify a 429 or 503 and its `Retry-After` even when the response body exceeds its limit.
|
|
104
104
|
|
|
105
105
|
```js
|
|
@@ -84,7 +84,7 @@ var AddressRefusal = class extends Error {
|
|
|
84
84
|
reason;
|
|
85
85
|
};
|
|
86
86
|
var ProviderTransportError = class extends Error {
|
|
87
|
-
/** True only when
|
|
87
|
+
/** True only when the request failed before a usable connection could send HTTP bytes. */
|
|
88
88
|
constructor(isProvablyNotSent) {
|
|
89
89
|
super("provider request failed in transport");
|
|
90
90
|
this.isProvablyNotSent = isProvablyNotSent;
|
|
@@ -181,10 +181,10 @@ async function sendProviderRequest(request) {
|
|
|
181
181
|
method: request.method,
|
|
182
182
|
headers: request.headers,
|
|
183
183
|
signal,
|
|
184
|
-
lookup: (_hostname,
|
|
184
|
+
lookup: (_hostname, options2, callback) => options2?.all ? callback(null, [{ address: selected.address, family: selected.family }]) : callback(null, selected.address, selected.family)
|
|
185
185
|
};
|
|
186
186
|
return new Promise((resolve, reject) => {
|
|
187
|
-
let
|
|
187
|
+
let hasConnected = false;
|
|
188
188
|
let hasWrittenRequest = false;
|
|
189
189
|
let clientRequest;
|
|
190
190
|
try {
|
|
@@ -200,17 +200,20 @@ async function sendProviderRequest(request) {
|
|
|
200
200
|
reject(new ProviderTransportError(true));
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
|
-
clientRequest.on("socket", () => {
|
|
204
|
-
|
|
203
|
+
clientRequest.on("socket", (socket) => {
|
|
204
|
+
if (!socket.connecting) hasConnected = true;
|
|
205
|
+
socket.once(parsed.protocol === "https:" ? "secureConnect" : "connect", () => {
|
|
206
|
+
hasConnected = true;
|
|
207
|
+
});
|
|
205
208
|
});
|
|
206
209
|
clientRequest.on("finish", () => {
|
|
207
210
|
hasWrittenRequest = true;
|
|
208
211
|
});
|
|
209
|
-
clientRequest.on("error", () => reject(new ProviderTransportError(!
|
|
212
|
+
clientRequest.on("error", () => reject(new ProviderTransportError(!hasConnected && !hasWrittenRequest)));
|
|
210
213
|
try {
|
|
211
214
|
clientRequest.end(request.body);
|
|
212
215
|
} catch {
|
|
213
|
-
reject(new ProviderTransportError(!
|
|
216
|
+
reject(new ProviderTransportError(!hasConnected && !hasWrittenRequest));
|
|
214
217
|
}
|
|
215
218
|
});
|
|
216
219
|
}
|
|
@@ -19,7 +19,7 @@ declare class AddressRefusal extends Error {
|
|
|
19
19
|
/** Sanitized transport failure with positive evidence about dispatch. */
|
|
20
20
|
declare class ProviderTransportError extends Error {
|
|
21
21
|
readonly isProvablyNotSent: boolean;
|
|
22
|
-
/** True only when
|
|
22
|
+
/** True only when the request failed before a usable connection could send HTTP bytes. */
|
|
23
23
|
constructor(isProvablyNotSent: boolean);
|
|
24
24
|
}
|
|
25
25
|
/** Public-only HTTPS or explicitly owned private-network HTTP. */
|