wasmlock 0.0.1 → 0.1.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/LICENSE +21 -0
- package/README.md +242 -2
- package/THIRD_PARTY_NOTICES.txt +580 -0
- package/dist/add.d.ts +38 -0
- package/dist/atomic.d.ts +12 -0
- package/dist/check-format.d.ts +5 -0
- package/dist/check.d.ts +120 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +40474 -0
- package/dist/config.d.ts +18 -0
- package/dist/diff-format.d.ts +19 -0
- package/dist/diff-pending.d.ts +26 -0
- package/dist/diff.d.ts +85 -0
- package/dist/entry.d.ts +37 -0
- package/dist/exit.d.ts +15 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +40093 -0
- package/dist/interface-diff.d.ts +66 -0
- package/dist/json.d.ts +11 -0
- package/dist/ledger.d.ts +43 -0
- package/dist/lockfile.d.ts +100 -0
- package/dist/network.d.ts +5 -0
- package/dist/pending.d.ts +38 -0
- package/dist/rpc.d.ts +141 -0
- package/dist/rules.d.ts +109 -0
- package/dist/snapshot.d.ts +96 -0
- package/dist/spec.d.ts +25 -0
- package/dist/strkey.d.ts +2 -0
- package/dist/typestring.d.ts +22 -0
- package/dist/untrusted.d.ts +91 -0
- package/dist/update-report.d.ts +14 -0
- package/dist/update.d.ts +82 -0
- package/dist/upgrade.d.ts +227 -0
- package/dist/version.d.ts +2 -0
- package/dist/wasm.d.ts +40 -0
- package/package.json +42 -3
- package/schema/wasmlock-rules.schema.json +90 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Network } from "./network.ts";
|
|
2
|
+
/** A bad option, environment variable or endpoint. Reported as a usage error (exit 4). */
|
|
3
|
+
export declare class ConfigError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
/** Keyless public endpoints. No credentials are built in. */
|
|
7
|
+
export declare const DEFAULT_ENDPOINTS: Readonly<Record<Network, string>>;
|
|
8
|
+
/** Accepts https, and http only for a loopback host. Credentials in the URL are refused. */
|
|
9
|
+
export declare function validateEndpoint(text: string, source: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The endpoint: the `--rpc` flag, then `WASMLOCK_RPC_URL`, then the public default for the
|
|
12
|
+
* network. It is never read from the lockfile.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveEndpoint(flag: string | undefined, env: Readonly<Record<string, string | undefined>>, network: Network): string;
|
|
15
|
+
/** `WASMLOCK_RPC_HEADERS`: a JSON object of header names to string values. Values are never echoed. */
|
|
16
|
+
export declare function parseHeaders(text: string | undefined): Record<string, string>;
|
|
17
|
+
export declare const MAX_TIMEOUT_MS = 120000;
|
|
18
|
+
export declare function parseTimeout(text: string | undefined, fallback: number): number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DiffReport } from "./diff.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Text and markdown for a diff. Everything a contract, a lockfile edit or an RPC provider controls
|
|
4
|
+
* (messages, reasons, notes, the label, `uses`, type names) is written through the renderers of
|
|
5
|
+
* `src/untrusted.ts`: inert code in markdown, escaped printable text in a terminal. The fixed
|
|
6
|
+
* words, hashes, ledger numbers and contract ids are written as they are.
|
|
7
|
+
*/
|
|
8
|
+
export type DiffFormat = "text" | "json" | "md";
|
|
9
|
+
export declare function isDiffFormat(value: string): value is DiffFormat;
|
|
10
|
+
export declare function formatDiffText(report: DiffReport): string;
|
|
11
|
+
export declare function formatDiffJson(report: DiffReport): string;
|
|
12
|
+
/**
|
|
13
|
+
* The lines of a ready-to-paste section, without the scope statement, so a report that holds
|
|
14
|
+
* several contracts prints the statement once.
|
|
15
|
+
*/
|
|
16
|
+
export declare function diffMarkdownLines(report: DiffReport): string[];
|
|
17
|
+
/** A ready-to-paste pull request section. */
|
|
18
|
+
export declare function formatDiffMarkdown(report: DiffReport): string;
|
|
19
|
+
export declare function formatDiff(report: DiffReport, format: DiffFormat): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type DiffReport } from "./diff.ts";
|
|
2
|
+
import type { Lockfile } from "./lockfile.ts";
|
|
3
|
+
import type { RpcTransport } from "./rpc.ts";
|
|
4
|
+
import type { Rule } from "./rules.ts";
|
|
5
|
+
export type PendingDiff = {
|
|
6
|
+
readonly kind: "report";
|
|
7
|
+
readonly report: DiffReport;
|
|
8
|
+
}
|
|
9
|
+
/** No contract was named and none of the contracts that name rules is pending. */
|
|
10
|
+
| {
|
|
11
|
+
readonly kind: "none";
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly exitCode: 0 | 3;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Diffs the pinned interface of a contract against the CANDIDATE code of its pending upgrade: the
|
|
17
|
+
* code entry named by the hash its rule read from the instance storage, not the code it runs now.
|
|
18
|
+
* It classifies exactly as `diff` does, with the contract's `uses`. Read-only.
|
|
19
|
+
*
|
|
20
|
+
* With no `contractId` the contracts that name rules are read, and the one that is pending is
|
|
21
|
+
* diffed. Throws `ConfigError` for a contract the lockfile does not hold or that names no rules, or
|
|
22
|
+
* when several contracts are pending and none was named; `UsesError` for a `uses` name the pinned
|
|
23
|
+
* interface lacks; `NetworkMismatchError` for an endpoint of another network. Everything that
|
|
24
|
+
* cannot be read or understood is an incomplete report.
|
|
25
|
+
*/
|
|
26
|
+
export declare function diffPending(lockfile: Lockfile, contractId: string | undefined, transport: RpcTransport, usesOverride?: readonly string[], userRules?: readonly Rule[]): Promise<PendingDiff>;
|
package/dist/diff.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type ContractResult } from "./check.ts";
|
|
2
|
+
import { type InterfaceChange, type Classification, type UnreferencedRemoval } from "./interface-diff.ts";
|
|
3
|
+
import type { ContractEntry, Lockfile } from "./lockfile.ts";
|
|
4
|
+
import type { Network } from "./network.ts";
|
|
5
|
+
import type { RpcTransport } from "./rpc.ts";
|
|
6
|
+
import type { Rule } from "./rules.ts";
|
|
7
|
+
import { type WasmInterface } from "./spec.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Printed in every report, in every format. The spec is whatever the contract's author put in a
|
|
10
|
+
* custom section: nothing makes the code honor it, and most of what decides whether a re-pin is
|
|
11
|
+
* safe is not in it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SCOPE_STATEMENT: string;
|
|
14
|
+
export type DiffStatus = "unchanged" | "changed" | "incomplete";
|
|
15
|
+
export interface UsesInfo {
|
|
16
|
+
/** False when the integrator never said which functions they call. */
|
|
17
|
+
readonly declared: boolean;
|
|
18
|
+
readonly functions: readonly string[] | null;
|
|
19
|
+
readonly source: "lockfile" | "flag" | "undeclared";
|
|
20
|
+
}
|
|
21
|
+
export interface DiffReport {
|
|
22
|
+
readonly version: 1;
|
|
23
|
+
readonly network: Network;
|
|
24
|
+
readonly ledger: number | null;
|
|
25
|
+
readonly contract: {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly label: string | null;
|
|
28
|
+
};
|
|
29
|
+
readonly status: DiffStatus;
|
|
30
|
+
readonly pinnedHash: string;
|
|
31
|
+
/** The hash of the code the contract runs now. Null when it could not be determined. */
|
|
32
|
+
readonly liveHash: string | null;
|
|
33
|
+
/** Only in `diff --pending`: the code hash the pending upgrade will run, which the diff compares the pin with. */
|
|
34
|
+
readonly candidateHash?: string;
|
|
35
|
+
readonly uses: UsesInfo;
|
|
36
|
+
readonly counts: Readonly<Record<Classification, number>>;
|
|
37
|
+
readonly changes: readonly InterfaceChange[];
|
|
38
|
+
readonly unreferencedRemovals: readonly UnreferencedRemoval[];
|
|
39
|
+
/** Why the diff could not be made. Empty unless the status is incomplete. */
|
|
40
|
+
readonly reasons: readonly string[];
|
|
41
|
+
/** Things the reader should know: what was not compared and why. */
|
|
42
|
+
readonly notes: readonly string[];
|
|
43
|
+
/** 0 nothing breaking, 1 a breaking or potentially breaking change, 3 incomplete. */
|
|
44
|
+
readonly exitCode: 0 | 1 | 3;
|
|
45
|
+
readonly scope: string;
|
|
46
|
+
}
|
|
47
|
+
/** Why a pin made with `--no-snapshot` cannot be diffed. */
|
|
48
|
+
export declare const PINNED_SIDE_UNAVAILABLE = "pinned side unavailable: the lockfile entry holds only an interface digest, and the code it was taken from cannot be fetched in this version";
|
|
49
|
+
export declare const DIFF_EXIT: {
|
|
50
|
+
readonly ok: 0;
|
|
51
|
+
readonly breaking: 1;
|
|
52
|
+
readonly incomplete: 3;
|
|
53
|
+
readonly usage: 4;
|
|
54
|
+
};
|
|
55
|
+
export declare function usesInfo(entry: ContractEntry, override: readonly string[] | undefined): UsesInfo;
|
|
56
|
+
export interface Base {
|
|
57
|
+
readonly network: Network;
|
|
58
|
+
readonly ledger: number | null;
|
|
59
|
+
readonly entry: ContractEntry;
|
|
60
|
+
readonly liveHash: string | null;
|
|
61
|
+
readonly candidateHash?: string;
|
|
62
|
+
readonly uses: UsesInfo;
|
|
63
|
+
}
|
|
64
|
+
export declare function incompleteReport(base: Base, reasons: readonly string[], notes?: readonly string[]): DiffReport;
|
|
65
|
+
export declare function completeReport(base: Base, status: "unchanged" | "changed", changes: readonly InterfaceChange[], unreferencedRemovals: readonly UnreferencedRemoval[], notes: readonly string[]): DiffReport;
|
|
66
|
+
/** What the classifier finds between a pin and the live interface: the one place that decides it. */
|
|
67
|
+
export interface Classified {
|
|
68
|
+
readonly changes: readonly InterfaceChange[];
|
|
69
|
+
readonly unreferencedRemovals: readonly UnreferencedRemoval[];
|
|
70
|
+
readonly notes: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Classifies the change from a pinned entry to the live interface for the functions in `uses`.
|
|
74
|
+
* The pinned entry must hold a snapshot. Used by `diff` and by `update`, so both say the same.
|
|
75
|
+
*/
|
|
76
|
+
export declare function classifyChange(entry: ContractEntry, uses: UsesInfo, live: WasmInterface, result: ContractResult): Classified;
|
|
77
|
+
/**
|
|
78
|
+
* Diffs the pinned interface of one contract against the code it runs now. Read-only. Throws
|
|
79
|
+
* `ConfigError` for a contract the lockfile does not hold, `UsesError` when `uses` names a function
|
|
80
|
+
* the pinned interface lacks, and `NetworkMismatchError` for an endpoint of another network (all
|
|
81
|
+
* usage errors). Everything that cannot be read or understood is an incomplete report.
|
|
82
|
+
*
|
|
83
|
+
* With `uses` overridden (the `--uses` flag) the lockfile's own `uses` is ignored for this run.
|
|
84
|
+
*/
|
|
85
|
+
export declare function diffContract(lockfile: Lockfile, contractId: string, transport: RpcTransport, usesOverride?: readonly string[], userRules?: readonly Rule[]): Promise<DiffReport>;
|
package/dist/entry.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ContractResult, EntryReader } from "./check.ts";
|
|
2
|
+
import type { ContractEntry, Reach } from "./lockfile.ts";
|
|
3
|
+
import { type WasmInterface } from "./spec.ts";
|
|
4
|
+
/** Everything a pin records about the code a contract runs, every value read from the ledger. */
|
|
5
|
+
export interface LiveCode {
|
|
6
|
+
readonly reach: Reach;
|
|
7
|
+
readonly wasmHash: string;
|
|
8
|
+
readonly codeLedgerHint: number;
|
|
9
|
+
readonly instanceLedgerHint: number;
|
|
10
|
+
readonly pinnedAt: number;
|
|
11
|
+
readonly wasm: WasmInterface;
|
|
12
|
+
}
|
|
13
|
+
export type LiveRead = {
|
|
14
|
+
readonly kind: "code";
|
|
15
|
+
readonly live: LiveCode;
|
|
16
|
+
}
|
|
17
|
+
/** The contract is a Stellar Asset Contract: it has no Wasm to pin. */
|
|
18
|
+
| {
|
|
19
|
+
readonly kind: "stellar-asset";
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "incomplete";
|
|
22
|
+
readonly reasons: readonly string[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Turns an evaluated contract and the entries the evaluation read into what a pin records. Pure:
|
|
26
|
+
* it reads nothing more. Anything that is not completely known is `incomplete`, with the reason;
|
|
27
|
+
* no value is ever filled in.
|
|
28
|
+
*/
|
|
29
|
+
export declare function readLiveCode(result: ContractResult, ledger: number | null, reader: EntryReader): LiveRead;
|
|
30
|
+
/** What a pin keeps of an entry across a re-pin: the integrator's own fields. */
|
|
31
|
+
export type Kept = Pick<ContractEntry, "id" | "label" | "uses" | "pending">;
|
|
32
|
+
/**
|
|
33
|
+
* Builds the entry for what the ledger says now. With `snapshot` false only the digest is stored,
|
|
34
|
+
* which is what a pin made with `--no-snapshot` keeps. `meta` and `imports` always come from the
|
|
35
|
+
* live code.
|
|
36
|
+
*/
|
|
37
|
+
export declare function entryFromLive(kept: Kept, live: LiveCode, snapshot: boolean): ContractEntry;
|
package/dist/exit.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The process exit codes of `wasmlock check`. */
|
|
2
|
+
export declare const EXIT: {
|
|
3
|
+
readonly clean: 0;
|
|
4
|
+
readonly drift: 1;
|
|
5
|
+
readonly pending: 2;
|
|
6
|
+
readonly incomplete: 3;
|
|
7
|
+
readonly usage: 4;
|
|
8
|
+
};
|
|
9
|
+
export type Status = "clean" | "drift" | "pending" | "incomplete";
|
|
10
|
+
/**
|
|
11
|
+
* The exit code for a set of contract statuses. Precedence when mixed: drift over pending over
|
|
12
|
+
* incomplete, and incomplete is never 0. An empty set is 0: there is nothing to doubt. Usage,
|
|
13
|
+
* lockfile and configuration errors (4) never come from statuses.
|
|
14
|
+
*/
|
|
15
|
+
export declare function exitCodeOf(statuses: Iterable<Status>): 0 | 1 | 2 | 3;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export * from "./lockfile.ts";
|
|
2
|
+
export { isNetwork, NETWORK_PASSPHRASES, networkIdOf, type Network } from "./network.ts";
|
|
3
|
+
export { isContractAddress } from "./strkey.ts";
|
|
4
|
+
export type { JsonValue } from "./json.ts";
|
|
5
|
+
export { checkLockfile, formatDuration, formatReport, NetworkMismatchError } from "./check.ts";
|
|
6
|
+
export type { Change, CheckReport, ContractResult, LedgerStamp, ReachState } from "./check.ts";
|
|
7
|
+
export { EXIT, exitCodeOf, type Status } from "./exit.ts";
|
|
8
|
+
export { createRpcTransport, readLedgerEntries, RpcError } from "./rpc.ts";
|
|
9
|
+
export type { RpcTransport } from "./rpc.ts";
|
|
10
|
+
export { diffContract, DIFF_EXIT, SCOPE_STATEMENT } from "./diff.ts";
|
|
11
|
+
export type { DiffReport, DiffStatus, UsesInfo } from "./diff.ts";
|
|
12
|
+
export { formatDiff, formatDiffJson, formatDiffMarkdown, formatDiffText, isDiffFormat } from "./diff-format.ts";
|
|
13
|
+
export type { DiffFormat } from "./diff-format.ts";
|
|
14
|
+
export { assertUsesKnown, CLASSIFICATIONS, diffImports, diffMeta, diffSnapshots, isNotableMetaKey, UsesError } from "./interface-diff.ts";
|
|
15
|
+
export type { Area, InterfaceChange, Classification, InterfaceDiff, UnreferencedRemoval } from "./interface-diff.ts";
|
|
16
|
+
export { snapshotFromWasm, SpecError } from "./spec.ts";
|
|
17
|
+
export type { WasmInterface } from "./spec.ts";
|
|
18
|
+
export { interfaceDigest, reachableFrom, sortSnapshot } from "./snapshot.ts";
|
|
19
|
+
export type * from "./snapshot.ts";
|
|
20
|
+
export { MAX_WASM_BYTES, parseWasm, WasmError } from "./wasm.ts";
|
|
21
|
+
export type { ImportRef, WasmSections } from "./wasm.ts";
|
|
22
|
+
export { isTypeString, typeRefs, TypeStringError } from "./typestring.ts";
|
|
23
|
+
export { addContract } from "./add.ts";
|
|
24
|
+
export type { AddOptions, AddResult } from "./add.ts";
|
|
25
|
+
export { writeFileAtomic } from "./atomic.ts";
|
|
26
|
+
export { entryFromLive, readLiveCode } from "./entry.ts";
|
|
27
|
+
export type { LiveCode, LiveRead } from "./entry.ts";
|
|
28
|
+
export { planUpdate, PROPOSAL_STATEMENT, summarizePin } from "./update.ts";
|
|
29
|
+
export type { PinSummary, UpdateItem, UpdateOutcome, UpdatePlan, UpdateReport } from "./update.ts";
|
|
30
|
+
export { formatUpdateJson, formatUpdateMarkdown, formatUpdateText, isUpdateFormat } from "./update-report.ts";
|
|
31
|
+
export type { UpdateFormat } from "./update-report.ts";
|
|
32
|
+
export { buildChain, locateUpgrade, parseUpgradeEvent, readAuthorizers, scanUpgradeEvents } from "./upgrade.ts";
|
|
33
|
+
export type { Authorizers, FoundLocation, TransactionInfo, UpgradeEvent, UpgradeLocation } from "./upgrade.ts";
|
|
34
|
+
export { diffPending } from "./diff-pending.ts";
|
|
35
|
+
export type { PendingDiff } from "./diff-pending.ts";
|
|
36
|
+
export { PENDING_STATEMENT } from "./pending.ts";
|
|
37
|
+
export type { DecodedValue, OutcomeState, PendingState, RuleOutcome } from "./pending.ts";
|
|
38
|
+
export { loadRules, MAX_KEYS_PER_RULE, MAX_RULES, MAX_RULES_FILE_BYTES, parseRules, PRESETS, resolveRules, RULE_NAME, RULES_FILE_NAME, RulesError, validateRules, VALUE_TYPES, } from "./rules.ts";
|
|
39
|
+
export type { FireWhen, KeyPart, KeyRead, KeySpec, Rule, ValueType } from "./rules.ts";
|
|
40
|
+
export { clip, forMarkdown, forTerminal, linesForTerminal } from "./untrusted.ts";
|