@verdaccio/store 9.0.0-next-9.41 → 9.0.0-next-9.43
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/build/storage.d.ts +11 -0
- package/build/storage.js +65 -1
- package/build/storage.js.map +1 -1
- package/build/storage.mjs +65 -1
- package/build/storage.mjs.map +1 -1
- package/package.json +12 -12
package/build/storage.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PassThrough, Readable } from 'node:stream';
|
|
2
2
|
import type { searchUtils } from '@verdaccio/core';
|
|
3
3
|
import type { ISyncUplinksOptions, ProxyInstanceList, ProxySearchParams } from '@verdaccio/proxy';
|
|
4
|
+
import type { AttestationsResponse, RegistryKey } from '@verdaccio/proxy';
|
|
4
5
|
import type { RequestOptions } from '@verdaccio/url';
|
|
5
6
|
import type { AbbreviatedManifest, Config, Logger, Manifest, MergeTags, Token, TokenFilter, UnPublishManifest, Version } from '@verdaccio/types';
|
|
6
7
|
import type { UpdateManifestOptions } from '.';
|
|
@@ -17,6 +18,7 @@ declare class Storage {
|
|
|
17
18
|
readonly config: Config;
|
|
18
19
|
readonly logger: Logger;
|
|
19
20
|
readonly uplinks: ProxyInstanceList;
|
|
21
|
+
private registryKeysCache?;
|
|
20
22
|
private searchService;
|
|
21
23
|
private stageStorage;
|
|
22
24
|
constructor(config: Config, logger: Logger);
|
|
@@ -127,6 +129,15 @@ declare class Storage {
|
|
|
127
129
|
* @param tags list of dist-tags
|
|
128
130
|
*/
|
|
129
131
|
mergeTagsNext(name: string, tags: MergeTags, requestOptions?: RequestOptions): Promise<Manifest>;
|
|
132
|
+
/** Signing keys of every uplink merged by keyid, for `GET /-/npm/v1/keys`; null when none has keys. */
|
|
133
|
+
getRegistryKeys(): Promise<RegistryKey[] | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Attestations of a version, asked to the uplink recorded for it in `_distfiles` or, when
|
|
136
|
+
* unknown, to the uplinks that proxy the package in order. Null when
|
|
137
|
+
* none has them; the last lookup error is thrown when no uplink could answer.
|
|
138
|
+
*/
|
|
139
|
+
getAttestations(name: string, version: string): Promise<AttestationsResponse | null>;
|
|
140
|
+
private uplinkOfVersion;
|
|
130
141
|
/**
|
|
131
142
|
* Resolve the uplink to fetch a distfile url from, or null when the fetch
|
|
132
143
|
* must be refused.
|
package/build/storage.js
CHANGED
|
@@ -23,6 +23,7 @@ _verdaccio_search = require_runtime.__toESM(_verdaccio_search);
|
|
|
23
23
|
let _verdaccio_tarball = require("@verdaccio/tarball");
|
|
24
24
|
//#region src/storage.ts
|
|
25
25
|
var debug$1 = (0, debug.default)("verdaccio:storage");
|
|
26
|
+
var REGISTRY_KEYS_TTL = 36e5;
|
|
26
27
|
var noSuchFile = "ENOENT";
|
|
27
28
|
var resourceNotAvailable = "EAGAIN";
|
|
28
29
|
var PROTO_NAME = "__proto__";
|
|
@@ -32,6 +33,7 @@ var Storage = class {
|
|
|
32
33
|
config;
|
|
33
34
|
logger;
|
|
34
35
|
uplinks;
|
|
36
|
+
registryKeysCache;
|
|
35
37
|
searchService;
|
|
36
38
|
stageStorage = null;
|
|
37
39
|
constructor(config, logger) {
|
|
@@ -697,6 +699,68 @@ var Storage = class {
|
|
|
697
699
|
return newData;
|
|
698
700
|
});
|
|
699
701
|
}
|
|
702
|
+
/** Signing keys of every uplink merged by keyid, for `GET /-/npm/v1/keys`; null when none has keys. */
|
|
703
|
+
async getRegistryKeys() {
|
|
704
|
+
if (this.registryKeysCache && this.registryKeysCache.expires > Date.now()) return this.registryKeysCache.keys;
|
|
705
|
+
const byKeyId = /* @__PURE__ */ new Map();
|
|
706
|
+
let complete = true;
|
|
707
|
+
let lastError;
|
|
708
|
+
for (const uplinkName of Object.keys(this.uplinks)) try {
|
|
709
|
+
for (const key of await this.uplinks[uplinkName].getRegistryKeys() ?? []) {
|
|
710
|
+
const known = byKeyId.get(key.keyid);
|
|
711
|
+
if (known && known.key !== key.key) this.logger.warn({
|
|
712
|
+
uplinkName,
|
|
713
|
+
keyid: key.keyid
|
|
714
|
+
}, "uplink @{uplinkName} publishes a different key for @{keyid}, ignored");
|
|
715
|
+
else if (!known) byKeyId.set(key.keyid, key);
|
|
716
|
+
}
|
|
717
|
+
} catch (err) {
|
|
718
|
+
complete = false;
|
|
719
|
+
lastError = err;
|
|
720
|
+
this.logger.warn({
|
|
721
|
+
uplinkName,
|
|
722
|
+
err: err.message
|
|
723
|
+
}, "signing keys of uplink @{uplinkName} unavailable: @{err}");
|
|
724
|
+
}
|
|
725
|
+
if (byKeyId.size === 0 && lastError) throw lastError;
|
|
726
|
+
const keys = byKeyId.size === 0 ? null : [...byKeyId.values()];
|
|
727
|
+
if (complete) this.registryKeysCache = {
|
|
728
|
+
keys,
|
|
729
|
+
expires: Date.now() + REGISTRY_KEYS_TTL
|
|
730
|
+
};
|
|
731
|
+
return keys;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Attestations of a version, asked to the uplink recorded for it in `_distfiles` or, when
|
|
735
|
+
* unknown, to the uplinks that proxy the package in order. Null when
|
|
736
|
+
* none has them; the last lookup error is thrown when no uplink could answer.
|
|
737
|
+
*/
|
|
738
|
+
async getAttestations(name, version) {
|
|
739
|
+
const cached = await this.getPackagelocalByName(name);
|
|
740
|
+
const source = cached ? this.uplinkOfVersion(cached, version) : void 0;
|
|
741
|
+
const candidates = source ? [source] : Object.keys(this.uplinks).filter((uplinkName) => (0, _verdaccio_config.hasProxyTo)(name, uplinkName, this.config.packages));
|
|
742
|
+
let lastError;
|
|
743
|
+
for (const uplinkName of candidates) try {
|
|
744
|
+
const attestations = await this.uplinks[uplinkName].getAttestations(name, version);
|
|
745
|
+
if (attestations) return attestations;
|
|
746
|
+
lastError = void 0;
|
|
747
|
+
} catch (err) {
|
|
748
|
+
lastError = err;
|
|
749
|
+
this.logger.warn({
|
|
750
|
+
name,
|
|
751
|
+
version,
|
|
752
|
+
uplinkName,
|
|
753
|
+
err: err.message
|
|
754
|
+
}, "attestations of @{name}@@{version} unavailable on uplink @{uplinkName}: @{err}");
|
|
755
|
+
}
|
|
756
|
+
if (lastError) throw lastError;
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
uplinkOfVersion(manifest, version) {
|
|
760
|
+
const tarball = manifest.versions?.[version]?.dist?.tarball;
|
|
761
|
+
const registry = typeof tarball === "string" ? manifest._distfiles?.[_verdaccio_core.tarballUtils.extractTarballFromUrl(tarball)]?.registry : void 0;
|
|
762
|
+
return registry && this.uplinks[registry] && (0, _verdaccio_config.hasProxyTo)(manifest.name, registry, this.config.packages) ? registry : void 0;
|
|
763
|
+
}
|
|
700
764
|
/**
|
|
701
765
|
* Resolve the uplink to fetch a distfile url from, or null when the fetch
|
|
702
766
|
* must be refused.
|
|
@@ -1449,7 +1513,7 @@ var Storage = class {
|
|
|
1449
1513
|
url: version.dist.tarball,
|
|
1450
1514
|
sha: version.dist.shasum
|
|
1451
1515
|
};
|
|
1452
|
-
const upLink = version[Symbol.for("__verdaccio_uplink")];
|
|
1516
|
+
const upLink = version[Symbol.for("__verdaccio_uplink")] ?? uplinkName;
|
|
1453
1517
|
if ((0, lodash_es.isNil)(upLink) === false) this.updateUplinkToRemoteProtocol(hash, upLink);
|
|
1454
1518
|
}
|
|
1455
1519
|
}
|