Comcast / rulio

Rulio
Apache License 2.0
336 stars 59 forks source link

Support base64 Javascript rule action encoding #21

Closed trentontrees closed 8 years ago

trentontrees commented 8 years ago

It would be very helpful to be able to upload the code section of a rule as base64 and then have it decode before running.

Example: cat <<EOF | curl -s -d "@-" $ENDPOINT/api/loc/rules/add {"location":"$LOCATION", "rule": { "schedule" : "+1s" ,"action": {"code" : ["ZW52LmNvbnNvbGUoJ0hlbGxvJyk7"] } }}} EOF

When run, this will result in env.console('Hello');

I think this would be an all or nothing as an endpoint option or with a flag.

jsccast commented 8 years ago

A rule action has that opts property, which has a map as a value. This property was more or less designed for this sort of extension, so we can use that. Maybe "opts":{"base64": true, ... }.

jsccast commented 8 years ago

Generalize encoding specification to "opts":{"encoding":"base64", ... }.