Skip to content

Commit 530d062

Browse files
committed
attempts to connect to localhost:8080 WIP
1 parent b63a58f commit 530d062

5 files changed

Lines changed: 37 additions & 12 deletions

File tree

capacitor.config.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
"appName": "LeapChat",
44
"webDir": "build",
55
"bundledWebRuntime": false,
6+
"plugins": {
7+
"CapacitorHttp": {
8+
"enabled": true
9+
}
10+
},
611
"server": {
7-
"hostname": "localhost:8080"
12+
"cleartext": "true",
13+
"allowNavigation": [
14+
"192.168.1.247:8080/*",
15+
"localhost:8080/*",
16+
"leapchat.org/*"
17+
]
818
}
919
}

server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func ProductionServer(srv *http.Server, httpsAddr, domain string, manager *autoc
7474

7575
func Login(m *miniware.Mapper, pgClient *PGClient) func(w http.ResponseWriter, req *http.Request) {
7676
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
77+
//w.Header().Set("Access-Control-Allow-Origin", "*")
7778
mID, keypair, err := parseMinilockID(req)
7879
if err != nil {
7980
WriteErrorStatus(w, "Error: invalid miniLock ID",

src/store/epics/chatEpics.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ const ownUserStatusEpic = (action$, store) =>
137137
.map(() => userStatusSent())
138138
)
139139
.catch(error => {
140-
console.error(error);
141140
return Observable.of(alertWarning('Error sending user status.'));
142141
});
143142

src/utils/miniLock.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ miniLock.crypto.decryptFile = function (
443443
);
444444
miniLock.file.read(file, 12, headerLength + 12, function (header) {
445445
try {
446-
alert(header.data);
447446
header = nacl.util.encodeUTF8(header.data);
448447
header = JSON.parse(header);
449448
}

src/utils/sessions.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
import { getEmail, getPassphrase } from '../utils/encrypter';
22
import miniLock from '../utils/miniLock';
3+
import { Capacitor } from '@capacitor/core';
4+
import { CapacitorHttp } from '@capacitor/core';
35

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

9+
if (Capacitor.isNativePlatform()){
10+
authUrl = "http://192.168.1.247:8080/api/login";
11+
}
712

8-
async function connectWithAuthRequest(initiateConnection, mID, secretKey, isNewPassphrase) {
9-
alert(authUrl);
10-
const response = await fetch(authUrl, {
11-
method: "GET",
12-
headers: {
13-
'X-Minilock-Id': mID
14-
}
15-
});
1613

14+
async function connectWithAuthRequest(initiateConnection, mID, secretKey, isNewPassphrase) {
15+
let response;
16+
if (Capacitor.isNativePlatform()){
17+
response = await CapacitorHttp.request({
18+
url: authUrl,
19+
headers: {
20+
'X-Minilock-Id': mID
21+
},
22+
method: 'GET'
23+
});
24+
} else {
25+
response = await fetch(authUrl, {
26+
method: "GET",
27+
headers: {
28+
'X-Minilock-Id': mID
29+
}
30+
});
31+
}
32+
1733
const message = await response.blob();
1834
miniLock.crypto.decryptFile(message, mID, secretKey,
1935
function (fileBlob, saveName, senderID) {

0 commit comments

Comments
 (0)