-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SES to wallet-mobile (#420)
* refactor: feature toggle using hathor unleash client * feat: handling feature updates * feat: added SES to the project and enabled lockdown * chore: added patch-package and patch to react-native * chore: removed unused diff from react-native patch * chore: added allow-scripts * chore: added updated allowScript config * chore: added sha256sum of lockdown file * refactor: moved lavamoat lockdown to a patch instead of entrypoint * refactor: removed ses from package.json, reading from file * chore: fix lint by ignoring lockdown * chore: allowing root postinstall and running allow-scripts on npm run setup * chore: added comment explaining why we can't use hermes * chore: uninstall ses as we're using a downloaded file * chore: removed unused diff from react-native patch * chore: no need to remove polyfill promise as injecting it on initializeCore fixes the issue * chore: updated react-native patch to include react-native-mmkv and use it * feat: added ses saga and restarting bundle when ses is disabled * chore: added a document explaining how to update SES * chore: added postinstall to setup script and updated packages * chore: fixed allow-scripts version * chore: added patch-package to postinstall * chore: added MKMV to podfile.lock * chore: reading ses enabled from constant * feat: yield fatal error when SES should be enabled but is not * refactor: improved verifySesEnabled method * feat: update SES to 1.5.0 * feat: patched intl to work in SES * refactor: updated react-native patch import order * feat: improved logging and updated podfile with sentry update and mmkv * fix: typo * docs: improved comment on unleash disabled * refactor: use isSESEnabled * chore: updated sha256sums * docs: updated SES_AND_LAVAMOAT document with better explanation on SES * refactor: disabled hermes on android * refactor: updated react-native patch, removed unused changes * refactor: updated intl patch to remove unused implementation * chore: added comment on react-native patch * chore: removed exit 1 from preinstall on root * chore: updated intl patch to add a comment * fix: updated translation files * chore: remove unused actions, reducer and saga effect --------- Co-authored-by: Alex Ruzenhack <[email protected]>
- Loading branch information
1 parent
eb36418
commit 2a65bf2
Showing
24 changed files
with
13,963 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lockdown.umd.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ignore-scripts=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lockdown.umd.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# LavaMoat and SES (Secure Ecmascript) maintenance | ||
|
||
### Hermes | ||
|
||
SES does not yet work with Hermes, so we had to disable it on both platforms https://github.com/facebook/hermes/issues/957 | ||
|
||
### SES injection | ||
|
||
LavaMoat does not yet fully support react-native, there is a compatibility tracker [here](https://github.com/LavaMoat/docs/issues/12). Until then, we're using [SES](https://github.com/endojs/endo/tree/master/packages/ses) directly, injecting it directly into the InitializeCore which is the entrypoint for the react-native's bundle so it hardens our app as soon as possible in the process. | ||
|
||
This is done through a patch on the react-native package, using `patch-package`. | ||
|
||
We are currently using version `1.5.0` of SES, which is the latest version that works with react-native, it is loaded from the project root, `lockdown.umd.js`. | ||
|
||
|
||
### Understanding SES Hardening | ||
|
||
SES hardens JavaScript's built-in objects ("intrinsics") to prevent malicious code from modifying them. This includes: | ||
|
||
- Object prototype methods (e.g. `Object.prototype.toString`) | ||
- Array methods (e.g. `Array.prototype.push`) | ||
- String methods | ||
- Promise implementation | ||
- Math object | ||
- JSON object | ||
- And other global objects | ||
|
||
Common issues you might encounter: | ||
1. "TypeError: Cannot assign to read only property": This means code is trying to modify a hardened object | ||
2. "TypeError: Object.prototype.foo is not configurable": Attempting to add methods to hardened prototypes | ||
3. "Cannot create property 'bar' on frozen object": Trying to modify frozen global objects | ||
|
||
Debug tips: | ||
- If you see these errors, check if your code or a third-party library is trying to: | ||
- Modify built-in prototypes | ||
- Add properties to global objects | ||
- Override native methods | ||
- Consider using proper alternatives: | ||
- Create new objects instead of modifying built-ins | ||
- Use class inheritance instead of prototype modification | ||
- Keep modifications within your own object instances | ||
|
||
### Updating SES | ||
|
||
Once React Native is fully supported by LavaMoat, we'll replace the current patch with its official npm package. Until then, to update SES: | ||
|
||
1. Update the `lockdown.umd.js` file to the latest supported SES lockdown file | ||
2. Update the sha256sum of the lockdown library in the SHA256SUMS file | ||
|
||
### Future Plans | ||
|
||
We plan to migrate to LavaMoat's full implementation once React Native support is complete. This will provide: | ||
- Better integration with the ecosystem | ||
- Easier updates through npm | ||
- Additional security features from LavaMoat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f10f4088c8bd9689f6108fac0e2c1d7ea3f0c1f159c64822e7830aa7018671a7 lockdown.umd.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.