Permalink
Browse files

rename browserid to persona

  • Loading branch information...
1 parent 15db2db commit 04ff5e2b68c94e7070a71b6e48da3da226f4e318 @jchris jchris committed Mar 22, 2013
View
@@ -1,8 +1,8 @@
-## Mozilla Persona (aka BrowserID) and PhoneGap / Cordova, together at last.
+## Mozilla Persona (aka Persona) and PhoneGap / Cordova, together at last.
This plugin is a reasonably non-dirty workaround to [the existing issues with browserid and PhoneGap](https://github.com/mozilla/browserid/issues/2034).
-It includes code from the [Couchbase fork of the Mozilla iOS BrowserID SDK](https://github.com/couchbaselabs/browserid-ios).
+It includes code from the [Couchbase fork of the Mozilla iOS Persona SDK](https://github.com/couchbaselabs/browserid-ios).
The gist is that rather than trying to work with the PhoneGap web view, or the ChildBrowser plugin, or the system browser, instead it just brute forces a new webview, just like you would do if you were a native app.
@@ -11,6 +11,3 @@ To install, use [plugman](https://github.com/imhotep/plugman) and run it like th
plugman --debug --platform ios --project $MYPRJOJECT --plugin git://github.com/couchbaselabs/cordova-browserid.git
Sorry, only iOS support for now. Happy to accept pull reqs for Android.
-
-
-
View
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
- id="com.couchbase.browserid"
+ id="com.couchbase.persona"
version="0.1.0">
- <name>CordovaBrowserId</name>
- <asset src="www/cordova-browserid.js" />
+ <name>CordovaPersona</name>
+ <asset src="www/cordova-persona.js" />
<platform name="ios">
<config-file target="config.xml" parent="/cordova/plugins">
- <plugin name="CBCordovaBrowserId" value="CBCordovaBrowserId"/>
+ <plugin name="CBCordovaPersona" value="CBCordovaPersona"/>
</config-file>
- <header-file src="CBCordovaBrowserId.h" />
- <source-file src="CBCordovaBrowserId.m" />
+ <header-file src="CBCordovaPersona.h" />
+ <source-file src="CBCordovaPersona.m" />
- <header-file src="../../vendor/browserid-ios/Sources/BrowserIDController.h" />
- <source-file src="../../vendor/browserid-ios/Sources/BrowserIDController.m" />
+ <header-file src="../../vendor/browserid-ios/Sources/PersonaController.h" />
+ <source-file src="../../vendor/browserid-ios/Sources/PersonaController.m" />
- <resource-file src="../../vendor/browserid-ios/Sources/BrowserIDController.js" />
+ <resource-file src="../../vendor/browserid-ios/Sources/PersonaController.js" />
- <header-file src="../../vendor/browserid-ios/Sources/BrowserIDController+UIKit.h" />
- <source-file src="../../vendor/browserid-ios/Sources/BrowserIDController+UIKit.m" />
+ <header-file src="../../vendor/browserid-ios/Sources/PersonaController+UIKit.h" />
+ <source-file src="../../vendor/browserid-ios/Sources/PersonaController+UIKit.m" />
</platform>
@@ -1,10 +1,10 @@
#import <Cordova/CDV.h>
-#import "BrowserIDController+UIKit.h"
+#import "PersonaController+UIKit.h"
-@interface CBCordovaBrowserId : CDVPlugin <BrowserIDControllerDelegate>
+@interface CBCordovaPersona : CDVPlugin <PersonaControllerDelegate>
@property (nonatomic, strong) CDVInvokedUrlCommand *command;
-- (void)presentBrowserIdDialog:(CDVInvokedUrlCommand*)urlCommand;
+- (void)presentPersonaDialog:(CDVInvokedUrlCommand*)urlCommand;
@end
@@ -1,7 +1,7 @@
-#import "CBCordovaBrowserId.h"
+#import "CBCordovaPersona.h"
#import <Cordova/CDV.h>
-@implementation CBCordovaBrowserId
+@implementation CBCordovaPersona
@synthesize command;
@@ -14,49 +14,49 @@ - (id) initWithWebView:(UIWebView*)theWebView
return self;
}
-- (void)presentBrowserIdDialog:(CDVInvokedUrlCommand*)urlCommand
+- (void)presentPersonaDialog:(CDVInvokedUrlCommand*)urlCommand
{
if (self.command != nil) {
- [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"There is already a browserid call in progress"] callbackId:urlCommand.callbackId];
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"There is already a Persona call in progress"] callbackId:urlCommand.callbackId];
return;
}
self.command = urlCommand;
// present modal controller, set us as the delegate
- BrowserIDController* browserIDController = [[BrowserIDController alloc] init];
- browserIDController.origin = [NSURL URLWithString:[urlCommand.arguments objectAtIndex:0]];
- browserIDController.delegate = self;
+ PersonaController* personaController = [[PersonaController alloc] init];
+ personaController.origin = [NSURL URLWithString:[urlCommand.arguments objectAtIndex:0]];
+ personaController.delegate = self;
id rootVC = [[[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0] nextResponder];
- [browserIDController presentModalInController: rootVC];
+ [personaController presentModalInController: rootVC];
}
-- (void) dismissBrowserIDController: (BrowserIDController*) browserIDController {
- [browserIDController.viewController dismissViewControllerAnimated: YES completion: NULL];
+- (void) dismissPersonaController: (PersonaController*) personaController {
+ [personaController.viewController dismissViewControllerAnimated: YES completion: NULL];
}
-- (void) browserIDControllerDidCancel: (BrowserIDController*) browserIDController {
- [self dismissBrowserIDController: browserIDController];
+- (void) personaControllerDidCancel: (PersonaController*) personaController {
+ [self dismissPersonaController: personaController];
// send error back to javascript
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"canceled"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.command.callbackId];
self.command = nil;
}
-- (void) browserIDController: (BrowserIDController*) browserIDController
+- (void) personaController: (PersonaController*) personaController
didFailWithReason: (NSString*) reason
{
- [self dismissBrowserIDController: browserIDController];
+ [self dismissPersonaController: personaController];
// send error back to javascript
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:reason];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.command.callbackId];
self.command = nil;
}
-- (void) browserIDController: (BrowserIDController*) browserIDController
+- (void) personaController: (PersonaController*) personaController
didSucceedWithAssertion: (NSString*) assertion
{
- [self dismissBrowserIDController: browserIDController];
+ [self dismissPersonaController: personaController];
// send assertion back to javascript
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:assertion];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.command.callbackId];
@@ -4,7 +4,7 @@ window.onload = function()
{
// The origin is setup when this code template is loaded in the native application
var origin = "%@";
-
+
var callbackToCocoa = function(name, value) {
window.location = "personaViewController://" + name + "/callback?data=" + value;
};
@@ -29,8 +29,8 @@ window.onload = function()
var options = {};
// Doomed attempt to future-proof against internal changes Mozilla may or may not make to dialog.js
- if (BrowserID && BrowserID.internal) {
- BrowserID.internal.get(origin, internalGetCallback, options);
+ if (Persona && Persona.internal) {
+ Persona.internal.get(origin, internalGetCallback, options);
} else if (Persona && Persona.internal) {
Persona.internal.get(origin, internalGetCallback, options);
}
@@ -1,8 +1,8 @@
-window.presentBrowserIdDialog = function(origin, callback) {
+window.presentPersonaDialog = function(origin, callback) {
// use node.js style error reporting (first argument)
cordova.exec(function(assertion){
callback(false, assertion);
}, function(err) {
callback(err);
- }, "CBCordovaBrowserId", "presentBrowserIdDialog", [origin]);
+ }, "CBCordovaPersona", "presentPersonaDialog", [origin]);
};

0 comments on commit 04ff5e2

Please sign in to comment.