@jini-ai/registry 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/dist/trust.js ADDED
@@ -0,0 +1,295 @@
1
+ /**
2
+ * @module trust
3
+ *
4
+ * A real (not config-asserted) verifier for `RegistryEntry.signatures[]`
5
+ * (`@jini-ai/protocol`'s `RegistrySignatureSchema`), closing the still-open half
6
+ * of SEC-RB-005 per
7
+ * `ADS-memory/reports/proposals/PROP-registry-signature-trust-verification-2026-07-21.md`
8
+ * and its follow-up sign-off: v1 supports exactly one signature `kind`,
9
+ * `'github-oidc'` — `'cosign'`/`'minisign'`/`'custom'` are recognized but
10
+ * always report `verified: false` with an explicit "unsupported kind"
11
+ * reason, never silently pass and never throw.
12
+ *
13
+ * ## What `github-oidc` actually verifies
14
+ *
15
+ * A GitHub Actions OIDC *ID token* (a short-lived JWT, `iss:
16
+ * https://token.actions.githubusercontent.com`, `exp` typically minutes in
17
+ * the future) cannot itself be the durable, at-rest proof stored in
18
+ * `RegistryEntry.signatures[]` — a registry entry is resolved and re-checked
19
+ * long after it was signed, and a raw ID token would already be expired by
20
+ * then. This is exactly why GitHub's own recommended mechanism for durable
21
+ * artifact provenance ("Artifact Attestations",
22
+ * `docs.github.com/en/actions/tutorials/publish-artifacts/verify-artifact-attestations-with-cli`)
23
+ * is Sigstore-style **keyless signing**: the short-lived OIDC token is used
24
+ * once, at signing time, to obtain a short-lived Fulcio-issued X.509
25
+ * certificate whose Subject Alternative Name (SAN) encodes the OIDC
26
+ * identity (e.g. a GitHub Actions workflow ref); that certificate's public
27
+ * key then verifies a signature that remains checkable indefinitely. This
28
+ * matches `RegistrySignatureSchema`'s own shape (`certificate` alongside
29
+ * `signature`/`issuer`/`subject`/`signedAt`) far better than a raw JWT would
30
+ * — the schema already models "signature + the cert that proves who made
31
+ * it," not "a bearer token." So `kind: 'github-oidc'` here means: a
32
+ * Sigstore/Fulcio-style keyless signature, cryptographically verified
33
+ * end-to-end by this module.
34
+ *
35
+ * ## What this module deliberately does NOT do (v1 scope)
36
+ *
37
+ * - **No Sigstore transparency-log (Rekor) inclusion-proof verification.**
38
+ * Real Sigstore verifiers don't trust "is this short-lived cert valid
39
+ * *right now*" (it never is, days/weeks after signing) — they trust "was
40
+ * there a Rekor log entry, with an independent timestamp, proving the
41
+ * signature existed while the cert was valid." This module instead trusts
42
+ * the signature's own self-reported `signedAt` field against the
43
+ * certificate's validity window (see {@link verifyRegistrySignature}) —
44
+ * `signedAt` is NOT independently attested by a timestamp authority in
45
+ * v1. A host that needs that guarantee should not rely on this alone.
46
+ * - **No Sigstore public-good root/TUF auto-discovery.** This module never
47
+ * hardcodes or fetches Sigstore's public Fulcio root — the host explicitly
48
+ * supplies the CA certificate(s) to trust via
49
+ * {@link GithubOidcTrustRoot.caCertificates} (which may be Sigstore's
50
+ * public root, a GitHub Enterprise private Fulcio-equivalent root, or any
51
+ * other CA the host chooses to trust). No network calls are made by this
52
+ * module.
53
+ * - **No revocation checking (CRL/OCSP).** Fulcio-style short-lived certs
54
+ * are designed around expiry, not revocation, matching Sigstore's own
55
+ * documented model.
56
+ * - **No Fulcio-specific custom-OID extension parsing** (e.g. the
57
+ * `1.3.6.1.4.1.57264.1.1` OIDC-issuer extension) — Node's built-in
58
+ * `X509Certificate` has no public API for arbitrary extension OIDs
59
+ * without a hand-rolled ASN.1 parser. Identity is instead read from the
60
+ * certificate's `subjectAltName` URI entries (a real, cert-bound value
61
+ * `X509Certificate` does expose) — see {@link GithubOidcTrustRoot.allowedIdentities}.
62
+ * The self-reported `signature.issuer`/`signature.subject` wire fields are
63
+ * checked too, but only as declarative/audit metadata layered on top of
64
+ * the cert-bound checks below — not the cryptographic root of trust.
65
+ *
66
+ * ## What IS cryptographically real here
67
+ *
68
+ * 1. The certificate chains (via `X509Certificate#checkIssued` +
69
+ * `X509Certificate#verify`, i.e. an actual signature check, not just a
70
+ * DN string match) to one of the host-configured
71
+ * {@link GithubOidcTrustRoot.caCertificates}.
72
+ * 2. `signature.signature` is a real cryptographic signature (verified via
73
+ * `node:crypto`'s `verify()`) over {@link canonicalRegistrySigningPayload},
74
+ * made with the certificate's own public key.
75
+ * 3. The certificate's `subjectAltName` URI (the cert-bound identity) is
76
+ * checked against {@link GithubOidcTrustRoot.allowedIdentities}, when
77
+ * configured.
78
+ */
79
+ import { X509Certificate, verify as nodeVerify } from 'node:crypto';
80
+ /** GitHub Actions' own OIDC token issuer — the default {@link GithubOidcTrustRoot.allowedIssuers} entry. */
81
+ export const GITHUB_ACTIONS_OIDC_ISSUER = 'https://token.actions.githubusercontent.com';
82
+ /**
83
+ * The exact string a `github-oidc` signature's `signature` bytes must cover.
84
+ * `@jini-ai/protocol`'s `RegistrySignatureSchema` does not itself define a
85
+ * canonical signing payload (it only models the wire shape of a signature),
86
+ * so this is this package's own convention: `name@version:digest`, where
87
+ * `digest` is whichever integrity/manifest-digest field the entry declares.
88
+ * Exported so a future signing tool can compute the exact same string this
89
+ * verifier checks against, rather than the two drifting independently.
90
+ *
91
+ * @param entry - The registry entry the signature is claimed to cover.
92
+ * @returns The canonical UTF-8 string the signature must be a valid signature over.
93
+ */
94
+ export function canonicalRegistrySigningPayload(entry) {
95
+ const digest = entry.integrity ?? entry.manifestDigest ?? entry.dist?.integrity ?? entry.dist?.manifestDigest ?? '';
96
+ return `${entry.name}@${entry.version}:${digest}`;
97
+ }
98
+ /**
99
+ * Verify one {@link RegistrySignature} against a host-configured
100
+ * {@link RegistryTrustRoot}. Never throws — a malformed certificate,
101
+ * unparseable signature, or missing trust root all resolve to
102
+ * `verified: false` with a `reason`, matching this package's existing
103
+ * "never crash a caller-facing read on untrusted input" convention (see
104
+ * `static-backend.ts`'s `validEntries()`/`doctor()`).
105
+ *
106
+ * @param entry - The entry the signature is claimed to cover (used to derive {@link canonicalRegistrySigningPayload}).
107
+ * @param signature - One entry of `entry.signatures`.
108
+ * @param trustRoot - The backend's configured trust root, if any.
109
+ * @returns The verification outcome; check `.verified` before trusting `.issuer`/`.subject`.
110
+ */
111
+ export function verifyRegistrySignature(entry, signature, trustRoot) {
112
+ if (signature.kind !== 'github-oidc') {
113
+ // Decision 1: recognize but don't implement cosign/minisign/custom —
114
+ // report "unsupported", never silently pass and never throw.
115
+ return { verified: false, kind: signature.kind, reason: `unsupported signature kind: ${signature.kind}` };
116
+ }
117
+ const root = trustRoot?.githubOidc;
118
+ if (!root || root.caCertificates.length === 0) {
119
+ // Decision 4: a backend with no configured trust root gets no
120
+ // verification at all — current (pre-this-task) behavior, unchanged.
121
+ return { verified: false, kind: signature.kind, reason: 'no github-oidc trust root configured' };
122
+ }
123
+ if (!signature.certificate) {
124
+ return { verified: false, kind: signature.kind, reason: 'github-oidc signature is missing a certificate' };
125
+ }
126
+ if (!signature.issuer) {
127
+ return { verified: false, kind: signature.kind, reason: 'github-oidc signature is missing an issuer' };
128
+ }
129
+ const allowedIssuers = root.allowedIssuers ?? [GITHUB_ACTIONS_OIDC_ISSUER];
130
+ if (!allowedIssuers.includes(signature.issuer)) {
131
+ return { verified: false, kind: signature.kind, reason: `issuer ${JSON.stringify(signature.issuer)} is not in the configured allowlist` };
132
+ }
133
+ if (!signature.signedAt) {
134
+ return { verified: false, kind: signature.kind, reason: 'github-oidc signature is missing signedAt' };
135
+ }
136
+ const signedAt = new Date(signature.signedAt);
137
+ if (Number.isNaN(signedAt.getTime())) {
138
+ return { verified: false, kind: signature.kind, reason: 'github-oidc signature has an invalid signedAt timestamp' };
139
+ }
140
+ let chain;
141
+ try {
142
+ chain = parseCertificateBundle(signature.certificate);
143
+ }
144
+ catch (cause) {
145
+ return { verified: false, kind: signature.kind, reason: `could not parse certificate: ${cause.message}` };
146
+ }
147
+ if (chain.length === 0) {
148
+ return { verified: false, kind: signature.kind, reason: 'no PEM certificate found in signature.certificate' };
149
+ }
150
+ const leaf = chain[0];
151
+ let trustedCas;
152
+ try {
153
+ trustedCas = root.caCertificates.map((pem) => new X509Certificate(pem));
154
+ }
155
+ catch (cause) {
156
+ return { verified: false, kind: signature.kind, reason: `configured trust root certificate is invalid: ${cause.message}` };
157
+ }
158
+ if (!chainToTrustedRoot(chain, trustedCas)) {
159
+ return { verified: false, kind: signature.kind, reason: 'certificate does not chain to a configured trust root' };
160
+ }
161
+ if (signedAt < leaf.validFromDate || signedAt > leaf.validToDate) {
162
+ return { verified: false, kind: signature.kind, reason: 'signedAt falls outside the certificate validity window' };
163
+ }
164
+ const identities = parseSanUris(leaf.subjectAltName);
165
+ if (root.allowedIdentities && root.allowedIdentities.length > 0) {
166
+ const matched = identities.some((identity) => root.allowedIdentities.some((pattern) => (typeof pattern === 'string' ? pattern === identity : pattern.test(identity))));
167
+ if (!matched) {
168
+ return { verified: false, kind: signature.kind, reason: 'signer identity is not in the configured allowlist' };
169
+ }
170
+ }
171
+ // `Buffer.from(str, 'base64')` never throws (Node's base64 decoder is
172
+ // lenient about invalid input, silently dropping bad characters) — a
173
+ // malformed encoding surfaces as an empty/garbage buffer that then fails
174
+ // the signature check below, not as an exception here.
175
+ const signatureBytes = Buffer.from(signature.signature, 'base64');
176
+ if (signatureBytes.length === 0) {
177
+ return { verified: false, kind: signature.kind, reason: 'signature is empty after base64 decoding' };
178
+ }
179
+ const payload = Buffer.from(canonicalRegistrySigningPayload(entry), 'utf8');
180
+ let signatureValid;
181
+ try {
182
+ // `crypto.verify()` CAN throw (not just return false) for a
183
+ // structurally-incompatible key/algorithm pairing — e.g. an Ed25519
184
+ // certificate's key does not accept an explicit 'sha256' digest
185
+ // algorithm the way RSA/ECDSA keys do. Verified empirically, not
186
+ // assumed: an Ed25519 test certificate throws
187
+ // "Provider routines::invalid digest" from this exact call.
188
+ signatureValid = nodeVerify('sha256', payload, leaf.publicKey, signatureBytes);
189
+ }
190
+ catch (cause) {
191
+ return { verified: false, kind: signature.kind, reason: `signature verification failed: ${cause.message}` };
192
+ }
193
+ if (!signatureValid) {
194
+ return { verified: false, kind: signature.kind, reason: 'signature does not match the certificate public key' };
195
+ }
196
+ const subject = signature.subject ?? identities[0];
197
+ return { verified: true, kind: signature.kind, issuer: signature.issuer, ...(subject !== undefined ? { subject } : {}) };
198
+ }
199
+ /**
200
+ * Verify every signature on `entry` against `trustRoot`, returning the first
201
+ * result that verifies, or (if none do) the last failure — so a caller gets
202
+ * a meaningful `reason` even when an entry declares multiple signatures and
203
+ * all fail.
204
+ *
205
+ * @param entry - The entry to verify.
206
+ * @param trustRoot - The backend's configured trust root, if any.
207
+ * @returns The first verifying result, or the last failing one.
208
+ */
209
+ export function verifyRegistryEntrySignatures(entry, trustRoot) {
210
+ const signatures = entry.signatures ?? [];
211
+ let last = { verified: false, reason: 'entry has no signatures' };
212
+ for (const signature of signatures) {
213
+ const result = verifyRegistrySignature(entry, signature, trustRoot);
214
+ if (result.verified)
215
+ return result;
216
+ last = result;
217
+ }
218
+ return last;
219
+ }
220
+ /** @internal Split a PEM string that may contain a leaf certificate followed by one or more intermediate certificates into individual parsed certificates, leaf first. */
221
+ function parseCertificateBundle(pem) {
222
+ const blocks = pem.match(/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g) ?? [];
223
+ return blocks.map((block) => new X509Certificate(block));
224
+ }
225
+ /**
226
+ * @internal Walk from `chain[0]` (the leaf) through any bundled
227
+ * intermediates toward a certificate in `trustedCas`, checking a genuine
228
+ * cryptographic signature at every hop (`X509Certificate#verify`, not just
229
+ * `checkIssued`'s DN-string comparison). Bounded by `chain.length +
230
+ * trustedCas.length + 1` hops so a malformed/cyclic bundle cannot loop
231
+ * forever.
232
+ */
233
+ function chainToTrustedRoot(chain, trustedCas) {
234
+ let current = chain[0];
235
+ if (!current)
236
+ return false;
237
+ const remaining = chain.slice(1);
238
+ const maxHops = chain.length + trustedCas.length + 1;
239
+ for (let hop = 0; hop < maxHops; hop += 1) {
240
+ if (trustedCas.some((ca) => certIssuedAndSignedBy(current, ca)))
241
+ return true;
242
+ const nextIndex = remaining.findIndex((candidate) => certIssuedAndSignedBy(current, candidate));
243
+ if (nextIndex === -1)
244
+ return false;
245
+ current = remaining[nextIndex];
246
+ remaining.splice(nextIndex, 1);
247
+ }
248
+ return false;
249
+ }
250
+ /**
251
+ * @internal `checkIssued` (DN linkage) AND `verify` (the actual cryptographic
252
+ * signature check) — either alone is insufficient: DN match alone proves
253
+ * nothing cryptographically. The `try`/`catch` is defense-in-depth for this
254
+ * function's own "never throw" contract, not a path this module's test
255
+ * suite demonstrates reachable: empirically, `X509Certificate#verify()`
256
+ * (unlike the standalone `crypto.verify()` function used later in this
257
+ * file, which genuinely does throw for an incompatible key/digest pairing —
258
+ * see `verifyRegistrySignature`'s doc comment on that call) was checked
259
+ * across EC/RSA/Ed25519 issuer-key combinations during this module's
260
+ * construction and consistently returned `false` rather than throwing.
261
+ * Kept anyway in case a future Node/OpenSSL version or an exotic key type
262
+ * behaves differently.
263
+ *
264
+ * **Re-verified 2026-07-22** (audit fix — re-derived independently rather than
265
+ * trusted from this comment's own prior claim): all 9 cross-combinations of
266
+ * {RSA, P-256, Ed25519} signer × tester, plus same-key self-verification for
267
+ * each, plus a P-384 cross-check, all returned a clean `boolean` — zero
268
+ * throws — against this repo's actual Node/OpenSSL (v22.22.2 / OpenSSL
269
+ * 3.0.13). `X509Certificate#verify(publicKey)` *can* throw a `TypeError`,
270
+ * but only for a malformed `publicKey` argument (a non-`KeyObject`, or a
271
+ * private key passed where a public key is required) — neither is reachable
272
+ * through this function's only call site (`chainToTrustedRoot`, which always
273
+ * passes `issuer.publicKey`, a real `X509Certificate`'s own getter, never
274
+ * arbitrary user input). The `catch` here is genuinely unreachable through
275
+ * this module's real call graph, confirmed empirically, not merely asserted.
276
+ */
277
+ function certIssuedAndSignedBy(cert, issuer) {
278
+ try {
279
+ return cert.checkIssued(issuer) && cert.verify(issuer.publicKey);
280
+ }
281
+ catch {
282
+ return false;
283
+ }
284
+ }
285
+ /** @internal Extract `URI:...` entries from an `X509Certificate#subjectAltName` string (e.g. `"URI:https://github.com/acme/example/.github/workflows/build.yml@refs/heads/main"`, comma-separated when multiple SAN entries are present). */
286
+ function parseSanUris(subjectAltName) {
287
+ if (!subjectAltName)
288
+ return [];
289
+ return subjectAltName
290
+ .split(',')
291
+ .map((part) => part.trim())
292
+ .filter((part) => part.startsWith('URI:'))
293
+ .map((part) => part.slice('URI:'.length));
294
+ }
295
+ //# sourceMappingURL=trust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trust.js","sourceRoot":"","sources":["../src/trust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAGpE,4GAA4G;AAC5G,MAAM,CAAC,MAAM,0BAA0B,GAAG,6CAA6C,CAAC;AAyDxF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAAoB;IAClE,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,IAAI,EAAE,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,cAAc,IAAI,EAAE,CAAC;IACpH,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,EAAE,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAoB,EACpB,SAA4B,EAC5B,SAAwC;IAExC,IAAI,SAAS,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QACrC,qEAAqE;QACrE,6DAA6D;QAC7D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,+BAA+B,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;IAC5G,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,EAAE,UAAU,CAAC;IACnC,I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,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAS,qBAAqB,CAAC,IAAqB,EAAE,MAAuB;IAC3E,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,6OAA6O;AAC7O,SAAS,YAAY,CAAC,cAAyC;IAC7D,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAC/B,OAAO,cAAc;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SACzC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @module versioning
3
+ *
4
+ * Registry-entry specifier parsing (`vendor/name@range`) and npm-style
5
+ * semver-range resolution (`^`/`~`/dist-tag/exact) against a
6
+ * {@link RegistryEntry}'s `versions` array. Pure — no I/O, no backend
7
+ * dependency. Shared by every `RegistryBackend` implementation in this
8
+ * package (`static`/`github`/`database`) so version-resolution semantics
9
+ * stay identical across backend kind.
10
+ */
11
+ import type { RegistryEntry } from '@jini-ai/protocol';
12
+ export interface ParsedRegistrySpecifier {
13
+ name: string;
14
+ range?: string;
15
+ }
16
+ export interface ResolvedRegistryEntryVersion {
17
+ version: string;
18
+ source: string;
19
+ ref?: string;
20
+ manifestDigest?: string;
21
+ archiveIntegrity?: string;
22
+ deprecated?: boolean | string;
23
+ }
24
+ /**
25
+ * Split a `vendor/name` or `vendor/name@range` specifier into its name and
26
+ * optional range. A bare `@` with nothing after it (`vendor/name@`) is
27
+ * treated as no range, matching how an empty trailing segment is dropped.
28
+ *
29
+ * @param input - The raw specifier string.
30
+ * @returns The parsed `{ name, range? }`.
31
+ */
32
+ export declare function parseRegistrySpecifier(input: string): ParsedRegistrySpecifier;
33
+ /**
34
+ * Resolve which of a {@link RegistryEntry}'s versions satisfies a requested
35
+ * range, following npm-style precedence: an explicit dist-tag, then an
36
+ * exact version string, then `^`/`~` range matching against non-yanked,
37
+ * non-prerelease-excluded candidates (unless the range itself pins a
38
+ * prerelease). Falls back to the entry's `distTags.latest` / top-level
39
+ * `version` when no range is requested. Returns `null` when the entry (or
40
+ * the resolved version) is yanked, or when nothing satisfies the range.
41
+ *
42
+ * @param entry - The registry entry to resolve a version against.
43
+ * @param requestedRange - An optional exact version, dist-tag, or `^`/`~` range.
44
+ * @returns The resolved version's source/ref/integrity/digest, or `null`.
45
+ */
46
+ export declare function resolveRegistryEntryVersion(entry: RegistryEntry, requestedRange?: string): ResolvedRegistryEntryVersion | null;
47
+ //# sourceMappingURL=versioning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,uBAAuB,CAS7E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,aAAa,EACpB,cAAc,CAAC,EAAE,MAAM,GACtB,4BAA4B,GAAG,IAAI,CA4BrC"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Split a `vendor/name` or `vendor/name@range` specifier into its name and
3
+ * optional range. A bare `@` with nothing after it (`vendor/name@`) is
4
+ * treated as no range, matching how an empty trailing segment is dropped.
5
+ *
6
+ * @param input - The raw specifier string.
7
+ * @returns The parsed `{ name, range? }`.
8
+ */
9
+ export function parseRegistrySpecifier(input) {
10
+ const trimmed = input.trim();
11
+ const slash = trimmed.indexOf('/');
12
+ const at = trimmed.lastIndexOf('@');
13
+ if (slash > 0 && at > slash + 1) {
14
+ const range = trimmed.slice(at + 1);
15
+ return range ? { name: trimmed.slice(0, at), range } : { name: trimmed.slice(0, at) };
16
+ }
17
+ return { name: trimmed };
18
+ }
19
+ /**
20
+ * Resolve which of a {@link RegistryEntry}'s versions satisfies a requested
21
+ * range, following npm-style precedence: an explicit dist-tag, then an
22
+ * exact version string, then `^`/`~` range matching against non-yanked,
23
+ * non-prerelease-excluded candidates (unless the range itself pins a
24
+ * prerelease). Falls back to the entry's `distTags.latest` / top-level
25
+ * `version` when no range is requested. Returns `null` when the entry (or
26
+ * the resolved version) is yanked, or when nothing satisfies the range.
27
+ *
28
+ * @param entry - The registry entry to resolve a version against.
29
+ * @param requestedRange - An optional exact version, dist-tag, or `^`/`~` range.
30
+ * @returns The resolved version's source/ref/integrity/digest, or `null`.
31
+ */
32
+ export function resolveRegistryEntryVersion(entry, requestedRange) {
33
+ if (entry.yanked)
34
+ return null;
35
+ const versions = entry.versions ?? [];
36
+ const range = requestedRange?.trim();
37
+ const defaultVersion = entry.distTags?.['latest'] ?? entry.version ?? versions.find((version) => !version.yanked)?.version;
38
+ const targetVersion = range && range !== 'latest' ? resolveRequestedVersion(entry, range) : defaultVersion;
39
+ if (!targetVersion)
40
+ return null;
41
+ const versionRecord = versions.find((version) => version.version === targetVersion);
42
+ if (versionRecord?.yanked)
43
+ return null;
44
+ const source = versionRecord?.source ?? entry.source;
45
+ if (!source)
46
+ return null;
47
+ const resolved = { version: targetVersion, source };
48
+ const ref = versionRecord?.ref ?? entry.ref;
49
+ if (ref)
50
+ resolved.ref = ref;
51
+ const manifestDigest = versionRecord?.manifestDigest ?? versionRecord?.dist?.manifestDigest ?? entry.manifestDigest ?? entry.dist?.manifestDigest;
52
+ if (manifestDigest)
53
+ resolved.manifestDigest = manifestDigest;
54
+ const archiveIntegrity = versionRecord?.integrity ?? versionRecord?.dist?.integrity ?? entry.integrity ?? entry.dist?.integrity;
55
+ if (archiveIntegrity)
56
+ resolved.archiveIntegrity = archiveIntegrity;
57
+ const deprecated = versionRecord?.deprecated ?? entry.deprecated;
58
+ if (deprecated !== undefined)
59
+ resolved.deprecated = deprecated;
60
+ return resolved;
61
+ }
62
+ /**
63
+ * Resolve an exact-version request or dist-tag lookup to a version string
64
+ * that is *proven* to exist in `entry.versions` (and is not yanked) before
65
+ * it is ever handed back to a caller alongside a source/integrity payload.
66
+ *
67
+ * Without this check, a caller could request a version that has no record
68
+ * in `entry.versions` and still receive the top-level entry's source/ref/
69
+ * integrity — silently mislabeling those bytes with the requested (but
70
+ * nonexistent) version number. See CR-008.
71
+ *
72
+ * The one legacy exception: an entry that declares no `versions` ledger at
73
+ * all (a single-version registry entry) is allowed to resolve an exact
74
+ * request that matches its own top-level `version` — there is no ledger to
75
+ * be authoritative over in that case, and the top-level fields *are* that
76
+ * version's source/integrity by construction.
77
+ */
78
+ function resolveRequestedVersion(entry, range) {
79
+ const versions = entry.versions ?? [];
80
+ const distTags = entry.distTags ?? {};
81
+ const tagged = distTags[range];
82
+ if (tagged) {
83
+ return versionExists(versions, entry, tagged) ? tagged : null;
84
+ }
85
+ if (!range.startsWith('^') && !range.startsWith('~')) {
86
+ return versionExists(versions, entry, range) ? range : null;
87
+ }
88
+ const base = parseSemver(range.slice(1));
89
+ if (!base)
90
+ return null;
91
+ const candidates = versions
92
+ .filter((version) => !version.yanked)
93
+ .map((version) => version.version)
94
+ .filter((version) => {
95
+ const parsed = parseSemver(version);
96
+ if (!parsed)
97
+ return false;
98
+ // npm excludes prerelease candidates from a range unless the range is
99
+ // itself a prerelease of the same major.minor.patch tuple (so `^0.2.0`
100
+ // never matches `0.2.1-beta.1`, but `^0.2.1-beta.1` matches 0.2.1-beta.2).
101
+ if (parsed.prerelease &&
102
+ !(base.prerelease && parsed.major === base.major && parsed.minor === base.minor && parsed.patch === base.patch)) {
103
+ return false;
104
+ }
105
+ if (range.startsWith('^')) {
106
+ // npm caret locks the leftmost non-zero component: `^1.2.3` allows
107
+ // `<2.0.0`, but `^0.2.3` only `<0.3.0` and `^0.0.3` only `<0.0.4`.
108
+ // Locking major alone wrongly resolves `^0.2.0` to a breaking `0.3.0`.
109
+ if (parsed.major !== base.major)
110
+ return false;
111
+ if (base.major === 0) {
112
+ if (parsed.minor !== base.minor)
113
+ return false;
114
+ if (base.minor === 0 && parsed.patch !== base.patch)
115
+ return false;
116
+ }
117
+ return compareSemver(parsed, base) >= 0;
118
+ }
119
+ return parsed.major === base.major && parsed.minor === base.minor && compareSemver(parsed, base) >= 0;
120
+ })
121
+ .sort((left, right) => compareSemver(parseSemver(right), parseSemver(left)));
122
+ return candidates[0] ?? null;
123
+ }
124
+ /**
125
+ * True when `version` is a real, non-yanked version of `entry`: either a
126
+ * matching, non-yanked record in `entry.versions`, or — only when
127
+ * `entry.versions` declares no ledger at all — an exact match against the
128
+ * entry's own top-level `version` (the legacy single-version case).
129
+ *
130
+ * A version that *is* present in `entry.versions` but yanked is explicitly
131
+ * rejected here rather than left for the caller to notice later, so a
132
+ * yanked exact-version/dist-tag request can never resolve.
133
+ */
134
+ function versionExists(versions, entry, version) {
135
+ const record = versions.find((candidate) => candidate.version === version);
136
+ if (record)
137
+ return !record.yanked;
138
+ // No versions ledger at all (not just "this version is missing from it")
139
+ // — fall back to treating the entry's own top-level version as the one
140
+ // version this entry has.
141
+ return versions.length === 0 && entry.version === version;
142
+ }
143
+ function parseSemver(value) {
144
+ // Capture an optional `-prerelease`; `+build` metadata is ignored for
145
+ // precedence (semver §10). The prerelease drives npm's caret/tilde exclusion.
146
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([^+]*))?(?:\+.*)?$/.exec(value);
147
+ if (!match)
148
+ return null;
149
+ // Groups 1-3 are mandatory `\d+` captures in the pattern above, so a
150
+ // successful match always populates them — the non-null assertions are
151
+ // TS-required (capture groups type as `string | undefined`) with no real
152
+ // runtime path where they're actually absent.
153
+ return {
154
+ major: Number(match[1]),
155
+ minor: Number(match[2]),
156
+ patch: Number(match[3]),
157
+ prerelease: match[4] || null,
158
+ };
159
+ }
160
+ function compareSemver(left, right) {
161
+ const core = left.major - right.major || left.minor - right.minor || left.patch - right.patch;
162
+ if (core !== 0)
163
+ return core;
164
+ return comparePrerelease(left.prerelease, right.prerelease);
165
+ }
166
+ // semver §11 precedence: a normal release outranks a prerelease of the same
167
+ // core version; otherwise compare dot-separated identifiers left to right —
168
+ // numeric ones numerically and ranked below alphanumeric, and a longer set of
169
+ // identifiers wins when all preceding ones are equal.
170
+ function comparePrerelease(left, right) {
171
+ if (!left && !right)
172
+ return 0;
173
+ if (!left)
174
+ return 1;
175
+ if (!right)
176
+ return -1;
177
+ const a = left.split('.');
178
+ const b = right.split('.');
179
+ for (let i = 0; i < Math.max(a.length, b.length); i += 1) {
180
+ const x = a[i];
181
+ const y = b[i];
182
+ if (x === undefined)
183
+ return -1;
184
+ if (y === undefined)
185
+ return 1;
186
+ const xNum = /^\d+$/.test(x);
187
+ const yNum = /^\d+$/.test(y);
188
+ if (xNum && yNum) {
189
+ const d = Number(x) - Number(y);
190
+ if (d !== 0)
191
+ return d < 0 ? -1 : 1;
192
+ }
193
+ else if (xNum) {
194
+ return -1;
195
+ }
196
+ else if (yNum) {
197
+ return 1;
198
+ }
199
+ else if (x !== y) {
200
+ return x < y ? -1 : 1;
201
+ }
202
+ }
203
+ return 0;
204
+ }
205
+ //# sourceMappingURL=versioning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versioning.js","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":"AA0BA;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IACxF,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAoB,EACpB,cAAuB;IAEvB,IAAI,KAAK,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAE9B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,cAAc,EAAE,IAAI,EAAE,CAAC;IACrC,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AC,CAAC;YAChC,IAAI,CAAC,KAAK,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,IAAI,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;aAAM,IAAI,IAAI,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC;QACX,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@jini-ai/registry",
3
+ "version": "0.1.0",
4
+ "license": "Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/AINSEP/Jini.git",
8
+ "directory": "packages/registry"
9
+ },
10
+ "jini": {
11
+ "domain": "capability",
12
+ "kind": "registry",
13
+ "runtime": "node",
14
+ "admission": "incubating"
15
+ },
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "!dist/**/*.test.js",
26
+ "!dist/**/*.test.d.ts",
27
+ "!dist/**/*.test.js.map",
28
+ "!dist/**/*.test.d.ts.map",
29
+ "!dist/**/__tests__/**"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "registry": "https://registry.npmjs.org"
34
+ },
35
+ "dependencies": {
36
+ "better-sqlite3": "^11.10.0",
37
+ "@jini-ai/protocol": "0.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/better-sqlite3": "^7.6.11"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.json",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit",
45
+ "test": "vitest run",
46
+ "test:coverage": "vitest run --coverage"
47
+ }
48
+ }