Configuring yarn
How to configure the yarn package manager
This page explains how to configure the yarn package manager to pull packages from the Seal artifact server based on your existing setup.
Make sure you have the access token for the server ready.
Configure classic yarn (v1) to pull directly from the artifact server
To configure Classic yarn it's best to use the npm configuration .npmrc files.
These configuration files can be global, per-user and per-project. We recommend using a per-project configuration, which you do by creating or editing the relevant file in your project's root directory.
Our goal is to replace https://registry.npmjs.org/ as your default registry with https://npm.sealsecurity.io/. The configuration file may still refer to other registries for privately scoped packages.
Using an .npmrc file
.npmrc fileWe want the file to look similar to this:
registry=https://npm.sealsecurity.io/
//npm.sealsecurity.io/:username=$PROJECT_ID
//npm.sealsecurity.io/:_password=$TOKEN_IN_BASE64
//npm.sealsecurity.io/:always-auth=trueThe $PROJECT_ID and $TOKEN_IN_BASE64 fields
In the
$PROJECT_IDput the name of your project. This value will later be used in the reporting to indicate which project pulled which vulnerable package.In the
$TOKEN_IN_BASE64we need to put the base64 value of the access token. To encode the token in base64 you can useecho -n $TOKEN | base64on Mac orecho -n $TOKEN | base64 -w0on Ubuntu.
Configure yarn v2+ to pull directly from the artifact server
The yarn configuration is saved in the .yarnrc files, which can be global, per-user and per-project. We recommend using a per-project setup, which you can do by creating or editing the .yarnrc file in the project's root.
Our goal is to replace https://registry.npmjs.org/ as your default registry with https://npm.sealsecurity.io/. The configuration file may still refer to other registries for privately scoped packages. The file should end up looking like this:
npmRegistries:
"https://npm.sealsecurity.io":
npmAlwaysAuth: true
npmAuthIdent: $AUTHENTICATION_STRING
npmRegistryServer: "https://npm.sealsecurity.io"
yarnPath: .yarn/releases/yarn-{yarn_version}.cjsMake sure the
yarnPathis pointing to the correct yarn version.Let
$TOKENbe the access token you have for the server. And let$PROJECT_IDbe the name of your project, which will later be used in the reporting to indicate which project pulled which vulnerable package.If you're using yarn v2 replace
$AUTHENTICATION_STRINGwith the base64 encoding of$PROJECT_ID:$TOKEN.If you're using yarn v3+ just replace
$AUTHENTICATION_STRINGwith"$PROJECT_ID:$TOKEN".
Pull using JFrog's Artifactory
Go to JFrog's Artifactory configuration and create a new remote npm repository.
In the Basic configuration, choose whatever Repository Key you like.
Set
https://npm.sealsecurity.ioas the URL.In the User Name field use
jfrog.In the Password / Access Token field paste the token you created earlier.
Click the
Testbutton. This will test whether the connection and authentication to the Seal artifact server is configured properly.Save the new repository, and set it as the top priority remote repository in the virtual repository you're using.
Last updated