Definition file for Persona

This commit is contained in:
Nycto
2013-08-04 10:52:13 -07:00
parent 2089d27c7f
commit e10beb2077
3 changed files with 96 additions and 0 deletions
+1
View File
@@ -145,6 +145,7 @@ List of Definitions
* [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown))
* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov))
* [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/))
* [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto))
* [PhantomJS](http://phantomjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker))
* [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov))
* [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH))
+48
View File
@@ -0,0 +1,48 @@
/// <reference path="persona.d.ts" />
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.watch
navigator.id.watch({
loggedInUser: 'bob@example.org',
onlogin: function(assertion: String) {},
onlogout: function() {}
});
navigator.id.watch({
loggedInUser: 'bob@example.org',
onlogin: function(assertion: String) {},
onlogout: function() {},
onready: function() {}
});
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.request
navigator.id.request();
navigator.id.request({siteName: 'Example Site', siteLogo: '/logo.png'});
navigator.id.request({termsOfService: '/tos.html', privacyPolicy: '/privacy.html'});
navigator.id.request({
backgroundColor: '#rrggbb',
siteName: 'My Example Site',
siteLogo: '/logo.png',
termsOfService: '/tos.html',
privacyPolicy: '/privacy.html',
returnTo: '/welcome.html',
oncancel: function() {}
});
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.logout
navigator.id.logout();
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.get
var gotAssertion = function ( assertion: String ) {}
navigator.id.get(gotAssertion);
navigator.id.get(gotAssertion, {privacyPolicy: "/privacy.html", termsOfService: "/tos.html"});
navigator.id.get(gotAssertion, {
backgroundColor: '#rrggbb',
siteName: 'My Example Site',
siteLogo: '/logo.png',
termsOfService: '/tos.html',
privacyPolicy: '/privacy.html'
});
+47
View File
@@ -0,0 +1,47 @@
// Type definitions for Persona
// Project: http://www.mozilla.org/en-US/persona
// Definitions by: James Frasca <https://github.com/Nycto>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Persona {
export interface WatchOptions {
loggedInUser: String
onlogin: (String) => void
onlogout: () => void
onready?: () => void
}
export interface RequestOptions {
backgroundColor?: String
siteName?: String
siteLogo?: String
termsOfService?: String
privacyPolicy?: String
returnTo?: String
oncancel?: () => void
}
export interface GetOptions {
backgroundColor?: String
siteName?: String
siteLogo?: String
termsOfService?: String
privacyPolicy?: String
}
export interface Persona {
watch( options: WatchOptions ): void
request( options: RequestOptions ): void
request(): void
logout(): void
get( gotAssertion: (String) => void ): void
get( gotAssertion: (String) => void, options: GetOptions ): void
}
}
interface Navigator {
id: Persona.Persona
}