Skip to content

feat: @lavamoat/react-native-lockdown#1438

Merged
leotm merged 8 commits into
mainfrom
react-native-lockdown
Jun 10, 2025
Merged

feat: @lavamoat/react-native-lockdown#1438
leotm merged 8 commits into
mainfrom
react-native-lockdown

Conversation

@leotm

@leotm leotm commented Nov 1, 2024

Copy link
Copy Markdown
Member

New package

  • @lavamoat/react-native-lockdown (beta)
  • SES lockdown via Metro serializer
  • Supports Hermes and legacy JSC (unsupported V8 untested)

React Native app init order

Metro

  • resolution
  • transformation
  • serialization
    • getPolyfills
      • ses (jsc) or ses/hermes
      • repair
        • backup: Promise._<_onHandle/_onReject/_noop>
        • repairIntrinsics(rnOptions)
        • restore: Promise._<_onHandle/_onReject/_noop>
      • @react-native/js-polyfills
      • vetted shims (e.g. reflect-metadata)
  • getRunModuleStatement
    • node_modules/react-native/Libraries/Core/InitializeCore.js
      • [metro] moduleId: 59/64/69/111/x
    • hardenIntrinsics()
    • index.js
      • [metro] moduleId: 0

(user ignores SES shim with babel)

Hermes https://github.com/facebook/hermes/blob/main/utils/promise/index.js
RN https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/polyfillPromise.js
SES removes https://github.com/then/promise/blob/master/src/core.js#L68-L70
(https://github.com/then/promise/blob/master/src/es6-extensions.js requires)
so we add them back as vetted shims after repair

https://github.com/facebook/react-native/blob/main/packages/community-cli-plugin/src/utils/loadMetroConfig.js#L59-L76
https://github.com/facebook/react-native/blob/main/packages/metro-config/src/index.flow.js#L61-L73

Follow-up with e2e test

Follow-up ship type declarations

  • tsconfig.json
  • improve types
  • repair.js -> repair.ts (cross-module linking)
  • index.js -> index.js? etc

Follow-up extend assertPolyfills

Follow-up node/macOS CI failures (unrelated to this PR)

Follow-up update upstream template metro.config.js to modern TS @import

Follow-up maybe another refactor

Follow-up update all /packages LICENSE.md -> LICENSE and add one for laverna

@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Nov 1, 2024
Comment thread packages/react-native-lockdown/src/makeGetPolyfills.js Outdated
Comment thread packages/react-native-lockdown/src/repair.js Outdated
Comment thread packages/react-native-lockdown/src/makeGetPolyfills.js Outdated
Comment thread packages/react-native-lockdown/src/makeGetPolyfills.js Outdated
@leotm leotm force-pushed the react-native-lockdown branch 3 times, most recently from 07f580a to 299ba72 Compare March 28, 2025 17:37
Comment thread packages/react-native-lockdown/package.json Outdated
@leotm leotm force-pushed the react-native-lockdown branch 2 times, most recently from 9426cb3 to e5401c3 Compare March 28, 2025 17:47
Comment thread packages/react-native-lockdown/src/repair.js
Comment thread packages/react-native-lockdown/src/repair.js
Comment thread packages/react-native-lockdown/package.json Outdated
@leotm leotm force-pushed the react-native-lockdown branch from e5401c3 to b119fac Compare March 28, 2025 18:02
Comment thread packages/react-native-lockdown/src/makeGetPolyfills.js Outdated
Comment thread packages/react-native-lockdown/src/makeGetPolyfills.js Outdated
@leotm leotm force-pushed the react-native-lockdown branch from b119fac to c3521cb Compare March 28, 2025 18:22
Comment thread packages/react-native-lockdown/src/makeGetPolyfills.js Outdated
@leotm leotm force-pushed the react-native-lockdown branch from c3521cb to 26d1e4e Compare March 31, 2025 12:24
@github-actions github-actions Bot added the documentation Docs, examples, tutorials, and associated tooling label Mar 31, 2025
Comment thread packages/react-native-lockdown/package.json Outdated
Comment thread packages/react-native-lockdown/package.json Outdated
@leotm leotm force-pushed the react-native-lockdown branch from 26d1e4e to 81275cf Compare March 31, 2025 16:16
Comment thread packages/react-native-lockdown/package.json Outdated
Comment thread packages/react-native-lockdown/package.json Outdated
@leotm leotm force-pushed the react-native-lockdown branch 2 times, most recently from 1191499 to e0f0782 Compare March 31, 2025 16:50
Comment thread packages/react-native-lockdown/LICENSE.md Outdated
@leotm leotm force-pushed the react-native-lockdown branch from b65aac8 to 5f93583 Compare June 3, 2025 11:44
leotm added a commit that referenced this pull request Jun 3, 2025
@leotm leotm force-pushed the react-native-lockdown branch 2 times, most recently from f41f7a8 to 77534c4 Compare June 5, 2025 17:31
@leotm leotm requested review from boneskull and naugtur June 5, 2025 19:01
Comment thread packages/react-native-lockdown/TROUBLESHOOTING.md Outdated
Comment thread packages/react-native-lockdown/src/repair.js

@boneskull boneskull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any blockers, but some more suggestions / questions.

Comment thread packages/react-native-lockdown/src/index.js
Comment thread packages/react-native-lockdown/src/index.js
Comment thread packages/react-native-lockdown/src/index.js
Comment thread packages/react-native-lockdown/src/index.js Outdated
Comment thread packages/react-native-lockdown/src/index.js
Comment thread packages/react-native-lockdown/src/index.js Outdated
Comment thread packages/react-native-lockdown/src/repair.js
Comment thread packages/react-native-lockdown/src/repair.js
@boneskull boneskull added the enhancement New feature or request label Jun 6, 2025
@leotm

leotm commented Jun 9, 2025

Copy link
Copy Markdown
Member Author

tested packed in metamask-mobile, 120 commit rebase inc, follow-ups noted in description

@boneskull boneskull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@boneskull

Copy link
Copy Markdown
Member

@leotm I'll let you squash this mofo

leotm added a commit that referenced this pull request Jun 10, 2025
@leotm leotm force-pushed the react-native-lockdown branch from 033deac to d96574c Compare June 10, 2025 11:12
Comment thread packages/react-native-lockdown/test/unit/validatePolyfills.spec.js
@leotm leotm force-pushed the react-native-lockdown branch from 044c951 to c66feb0 Compare June 10, 2025 12:01
@leotm leotm merged commit 27bbe4f into main Jun 10, 2025
14 of 15 checks passed
@leotm leotm deleted the react-native-lockdown branch June 10, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Docs, examples, tutorials, and associated tooling enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants