@pacspace-io/check 0.5.6 → 0.6.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 +16 -0
- package/README.md +34 -0
- package/dist/cli.d.ts +5 -1
- package/dist/cli.js +1993 -121
- package/dist/index.js +196 -19
- package/dist/inputs.txt +11 -0
- package/dist/open-io.d.ts +38 -0
- package/dist/open.d.ts +16 -15
- package/dist/records-crypto-types/records/flag-threads-v1.d.ts +53 -0
- package/dist/records-crypto-types/records/labels.d.ts +37 -0
- package/dist/records-crypto-types/records/link-handle-v1.d.ts +16 -0
- package/dist/records-crypto-types/records/reader-crypto-v1.d.ts +198 -0
- package/dist/records-crypto-types/records/reader-link-v1.d.ts +164 -0
- package/dist/records-crypto-types/records/shared-record-ack-v2.d.ts +72 -0
- package/dist/records-crypto-types/records/trail-index-v1.d.ts +89 -0
- package/dist/records-crypto-types/records/trail-rule.d.ts +54 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/ack-flag-notes-v1.d.ts +57 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/flag-notes-v1.d.ts +55 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/index.d.ts +3 -0
- package/dist/records-crypto-types/records-crypto/asymmetric/reader-wraps-v1.d.ts +83 -0
- package/dist/records-crypto-types/records-crypto/disclosure-envelope-v1.d.ts +1 -1
- package/dist/records-crypto-types/records-crypto/index.d.ts +1 -1
- package/dist/records-crypto-types/records-crypto/records-encryption-v1.d.ts +1 -0
- package/dist/records-crypto.js +547 -66
- package/dist/shared-record-link.d.ts +121 -0
- package/dist/shared-record-words.d.ts +97 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2102,12 +2102,6 @@ var import_ethers14 = require("ethers");
|
|
|
2102
2102
|
// ../shared/src/demo/mirror-node-record-chain-reader.ts
|
|
2103
2103
|
var import_ethers13 = require("ethers");
|
|
2104
2104
|
|
|
2105
|
-
// ../shared/src/records/inspect-record-calldata-v1.ts
|
|
2106
|
-
var MIRROR_NODE_BY_CHAIN = Object.freeze({
|
|
2107
|
-
296: "https://testnet.mirrornode.hedera.com",
|
|
2108
|
-
295: "https://mainnet-public.mirrornode.hedera.com"
|
|
2109
|
-
});
|
|
2110
|
-
|
|
2111
2105
|
// ../shared/src/records/ledger-write-search-v1.ts
|
|
2112
2106
|
var LEDGER_WRITE_SEARCH_WINDOW_LIMIT_SECONDS = 7 * 24 * 60 * 60;
|
|
2113
2107
|
var LEDGER_WRITE_SEARCH_PAGE_LIMIT = 100;
|
|
@@ -2276,6 +2270,12 @@ function parseLedgerWriteLog(log, expected) {
|
|
|
2276
2270
|
};
|
|
2277
2271
|
}
|
|
2278
2272
|
|
|
2273
|
+
// ../shared/src/records/inspect-record-calldata-v1.ts
|
|
2274
|
+
var MIRROR_NODE_BY_CHAIN = Object.freeze({
|
|
2275
|
+
296: "https://testnet.mirrornode.hedera.com",
|
|
2276
|
+
295: "https://mainnet-public.mirrornode.hedera.com"
|
|
2277
|
+
});
|
|
2278
|
+
|
|
2279
2279
|
// ../shared/src/demo/independent-verify-records.ts
|
|
2280
2280
|
var import_ethers12 = require("ethers");
|
|
2281
2281
|
|
|
@@ -2289,7 +2289,7 @@ var MIN_SECRET_LENGTH = 8;
|
|
|
2289
2289
|
var URL_IN_TEXT = /[a-z][a-z0-9+.-]*:\/\/[^\s"'<>\\`]+/gi;
|
|
2290
2290
|
var RAW_SEPARATORS = /[/?&=#;@:]/;
|
|
2291
2291
|
var ETHERS_ERROR_EXTRA_FIELDS = ["operation", "reason", "event"];
|
|
2292
|
-
function
|
|
2292
|
+
function rpcHttpUrl(value) {
|
|
2293
2293
|
const trimmed = value.trim();
|
|
2294
2294
|
if (trimmed.startsWith("wss://")) return trimmed.replace(/^wss:\/\//, "https://");
|
|
2295
2295
|
if (trimmed.startsWith("ws://")) return trimmed.replace(/^ws:\/\//, "http://");
|
|
@@ -2297,7 +2297,7 @@ function normalizeRpcUrl(value) {
|
|
|
2297
2297
|
}
|
|
2298
2298
|
function rpcEndpointLabel(value) {
|
|
2299
2299
|
try {
|
|
2300
|
-
return new URL(
|
|
2300
|
+
return new URL(rpcHttpUrl(value)).hostname.toLowerCase();
|
|
2301
2301
|
} catch {
|
|
2302
2302
|
return "unparseable-rpc-endpoint";
|
|
2303
2303
|
}
|
|
@@ -2396,6 +2396,90 @@ function redactRpcError(error, secrets) {
|
|
|
2396
2396
|
}
|
|
2397
2397
|
return new Error(cleanText(String(error), secrets));
|
|
2398
2398
|
}
|
|
2399
|
+
var RpcResultUnavailableError = class extends Error {
|
|
2400
|
+
constructor(what, reason) {
|
|
2401
|
+
super(`${what} from the RPC is incomplete: ${reason}`);
|
|
2402
|
+
this.code = "RPC_RESULT_UNAVAILABLE";
|
|
2403
|
+
this.name = "RpcResultUnavailableError";
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
var HEX_QUANTITY = /^0x[0-9a-f]+$/i;
|
|
2407
|
+
function parseRpcQuantity(value, what) {
|
|
2408
|
+
if (typeof value !== "string" || !HEX_QUANTITY.test(value)) {
|
|
2409
|
+
throw new RpcResultUnavailableError(what, "not a hex quantity");
|
|
2410
|
+
}
|
|
2411
|
+
return BigInt(value);
|
|
2412
|
+
}
|
|
2413
|
+
var QUANTITY_RESULTS = {
|
|
2414
|
+
getBlockNumber: "eth_blockNumber",
|
|
2415
|
+
getTransactionCount: "eth_getTransactionCount",
|
|
2416
|
+
getBalance: "eth_getBalance",
|
|
2417
|
+
getGasPrice: "eth_gasPrice",
|
|
2418
|
+
getPriorityFee: "eth_maxPriorityFeePerGas",
|
|
2419
|
+
estimateGas: "eth_estimateGas"
|
|
2420
|
+
};
|
|
2421
|
+
function incompleteReason(error) {
|
|
2422
|
+
const short = String(error?.shortMessage ?? error?.message ?? error);
|
|
2423
|
+
const field = /^invalid value for value\.(\w+) \(([^(]*)/.exec(short);
|
|
2424
|
+
return field ? `${field[1]}: ${field[2].trim()}` : short.split(" (")[0];
|
|
2425
|
+
}
|
|
2426
|
+
function formatted(what, format) {
|
|
2427
|
+
try {
|
|
2428
|
+
return format();
|
|
2429
|
+
} catch (error) {
|
|
2430
|
+
throw new RpcResultUnavailableError(what, incompleteReason(error));
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
var SUBSCRIBE_METHODS = /* @__PURE__ */ new Set(["eth_subscribe", "eth_newFilter"]);
|
|
2434
|
+
var UNSUBSCRIBE_METHODS = /* @__PURE__ */ new Set(["eth_unsubscribe", "eth_uninstallFilter"]);
|
|
2435
|
+
var SUBSCRIBE_RETRY_BASE_MS = 1e3;
|
|
2436
|
+
var SUBSCRIBE_RETRY_MAX_MS = 6e4;
|
|
2437
|
+
var REJECTION_MESSAGE_MAX = 300;
|
|
2438
|
+
function rejectionMessage(error, secrets) {
|
|
2439
|
+
const inner = error?.error?.message;
|
|
2440
|
+
let text;
|
|
2441
|
+
if (typeof inner === "string") text = inner;
|
|
2442
|
+
else if (isEthersError(error)) text = error.shortMessage;
|
|
2443
|
+
else if (isErrorLike(error)) text = error.message;
|
|
2444
|
+
else text = String(error);
|
|
2445
|
+
return cleanText(text, secrets).slice(0, REJECTION_MESSAGE_MAX);
|
|
2446
|
+
}
|
|
2447
|
+
function pause(ms) {
|
|
2448
|
+
return new Promise((resolve) => {
|
|
2449
|
+
const timer = setTimeout(resolve, ms);
|
|
2450
|
+
timer.unref?.();
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
async function guardSubscriptionSend(method, send, provider, retry, secrets) {
|
|
2454
|
+
const report = (rejection) => {
|
|
2455
|
+
try {
|
|
2456
|
+
retry.onRejected?.(rejection);
|
|
2457
|
+
} catch {
|
|
2458
|
+
}
|
|
2459
|
+
};
|
|
2460
|
+
if (UNSUBSCRIBE_METHODS.has(method)) {
|
|
2461
|
+
try {
|
|
2462
|
+
return await send();
|
|
2463
|
+
} catch (error) {
|
|
2464
|
+
report({ method, attempt: 1, retryInMs: null, message: rejectionMessage(error, secrets) });
|
|
2465
|
+
return false;
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
if (!SUBSCRIBE_METHODS.has(method)) return send();
|
|
2469
|
+
const base = retry.baseDelayMs ?? SUBSCRIBE_RETRY_BASE_MS;
|
|
2470
|
+
const max = retry.maxDelayMs ?? SUBSCRIBE_RETRY_MAX_MS;
|
|
2471
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
2472
|
+
try {
|
|
2473
|
+
return await send();
|
|
2474
|
+
} catch (error) {
|
|
2475
|
+
if (provider.destroyed) return new Promise(() => void 0);
|
|
2476
|
+
const retryInMs = Math.min(base * 2 ** (attempt - 1), max);
|
|
2477
|
+
report({ method, attempt, retryInMs, message: rejectionMessage(error, secrets) });
|
|
2478
|
+
await pause(retryInMs);
|
|
2479
|
+
if (provider.destroyed) return new Promise(() => void 0);
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2399
2483
|
function requestFor(url, options) {
|
|
2400
2484
|
const request = new import_ethers10.FetchRequest(url);
|
|
2401
2485
|
if (options.timeoutMs !== void 0) request.timeout = options.timeoutMs;
|
|
@@ -2413,7 +2497,7 @@ async function readRpcChainId(url, options = {}) {
|
|
|
2413
2497
|
response.assertOk();
|
|
2414
2498
|
const answer = response.bodyJson;
|
|
2415
2499
|
const result = answer !== null && typeof answer === "object" ? answer.result : void 0;
|
|
2416
|
-
if (typeof result !== "string" || !CHAIN_ID_RESULT.test(result)) throw new
|
|
2500
|
+
if (typeof result !== "string" || !CHAIN_ID_RESULT.test(result)) throw new RpcResultUnavailableError("eth_chainId", "not a chain id");
|
|
2417
2501
|
return Number.parseInt(result, 16);
|
|
2418
2502
|
} catch (error) {
|
|
2419
2503
|
throw redactRpcError(error, secrets);
|
|
@@ -2421,10 +2505,15 @@ async function readRpcChainId(url, options = {}) {
|
|
|
2421
2505
|
}
|
|
2422
2506
|
var RedactingJsonRpcProvider = class extends import_ethers10.JsonRpcProvider {
|
|
2423
2507
|
#secrets;
|
|
2508
|
+
#subscriptionRetry;
|
|
2424
2509
|
constructor(url, network, options) {
|
|
2425
|
-
const { timeoutMs, prepareRequest, ...providerOptions } = options;
|
|
2510
|
+
const { timeoutMs, subscriptionRetry, prepareRequest, ...providerOptions } = options;
|
|
2426
2511
|
super(requestFor(url, { timeoutMs, prepareRequest }), network, providerOptions);
|
|
2427
2512
|
this.#secrets = rpcUrlSecrets(url);
|
|
2513
|
+
this.#subscriptionRetry = subscriptionRetry ?? {};
|
|
2514
|
+
}
|
|
2515
|
+
send(method, params) {
|
|
2516
|
+
return guardSubscriptionSend(method, () => super.send(method, params), this, this.#subscriptionRetry, this.#secrets);
|
|
2428
2517
|
}
|
|
2429
2518
|
async _send(payload) {
|
|
2430
2519
|
try {
|
|
@@ -2433,6 +2522,24 @@ var RedactingJsonRpcProvider = class extends import_ethers10.JsonRpcProvider {
|
|
|
2433
2522
|
throw redactRpcError(error, this.#secrets);
|
|
2434
2523
|
}
|
|
2435
2524
|
}
|
|
2525
|
+
async _perform(req) {
|
|
2526
|
+
const result = await super._perform(req);
|
|
2527
|
+
const method = QUANTITY_RESULTS[req.method];
|
|
2528
|
+
if (method) parseRpcQuantity(result, method);
|
|
2529
|
+
return result;
|
|
2530
|
+
}
|
|
2531
|
+
_wrapTransactionResponse(tx, network) {
|
|
2532
|
+
return formatted("transaction", () => super._wrapTransactionResponse(tx, network));
|
|
2533
|
+
}
|
|
2534
|
+
_wrapTransactionReceipt(value, network) {
|
|
2535
|
+
return formatted("transaction receipt", () => super._wrapTransactionReceipt(value, network));
|
|
2536
|
+
}
|
|
2537
|
+
_wrapBlock(value, network) {
|
|
2538
|
+
return formatted("block", () => super._wrapBlock(value, network));
|
|
2539
|
+
}
|
|
2540
|
+
_wrapLog(value, network) {
|
|
2541
|
+
return formatted("log", () => super._wrapLog(value, network));
|
|
2542
|
+
}
|
|
2436
2543
|
};
|
|
2437
2544
|
function createRpcProvider(url, network, options = {}) {
|
|
2438
2545
|
return new RedactingJsonRpcProvider(url, network, options);
|
|
@@ -2550,7 +2657,7 @@ function checkLayoutOnChain(onChainLayout, published) {
|
|
|
2550
2657
|
const matchesPublished = !!published && onChainLayout.registered && onChainLayout.layoutDigest === published.digest;
|
|
2551
2658
|
return { ...onChainLayout, matchesPublished, failure: matchesPublished ? null : LAYOUT_NOT_REGISTERED };
|
|
2552
2659
|
}
|
|
2553
|
-
function
|
|
2660
|
+
function normalizeRpcUrl(url) {
|
|
2554
2661
|
const trimmed = String(url || "").trim();
|
|
2555
2662
|
if (trimmed.startsWith("wss://")) return trimmed.replace(/^wss:\/\//, "https://");
|
|
2556
2663
|
if (trimmed.startsWith("ws://")) return trimmed.replace(/^ws:\/\//, "http://");
|
|
@@ -2570,7 +2677,7 @@ async function withTimeout(p, ms, label) {
|
|
|
2570
2677
|
}
|
|
2571
2678
|
}
|
|
2572
2679
|
function createRpcRecordChainReader(options) {
|
|
2573
|
-
const rpcUrl =
|
|
2680
|
+
const rpcUrl = normalizeRpcUrl(options.rpcUrl);
|
|
2574
2681
|
if (!rpcUrl) throw new Error("rpcUrl is required.");
|
|
2575
2682
|
const contractAddress = import_ethers12.ethers.getAddress(options.contractAddress).toLowerCase();
|
|
2576
2683
|
const timeoutMs = Number(options.timeoutMs || 1e4);
|
|
@@ -2712,6 +2819,10 @@ function createRpcRecordChainReader(options) {
|
|
|
2712
2819
|
const writes = [];
|
|
2713
2820
|
const blockTimes = /* @__PURE__ */ new Map();
|
|
2714
2821
|
let requests = 0;
|
|
2822
|
+
const asked = () => {
|
|
2823
|
+
requests += 1;
|
|
2824
|
+
search.onRequest?.();
|
|
2825
|
+
};
|
|
2715
2826
|
const CUT = Symbol("cut");
|
|
2716
2827
|
const within2 = async (p) => {
|
|
2717
2828
|
const left = deadline - now2();
|
|
@@ -2732,13 +2843,13 @@ function createRpcRecordChainReader(options) {
|
|
|
2732
2843
|
const found = await within2(endpoint());
|
|
2733
2844
|
if (found === CUT) return end("timeout");
|
|
2734
2845
|
const { provider } = found;
|
|
2735
|
-
|
|
2846
|
+
asked();
|
|
2736
2847
|
const latest = await within2(provider.getBlockNumber());
|
|
2737
2848
|
if (latest === CUT) return end("timeout");
|
|
2738
2849
|
for (let to = latest; to >= 0; to -= chunk) {
|
|
2739
2850
|
if (search.done(writes)) return end("done");
|
|
2740
2851
|
if (requests >= search.maxRequests || now2() >= deadline) return end("limit");
|
|
2741
|
-
|
|
2852
|
+
asked();
|
|
2742
2853
|
const logs = await within2(provider.getLogs({ address: contractAddress, topics: [RECORD_WRITTEN_TOPIC, key], fromBlock: Math.max(0, to - chunk + 1), toBlock: to }));
|
|
2743
2854
|
if (logs === CUT) return end("timeout");
|
|
2744
2855
|
for (const log of [...logs].reverse()) {
|
|
@@ -2747,7 +2858,7 @@ function createRpcRecordChainReader(options) {
|
|
|
2747
2858
|
let committedAt = blockTimes.get(log.blockNumber);
|
|
2748
2859
|
if (committedAt === void 0) {
|
|
2749
2860
|
if (requests >= search.maxRequests || now2() >= deadline) return end("limit");
|
|
2750
|
-
|
|
2861
|
+
asked();
|
|
2751
2862
|
const block = await within2(provider.getBlock(log.blockNumber));
|
|
2752
2863
|
if (block === CUT) return end("timeout");
|
|
2753
2864
|
if (!block || !Number.isSafeInteger(block.timestamp)) throw new Error(`getBlock ${log.blockNumber} returned no time`);
|
|
@@ -2856,6 +2967,15 @@ function committedAtOf(timestamp) {
|
|
|
2856
2967
|
const [seconds, fraction] = timestamp.split(".");
|
|
2857
2968
|
return new Date(Number(seconds) * 1e3 + Number(fraction.slice(0, 3))).toISOString();
|
|
2858
2969
|
}
|
|
2970
|
+
var SearchLimited = class {
|
|
2971
|
+
constructor(retryAfterMs2) {
|
|
2972
|
+
this.retryAfterMs = retryAfterMs2;
|
|
2973
|
+
}
|
|
2974
|
+
};
|
|
2975
|
+
function retryAfterMsOf(response) {
|
|
2976
|
+
const value = response.headers?.get?.("retry-after");
|
|
2977
|
+
return typeof value === "string" && /^\d{1,6}$/.test(value.trim()) ? Number(value.trim()) * 1e3 : null;
|
|
2978
|
+
}
|
|
2859
2979
|
var KEPT_TOPICS = [RECORD_WRITTEN_TOPIC.toLowerCase(), LEDGER_HEAD_ADVANCED_TOPIC.toLowerCase()];
|
|
2860
2980
|
var HEX_DATA2 = /^0x[0-9a-fA-F]*$/;
|
|
2861
2981
|
function mirrorLogPosition(raw) {
|
|
@@ -3038,6 +3158,10 @@ function createMirrorNodeRecordChainReader(options) {
|
|
|
3038
3158
|
try {
|
|
3039
3159
|
const response = await fetchImpl(`${base}${path}`, { headers: { accept: "application/json" }, redirect: "error", signal: controller.signal });
|
|
3040
3160
|
if (isMirrorRedirect(response)) throw mirrorRefusal.redirect(path);
|
|
3161
|
+
if (response.status === 429) {
|
|
3162
|
+
await response.body?.cancel?.().catch(() => void 0);
|
|
3163
|
+
return new SearchLimited(retryAfterMsOf(response));
|
|
3164
|
+
}
|
|
3041
3165
|
if (!response.ok) throw new Error(`mirror node ${response.status} for a record's writes`);
|
|
3042
3166
|
const page = await readMirrorJson(response, MIRROR_ANSWER_MAX_BYTES, path);
|
|
3043
3167
|
if (Array.isArray(page.logs) && page.logs.length > LEDGER_WRITE_SEARCH_PAGE_LIMIT) throw mirrorRefusal.tooManyLogs(LEDGER_WRITE_SEARCH_PAGE_LIMIT, path);
|
|
@@ -3108,7 +3232,8 @@ function createMirrorNodeRecordChainReader(options) {
|
|
|
3108
3232
|
transactionHash: log.transaction_hash,
|
|
3109
3233
|
logIndex: log.index,
|
|
3110
3234
|
committedAt: committedAtOf(log.timestamp),
|
|
3111
|
-
contractAddress: typeof log.address === "string" ? log.address.toLowerCase() : void 0
|
|
3235
|
+
contractAddress: typeof log.address === "string" ? log.address.toLowerCase() : void 0,
|
|
3236
|
+
...typeof log.timestamp === "string" && CONSENSUS_TIMESTAMP.test(log.timestamp) ? { consensusTimestamp: log.timestamp } : {}
|
|
3112
3237
|
});
|
|
3113
3238
|
}
|
|
3114
3239
|
return out;
|
|
@@ -3124,6 +3249,7 @@ function createMirrorNodeRecordChainReader(options) {
|
|
|
3124
3249
|
let upper = Math.min(Number.isFinite(hint) ? Math.floor(hint / 1e3) : nowSeconds, nowSeconds) + DAY_SECONDS;
|
|
3125
3250
|
const writes = [];
|
|
3126
3251
|
let requests = 0;
|
|
3252
|
+
let waits = 0;
|
|
3127
3253
|
const end = (ended) => ({ writes, ended, requests });
|
|
3128
3254
|
while (!search.done(writes)) {
|
|
3129
3255
|
if (upper <= 0) return end("limit");
|
|
@@ -3133,8 +3259,18 @@ function createMirrorNodeRecordChainReader(options) {
|
|
|
3133
3259
|
const left = deadline - now2();
|
|
3134
3260
|
if (requests >= search.maxRequests || left <= 0) return end("limit");
|
|
3135
3261
|
requests += 1;
|
|
3262
|
+
search.onRequest?.();
|
|
3136
3263
|
const page = await searchPage(path, left);
|
|
3137
3264
|
if (page === "timeout") return end("timeout");
|
|
3265
|
+
if (page instanceof SearchLimited) {
|
|
3266
|
+
const waitOut = search.waitOut;
|
|
3267
|
+
if (!waitOut || waits >= waitOut.times) throw new Error("mirror node 429 for a record's writes");
|
|
3268
|
+
waits += 1;
|
|
3269
|
+
const wait = Math.max(0, Math.min(waitOut.maxWaitMs, page.retryAfterMs ?? waitOut.waitMs));
|
|
3270
|
+
if (wait >= deadline - now2()) return end("limit");
|
|
3271
|
+
await (waitOut.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(wait);
|
|
3272
|
+
continue;
|
|
3273
|
+
}
|
|
3138
3274
|
for (const log of Array.isArray(page?.logs) ? page.logs : []) {
|
|
3139
3275
|
const write = parseLedgerWriteLog(log, { topic0, recordKey: key, contractAddress });
|
|
3140
3276
|
if (!write || !CONSENSUS_TIMESTAMP.test(write.timestamp)) continue;
|
|
@@ -3147,10 +3283,11 @@ function createMirrorNodeRecordChainReader(options) {
|
|
|
3147
3283
|
transactionHash: write.transactionHash,
|
|
3148
3284
|
logIndex: write.logIndex ?? void 0,
|
|
3149
3285
|
committedAt: write.committedAt,
|
|
3150
|
-
contractAddress: write.address
|
|
3286
|
+
contractAddress: write.address,
|
|
3287
|
+
consensusTimestamp: write.timestamp
|
|
3151
3288
|
});
|
|
3152
3289
|
}
|
|
3153
|
-
if (search.done(writes)) return end("done");
|
|
3290
|
+
if (!search.wholeWindows && search.done(writes)) return end("done");
|
|
3154
3291
|
const link = page?.links?.next;
|
|
3155
3292
|
path = nextLogPath(link, { base, contract: contractAddress });
|
|
3156
3293
|
if (!path && link !== null && link !== void 0 && link !== "") throw mirrorRefusal.nextPage();
|
|
@@ -3725,6 +3862,46 @@ var HEADER_BYTES = 1 + IV_BYTES2;
|
|
|
3725
3862
|
// ../shared/src/records-crypto/wrap-shapes-v1.ts
|
|
3726
3863
|
var SEP5 = new Uint8Array([0]);
|
|
3727
3864
|
|
|
3865
|
+
// ../shared/src/records/reader-crypto-v1.ts
|
|
3866
|
+
var SEP6 = new Uint8Array([0]);
|
|
3867
|
+
var P256_SPKI_PREFIX = Uint8Array.from([
|
|
3868
|
+
48,
|
|
3869
|
+
89,
|
|
3870
|
+
48,
|
|
3871
|
+
19,
|
|
3872
|
+
6,
|
|
3873
|
+
7,
|
|
3874
|
+
42,
|
|
3875
|
+
134,
|
|
3876
|
+
72,
|
|
3877
|
+
206,
|
|
3878
|
+
61,
|
|
3879
|
+
2,
|
|
3880
|
+
1,
|
|
3881
|
+
6,
|
|
3882
|
+
8,
|
|
3883
|
+
42,
|
|
3884
|
+
134,
|
|
3885
|
+
72,
|
|
3886
|
+
206,
|
|
3887
|
+
61,
|
|
3888
|
+
3,
|
|
3889
|
+
1,
|
|
3890
|
+
7,
|
|
3891
|
+
3,
|
|
3892
|
+
66,
|
|
3893
|
+
0
|
|
3894
|
+
]);
|
|
3895
|
+
|
|
3896
|
+
// ../shared/src/records/shared-record-list-v1.ts
|
|
3897
|
+
var import_ethers15 = require("ethers");
|
|
3898
|
+
|
|
3899
|
+
// ../shared/src/records/shared-record-check-v1.ts
|
|
3900
|
+
var ZERO_WORD = `0x${"0".repeat(64)}`;
|
|
3901
|
+
|
|
3902
|
+
// ../shared/src/records/shared-record-copy-v1.ts
|
|
3903
|
+
var import_ethers16 = require("ethers");
|
|
3904
|
+
|
|
3728
3905
|
// src/report.ts
|
|
3729
3906
|
var REPORT_SCHEMA = "pacspace-check-report/v1";
|
|
3730
3907
|
var SOURCE_REFUSAL_REASONS = {
|
|
@@ -4185,7 +4362,7 @@ async function lookUpWrites(input) {
|
|
|
4185
4362
|
|
|
4186
4363
|
// src/check.ts
|
|
4187
4364
|
var CHECKER_NAME = "@pacspace-io/check";
|
|
4188
|
-
var CHECKER_VERSION = true ? "0.
|
|
4365
|
+
var CHECKER_VERSION = true ? "0.6.0" : "0.0.0-dev";
|
|
4189
4366
|
var HISTORY_SCHEMAS = [
|
|
4190
4367
|
RECORD_HISTORY_BUNDLE_SCHEMA_V1,
|
|
4191
4368
|
RECORD_HISTORY_BUNDLE_SCHEMA_V2,
|
package/dist/inputs.txt
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
../shared/src/records/layouts.generated.ts
|
|
32
32
|
../shared/src/records/layouts.ts
|
|
33
33
|
../shared/src/records/ledger-write-search-v1.ts
|
|
34
|
+
../shared/src/records/link-handle-v1.ts
|
|
34
35
|
../shared/src/records/model-record-link-v1.ts
|
|
36
|
+
../shared/src/records/reader-crypto-v1.ts
|
|
35
37
|
../shared/src/records/record-content-v1.ts
|
|
36
38
|
../shared/src/records/record-entry-kind-v1.ts
|
|
37
39
|
../shared/src/records/record-history-bundle-v1.ts
|
|
@@ -39,10 +41,19 @@
|
|
|
39
41
|
../shared/src/records/record-history-bundle-v3.ts
|
|
40
42
|
../shared/src/records/record-link-copy-v1.ts
|
|
41
43
|
../shared/src/records/record-seal-history-v1.ts
|
|
44
|
+
../shared/src/records/shared-record-check-v1.ts
|
|
45
|
+
../shared/src/records/shared-record-copy-v1.ts
|
|
46
|
+
../shared/src/records/shared-record-list-v1.ts
|
|
47
|
+
../shared/src/records/shared-record-pace-v1.ts
|
|
48
|
+
../shared/src/records/shared-record-v2.ts
|
|
49
|
+
../shared/src/records/signed-acknowledgment-v2.ts
|
|
42
50
|
scripts/shared-surface.ts
|
|
43
51
|
src/check.ts
|
|
44
52
|
src/cli.ts
|
|
53
|
+
src/open-io.ts
|
|
45
54
|
src/open.ts
|
|
46
55
|
src/release.ts
|
|
47
56
|
src/report.ts
|
|
57
|
+
src/shared-record-link.ts
|
|
58
|
+
src/shared-record-words.ts
|
|
48
59
|
src/writes.ts
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CliIo } from './cli';
|
|
2
|
+
/**
|
|
3
|
+
* What `open` and a kept copy's check share: how a run ends early, small files, new files, and a link host's
|
|
4
|
+
* answers read within a bound. Nothing here prints a handle, a code, a key or a session.
|
|
5
|
+
*/
|
|
6
|
+
/** W-L2g-15 */
|
|
7
|
+
export declare const hostUnreachableSentence: (host: string) => string;
|
|
8
|
+
/** W-L2g-16 */
|
|
9
|
+
export declare const NO_KEY_SENTENCE = "This link reveals fields, but it has no key after #. Ask the sender for the whole link.";
|
|
10
|
+
/** W-L2g-21 */
|
|
11
|
+
export declare const pathExistsSentence: (path: string) => string;
|
|
12
|
+
/** W-L2g-22 */
|
|
13
|
+
export declare const savedReportSentence: (path: string) => string;
|
|
14
|
+
/** Ends the run with this exit code, its sentence on stderr. */
|
|
15
|
+
export declare class OpenStop extends Error {
|
|
16
|
+
readonly exitCode: 1 | 2 | 3;
|
|
17
|
+
constructor(message: string, exitCode: 1 | 2 | 3);
|
|
18
|
+
}
|
|
19
|
+
/** The first line of a small file. */
|
|
20
|
+
export declare function firstLineOf(io: CliIo, path: string): Promise<string>;
|
|
21
|
+
/** A new file only its owner reads; an existing path is refused. */
|
|
22
|
+
export declare function writeNew(io: CliIo, path: string, bytes: Uint8Array): Promise<void>;
|
|
23
|
+
/** Text from a host or a file with no control character, so none reaches the screen. */
|
|
24
|
+
export declare const withoutControls: (text: string) => string;
|
|
25
|
+
export declare const escapeHtml: (text: string) => string;
|
|
26
|
+
/** A refusal as a link host words it: its code, its sentence and the wait it names, from the body alone. */
|
|
27
|
+
export interface Refusal {
|
|
28
|
+
code: string | null;
|
|
29
|
+
message: string | null;
|
|
30
|
+
retryAfterSeconds: number | null;
|
|
31
|
+
}
|
|
32
|
+
export declare function refusalOfBody(body: unknown): Refusal;
|
|
33
|
+
/** A refusal's own sentence and code, as the link host serves it; control characters dropped. */
|
|
34
|
+
export declare function refusalOf(response: Response): Promise<Refusal>;
|
|
35
|
+
/** An answer's body, read no further than `max` bytes. Null when it is longer, or says it is. */
|
|
36
|
+
export declare function bodyWithin(response: Response, max: number): Promise<Uint8Array | null>;
|
|
37
|
+
/** `Retry-After` as seconds, from the header or the body; null when neither names a wait. */
|
|
38
|
+
export declare function retryAfterSecondsOf(response: Response, refusal: Refusal): number | null;
|
package/dist/open.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { type CheckOptions, type RevealedEntry } from './check';
|
|
2
2
|
import type { CliIo } from './cli';
|
|
3
3
|
import { type CheckReport } from './report';
|
|
4
|
+
export { hostUnreachableSentence, NO_KEY_SENTENCE, pathExistsSentence, savedReportSentence } from './open-io';
|
|
4
5
|
/**
|
|
5
|
-
* `pacspace-check open` (ADR 0015 section 8, layer 2; L2g design D2): reads
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* `pacspace-check open` (ADR 0015 section 8, layer 2; L2g design D2; ADR 0021): reads a Shared Record link the
|
|
7
|
+
* way the Shared Record does and checks what it serves.
|
|
8
|
+
*
|
|
9
|
+
* The address is read first, and the handle is the one in it, never one from an answer. Every request goes to one
|
|
10
|
+
* origin: the link's own, or the app host for an address on the key host, which serves files only. That origin is
|
|
11
|
+
* named before anything is asked of it, and named as not PacSpace's, before a code is asked for and again beside
|
|
12
|
+
* the result, when it is not. No redirect is followed, and the part after # never leaves this machine.
|
|
13
|
+
*
|
|
14
|
+
* What the handle answers as decides the rest. A link with a list of records is checked record by record
|
|
15
|
+
* (`shared-record-link.ts`). A link to one record has its revealed fields opened with the key after # and is
|
|
16
|
+
* checked as a kept copy. The access code goes only to the route that takes it; it, the key and the session are
|
|
17
|
+
* never printed or written.
|
|
12
18
|
*/
|
|
13
19
|
/** W-L2g-11 */
|
|
14
20
|
export declare const LINK_PROMPT = "Paste the link, then press Enter:";
|
|
@@ -18,20 +24,12 @@ export declare const LINK_IN_ARGV_SENTENCE = "The link was given on the command
|
|
|
18
24
|
export declare const NOT_A_LINK_SENTENCE = "This is not a PacSpace record link. A record link looks like https://<host>/c/<handle>/.";
|
|
19
25
|
/** W-L2g-14 */
|
|
20
26
|
export declare const ACCESS_CODE_PROMPT = "This link asks for an access code. Type it, then press Enter:";
|
|
21
|
-
/** W-L2g-15 */
|
|
22
|
-
export declare const hostUnreachableSentence: (host: string) => string;
|
|
23
|
-
/** W-L2g-16 */
|
|
24
|
-
export declare const NO_KEY_SENTENCE = "This link reveals fields, but it has no key after #. Ask the sender for the whole link.";
|
|
25
27
|
/** W-L2g-17 */
|
|
26
28
|
export declare const KEY_DOES_NOT_OPEN_SENTENCE = "The revealed fields didn't open with this link's key. Ask the sender for the whole link.";
|
|
27
29
|
/** W-L2g-18 */
|
|
28
30
|
export declare const REVEALED_HEADER = "Revealed fields";
|
|
29
31
|
/** W-L2g-20 */
|
|
30
32
|
export declare const savedCopySentence: (path: string) => string;
|
|
31
|
-
/** W-L2g-21 */
|
|
32
|
-
export declare const pathExistsSentence: (path: string) => string;
|
|
33
|
-
/** W-L2g-22 */
|
|
34
|
-
export declare const savedReportSentence: (path: string) => string;
|
|
35
33
|
export interface OpenArgs {
|
|
36
34
|
link: string | null;
|
|
37
35
|
linkFile: string | null;
|
|
@@ -39,6 +37,8 @@ export interface OpenArgs {
|
|
|
39
37
|
copy: string | null;
|
|
40
38
|
html: string | null;
|
|
41
39
|
source: CheckOptions['source'];
|
|
40
|
+
/** A link with a list of records only: read each contract's whole log. */
|
|
41
|
+
full: boolean;
|
|
42
42
|
timeoutMs: number | undefined;
|
|
43
43
|
json: boolean;
|
|
44
44
|
}
|
|
@@ -51,5 +51,6 @@ export declare function renderOpenHtml(input: {
|
|
|
51
51
|
revealed: RevealedEntry[];
|
|
52
52
|
version: string;
|
|
53
53
|
now: Date;
|
|
54
|
+
notice?: string | null;
|
|
54
55
|
}): string;
|
|
55
56
|
export declare function runOpen(argv: string[], io: CliIo): Promise<number>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type NoteNameV1, type SealedNoteV1 } from './reader-crypto-v1';
|
|
2
|
+
export declare const FLAG_REF_PATTERN_V1: RegExp;
|
|
3
|
+
export declare const FLAG_RESULTS_V1: readonly ["matches", "does-not-match", "copy-differs"];
|
|
4
|
+
export type FlagResultV1 = (typeof FLAG_RESULTS_V1)[number];
|
|
5
|
+
export type FlagStatusV1 = 'open' | 'answered' | 'closed';
|
|
6
|
+
export declare const FLAG_TEXT_MAX_V1 = 2000;
|
|
7
|
+
export declare const FLAG_SEALED_NOTE_MAX_CHARS_V1: number;
|
|
8
|
+
export declare const FLAG_DRAFTS_MAX_V1 = 100;
|
|
9
|
+
export declare const FLAG_DRAFT_NOTE_MAX_V1 = 500;
|
|
10
|
+
export declare const PLAIN_NOTE_SCHEMA_V1: "plain-note/v1";
|
|
11
|
+
export declare const FLAG_DRAFTS_SCHEMA_V1: "flag-drafts/v1";
|
|
12
|
+
export declare function flagRefV1(n: number): string;
|
|
13
|
+
export declare function flagNoteNameV1(input: {
|
|
14
|
+
handle: string;
|
|
15
|
+
kind: 'answer' | 'reply';
|
|
16
|
+
ref: string;
|
|
17
|
+
n: number;
|
|
18
|
+
}): NoteNameV1;
|
|
19
|
+
export declare function flagDraftsNoteNameV1(input: {
|
|
20
|
+
handle: string;
|
|
21
|
+
reference: string;
|
|
22
|
+
version: number;
|
|
23
|
+
}): NoteNameV1;
|
|
24
|
+
export declare function readFlagTextV1(value: unknown): string | null;
|
|
25
|
+
export interface PlainNoteV1 {
|
|
26
|
+
schema: typeof PLAIN_NOTE_SCHEMA_V1;
|
|
27
|
+
text: string;
|
|
28
|
+
salt: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function plainNoteV1(value: string): PlainNoteV1;
|
|
31
|
+
export declare function readPlainNoteV1(value: unknown): {
|
|
32
|
+
ok: true;
|
|
33
|
+
text: string;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
};
|
|
37
|
+
export declare function readFlagSealedNoteV1(value: unknown): SealedNoteV1 | null;
|
|
38
|
+
export declare function flagNoteDigestV1(note: SealedNoteV1 | PlainNoteV1): Promise<string>;
|
|
39
|
+
export interface FlagDraftV1 {
|
|
40
|
+
record: number;
|
|
41
|
+
entry: number;
|
|
42
|
+
note: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface FlagDraftsV1 {
|
|
45
|
+
schema: typeof FLAG_DRAFTS_SCHEMA_V1;
|
|
46
|
+
flags: FlagDraftV1[];
|
|
47
|
+
}
|
|
48
|
+
export declare function readFlagDraftsV1(value: unknown): {
|
|
49
|
+
ok: true;
|
|
50
|
+
drafts: FlagDraftsV1;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const LABEL_PAIR_RE: RegExp;
|
|
2
|
+
export declare const LABELS_MAX = 10;
|
|
3
|
+
export declare const LABEL_KEY_RE: RegExp;
|
|
4
|
+
export declare const LABEL_VALUE_RE: RegExp;
|
|
5
|
+
export declare const BLINDED_LABEL_RE: RegExp;
|
|
6
|
+
export type PlainLabels = Record<string, string>;
|
|
7
|
+
export type BlindedLabels = {
|
|
8
|
+
b: string[];
|
|
9
|
+
};
|
|
10
|
+
export type StoredLabels = PlainLabels | BlindedLabels;
|
|
11
|
+
export declare function parseLabels(input: unknown): PlainLabels;
|
|
12
|
+
export declare function labelsUnreadable(input: unknown): boolean;
|
|
13
|
+
export type LabelsCheck = {
|
|
14
|
+
ok: true;
|
|
15
|
+
kind: 'plain';
|
|
16
|
+
labels: PlainLabels;
|
|
17
|
+
} | {
|
|
18
|
+
ok: true;
|
|
19
|
+
kind: 'blinded';
|
|
20
|
+
labels: string[];
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
code: 'RECORD_LABELS_INVALID';
|
|
24
|
+
};
|
|
25
|
+
export declare function checkLabels(input: unknown): LabelsCheck;
|
|
26
|
+
export type LabelsMerge = {
|
|
27
|
+
ok: true;
|
|
28
|
+
labels: StoredLabels;
|
|
29
|
+
changed: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
ok: false;
|
|
32
|
+
code: 'RECORD_LABEL_CONFLICT' | 'RECORD_LABELS_INVALID';
|
|
33
|
+
};
|
|
34
|
+
export declare function isBlindedLabels(stored: unknown): stored is BlindedLabels;
|
|
35
|
+
export declare function mergeLabels(stored: unknown, incoming: Exclude<LabelsCheck, {
|
|
36
|
+
ok: false;
|
|
37
|
+
}>): LabelsMerge;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const LINK_HANDLE_PREFIX = "csh1_";
|
|
2
|
+
export declare const LIST_HANDLE_PREFIX = "csl1_";
|
|
3
|
+
export declare const LINK_HANDLE_PREFIXES: readonly ["csh1_", "csl1_"];
|
|
4
|
+
export type LinkHandlePrefix = (typeof LINK_HANDLE_PREFIXES)[number];
|
|
5
|
+
export declare const LINK_HANDLE_PATTERN: RegExp;
|
|
6
|
+
export declare const LINK_HANDLE_PREFIX_SOURCE = "cs[hl]1_";
|
|
7
|
+
export declare const LINK_HANDLE_ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
|
|
8
|
+
export interface LinkHandlePartsV1 {
|
|
9
|
+
handle: string;
|
|
10
|
+
prefix: LinkHandlePrefix;
|
|
11
|
+
body: string;
|
|
12
|
+
checksum: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function normalizeLinkHandleV1(text: unknown): string | null;
|
|
15
|
+
export declare function linkHandlePartsV1(handle: string): LinkHandlePartsV1 | null;
|
|
16
|
+
export declare function hasListHandlePrefixV1(handle: unknown): boolean;
|