Skip to content

Instantly share code, notes, and snippets.

🐉
!

kumavis kumavis

🐉
!
View GitHub Profile
@kumavis
kumavis / readme.md
Created Jun 5, 2020
LavaMoat webpack plugin requirements
View readme.md

LavaMoat

js tooling to help prevent attacks from evil dependencies.

read more here

lavamoat-webpack

webpack plugin for creating bundles protected by the LavaMoat kernel.

@kumavis
kumavis / plugin.js
Created Dec 12, 2019
lavamoat workaround plugin
View plugin.js
const { makeStringTransform } = require('browserify-transform-tools')
module.exports = makeStringTransform('lavamoat-browserify-workarounds', { excludeExtension: ['.json'] }, (content, _, cb) => {
const result = content
// fix html comments
.split('-->').join('-- >')
// fix direct eval
.split(' eval(').join(' (eval)(')
.split('\neval(').join('\n(eval)(')
View gist:cfec971e3224252f038a8ae575925b3e
> x = 'hello'
'hello'
> x.toString = () => 'ayy'
[Function]
> x.valueOf = () => 'yoo'
[Function]
> x
'hello'
> x+''
'hello'
View promise.then.js
_then = Promise.prototype.then
// [Function: then]
Promise.prototype.then = function(){ console.log('then!'); return _then.apply(this, arguments); }
// [Function (anonymous)]
p = new Promise(resolve => resolve())
// Promise { undefined }
View polyfillJsonRpcBatchAsBatchTx.js
const provider = polyfillJsonRpcBatchAsBatchTx(inpageProvider)
function polyfillJsonRpcBatchAsBatchTx (oldProvider) {
const newProvider = { sendAsync }
return newProvider
function sendAsync (req, cb) {
if (Array.isArray(req)) {
@kumavis
kumavis / read-only-membrane.js
Last active Nov 19, 2019
read-only handler for es-membrane
View read-only-membrane.js
"use strict"
const { Membrane } = require('es-membrane')
// create raw object to be protected by membrane
const rawObj = { secure: true }
// create membrane to manage interaction
const membrane = new Membrane()
@kumavis
kumavis / membrane_module.js
Last active Nov 18, 2019
simple membrane module system
View membrane_module.js
const { Membrane } = require('es-membrane')
const { defineModule, getRawModule } = createModuleSystem()
//
// define modules
//
// module X
defineModule('x', (require) => {
@kumavis
kumavis / background.js
Last active Nov 14, 2019
WebExtension Manifest v3
View background.js
// // Called when the user clicks on the browser action.
// chrome.action.onClicked.addListener(function(tab) {
// // No tabs or host permissions needed!
// console.log('Turning ' + tab.url + ' red!');
// // chrome.tabs.executeScript({
// // code: 'document.body.style.backgroundColor="red"'
// // });
// });
@kumavis
kumavis / experiment1.js
Last active Aug 21, 2019
ses sloppyGlobals mini kernel
View experiment1.js
const test = require('tape-promise').default(require('tape'))
const SES = require('../lib/ses.umd.js')
const realm = SES.makeSESRootRealm()
test(async t => {
const globalStore = {}
runModuleA()
View dht findProviders query.md

test details

contentRouting.findProviders

real browser dht network network size 60 kbucket 20 maxPeers 40 randomWalk off visible connection churn due to maxPeers

You can’t perform that action at this time.