@@ -32,6 +32,7 @@ var url = require('url')
32
32
var request = require ( "request" )
33
33
var vm = require ( 'vm' )
34
34
var path = require ( 'path' )
35
+ var crypto = require ( 'crypto' )
35
36
36
37
var local_driver = require ( './exec_drivers/local/index.js' )
37
38
@@ -147,6 +148,37 @@ IOpipe.prototype.make_context = function(done) {
147
148
return ctx
148
149
}
149
150
151
+ IOpipe . prototype . post_function = function ( data , callback ) {
152
+ this . define ( base + '/v0/filters/' ,
153
+ iopipe . make_context ( callback ) ) ( data )
154
+ }
155
+
156
+ IOpipe . prototype . fetch_function = function ( id , callback ) {
157
+ this . fetch ( base + '/v0/filters/' + id , function ( func ) {
158
+ const hash = crypto . createHash ( 'sha256' ) ;
159
+ hash . update ( func )
160
+ var hex = hash . digest ( 'hex' )
161
+ if ( hex !== id ) {
162
+ throw "Error"
163
+ }
164
+ callback ( input )
165
+ } )
166
+ }
167
+
168
+ IOpipe . prototype . pull_function = function ( id , callback ) {
169
+ var iopipe = this
170
+ this . fetch_function ( id , function ( func ) {
171
+ iopipe . _exec_driver . CreateFunction ( func , callback )
172
+ } )
173
+ }
174
+
175
+ IOpipe . prototype . push_function = function ( id , callback ) {
176
+ var iopipe = this
177
+ this . _exec_driver . GetFunction ( id , function ( func ) {
178
+ iopipe . post_function ( func , callback )
179
+ } )
180
+ }
181
+
150
182
/**
151
183
@description
152
184
Defines a pipeline, returning a function.
0 commit comments