ovsx 1.1.1 → 1.3.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/README.md +73 -1
- package/lib/check-license.d.ts.map +1 -1
- package/lib/check-license.js +3 -2
- package/lib/check-license.js.map +1 -1
- package/lib/get.js +6 -6
- package/lib/get.js.map +1 -1
- package/lib/http.d.ts +32 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +170 -0
- package/lib/http.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/list-options.d.ts +24 -0
- package/lib/list-options.d.ts.map +1 -0
- package/lib/list-options.js +15 -0
- package/lib/list-options.js.map +1 -0
- package/lib/list.d.ts +18 -0
- package/lib/list.d.ts.map +1 -0
- package/lib/list.js +46 -0
- package/lib/list.js.map +1 -0
- package/lib/main.js +111 -32
- package/lib/main.js.map +1 -1
- package/lib/oidc.d.ts +22 -0
- package/lib/oidc.d.ts.map +1 -0
- package/lib/oidc.js +59 -0
- package/lib/oidc.js.map +1 -0
- package/lib/publish-options.d.ts +8 -1
- package/lib/publish-options.d.ts.map +1 -1
- package/lib/publish.d.ts.map +1 -1
- package/lib/publish.js +150 -13
- package/lib/publish.js.map +1 -1
- package/lib/registry-options.d.ts +8 -0
- package/lib/registry-options.d.ts.map +1 -1
- package/lib/registry.d.ts +161 -5
- package/lib/registry.d.ts.map +1 -1
- package/lib/registry.js +259 -100
- package/lib/registry.js.map +1 -1
- package/lib/search-options.d.ts +48 -0
- package/lib/search-options.d.ts.map +1 -0
- package/lib/search-options.js +15 -0
- package/lib/search-options.js.map +1 -0
- package/lib/search.d.ts +22 -0
- package/lib/search.d.ts.map +1 -0
- package/lib/search.js +86 -0
- package/lib/search.js.map +1 -0
- package/lib/show-options.d.ts +33 -0
- package/lib/show-options.d.ts.map +1 -0
- package/lib/show-options.js +15 -0
- package/lib/show-options.js.map +1 -0
- package/lib/show.d.ts +18 -0
- package/lib/show.d.ts.map +1 -0
- package/lib/show.js +289 -0
- package/lib/show.js.map +1 -0
- package/lib/table.d.ts +27 -0
- package/lib/table.d.ts.map +1 -0
- package/lib/table.js +56 -0
- package/lib/table.js.map +1 -0
- package/lib/trusted-publishing-options.d.ts +30 -0
- package/lib/trusted-publishing-options.d.ts.map +1 -0
- package/lib/trusted-publishing-options.js +15 -0
- package/lib/trusted-publishing-options.js.map +1 -0
- package/lib/trusted-publishing.d.ts +35 -0
- package/lib/trusted-publishing.d.ts.map +1 -0
- package/lib/trusted-publishing.js +112 -0
- package/lib/trusted-publishing.js.map +1 -0
- package/lib/unpublish-options.d.ts +34 -0
- package/lib/unpublish-options.d.ts.map +1 -0
- package/lib/unpublish-options.js +15 -0
- package/lib/unpublish-options.js.map +1 -0
- package/lib/unpublish.d.ts +22 -0
- package/lib/unpublish.d.ts.map +1 -0
- package/lib/unpublish.js +137 -0
- package/lib/unpublish.js.map +1 -0
- package/lib/util.d.ts +51 -9
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +130 -67
- package/lib/util.js.map +1 -1
- package/lib/verify-options.d.ts +24 -0
- package/lib/verify-options.d.ts.map +1 -0
- package/lib/verify-options.js +15 -0
- package/lib/verify-options.js.map +1 -0
- package/lib/verify-signature-options.d.ts +32 -0
- package/lib/verify-signature-options.d.ts.map +1 -0
- package/lib/verify-signature-options.js +15 -0
- package/lib/verify-signature-options.js.map +1 -0
- package/lib/verify-signature.d.ts +28 -0
- package/lib/verify-signature.d.ts.map +1 -0
- package/lib/verify-signature.js +105 -0
- package/lib/verify-signature.js.map +1 -0
- package/lib/verify.d.ts +21 -0
- package/lib/verify.d.ts.map +1 -0
- package/lib/verify.js +97 -0
- package/lib/verify.js.map +1 -0
- package/lib/zip.d.ts +10 -0
- package/lib/zip.d.ts.map +1 -1
- package/lib/zip.js +33 -10
- package/lib/zip.js.map +1 -1
- package/package.json +21 -14
- package/src/check-license.ts +4 -3
- package/src/get.ts +7 -7
- package/src/http.ts +176 -0
- package/src/index.ts +4 -0
- package/src/list-options.ts +25 -0
- package/src/list.ts +48 -0
- package/src/main.ts +125 -34
- package/src/oidc.ts +65 -0
- package/src/publish-options.ts +8 -1
- package/src/publish.ts +208 -14
- package/src/registry-options.ts +8 -0
- package/src/registry.ts +379 -98
- package/src/search-options.ts +49 -0
- package/src/search.ts +95 -0
- package/src/show-options.ts +34 -0
- package/src/show.ts +328 -0
- package/src/table.ts +53 -0
- package/src/trusted-publishing-options.ts +30 -0
- package/src/trusted-publishing.ts +148 -0
- package/src/unpublish-options.ts +35 -0
- package/src/unpublish.ts +160 -0
- package/src/util.ts +138 -70
- package/src/verify-options.ts +25 -0
- package/src/verify-signature-options.ts +32 -0
- package/src/verify-signature.ts +124 -0
- package/src/verify.ts +107 -0
- package/src/zip.ts +33 -13
- package/lib/version.d.ts +0 -2
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js +0 -5
- package/lib/version.js.map +0 -1
- package/src/version.ts +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
|
|
3
|
+
*
|
|
4
|
+
* See the NOTICE file(s) distributed with this work for additional
|
|
5
|
+
* information regarding copyright ownership.
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made available under the
|
|
8
|
+
* terms of the Eclipse Public License 2.0 which is available at
|
|
9
|
+
* https://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
*
|
|
11
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
12
|
+
*****************************************************************************/
|
|
13
|
+
import { Registry } from './registry';
|
|
14
|
+
import { TrustedPublishingOptions } from './trusted-publishing-options';
|
|
15
|
+
/**
|
|
16
|
+
* Whether the given options ask for trusted publishing. If the user did not decide explicitly,
|
|
17
|
+
* it is used whenever the surrounding CI system can provide an OIDC ID token.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useTrustedPublishing(options: TrustedPublishingOptions): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Exchanges an OIDC ID token for a short-lived access token that can publish the given extension.
|
|
22
|
+
* The token is not stored, it is only valid for a few minutes.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getTrustedPublishingToken(registry: Registry, namespace: string, extension: string, options: TrustedPublishingOptions): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Exchanges the ID token again after the registry refused the one this extension was publishing with.
|
|
27
|
+
* The issued token is short-lived and shared by every target platform of a release, so a slow fan-out
|
|
28
|
+
* can outlive it and be refused partway through.
|
|
29
|
+
*
|
|
30
|
+
* `stale` is the token that was refused. If the cache no longer holds it, another target has already
|
|
31
|
+
* replaced it and that exchange is awaited instead, so one expiry costs one exchange however many
|
|
32
|
+
* targets hit it at once.
|
|
33
|
+
*/
|
|
34
|
+
export declare function refreshTrustedPublishingToken(registry: Registry, namespace: string, extension: string, options: TrustedPublishingOptions, stale: string): Promise<string>;
|
|
35
|
+
//# sourceMappingURL=trusted-publishing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trusted-publishing.d.ts","sourceRoot":"","sources":["../src/trusted-publishing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;+EAW+E;AAG/E,OAAO,EAAe,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAQxE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAE/E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACrC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CACzC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,wBAAwB,EACjC,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
|
|
4
|
+
*
|
|
5
|
+
* See the NOTICE file(s) distributed with this work for additional
|
|
6
|
+
* information regarding copyright ownership.
|
|
7
|
+
*
|
|
8
|
+
* This program and the accompanying materials are made available under the
|
|
9
|
+
* terms of the Eclipse Public License 2.0 which is available at
|
|
10
|
+
* https://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
*
|
|
12
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
13
|
+
*****************************************************************************/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useTrustedPublishing = useTrustedPublishing;
|
|
16
|
+
exports.getTrustedPublishingToken = getTrustedPublishingToken;
|
|
17
|
+
exports.refreshTrustedPublishingToken = refreshTrustedPublishingToken;
|
|
18
|
+
const oidc_1 = require("./oidc");
|
|
19
|
+
const tokens = new Map();
|
|
20
|
+
// The value each cached exchange resolved to, so a token a publish was refused with can be told from one
|
|
21
|
+
// another publish has already replaced. Cleared while an exchange is in flight.
|
|
22
|
+
const issued = new Map();
|
|
23
|
+
/**
|
|
24
|
+
* Whether the given options ask for trusted publishing. If the user did not decide explicitly,
|
|
25
|
+
* it is used whenever the surrounding CI system can provide an OIDC ID token.
|
|
26
|
+
*/
|
|
27
|
+
function useTrustedPublishing(options) {
|
|
28
|
+
return options.trustedPublishing ?? (0, oidc_1.hasIdTokenSource)(options);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Exchanges an OIDC ID token for a short-lived access token that can publish the given extension.
|
|
32
|
+
* The token is not stored, it is only valid for a few minutes.
|
|
33
|
+
*/
|
|
34
|
+
function getTrustedPublishingToken(registry, namespace, extension, options) {
|
|
35
|
+
// publishing fans out over targets and package paths, but one token is enough per extension
|
|
36
|
+
const key = `${namespace}.${extension}`;
|
|
37
|
+
return tokens.get(key) ?? exchange(key, registry, namespace, extension, options);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Exchanges the ID token again after the registry refused the one this extension was publishing with.
|
|
41
|
+
* The issued token is short-lived and shared by every target platform of a release, so a slow fan-out
|
|
42
|
+
* can outlive it and be refused partway through.
|
|
43
|
+
*
|
|
44
|
+
* `stale` is the token that was refused. If the cache no longer holds it, another target has already
|
|
45
|
+
* replaced it and that exchange is awaited instead, so one expiry costs one exchange however many
|
|
46
|
+
* targets hit it at once.
|
|
47
|
+
*/
|
|
48
|
+
function refreshTrustedPublishingToken(registry, namespace, extension, options, stale) {
|
|
49
|
+
const key = `${namespace}.${extension}`;
|
|
50
|
+
const current = tokens.get(key);
|
|
51
|
+
if (current && issued.get(key) !== stale) {
|
|
52
|
+
return current;
|
|
53
|
+
}
|
|
54
|
+
return exchange(key, registry, namespace, extension, options);
|
|
55
|
+
}
|
|
56
|
+
function exchange(key, registry, namespace, extension, options) {
|
|
57
|
+
// Dropped up front, so a refresh that is still in flight does not look like the stale token to the
|
|
58
|
+
// next caller and start a second exchange of its own.
|
|
59
|
+
issued.delete(key);
|
|
60
|
+
const token = requestToken(registry, namespace, extension, options).then(value => {
|
|
61
|
+
issued.set(key, value);
|
|
62
|
+
return value;
|
|
63
|
+
});
|
|
64
|
+
tokens.set(key, token);
|
|
65
|
+
return token;
|
|
66
|
+
}
|
|
67
|
+
// The registry answers 503 when it could not reach the identity provider to check the token, as opposed
|
|
68
|
+
// to checking it and refusing. That is worth another go: publishing runs unattended on CI, and a blip
|
|
69
|
+
// reaching GitHub or GitLab should not fail a release build. A refusal is never retried.
|
|
70
|
+
const RETRYABLE_STATUS = [502, 503, 504];
|
|
71
|
+
const RETRY_DELAYS_MS = [1000, 4000];
|
|
72
|
+
async function requestToken(registry, namespace, extension, options) {
|
|
73
|
+
const audience = options.oidcAudience ?? registry.url;
|
|
74
|
+
const idToken = await (0, oidc_1.getIdToken)(audience, options);
|
|
75
|
+
let result;
|
|
76
|
+
try {
|
|
77
|
+
result = await exchangeWithRetry(registry, namespace, extension, idToken);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
throw new Error(`${err.message}\n${registrationHint(registry, namespace, extension)}`);
|
|
81
|
+
}
|
|
82
|
+
if (result.error) {
|
|
83
|
+
throw new Error(`${result.error}\n${registrationHint(registry, namespace, extension)}`);
|
|
84
|
+
}
|
|
85
|
+
if (!result.value) {
|
|
86
|
+
throw new Error('The registry did not return a publishing token.');
|
|
87
|
+
}
|
|
88
|
+
const expires = result.expiresTimestamp ? `, expires at ${result.expiresTimestamp}` : '';
|
|
89
|
+
console.log(`\ud83d\udd10 Trusted publishing token issued for ${namespace}.${extension}${expires}`);
|
|
90
|
+
return result.value;
|
|
91
|
+
}
|
|
92
|
+
async function exchangeWithRetry(registry, namespace, extension, idToken) {
|
|
93
|
+
for (let attempt = 0;; attempt++) {
|
|
94
|
+
try {
|
|
95
|
+
return await registry.requestTrustedPublishingToken(namespace, extension, idToken);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
const status = err?.status;
|
|
99
|
+
if (attempt >= RETRY_DELAYS_MS.length || status === undefined || !RETRYABLE_STATUS.includes(status)) {
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
const delay = RETRY_DELAYS_MS[attempt];
|
|
103
|
+
console.log(`The registry could not verify the token (${status}), retrying in ${delay / 1000}s`);
|
|
104
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function registrationHint(registry, namespace, extension) {
|
|
109
|
+
return `Check the trusted publishers registered for '${namespace}.${extension}' at `
|
|
110
|
+
+ `${registry.url}/user-settings/trusted-publishers.`;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=trusted-publishing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trusted-publishing.js","sourceRoot":"","sources":["../src/trusted-publishing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;+EAW+E;;AAiB/E,oDAEC;AAMD,8DASC;AAWD,sEAcC;AAzDD,iCAAsD;AAKtD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;AAElD,yGAAyG;AACzG,gFAAgF;AAChF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEzC;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,OAAiC;IAClE,OAAO,OAAO,CAAC,iBAAiB,IAAI,IAAA,uBAAgB,EAAC,OAAO,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,SAAgB,yBAAyB,CACrC,QAAkB,EAClB,SAAiB,EACjB,SAAiB,EACjB,OAAiC;IAEjC,4FAA4F;IAC5F,MAAM,GAAG,GAAG,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC;IACxC,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACrF,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CACzC,QAAkB,EAClB,SAAiB,EACjB,SAAiB,EACjB,OAAiC,EACjC,KAAa;IAEb,MAAM,GAAG,GAAG,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;QACvC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAA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CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAkB,EAAE,SAAiB,EAAE,SAAiB;IAC9E,OAAO,gDAAgD,SAAS,IAAI,SAAS,OAAO;UAC9E,GAAG,QAAQ,CAAC,GAAG,oCAAoC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
|
|
3
|
+
*
|
|
4
|
+
* See the NOTICE file(s) distributed with this work for additional
|
|
5
|
+
* information regarding copyright ownership.
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made available under the
|
|
8
|
+
* terms of the Eclipse Public License 2.0 which is available at
|
|
9
|
+
* https://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
*
|
|
11
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
12
|
+
*****************************************************************************/
|
|
13
|
+
import { RegistryOptions } from './registry-options';
|
|
14
|
+
export interface UnpublishOptions extends RegistryOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Identifier in the form `namespace.extension` or `namespace/extension`.
|
|
17
|
+
* Read from the `package.json` in the current directory if omitted.
|
|
18
|
+
*/
|
|
19
|
+
extensionId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Versions to delete. All versions are deleted if omitted.
|
|
22
|
+
*/
|
|
23
|
+
versions?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Target platforms to delete. All target platforms of the selected versions
|
|
26
|
+
* are deleted if omitted. Can only be used together with `versions`.
|
|
27
|
+
*/
|
|
28
|
+
targets?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Delete without asking for confirmation.
|
|
31
|
+
*/
|
|
32
|
+
force?: boolean;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=unpublish-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpublish-options.d.ts","sourceRoot":"","sources":["../src/unpublish-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;+EAW+E;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACrD;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
|
|
4
|
+
*
|
|
5
|
+
* See the NOTICE file(s) distributed with this work for additional
|
|
6
|
+
* information regarding copyright ownership.
|
|
7
|
+
*
|
|
8
|
+
* This program and the accompanying materials are made available under the
|
|
9
|
+
* terms of the Eclipse Public License 2.0 which is available at
|
|
10
|
+
* https://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
*
|
|
12
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
13
|
+
*****************************************************************************/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
//# sourceMappingURL=unpublish-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpublish-options.js","sourceRoot":"","sources":["../src/unpublish-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;+EAW+E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
|
|
3
|
+
*
|
|
4
|
+
* See the NOTICE file(s) distributed with this work for additional
|
|
5
|
+
* information regarding copyright ownership.
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made available under the
|
|
8
|
+
* terms of the Eclipse Public License 2.0 which is available at
|
|
9
|
+
* https://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
*
|
|
11
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
12
|
+
*****************************************************************************/
|
|
13
|
+
import { UnpublishOptions } from './unpublish-options';
|
|
14
|
+
/**
|
|
15
|
+
* Oldest registry version that exposes the `delete` endpoint used by this command.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MIN_UNPUBLISH_REGISTRY_VERSION = "1.2.0";
|
|
18
|
+
/**
|
|
19
|
+
* Deletes an extension or some of its versions from the registry.
|
|
20
|
+
*/
|
|
21
|
+
export declare function unpublish(options?: UnpublishOptions): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=unpublish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpublish.d.ts","sourceRoot":"","sources":["../src/unpublish.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;+EAW+E;AAY/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD;;GAEG;AACH,eAAO,MAAM,8BAA8B,UAAU,CAAC;AAEtD;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B7E"}
|
package/lib/unpublish.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
|
|
4
|
+
*
|
|
5
|
+
* See the NOTICE file(s) distributed with this work for additional
|
|
6
|
+
* information regarding copyright ownership.
|
|
7
|
+
*
|
|
8
|
+
* This program and the accompanying materials are made available under the
|
|
9
|
+
* terms of the Eclipse Public License 2.0 which is available at
|
|
10
|
+
* https://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
*
|
|
12
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
13
|
+
*****************************************************************************/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MIN_UNPUBLISH_REGISTRY_VERSION = void 0;
|
|
16
|
+
exports.unpublish = unpublish;
|
|
17
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
18
|
+
// `import * as isCI from 'is-ci'` would bind to a namespace object instead of the boolean `is-ci`
|
|
19
|
+
// exports whenever the importer applies ES module interop (e.g. a bundler, or vitest's own
|
|
20
|
+
// transform), making the truthiness check below always true. `import = require` always binds
|
|
21
|
+
// directly to the exported value, regardless of how the importing tool handles interop.
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
23
|
+
const isCI = require("is-ci");
|
|
24
|
+
const semver = require("semver");
|
|
25
|
+
const pat_1 = require("./pat");
|
|
26
|
+
const registry_1 = require("./registry");
|
|
27
|
+
const util_1 = require("./util");
|
|
28
|
+
/**
|
|
29
|
+
* Oldest registry version that exposes the `delete` endpoint used by this command.
|
|
30
|
+
*/
|
|
31
|
+
exports.MIN_UNPUBLISH_REGISTRY_VERSION = '1.2.0';
|
|
32
|
+
/**
|
|
33
|
+
* Deletes an extension or some of its versions from the registry.
|
|
34
|
+
*/
|
|
35
|
+
async function unpublish(options = {}) {
|
|
36
|
+
(0, util_1.addEnvOptions)(options);
|
|
37
|
+
if (options.targets && !options.versions) {
|
|
38
|
+
throw new Error("Please specify the versions to delete with '--versions' when using '--target'.");
|
|
39
|
+
}
|
|
40
|
+
const extensionId = options.extensionId ?? await readExtensionId();
|
|
41
|
+
const match = (0, util_1.matchExtensionId)(extensionId);
|
|
42
|
+
if (!match) {
|
|
43
|
+
throw new Error('The extension identifier must have the form `namespace.extension` or `namespace/extension`.');
|
|
44
|
+
}
|
|
45
|
+
const [, namespace, extension] = match;
|
|
46
|
+
const registry = new registry_1.Registry(options);
|
|
47
|
+
await ensureUnpublishSupported(registry);
|
|
48
|
+
options.pat = await (0, pat_1.getPAT)(namespace, { ...options, namespace }, false);
|
|
49
|
+
const targetVersions = getTargetVersions(options);
|
|
50
|
+
await confirmUnpublish(`${namespace}.${extension}`, targetVersions, registry.url, options.force);
|
|
51
|
+
const result = await registry.deleteExtension(namespace, extension, targetVersions, options.pat);
|
|
52
|
+
if (result.error) {
|
|
53
|
+
throw new Error(result.error);
|
|
54
|
+
}
|
|
55
|
+
// the registry reports one line per deleted version, and nothing at all if there was nothing to delete
|
|
56
|
+
console.log(`🗑 ${result.success || `Nothing to delete for ${namespace}.${extension}`}`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reads the extension identifier from the `package.json` in the current directory,
|
|
60
|
+
* so that `ovsx unpublish` can be run from an extension folder without arguments.
|
|
61
|
+
*/
|
|
62
|
+
async function readExtensionId() {
|
|
63
|
+
let error;
|
|
64
|
+
try {
|
|
65
|
+
const manifest = await (0, util_1.readManifest)();
|
|
66
|
+
if (manifest.publisher && manifest.name) {
|
|
67
|
+
return `${manifest.publisher}.${manifest.name}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
error = e;
|
|
72
|
+
}
|
|
73
|
+
throw new Error('Unable to read the extension identifier. Please supply it as an argument or run ovsx from the extension folder.' +
|
|
74
|
+
(error ? `\n\n${error}` : ''));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fails fast with an actionable message when the registry is known to be too old to support
|
|
78
|
+
* deleting extensions, rather than letting the delete request fail with a generic 404.
|
|
79
|
+
*
|
|
80
|
+
* The check is best-effort: registries that don't expose `/api/version` at all, or report a
|
|
81
|
+
* version that can't be parsed as semver (e.g. a build without `ovsx.registry.version` set),
|
|
82
|
+
* are assumed to support the endpoint. The delete request itself will surface any real
|
|
83
|
+
* incompatibility in that case.
|
|
84
|
+
*/
|
|
85
|
+
async function ensureUnpublishSupported(registry) {
|
|
86
|
+
let reportedVersion;
|
|
87
|
+
try {
|
|
88
|
+
reportedVersion = (await registry.getRegistryVersion()).version;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// `coerce` drops any prerelease/build suffix (e.g. `1.2.0-dev.0` or `1.2.0-SNAPSHOT` both
|
|
94
|
+
// become `1.2.0`), so development builds of a supported release compare as supported too.
|
|
95
|
+
const version = semver.coerce(reportedVersion);
|
|
96
|
+
if (version && semver.lt(version, exports.MIN_UNPUBLISH_REGISTRY_VERSION)) {
|
|
97
|
+
throw new Error(`The registry at ${registry.url} runs version ${reportedVersion}, but deleting extensions requires `
|
|
98
|
+
+ `version ${exports.MIN_UNPUBLISH_REGISTRY_VERSION} or later.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the versions to delete, or `undefined` to delete the extension as a whole.
|
|
103
|
+
* A version without target platform tells the registry to delete all target platforms
|
|
104
|
+
* of that version.
|
|
105
|
+
*/
|
|
106
|
+
function getTargetVersions(options) {
|
|
107
|
+
if (!options.versions) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (!options.targets) {
|
|
111
|
+
return options.versions.map(version => ({ version }));
|
|
112
|
+
}
|
|
113
|
+
return options.versions.flatMap(version => options.targets.map(targetPlatform => ({ version, targetPlatform })));
|
|
114
|
+
}
|
|
115
|
+
async function confirmUnpublish(extensionId, targetVersions, registryUrl, force) {
|
|
116
|
+
if (force) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (isCI || !process.stdin.isTTY) {
|
|
120
|
+
throw new Error("Aborted. Use '--force' to delete without confirmation.");
|
|
121
|
+
}
|
|
122
|
+
const what = targetVersions
|
|
123
|
+
? targetVersions.map(target => describe(extensionId, target)).join(', ')
|
|
124
|
+
: `all versions of ${extensionId}`;
|
|
125
|
+
const confirmed = await (0, prompts_1.confirm)({
|
|
126
|
+
message: `Delete ${what} from ${registryUrl}? Deleted versions can never be published again.`,
|
|
127
|
+
default: false
|
|
128
|
+
});
|
|
129
|
+
if (!confirmed) {
|
|
130
|
+
throw new Error('Aborted.');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function describe(extensionId, target) {
|
|
134
|
+
const version = `${extensionId} v${target.version}`;
|
|
135
|
+
return target.targetPlatform ? `${version}@${target.targetPlatform}` : version;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=unpublish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpublish.js","sourceRoot":"","sources":["../src/unpublish.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;+EAW+E;;;AAuB/E,8BA2BC;AAhDD,+CAA4C;AAC5C,kGAAkG;AAClG,2FAA2F;AAC3F,6FAA6F;AAC7F,wFAAwF;AACxF,iEAAiE;AACjE,8BAA+B;AAC/B,iCAAiC;AACjC,+BAA+B;AAC/B,yCAA6D;AAE7D,iCAAuE;AAEvE;;GAEG;AACU,QAAA,8BAA8B,GAAG,OAAO,CAAC;AAEtD;;GAEG;AACI,KAAK,UAAU,SAAS,CAAC,UAA4B,EAAE;IAC1D,IAAA,oBAAa,EAAC,OAAO,CAAC,CAAC;IACvB,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACtG,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,MAAM,eAAe,EAAE,CAAC;IACnE,MAAM,KAAK,GAAG,IAAA,uBAAgB,EAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,6FAA6F,CAAC,CAAC;IACnH,CAAC;IAED,MAAM,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,wBAAwB,CAAC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AAK,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,IAAI,GAAG,cAAc;QACvB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACxE,CAAC,CAAC,mBAAmB,WAAW,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,MAAM,IAAA,iBAAO,EAAC;QAC5B,OAAO,EAAE,UAAU,IAAI,SAAS,WAAW,kDAAkD;QAC7F,OAAO,EAAE,KAAK;KACjB,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAC,WAAmB,EAAE,MAA6B;IAChE,MAAM,OAAO,GAAG,GAAG,WAAW,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;IACpD,OAAO,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACnF,CAAC"}
|
package/lib/util.d.ts
CHANGED
|
@@ -7,23 +7,65 @@
|
|
|
7
7
|
*
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
********************************************************************************/
|
|
10
|
-
import * as fs from 'fs';
|
|
11
|
-
import * as tmp from 'tmp';
|
|
12
10
|
import * as http from 'http';
|
|
13
11
|
import { RegistryOptions } from './registry-options';
|
|
14
|
-
|
|
12
|
+
import { TrustedPublishingOptions } from './trusted-publishing-options';
|
|
15
13
|
export declare function addEnvOptions(options: RegistryOptions): void;
|
|
14
|
+
export declare function addTrustedPublishingEnvOptions(options: TrustedPublishingOptions): void;
|
|
15
|
+
/** How long a request may make no progress before it is abandoned; see RegistryOptions.timeout. */
|
|
16
|
+
export declare const DEFAULT_TIMEOUT = 30000;
|
|
17
|
+
/**
|
|
18
|
+
* The configured request timeout, for requests that have no RegistryOptions to read it from - the CI
|
|
19
|
+
* token exchange deliberately shares nothing with the registry, but there is no reason for it to be
|
|
20
|
+
* on a different clock.
|
|
21
|
+
*/
|
|
22
|
+
export declare function configuredTimeout(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Parses a commander option that must be a non-negative whole number, so a typo is reported by the
|
|
25
|
+
* CLI rather than sent to the registry as a bad request.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseNonNegativeInt(value: string): number;
|
|
16
28
|
export declare function matchExtensionId(id: string): RegExpExecArray | null;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Levenshtein distance between `a` and `b`: the minimum number of single-character insertions,
|
|
31
|
+
* deletions or substitutions needed to turn one into the other. Used to suggest the closest known
|
|
32
|
+
* command for a typo.
|
|
33
|
+
*/
|
|
34
|
+
export declare function levenshtein(a: string, b: string): number;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a random, not-yet-created file path ending in `postfix`, directly in the OS temp directory.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getTempFilePath(postfix?: string): string;
|
|
20
39
|
export declare function rejectError(err: any): Promise<never>;
|
|
21
40
|
export declare function handleError(debug?: boolean, additionalMessage?: string, exit?: boolean): (reason: any) => void;
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Formats a byte count for display, e.g. `1536` -> `1.5 KB`. Mirrors the registry's own
|
|
43
|
+
* `FileUtils.byteCountToDisplaySize` formatting so client- and server-side size limit messages read
|
|
44
|
+
* the same way.
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatBytes(bytes: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* An error carrying the HTTP status that produced it, so a caller can tell "the registry refused this"
|
|
49
|
+
* from "the registry could not answer right now" without matching on the message.
|
|
50
|
+
*/
|
|
51
|
+
export interface StatusError extends Error {
|
|
52
|
+
status?: number;
|
|
53
|
+
}
|
|
54
|
+
export declare function withStatus(error: Error, status?: number): StatusError;
|
|
55
|
+
/**
|
|
56
|
+
* A URL in the form it can safely be printed: no user info and no query string.
|
|
57
|
+
*
|
|
58
|
+
* The personal access token travels in a header now, but `createNamespace`, `verifyPat`, `publish`
|
|
59
|
+
* and `delete` still carry it in the query string too when talking to a registry too old to resolve
|
|
60
|
+
* it from the header (see `Registry.tokenQuery`, #1344). An error message goes straight to stderr
|
|
61
|
+
* and from there into CI logs, and the query carries nothing an error needs - so it stays dropped
|
|
62
|
+
* whole rather than filtered key by key, a filter having to be kept in step with every parameter
|
|
63
|
+
* anyone ever adds.
|
|
64
|
+
*/
|
|
65
|
+
export declare function redactUrl(url: URL | string): string;
|
|
66
|
+
export declare function statusError(response: http.IncomingMessage): StatusError;
|
|
24
67
|
export declare function readManifest(packagePath?: string): Promise<Manifest>;
|
|
25
68
|
export declare function validateManifest(manifest: Manifest): void;
|
|
26
|
-
export declare function writeFile(name: string, content: string, packagePath?: string, encoding?: BufferEncoding): Promise<void>;
|
|
27
69
|
export declare function writeManifest(manifest: Manifest, packagePath?: string): Promise<void>;
|
|
28
70
|
export interface Manifest {
|
|
29
71
|
publisher: string;
|
package/lib/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;kFAQkF;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;kFAQkF;AAMlF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE,wBAAgB,aAAa,CAAC,OAAO,EAAE,eA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