Skip to content

Commit

Permalink
prepare for ver 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
deleolajide committed Aug 2, 2020
1 parent 327223f commit d569903
Show file tree
Hide file tree
Showing 24 changed files with 772 additions and 565 deletions.
2 changes: 1 addition & 1 deletion config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.igniterealtime.openfire.ofmeet</groupId>
<artifactId>parent</artifactId>
<version>0.9.13-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>config</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion offocus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.igniterealtime.openfire.ofmeet</groupId>
<artifactId>parent</artifactId>
<version>0.9.13-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>offocus</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ofgasi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.igniterealtime.openfire.ofmeet</groupId>
<artifactId>parent</artifactId>
<version>0.9.13-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>ofgasi</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ofmeet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.igniterealtime.openfire.ofmeet</groupId>
<artifactId>parent</artifactId>
<version>0.9.13-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>ofmeet</artifactId>
Expand Down
4 changes: 3 additions & 1 deletion pade/classes/public/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@

<h1 id="changelog">Changelog</h1>

<p><b>1.6.8</b> -- <i>July ??, 2020</i></p>
<p><b>1.6.8</b> -- <i>July 31, 2020</i></p>
<ul>
<li>Added Meet now button to Converse for direct access to Openfire Meetings</li>
<li><a href="https://github.com/igniterealtime/pade/issues/231">Fixed #231: Building custom chrom extension / problem with setting ofmeetUrl in branding.js</a></li>
</ul>

