Comments (2)
Normally what we do for that kind of thing is we just allocate a String/flat String containing the info and put it as a child of the variable - you can prefix the name with \xff
to hide it from JS. For example this is what we do in Graphics to add a gfx
variable with data in it:
>var b = Graphics.createArrayBuffer(8,8,1)
=Graphics: {
buffer: new ArrayBuffer(8)
}
so 'gfx' is not visible normally, but if you look inside with 'trace'...
>trace(b)
#10329[r1,l1] Object {
#10281[r1,l2] Name String [2 blocks] "__proto__" #19[r4,l0] Object {
#20[r1,l2] Name String [2 blocks] "constructor" #17[r3,l0] NativeFunction 0x5e451 (1) {
.....
}
}
#10332[r1,l2] Name String [2 blocks] "buffer" #10262[r1,l0] ArrayBuffer (offs 0, len 8) #10312[r1,l0] String [1 blocks] "\0\0\0\0\0\0\0\0"
#10268[r1,l2] Name String [1 blocks] "\xFFgfx" #9718[r1,l0] FlatString [4 blocks] "\0\0\0\b\0\b\0\1\1\0\0\0\0\0\0\0\1 \0\0\0\0\x0F\0\0\0\0\7\0\7\0\xFF\x7F\xFF\x7F\0\x80\0\x80"
}
=undefined
>
Sure, you could access it from JS if you really tried, but since JS is able to use peek
to access any area of memory, anything is ultimately accessible from JS if you try hard enough, so I feel like this is good enough
from espruino.
Thanks for the quick response, @gfwilliams!
Ok, then as I understand it the whole system runs as a single trusted environment; apps can't really keep secrets from other apps.
In this context I agree that the method you describe is enough for hiding data that is not relevant to JS (apart from debugging, maybe). Sounds good.
Closing as feature already exists.
from espruino.
Related Issues (20)
- overlays are cut off from the top instead of landing at desired y position HOT 2
- [Bangle.js 2 Question] EXTCOM frequency HOT 1
- nrf5x_dfu/main.c highlight potential impossible code path HOT 2
- Scoping bug when defining a function from a previous scope HOT 14
- Stuck uploading firmware v23 HOT 2
- Images pixel crop when rotating HOT 1
- analogRead doesn't work (0.99 first time, 0 after) HOT 2
- Modulus with infinity returns unexpected value HOT 1
- Extra undefined element added in array.map() HOT 3
- SyntaxError not thrown for duplicate parameters in arrow functions HOT 1
- Unexpected result in array manipulation and arithmetic operations HOT 1
- ESP32_IDF4 issues HOT 7
- Infinite loop with reduce HOT 1
- Spread operator unsupported? HOT 1
- Conversion of "1A" to 1 instead of NaN
- NaN vs 0 issues?
- "FW addr ... fail" can be caused by being called while jspIsInterrupted=true
- Security Vulnerability - Action Required: Insufficient Information vulnerability may in your project HOT 3
- Obj.on/emit should always allocate an array
- BLE connection randomly hangs on Bangle.js2 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espruino.