Esri / Esri/esri-leaflet-vector

Salesforce Lightning Locker Service Compatibilty

Open
#172 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
72
Forks
54
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

Esri Leaflet Vector appears to be incompatible with Salesforce Lightning Locker Service. We are able to use Esri Leaflet in a Lightning Web Component (LWC) to render maps in Lightning Experience (the internal SF UI) and Experience Cloud (the external-facing "portal" UI), but when we add the Esri Leaflet Vector plugin, it triggers Locker Service, a security feature which protects against cross-site scripting. We've whitelisted multiple domains (including *.leafletjs.com and *.arcgis.com) but the problem persists. I've also looked through the Leaflet source code for domains that might need to be whitelisted.

We've worked around the problem by embedding our LWC into an Aura component configured to run using Salesforce API version 39.0, which pre-dates Locker Service. This is a short-term workaround, as Salesforce has already deprecated version up through 30.0 and will continue to deprecate API versions (the current version is 57.0).

The ask here is either to ensure there is no cross-site scripting in the Vector code, or to document any domains that need to be whitelisted to avoid this issue.

### Reproduction

To reproduce, create a Lightning Web Component that imports the Esri Leaflet Vector plugin:
```
import LEAFLET from '@salesforce/resourceUrl/leaflet';
import ESRILEAFLET from '@salesforce/resourceUrl/esriLeaflet';
import ESRILEAFLETVECTOR from '@salesforce/resourceUrl/esriLeafletVector';
import ESRILEAFLETGEOCODER from '@salesforce/resourceUrl/esriLeafletGeocoder';
```
and embed it in a Lightning App Builder page or Experience Builder page with Content Security Policy set to Strict.

### Logs

_No response_

### System Info

```shell
/* Leaflet 1.9.3, a JS library for interactive maps. https://leafletjs.com
/* esri-leaflet - v3.0.10 - Tue Jan 17 2023 09:24:14 GMT-0600 (Central Standard Time)
/* esri-leaflet-vector - v4.0.1 - Thu Feb 23 2023 14:15:02 GMT-0600 (Central Standard Time)
/* esri-leaflet-geocoder - v3.1.4 - Thu Feb 23 2023 13:29:25 GMT-0600 (Central Standard Time)
```

### Additional Information

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the listed Leaflet, esri-leaflet, and esri-leaflet-vector versions in a Lightning Web Component under Strict Content Security Policy. Inspect the vector plugin's compatibility with Locker Service and determine whether the result is a code fix or documentation of required domains; done means the plugin works without the workaround or the required whitelist is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
security, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.