<p><b>1.6.7</b> -- <i>June 28, 2020</i></p>
Expand Down
10 changes: 9 additions & 1 deletion pade/classes/public/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ function getCredentials(username, password, callback)
navigator.credentials.get({password: true, federated: {providers: [ 'https://accounts.google.com' ]}}).then(function(credential)
{
console.log("credential management api get", credential);
if (callback) callback(credential || {err: !credential, id: username, password: password, anonymous: !password});
const creds = {err: !credential, id: username, password: password, anonymous: !password};

if (credential)
{
creds.id = credential.id.split("@")[0];
creds.password = credential.password;
}

if (callback) callback(creds);

}).catch(function(err){
console.error ("credential management api get error", err);
Expand Down
6 changes: 0 additions & 6 deletions pade/classes/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@

<script src="inverse/chrome.js"></script>
<script src="options/branding.js"></script>
<script src="js/jquery.js"></script>
<script src="js/libs.bundle.js"></script>
<script src="js/strophe.vcard.js"></script>
<script src="js/moment.js"></script>
<script src="js/sip.js"></script>
<script src="js/etherlynk.js"></script>
<script src="js/background.js"></script>
<script src="credentials.js"></script>
<script src="index.js"></script>
Expand Down
153 changes: 0 additions & 153 deletions pade/classes/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,156 +9,3 @@ window.addEventListener("load", function()
document.title = chrome.i18n.getMessage('manifest_shortExtensionName') + " | " + chrome.runtime.getManifest().version;
});

var webpush = (function(push)
{
var hostname, username, password, publicKey;

function vapidGetPublicKey(host, user, pass)
{
var getUrl = "https://" + host + "/rest/api/restapi/v1/meet/webpush/" + user;
var options = {method: "GET", headers: {"Authorization": "Basic " + btoa(user + ":" + pass), "Accept":"application/json", "Content-Type":"application/json"}};

console.debug("vapidGetPublicKey", getUrl, options);

fetch(getUrl, options).then(function(response) {return response.json()}).then(function(vapid)
{
if (vapid.publicKey)
{
console.debug("vapidGetPublicKey found", vapid);

publicKey = vapid.publicKey;
hostname = host;
username = user;
password = pass;

navigator.serviceWorker.register('./serviceworker.js', {scope: './'}).then(initialiseState, initialiseError);
} else {
console.error("no web push, vapid public key not available");
}

}).catch(function (err) {
console.error('vapidGetPublicKey error!', err);
});
}

function initialiseError(error)
{
console.error("initialiseError", error);
}

function initialiseState(registration)
{
if (!('showNotification' in ServiceWorkerRegistration.prototype)) {
console.warn('Notifications aren\'t supported.');
return;
}

if (Notification.permission === 'denied') {
console.warn('The user has blocked notifications.');
return;
}

if (!('PushManager' in window)) {
console.warn('Push messaging isn\'t supported.');
return;
}

console.debug("initialiseState", registration);

navigator.serviceWorker.ready.then(function (serviceWorkerRegistration)
{
console.debug("initialiseState ready", serviceWorkerRegistration);

serviceWorkerRegistration.pushManager.getSubscription().then(function (subscription)
{
console.debug("serviceWorkerRegistration getSubscription", subscription);

if (!subscription && publicKey) {
subscribe();
return;
}

// Keep your server in sync with the latest subscriptionId
sendSubscriptionToServer(subscription);
})
.catch(function(err) {
console.warn('Error during getSubscription()', err);
});
});
}

function subscribe()
{
console.debug("subscribe", publicKey);

navigator.serviceWorker.ready.then(function (serviceWorkerRegistration)
{
serviceWorkerRegistration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: base64UrlToUint8Array(publicKey)
})
.then(function (subscription) {
return sendSubscriptionToServer(subscription);
})
.catch(function (e) {
if (Notification.permission === 'denied') {
console.warn('Permission for Notifications was denied');
} else {
console.error('Unable to subscribe to push.', e);
}
});
});
}

function base64UrlToUint8Array(base64UrlData)
{
const padding = '='.repeat((4 - base64UrlData.length % 4) % 4);
const base64 = (base64UrlData + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');

const rawData = atob(base64);
const buffer = new Uint8Array(rawData.length);

for (let i = 0; i < rawData.length; ++i) {
buffer[i] = rawData.charCodeAt(i);
}

return buffer;
}

function sendSubscriptionToServer(subscription)
{
console.debug("sendSubscriptionToServer", subscription);

var key = subscription.getKey ? subscription.getKey('p256dh') : '';
var auth = subscription.getKey ? subscription.getKey('auth') : '';

var subscriptionString = JSON.stringify(subscription); // TODO

console.debug("web push subscription", {
endpoint: subscription.endpoint,
key: key ? btoa(String.fromCharCode.apply(null, new Uint8Array(key))) : '',
auth: auth ? btoa(String.fromCharCode.apply(null, new Uint8Array(auth))) : ''
}, subscription);

var resource = chrome.i18n.getMessage('manifest_shortExtensionName').toLowerCase() + "-" + BrowserDetect.browser + BrowserDetect.version + BrowserDetect.OS;
var putUrl = "https://" + hostname + "/rest/api/restapi/v1/meet/webpush/" + username + "/" + resource;
var options = {method: "PUT", body: JSON.stringify(subscription), headers: {"Authorization": "Basic " + btoa(username + ":" + password), "Accept":"application/json", "Content-Type":"application/json"}};

return fetch(putUrl, options).then(function(response) {
console.debug("subscribe response", response);

}).catch(function (err) {
console.error('subscribe error!', err);
});
}

push.registerServiceWorker = function(host, username, password)
{
vapidGetPublicKey(host, username, password);
}

return push;

}(webpush || {}));
9 changes: 0 additions & 9 deletions pade/classes/public/inverse/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,6 @@ function getSetting(name, defaultValue)
{
var localStorage = window.localStorage
//console.debug("getSetting", name, defaultValue, localStorage["store.settings." + name]);

if (window.pade)
{
if (name == "username") return window.pade.username;
if (name == "password") return window.pade.password;
if (name == "domain") return window.pade.domain;
if (name == "server") return window.pade.server;
}

var value = defaultValue;

if (localStorage["store.settings." + name])
Expand Down
2 changes: 1 addition & 1 deletion pade/classes/public/inverse/dist/converse.js
Original file line number Diff line number Diff line change
Expand Up @@ -73105,7 +73105,7 @@ converse.plugins.add('converse-emoji-views', {
return;
}

if (!_converse.emojipicker) {
if (!_converse.emojipicker && _converse.emojis.json) {
_converse.emojis.json.recent = {}; // BAO
const id = "converse.emoji-".concat(_converse.bare_jid);
_converse.emojipicker = new _converse.EmojiPicker({
Expand Down
1 change: 1 addition & 0 deletions pade/classes/public/inverse/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script src="plugins/themes.js"></script>
<script src="dist/libsignal-protocol.js"></script>
<script src="dist/converse.js"></script>
<script src="webpush.js"></script>
<script src="index.js"></script>

</head>
Expand Down
Loading

0 comments on commit d569903

Please sign in to comment.