Auth0 Home Blog Docs

How Lock.js and Auth0.js are uploaded to the CDN

cdn
bundle
release
lock
auth0js

#1

How does the Jenkins build job makes the CDN bundle of lock available on each release?


#2

All Auth0 libraries, that have a bundle uploaded to the CDN, should be placed using the following folder structure in the S3 bucket.

/js/{name}/{version}/

And taking Lock@10.0.0 as an example the path will be

/js/lock/10.0.0/

Inside the directory we upload all the files needed like bundle, source maps, assets, etc.

Also we upload at most these different versions

  • full (major.minor.path)
  • latest minor (major.minor)
  • latest master (development)

All this is done using the library https://github.com/auth0/component-cdn-uploader which checks what versions needs to upload and handles the upload to the S3 bucket

The configuration for Lock is (configured in package.json)

"cdn-component": {
  "name": "lock",
  "cdn": "https://cdn.auth0.com",
  "mainBundleFile": "lock.min.js",
  "bucket": "assets.us.auth0.com",
  "localPath": "build"
} 

and for auth0.js (also in its package.json)

"cdn-component": {
  "name": "auth0",
  "cdn": "https://cdn.auth0.com",
  "mainBundleFile": "auth0.min.js",
  "bucket": "assets.us.auth0.com",
  "localPath": "build"
}

Using this information the library will first perform a HEAD to the cdn to check the existence of the current package version (from the package.json) of the mainBundleFile. If it exists it will only upload the contents of the localPath to the development version, otherwise will also upload the full and latest minor versions too.

The process currently is done by Jenkins in the following builds

that runs on every push to master branch of the Github repository and also runs test and linter.


#3