auth0/webtask-widget

Name: webtask-widget

Owner: Auth0

Description: [BETA] Widget that can be embedded in websites to allow transparent creation of extension points or urls.

Created: 2015-09-18 15:37:10.0

Updated: 2018-01-31 20:12:43.0

Pushed: 2017-04-18 16:18:35.0

Homepage:

Size: 6964

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Auth0 Webtask Widget

Usage
et a reference to an existing HTMLElement instance
containerEl = document.getElementById('container');

reate a webtask widget in the element with id `container`.
he webtask widget will prompt the user for their phone # or email address
he first time they visit the page. Because `storeProfile` is enabled,
he user's credentials will be saved locally for the next time they visit.
editor = webtaskWidget.createEditor({
mount: containerEl,
storeProfile: true,


he returned editor object is an instance of an A0EditorWidget class that 
mits certain events and gives programmatic access to some of the underlying
unctionality of the widget.
or.on('save', function (webtask) {
console.log('I just saved a webtask that can be accessed at', webtask.url);

API
Functions
showCronListing([options])

Create a widget that lists cron jobs associated with the active profile

showEditor([options])

Create a widget that lets users create or edit Webtasks and Cron Jobs

showLogin([options])

Create a widget that allows users to obtain Sandbox credentials

showLogs([options])

Create a widget that streams logs for a container

showCronListing([options])

Create a widget that lists cron jobs associated with the active profile

Kind: global function

| Param | Type | Description | | — | — | — | | [options] | Object | Customize the behaviour and appearance of the widget | | [options.mount] | HTMLElement | Indicate where the widget should be mounted. If not specified the widget will be shown as a modal dialog. | | [options.url] | String | The url of the Webtask cluster to be used. Defaults to https://webtask.it.auth0.com. | | [options.token] | String | The webtask token of the current user. If missing, and no {@see options.readProfile} profided, the SMS/email login flow will be triggered. | | [options.container] | String | The webtask container of the current user. If missing, will be derived from {@see options.token}, from the result of {@see options.readProfile}, or finally from the result of the SMS/email login flow. | | [options.readProfile] | function | A function that should return a Object or a Promise for an object with url, token and container properties. | | [options.writeProfile] | function | A function that will be called with the resolved Profile that should return a Promise that resolves once the profile has been written. | | [options.storageKey] | function | A key that will be used by localStorage to read/write the resolved Profile when you do not use pass in custom {@see options.readProfile} and {@see options.writeProfile} functions. |

showEditor([options])

Create a widget that lets users create or edit Webtasks and Cron Jobs

Kind: global function

| Param | Type | Description | | — | — | — | | [options] | Object | Customize the behaviour and appearance of the widget | | [options.mount] | HTMLElement | Indicate where the widget should be mounted. If not specified the widget will be shown as a modal dialog. | | [options.url] | String | The url of the Webtask cluster to be used. Defaults to https://webtask.it.auth0.com. | | [options.token] | String | The webtask token of the current user. If missing, and no {@see options.readProfile} profided, the SMS/email login flow will be triggered. | | [options.container] | String | The webtask container of the current user. If missing, will be derived from {@see options.token}, from the result of {@see options.readProfile}, or finally from the result of the SMS/email login flow. | | [options.code] | String | Initial code to be shown in the code editor of the widget. This will be ignored when the edit option is used. | | [options.cron] | Boolean | Flag indicating whether the widget should be in cron or normal webtask mode. If cron is true and edit is a String then the value of edit will be taken as the name of a cron job instead of a simple webtask. | | [options.edit] | String | The name of the webtask or cron job that you would like to edit. Can also be a sandboxjs CronJob or Webtask instance. | | [options.name] | String | The default name for a new webtask or cron job. This will be ignored when the edit option is used. | | [options.pane] | String | The name of the sidebar pane to show by default. Can be any of: code, history, logs, schedule, secrets, settings | | [options.secrets] | Object | Object mapping secret keys to secret values that will be exposed via the webtask token secrets mechanism. This will be ignored when the edit option is used. | | [options.readProfile] | function | A function that should return a Object or a Promise for an object with url, token and container properties. | | [options.writeProfile] | function | A function that will be called with the resolved Profile that should return a Promise that resolves once the profile has been written. | | [options.storageKey] | function | A key that will be used by localStorage to read/write the resolved Profile when you do not use pass in custom {@see options.readProfile} and {@see options.writeProfile} functions. |

showLogin([options])

Create a widget that allows users to obtain Sandbox credentials

Kind: global function

| Param | Type | Description | | — | — | — | | [options] | Object | Customize the behaviour and appearance of the widget | | [options.mount] | HTMLElement | Indicate where the widget should be mounted. If not specified the widget will be shown as a modal dialog. | | [options.url] | String | The url of the Webtask cluster to be used. Defaults to https://webtask.it.auth0.com. | | [options.token] | String | The webtask token of the current user. If missing, and no {@see options.readProfile} profided, the SMS/email login flow will be triggered. | | [options.container] | String | The webtask container of the current user. If missing, will be derived from {@see options.token}, from the result of {@see options.readProfile}, or finally from the result of the SMS/email login flow. |

showLogs([options])

Create a widget that streams logs for a container

Kind: global function

| Param | Type | Description | | — | — | — | | [options] | Object | Customize the behaviour and appearance of the widget | | [options.mount] | HTMLElement | Indicate where the widget should be mounted. If not specified the widget will be shown as a modal dialog. | | [options.url] | String | The url of the Webtask cluster to be used. Defaults to https://webtask.it.auth0.com. | | [options.token] | String | The webtask token of the current user. If missing, and no {@see options.readProfile} profided, the SMS/email login flow will be triggered. | | [options.container] | String | The webtask container of the current user. If missing, will be derived from {@see options.token}, from the result of {@see options.readProfile}, or finally from the result of the SMS/email login flow. | | [options.readProfile] | function | A function that should return a Object or a Promise for an object with url, token and container properties. | | [options.writeProfile] | function | A function that will be called with the resolved Profile that should return a Promise that resolves once the profile has been written. | | [options.storageKey] | function | A key that will be used by localStorage to read/write the resolved Profile when you do not use pass in custom {@see options.readProfile} and {@see options.writeProfile} functions. |

Build
Development workflow
clone git@github.com:auth0/auth0-webtask-widget.git
uth0-webtask-widget
install
run develop

This starts webpack-dev-server at http://localhost:8080. The script will watch all dependencies and recompile on changes. Everything is served from memory with source-maps.

Production build
run build

This creates builds in the ./dist folder.

Two builds are created:

  1. webtask.js - Production bundle.
  2. webtask.min.js - Development bundle.
Concepts
Profile

A profile represents a user's claim to create and run webtasks on a webtask cluster as defined by sandboxjs:

Profiles are the combination of:

  1. url - The url of the webtask cluster
  2. container - The container in which the webtask will be run
  3. token - The user's webtask Token
Token

A webtask token is a JSON Web Token that encodes a user's claims to perform actions on a webtask cluster. See: the webtask documentation for details on how this works.

Webtask

A webtask is a claim to run code at a url where that code will have access to any secrets embedded in the webtask. Webtask objects expose several properties and methods.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.