Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-artifactregistry-auth

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-artifactregistry-auth - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

2

package.json
{
"name": "google-artifactregistry-auth",
"version": "2.0.3",
"version": "2.0.4",
"description": "google-artifactregistry-auth is an npm module that allows you to configure npm to interact with npm repositories stored in Artifact Registry.",

@@ -5,0 +5,0 @@ "main": "./src/main.js",

@@ -41,5 +41,3 @@ # Artifact Registry tools for npm

registry=https://LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/
//LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/:_password=""
//LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID:username=oauth2accesstoken
//LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/:email=not.valid@email.com
//LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/:_authToken=""
//LOCATION-npm.pkg.dev/PROJECT_ID/REPOSITORY_ID/:always-auth=true

@@ -46,0 +44,0 @@ ```

@@ -57,3 +57,3 @@ // Copyright 2019 Google LLC

}
return Buffer.from(creds).toString('base64');
return creds;
}

@@ -76,4 +76,13 @@

const regex = /(\/\/[a-zA-Z1-9-]+[-]npm[.]pkg[.]dev\/.*\/:_password=).*/g;
if (!contents.match(regex)) {
const regex = /(\/\/[a-zA-Z1-9-]+[-]npm[.]pkg[.]dev\/.*\/:_authToken=).*/g;
const legacy_regex =
/(\/\/[a-zA-Z1-9-]+[-]npm[.]pkg[.]dev\/.*\/:_password=).*(\n\/\/[a-zA-Z1-9-]+[-]npm[.]pkg[.]dev\/.*\/:username=oauth2accesstoken)/g;
let newContents;
// If config is basic auth, encrypt the token.
if (contents.match(legacy_regex)) {
encrypted_creds = Buffer.from(creds).toString('base64');
newContents = contents.replace(legacy_regex, `$1"${encrypted_creds}"$2`);
contents = newContents;
}
else if (!contents.match(regex)) {
reject(new Error(

@@ -85,3 +94,3 @@ 'Artifact Registry config not found in ' + configPath +

const newContents = contents.replace(regex, `$1"${creds}"`);
newContents = contents.replace(regex, `$1"${creds}"`);

@@ -88,0 +97,0 @@ const tempConfigPath = configPath.replace('.npmrc', '.npmrc-temp');

@@ -26,28 +26,18 @@ /**

const newConfig = `registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password=""
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com
//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=""
//us-west1-npm.pkg.dev/my-project/my-repo/:always-auth=true`;
const existingConfig = `registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="not_abcd"
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com
//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken="not_abcd"
//us-west1-npm.pkg.dev/my-project/my-repo/:always-auth=true`;
const multipleConfig = `registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="my-repo-creds"
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com
//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken="my-repo-creds"
//us-west1-npm.pkg.dev/my-project/my-repo/:always-auth=true
@cba:registry=https://asia-npm.pkg.dev/my-project/my-other-repo/
//asia-npm.pkg.dev/my-project/my-other-repo/:_password="my-other-repo-creds"
//asia-npm.pkg.dev/my-project/my-other-repo/:username=oauth2accesstoken
//asia-npm.pkg.dev/my-project/my-other-repo/:email=not.valid@email.com
//asia-npm.pkg.dev/my-project/my-other-repo/:_authToken="my-other-repo-creds"
//asia-npm.pkg.dev/my-project/my-other-repo/:always-auth=true`;
const wantContent = `registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="abcd"
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com
//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken="abcd"
//us-west1-npm.pkg.dev/my-project/my-repo/:always-auth=true`;

@@ -57,10 +47,6 @@

`registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="abcd"
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com
//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken="abcd"
//us-west1-npm.pkg.dev/my-project/my-repo/:always-auth=true
@cba:registry=https://asia-npm.pkg.dev/my-project/my-other-repo/
//asia-npm.pkg.dev/my-project/my-other-repo/:_password="abcd"
//asia-npm.pkg.dev/my-project/my-other-repo/:username=oauth2accesstoken
//asia-npm.pkg.dev/my-project/my-other-repo/:email=not.valid@email.com
//asia-npm.pkg.dev/my-project/my-other-repo/:_authToken="abcd"
//asia-npm.pkg.dev/my-project/my-other-repo/:always-auth=true`;

@@ -70,8 +56,51 @@

`registry=https://npm.other.registry/my-project/my-repo/
//npm.other.registry/my-project/my-repo/:_password="other.registry.creds"
//npm.other.registry/my-project/my-repo/:username=oauth2accesstoken
//npm.other.registry/my-project/my-repo/:email=not.valid@email.com
//npm.other.registry/my-project/my-repo/:_authToken="other.registry.creds"
//npm.other.registry/my-project/my-repo/:always-auth=true
@old-registry=https://asia-npm.pkg/my-project/my-repo/
//asia-npm.pkg/my-project/my-repo/:_password="old.registry.creds"
//asia-npm.pkg/my-project/my-repo/:username=oauth2accesstoken
//asia-npm.pkg/my-project/my-repo/:email=not.valid@email.com
//asia-npm.pkg/my-project/my-repo/:always-auth=true
//another.registry.com/:_authToken=another-registry-creds`;
const existingWithLegacyConfig =
`registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="stale-creds"
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com
@cba:registry=https://asia-npm.pkg.dev/my-project/my-other-repo/
//asia-npm.pkg.dev/my-project/my-other-repo/:_authToken="another-stale-creds"
//asia-npm.pkg.dev/my-project/my-other-repo/:always-auth=true
@ar=https://asia-npm.pkg/my-project/my-repo/
//asia-npm.pkg/my-project/my-repo/:_password="json-key"
//asia-npm.pkg/my-project/my-repo/:username=_json_key_base64
//asia-npm.pkg/my-project/my-repo/:email=not.valid@email.com
//asia-npm.pkg/my-project/my-repo/:always-auth=true`;
const wantExistingWithLegacyContent =
`registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="YWJjZA=="
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com
@cba:registry=https://asia-npm.pkg.dev/my-project/my-other-repo/
//asia-npm.pkg.dev/my-project/my-other-repo/:_authToken="abcd"
//asia-npm.pkg.dev/my-project/my-other-repo/:always-auth=true
@ar=https://asia-npm.pkg/my-project/my-repo/
//asia-npm.pkg/my-project/my-repo/:_password="json-key"
//asia-npm.pkg/my-project/my-repo/:username=_json_key_base64
//asia-npm.pkg/my-project/my-repo/:email=not.valid@email.com
//asia-npm.pkg/my-project/my-repo/:always-auth=true`;
const legacyConfig =
`registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="stale-creds"
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com`;
const wantLegacyContent =
`registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
//us-west1-npm.pkg.dev/my-project/my-repo/:_password="YWJjZA=="
//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken
//us-west1-npm.pkg.dev/my-project/my-repo/:email=not.valid@email.com`;
beforeEach(() => {

@@ -109,2 +138,18 @@ fs.openSync(configPath, 'w');

it('replace creds with legacy', async () => {
fs.writeFileSync(configPath, existingWithLegacyConfig);
await buildartifactsAuth.updateConfigFile(configPath, creds);
const got = fs.readFileSync(configPath, 'utf8');
assert.equal(got, wantExistingWithLegacyContent);
});
it('replace legacy creds', async () => {
fs.writeFileSync(configPath, legacyConfig);
await buildartifactsAuth.updateConfigFile(configPath, creds);
const got = fs.readFileSync(configPath, 'utf8');
assert.equal(got, wantLegacyContent);
});
it('no creds', async () => {

@@ -111,0 +156,0 @@ fs.writeFileSync(configPath, nonCBAConfig);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc