LavaMoat / docs

React Native docs
1 stars 3 forks source link

Proof of Concept Insights - Attempt to assign a readonly property - `this.call` #8

Closed bentobox19 closed 1 year ago

bentobox19 commented 2 years ago

PoC

https://github.com/LavaMoat/docs/blob/main/react-native-and-ses-lockdown.md

Discussion

Sample Error

TypeError: Attempted to assign to readonly property.

We find the cause of this error at node_modules/web3-core-methods/src/index.js

var Method = function Method(options) {

    if (!options.call || !options.name) {
        throw new Error('When creating a method you need to provide at least the "name" and "call" property.');
    }

    this.name = options.name;
    this.call = options.call;
    this.params = options.params || 0;

Now, as Function.protoype.call was frozen, this.call = options.call throws

TypeError: Attempted to assign to readonly property.

Solution Proposed

The Object.defineProperty workaround

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty

Replace this

this.call = options.call;

By this

Object.defineProperty(this, 'call', {
  value: option.call
});

Items of Actions

leotm commented 1 year ago

closing as web3-core-methods been removed since from metamask-mobile