I’m learning how to use the integrated authenticator, having compiled the dev
branch of safe browser and following the example of MaidSafe’s web hosting manager.
Running safe browser binary for Windows.
Problem number one
The first two times I ran web hosting manager
I was able to see the auth pop-up within the authentication manager, but no longer.
Problem number two
The app that I’m building (simply meant to upload my website to mock routing), following the example, also uses shell.openExternal(...
, which will get my open authentication management page to come to the fore but I’ve haven’t been able to get the the pop-up to appear.
let shell = require('electron').shell;
let safeApp = require('safe-app');
const appInfo = {
'id': 'net.safe.upload.mock',
'name': 'Host Website',
'vendor': 'hunterlester'
}
const containers = {
_public: [
'Read',
'Insert',
'Update',
'Delete',
'ManagePermissions'
],
_publicNames: [
'Read',
'Insert',
'Update',
'Delete',
'ManagePermissions'
]
};
const parseUrl = (url) => (
(url.indexOf('safe-auth://') === -1) ? url.replace('safe-auth:', 'safe-auth://') : url
);
safeApp.initializeApp(appInfo).then(app => app.auth.genAuthUri(containers, {own_container: true}).then(uri => {
shell.openExternal(parseUrl(uri.uri))
}))
These two problems appear to be separate issues, but I’m not sure.
My research:
I’m wondering how the auth pop-up receives an event signal to show itself.
In safe_browser\app\shell-window\ui\navbar.js
:
ipcRenderer.on('onAuthReq', function(event, data) {
if (data) {
safeAuthData = data
showSafeAuthPopup()
}
});
The onAuthReq
event is called from safe_browser\authenticator\src\protocols\safe_auth_rpc.js
:
const registerOnAuthReq = (event) => {
clientManager.setAuthReqListener((req) => {
event.sender.send('onAuthReq', req);
});
};
In the same file, the event listener ipcMain.on('registerOnAuthReq', registerOnAuthReq);
is set.
Back in safe_browser\app\shell-window\ui\navbar.js
, an event is sent on the registerOnAuthReq
channel:
ipcRenderer.send('registerOnAuthReq');
This is where the trail goes cold for me. I can’t find from where else the onAuthReq
event is signaled.
I also can’t figure out why the pop-up no longer shows up for web hosting manager
.
Gratitude
Thank you to the developers that created the web hosting manager
example, safe browser, the plugin integrations, and the core files. I won’t name you all here because I don’t want to leave any contributors out.
Something to be celebrated at this point is that you all have created a code base that is so clear and easy to read that I, as a novice programmer, can follow along to get a sense of how it works and to also receive education from it.
@dirvine, you’ve achieved what you wanted as far as making the code base accessible and easy to understand.
Learning so much. Thank you.