@openmbee/opensysml 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,127 @@
1
+ import { OpenSysMLError } from "../core/errors.js";
2
+ import { ReleaseSigner } from "./signing.js";
3
+ /** Names a build of sysml-grpc to use, in place of any package, download or cache. */
4
+ export declare const BINARY_ENV = "OPENSYSML_BINARY";
5
+ /** Names the release to download, when the caller asks for none. */
6
+ export declare const VERSION_ENV = "OPENSYSML_GRPC_VERSION";
7
+ /** Overrides the repository releases are downloaded from. */
8
+ export declare const REPO_ENV = "OPENSYSML_GITHUB_REPO";
9
+ /** Repository whose unpinned downloads may be accepted (`1` for any): same-origin trust. */
10
+ export declare const ALLOW_UNPINNED_ENV = "OPENSYSML_ALLOW_UNPINNED_DOWNLOAD";
11
+ /** Repository releases are downloaded from unless $OPENSYSML_GITHUB_REPO names another. */
12
+ export declare const DEFAULT_GITHUB_REPO = "Open-MBEE/OpenSysML";
13
+ /** Origin a release publishes its assets at, and the API the latest tag is read from. */
14
+ export declare const RELEASES_BASE_URL = "https://github.com";
15
+ export declare const API_BASE_URL = "https://api.github.com";
16
+ /** Per-request timeout: this runs while a service is starting, so it must not hang. */
17
+ export declare const NETWORK_TIMEOUT_MS = 15000;
18
+ /** The pinned digest table, keyed by repository, release tag and asset name. */
19
+ export type PinnedDigests = Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, string>>>>>>;
20
+ /** Where a binary was found, and how. */
21
+ export interface Binary {
22
+ path: string;
23
+ /** Human-readable provenance, used in error messages and ServerInfo.origin. */
24
+ source: string;
25
+ }
26
+ /** What the cached binary was downloaded from, shared with the Python client. */
27
+ export interface CacheMetadata {
28
+ version: string;
29
+ sha256: string;
30
+ repo: string;
31
+ }
32
+ /** How a release is downloaded. Every field has a default; tests supply the seams. */
33
+ export interface DownloadOptions {
34
+ /** Release tag to install, or 'latest'; $OPENSYSML_GRPC_VERSION when omitted. */
35
+ version?: string;
36
+ /** Repository to download from; $OPENSYSML_GITHUB_REPO or the default when omitted. */
37
+ githubRepo?: string;
38
+ /** Origin release assets are published at. */
39
+ releasesBaseUrl?: string;
40
+ /** GitHub API the latest release tag is read from. */
41
+ apiBaseUrl?: string;
42
+ /** Directory the binary and its metadata are cached in. */
43
+ cacheDir?: string;
44
+ /** Platform the release asset is chosen for; this process's by default. */
45
+ platform?: string;
46
+ /** Architecture the release asset is chosen for; this process's by default. */
47
+ arch?: string;
48
+ /** Identity the release manifest's signature must carry; the pinned one when omitted. */
49
+ signer?: ReleaseSigner;
50
+ /** Digest table to verify against; the one this package ships when omitted. */
51
+ pinnedDigests?: PinnedDigests;
52
+ /** Where warnings go; Node's process warnings when omitted. */
53
+ warn?: (message: string) => void;
54
+ }
55
+ /** No usable binary was found, and none could be fetched. */
56
+ export declare class BinaryNotFoundError extends OpenSysMLError {
57
+ }
58
+ /**
59
+ * The digests this package ships, synced from client/release-digests.json: a pin
60
+ * resolved from outside the published artifact would not be a pin.
61
+ */
62
+ export declare const PINNED_SHA256: PinnedDigests;
63
+ /** The npm package that carries the service binary for this platform. */
64
+ export declare function platformPackage(platform?: string, arch?: string): string;
65
+ /** The binary's file name on this platform. */
66
+ export declare function binaryName(platform?: string): string;
67
+ /** Repository releases are downloaded from. */
68
+ export declare function defaultGithubRepo(): string;
69
+ /** Name a release publishes the service binary for a platform under. */
70
+ export declare function releaseAssetName(platform?: string, arch?: string): string;
71
+ /** The digest this release of the client pins for a release asset. */
72
+ export declare function pinnedDigest(version: string, asset: string, githubRepo?: string, table?: PinnedDigests): string | undefined;
73
+ /** Whether an unpinned download from a repository may fall back to same-origin trust. */
74
+ export declare function unpinnedDownloadsAllowed(githubRepo?: string): boolean;
75
+ /**
76
+ * The digest a download must have: the pin wherever there is one, else the signed
77
+ * manifest's, else nothing, unless same-origin trust was allowed explicitly.
78
+ */
79
+ export declare function expectedDigest(request: {
80
+ version: string;
81
+ asset: string;
82
+ servedDigest: string;
83
+ githubRepo?: string;
84
+ /** Digest from the release's signed checksum manifest, once its signature verified. */
85
+ verifiedDigest?: string;
86
+ /** Why there is no verified digest, said in the refusal when there is no pin either. */
87
+ unverifiedReason?: string;
88
+ pinnedDigests?: PinnedDigests;
89
+ warn?: (message: string) => void;
90
+ }): string;
91
+ /** URL a release publishes an asset at. */
92
+ export declare function releaseDownloadUrl(version: string, asset: string, options?: DownloadOptions): string;
93
+ /** The digest for an asset from the release's signed checksum manifest. */
94
+ export declare function signedManifestDigest(version: string, asset: string, options?: DownloadOptions): Promise<string>;
95
+ /** Resolve the tag of the repository's latest published release. */
96
+ export declare function resolveLatestVersion(options?: DownloadOptions): Promise<string>;
97
+ /** Path the downloaded binary is cached at, shared with the Python client. */
98
+ export declare function cachedBinaryPath(options?: DownloadOptions): string;
99
+ /** Path of the record of which release the cached binary was downloaded from. */
100
+ export declare function metadataPath(options?: DownloadOptions): string;
101
+ /** Read the record beside the cached binary, or nothing when it says nothing. */
102
+ export declare function readMetadata(options?: DownloadOptions): Promise<CacheMetadata | undefined>;
103
+ /** Record which release of which repository the cached binary is, and its digest. */
104
+ export declare function writeMetadata(version: string, sha256: string, options?: DownloadOptions): Promise<void>;
105
+ /**
106
+ * Release tag the cached binary was downloaded from, if from this repository: the
107
+ * digest is re-checked, so a binary swapped in by hand does not answer for it.
108
+ */
109
+ export declare function cachedRelease(options?: DownloadOptions): Promise<string | undefined>;
110
+ /**
111
+ * Why the cached binary is not the release asked for, or nothing when it is: an
112
+ * older cache would otherwise fail on whatever that build cannot do.
113
+ */
114
+ export declare function staleCacheReason(version: string | undefined, options?: DownloadOptions): Promise<string | undefined>;
115
+ /**
116
+ * Download a release's service binary and install it in the cache, replacing what is
117
+ * there only once the bytes match the digest expected of them.
118
+ */
119
+ export declare function downloadBinary(options?: DownloadOptions): Promise<string>;
120
+ /** Whether a file's SHA-256 digest is the one expected of it. */
121
+ export declare function verifyChecksum(path: string, expectedSha256: string): Promise<boolean>;
122
+ /**
123
+ * Finds a sysml-grpc binary: $OPENSYSML_BINARY, then the platform package, then a
124
+ * release download into the cache the Python client shares, then $PATH. A release is
125
+ * downloaded only when one is asked for, by `version` or $OPENSYSML_GRPC_VERSION.
126
+ */
127
+ export declare function resolveBinary(options?: DownloadOptions): Promise<Binary>;