Skip to content

Commit

Permalink
feat: deprecated key, cert config options and updated registry sc…
Browse files Browse the repository at this point in the history
…oped auth docs
  • Loading branch information
fritzy authored and lukekarrys committed Oct 19, 2022
1 parent 0d94f52 commit 6a27a7b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 32 deletions.
9 changes: 9 additions & 0 deletions docs/lib/content/configuring-npm/npmrc.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ The settings `_auth`, `_authToken`, `username` and `_password` must all be
scoped to a specific registry. This ensures that `npm` will never send
credentials to the wrong host.

The full list is:
- `_auth` (base64 authentication string)
- `_authToken` (authentication token)
- `username`
- `_password`
- `email`
- `certfile` (path to certificate file)
- `keyfile` (path to key file)

In order to scope these values, they must be prefixed by a URI fragment.
If the credential is meant for any request to a registry on a single host,
the scope may look like `//registry.npmjs.org/:`. If it must be scoped to a
Expand Down
3 changes: 3 additions & 0 deletions docs/lib/content/using-npm/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ used, which is supplied by the [`registry` config](/using-npm/config#registry)
parameter. See [`npm config`](/commands/npm-config),
[`npmrc`](/configuring-npm/npmrc), and [`config`](/using-npm/config) for more on
managing npm's configuration.
Authentication configuration such as auth tokens and certificates are configured
specifically scoped to an individual registry. See
[Auth Related Configuration](/configuring-npm/npmrc#auth-related-configuration)

When the default registry is used in a package-lock or shrinkwrap is has the
special meaning of "the currently configured registry". If you create a lock
Expand Down
14 changes: 14 additions & 0 deletions lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,13 @@ define('cert', {
It is _not_ the path to a certificate file, though you can set a registry-scoped
"certfile" path like "//other-registry.tld/:certfile=/path/to/cert.pem".
`,
deprecated: `
\`key\` and \`cert\` are no longer used for most registry operations.
Use registry scoped \`keyfile\` and \`certfile\` instead.
Example:
//other-registry.tld/:keyfile=/path/to/key.pem
//other-registry.tld/:certfile=/path/to/cert.crt
`,
flatten,
})

Expand Down Expand Up @@ -1124,6 +1131,13 @@ define('key', {
It is _not_ the path to a key file, though you can set a registry-scoped
"keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
`,
deprecated: `
\`key\` and \`cert\` are no longer used for most registry operations.
Use registry scoped \`keyfile\` and \`certfile\` instead.
Example:
//other-registry.tld/:keyfile=/path/to/key.pem
//other-registry.tld/:certfile=/path/to/cert.crt
`,
flatten,
})

Expand Down
72 changes: 40 additions & 32 deletions tap-snapshots/test/lib/docs.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -750,23 +750,6 @@ npm exec --package yo --package generator-node --call "yo node"
\`\`\`
#### \`cert\`
* Default: null
* Type: null or String
A client certificate to pass when accessing the registry. Values should be
in PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with
newlines replaced by the string "\\n". For example:
\`\`\`ini
cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
\`\`\`
It is _not_ the path to a certificate file, though you can set a
registry-scoped "certfile" path like
"//other-registry.tld/:certfile=/path/to/cert.pem".
#### \`ci-name\`
* Default: The name of the current CI system, or \`null\` when not on a known CI
Expand Down Expand Up @@ -1200,21 +1183,6 @@ Whether or not to output JSON data, rather than the normal output.
Not supported by all npm commands.
#### \`key\`
* Default: null
* Type: null or String
A client key to pass when accessing the registry. Values should be in PEM
format with newlines replaced by the string "\\n". For example:
\`\`\`ini
key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
\`\`\`
It is _not_ the path to a key file, though you can set a registry-scoped
"keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
#### \`legacy-peer-deps\`
* Default: false
Expand Down Expand Up @@ -1975,6 +1943,27 @@ When set to \`dev\` or \`development\`, this is an alias for \`--include=dev\`.
\`--cache-min=9999 (or bigger)\` is an alias for \`--prefer-offline\`.
#### \`cert\`
* Default: null
* Type: null or String
* DEPRECATED: \`key\` and \`cert\` are no longer used for most registry
operations. Use registry scoped \`keyfile\` and \`certfile\` instead. Example:
//other-registry.tld/:keyfile=/path/to/key.pem
//other-registry.tld/:certfile=/path/to/cert.crt
A client certificate to pass when accessing the registry. Values should be
in PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with
newlines replaced by the string "\\n". For example:
\`\`\`ini
cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----"
\`\`\`
It is _not_ the path to a certificate file, though you can set a
registry-scoped "certfile" path like
"//other-registry.tld/:certfile=/path/to/cert.pem".
#### \`dev\`
* Default: false
Expand Down Expand Up @@ -2041,6 +2030,25 @@ Alias for \`--init-module\`
Alias for \`--init-version\`
#### \`key\`
* Default: null
* Type: null or String
* DEPRECATED: \`key\` and \`cert\` are no longer used for most registry
operations. Use registry scoped \`keyfile\` and \`certfile\` instead. Example:
//other-registry.tld/:keyfile=/path/to/key.pem
//other-registry.tld/:certfile=/path/to/cert.crt
A client key to pass when accessing the registry. Values should be in PEM
format with newlines replaced by the string "\\n". For example:
\`\`\`ini
key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----"
\`\`\`
It is _not_ the path to a key file, though you can set a registry-scoped
"keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem".
#### \`legacy-bundling\`
* Default: false
Expand Down

0 comments on commit 6a27a7b

Please sign in to comment.