Skip to content

Commit

Permalink
Update SDK API
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Varache committed Jan 29, 2016
1 parent ad986e3 commit d378339
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 15 deletions.
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,51 @@ KW_SDK.init(function (err) {

KW_SDK.appStorage.set('my-app-name', { level: 1 }, function (err) {
if (err) { throw err; }

// Data stored on your profile stats

KW_SDK.appStorage.get('my-app-name', function (err, data) {
if (err) { throw err; }

console.log(data);
// { level: 1 }
});
});
});
```
```

### Custom Elements

You can register custom elements for login/register forms. These forms will take care of the field validation and authentication
and trigger events to notify when login/register/errors occurs.

You can register these elements like so:

```js
KW_SDK.registerForms();
```

You will then be able to use them in your HTML pages.

Available elements:

#### kano-login-form
Display a complete login form.
Usage:
```html
<kano-login-form></kano-login-form>
```
Events:
- success: The authentication process succeeded. (Will contain the session in the `details` attribute)
- error: The authentication process failed.


#### kano-register-form
Display a complete register form.
Usage:
```html
<kano-register-form></kano-register-form>
```
Events:
- success: The authentication process succeeded. (Will contain the session in the `details` attribute)
- error: The authentication process failed.
4 changes: 2 additions & 2 deletions lib/core/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (config) {
return token || localStorage.KW_TOKEN;
},

login: function (token) {
auth.setToken(token);
login: function () {
location.href = config.WORLD_URL + '/external/login?redirect_url=' + location.href;
},

logout: function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/kano-register/kano-email-field.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var xtag = window.xtag;
var xtag = require('x-tag');

module.exports = function () {
xtag.register('kano-email-field', {
Expand Down
2 changes: 1 addition & 1 deletion lib/kano-register/kano-login-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var xtag = window.xtag;
var xtag = require('x-tag');

module.exports = function (api, config) {
xtag.register('kano-login-form', {
Expand Down
2 changes: 1 addition & 1 deletion lib/kano-register/kano-password-field.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var xtag = window.xtag;
var xtag = require('x-tag');

module.exports = function () {
// password field component
Expand Down
2 changes: 1 addition & 1 deletion lib/kano-register/kano-signup-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var xtag = window.xtag;
var xtag = require('x-tag');

module.exports = function (api) {
//whole form component
Expand Down
2 changes: 1 addition & 1 deletion lib/kano-register/kano-tc-check.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var xtag = window.xtag;
var xtag = require('x-tag');

module.exports = function (api, config) {
xtag.register('kano-tc-check', {
Expand Down
2 changes: 1 addition & 1 deletion lib/kano-register/kano-username-field.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var generateUsername = require('../util/mixed').getSimpleCombination,
xtag = window.xtag;
xtag = require('x-tag');

module.exports = function (api) {
// username field component
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kano-world-sdk",
"version": "2.1.2",
"version": "3.0.0",
"description": "Kano World SDK",
"main": "lib/index.js",
"scripts": {
Expand All @@ -12,8 +12,9 @@
"dependencies": {
"api-service": "^1.0.0",
"browserify": "^6.3.3",
"watchify": "^2.1.1",
"haikunator": "^1.0.1",
"request-promise": "^0.4.3"
"request-promise": "^0.4.3",
"watchify": "^2.1.1",
"x-tag": "^1.5.6"
}
}

0 comments on commit d378339

Please sign in to comment.