Create npm proxy repository with authentication

I’m trying to create npm proxy repository via script API including authentication.
Looking at The source code, createNpmProxy function doesn’t seem to support it:

Is there a way to use some low level method like createProxy or createRepository in order to create npm repository with authentication?

Here’s an example of how to add credentials to a proxy repository.

import org.sonatype.nexus.blobstore.api.BlobStoreManager
import org.sonatype.nexus.repository.storage.WritePolicy
import org.sonatype.nexus.repository.maven.VersionPolicy
import org.sonatype.nexus.repository.maven.LayoutPolicy

repository.createMavenProxy('proxy1', 'https://some.remote.com/', 'default', true, VersionPolicy.RELEASE, LayoutPolicy.PERMISSIVE)

def creds = [:].withDefault { 0 }
creds.put('type','username')
creds.put('username','test')
creds.put('password','test123')

repository.getRepositoryManager().get('proxy1').getConfiguration().getAttributes().'httpclient'.'authentication' = creds