@needmoretruth/nmts-cli 0.40.0 → 0.42.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.
- package/CHANGELOG.md +23 -0
- package/README.ko.md +27 -1
- package/README.md +29 -1
- package/dist/api-advice.js +6 -0
- package/dist/api.d.ts +10 -1
- package/dist/api.js +14 -3
- package/dist/arg-options.d.ts +21 -0
- package/dist/args.js +12 -1
- package/dist/artifact-about.d.ts +1 -1
- package/dist/commands/create-link.d.ts +9 -0
- package/dist/commands/create-link.js +31 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.js +17 -0
- package/dist/commands/login-passphrase.d.ts +13 -0
- package/dist/commands/login-passphrase.js +64 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.js +15 -55
- package/dist/commands/openers-attach.d.ts +38 -0
- package/dist/commands/openers-attach.js +97 -0
- package/dist/commands/openers.d.ts +23 -0
- package/dist/commands/openers.js +195 -0
- package/dist/crypto-surface.d.ts +28 -0
- package/dist/crypto-surface.js +7 -0
- package/dist/extend-chain.js +2 -1
- package/dist/help.js +15 -0
- package/dist/main.js +11 -12
- package/dist/openers/doors.d.ts +65 -0
- package/dist/openers/doors.js +97 -0
- package/dist/openers/hints.d.ts +22 -0
- package/dist/openers/hints.js +11 -0
- package/dist/openers/sign.d.ts +56 -0
- package/dist/openers/sign.js +202 -0
- package/dist/openers/wallet.d.ts +71 -0
- package/dist/openers/wallet.js +210 -0
- package/dist/openers-key-file.d.ts +14 -0
- package/dist/openers-key-file.js +99 -0
- package/dist/openers.d.ts +7 -0
- package/dist/openers.js +21 -0
- package/dist/portable.d.ts +3 -0
- package/dist/portable.js +8 -0
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/progress.d.ts +4 -0
- package/dist/progress.js +7 -2
- package/dist/reach.d.ts +40 -0
- package/dist/reach.js +52 -0
- package/dist/risk.d.ts +11 -0
- package/dist/risk.js +15 -0
- package/dist/sui-rpc.js +2 -1
- package/dist/upload-wallet-chain.js +6 -1
- package/dist/walrus-write.js +9 -4
- package/dist/walrus.d.ts +33 -6
- package/dist/walrus.js +48 -8
- package/docs/commands/openers.md +31 -0
- package/package.json +5 -1
- package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +54 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm.js +108 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +4 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// The only wallet a terminal has: one `suiprivkey1…` line in a file this run is pointed at.
|
|
2
|
+
//
|
|
3
|
+
// ⛔ THE VALUE IS NEVER AN ARGUMENT AND NEVER PRINTED. A secret on a command line is readable by
|
|
4
|
+
// any process on the machine and is recorded by the shell, which is why every option table in
|
|
5
|
+
// this tool names paths and not values (`args.ts`). What this file takes is a PATH; what it
|
|
6
|
+
// hands back is a function that signs one message, and an address.
|
|
7
|
+
//
|
|
8
|
+
// ⛔ AND THE KEY DOES NOT COME BACK OUT. `wallet-sign.ts` keeps that rule for the wallets this
|
|
9
|
+
// account's own NMTS key derives; this is the other kind — somebody else's wallet, held for one
|
|
10
|
+
// run — and the rule is the same: the keypair is built inside a closure, asked for signatures
|
|
11
|
+
// over one message, and never returned, logged or copied.
|
|
12
|
+
//
|
|
13
|
+
// ⛔ IT CATCHES ITS OWN PARSER. `errors.ts` says why: an unknown error's message goes to stderr
|
|
14
|
+
// verbatim, and a decoder that fails on a secret-bearing file has been measured quoting the
|
|
15
|
+
// input back. Every failure below is this tool's own sentence, naming the path and never the
|
|
16
|
+
// contents.
|
|
17
|
+
//
|
|
18
|
+
// ⚠ NODE ONLY, WHICH IS WHY IT IS NOT IN `openers/`. That folder is bundled into a page by the
|
|
19
|
+
// SDK's browser entry; a page's wallet is an extension, and this one is a file on a disk.
|
|
20
|
+
import { readFileSync } from "node:fs";
|
|
21
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
22
|
+
import { Secp256k1Keypair } from "@mysten/sui/keypairs/secp256k1";
|
|
23
|
+
import { Secp256r1Keypair } from "@mysten/sui/keypairs/secp256r1";
|
|
24
|
+
import { decodeSuiPrivateKey } from "@mysten/sui/cryptography";
|
|
25
|
+
import { NmtsError } from "./errors.js";
|
|
26
|
+
/**
|
|
27
|
+
* The wallet held in `path`, ready to sign the opener message.
|
|
28
|
+
*
|
|
29
|
+
* The file holds one `suiprivkey1…` line — what `sui keytool export` writes and what every Sui
|
|
30
|
+
* tool reads. Surrounding whitespace and a trailing newline are ignored, because writing a secret
|
|
31
|
+
* to a file with `echo` appends one and refusing it would be a puzzle with no clue.
|
|
32
|
+
*/
|
|
33
|
+
export function walletFromKeyFile(path) {
|
|
34
|
+
const keypair = keypairFrom(readOneLine(path), path);
|
|
35
|
+
return {
|
|
36
|
+
address: keypair.toSuiAddress(),
|
|
37
|
+
// ⛔ THE CLOSURE HOLDS THE KEYPAIR AND NOTHING HOLDS THE CLOSURE PAST THE RUN. What it answers
|
|
38
|
+
// is the wallet standard's own pair — the serialized signature, and the bytes it signed, so
|
|
39
|
+
// that the layer above compares them against the message it built rather than trusting it.
|
|
40
|
+
sign: async (message) => keypair.signPersonalMessage(message),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** The first line with anything on it, or this tool's own refusal. */
|
|
44
|
+
function readOneLine(path) {
|
|
45
|
+
let raw;
|
|
46
|
+
try {
|
|
47
|
+
raw = readFileSync(path, "utf8");
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// ⛔ THE CAUSE IS NOT CARRIED. Node's own message for a read failure quotes the path, which is
|
|
51
|
+
// fine, but a decoding failure inside it would quote the contents, which is not.
|
|
52
|
+
throw new NmtsError(`Could not read ${path}.`, {
|
|
53
|
+
exitCode: 2,
|
|
54
|
+
// Copy facts — the next step. Facts: the file holds one line beginning `suiprivkey1`, it is
|
|
55
|
+
// read and never copied or written to, and nothing was signed.
|
|
56
|
+
nextStep: "Nothing was signed. Point --sui-key-file at a file holding one `suiprivkey1…` line.",
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const line = raw.split("\n").map((l) => l.trim()).find((l) => l !== "");
|
|
60
|
+
if (line === undefined || !line.startsWith("suiprivkey1")) {
|
|
61
|
+
throw new NmtsError(`${path} does not hold a Sui private key.`, {
|
|
62
|
+
exitCode: 2,
|
|
63
|
+
nextStep: "Nothing was signed. The file holds one line beginning `suiprivkey1`.",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return line;
|
|
67
|
+
}
|
|
68
|
+
/** The keypair that line names, for the three schemes an opener may use. */
|
|
69
|
+
function keypairFrom(line, path) {
|
|
70
|
+
let decoded;
|
|
71
|
+
try {
|
|
72
|
+
decoded = decodeSuiPrivateKey(line);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
throw new NmtsError(`${path} does not hold a Sui private key this version can read.`, {
|
|
76
|
+
exitCode: 2,
|
|
77
|
+
nextStep: "Nothing was signed. The line is the one `sui keytool export` writes.",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const { scheme, secretKey } = decoded;
|
|
81
|
+
try {
|
|
82
|
+
if (scheme === "ED25519")
|
|
83
|
+
return Ed25519Keypair.fromSecretKey(secretKey);
|
|
84
|
+
if (scheme === "Secp256k1")
|
|
85
|
+
return Secp256k1Keypair.fromSecretKey(secretKey);
|
|
86
|
+
if (scheme === "Secp256r1")
|
|
87
|
+
return Secp256r1Keypair.fromSecretKey(secretKey);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
// The keypair copied what it needed; this buffer is the only other one.
|
|
91
|
+
secretKey.fill(0);
|
|
92
|
+
}
|
|
93
|
+
// ⚠ An allow list, exactly as the layer above keeps: a scheme nobody has judged is refused for
|
|
94
|
+
// being unknown rather than let through for being new.
|
|
95
|
+
throw new NmtsError(`WALLET_UNKNOWN_SCHEME: ${path} holds a ${scheme} key.`, {
|
|
96
|
+
exitCode: 4,
|
|
97
|
+
nextStep: "Nothing was signed. An opener is held by an Ed25519, secp256k1 or secp256r1 wallet.",
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { OpenerHints } from "./openers/hints.ts";
|
|
2
|
+
export { fetchSlot, KIND_PASSKEY, KIND_WALLET, listOpeners, putOpener, removeOpener, } from "./openers/doors.ts";
|
|
3
|
+
export type { OpenerAccess, OpenerInfo, OpenerListing } from "./openers/doors.ts";
|
|
4
|
+
export { openerMessage, withRepeatedSignature, withSignature } from "./openers/sign.ts";
|
|
5
|
+
export type { SignedMessage, SignWallet, WalletOpener, WalletSignature } from "./openers/sign.ts";
|
|
6
|
+
export { addWallet, refuseIfWalletOpensAnAccount, removeWallet, signInWithWallet, walletSlot, } from "./openers/wallet.ts";
|
|
7
|
+
export type { AttachedWallet, WalletSignIn } from "./openers/wallet.ts";
|
package/dist/openers.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Wallet sign-in without a terminal: the message, the signature's judgement, and the four doors an
|
|
2
|
+
// opener travels through — decided and handed back rather than printed.
|
|
3
|
+
//
|
|
4
|
+
// ⛔ ONE IMPLEMENTATION, FOUR CALLERS, which is the whole reason this entry exists. `nmts login
|
|
5
|
+
// --wallet`, `nmts openers`, the SDK and a page are surfaces over these functions: the prompt,
|
|
6
|
+
// the key file, the button, the exit code belong to them. A second implementation of "which
|
|
7
|
+
// bytes are signed, what is compared, when the key bytes are wiped" would be a second place for
|
|
8
|
+
// rules about the account's root secret to be got right — and the copy nobody re-reads is the
|
|
9
|
+
// one that quietly disagrees.
|
|
10
|
+
//
|
|
11
|
+
// ⛔ WHAT A CALLER IMPORTS IS THIS NAME — `@needmoretruth/nmts-cli/openers` — so the pieces in
|
|
12
|
+
// `openers/` can be split and joined without a single caller changing. Nothing in the folder
|
|
13
|
+
// reaches for `node:`: the SDK's browser entry bundles what this exports, and the one thing
|
|
14
|
+
// that does touch a disk (reading a `suiprivkey1…` file) is the command line's own.
|
|
15
|
+
//
|
|
16
|
+
// ⛔ AND NOTHING IN THE FOLDER KEEPS A SIGNATURE. It is lent to one piece of work and dropped;
|
|
17
|
+
// nothing exported from here answers with it, and `cli/test/openers.test.ts` proves that the
|
|
18
|
+
// objects these functions return cannot reach one.
|
|
19
|
+
export { fetchSlot, KIND_PASSKEY, KIND_WALLET, listOpeners, putOpener, removeOpener, } from "./openers/doors.js";
|
|
20
|
+
export { openerMessage, withRepeatedSignature, withSignature } from "./openers/sign.js";
|
|
21
|
+
export { addWallet, refuseIfWalletOpensAnAccount, removeWallet, signInWithWallet, walletSlot, } from "./openers/wallet.js";
|
package/dist/portable.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { forgetHost, host, hostIsRegistered, registerHost } from "./host.ts";
|
|
2
2
|
export type { EngineHost, Host, HostName, StateHost, ZstdHost } from "./host.ts";
|
|
3
3
|
export { hostContract } from "./host-contract.ts";
|
|
4
|
+
export { forgetReach, reach, reachFetch, useReach } from "./reach.ts";
|
|
5
|
+
export type { Reach } from "./reach.ts";
|
|
4
6
|
export { concat, fromBase64Url, fromUtf8, toBase64Url, utf8 } from "./bytes.ts";
|
|
5
7
|
export { setZstdCodec, zstdCodec, zstdContentSize } from "./shared/lib/drive/zstd.ts";
|
|
6
8
|
export type { ZstdCodec } from "./shared/lib/drive/zstd.ts";
|
|
@@ -46,6 +48,7 @@ export { fetchFile, fetchWithKey } from "./download.ts";
|
|
|
46
48
|
export type { FetchedFile, FetchInput } from "./download.ts";
|
|
47
49
|
export type { PlaintextSink } from "./download-sink.ts";
|
|
48
50
|
export { AGGREGATOR_ENV_VAR, readBlob, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./walrus.ts";
|
|
51
|
+
export { relayHost, storageNodesThrough, suiRpcHosts } from "./walrus.ts";
|
|
49
52
|
export type { ReadOptions } from "./walrus.ts";
|
|
50
53
|
export { coinAmount, readBalances, walCoinType, walletAddress } from "./wallet.ts";
|
|
51
54
|
export type { ChainReader, CoinBalance, WalletBalances } from "./wallet.ts";
|
package/dist/portable.js
CHANGED
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
// The host every module below reaches for. A program that imported this entry point registers one.
|
|
20
20
|
export { forgetHost, host, hostIsRegistered, registerHost } from "./host.js";
|
|
21
21
|
export { hostContract } from "./host-contract.js";
|
|
22
|
+
// Where a caller says this client talks, and what it talks through — the addresses the
|
|
23
|
+
// command-line tool takes from its environment, and the one `fetch` every request here goes
|
|
24
|
+
// through. A library's caller has no environment to write, so this is how it says the same things.
|
|
25
|
+
export { forgetReach, reach, reachFetch, useReach } from "./reach.js";
|
|
22
26
|
// Bytes to text and back, in the two spellings the format uses.
|
|
23
27
|
export { concat, fromBase64Url, fromUtf8, toBase64Url, utf8 } from "./bytes.js";
|
|
24
28
|
// The file-list codec's zstd register (NCF-3 §6.3.4). A host fills it with the encoder its runtime
|
|
@@ -66,6 +70,10 @@ export { DEFAULT_UPLOAD_EPOCHS } from "./upload-wallet-plan.js";
|
|
|
66
70
|
// Downloading: fetching sealed parts from the storage network and opening them here.
|
|
67
71
|
export { fetchFile, fetchWithKey } from "./download.js";
|
|
68
72
|
export { AGGREGATOR_ENV_VAR, readBlob, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./walrus.js";
|
|
73
|
+
// ⛔ THE THREE ADDRESS ANSWERS, so that a caller — and a test — can ask what this client WILL talk
|
|
74
|
+
// to rather than finding out from a request that went somewhere else. Each reads what the
|
|
75
|
+
// caller said first, then the environment, then the network's own.
|
|
76
|
+
export { relayHost, storageNodesThrough, suiRpcHosts } from "./walrus.js";
|
|
69
77
|
// The wallet the NMTS key derives: reading it, and signing with it.
|
|
70
78
|
export { coinAmount, readBalances, walCoinType, walletAddress } from "./wallet.js";
|
|
71
79
|
export { chainReader } from "./wallet-chain.js";
|
package/dist/product.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const BINARY_NAME = "nmts";
|
|
|
9
9
|
* beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
|
|
10
10
|
* command importing the entry point is a cycle waiting to bite.
|
|
11
11
|
*/
|
|
12
|
-
export declare const VERSION = "0.
|
|
12
|
+
export declare const VERSION = "0.42.0";
|
|
13
13
|
/** Where the product lives, for messages that need to send somebody somewhere real. */
|
|
14
14
|
export declare const HOME_URL = "https://nmts.me";
|
|
15
15
|
/** The source, so a person holding only the built program can find what it was built from. */
|
package/dist/product.js
CHANGED
|
@@ -18,7 +18,7 @@ export const BINARY_NAME = "nmts";
|
|
|
18
18
|
* beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
|
|
19
19
|
* command importing the entry point is a cycle waiting to bite.
|
|
20
20
|
*/
|
|
21
|
-
export const VERSION = "0.
|
|
21
|
+
export const VERSION = "0.42.0";
|
|
22
22
|
/** Where the product lives, for messages that need to send somebody somewhere real. */
|
|
23
23
|
export const HOME_URL = "https://nmts.me";
|
|
24
24
|
/** The source, so a person holding only the built program can find what it was built from. */
|
package/dist/progress.d.ts
CHANGED
|
@@ -32,5 +32,9 @@ export declare class Progress {
|
|
|
32
32
|
*
|
|
33
33
|
* ⚠ `duplex: "half"` is required by the fetch specification for a streaming body and Node enforces
|
|
34
34
|
* it. Without it the request throws before a single byte is sent.
|
|
35
|
+
*
|
|
36
|
+
* ⛔ IT WRAPS `reachFetch`, NOT THE GLOBAL. Counting the bytes must not be a way around the
|
|
37
|
+
* function a caller asked every request to go through — this is the one request in an upload
|
|
38
|
+
* that carries the file.
|
|
35
39
|
*/
|
|
36
40
|
export declare function countingFetch(onSent: (sent: number, total: number) => void, chunkBytes?: number): (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
package/dist/progress.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// ⛔ THE TERMINAL SINK IS NOT HERE. Writing to a real stderr is Node's, so it is in
|
|
12
12
|
// `progress-node.ts`; what is left runs in a page, where the same reporter drives a caller's
|
|
13
13
|
// own `onProgress`.
|
|
14
|
+
import { reachFetch } from "./reach.js";
|
|
14
15
|
/** A reporter that says nothing. What `--json` gets, and what a test gets by default. */
|
|
15
16
|
export function silentSink() {
|
|
16
17
|
return { write: () => { }, interactive: false };
|
|
@@ -71,12 +72,16 @@ export class Progress {
|
|
|
71
72
|
*
|
|
72
73
|
* ⚠ `duplex: "half"` is required by the fetch specification for a streaming body and Node enforces
|
|
73
74
|
* it. Without it the request throws before a single byte is sent.
|
|
75
|
+
*
|
|
76
|
+
* ⛔ IT WRAPS `reachFetch`, NOT THE GLOBAL. Counting the bytes must not be a way around the
|
|
77
|
+
* function a caller asked every request to go through — this is the one request in an upload
|
|
78
|
+
* that carries the file.
|
|
74
79
|
*/
|
|
75
80
|
export function countingFetch(onSent, chunkBytes = 256 * 1024) {
|
|
76
81
|
return async (url, init) => {
|
|
77
82
|
const body = init?.body;
|
|
78
83
|
if (!(body instanceof Uint8Array))
|
|
79
|
-
return
|
|
84
|
+
return reachFetch(url, init);
|
|
80
85
|
const total = body.length;
|
|
81
86
|
let sent = 0;
|
|
82
87
|
const stream = new ReadableStream({
|
|
@@ -101,6 +106,6 @@ export function countingFetch(onSent, chunkBytes = 256 * 1024) {
|
|
|
101
106
|
if (!headers.has("content-length"))
|
|
102
107
|
headers.set("content-length", String(total));
|
|
103
108
|
next.headers = headers;
|
|
104
|
-
return
|
|
109
|
+
return reachFetch(url, next);
|
|
105
110
|
};
|
|
106
111
|
}
|
package/dist/reach.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** What a caller may say about where this client talks, and what it talks through. */
|
|
2
|
+
export interface Reach {
|
|
3
|
+
/**
|
|
4
|
+
* The storage network's upload relay to write through, instead of the network's own.
|
|
5
|
+
*
|
|
6
|
+
* ⚠ ONE host, not a list: the relay is named inside the transaction that pays its tip, so a
|
|
7
|
+
* write picks its host before the storage is bought and never moves.
|
|
8
|
+
*/
|
|
9
|
+
relay?: string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The Sui JSON-RPC endpoints to ask, in order, instead of the network's own.
|
|
12
|
+
*
|
|
13
|
+
* ⛔ IT REPLACES THE LIST rather than adding to it — somebody who names a node is saying *those*,
|
|
14
|
+
* and quietly reaching a public mirror as well would send their traffic somewhere they did
|
|
15
|
+
* not choose.
|
|
16
|
+
*/
|
|
17
|
+
suiRpc?: readonly string[] | undefined;
|
|
18
|
+
/** Hosts to read stored bytes from, instead of the public aggregators for the network. */
|
|
19
|
+
aggregators?: readonly string[] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The function every request this package makes goes through. Absent, the runtime's own.
|
|
22
|
+
*
|
|
23
|
+
* It is where a proxy goes: an agent, a SOCKS tunnel, a recorder, a counter. Nothing about a
|
|
24
|
+
* proxy is built into this package, because one function is the whole of what it would need.
|
|
25
|
+
*/
|
|
26
|
+
fetch?: typeof fetch | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** What the caller has said. */
|
|
29
|
+
export declare function reach(): Reach;
|
|
30
|
+
/** Tell this package what the caller chose. Fields that are absent leave what was there. */
|
|
31
|
+
export declare function useReach(next: Reach): void;
|
|
32
|
+
/** Start again with nothing — the runtime's own addresses and its own `fetch`. For tests. */
|
|
33
|
+
export declare function forgetReach(): void;
|
|
34
|
+
/**
|
|
35
|
+
* The one function every request in this package goes through.
|
|
36
|
+
*
|
|
37
|
+
* With nothing injected it is the runtime's `fetch`, called as the runtime's own — which is what
|
|
38
|
+
* the command-line tool has always done, byte for byte.
|
|
39
|
+
*/
|
|
40
|
+
export declare const reachFetch: typeof fetch;
|
package/dist/reach.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Where this program talks, and what it talks through — the caller's answer, not the runtime's.
|
|
2
|
+
//
|
|
3
|
+
// ⛔ WHY THIS IS NOT THE HOST. `host.ts` holds what a RUNTIME provides: an engine, a store, an
|
|
4
|
+
// environment, somewhere for progress to go, a zstd encoder. What is here is what a CALLER
|
|
5
|
+
// chose: a relay, a set of Sui nodes, a set of aggregators, and the function every request goes
|
|
6
|
+
// through. The command-line tool sets none of it and reads its addresses out of the environment
|
|
7
|
+
// exactly as it always has; a library's caller has no environment to write, and until this file
|
|
8
|
+
// existed the options it passed for two of those addresses were read only by the browser host —
|
|
9
|
+
// silently ignored on Node, which is the defect this fixes.
|
|
10
|
+
//
|
|
11
|
+
// ⛔ AN OPTION THAT WAS PASSED IS HONOURED ON EVERY HOST, or refused by name. Nothing in this
|
|
12
|
+
// package may quietly reach an address the caller did not choose: for somebody routing their
|
|
13
|
+
// traffic through a proxy, one leak makes the proxy a lie rather than a weaker promise.
|
|
14
|
+
//
|
|
15
|
+
// ⛔ IT IS READ AT THE MOMENT OF THE REQUEST, not copied when a client is made. `reachFetch` looks
|
|
16
|
+
// the function up on every call, so a caller that set one after building its client is not
|
|
17
|
+
// holding a stale copy.
|
|
18
|
+
//
|
|
19
|
+
// ⚠ ONE PER PROCESS, AND THE LAST WRITER WINS THE FIELDS IT NAMES. This is the same arrangement
|
|
20
|
+
// the SDK's `host-options.ts` already describes for a page: two clients pointed at different
|
|
21
|
+
// relays would be two answers to a question with one answer. On a server that means two clients
|
|
22
|
+
// with two different proxies share whichever was set last — said here rather than discovered.
|
|
23
|
+
//
|
|
24
|
+
// ⛔ NO `node:` IMPORT, EVER. This file is reachable from `portable.ts`, which promises that.
|
|
25
|
+
let current = {};
|
|
26
|
+
/** What the caller has said. */
|
|
27
|
+
export function reach() {
|
|
28
|
+
return current;
|
|
29
|
+
}
|
|
30
|
+
/** Tell this package what the caller chose. Fields that are absent leave what was there. */
|
|
31
|
+
export function useReach(next) {
|
|
32
|
+
const merged = { ...current };
|
|
33
|
+
for (const key of Object.keys(next)) {
|
|
34
|
+
if (next[key] !== undefined)
|
|
35
|
+
Reflect.set(merged, key, next[key]);
|
|
36
|
+
}
|
|
37
|
+
current = merged;
|
|
38
|
+
}
|
|
39
|
+
/** Start again with nothing — the runtime's own addresses and its own `fetch`. For tests. */
|
|
40
|
+
export function forgetReach() {
|
|
41
|
+
current = {};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The one function every request in this package goes through.
|
|
45
|
+
*
|
|
46
|
+
* With nothing injected it is the runtime's `fetch`, called as the runtime's own — which is what
|
|
47
|
+
* the command-line tool has always done, byte for byte.
|
|
48
|
+
*/
|
|
49
|
+
export const reachFetch = (input, init) => {
|
|
50
|
+
const given = current.fetch;
|
|
51
|
+
return given === undefined ? globalThis.fetch(input, init) : given(input, init);
|
|
52
|
+
};
|
package/dist/risk.d.ts
CHANGED
|
@@ -110,6 +110,9 @@ export declare const ACTS: {
|
|
|
110
110
|
readonly key: {
|
|
111
111
|
readonly tier: "none";
|
|
112
112
|
};
|
|
113
|
+
readonly openers: {
|
|
114
|
+
readonly tier: "none";
|
|
115
|
+
};
|
|
113
116
|
readonly env: {
|
|
114
117
|
readonly tier: "none";
|
|
115
118
|
};
|
|
@@ -233,6 +236,14 @@ export declare const ACTS: {
|
|
|
233
236
|
readonly tier: "medium";
|
|
234
237
|
readonly what: "Make a business key pair and write its private half to a file on this disk.";
|
|
235
238
|
};
|
|
239
|
+
readonly "openers.add": {
|
|
240
|
+
readonly tier: "medium";
|
|
241
|
+
readonly what: "Let this wallet open this account and every file in it.";
|
|
242
|
+
};
|
|
243
|
+
readonly "openers.remove": {
|
|
244
|
+
readonly tier: "medium";
|
|
245
|
+
readonly what: "Stop this wallet opening this account from now on.";
|
|
246
|
+
};
|
|
236
247
|
readonly "public-code.publish": {
|
|
237
248
|
readonly tier: "medium";
|
|
238
249
|
readonly what: "Publish this account's public code. Publishing cannot be undone.";
|
package/dist/risk.js
CHANGED
|
@@ -55,6 +55,9 @@ export const ACTS = {
|
|
|
55
55
|
unlabel: { tier: "none" },
|
|
56
56
|
devices: { tier: "none" },
|
|
57
57
|
key: { tier: "none" },
|
|
58
|
+
// Reading the inventory of roads into the account. It presents the NMTS key's own proof, like
|
|
59
|
+
// the two acts below, and changes nothing.
|
|
60
|
+
openers: { tier: "none" },
|
|
58
61
|
env: { tier: "none" },
|
|
59
62
|
mode: { tier: "none" },
|
|
60
63
|
unlock: { tier: "none" },
|
|
@@ -98,6 +101,16 @@ export const ACTS = {
|
|
|
98
101
|
// a browser, nothing is spent, and the file is never replaced — so it is not the tier that
|
|
99
102
|
// waits for an unlock.
|
|
100
103
|
"platform.keygen": { tier: "medium", what: "Make a business key pair and write its private half to a file on this disk." },
|
|
104
|
+
// ⛔ MEDIUM, BESIDE `key.new` AND `key.revoke`, AND FOR THE SAME REASONS. Adding an opener makes
|
|
105
|
+
// a standing way into the account that outlives the run — wider than a key, because what it
|
|
106
|
+
// opens is the files; removing one stops something that may be in use. Neither spends, and
|
|
107
|
+
// neither reaches a third party, which is where `high` begins.
|
|
108
|
+
// Copy facts — both `what` sentences — the gate asks them in the second person. Facts for the
|
|
109
|
+
// first: this wallet will open every file in the account from any machine until it is removed.
|
|
110
|
+
// For the second: that wallet stops opening the account from now on, and a wallet that opened it
|
|
111
|
+
// once has held the NMTS key — removal cannot unknow that.
|
|
112
|
+
"openers.add": { tier: "medium", what: "Let this wallet open this account and every file in it." },
|
|
113
|
+
"openers.remove": { tier: "medium", what: "Stop this wallet opening this account from now on." },
|
|
101
114
|
"public-code.publish": { tier: "medium", what: "Publish this account's public code. Publishing cannot be undone." },
|
|
102
115
|
"losses.dismiss": { tier: "medium", what: "Put this loss notice down. It will not be shown again." },
|
|
103
116
|
// ⛔ MEDIUM AND NOT HIGH. It moves value, so it is not `low`; but it moves it INSIDE one person's
|
|
@@ -177,6 +190,8 @@ export function actOf(args) {
|
|
|
177
190
|
return args.pay === "wallet" ? "push.wallet" : "push";
|
|
178
191
|
case "key":
|
|
179
192
|
return sub === "new" ? "key.new" : sub === "revoke" ? "key.revoke" : "key";
|
|
193
|
+
case "openers":
|
|
194
|
+
return sub === "add" ? "openers.add" : sub === "remove" ? "openers.remove" : "openers";
|
|
180
195
|
case "trial":
|
|
181
196
|
return sub === "apply" ? "trial.apply" : "trial";
|
|
182
197
|
case "credits":
|
package/dist/sui-rpc.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// ⛔ NOT A RETRIER. Each host is asked once. Anything other than "no answer" — any 4xx that is not
|
|
10
10
|
// 429 — is an answer, and asking a different node the same question gets the same one.
|
|
11
11
|
import { JsonRpcHTTPTransport } from "@mysten/sui/jsonRpc";
|
|
12
|
+
import { reachFetch } from "./reach.js";
|
|
12
13
|
import { suiRpcHosts } from "./walrus.js";
|
|
13
14
|
/** HTTP statuses that mean "no answer came", the only ones worth asking a second node about. */
|
|
14
15
|
function worthAnotherHost(status) {
|
|
@@ -39,7 +40,7 @@ export function suiRpcTransport(network) {
|
|
|
39
40
|
if (host === undefined)
|
|
40
41
|
continue;
|
|
41
42
|
try {
|
|
42
|
-
const res = await
|
|
43
|
+
const res = await reachFetch(new URL(asked.pathname + asked.search, host), init);
|
|
43
44
|
if (worthAnotherHost(res.status) && step < hosts.length - 1) {
|
|
44
45
|
lastError = new Error(`${host} answered ${res.status}`);
|
|
45
46
|
continue;
|
|
@@ -24,8 +24,10 @@ import { blobIdFromInt, blobIdToInt, MAINNET_WALRUS_PACKAGE_CONFIG, TESTNET_WALR
|
|
|
24
24
|
import { fromBase64Url } from "./bytes.js";
|
|
25
25
|
import { NmtsError } from "./errors.js";
|
|
26
26
|
import { extendReads, netGasFee, readBlobLease } from "./extend-chain.js";
|
|
27
|
+
import { reachFetch } from "./reach.js";
|
|
27
28
|
import { readOwnedStorage, readStorageType } from "./shared/lib/storage-control/chain.js";
|
|
28
29
|
import { registerIntoStorage, splitStorageToFit } from "./shared/lib/storage-control/reuse.js";
|
|
30
|
+
import { storageNodesThrough } from "./walrus.js";
|
|
29
31
|
import { suiRpcTransport } from "./sui-rpc.js";
|
|
30
32
|
import { readBalances, walCoinType } from "./wallet.js";
|
|
31
33
|
import { chainReader } from "./wallet-chain.js";
|
|
@@ -46,7 +48,10 @@ export function packageConfig(network) {
|
|
|
46
48
|
return network === "mainnet" ? MAINNET_WALRUS_PACKAGE_CONFIG : TESTNET_WALRUS_PACKAGE_CONFIG;
|
|
47
49
|
}
|
|
48
50
|
function build(network, relayUrl) {
|
|
49
|
-
return new SuiJsonRpcClient({ network, transport: suiRpcTransport(network) }).$extend(walrus({
|
|
51
|
+
return new SuiJsonRpcClient({ network, transport: suiRpcTransport(network) }).$extend(walrus({
|
|
52
|
+
...storageNodesThrough(),
|
|
53
|
+
uploadRelay: { host: relayUrl, sendTip: { max: RELAY_TIP_CEILING_MIST[network] }, fetch: reachFetch },
|
|
54
|
+
}));
|
|
50
55
|
}
|
|
51
56
|
/** A Walrus client bound to ONE relay, able to pay that relay's tip. */
|
|
52
57
|
export function payingClient(network, relayUrl) {
|
package/dist/walrus-write.js
CHANGED
|
@@ -17,7 +17,8 @@ import { epochClock } from "./expiry.js";
|
|
|
17
17
|
import { epochStartedMs as readEpochStart } from "./shared/lib/extend/epochs.js";
|
|
18
18
|
import { NmtsError } from "./errors.js";
|
|
19
19
|
import { countingFetch } from "./progress.js";
|
|
20
|
-
import {
|
|
20
|
+
import { reachFetch } from "./reach.js";
|
|
21
|
+
import { relayHost, storageNodesThrough } from "./walrus.js";
|
|
21
22
|
import { suiRpcTransport } from "./sui-rpc.js";
|
|
22
23
|
/**
|
|
23
24
|
* How long the relay gets for one blob PUT, sized to the body.
|
|
@@ -50,6 +51,7 @@ function extend(network, relayUrl, bodyBytes, onSent) {
|
|
|
50
51
|
transport: suiRpcTransport(network),
|
|
51
52
|
});
|
|
52
53
|
return base.$extend(walrus({
|
|
54
|
+
...storageNodesThrough(),
|
|
53
55
|
uploadRelay: {
|
|
54
56
|
host: relayUrl,
|
|
55
57
|
sendTip: { max: TIP_CEILING_UNUSED_MIST },
|
|
@@ -58,7 +60,10 @@ function extend(network, relayUrl, bodyBytes, onSent) {
|
|
|
58
60
|
// PUT is the one step of an upload that takes real time — a person watching a large
|
|
59
61
|
// file with no feedback cannot tell a slow upload from a hung one, and neither can an
|
|
60
62
|
// agent deciding whether to give up.
|
|
61
|
-
|
|
63
|
+
//
|
|
64
|
+
// ⛔ AND EITHER WAY IT IS THE CALLER'S `fetch`: the counting wrapper goes through it too,
|
|
65
|
+
// so the request that carries the file cannot be the one that misses a proxy.
|
|
66
|
+
fetch: onSent ? countingFetch(onSent) : reachFetch,
|
|
62
67
|
},
|
|
63
68
|
}));
|
|
64
69
|
}
|
|
@@ -131,7 +136,7 @@ export async function readCurrentEpoch(network) {
|
|
|
131
136
|
const base = new SuiJsonRpcClient({
|
|
132
137
|
network: network === "mainnet" ? "mainnet" : "testnet",
|
|
133
138
|
transport: suiRpcTransport(network),
|
|
134
|
-
}).$extend(walrus(
|
|
139
|
+
}).$extend(walrus(storageNodesThrough()));
|
|
135
140
|
// The epoch lives on the COMMITTEE, not beside it: the system state describes capacity and
|
|
136
141
|
// the deny lists as well, and only the committee is stamped with which epoch it serves.
|
|
137
142
|
const state = await base.walrus.systemState();
|
|
@@ -162,7 +167,7 @@ export async function readEpochWindow(network) {
|
|
|
162
167
|
const base = new SuiJsonRpcClient({
|
|
163
168
|
network: network === "mainnet" ? "mainnet" : "testnet",
|
|
164
169
|
transport: suiRpcTransport(network),
|
|
165
|
-
}).$extend(walrus(
|
|
170
|
+
}).$extend(walrus(storageNodesThrough()));
|
|
166
171
|
const [system, staking] = await Promise.all([base.walrus.systemState(), base.walrus.stakingState()]);
|
|
167
172
|
// Both numbers can arrive as strings — Sui reports 64-bit values that way — so they are
|
|
168
173
|
// converted here and the constructor below refuses whatever did not survive it.
|
package/dist/walrus.d.ts
CHANGED
|
@@ -29,19 +29,46 @@ export declare const SUI_RPC_HOSTS: Readonly<Record<string, readonly string[]>>;
|
|
|
29
29
|
/** How long one host gets before the next is tried. A read that stalls is a read that failed. */
|
|
30
30
|
export declare const READ_TIMEOUT_MS = 60000;
|
|
31
31
|
export { AGGREGATOR_ENV_VAR, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./env-vars.ts";
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The relay this run writes through: the caller's if it named one, then the environment's, then
|
|
34
|
+
* the network's.
|
|
35
|
+
*
|
|
36
|
+
* ⛔ THE CALLER COMES FIRST AND IS READ ON EVERY HOST. A library's caller has no environment to
|
|
37
|
+
* write, and until this order existed the `relay` option was answered by the browser host alone
|
|
38
|
+
* — so a program on a server named a relay and its bytes went to the public one, silently.
|
|
39
|
+
*/
|
|
33
40
|
export declare function relayHost(network: string): string;
|
|
34
41
|
/**
|
|
35
|
-
* Every Sui JSON-RPC node this run may ask, in order
|
|
42
|
+
* Every Sui JSON-RPC node this run may ask, in order: the caller's list if it named one, then the
|
|
43
|
+
* environment's, then the network's.
|
|
36
44
|
*
|
|
37
|
-
* ⛔ Naming
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
45
|
+
* ⛔ Naming nodes REPLACES the list rather than adding to it — the same rule the aggregator
|
|
46
|
+
* override follows, and for the same reason: somebody who names a node is saying *those*, and
|
|
47
|
+
* quietly reaching a public mirror instead would send their traffic somewhere they did not
|
|
48
|
+
* choose.
|
|
49
|
+
*
|
|
50
|
+
* ⚠ THE CALLER MAY NAME SEVERAL AND A VARIABLE MAY NAME ONE. The failover below is the same
|
|
51
|
+
* either way; a single name is a list of one.
|
|
41
52
|
*/
|
|
42
53
|
export declare function suiRpcHosts(network: string): readonly string[];
|
|
43
54
|
/** The node whose address gets RECORDED — the first one, since that is the one normally asked. */
|
|
44
55
|
export declare function suiRpcHost(network: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* What a storage-network client talks to the storage nodes through, spread into its options.
|
|
58
|
+
*
|
|
59
|
+
* ⚠ THIS TOOL DOES NOT NORMALLY REACH A STORAGE NODE — it writes through an upload relay and reads
|
|
60
|
+
* through an aggregator. The option is filled anyway, because the one path that fell back to a
|
|
61
|
+
* node directly would be a request going round whatever the caller asked every request to go
|
|
62
|
+
* through, and the whole worth of that option is that there is no exception to it.
|
|
63
|
+
*
|
|
64
|
+
* ⛔ HERE RATHER THAN IN EACH CLIENT. Five of them are built in this package; five copies of the
|
|
65
|
+
* same line is five places for the sixth to be forgotten.
|
|
66
|
+
*/
|
|
67
|
+
export declare function storageNodesThrough(): {
|
|
68
|
+
storageNodeClientOptions: {
|
|
69
|
+
fetch: typeof fetch;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
45
72
|
export interface ReadOptions {
|
|
46
73
|
/** Override the host list — for a development stack, or an aggregator somebody runs themselves. */
|
|
47
74
|
hosts?: readonly string[];
|
package/dist/walrus.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { AGGREGATOR_ENV_VAR, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./env-vars.js";
|
|
14
14
|
import { NmtsError } from "./errors.js";
|
|
15
15
|
import { host as runtime } from "./host.js";
|
|
16
|
+
import { reach, reachFetch } from "./reach.js";
|
|
16
17
|
/** Curated Walrus aggregator (read) endpoints per network, preference order. */
|
|
17
18
|
export const AGGREGATOR_HOSTS = {
|
|
18
19
|
testnet: ["https://aggregator.walrus-testnet.walrus.space"],
|
|
@@ -55,9 +56,16 @@ export const READ_TIMEOUT_MS = 60_000;
|
|
|
55
56
|
// Re-exported so every caller still finds them here; the names themselves live in a module with no
|
|
56
57
|
// imports, because `nmts --help` prints them (`env-vars.ts`).
|
|
57
58
|
export { AGGREGATOR_ENV_VAR, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./env-vars.js";
|
|
58
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* The relay this run writes through: the caller's if it named one, then the environment's, then
|
|
61
|
+
* the network's.
|
|
62
|
+
*
|
|
63
|
+
* ⛔ THE CALLER COMES FIRST AND IS READ ON EVERY HOST. A library's caller has no environment to
|
|
64
|
+
* write, and until this order existed the `relay` option was answered by the browser host alone
|
|
65
|
+
* — so a program on a server named a relay and its bytes went to the public one, silently.
|
|
66
|
+
*/
|
|
59
67
|
export function relayHost(network) {
|
|
60
|
-
const named = runtime().env(RELAY_ENV_VAR)?.trim();
|
|
68
|
+
const named = reach().relay?.trim() || runtime().env(RELAY_ENV_VAR)?.trim();
|
|
61
69
|
if (named)
|
|
62
70
|
return named;
|
|
63
71
|
const known = RELAY_HOSTS[network]?.[0];
|
|
@@ -69,14 +77,21 @@ export function relayHost(network) {
|
|
|
69
77
|
return known;
|
|
70
78
|
}
|
|
71
79
|
/**
|
|
72
|
-
* Every Sui JSON-RPC node this run may ask, in order
|
|
80
|
+
* Every Sui JSON-RPC node this run may ask, in order: the caller's list if it named one, then the
|
|
81
|
+
* environment's, then the network's.
|
|
73
82
|
*
|
|
74
|
-
* ⛔ Naming
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
83
|
+
* ⛔ Naming nodes REPLACES the list rather than adding to it — the same rule the aggregator
|
|
84
|
+
* override follows, and for the same reason: somebody who names a node is saying *those*, and
|
|
85
|
+
* quietly reaching a public mirror instead would send their traffic somewhere they did not
|
|
86
|
+
* choose.
|
|
87
|
+
*
|
|
88
|
+
* ⚠ THE CALLER MAY NAME SEVERAL AND A VARIABLE MAY NAME ONE. The failover below is the same
|
|
89
|
+
* either way; a single name is a list of one.
|
|
78
90
|
*/
|
|
79
91
|
export function suiRpcHosts(network) {
|
|
92
|
+
const asked = reach().suiRpc?.map((h) => h.trim()).filter((h) => h !== "");
|
|
93
|
+
if (asked !== undefined && asked.length > 0)
|
|
94
|
+
return asked;
|
|
80
95
|
const named = runtime().env(SUI_RPC_ENV_VAR)?.trim();
|
|
81
96
|
if (named)
|
|
82
97
|
return [named];
|
|
@@ -92,6 +107,20 @@ export function suiRpcHosts(network) {
|
|
|
92
107
|
export function suiRpcHost(network) {
|
|
93
108
|
return suiRpcHosts(network)[0] ?? "";
|
|
94
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* What a storage-network client talks to the storage nodes through, spread into its options.
|
|
112
|
+
*
|
|
113
|
+
* ⚠ THIS TOOL DOES NOT NORMALLY REACH A STORAGE NODE — it writes through an upload relay and reads
|
|
114
|
+
* through an aggregator. The option is filled anyway, because the one path that fell back to a
|
|
115
|
+
* node directly would be a request going round whatever the caller asked every request to go
|
|
116
|
+
* through, and the whole worth of that option is that there is no exception to it.
|
|
117
|
+
*
|
|
118
|
+
* ⛔ HERE RATHER THAN IN EACH CLIENT. Five of them are built in this package; five copies of the
|
|
119
|
+
* same line is five places for the sixth to be forgotten.
|
|
120
|
+
*/
|
|
121
|
+
export function storageNodesThrough() {
|
|
122
|
+
return { storageNodeClientOptions: { fetch: reachFetch } };
|
|
123
|
+
}
|
|
95
124
|
function fromEnvironment() {
|
|
96
125
|
const raw = runtime().env(AGGREGATOR_ENV_VAR);
|
|
97
126
|
if (raw === undefined)
|
|
@@ -99,9 +128,20 @@ function fromEnvironment() {
|
|
|
99
128
|
const hosts = raw.split(",").map((h) => h.trim()).filter((h) => h !== "");
|
|
100
129
|
return hosts.length > 0 ? hosts : null;
|
|
101
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Which aggregators this read may ask, in order: the ones this call named, then the ones the
|
|
133
|
+
* caller named for the client, then the environment's, then the network's.
|
|
134
|
+
*
|
|
135
|
+
* ⚠ THE CLIENT'S CHOICE IS NEW HERE. A caller that named aggregators used to be honoured only on
|
|
136
|
+
* the reads that carry a host list down as an argument; the rest of the package quietly went to
|
|
137
|
+
* the public ones, which is the same defect `relay` had.
|
|
138
|
+
*/
|
|
102
139
|
function hostsFor(network, options) {
|
|
103
140
|
if (options.hosts !== undefined && options.hosts.length > 0)
|
|
104
141
|
return options.hosts;
|
|
142
|
+
const asked = reach().aggregators;
|
|
143
|
+
if (asked !== undefined && asked.length > 0)
|
|
144
|
+
return asked;
|
|
105
145
|
const chosen = fromEnvironment();
|
|
106
146
|
if (chosen !== null)
|
|
107
147
|
return chosen;
|
|
@@ -129,7 +169,7 @@ async function readFrom(network, pathOf, what, options) {
|
|
|
129
169
|
const timer = AbortSignal.timeout(options.timeoutMs ?? READ_TIMEOUT_MS);
|
|
130
170
|
const signal = options.signal === undefined ? timer : AbortSignal.any([timer, options.signal]);
|
|
131
171
|
try {
|
|
132
|
-
const response = await
|
|
172
|
+
const response = await reachFetch(url, { signal, redirect: "follow", ...headersFor(options) });
|
|
133
173
|
if (!response.ok) {
|
|
134
174
|
tried.push(`${host} → ${response.status}`);
|
|
135
175
|
continue;
|