Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

  1. # registry-auth-token
  2. [![npm version](http://img.shields.io/npm/v/registry-auth-token.svg?style=flat-square)](http://browsenpm.org/package/registry-auth-token)[![Build Status](http://img.shields.io/travis/rexxars/registry-auth-token/master.svg?style=flat-square)](https://travis-ci.org/rexxars/registry-auth-token)
  3. Get the auth token set for an npm registry from `.npmrc`. Also allows fetching the configured registry URL for a given npm scope.
  4. ## Installing
  5. ```
  6. npm install --save registry-auth-token
  7. ```
  8. ## Usage
  9. Returns an object containing `token` and `type`, or `undefined` if no token can be found. `type` can be either `Bearer` or `Basic`.
  10. ```js
  11. var getAuthToken = require('registry-auth-token')
  12. var getRegistryUrl = require('registry-auth-token/registry-url')
  13. // Get auth token and type for default `registry` set in `.npmrc`
  14. console.log(getAuthToken()) // {token: 'someToken', type: 'Bearer'}
  15. // Get auth token for a specific registry URL
  16. console.log(getAuthToken('//registry.foo.bar'))
  17. // Find the registry auth token for a given URL (with deep path):
  18. // If registry is at `//some.host/registry`
  19. // URL passed is `//some.host/registry/deep/path`
  20. // Will find token the closest matching path; `//some.host/registry`
  21. console.log(getAuthToken('//some.host/registry/deep/path', {recursive: true}))
  22. // Find the configured registry url for scope `@foobar`.
  23. // Falls back to the global registry if not defined.
  24. console.log(getRegistryUrl('@foobar'))
  25. // Use the npm config that is passed in
  26. console.log(getRegistryUrl('http://registry.foobar.eu/', {
  27. npmrc: {
  28. 'registry': 'http://registry.foobar.eu/',
  29. '//registry.foobar.eu/:_authToken': 'qar'
  30. }
  31. }))
  32. ```
  33. ## Return value
  34. ```js
  35. // If auth info can be found:
  36. {token: 'someToken', type: 'Bearer'}
  37. // Or:
  38. {token: 'someOtherToken', type: 'Basic'}
  39. // Or, if nothing is found:
  40. undefined
  41. ```
  42. ## Security
  43. Please be careful when using this. Leaking your auth token is dangerous.
  44. ## License
  45. MIT-licensed. See LICENSE.