Skip to content

Commit

Permalink
attempts to connect to localhost:8080 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmcgaw committed Mar 1, 2023
1 parent b63a58f commit 530d062
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
12 changes: 11 additions & 1 deletion capacitor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
"appName": "LeapChat",
"webDir": "build",
"bundledWebRuntime": false,
"plugins": {
"CapacitorHttp": {
"enabled": true
}
},
"server": {
"hostname": "localhost:8080"
"cleartext": "true",
"allowNavigation": [
"192.168.1.247:8080/*",
"localhost:8080/*",
"leapchat.org/*"
]
}
}
1 change: 1 addition & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func ProductionServer(srv *http.Server, httpsAddr, domain string, manager *autoc

func Login(m *miniware.Mapper, pgClient *PGClient) func(w http.ResponseWriter, req *http.Request) {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
//w.Header().Set("Access-Control-Allow-Origin", "*")
mID, keypair, err := parseMinilockID(req)
if err != nil {
WriteErrorStatus(w, "Error: invalid miniLock ID",
Expand Down
1 change: 0 additions & 1 deletion src/store/epics/chatEpics.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ const ownUserStatusEpic = (action$, store) =>
.map(() => userStatusSent())
)
.catch(error => {
console.error(error);
return Observable.of(alertWarning('Error sending user status.'));
});

Expand Down
1 change: 0 additions & 1 deletion src/utils/miniLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ miniLock.crypto.decryptFile = function (
);
miniLock.file.read(file, 12, headerLength + 12, function (header) {
try {
alert(header.data);
header = nacl.util.encodeUTF8(header.data);
header = JSON.parse(header);
}
Expand Down
34 changes: 25 additions & 9 deletions src/utils/sessions.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
import { getEmail, getPassphrase } from '../utils/encrypter';
import miniLock from '../utils/miniLock';
import { Capacitor } from '@capacitor/core';
import { CapacitorHttp } from '@capacitor/core';

// TODO: will be different host from a mobile device, probably if (!window)
const authUrl = `${window.location.origin}/api/login`;
let authUrl = `${window.location.origin}/api/login`;

if (Capacitor.isNativePlatform()){
authUrl = "http://192.168.1.247:8080/api/login";
}

async function connectWithAuthRequest(initiateConnection, mID, secretKey, isNewPassphrase) {
alert(authUrl);
const response = await fetch(authUrl, {
method: "GET",
headers: {
'X-Minilock-Id': mID
}
});

async function connectWithAuthRequest(initiateConnection, mID, secretKey, isNewPassphrase) {
let response;
if (Capacitor.isNativePlatform()){
response = await CapacitorHttp.request({
url: authUrl,
headers: {
'X-Minilock-Id': mID
},
method: 'GET'
});
} else {
response = await fetch(authUrl, {
method: "GET",
headers: {
'X-Minilock-Id': mID
}
});
}

const message = await response.blob();
miniLock.crypto.decryptFile(message, mID, secretKey,
function (fileBlob, saveName, senderID) {
Expand Down

0 comments on commit 530d062

Please sign in to comment.