mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-27 03:21:55 -04:00
* feat(config): add support for token helper Use the new interface in `pnpm/credentials-by-uri` for supporting token helpers. A token helper is an executable, set in the user's `.npmrc` which outputs an auth token. This can be used in situations where the `authToken` is not a constant value, but is something that refreshes regularly, where a script or other tool can use an existing refresh token to obtain a new access token. The configuration for the path to the helper must be an absolute path, with no arguments. In order to be secure, it is _only_ permitted to set this value in the user `.npmrc`, otherwise a project could place a value in a project local `.npmrc` and run arbitrary executables. A similar feature is available in many similar tools. The implementation in `credentials-by-uri` is modelled after the `vault` (vaultproject.io) implementation - https://github.com/hashicorp/vault/blob/main/command/token/helper_external.go * test: fix * docs: add changesets Co-authored-by: Zoltan Kochan <z@kochan.io>
29 lines
788 B
TypeScript
29 lines
788 B
TypeScript
import os from 'os'
|
|
import path from 'path'
|
|
import { store } from '@pnpm/plugin-commands-store'
|
|
import prepare from '@pnpm/prepare'
|
|
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
|
|
|
const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/`
|
|
|
|
test('CLI prints the current store path', async () => {
|
|
prepare()
|
|
|
|
const candidateStorePath = await store.handler({
|
|
cacheDir: path.resolve('cache'),
|
|
dir: process.cwd(),
|
|
rawConfig: {
|
|
registry: REGISTRY,
|
|
},
|
|
registries: { default: REGISTRY },
|
|
storeDir: '/home/example/.pnpm-store',
|
|
userConfig: {},
|
|
}, ['path'])
|
|
|
|
const expectedStorePath = os.platform() === 'win32'
|
|
? '\\home\\example\\.pnpm-store\\v3'
|
|
: '/home/example/.pnpm-store/v3'
|
|
|
|
expect(candidateStorePath).toBe(expectedStorePath)
|
|
})
|