Share a secret across ES6 specific modules, so that other modules cannot access the secret?

/#!/JoePea joe at trusktr.io
Sun Apr 15 19:21:28 UTC 2018


Ah, interesting! That would be useful!

*/#!/*JoePea

On Sun, Apr 15, 2018 at 11:58 AM, Mike Samuel <mikesamuel at gmail.com> wrote:

> The box function defined in github.com/mikesamuel/tc39-module-keys
> enables things like this.
>
>
> On Sun, Apr 23, 2017 at 4:42 PM, /#!/JoePea <joe at trusktr.io> wrote:
>
>> Is there a way to share some secret value across a few modules, and
>> prevent other modules? f.e. prevent modules of an app dev who is importing
>> modules of a library where the library wants to share private stuff across
>> its modules. Is this possible to implement somehow?
>>
>> WeakMaps can be encapsulated inside a module to implement "private"
>> properties for a class defined inside that module and then exported. But
>> "protected" can't be implemented with a WeakMap shared with modules because
>> then end-user app code can import the WeakMap and read all the stuff. Is
>> there some way to share a WeakMap private with classes defined across
>> modules?
>>
>> */#!/*JoePea
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180415/f635dde9/attachment.html>


More information about the es-discuss mailing list