codekingpro/portable-devtools
114k
1<!DOCTYPE html><html><head>
2<meta charset="utf-8">
3<title>npm-trust</title>
4<style>
5body {
6 background-color: #ffffff;
7 color: #24292e;
8
9 margin: 0;
10
11 line-height: 1.5;
12
13 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
14}
15#rainbar {
16 height: 10px;
17 background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
18}
19
20a {
21 text-decoration: none;
22 color: #0366d6;
23}
24a:hover {
25 text-decoration: underline;
26}
27
28pre {
29 margin: 1em 0px;
30 padding: 1em;
31 border: solid 1px #e1e4e8;
32 border-radius: 6px;
33
34 display: block;
35 overflow: auto;
36
37 white-space: pre;
38
39 background-color: #f6f8fa;
40 color: #393a34;
41}
42code {
43 font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
44 font-size: 85%;
45 padding: 0.2em 0.4em;
46 background-color: #f6f8fa;
47 color: #393a34;
48}
49pre > code {
50 padding: 0;
51 background-color: inherit;
52 color: inherit;
53}
54h1, h2, h3 {
55 font-weight: 600;
56}
57
58#logobar {
59 background-color: #333333;
60 margin: 0 auto;
61 padding: 1em 4em;
62}
63#logobar .logo {
64 float: left;
65}
66#logobar .title {
67 font-weight: 600;
68 color: #dddddd;
69 float: left;
70 margin: 5px 0 0 1em;
71}
72#logobar:after {
73 content: "";
74 display: block;
75 clear: both;
76}
77
78#content {
79 margin: 0 auto;
80 padding: 0 4em;
81}
82
83#table_of_contents > h2 {
84 font-size: 1.17em;
85}
86#table_of_contents ul:first-child {
87 border: solid 1px #e1e4e8;
88 border-radius: 6px;
89 padding: 1em;
90 background-color: #f6f8fa;
91 color: #393a34;
92}
93#table_of_contents ul {
94 list-style-type: none;
95 padding-left: 1.5em;
96}
97#table_of_contents li {
98 font-size: 0.9em;
99}
100#table_of_contents li a {
101 color: #000000;
102}
103
104header.title {
105 border-bottom: solid 1px #e1e4e8;
106}
107header.title > h1 {
108 margin-bottom: 0.25em;
109}
110header.title > .description {
111 display: block;
112 margin-bottom: 0.5em;
113 line-height: 1;
114}
115
116header.title .version {
117 font-size: 0.8em;
118 color: #666666;
119}
120
121footer#edit {
122 border-top: solid 1px #e1e4e8;
123 margin: 3em 0 4em 0;
124 padding-top: 2em;
125}
126
127table {
128 width: 100%;
129 margin: 1em 0;
130 border-radius: 6px;
131 border: 1px solid #e1e4e8;
132 overflow: hidden;
133 border-collapse: separate;
134 border-spacing: 0;
135}
136
137table thead {
138 background-color: #f6f8fa;
139}
140
141table tbody {
142 background-color: #ffffff;
143}
144
145table th,
146table td {
147 padding: 0.75em;
148 text-align: left;
149 border-right: 1px solid #e1e4e8;
150 border-bottom: 1px solid #e1e4e8;
151}
152
153table th:last-child,
154table td:last-child {
155 border-right: none;
156}
157
158table tbody tr:last-child td {
159 border-bottom: none;
160}
161
162table th {
163 font-weight: 600;
164 background-color: #f6f8fa;
165}
166
167table code {
168 white-space: nowrap;
169}
170
171</style>
172</head>
173<body>
174<div id="banner">
175<div id="rainbar"></div>
176<div id="logobar">
177<svg class="logo" role="img" height="32" width="32" viewBox="0 0 700 700">
178<polygon fill="#cb0000" points="0,700 700,700 700,0 0,0"></polygon>
179<polygon fill="#ffffff" points="150,550 350,550 350,250 450,250 450,550 550,550 550,150 150,150"></polygon>
180</svg>
181<div class="title">
182npm command-line interface
183</div>
184</div>
185</div>
186
187<section id="content">
188<header class="title">
189<h1 id="----npm-trust----11121">
190 <span>npm-trust</span>
191 <span class="version">@11.12.1</span>
192</h1>
193<span class="description">Manage trusted publishing relationships between packages and CI/CD providers</span>
194</header>
195
196<section id="table_of_contents">
197<h2 id="table-of-contents">Table of contents</h2>
198<div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#prerequisites">Prerequisites</a></li><li><a href="#description">Description</a></li><li><a href="#bulk-usage">Bulk Usage</a></li><li><a href="#configuration">Configuration</a></li><li><a href="#npm-trust-github"><code>npm trust github</code></a></li><ul><li><a href="#synopsis2">Synopsis</a></li><li><a href="#flags">Flags</a></li></ul><li><a href="#npm-trust-gitlab"><code>npm trust gitlab</code></a></li><ul><li><a href="#synopsis3">Synopsis</a></li><li><a href="#flags2">Flags</a></li></ul><li><a href="#npm-trust-circleci"><code>npm trust circleci</code></a></li><ul><li><a href="#synopsis4">Synopsis</a></li><li><a href="#flags3">Flags</a></li></ul><li><a href="#npm-trust-list"><code>npm trust list</code></a></li><ul><li><a href="#synopsis5">Synopsis</a></li><li><a href="#flags4">Flags</a></li></ul><li><a href="#npm-trust-revoke"><code>npm trust revoke</code></a></li><ul><li><a href="#synopsis6">Synopsis</a></li><li><a href="#flags5">Flags</a></li></ul><li><a href="#see-also">See Also</a></li></ul></div>
199</section>
200
201<div id="_content"><h3 id="synopsis">Synopsis</h3>
202<p>Note: This command is unaware of workspaces.</p>
203<h3 id="prerequisites">Prerequisites</h3>
204<p>Before using npm trust commands, ensure the following requirements are met:</p>
205<ul>
206<li><strong>npm version</strong>: <code>npm@11.10.0</code> or above is required. Use <code>npm install -g npm@^11.10.0</code> to update if needed.</li>
207<li><strong>Write permissions on the package</strong>: You must have write access to the package you're configuring.</li>
208<li><strong>2FA enabled on account</strong>: Two-factor authentication must be enabled at the account level. Even if it's not currently enabled, you must enable it to use trust commands.</li>
209<li><strong>Supported authentication methods</strong>: Granular Access Tokens (GAT) with the bypass 2FA option are not supported. Legacy basic auth (username and password) credentials will not work for trust commands or endpoints.</li>
210<li><strong>Package must exist</strong>: The package you're configuring must already exist on the npm registry.</li>
211</ul>
212<h3 id="description">Description</h3>
213<p>Configure trust relationships between npm packages and CI/CD providers using OpenID Connect (OIDC). This is the command-line equivalent of managing trusted publisher configurations on the npm website.</p>
214<p>For a comprehensive overview of trusted publishing, see the <a href="https://docs.npmjs.com/trusted-publishers">npm trusted publishers documentation</a>.</p>
215<p>The <code>[package]</code> argument specifies the package name. If omitted, npm will use the name from the <code>package.json</code> in the current directory.</p>
216<p>Each trust relationship has its own set of configuration options and flags based on the OIDC claims provided by that provider. OIDC claims come from the CI/CD provider and include information such as repository name, workflow file, or environment. Since each provider's claims differ, the available flags and configuration keys are not universal—npm matches the claims supported by each provider's OIDC configuration. For specific details on which claims and flags are supported for a given provider, use <code>npm trust <provider> --help</code>.</p>
217<p>The required options depend on the CI/CD provider you're configuring. Detailed information about each option is available in the <a href="https://docs.npmjs.com/trusted-publishers#managing-trusted-publisher-configurations">managing trusted publisher configurations</a> section of the npm documentation. If a provider is repository-based and the option is not provided, npm will use the <code>repository.url</code> field from your <code>package.json</code>, if available.</p>
218<p>Currently, the registry only supports one configuration per package. If you attempt to create a new trust relationship when one already exists, it will result in an error. To replace an existing configuration:</p>
219<ol>
220<li>Use <code>npm trust list [package]</code> to view the ID of the existing trusted publisher</li>
221<li>Use <code>npm trust revoke --id <id> [package]</code> to remove the existing configuration</li>
222<li>Then create your new trust relationship</li>
223</ol>
224<h3 id="bulk-usage">Bulk Usage</h3>
225<p>For maintainers managing a large number of packages, you can configure trusted publishing in bulk using bash scripting. Create a loop that iterates through package names and their corresponding configuration details, executing the <code>npm trust <provider></code> command with the <code>--yes</code> flag for each package.</p>
226<p>The first request will require two-factor authentication. During two-factor authentication, you'll see an option on the npm website to skip two-factor authentication for the next 5 minutes. Enabling this option will allow subsequent <code>npm trust <provider></code> commands to proceed without two-factor authentication, streamlining the bulk configuration process.</p>
227<p>We recommend adding a 2-second sleep between each call to avoid rate limiting. With this approach, you can configure approximately 80 packages within the 5-minute two-factor authentication skip window.</p>
228<h3 id="configuration">Configuration</h3>
229<h3 id="npm-trust-github"><code>npm trust github</code></h3>
230<p>Create a trusted relationship between a package and GitHub Actions</p>
231<h4 id="synopsis2">Synopsis</h4>
232<pre><code class="language-bash">npm trust github [package] --file [--repo|--repository] [--env|--environment] [-y|--yes]
233</code></pre>
234<h4 id="flags">Flags</h4>
235<table>
236<thead>
237<tr>
238<th>Flag</th>
239<th>Default</th>
240<th>Type</th>
241<th>Description</th>
242</tr>
243</thead>
244<tbody>
245<tr>
246<td><code>--file</code></td>
247<td>null</td>
248<td>String (required)</td>
249<td>Name of workflow file within a repositories .GitHub folder (must end in yaml, yml)</td>
250</tr>
251<tr>
252<td><code>--repository</code>, <code>--repo</code></td>
253<td>null</td>
254<td>String</td>
255<td>Name of the repository in the format owner/repo</td>
256</tr>
257<tr>
258<td><code>--environment</code>, <code>--env</code></td>
259<td>null</td>
260<td>String</td>
261<td>CI environment name</td>
262</tr>
263<tr>
264<td><code>--dry-run</code></td>
265<td>false</td>
266<td>Boolean</td>
267<td>Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, <code>install</code>, <code>update</code>, <code>dedupe</code>, <code>uninstall</code>, as well as <code>pack</code> and <code>publish</code>. Note: This is NOT honored by other network related commands, eg <code>dist-tags</code>, <code>owner</code>, etc.</td>
268</tr>
269<tr>
270<td><code>--json</code></td>
271<td>false</td>
272<td>Boolean</td>
273<td>Whether or not to output JSON data, rather than the normal output. * In <code>npm pkg set</code> it enables parsing set values with JSON.parse() before saving them to your <code>package.json</code>. Not supported by all npm commands.</td>
274</tr>
275<tr>
276<td><code>--registry</code></td>
277<td>"<a href="https://registry.npmjs.org/">https://registry.npmjs.org/</a>"</td>
278<td>URL</td>
279<td>The base URL of the npm registry.</td>
280</tr>
281<tr>
282<td><code>--yes</code>, <code>-y</code></td>
283<td>null</td>
284<td>null or Boolean</td>
285<td>Automatically answer "yes" to any prompts that npm might print on the command line.</td>
286</tr>
287</tbody>
288</table>
289<h3 id="npm-trust-gitlab"><code>npm trust gitlab</code></h3>
290<p>Create a trusted relationship between a package and GitLab CI/CD</p>
291<h4 id="synopsis3">Synopsis</h4>
292<pre><code class="language-bash">npm trust gitlab [package] --file [--project|--repo|--repository] [--env|--environment] [-y|--yes]
293</code></pre>
294<h4 id="flags2">Flags</h4>
295<table>
296<thead>
297<tr>
298<th>Flag</th>
299<th>Default</th>
300<th>Type</th>
301<th>Description</th>
302</tr>
303</thead>
304<tbody>
305<tr>
306<td><code>--file</code></td>
307<td>null</td>
308<td>String (required)</td>
309<td>Name of pipeline file (e.g., .gitlab-ci.yml)</td>
310</tr>
311<tr>
312<td><code>--project</code></td>
313<td>null</td>
314<td>String</td>
315<td>Name of the project in the format group/project or group/subgroup/project</td>
316</tr>
317<tr>
318<td><code>--environment</code>, <code>--env</code></td>
319<td>null</td>
320<td>String</td>
321<td>CI environment name</td>
322</tr>
323<tr>
324<td><code>--dry-run</code></td>
325<td>false</td>
326<td>Boolean</td>
327<td>Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, <code>install</code>, <code>update</code>, <code>dedupe</code>, <code>uninstall</code>, as well as <code>pack</code> and <code>publish</code>. Note: This is NOT honored by other network related commands, eg <code>dist-tags</code>, <code>owner</code>, etc.</td>
328</tr>
329<tr>
330<td><code>--json</code></td>
331<td>false</td>
332<td>Boolean</td>
333<td>Whether or not to output JSON data, rather than the normal output. * In <code>npm pkg set</code> it enables parsing set values with JSON.parse() before saving them to your <code>package.json</code>. Not supported by all npm commands.</td>
334</tr>
335<tr>
336<td><code>--registry</code></td>
337<td>"<a href="https://registry.npmjs.org/">https://registry.npmjs.org/</a>"</td>
338<td>URL</td>
339<td>The base URL of the npm registry.</td>
340</tr>
341<tr>
342<td><code>--yes</code>, <code>-y</code></td>
343<td>null</td>
344<td>null or Boolean</td>
345<td>Automatically answer "yes" to any prompts that npm might print on the command line.</td>
346</tr>
347</tbody>
348</table>
349<h3 id="npm-trust-circleci"><code>npm trust circleci</code></h3>
350<p>Create a trusted relationship between a package and CircleCI</p>
351<h4 id="synopsis4">Synopsis</h4>
352<pre><code class="language-bash">npm trust circleci [package] --org-id <uuid> --project-id <uuid> --pipeline-definition-id <uuid> --vcs-origin <origin> [--context-id <uuid>...] [-y|--yes]
353</code></pre>
354<h4 id="flags3">Flags</h4>
355<table>
356<thead>
357<tr>
358<th>Flag</th>
359<th>Default</th>
360<th>Type</th>
361<th>Description</th>
362</tr>
363</thead>
364<tbody>
365<tr>
366<td><code>--org-id</code></td>
367<td>null</td>
368<td>String (required)</td>
369<td>CircleCI organization UUID</td>
370</tr>
371<tr>
372<td><code>--project-id</code></td>
373<td>null</td>
374<td>String (required)</td>
375<td>CircleCI project UUID</td>
376</tr>
377<tr>
378<td><code>--pipeline-definition-id</code></td>
379<td>null</td>
380<td>String (required)</td>
381<td>CircleCI pipeline definition UUID</td>
382</tr>
383<tr>
384<td><code>--vcs-origin</code></td>
385<td>null</td>
386<td>String (required)</td>
387<td>CircleCI repository origin in format 'provider/owner/repo'</td>
388</tr>
389<tr>
390<td><code>--context-id</code></td>
391<td>null</td>
392<td>null or String (can be set multiple times)</td>
393<td>CircleCI context UUID to match</td>
394</tr>
395<tr>
396<td><code>--dry-run</code></td>
397<td>false</td>
398<td>Boolean</td>
399<td>Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, <code>install</code>, <code>update</code>, <code>dedupe</code>, <code>uninstall</code>, as well as <code>pack</code> and <code>publish</code>. Note: This is NOT honored by other network related commands, eg <code>dist-tags</code>, <code>owner</code>, etc.</td>
400</tr>
401<tr>
402<td><code>--json</code></td>
403<td>false</td>
404<td>Boolean</td>
405<td>Whether or not to output JSON data, rather than the normal output. * In <code>npm pkg set</code> it enables parsing set values with JSON.parse() before saving them to your <code>package.json</code>. Not supported by all npm commands.</td>
406</tr>
407<tr>
408<td><code>--registry</code></td>
409<td>"<a href="https://registry.npmjs.org/">https://registry.npmjs.org/</a>"</td>
410<td>URL</td>
411<td>The base URL of the npm registry.</td>
412</tr>
413<tr>
414<td><code>--yes</code>, <code>-y</code></td>
415<td>null</td>
416<td>null or Boolean</td>
417<td>Automatically answer "yes" to any prompts that npm might print on the command line.</td>
418</tr>
419</tbody>
420</table>
421<h3 id="npm-trust-list"><code>npm trust list</code></h3>
422<p>List trusted relationships for a package</p>
423<h4 id="synopsis5">Synopsis</h4>
424<pre><code class="language-bash">npm trust list [package]
425</code></pre>
426<h4 id="flags4">Flags</h4>
427<table>
428<thead>
429<tr>
430<th>Flag</th>
431<th>Default</th>
432<th>Type</th>
433<th>Description</th>
434</tr>
435</thead>
436<tbody>
437<tr>
438<td><code>--json</code></td>
439<td>false</td>
440<td>Boolean</td>
441<td>Whether or not to output JSON data, rather than the normal output. * In <code>npm pkg set</code> it enables parsing set values with JSON.parse() before saving them to your <code>package.json</code>. Not supported by all npm commands.</td>
442</tr>
443<tr>
444<td><code>--registry</code></td>
445<td>"<a href="https://registry.npmjs.org/">https://registry.npmjs.org/</a>"</td>
446<td>URL</td>
447<td>The base URL of the npm registry.</td>
448</tr>
449</tbody>
450</table>
451<h3 id="npm-trust-revoke"><code>npm trust revoke</code></h3>
452<p>Revoke a trusted relationship for a package</p>
453<h4 id="synopsis6">Synopsis</h4>
454<pre><code class="language-bash">npm trust revoke [package] --id=<trust-id>
455</code></pre>
456<h4 id="flags5">Flags</h4>
457<table>
458<thead>
459<tr>
460<th>Flag</th>
461<th>Default</th>
462<th>Type</th>
463<th>Description</th>
464</tr>
465</thead>
466<tbody>
467<tr>
468<td><code>--id</code></td>
469<td>null</td>
470<td>String (required)</td>
471<td>ID of the trusted relationship to revoke</td>
472</tr>
473<tr>
474<td><code>--dry-run</code></td>
475<td>false</td>
476<td>Boolean</td>
477<td>Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, <code>install</code>, <code>update</code>, <code>dedupe</code>, <code>uninstall</code>, as well as <code>pack</code> and <code>publish</code>. Note: This is NOT honored by other network related commands, eg <code>dist-tags</code>, <code>owner</code>, etc.</td>
478</tr>
479<tr>
480<td><code>--registry</code></td>
481<td>"<a href="https://registry.npmjs.org/">https://registry.npmjs.org/</a>"</td>
482<td>URL</td>
483<td>The base URL of the npm registry.</td>
484</tr>
485</tbody>
486</table>
487<h3 id="see-also">See Also</h3>
488<ul>
489<li><a href="../commands/npm-publish.html">npm publish</a></li>
490<li><a href="../commands/npm-token.html">npm token</a></li>
491<li><a href="../commands/npm-access.html">npm access</a></li>
492<li><a href="../commands/npm-config.html">npm config</a></li>
493<li><a href="../using-npm/registry.html">npm registry</a></li>
494</ul></div>
495
496<footer id="edit">
497<a href="https://github.com/npm/cli/edit/latest/docs/lib/content/commands/npm-trust.md">
498<svg role="img" viewBox="0 0 16 16" width="16" height="16" fill="currentcolor" style="vertical-align: text-bottom; margin-right: 0.3em;">
499<path fill-rule="evenodd" d="M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 000-.354l-1.086-1.086zM11.189 6.25L9.75 4.81l-6.286 6.287a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.249.249 0 00.108-.064l6.286-6.286z"></path>
500</svg>
501Edit this page on GitHub
502</a>
503</footer>
504</section>
505
506
507
508</body></html>