registry-auth-token

WebJar for registry-auth-token

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

registry-auth-token
Last Version

Last Version

4.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

registry-auth-token
WebJar for registry-auth-token
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/rexxars/registry-auth-token

Download registry-auth-token

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/registry-auth-token/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>registry-auth-token</artifactId>
    <version>4.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/registry-auth-token/
implementation 'org.webjars.npm:registry-auth-token:4.2.1'
// https://jarcasting.com/artifacts/org.webjars.npm/registry-auth-token/
implementation ("org.webjars.npm:registry-auth-token:4.2.1")
'org.webjars.npm:registry-auth-token:jar:4.2.1'
<dependency org="org.webjars.npm" name="registry-auth-token" rev="4.2.1">
  <artifact name="registry-auth-token" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='registry-auth-token', version='4.2.1')
)
libraryDependencies += "org.webjars.npm" % "registry-auth-token" % "4.2.1"
[org.webjars.npm/registry-auth-token "4.2.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : rc jar [1.2.8,2)

Project Modules

There are no modules declared in this project.

registry-auth-token

npm versionBuild Status

Get the auth token set for an npm registry from .npmrc. Also allows fetching the configured registry URL for a given npm scope.

Installing

npm install --save registry-auth-token

Usage

Returns an object containing token and type, or undefined if no token can be found. type can be either Bearer or Basic.

var getAuthToken = require('registry-auth-token')
var getRegistryUrl = require('registry-auth-token/registry-url')

// Get auth token and type for default `registry` set in `.npmrc`
console.log(getAuthToken()) // {token: 'someToken', type: 'Bearer'}

// Get auth token for a specific registry URL
console.log(getAuthToken('//registry.foo.bar'))

// Find the registry auth token for a given URL (with deep path):
// If registry is at `//some.host/registry`
// URL passed is `//some.host/registry/deep/path`
// Will find token the closest matching path; `//some.host/registry`
console.log(getAuthToken('//some.host/registry/deep/path', {recursive: true}))

// Find the configured registry url for scope `@foobar`.
// Falls back to the global registry if not defined.
console.log(getRegistryUrl('@foobar'))

// Use the npm config that is passed in
console.log(getRegistryUrl('http://registry.foobar.eu/', {
  npmrc: {
    'registry': 'http://registry.foobar.eu/',
    '//registry.foobar.eu/:_authToken': 'qar'
  }
}))

Return value

// If auth info can be found:
{token: 'someToken', type: 'Bearer'}

// Or:
{token: 'someOtherToken', type: 'Basic'}

// Or, if nothing is found:
undefined

Security

Please be careful when using this. Leaking your auth token is dangerous.

License

MIT-licensed. See LICENSE.

Versions

Version
4.2.1
4.2.0
4.1.1
4.0.0
3.4.0
3.3.2
3.0.1