Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
68
gaia/dev_apps/uitest-privileged/js/API/mobileid.js
Executable file
68
gaia/dev_apps/uitest-privileged/js/API/mobileid.js
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict';
|
||||
|
||||
var MobileId = {
|
||||
init: function() {
|
||||
this.clearButton = document.getElementById('clear-button');
|
||||
this.clearButton.classList.add('hidden');
|
||||
this.clearButton.addEventListener('click', this.onClear.bind(this));
|
||||
|
||||
this.getAssertionButton = document.getElementById('get-assertion-button');
|
||||
this.getAssertionButton.addEventListener('click', (function() {
|
||||
navigator.getMobileIdAssertion().then(
|
||||
this.onAssertion.bind(this),
|
||||
this.onError.bind(this)
|
||||
);
|
||||
}).bind(this));
|
||||
|
||||
this.forceSelectionButton = document.getElementById('force-selection-button');
|
||||
this.forceSelectionButton.addEventListener('click', (function() {
|
||||
navigator.getMobileIdAssertion({
|
||||
forceSelection: true
|
||||
}).then(
|
||||
this.onAssertion.bind(this),
|
||||
this.onError.bind(this)
|
||||
);
|
||||
}).bind(this));
|
||||
|
||||
this.assertionPlaceholder = document.getElementById('assertion-placeholder');
|
||||
this.assertionContainer = document.getElementById('assertion-container');
|
||||
|
||||
this.errorPlaceholder = document.getElementById('error-placeholder');
|
||||
this.errorContainer = document.getElementById('error-container');
|
||||
},
|
||||
|
||||
onAssertion: function(aAssertion) {
|
||||
var segments = aAssertion.split('.');
|
||||
|
||||
var decoded = JSON.parse(atob(segments[1].replace(/-/g, '+')
|
||||
.replace(/_/g, '/')));
|
||||
if (!decoded || !decoded.verifiedMSISDN) {
|
||||
this.onError('Invalid assertion :(');
|
||||
return;
|
||||
}
|
||||
this.assertionContainer.classList.remove('hidden');
|
||||
this.assertionPlaceholder.textContent = 'Verified phone number ' +
|
||||
decoded.verifiedMSISDN;
|
||||
this.clearButton.classList.remove('hidden');
|
||||
},
|
||||
|
||||
onError: function(aError) {
|
||||
console.error('ERROR ' + aError.name || aError);
|
||||
this.errorContainer.classList.remove('hidden');
|
||||
this.errorPlaceholder.textContent = aError.name;
|
||||
this.clearButton.classList.remove('hidden');
|
||||
},
|
||||
|
||||
onClear: function() {
|
||||
this.assertionPlaceholder.textContent = '';
|
||||
this.assertionContainer.classList.add('hidden');
|
||||
this.errorPlaceholder.textContent = '';
|
||||
this.errorContainer.classList.add('hidden');
|
||||
this.clearButton.classList.add('hidden');
|
||||
},
|
||||
};
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function onload() {
|
||||
window.removeEventListener('DOMContentLoaded', onload);
|
||||
MobileId.init();
|
||||
});
|
||||
Loading…
Reference in a new issue