From e10beb2077862dda63219743174fede93410560c Mon Sep 17 00:00:00 2001 From: Nycto Date: Sun, 4 Aug 2013 10:52:13 -0700 Subject: [PATCH] Definition file for Persona --- README.md | 1 + persona/persona-tests.ts | 48 ++++++++++++++++++++++++++++++++++++++++ persona/persona.d.ts | 47 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 persona/persona-tests.ts create mode 100644 persona/persona.d.ts diff --git a/README.md b/README.md index 2db6bb1c3..cfee3871a 100755 --- a/README.md +++ b/README.md @@ -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)) diff --git a/persona/persona-tests.ts b/persona/persona-tests.ts new file mode 100644 index 000000000..1a62f1bc2 --- /dev/null +++ b/persona/persona-tests.ts @@ -0,0 +1,48 @@ +/// + + +// 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' +}); + diff --git a/persona/persona.d.ts b/persona/persona.d.ts new file mode 100644 index 000000000..0e9dc15e3 --- /dev/null +++ b/persona/persona.d.ts @@ -0,0 +1,47 @@ +// Type definitions for Persona +// Project: http://www.mozilla.org/en-US/persona +// Definitions by: James Frasca +// 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 +} +