UNPKG

47.5 kBMarkdownView Raw
1# sandboxjs
2
3Sandbox node.js code like a boss.
4
5## Key Features
6
7* Runs code on the public [webtask.io](https://webtask.io) cluster.
8* Your code is totally sandboxed from everyone else's.
9* Integrated with your [wt-cli](https://npmjs.org/package/wt-cli) profiles.
10* Supports returning Promises and/or invoking node-style callbacks.
11
12## Installing it
13
14```bash
15npm install sandboxjs
16
17# Optionally configure a default wt-cli profile
18```
19
20## Using it
21
22**First, get a webtask token using [wt-cli](https://npmjs.org/package/wt-cli):**
23
24```bash
25# Create a new wt-cli profile
26npm install -g wt-cli
27wt init
28
29# Or, if you already use wt-cli:
30wt profile ls
31```
32
33```js
34var Assert = require('assert');
35var Sandbox = require('sandboxjs');
36
37// You can get your webtask token using the steps above
38var code = 'module.exports = function (ctx, cb) { cb(null, "hello world"); }';
39var profile = Sandbox.fromToken(process.env.WEBTASK_TOKEN);
40
41// This library lets you create a webtask and run it in one step as a shortcut:
42profile.run(code, function (err, res, body) {
43 Assert.ifError(err);
44 Assert.equal(res.statusCode, 200, 'The webtask executed as expected');
45 Assert.equal(body, 'hello world', 'The webtask returned the expected string');
46});
47
48// Alternatively, your application might want to to create a webtask url
49// with your (or your users') custom code and secrets.
50profile.create(code, { secrets: { auth0: 'rocks' } }, function (err, webtask) {
51 Assert.ifError(err);
52
53 // Making requests to this url will run the specified custom code in a
54 // node.js sandbox and will give it access to your secrets in the first
55 // argument (`ctx`) of your exported webtask function.
56 // For more information on the different styles of webtask functions that
57 // are supported, see: https://webtask.io/docs/model
58 console.log(webtask.url);
59});
60```
61
62### Examples
63
64**Update the code of an existing named webtask**
65
66```js
67var Sandbox = require('sandboxjs');
68
69var sandbox = Sandbox.init({ /* ... */ });
70var webtaskName = 'my_webtask';
71var webtaskCode = 'module.exports = ...';
72
73sandbox.inspectWebtask({
74 name: webtaskName,
75 // We need to decrypt embedded secrets so that we can set them on the
76 // replacement named webtask
77 decrypt: true,
78 // No need to fetch code since we will be updating it anyway
79 fetch_code: false,
80}).then(handleClaims);
81
82function handleClaims(claims) {
83 // We will pull any claims from the existing webtask that are user-defined
84 // and set them on a new claims object. Note that some claims are *NOT*
85 // copied over because they are read-only claims generated by the platform.
86 // Common examples include: `ca`, `jti` and `iat`.
87 var newClaims = {
88 jtn: webtaskName,
89 dd: claims.dd,
90 mb: claims.mb,
91 pb: claims.pb,
92 // Instead of being an opaque, encrypted blob, this will be a javascript
93 // Object mapping secret key to value because we set the `decrypt`
94 // option on the call to `inspectWebtask`.
95 ectx: claims.ectx,
96 pctx: claims.pctx,
97 code: webtaskCode,
98 };
99
100 // Create a replacement webtask from raw claims. We use `createRaw` instead
101 // of `create` so that we can deal directly with the platform's claims
102 // instead of the more human-friendly aliases in `create`.
103 // This method will make a token issue request with the updated claims
104 // and resolve the Promise with a new `Webtask` instance based on that
105 // token.
106 return sandbox.createRaw(newClaims);
107}
108```
109
110## API
111
112## Modules
113
114<dl>
115<dt><a href="#module_sandboxjs">sandboxjs</a></dt>
116<dd><p>Sandbox node.js code.</p>
117</dd>
118</dl>
119
120## Classes
121
122<dl>
123<dt><a href="#CronJob">CronJob</a></dt>
124<dd></dd>
125<dt><a href="#Webtask">Webtask</a></dt>
126<dd></dd>
127</dl>
128
129<a name="module_sandboxjs"></a>
130
131## sandboxjs
132Sandbox node.js code.
133
134
135* [sandboxjs](#module_sandboxjs)
136 * _static_
137 * [.fromToken(token, options)](#module_sandboxjs.fromToken) ⇒ <code>Sandbox</code>
138 * [.init(options)](#module_sandboxjs.init) ⇒ <code>Sandbox</code>
139 * _inner_
140 * [~Sandbox](#module_sandboxjs..Sandbox)
141 * [new Sandbox(options)](#new_module_sandboxjs..Sandbox_new)
142 * [.clone(options)](#module_sandboxjs..Sandbox+clone)
143 * [.create([codeOrUrl], [options], [cb])](#module_sandboxjs..Sandbox+create) ⇒ <code>Promise</code>
144 * [.createRaw(claims, [cb])](#module_sandboxjs..Sandbox+createRaw) ⇒ <code>Promise</code>
145 * [.createUrl(options, [cb])](#module_sandboxjs..Sandbox+createUrl) ⇒ <code>Promise</code>
146 * [.run([codeOrUrl], [options], [cb])](#module_sandboxjs..Sandbox+run) ⇒ <code>Promise</code>
147 * [.createToken(options, [cb])](#module_sandboxjs..Sandbox+createToken) ⇒ <code>Promise</code>
148 * [.issueRequest(request, [cb])](#module_sandboxjs..Sandbox+issueRequest) ⇒ <code>Promise</code>
149 * [.createTokenRaw(claims, [options], [cb])](#module_sandboxjs..Sandbox+createTokenRaw) ⇒ <code>Promise</code>
150 * [.createLogStream(options)](#module_sandboxjs..Sandbox+createLogStream) ⇒ <code>Stream</code>
151 * [.getWebtask(options, [cb])](#module_sandboxjs..Sandbox+getWebtask) ⇒ <code>Promise</code>
152 * [.createWebtask(options, [cb])](#module_sandboxjs..Sandbox+createWebtask) ⇒ <code>Promise</code>
153 * [.removeWebtask(options, [cb])](#module_sandboxjs..Sandbox+removeWebtask) ⇒ <code>Promise</code>
154 * [.updateWebtask(options, [cb])](#module_sandboxjs..Sandbox+updateWebtask) ⇒ <code>Promise</code>
155 * [.listWebtasks(options, [cb])](#module_sandboxjs..Sandbox+listWebtasks) ⇒ <code>Promise</code>
156 * [.createCronJob(options, [cb])](#module_sandboxjs..Sandbox+createCronJob) ⇒ <code>Promise</code>
157 * [.removeCronJob(options, [cb])](#module_sandboxjs..Sandbox+removeCronJob) ⇒ <code>Promise</code>
158 * [.setCronJobState(options, [cb])](#module_sandboxjs..Sandbox+setCronJobState) ⇒ <code>Promise</code>
159 * [.listCronJobs([options], [cb])](#module_sandboxjs..Sandbox+listCronJobs) ⇒ <code>Promise</code>
160 * [.getCronJob(options, [cb])](#module_sandboxjs..Sandbox+getCronJob) ⇒ <code>Promise</code>
161 * [.getCronJobHistory(options, [cb])](#module_sandboxjs..Sandbox+getCronJobHistory) ⇒ <code>Promise</code>
162 * [.inspectToken(options, [cb])](#module_sandboxjs..Sandbox+inspectToken) ⇒ <code>Promise</code>
163 * [.inspectWebtask(options, [cb])](#module_sandboxjs..Sandbox+inspectWebtask) ⇒ <code>Promise</code>
164 * [.revokeToken(token, [cb])](#module_sandboxjs..Sandbox+revokeToken) ⇒ <code>Promise</code>
165 * [.listNodeModuleVersions(options, [cb])](#module_sandboxjs..Sandbox+listNodeModuleVersions) ⇒ <code>Promise</code>
166 * [.ensureNodeModules(options, [cb])](#module_sandboxjs..Sandbox+ensureNodeModules) ⇒ <code>Promise</code>
167 * [.updateStorage(options, storage, [cb])](#module_sandboxjs..Sandbox+updateStorage) ⇒ <code>Promise</code>
168 * [.getStorage(options, [cb])](#module_sandboxjs..Sandbox+getStorage) ⇒ <code>Promise</code>
169
170<a name="module_sandboxjs.fromToken"></a>
171
172### Sandbox.fromToken(token, options) ⇒ <code>Sandbox</code>
173Create a Sandbox instance from a webtask token
174
175**Kind**: static method of <code>[sandboxjs](#module_sandboxjs)</code>
176**Returns**: <code>Sandbox</code> - A {@see Sandbox} instance whose url, token and container were derived from the given webtask token.
177
178| Param | Type | Description |
179| --- | --- | --- |
180| token | <code>String</code> | The webtask token from which the Sandbox profile will be derived. |
181| options | <code>Object</code> | The options for creating the Sandbox instance that override the derived values from the token. |
182| [options.url] | <code>String</code> | The url of the webtask cluster. Defaults to the public 'webtask.it.auth0.com' cluster. |
183| options.container | <code>String</code> | The container with which this Sandbox instance should be associated. Note that your Webtask token must give you access to that container or all operations will fail. |
184| options.token | <code>String</code> | The Webtask Token. See: https://webtask.io/docs/api_issue. |
185
186<a name="module_sandboxjs.init"></a>
187
188### Sandbox.init(options) ⇒ <code>Sandbox</code>
189Create a Sandbox instance
190
191**Kind**: static method of <code>[sandboxjs](#module_sandboxjs)</code>
192**Returns**: <code>Sandbox</code> - A {@see Sandbox} instance.
193
194| Param | Type | Description |
195| --- | --- | --- |
196| options | <code>Object</code> | The options for creating the Sandbox instance. |
197| [options.url] | <code>String</code> | The url of the webtask cluster. Defaults to the public 'webtask.it.auth0.com' cluster. |
198| options.container | <code>String</code> | The container with which this Sandbox instance should be associated. Note that your Webtask token must give you access to that container or all operations will fail. |
199| options.token | <code>String</code> | The Webtask Token. See: https://webtask.io/docs/api_issue. |
200
201<a name="module_sandboxjs..Sandbox"></a>
202
203### Sandbox~Sandbox
204**Kind**: inner class of <code>[sandboxjs](#module_sandboxjs)</code>
205
206* [~Sandbox](#module_sandboxjs..Sandbox)
207 * [new Sandbox(options)](#new_module_sandboxjs..Sandbox_new)
208 * [.clone(options)](#module_sandboxjs..Sandbox+clone)
209 * [.create([codeOrUrl], [options], [cb])](#module_sandboxjs..Sandbox+create) ⇒ <code>Promise</code>
210 * [.createRaw(claims, [cb])](#module_sandboxjs..Sandbox+createRaw) ⇒ <code>Promise</code>
211 * [.createUrl(options, [cb])](#module_sandboxjs..Sandbox+createUrl) ⇒ <code>Promise</code>
212 * [.run([codeOrUrl], [options], [cb])](#module_sandboxjs..Sandbox+run) ⇒ <code>Promise</code>
213 * [.createToken(options, [cb])](#module_sandboxjs..Sandbox+createToken) ⇒ <code>Promise</code>
214 * [.issueRequest(request, [cb])](#module_sandboxjs..Sandbox+issueRequest) ⇒ <code>Promise</code>
215 * [.createTokenRaw(claims, [options], [cb])](#module_sandboxjs..Sandbox+createTokenRaw) ⇒ <code>Promise</code>
216 * [.createLogStream(options)](#module_sandboxjs..Sandbox+createLogStream) ⇒ <code>Stream</code>
217 * [.getWebtask(options, [cb])](#module_sandboxjs..Sandbox+getWebtask) ⇒ <code>Promise</code>
218 * [.createWebtask(options, [cb])](#module_sandboxjs..Sandbox+createWebtask) ⇒ <code>Promise</code>
219 * [.removeWebtask(options, [cb])](#module_sandboxjs..Sandbox+removeWebtask) ⇒ <code>Promise</code>
220 * [.updateWebtask(options, [cb])](#module_sandboxjs..Sandbox+updateWebtask) ⇒ <code>Promise</code>
221 * [.listWebtasks(options, [cb])](#module_sandboxjs..Sandbox+listWebtasks) ⇒ <code>Promise</code>
222 * [.createCronJob(options, [cb])](#module_sandboxjs..Sandbox+createCronJob) ⇒ <code>Promise</code>
223 * [.removeCronJob(options, [cb])](#module_sandboxjs..Sandbox+removeCronJob) ⇒ <code>Promise</code>
224 * [.setCronJobState(options, [cb])](#module_sandboxjs..Sandbox+setCronJobState) ⇒ <code>Promise</code>
225 * [.listCronJobs([options], [cb])](#module_sandboxjs..Sandbox+listCronJobs) ⇒ <code>Promise</code>
226 * [.getCronJob(options, [cb])](#module_sandboxjs..Sandbox+getCronJob) ⇒ <code>Promise</code>
227 * [.getCronJobHistory(options, [cb])](#module_sandboxjs..Sandbox+getCronJobHistory) ⇒ <code>Promise</code>
228 * [.inspectToken(options, [cb])](#module_sandboxjs..Sandbox+inspectToken) ⇒ <code>Promise</code>
229 * [.inspectWebtask(options, [cb])](#module_sandboxjs..Sandbox+inspectWebtask) ⇒ <code>Promise</code>
230 * [.revokeToken(token, [cb])](#module_sandboxjs..Sandbox+revokeToken) ⇒ <code>Promise</code>
231 * [.listNodeModuleVersions(options, [cb])](#module_sandboxjs..Sandbox+listNodeModuleVersions) ⇒ <code>Promise</code>
232 * [.ensureNodeModules(options, [cb])](#module_sandboxjs..Sandbox+ensureNodeModules) ⇒ <code>Promise</code>
233 * [.updateStorage(options, storage, [cb])](#module_sandboxjs..Sandbox+updateStorage) ⇒ <code>Promise</code>
234 * [.getStorage(options, [cb])](#module_sandboxjs..Sandbox+getStorage) ⇒ <code>Promise</code>
235
236<a name="new_module_sandboxjs..Sandbox_new"></a>
237
238#### new Sandbox(options)
239Creates an object representing a user's webtask.io credentials
240
241
242| Param | Type | Description |
243| --- | --- | --- |
244| options | <code>Object</code> | Options used to configure the profile |
245| options.url | <code>String</code> | The url of the webtask cluster where code will run |
246| options.container | <code>String</code> | The name of the container in which code will run |
247| options.token | <code>String</code> | The JWT (see: http://jwt.io) issued by webtask.io that grants rights to run code in the indicated container |
248| [options.onBeforeRequest] | <code>String</code> | An array of hook functions to be invoked with a prepared request |
249
250<a name="module_sandboxjs..Sandbox+clone"></a>
251
252#### sandbox.clone(options)
253Create a clone of this sandbox instances with one or more different parameters
254
255**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
256
257| Param | Type | Description |
258| --- | --- | --- |
259| options | <code>Object</code> | Options used to configure the profile |
260| [options.url] | <code>String</code> | The url of the webtask cluster where code will run |
261| [options.container] | <code>String</code> | The name of the container in which code will run |
262| [options.token] | <code>String</code> | The JWT (see: http://jwt.io) issued by webtask.io that grants rights to run code in the indicated container |
263| [options.onBeforeRequest] | <code>String</code> | An array of hook functions to be invoked with a prepared request |
264
265<a name="module_sandboxjs..Sandbox+create"></a>
266
267#### sandbox.create([codeOrUrl], [options], [cb]) ⇒ <code>Promise</code>
268Create a Webtask from the given options
269
270**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
271**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
272
273| Param | Type | Description |
274| --- | --- | --- |
275| [codeOrUrl] | <code>String</code> | The code for the webtask or a url starting with http:// or https:// |
276| [options] | <code>Object</code> | Options for creating the webtask |
277| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
278
279<a name="module_sandboxjs..Sandbox+createRaw"></a>
280
281#### sandbox.createRaw(claims, [cb]) ⇒ <code>Promise</code>
282Create a Webtask from the given claims
283
284**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
285**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
286
287| Param | Type | Description |
288| --- | --- | --- |
289| claims | <code>Object</code> | Options for creating the webtask |
290| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
291
292<a name="module_sandboxjs..Sandbox+createUrl"></a>
293
294#### sandbox.createUrl(options, [cb]) ⇒ <code>Promise</code>
295Shortcut to create a Webtask and get its url from the given options
296
297**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
298**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
299
300| Param | Type | Description |
301| --- | --- | --- |
302| options | <code>Object</code> | Options for creating the webtask |
303| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
304
305<a name="module_sandboxjs..Sandbox+run"></a>
306
307#### sandbox.run([codeOrUrl], [options], [cb]) ⇒ <code>Promise</code>
308Shortcut to create and run a Webtask from the given options
309
310**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
311**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
312
313| Param | Type | Description |
314| --- | --- | --- |
315| [codeOrUrl] | <code>String</code> | The code for the webtask or a url starting with http:// or https:// |
316| [options] | <code>Object</code> | Options for creating the webtask |
317| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
318
319<a name="module_sandboxjs..Sandbox+createToken"></a>
320
321#### sandbox.createToken(options, [cb]) ⇒ <code>Promise</code>
322Create a webtask token - A JWT (see: http://jwt.io) with the supplied options
323
324**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
325**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
326
327| Param | Type | Description |
328| --- | --- | --- |
329| options | <code>Object</code> | Claims to make for this token (see: https://webtask.io/docs/api_issue) |
330| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
331
332<a name="module_sandboxjs..Sandbox+issueRequest"></a>
333
334#### sandbox.issueRequest(request, [cb]) ⇒ <code>Promise</code>
335Run a prepared Superagent request through any configured
336onBeforeRequest hooks.
337
338This can be useful for enablying proxies for server-side
339consumers of sandboxjs.
340
341**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
342**Returns**: <code>Promise</code> - - A promise representing the fulfillment of the request
343
344| Param | Type | Description |
345| --- | --- | --- |
346| request | <code>Superagent.Request</code> | Instance of a superagent request |
347| [cb] | <code>function</code> | Node-style callback function |
348
349<a name="module_sandboxjs..Sandbox+createTokenRaw"></a>
350
351#### sandbox.createTokenRaw(claims, [options], [cb]) ⇒ <code>Promise</code>
352Create a webtask token - A JWT (see: http://jwt.io) with the supplied claims
353
354**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
355**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
356
357| Param | Type | Description |
358| --- | --- | --- |
359| claims | <code>Object</code> | Claims to make for this token (see: https://webtask.io/docs/api_issue) |
360| [options] | <code>Object</code> | Optional options. Currently only options.include_webtask_url is supported. |
361| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
362
363<a name="module_sandboxjs..Sandbox+createLogStream"></a>
364
365#### sandbox.createLogStream(options) ⇒ <code>Stream</code>
366Create a stream of logs from the webtask container
367
368Note that the logs will include messages from our infrastructure.
369
370**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
371**Returns**: <code>Stream</code> - A stream that will emit 'data' events with container logs
372
373| Param | Type | Description |
374| --- | --- | --- |
375| options | <code>Object</code> | Streaming options overrides |
376| [options.container] | <code>String</code> | The container for which you would like to stream logs. Defaults to the current profile's container. |
377
378<a name="module_sandboxjs..Sandbox+getWebtask"></a>
379
380#### sandbox.getWebtask(options, [cb]) ⇒ <code>Promise</code>
381Read a named webtask
382
383**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
384**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
385
386| Param | Type | Description |
387| --- | --- | --- |
388| options | <code>Object</code> | Options |
389| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
390| options.name | <code>String</code> | The name of the webtask. |
391| [options.decrypt] | <code>Boolean</code> | Decrypt the webtask's secrets. |
392| [options.fetch_code] | <code>Boolean</code> | Fetch the code associated with the webtask. |
393| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
394
395<a name="module_sandboxjs..Sandbox+createWebtask"></a>
396
397#### sandbox.createWebtask(options, [cb]) ⇒ <code>Promise</code>
398Create a named webtask
399
400**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
401**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
402
403| Param | Type | Description |
404| --- | --- | --- |
405| options | <code>Object</code> | Options |
406| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
407| options.name | <code>String</code> | The name of the webtask. |
408| [options.secrets] | <code>String</code> | Set the webtask secrets. |
409| [options.meta] | <code>String</code> | Set the webtask metadata. |
410| [options.host] | <code>String</code> | Set the webtask hostname. |
411| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
412
413<a name="module_sandboxjs..Sandbox+removeWebtask"></a>
414
415#### sandbox.removeWebtask(options, [cb]) ⇒ <code>Promise</code>
416Remove a named webtask from the webtask container
417
418**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
419**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
420
421| Param | Type | Description |
422| --- | --- | --- |
423| options | <code>Object</code> | Options |
424| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
425| options.name | <code>String</code> | The name of the cron job. |
426| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
427
428<a name="module_sandboxjs..Sandbox+updateWebtask"></a>
429
430#### sandbox.updateWebtask(options, [cb]) ⇒ <code>Promise</code>
431Update an existing webtask's code, secrets or other claims
432
433Note that this method should be used with caution as there is the potential
434for a race condition where another agent updates the webtask between the time
435that the webtask details and claims are resolved and when the webtask
436update is issued.
437
438**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
439**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an instance of Webtask representing the updated webtask
440
441| Param | Type | Description |
442| --- | --- | --- |
443| options | <code>Object</code> | Options |
444| options.name | <code>String</code> | Name of the webtask to update |
445| [options.code] | <code>String</code> | Updated code for the webtask |
446| [options.url] | <code>String</code> | Updated code URL for the webtask |
447| [options.secrets] | <code>String</code> | If `false`, remove existing secrets, if an object update secrets, otherwise preserve |
448| [options.params] | <code>String</code> | If `false`, remove existing params, if an object update params, otherwise preserve |
449| [options.host] | <code>String</code> | If `false`, remove existing host, if a string update host, otherwise preserve |
450| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
451
452<a name="module_sandboxjs..Sandbox+listWebtasks"></a>
453
454#### sandbox.listWebtasks(options, [cb]) ⇒ <code>Promise</code>
455List named webtasks from the webtask container
456
457**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
458**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
459
460| Param | Type | Description |
461| --- | --- | --- |
462| options | <code>Object</code> | Options |
463| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
464| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
465
466<a name="module_sandboxjs..Sandbox+createCronJob"></a>
467
468#### sandbox.createCronJob(options, [cb]) ⇒ <code>Promise</code>
469Create a cron job from an already-existing webtask
470
471**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
472**Returns**: <code>Promise</code> - A Promise that will be fulfilled with a {@see CronJob} instance.
473
474| Param | Type | Description |
475| --- | --- | --- |
476| options | <code>Object</code> | Options for creating a cron job |
477| [options.container] | <code>String</code> | The container in which the job will run. Defaults to the current profile's container. |
478| options.name | <code>String</code> | The name of the cron job. |
479| [options.token] | <code>String</code> | The webtask token that will be used to run the job. |
480| options.schedule | <code>String</code> | The cron schedule that will be used to determine when the job will be run. |
481| options.tz | <code>String</code> | The cron timezone (IANA timezone). |
482| options.meta | <code>String</code> | The cron metadata (set of string key value pairs). |
483| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
484
485<a name="module_sandboxjs..Sandbox+removeCronJob"></a>
486
487#### sandbox.removeCronJob(options, [cb]) ⇒ <code>Promise</code>
488Remove an existing cron job
489
490**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
491**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the response from removing the job.
492
493| Param | Type | Description |
494| --- | --- | --- |
495| options | <code>Object</code> | Options for removing the cron job |
496| [options.container] | <code>String</code> | The container in which the job will run. Defaults to the current profile's container. |
497| options.name | <code>String</code> | The name of the cron job. |
498| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
499
500<a name="module_sandboxjs..Sandbox+setCronJobState"></a>
501
502#### sandbox.setCronJobState(options, [cb]) ⇒ <code>Promise</code>
503Set an existing cron job's state
504
505**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
506**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the response from removing the job.
507
508| Param | Type | Description |
509| --- | --- | --- |
510| options | <code>Object</code> | Options for updating the cron job's state |
511| [options.container] | <code>String</code> | The container in which the job will run. Defaults to the current profile's container. |
512| options.name | <code>String</code> | The name of the cron job. |
513| options.state | <code>String</code> | The new state of the cron job. |
514| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
515
516<a name="module_sandboxjs..Sandbox+listCronJobs"></a>
517
518#### sandbox.listCronJobs([options], [cb]) ⇒ <code>Promise</code>
519List cron jobs associated with this profile
520
521**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
522**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an Array of {@see CronJob} instances.
523
524| Param | Type | Description |
525| --- | --- | --- |
526| [options] | <code>Object</code> | Options for listing cron jobs. |
527| [options.container] | <code>String</code> | The container in which the job will run. Defaults to the current profile's container. |
528| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
529
530<a name="module_sandboxjs..Sandbox+getCronJob"></a>
531
532#### sandbox.getCronJob(options, [cb]) ⇒ <code>Promise</code>
533Get a CronJob instance associated with an existing cron job
534
535**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
536**Returns**: <code>Promise</code> - A Promise that will be fulfilled with a {@see CronJob} instance.
537
538| Param | Type | Description |
539| --- | --- | --- |
540| options | <code>Object</code> | Options for retrieving the cron job. |
541| [options.container] | <code>String</code> | The container in which the job will run. Defaults to the current profile's container. |
542| options.name | <code>String</code> | The name of the cron job. |
543| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
544
545<a name="module_sandboxjs..Sandbox+getCronJobHistory"></a>
546
547#### sandbox.getCronJobHistory(options, [cb]) ⇒ <code>Promise</code>
548Get the historical results of executions of an existing cron job.
549
550**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
551**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an Array of cron job results.
552
553| Param | Type | Description |
554| --- | --- | --- |
555| options | <code>Object</code> | Options for retrieving the cron job. |
556| [options.container] | <code>String</code> | The container in which the job will run. Defaults to the current profile's container. |
557| options.name | <code>String</code> | The name of the cron job. |
558| [options.offset] | <code>String</code> | The offset to use when paging through results. |
559| [options.limit] | <code>String</code> | The limit to use when paging through results. |
560| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
561
562<a name="module_sandboxjs..Sandbox+inspectToken"></a>
563
564#### sandbox.inspectToken(options, [cb]) ⇒ <code>Promise</code>
565Inspect an existing webtask token to resolve code and/or secrets
566
567**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
568**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the resolved webtask data.
569
570| Param | Type | Description |
571| --- | --- | --- |
572| options | <code>Object</code> | Options for inspecting the webtask. |
573| options.token | <code>Boolean</code> | The token that you would like to inspect. |
574| [options.decrypt] | <code>Boolean</code> | Decrypt the webtask's secrets. |
575| [options.fetch_code] | <code>Boolean</code> | Fetch the code associated with the webtask. |
576| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
577
578<a name="module_sandboxjs..Sandbox+inspectWebtask"></a>
579
580#### sandbox.inspectWebtask(options, [cb]) ⇒ <code>Promise</code>
581Inspect an existing named webtask to resolve code and/or secrets
582
583**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
584**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the resolved webtask data.
585
586| Param | Type | Description |
587| --- | --- | --- |
588| options | <code>Object</code> | Options for inspecting the webtask. |
589| options.name | <code>Boolean</code> | The named webtask that you would like to inspect. |
590| [options.decrypt] | <code>Boolean</code> | Decrypt the webtask's secrets. |
591| [options.fetch_code] | <code>Boolean</code> | Fetch the code associated with the webtask. |
592| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
593
594<a name="module_sandboxjs..Sandbox+revokeToken"></a>
595
596#### sandbox.revokeToken(token, [cb]) ⇒ <code>Promise</code>
597Revoke a webtask token
598
599**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
600**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
601**See**: https://webtask.io/docs/api_revoke
602
603| Param | Type | Description |
604| --- | --- | --- |
605| token | <code>String</code> | The token that should be revoked |
606| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
607
608<a name="module_sandboxjs..Sandbox+listNodeModuleVersions"></a>
609
610#### sandbox.listNodeModuleVersions(options, [cb]) ⇒ <code>Promise</code>
611List versions of a given node module that are available on the platform
612
613**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
614**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
615
616| Param | Type | Description |
617| --- | --- | --- |
618| options | <code>Object</code> | Options |
619| options.name | <code>String</code> | Name of the node module |
620| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
621
622<a name="module_sandboxjs..Sandbox+ensureNodeModules"></a>
623
624#### sandbox.ensureNodeModules(options, [cb]) ⇒ <code>Promise</code>
625Ensure that a set of modules are available on the platform
626
627**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
628**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of { name, version, state } objects
629
630| Param | Type | Description |
631| --- | --- | --- |
632| options | <code>Object</code> | Options |
633| options.modules | <code>Array</code> | Array of { name, version } pairs |
634| options.reset | <code>Boolean</code> | Trigger a rebuild of the modules (Requires administrative token) |
635| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
636
637<a name="module_sandboxjs..Sandbox+updateStorage"></a>
638
639#### sandbox.updateStorage(options, storage, [cb]) ⇒ <code>Promise</code>
640Update the storage associated to the a webtask
641
642**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
643**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
644
645| Param | Type | Description |
646| --- | --- | --- |
647| options | <code>Object</code> | Options |
648| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
649| options.name | <code>String</code> | The name of the webtask. |
650| storage | <code>Object</code> | storage |
651| storage.data | <code>Object</code> | The data to be stored |
652| storage.etag | <code>String</code> | Pass in an optional string to be used for optimistic concurrency control to prevent simultaneous updates of the same data. |
653| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
654
655<a name="module_sandboxjs..Sandbox+getStorage"></a>
656
657#### sandbox.getStorage(options, [cb]) ⇒ <code>Promise</code>
658Read the storage associated to the a webtask
659
660**Kind**: instance method of <code>[Sandbox](#module_sandboxjs..Sandbox)</code>
661**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
662
663| Param | Type | Description |
664| --- | --- | --- |
665| options | <code>Object</code> | Options |
666| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
667| options.name | <code>String</code> | The name of the webtask. |
668| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
669
670<a name="CronJob"></a>
671
672## CronJob
673**Kind**: global class
674
675* [CronJob](#CronJob)
676 * [new CronJob()](#new_CronJob_new)
677 * [.sandbox](#CronJob+sandbox)
678 * [.refresh([cb])](#CronJob+refresh) ⇒ <code>Promise</code>
679 * [.remove([cb])](#CronJob+remove) ⇒ <code>Promise</code>
680 * [.getHistory(options, [cb])](#CronJob+getHistory) ⇒ <code>Promise</code>
681 * [.inspect(options, [cb])](#CronJob+inspect) ⇒ <code>Promise</code>
682 * [.setJobState(options, [cb])](#CronJob+setJobState) ⇒ <code>Promise</code>
683
684<a name="new_CronJob_new"></a>
685
686### new CronJob()
687Creates an object representing a CronJob
688
689<a name="CronJob+sandbox"></a>
690
691### cronJob.sandbox
692**Kind**: instance property of <code>[CronJob](#CronJob)</code>
693**Properties**
694
695| Name | Description |
696| --- | --- |
697| sandbox | The {@see Sandbox} instance used to create this Webtask instance |
698
699<a name="CronJob+refresh"></a>
700
701### cronJob.refresh([cb]) ⇒ <code>Promise</code>
702Refresh this job's metadata
703
704**Kind**: instance method of <code>[CronJob](#CronJob)</code>
705**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the this cron job instance
706
707| Param | Type | Description |
708| --- | --- | --- |
709| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
710
711<a name="CronJob+remove"></a>
712
713### cronJob.remove([cb]) ⇒ <code>Promise</code>
714Remove this cron job from the webtask cluster
715
716Note that this will not revoke the underlying webtask token, so the underlying webtask will remain functional.
717
718**Kind**: instance method of <code>[CronJob](#CronJob)</code>
719**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the token
720
721| Param | Type | Description |
722| --- | --- | --- |
723| [cb] | <code>function</code> | Optional callback function for node-style callbacks |
724
725<a name="CronJob+getHistory"></a>
726
727### cronJob.getHistory(options, [cb]) ⇒ <code>Promise</code>
728Get the history of this cron job
729
730**Kind**: instance method of <code>[CronJob](#CronJob)</code>
731**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an Array of cron job results.
732
733| Param | Type | Description |
734| --- | --- | --- |
735| options | <code>Object</code> | Options for retrieving the cron job. |
736| [options.offset] | <code>String</code> | The offset to use when paging through results. |
737| [options.limit] | <code>String</code> | The limit to use when paging through results. |
738| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
739
740<a name="CronJob+inspect"></a>
741
742### cronJob.inspect(options, [cb]) ⇒ <code>Promise</code>
743Inspect an existing webtask to optionally get code and/or secrets
744
745**Kind**: instance method of <code>[CronJob](#CronJob)</code>
746**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an Array of cron job results.
747
748| Param | Type | Description |
749| --- | --- | --- |
750| options | <code>Object</code> | Options for inspecting the webtask. |
751| [options.fetch_code] | <code>Boolean</code> | Fetch the code associated with the webtask. |
752| [options.decrypt] | <code>Boolean</code> | Decrypt the webtask's secrets. |
753| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
754
755<a name="CronJob+setJobState"></a>
756
757### cronJob.setJobState(options, [cb]) ⇒ <code>Promise</code>
758Set the cron job's state
759
760**Kind**: instance method of <code>[CronJob](#CronJob)</code>
761**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an Array of cron job results.
762
763| Param | Type | Description |
764| --- | --- | --- |
765| options | <code>Object</code> | Options for updating the webtask. |
766| options.state | <code>Boolean</code> | Set the cron job's state to this. |
767| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
768
769<a name="Webtask"></a>
770
771## Webtask
772**Kind**: global class
773
774* [Webtask](#Webtask)
775 * [new Webtask()](#new_Webtask_new)
776 * [.claims](#Webtask+claims)
777 * [.token](#Webtask+token)
778 * [.sandbox](#Webtask+sandbox)
779 * [.meta](#Webtask+meta)
780 * [.secrets](#Webtask+secrets)
781 * [.code](#Webtask+code)
782 * [.createLogStream(options)](#Webtask+createLogStream) ⇒ <code>Stream</code>
783 * [.run(options, [cb])](#Webtask+run) ⇒ <code>Promise</code>
784 * [.createCronJob(options, [cb])](#Webtask+createCronJob) ⇒ <code>Promise</code>
785 * [.inspect(options, [cb])](#Webtask+inspect) ⇒ <code>Promise</code>
786 * [.remove([cb])](#Webtask+remove) ⇒ <code>Promise</code>
787 * [.revoke([cb])](#Webtask+revoke) ⇒ <code>Promise</code>
788 * [.update([options], [cb])](#Webtask+update) ⇒ <code>Promise</code>
789 * [.updateStorage(options, storage, [cb])](#Webtask+updateStorage) ⇒ <code>Promise</code>
790 * [.getStorage(options, [cb])](#Webtask+getStorage) ⇒ <code>Promise</code>
791
792<a name="new_Webtask_new"></a>
793
794### new Webtask()
795Creates an object representing a Webtask
796
797<a name="Webtask+claims"></a>
798
799### webtask.claims
800**Kind**: instance property of <code>[Webtask](#Webtask)</code>
801**Properties**
802
803| Name | Description |
804| --- | --- |
805| claims | The claims embedded in the Webtask's token |
806
807<a name="Webtask+token"></a>
808
809### webtask.token
810**Kind**: instance property of <code>[Webtask](#Webtask)</code>
811**Properties**
812
813| Name | Description |
814| --- | --- |
815| token | The token associated with this webtask |
816
817<a name="Webtask+sandbox"></a>
818
819### webtask.sandbox
820**Kind**: instance property of <code>[Webtask](#Webtask)</code>
821**Properties**
822
823| Name | Description |
824| --- | --- |
825| sandbox | The {@see Sandbox} instance used to create this Webtask instance |
826
827<a name="Webtask+meta"></a>
828
829### webtask.meta
830**Kind**: instance property of <code>[Webtask](#Webtask)</code>
831**Properties**
832
833| Name | Description |
834| --- | --- |
835| meta | The metadata associated with this webtask |
836
837<a name="Webtask+secrets"></a>
838
839### webtask.secrets
840**Kind**: instance property of <code>[Webtask](#Webtask)</code>
841**Properties**
842
843| Name | Description |
844| --- | --- |
845| secrets | The secrets associated with this webtask if `decrypt=true` |
846
847<a name="Webtask+code"></a>
848
849### webtask.code
850**Kind**: instance property of <code>[Webtask](#Webtask)</code>
851**Properties**
852
853| Name | Description |
854| --- | --- |
855| code | The code associated with this webtask if `fetch_code=true` |
856
857<a name="Webtask+createLogStream"></a>
858
859### webtask.createLogStream(options) ⇒ <code>Stream</code>
860Create a stream of logs from the webtask container
861
862Note that the logs will include messages from our infrastructure.
863
864**Kind**: instance method of <code>[Webtask](#Webtask)</code>
865**Returns**: <code>Stream</code> - A stream that will emit 'data' events with container logs
866
867| Param | Type | Description |
868| --- | --- | --- |
869| options | <code>Object</code> | Streaming options overrides |
870| [options.container] | <code>String</code> | The container for which you would like to stream logs. Defaults to the current profile's container. |
871
872<a name="Webtask+run"></a>
873
874### webtask.run(options, [cb]) ⇒ <code>Promise</code>
875Run the webtask and return the result of execution
876
877**Kind**: instance method of <code>[Webtask](#Webtask)</code>
878**Returns**: <code>Promise</code> - - A Promise that will be resolved with the response from the server.
879
880| Param | Type | Description |
881| --- | --- | --- |
882| options | <code>Object</code> | Options used to tweak how the webtask will be invoked |
883| [cb] | <code>function</code> | Optional node-style callback that will be invoked upon completion |
884
885<a name="Webtask+createCronJob"></a>
886
887### webtask.createCronJob(options, [cb]) ⇒ <code>Promise</code>
888Schedule the webtask to run periodically
889
890**Kind**: instance method of <code>[Webtask](#Webtask)</code>
891**Returns**: <code>Promise</code> - - A Promise that will be resolved with a {@see CronJob} instance.
892
893| Param | Type | Description |
894| --- | --- | --- |
895| options | <code>Object</code> | Options for creating the webtask |
896| options.schedule | <code>Object</code> | Cron-string-formatted schedule |
897| [options.name] | <code>Object</code> | The name for the cron job |
898| [options.tz] | <code>Object</code> | The timezone for the cron job (IANA timezone) |
899| [cb] | <code>function</code> | Optional node-style callback that will be invoked upon completion |
900
901<a name="Webtask+inspect"></a>
902
903### webtask.inspect(options, [cb]) ⇒ <code>Promise</code>
904Inspect an existing webtask to optionally get code and/or secrets
905
906**Kind**: instance method of <code>[Webtask](#Webtask)</code>
907**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the result of inspecting the token.
908
909| Param | Type | Description |
910| --- | --- | --- |
911| options | <code>Object</code> | Options for inspecting the webtask. |
912| [options.decrypt] | <code>Boolean</code> | Decrypt the webtask's secrets. |
913| [options.fetch_code] | <code>Boolean</code> | Fetch the code associated with the webtask. |
914| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
915
916<a name="Webtask+remove"></a>
917
918### webtask.remove([cb]) ⇒ <code>Promise</code>
919Remove the named webtask
920
921**Kind**: instance method of <code>[Webtask](#Webtask)</code>
922**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the result of inspecting the token.
923
924| Param | Type | Description |
925| --- | --- | --- |
926| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
927
928<a name="Webtask+revoke"></a>
929
930### webtask.revoke([cb]) ⇒ <code>Promise</code>
931Revoke the webtask's token
932
933**Kind**: instance method of <code>[Webtask](#Webtask)</code>
934**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the result of revoking the token.
935
936| Param | Type | Description |
937| --- | --- | --- |
938| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
939
940<a name="Webtask+update"></a>
941
942### webtask.update([options], [cb]) ⇒ <code>Promise</code>
943Update a webtask
944
945**Kind**: instance method of <code>[Webtask](#Webtask)</code>
946**Returns**: <code>Promise</code> - A Promise that will be fulfilled with the result of revoking the token.
947
948| Param | Type | Description |
949| --- | --- | --- |
950| [options] | <code>Object</code> | Options for updating a webtask (@see: Sandbox.updateWebtask) |
951| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
952
953<a name="Webtask+updateStorage"></a>
954
955### webtask.updateStorage(options, storage, [cb]) ⇒ <code>Promise</code>
956Update the storage associated to the a webtask
957
958**Kind**: instance method of <code>[Webtask](#Webtask)</code>
959**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
960
961| Param | Type | Description |
962| --- | --- | --- |
963| options | <code>Object</code> | Options |
964| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
965| options.name | <code>String</code> | The name of the webtask. |
966| storage | <code>Object</code> | storage |
967| storage.data | <code>Object</code> | The data to be stored |
968| storage.etag | <code>String</code> | Pass in an optional string to be used for optimistic concurrency control to prevent simultaneous updates of the same data. |
969| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
970
971<a name="Webtask+getStorage"></a>
972
973### webtask.getStorage(options, [cb]) ⇒ <code>Promise</code>
974Read the storage associated to the a webtask
975
976**Kind**: instance method of <code>[Webtask](#Webtask)</code>
977**Returns**: <code>Promise</code> - A Promise that will be fulfilled with an array of Webtasks
978
979| Param | Type | Description |
980| --- | --- | --- |
981| options | <code>Object</code> | Options |
982| [options.container] | <code>String</code> | Set the webtask container. Defaults to the profile's container. |
983| options.name | <code>String</code> | The name of the webtask. |
984| [cb] | <code>function</code> | Optional callback function for node-style callbacks. |
985
986
987## Usages
988
989This library will be used in [wt-cli](https://github.com/auth0/wt-cli).
990
991## Contributing
992
993Just clone the repo, run `npm install` and then hack away.
994
995## Issue reporting
996
997If you have found a bug or if you have a feature request, please report them at
998this repository issues section. Please do not report security vulnerabilities on
999the public GitHub issue tracker. The
1000[Responsible Disclosure Program](https://auth0.com/whitehat) details the
1001procedure for disclosing security issues.
1002
1003## License
1004
1005MIT
1006
1007## What is Auth0?
1008
1009Auth0 helps you to:
1010
1011* Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**.
1012* Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**.
1013* Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user.
1014* Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely.
1015* Analytics of how, when and where users are logging in.
1016* Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules).
1017
1018## Create a free account in Auth0
1019
10201. Go to [Auth0](https://auth0.com) and click Sign Up.
10212. Use Google, GitHub or Microsoft Account to login.