This is a Salesforce sample application created with SFDX where it's showed up the implementation of some basic Lightning Web Component.
Lightning Web Components uses core Web Components standards and provides only what’s necessary to perform well in browsers supported by Salesforce. Because it’s built on code that runs natively in browsers, Lightning Web Components is lightweight and delivers exceptional performance. Most of the code you write is standard JavaScript and HTML.
Read more in the Official Documentation
This project holds Continuous Integration and Continuous Delivery capabilities over CircleCI. If you're interested in how to setup all this stuff, you can read more below and use the .circleci/config.yml as a reference.
Continuous integration (CI) environments are fully automated and don’t support the human interactivity of a web-based flow. In these environments, you must use the JSON web tokens (JWT) to authorize an org.
The JWT-based authorization flow requires first generating a digital certificate and creating a connected app. You execute these tasks only once. After that, you can authorize the org in a script that runs in your CI environment.
This process produces two files.
server.key
— The private key. You specify this file when you authorize an org with the force:auth:jwt:grant
command.
server.crt
— The digital certification. You upload this file when you create the connected app required by the JWT-based flow.
- Generate a private key, and store it in a file called server.key. At the end, you can delete the
server.pass.key
file because you no longer need it.
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
- Generate a certificate signing request using the
server.key
file. Store the certificate signing request in a file calledserver.csr
. Enter information about your company when prompted.
openssl req -new -key server.key -out server.csr
- Generate a self-signed digital certificate from the
server.key
andserver.csr
files. Store the certificate in a file calledserver.crt
.
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
If you use JWT-based authorization, you must create your own connected app in your Dev Hub org.
- Log in to your Dev Hub org.
- From Setup, enter
App Manager
in the Quick Find box to get to the Lightning Experience App Manager. - In the top-right corner, click New Connected App.
- Update the basic information as needed, such as the connected app name and your email address.
- Select Enable OAuth Settings.
- For the callback URL, enter
http://localhost:1717/OauthRedirect
. If port 1717 (the default) is already in use on your local machine, specify an available one instead. Make sure to also update yoursfdx-project.json
file by setting theoauthLocalPort
property to the new port. For example, if you set the callback URL tohttp://localhost:1919/OauthRedirect
:
"oauthLocalPort" : "1919"
- (JWT only) Select Use digital signatures.
- (JWT only) Click Choose File and upload the
server.crt
file that contains your digital certificate. - Add these OAuth scopes:
- Access and manage your data (api)
- Perform requests on your behalf at any time (refresh_token, offline_access)
- Provide access to your data via the Web (web)
- Click Save.
- (JWT only) Click Manage.
- (JWT only) Click Edit Policies.
- (JWT only) In the OAuth Policies section, select Admin approved users are pre-authorized for Permitted Users, and click OK.
- (JWT only) Click Save.
- (JWT only) Click Manage Profiles and then click Manage Permission Sets. Select the profiles and permission sets that are pre-authorized to use this connected app. Create permission sets if necessary.
Encrypt the server.key
generated above using the instructions below.
-
Generate a
key
andinitializtion vector (iv)
to encrypt yourserver.key
file locally. Thekey
andiv
will be used by CI Tool to decrypt your server key in the build environment.openssl enc -aes-256-cbc -k <passphrase here> -P -md sha1 -nosalt
Make note of the
key
andiv
values output to the screen. -
Encrypt the
server.key
using the newly generatedkey
andiv
values.openssl enc -nosalt -aes-256-cbc -in server.key -out server.key.enc -base64 -K <key from above> -iv <iv from above>
-
Store the
key
andiv
contents as protected environment variables in the CI Tool. These values are considered secret so please treat them as such. For example you can store thekey
as$DECRYPTION_KEY
and theiv
as$DECRYPTION_IV
. -
Add the
server.key.enc
file into your project. Starting from now you can keep it under VCS and use it in the build environment in order to decrypt theserver.key
. Let's suppose you're adding it toassets/server.key.enc
, to decrypt theserver.key
you can run:openssl enc -nosalt -aes-256-cbc -d -in assets/server.key.enc -out assets/server.key -base64 -K $DECRYPTION_KEY -iv $DECRYPTION_IV