mergin latest into fdroid

This commit is contained in:
Roland Osborne 2024-05-06 18:52:03 -07:00
parent d5d4c0f5f4
commit 2555fcbf52
126 changed files with 600 additions and 35978 deletions

View File

@ -7,6 +7,10 @@
<p align="center">A federated messenger for self-hosting</p>
</div>
<p align="center">
<a href="/doc/design_overview.md">-> Design Overview <-</a>
</p>
<br>
<p align="center">
@ -19,13 +23,14 @@
</p>
<br>
Databag is designed for efficiency, consuming minimal resources on the host system and network. Notable features include:
Databag is designed for efficiency, consuming minimal hosting resources. Notable features include:
- Decentralized (direct communication between app and server node)
- Federated (accounts on different nodes can communicate)
- Public-Private key based identity (not bound to any blockchain or hosting domain)
- End-to-End encryption (the hosting admin cannot view topics if sealed)
- Audio and Video Calls (nat traversal requires separate relay server)
- Topic based threads (messages organized by topic not contacts)
- Unlimited participants (no limit on group thread members)
- Lightweight (server can run on a raspberry pi zero v1.3)
- Low latency (use of websockets for push events to avoid polling)
- Unlimited accounts per node (host for your whole family)
@ -131,7 +136,7 @@ Install without a container in AWS [here](/doc/aws.md).
Integrate Databag in an OpenWrt firmware [here](/doc/openwrt.md).
1-click installs in [CapRover](https://caprover.com/), [CasaOS](https://casaos.io), [Unraid](https://unraid.net/), [Runtipi](https://www.runtipi.io/), [Kubero](https://www.kubero.dev/)
1-click installs in [CapRover](https://caprover.com/), [CasaOS](https://casaos.io), [Unraid](https://unraid.net/), [Runtipi](https://www.runtipi.io/), [Kubero](https://www.kubero.dev/), [Umbrel](https://umbrel.com/)
## Audio and Video Calls
@ -142,3 +147,7 @@ If you want to enable audio and video calls, you should setup your own relay ser
- WebRTC Server URL: turn:34.210.172.114:3478?transport=udp
- WebRTC Username: user
- WebRTC Password: pass
### Roadmap
Please let me know any missing features; [here](/doc/backlog.md) is the current backlog. Features are prioritized based on interest from the community.

View File

@ -2,13 +2,15 @@ import { checkResponse, fetchWithCustomTimeout } from './fetchUtil';
import base64 from 'react-native-base64'
export async function addAccount(server, username, password, token) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let access = "";
if (token) {
access = `?token=${token}`
}
let headers = new Headers()
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
let profile = await fetchWithCustomTimeout(`https://${server}/account/profile${access}`, { method: 'POST', headers: headers }, 60000)
let profile = await fetchWithCustomTimeout(`${protocol}://${server}/account/profile${access}`, { method: 'POST', headers: headers }, 60000)
checkResponse(profile);
return await profile.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addAccountAccess(server, token, accountId) {
let access = await fetchWithTimeout(`https://${server}/admin/accounts/${accountId}/auth?token=${token}`, { method: 'POST' })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let access = await fetchWithTimeout(`${protocol}://${server}/admin/accounts/${accountId}/auth?token=${token}`, { method: 'POST' })
checkResponse(access);
return await access.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addAccountCreate(server, token) {
let access = await fetchWithTimeout(`https://${server}/admin/accounts?token=${token}`, { method: 'POST' })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let access = await fetchWithTimeout(`${protocol}://${server}/admin/accounts?token=${token}`, { method: 'POST' })
checkResponse(access);
return await access.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addCall(server, token, cardId) {
let call = await fetchWithTimeout(`https://${server}/talk/calls?agent=${token}`, { method: 'POST', body: JSON.stringify(cardId)} );
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let call = await fetchWithTimeout(`${protocol}://${server}/talk/calls?agent=${token}`, { method: 'POST', body: JSON.stringify(cardId)} );
checkResponse(call);
return await call.json();
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addCard(server, token, message) {
let card = await fetchWithTimeout(`https://${server}/contact/cards?agent=${token}`, { method: 'POST', body: JSON.stringify(message)} );
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards?agent=${token}`, { method: 'POST', body: JSON.stringify(message)} );
checkResponse(card);
return await card.json();
}

View File

@ -1,8 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addChannel(server, token, type, data, cards ) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let params = { dataType: type, data: JSON.stringify(data), groups: [], cards };
let channel = await fetchWithTimeout(`https://${server}/content/channels?agent=${token}`, { method: 'POST', body: JSON.stringify(params)} );
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels?agent=${token}`, { method: 'POST', body: JSON.stringify(params)} );
checkResponse(channel);
return await channel.json();
}

View File

@ -1,9 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addChannelTopic(server, token, channelId, messageType, message, assets ): string {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
if (message == null && (assets == null || assets.length === 0)) {
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}`,
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}`,
{ method: 'POST', body: JSON.stringify({}) });
checkResponse(topic);
let slot = await topic.json();
@ -14,7 +16,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
if (value !== null) return value
}), datatype: messageType };
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}&confirm=true`,
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}&confirm=true`,
{ method: 'POST', body: JSON.stringify(subject) });
checkResponse(topic);
let slot = await topic.json();
@ -22,7 +24,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
}
else {
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}`,
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}`,
{ method: 'POST', body: JSON.stringify({}) });
checkResponse(topic);
let slot = await topic.json();
@ -34,7 +36,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
const formData = new FormData();
formData.append('asset', asset.image);
let transform = encodeURIComponent(JSON.stringify(["ithumb;photo", "icopy;photo"]));
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
checkResponse(topicAsset);
let assetEntry = await topicAsset.json();
message.assets.push({
@ -49,7 +51,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
formData.append('asset', asset.video);
let thumb = 'vthumb;video;' + asset.position;
let transform = encodeURIComponent(JSON.stringify(["vlq;video", "vhd;video", thumb]));
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
checkResponse(topicAsset);
let assetEntry = await topicAsset.json();
message.assets.push({
@ -64,7 +66,7 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
const formData = new FormData();
formData.append('asset', asset.audio);
let transform = encodeURIComponent(JSON.stringify(["acopy;audio"]));
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData });
checkResponse(topicAsset);
let assetEntry = await topicAsset.json();
message.assets.push({
@ -80,11 +82,11 @@ export async function addChannelTopic(server, token, channelId, messageType, mes
if (value !== null) return value
}), datatype: messageType };
let unconfirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/subject?agent=${token}`,
let unconfirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/subject?agent=${token}`,
{ method: 'PUT', body: JSON.stringify(subject) });
checkResponse(unconfirmed);
let confirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?agent=${token}`,
let confirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?agent=${token}`,
{ method: 'PUT', body: JSON.stringify('confirmed') });
checkResponse(confirmed);
return slot.id;

View File

@ -1,8 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addContactChannelTopic(server, token, channelId, messageType, message, assets ) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
if (message == null && (assets == null || assets.length === 0)) {
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}`,
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}`,
{ method: 'POST', body: JSON.stringify({}) });
checkResponse(topic);
let slot = await topic.json();
@ -13,14 +16,14 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
if (value !== null) return value
}), datatype: messageType };
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}&confirm=true`,
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}&confirm=true`,
{ method: 'POST', body: JSON.stringify(subject) });
checkResponse(topic);
let slot = await topic.json();
return slot.id;
}
else {
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}`,
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}`,
{ method: 'POST', body: JSON.stringify({}) });
checkResponse(topic);
let slot = await topic.json();
@ -32,7 +35,7 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
const formData = new FormData();
formData.append('asset', asset.image);
let transform = encodeURIComponent(JSON.stringify(["ithumb;photo", "icopy;photo"]));
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
checkResponse(topicAsset);
let assetEntry = await topicAsset.json();
message.assets.push({
@ -47,7 +50,7 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
formData.append('asset', asset.video);
let thumb = "vthumb;video;" + asset.position
let transform = encodeURIComponent(JSON.stringify(["vhd;video", "vlq;video", thumb]));
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
checkResponse(topicAsset);
let assetEntry = await topicAsset.json();
message.assets.push({
@ -62,7 +65,7 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
const formData = new FormData();
formData.append('asset', asset.audio);
let transform = encodeURIComponent(JSON.stringify(["acopy;audio"]));
let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
let topicAsset = await fetch(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData });
checkResponse(topicAsset);
let assetEntry = await topicAsset.json();
message.assets.push({
@ -78,11 +81,11 @@ export async function addContactChannelTopic(server, token, channelId, messageTy
if (value !== null) return value
}), datatype: messageType };
let unconfirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/subject?contact=${token}`,
let unconfirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/subject?contact=${token}`,
{ method: 'PUT', body: JSON.stringify(subject) });
checkResponse(unconfirmed);
let confirmed = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?contact=${token}`,
let confirmed = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${slot.id}/confirmed?contact=${token}`,
{ method: 'PUT', body: JSON.stringify('confirmed') });
checkResponse(confirmed);
return slot.id;

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addContactRing(server, token, call) {
let ring = await fetchWithTimeout(`https://${server}/talk/rings?contact=${token}`, { method: 'POST', body: JSON.stringify(call) });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let ring = await fetchWithTimeout(`${protocol}://${server}/talk/rings?contact=${token}`, { method: 'POST', body: JSON.stringify(call) });
checkResponse(ring);
}

View File

@ -1,13 +1,15 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function addFlag(server, guid, channel, topic) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
if (channel) {
const param = topic ? `&topic=${topic}` : '';
const flag = await fetchWithTimeout(`https://${server}/account/flag/${guid}?channel=${channel}${param}`, { method: 'POST' } );
const flag = await fetchWithTimeout(`${protocol}://${server}/account/flag/${guid}?channel=${channel}${param}`, { method: 'POST' } );
checkResponse(flag);
}
else {
const flag = await fetchWithTimeout(`https://${server}/account/flag/${guid}`, { method: 'POST' } );
const flag = await fetchWithTimeout(`${protocol}://${server}/account/flag/${guid}`, { method: 'POST' } );
checkResponse(flag);
}
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function clearChannelCard(server, token, channelId, cardId ) {
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'DELETE'});
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'DELETE'});
checkResponse(channel);
return await channel.json();
}

View File

@ -2,6 +2,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
import base64 from 'react-native-base64'
export async function clearLogin(server, token) {
let logout = await fetchWithTimeout(`https://${server}/account/apps?agent=${token}`, { method: 'DELETE' })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let logout = await fetchWithTimeout(`${protocol}://${server}/account/apps?agent=${token}`, { method: 'DELETE' })
checkResponse(logout)
}

View File

@ -2,6 +2,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
import base64 from 'react-native-base64'
export async function createAccount(username, password) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let headers = new Headers()
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
let profile = await fetchWithTimeout("/account/profile", { method: 'POST', headers: headers })

View File

@ -1,4 +1,6 @@
export function getAccountImageUrl(server, token, accountId) {
return `https://${server}/admin/accounts/${accountId}/image?token=${token}`
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
return `${protocol}://${server}/admin/accounts/${accountId}/image?token=${token}`
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getAccountStatus(server, token) {
let status = await fetchWithTimeout(`https://${server}/account/status?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let status = await fetchWithTimeout(`${protocol}://${server}/account/status?agent=${token}`, { method: 'GET' });
checkResponse(status);
return await status.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getAvailable(server) {
let available = await fetchWithTimeout(`https://${server}/account/available`, { method: 'GET' })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let available = await fetchWithTimeout(`${protocol}://${server}/account/available`, { method: 'GET' })
checkResponse(available)
return await available.json()
}

View File

@ -1,8 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getCard(server, token, cardId) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let param = "?agent=" + token
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}${param}`, { method: 'GET' });
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}${param}`, { method: 'GET' });
checkResponse(card);
return await card.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getCardCloseMessage(server, token, cardId) {
let message = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/closeMessage?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let message = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/closeMessage?agent=${token}`, { method: 'GET' });
checkResponse(message);
return await message.json();
}

View File

@ -1,8 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getCardDetail(server, token, cardId) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let param = "?agent=" + token
let detail = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/detail${param}`, { method: 'GET' });
let detail = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/detail${param}`, { method: 'GET' });
checkResponse(detail);
return await detail.json()
}

View File

@ -1,4 +1,6 @@
export function getCardImageUrl(server, token, cardId, revision) {
return `https://${server}/contact/cards/${cardId}/profile/image?agent=${token}&revision=${revision}`
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
return `${protocol}://${server}/contact/cards/${cardId}/profile/image?agent=${token}&revision=${revision}`
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getCardOpenMessage(server, token, cardId) {
let message = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/openMessage?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let message = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/openMessage?agent=${token}`, { method: 'GET' });
checkResponse(message);
return await message.json();
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getCardProfile(server, token, cardId) {
let profile = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let profile = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'GET' });
checkResponse(profile);
return await profile.json()
}

View File

@ -1,11 +1,13 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getCards(server, token, revision) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let param = "agent=" + token
if (revision != null) {
param += '&revision=' + revision
}
let cards = await fetchWithTimeout(`https://${server}/contact/cards?${param}`, { method: 'GET' });
let cards = await fetchWithTimeout(`${protocol}://${server}/contact/cards?${param}`, { method: 'GET' });
checkResponse(cards)
return await cards.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getChannelDetail(server, token, channelId) {
let detail = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/detail?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let detail = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/detail?agent=${token}`, { method: 'GET' });
checkResponse(detail)
return await detail.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getChannelNotifications(server, token, channelId) {
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'GET' });
checkResponse(notify)
return await notify.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getChannelSummary(server, token, channelId) {
let summary = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/summary?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let summary = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/summary?agent=${token}`, { method: 'GET' });
checkResponse(summary)
return await summary.json()
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getChannelTopic(server, token, channelId, topicId) {
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/detail?agent=${token}`,
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/detail?agent=${token}`,
{ method: 'GET' });
checkResponse(topic)
return await topic.json()

View File

@ -1,4 +1,6 @@
export function getChannelTopicAssetUrl(server, token, channelId, topicId, assetId) {
return `https://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?agent=${token}`
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
return `${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?agent=${token}`
}

View File

@ -1,6 +1,8 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getChannelTopics(server, token, channelId, revision, count, begin, end) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let rev = ''
if (revision != null) {
@ -18,7 +20,7 @@ export async function getChannelTopics(server, token, channelId, revision, count
if (end != null) {
edn = `&end=${end}`
}
let topics = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?agent=${token}${rev}${cnt}${bgn}${edn}`,
let topics = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?agent=${token}${rev}${cnt}${bgn}${edn}`,
{ method: 'GET' });
checkResponse(topics)
return {

View File

@ -1,12 +1,14 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getChannels(server, token, revision) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let param = "?agent=" + token
if (revision != null) {
param += `&channelRevision=${revision}`
}
param += `&types=${encodeURIComponent(JSON.stringify(['sealed','superbasic']))}`;
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
let channels = await fetchWithTimeout(`${protocol}://${server}/content/channels${param}`, { method: 'GET' });
checkResponse(channels)
let ret = await channels.json()
return ret;

View File

@ -1,9 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannelDetail(server, token, channelId) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let host = "";
if (server) {
host = `https://${server}`;
host = `${protocol}://${server}`;
}
let detail = await fetchWithTimeout(`${host}/content/channels/${channelId}/detail?contact=${token}`, { method: 'GET' });
checkResponse(detail)

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannelNotifications(server, token, channelId) {
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'GET' });
checkResponse(notify)
return await notify.json()
}

View File

@ -1,9 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannelSummary(server, token, channelId) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let host = "";
if (server) {
host = `https://${server}`;
host = `${protocol}://${server}`;
}
let summary = await fetchWithTimeout(`${host}/content/channels/${channelId}/summary?contact=${token}`, { method: 'GET' });
checkResponse(summary)

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannelTopic(server, token, channelId, topicId) {
let topic = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/detail?contact=${token}`,
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let topic = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/detail?contact=${token}`,
{ method: 'GET' });
checkResponse(topic)
return await topic.json()

View File

@ -1,4 +1,6 @@
export function getContactChannelTopicAssetUrl(server, token, channelId, topicId, assetId) {
return `https://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?contact=${token}`
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
return `${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/assets/${assetId}?contact=${token}`
}

View File

@ -1,6 +1,8 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannelTopics(server, token, channelId, revision, count, begin, end) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let rev = ''
if (revision != null) {
@ -18,7 +20,7 @@ export async function getContactChannelTopics(server, token, channelId, revision
if (end != null) {
edn = `&end=${end}`
}
let topics = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}${rev}${cnt}${bgn}${edn}`,
let topics = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics?contact=${token}${rev}${cnt}${bgn}${edn}`,
{ method: 'GET' });
checkResponse(topics)

View File

@ -1,6 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannels(server, token, viewRevision, channelRevision) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let param = "?contact=" + token
if (viewRevision != null) {
param += `&viewRevision=${viewRevision}`;
@ -9,7 +12,7 @@ export async function getContactChannels(server, token, viewRevision, channelRev
param += `&channelRevision=${channelRevision}`;
}
param += `&types=${encodeURIComponent(JSON.stringify(['sealed','superbasic']))}`;
let channels = await fetchWithTimeout(`https://${server}/content/channels${param}`, { method: 'GET' });
let channels = await fetchWithTimeout(`${protocol}://${server}/content/channels${param}`, { method: 'GET' });
checkResponse(channels)
return await channels.json()
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactProfile(server, token) {
let profile = await fetchWithTimeout(`https://${server}/profile/message?contact=${token}`, { method: 'GET', });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let profile = await fetchWithTimeout(`${protocol}://${server}/profile/message?contact=${token}`, { method: 'GET', });
checkResponse(profile);
return await profile.json()
}

View File

@ -1,11 +1,14 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getGroups(token, revision) {
export async function getGroups(server, token, revision) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let param = "agent=" + token
if (revision != null) {
param += '&revision=' + revision
}
let groups = await fetchWithTimeout(`/alias/groups?${param}`, { method: 'GET' });
let groups = await fetchWithTimeout(`${protocol}://server/alias/groups?${param}`, { method: 'GET' });
checkResponse(groups)
return await groups.json()
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getHandle(server, token, name) {
let available = await fetchWithTimeout(`https://${server}/account/username?agent=${token}&name=${encodeURIComponent(name)}`, { method: 'GET' })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let available = await fetchWithTimeout(`${protocol}://${server}/account/username?agent=${token}&name=${encodeURIComponent(name)}`, { method: 'GET' })
checkResponse(available)
return await available.json()
}

View File

@ -1,8 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getListing(server, filter) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
const param = filter ? `?filter=${filter}` : '';
let listing = await fetchWithTimeout(`https://${server}/account/listing${param}`, { method: 'GET' });
let listing = await fetchWithTimeout(`${protocol}://${server}/account/listing${param}`, { method: 'GET' });
checkResponse(listing);
return await listing.json();
}

View File

@ -1,7 +1,10 @@
export function getListingImageUrl(server, guid) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let host = "";
if (server) {
host = `https://${server}`;
host = `${protocol}://${server}`;
}
return `${host}/account/listing/${guid}/image`

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getListingMessage(server, guid) {
let listing = await fetchWithTimeout(`https://${server}/account/listing/${guid}/message`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let listing = await fetchWithTimeout(`${protocol}://${server}/account/listing/${guid}/message`, { method: 'GET' });
checkResponse(listing);
return await listing.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getNodeAccounts(server, token) {
let accounts = await fetchWithTimeout(`https://${server}/admin/accounts?token=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let accounts = await fetchWithTimeout(`${protocol}://${server}/admin/accounts?token=${token}`, { method: 'GET' });
checkResponse(accounts);
return await accounts.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getNodeConfig(server, token) {
let config = await fetchWithTimeout(`https://${server}/admin/config?token=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let config = await fetchWithTimeout(`${protocol}://${server}/admin/config?token=${token}`, { method: 'GET' });
checkResponse(config);
return await config.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getNodeStatus(server) {
let status = await fetchWithTimeout(`https://${server}/admin/status`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let status = await fetchWithTimeout(`${protocol}://${server}/admin/status`, { method: 'GET' });
checkResponse(status);
return await status.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getProfile(server, token) {
let profile = await fetchWithTimeout(`https://${server}/profile?agent=${token}`, { method: 'GET' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let profile = await fetchWithTimeout(`${protocol}://${server}/profile?agent=${token}`, { method: 'GET' });
checkResponse(profile)
return await profile.json()
}

View File

@ -1,4 +1,7 @@
export function getProfileImageUrl(server, token, revision) {
return `https://${server}/profile/image?agent=${token}&revision=${revision}`;
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
return `${protocol}://${server}/profile/image?agent=${token}&revision=${revision}`;
}

View File

@ -1,6 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getUsername(name, server, token) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let query = "";
if (token && name) {
query = `?name=${encodeURIComponent(name)}&token=${token}`;
@ -12,7 +15,7 @@ export async function getUsername(name, server, token) {
query = `?token=${token}`;
}
let available = await fetchWithTimeout(`https://${server}/account/username${query}`, { method: 'GET' })
let available = await fetchWithTimeout(`${protocol}://${server}/account/username${query}`, { method: 'GET' })
checkResponse(available)
return await available.json()
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function keepCall(server, token, callId) {
let call = await fetchWithTimeout(`https://${server}/talk/calls/${callId}?agent=${token}`, { method: 'PUT' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let call = await fetchWithTimeout(`${protocol}://${server}/talk/calls/${callId}?agent=${token}`, { method: 'PUT' });
checkResponse(call);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeAccount(server, token, accountId) {
let res = await fetchWithTimeout(`https://${server}/admin/accounts/${accountId}?token=${token}`, { method: 'DELETE' })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let res = await fetchWithTimeout(`${protocol}://${server}/admin/accounts/${accountId}?token=${token}`, { method: 'DELETE' })
checkResponse(res);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeCall(server, token, callId) {
let call = await fetchWithTimeout(`https://${server}/talk/calls/${callId}?agent=${token}`, { method: 'DELETE' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let call = await fetchWithTimeout(`${protocol}://${server}/talk/calls/${callId}?agent=${token}`, { method: 'DELETE' });
checkResponse(call)
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeCard(server, token, cardId) {
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}?agent=${token}`, { method: 'DELETE' } );
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}?agent=${token}`, { method: 'DELETE' } );
checkResponse(card);
return await card.json();
}

View File

@ -1,8 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeChannel(server, token, channelId) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}?agent=${token}`,
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}?agent=${token}`,
{ method: 'DELETE' });
checkResponse(channel);
}

View File

@ -1,8 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeChannelTopic(server, token, channelId, topicId) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}?agent=${token}`,
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}?agent=${token}`,
{ method: 'DELETE' });
checkResponse(channel);
}

View File

@ -1,6 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeContactCall(server, token, callId) {
const call = await fetchWithTimeout(`https://${server}/talk/calls/${callId}?contact=${token}`, { method: 'DELETE' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
const call = await fetchWithTimeout(`${protocol}://${server}/talk/calls/${callId}?contact=${token}`, { method: 'DELETE' });
checkResponse(call);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeContactChannel(server, token, channelId) {
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}?contact=${token}`,
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}?contact=${token}`,
{ method: 'DELETE' });
checkResponse(channel);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeContactChannelTopic(server, token, channelId, topicId) {
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}?contact=${token}`,
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}?contact=${token}`,
{ method: 'DELETE' });
checkResponse(channel);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function removeProfile(server, token) {
let profile = await fetchWithTimeout(`https://${server}/profile?agent=${token}`, { method: 'DELETE' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let profile = await fetchWithTimeout(`${protocol}://${server}/profile?agent=${token}`, { method: 'DELETE' });
checkResponse(profile)
}

View File

@ -1,7 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setAccountAccess(server, token, appName, appVersion, platform, deviceToken, notifications) {
let access = await fetchWithTimeout(`https://${server}/account/access?token=${token}&appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=up`, { method: 'PUT', body: JSON.stringify(notifications) })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let access = await fetchWithTimeout(`${protocol}://${server}/account/access?token=${token}&appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=up`, { method: 'PUT', body: JSON.stringify(notifications) })
checkResponse(access)
return await access.json()
}

View File

@ -2,9 +2,12 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
import base64 from 'react-native-base64'
export async function setAccountLogin(server, token, username, password) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let headers = new Headers()
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
let res = await fetchWithTimeout(`https://${server}/account/login?agent=${token}`, { method: 'PUT', headers })
let res = await fetchWithTimeout(`${protocol}://${server}/account/login?agent=${token}`, { method: 'PUT', headers })
checkResponse(res);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setAccountNotifications(server, token, flag) {
let res = await fetchWithTimeout(`https://${server}/account/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let res = await fetchWithTimeout(`${protocol}://${server}/account/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
checkResponse(res);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setAccountSeal(server, token, seal) {
let res = await fetchWithTimeout(`https://${server}/account/seal?agent=${token}`, { method: 'PUT', body: JSON.stringify(seal) })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let res = await fetchWithTimeout(`${protocol}://${server}/account/seal?agent=${token}`, { method: 'PUT', body: JSON.stringify(seal) })
checkResponse(res);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setAccountSearchable(server, token, flag) {
let res = await fetchWithTimeout(`https://${server}/account/searchable?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let res = await fetchWithTimeout(`${protocol}://${server}/account/searchable?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) })
checkResponse(res);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setAccountStatus(server, token, accountId, disabled) {
let res = await fetchWithTimeout(`https://${server}/admin/accounts/${accountId}/status?token=${token}`, { method: 'PUT', body: JSON.stringify(disabled) })
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let res = await fetchWithTimeout(`${protocol}://${server}/admin/accounts/${accountId}/status?token=${token}`, { method: 'PUT', body: JSON.stringify(disabled) })
checkResponse(res);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setCardCloseMessage(server, message) {
let status = await fetchWithTimeout(`https://${server}/contact/closeMessage`, { method: 'PUT', body: JSON.stringify(message) });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let status = await fetchWithTimeout(`${protocol}://${server}/contact/closeMessage`, { method: 'PUT', body: JSON.stringify(message) });
checkResponse(status);
return await status.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setCardOpenMessage(server, message) {
let status = await fetchWithTimeout(`https://${server}/contact/openMessage`, { method: 'PUT', body: JSON.stringify(message) });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let status = await fetchWithTimeout(`${protocol}://${server}/contact/openMessage`, { method: 'PUT', body: JSON.stringify(message) });
checkResponse(status);
return await status.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setCardProfile(server, token, cardId, message) {
let profile = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'PUT', body: JSON.stringify(message) });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let profile = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/profile?agent=${token}`, { method: 'PUT', body: JSON.stringify(message) });
checkResponse(profile);
return await profile.json()
}

View File

@ -1,19 +1,22 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setCardConnecting(server, token, cardId) {
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/status?agent=${token}`, { method: 'PUT', body: JSON.stringify('connecting') } );
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/status?agent=${token}`, { method: 'PUT', body: JSON.stringify('connecting') } );
checkResponse(card);
return await card.json();
}
export async function setCardConnected(server, token, cardId, access, view, article, channel, profile) {
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/status?agent=${token}&token=${access}&viewRevision=${view}&articleRevision=${article}&channelRevision=${channel}&profileRevision=${profile}`, { method: 'PUT', body: JSON.stringify('connected') } );
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/status?agent=${token}&token=${access}&viewRevision=${view}&articleRevision=${article}&channelRevision=${channel}&profileRevision=${profile}`, { method: 'PUT', body: JSON.stringify('connected') } );
checkResponse(card);
return await card.json();
}
export async function setCardConfirmed(server, token, cardId) {
let card = await fetchWithTimeout(`https://${server}/contact/cards/${cardId}/status?agent=${token}`, { method: 'PUT', body: JSON.stringify('confirmed') } );
let card = await fetchWithTimeout(`${protocol}://${server}/contact/cards/${cardId}/status?agent=${token}`, { method: 'PUT', body: JSON.stringify('confirmed') } );
checkResponse(card);
return await card.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setChannelCard(server, token, channelId, cardId ) {
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'PUT'});
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/cards/${cardId}?agent=${token}`, {method: 'PUT'});
checkResponse(channel);
return await channel.json();
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setChannelNotifications(server, token, channelId, flag) {
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?agent=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
checkResponse(notify)
}

View File

@ -1,8 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setChannelSubject(server, token, channelId, dataType, data ) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let params = { dataType, data: JSON.stringify(data) };
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/subject?agent=${token}`, { method: 'PUT', body: JSON.stringify(params)} );
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/subject?agent=${token}`, { method: 'PUT', body: JSON.stringify(params)} );
checkResponse(channel);
return await channel.json();
}

View File

@ -1,6 +1,9 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setChannelTopicSubject(token, channelId, topicId, asset) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
if (asset.image) {
const formData = new FormData();
formData.append('asset', asset.image);

View File

@ -1,11 +1,14 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setChannelTopicSubject(server, token, channelId, topicId, dataType, data) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let subject = { data: JSON.stringify(data, (key, value) => {
if (value !== null) return value
}), datatype: dataType };
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/subject?agent=${token}&confirm=true`,
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/subject?agent=${token}&confirm=true`,
{ method: 'PUT', body: JSON.stringify(subject) });
checkResponse(channel);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setContactChannelNotifications(server, token, channelId, flag) {
const notify = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
const notify = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/notification?contact=${token}`, { method: 'PUT', body: JSON.stringify(flag) });
checkResponse(notify)
}

View File

@ -1,9 +1,12 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setContactChannelTopicSubject(server, token, channelId, topicId, asset) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let host = "";
if (server) {
host = `https://${server}`;
host = `${protocol}://${server}`;
}
if (asset.image) {

View File

@ -1,11 +1,14 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setContactChannelTopicSubject(server, token, channelId, topicId, dataType, data) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let subject = { data: JSON.stringify(data, (key, value) => {
if (value !== null) return value
}), datatype: dataType };
let channel = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics/${topicId}/subject?contact=${token}&confirm=true`,
let channel = await fetchWithTimeout(`${protocol}://${server}/content/channels/${channelId}/topics/${topicId}/subject?contact=${token}&confirm=true`,
{ method: 'PUT', body: JSON.stringify(subject) });
checkResponse(channel);
}

View File

@ -2,9 +2,11 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
import base64 from 'react-native-base64'
export async function setLogin(username, server, password, appName, appVersion, platform, deviceToken, notifications) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let headers = new Headers()
headers.append('Authorization', 'Basic ' + base64.encode(username + ":" + password));
let login = await fetchWithTimeout(`https://${server}/account/apps?appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=up`, { method: 'POST', body: JSON.stringify(notifications), headers: headers })
let login = await fetchWithTimeout(`${protocol}://${server}/account/apps?appName=${appName}&appVersion=${appVersion}&platform=${platform}&deviceToken=${deviceToken}&pushType=up`, { method: 'POST', body: JSON.stringify(notifications), headers: headers })
checkResponse(login)
return await login.json()
}

View File

@ -1,8 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setNodeConfig(server, token, config) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let body = JSON.stringify(config);
let settings = await fetchWithTimeout(`https://${server}/admin/config?token=${token}`, { method: 'PUT', body });
let settings = await fetchWithTimeout(`${protocol}://${server}/admin/config?token=${token}`, { method: 'PUT', body });
checkResponse(settings);
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setNodeStatus(server, token) {
let status = await fetchWithTimeout(`https://${server}/admin/status?token=${token}`, { method: 'PUT' });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let status = await fetchWithTimeout(`${protocol}://${server}/admin/status?token=${token}`, { method: 'PUT' });
checkResponse(status);
}

View File

@ -1,8 +1,11 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setProfileData(server, token, name, location, description) {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let data = { name: name, location: location, description: description };
let profile = await fetchWithTimeout(`https://${server}/profile/data?agent=${token}`, { method: 'PUT', body: JSON.stringify(data) });
let profile = await fetchWithTimeout(`${protocol}://${server}/profile/data?agent=${token}`, { method: 'PUT', body: JSON.stringify(data) });
checkResponse(profile)
return await profile.json()
}

View File

@ -1,7 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function setProfileImage(server, token, image) {
let profile = await fetchWithTimeout(`https://${server}/profile/image?agent=${token}`, { method: 'PUT', body: JSON.stringify(image) });
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(server);
const protocol = insecure ? 'http' : 'https';
let profile = await fetchWithTimeout(`${protocol}://${server}/profile/image?agent=${token}`, { method: 'PUT', body: JSON.stringify(image) });
checkResponse(profile)
return await profile.json()
}

View File

@ -158,6 +158,7 @@ const Strings = [
enableImage: 'Enable Image Queue',
enableAudio: 'Enable Audio Queue',
enableVideo: 'Enable Video Queue',
enableBinary: 'Enable Binary Files',
enableCalls: 'Enable WebRTC Calls',
relayUrl: 'Relay URL',
relayUsername: 'Relay Username',
@ -356,6 +357,7 @@ const Strings = [
enableImage: 'Activer les Fichiers Image',
enableAudio: 'Activer les Fichiers Audio',
enableVideo: 'Activer les Fichiers Vidéo',
enableBinary: 'Activer les Fichiers Binaires',
enableCalls: 'Activer les Appels',
relayUrl: 'URL de Relais',
relayUsername: 'Nom d\'Utilisateur du Relais',
@ -554,6 +556,7 @@ const Strings = [
enableImage: 'Permitir Archivos de Imagen',
enableAudio: 'Permitir Archivos de Audio',
enableVideo: 'Permitir Archivos de Vídeo',
enableBinary: 'Permitir Archivos Binarios',
enableCalls: 'Permitier Llamadas',
relayUrl: 'URL para Llamadas',
relayUsername: 'Nombre de Usuario para Llamadas',
@ -753,6 +756,7 @@ const Strings = [
enableImage: 'Bilddateien Aktivieren',
enableAudio: 'Audiodateien Aktivieren',
enableVideo: 'Videodateien aktivieren',
enableBinary: 'Binärdateien aktivieren',
enableCalls: 'Anrufe Ermöglichen',
relayUrl: 'URL für Anrufe',
relayUsername: 'Benutzername für Anrufe',
@ -940,6 +944,7 @@ const Strings = [
enableImage: 'Habilitar Fila de Imagens',
enableAudio: 'Habilitar Fila de Áudio',
enableVideo: 'Habilitar Fila de Vídeo',
enableBinary: 'Habilitar Fila Binários',
enableCalls: 'Habilitar Chamadas WebRTC',
relayUrl: 'URL do Relay',
relayUsername: 'Nome de Usuário do Relay',
@ -1124,6 +1129,7 @@ const Strings = [
enableImage: 'Включить очередь изображений',
enableAudio: 'Включить очередь аудио',
enableVideo: 'Включить очередь видео',
enableBinary: 'Включить двоичные файлы',
enableCalls: 'Включить звонки WebRTC',
relayUrl: 'URL релея',
relayUsername: 'Имя пользователя релея',

View File

@ -157,7 +157,9 @@ export function useAppContext() {
}
const setWebsocket = (session) => {
ws.current = createWebsocket(`wss://${session.server}/status?mode=ring`);
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(session.server);
const protocol = insecure ? 'ws' : 'wss';
ws.current = createWebsocket(`${protocol}://${session.server}/status?mode=ring`);
ws.current.onmessage = (ev) => {
if (ev.data == '') {
actions.logout();

View File

@ -239,7 +239,9 @@ export function useRingContext() {
videoTrack.current = false;
audioTrack.current = false;
ws.current = createWebsocket(`wss://${node}/signal`);
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(node);
const protocol = insecure ? 'ws' : 'wss';
ws.current = createWebsocket(`${protocol}://${node}/signal`);
ws.current.onmessage = async (ev) => {
// handle messages [impolite]
try {

View File

@ -66,11 +66,13 @@ export function useUploadContext() {
const actions = {
addTopic: (node, token, channelId, topicId, files, success, failure, cardId) => {
const insecure = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|:\d+$|$)){4}$/.test(node);
const protocol = insecure ? 'http' : 'https';
const key = cardId ? `${cardId}:${channelId}` : `:${channelId}`;
const controller = new AbortController();
const entry = {
index: index.current,
baseUrl: cardId ? `https://${node}/content/channels/${channelId}/topics/${topicId}/` : `https://${node}/content/channels/${channelId}/topics/${topicId}/`,
baseUrl: cardId ? `${protocol}://${node}/content/channels/${channelId}/topics/${topicId}/` : `${protocol}://${node}/content/channels/${channelId}/topics/${topicId}/`,
urlParams: cardId ? `?contact=${token}` : `?agent=${token}`,
files,
assets: [],

View File

@ -217,6 +217,12 @@ export function Dashboard(props) {
<Switch style={styles.switch} value={state.enableVideo}
onValueChange={actions.setEnableVideo} trackColor={styles.track}/>
</TouchableOpacity>
<TouchableOpacity style={styles.media} activeOpacity={1}
onPress={() => actions.setEnableBinary(!state.enableBinary)}>
<Text style={styles.modalLabel}>{ state.strings.enableBinary }</Text>
<Switch style={styles.switch} value={state.enableBinary}
onValueChange={actions.setEnableBinary} trackColor={styles.track}/>
</TouchableOpacity>
<View style={styles.label}></View>
<TouchableOpacity style={styles.ice} activeOpacity={1}

View File

@ -34,6 +34,7 @@ export function useDashboard(config, server, token) {
enableImage: true,
enableAudio: true,
enableVideo: true,
enableBinary: true,
createToken: null,
enableIce: false,
iceUrl: null,
@ -67,8 +68,9 @@ export function useDashboard(config, server, token) {
};
useEffect(() => {
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
updateState({ keyType, storage: accountStorage.toString(), domain, enableImage, enableAudio, enableVideo, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword });
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword } = config;
const storage = Math.ceil(accountStorage / 1073741824);
updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceUrl, iceUsername, icePassword });
}, [config]);
useEffect(() => {
@ -123,6 +125,9 @@ export function useDashboard(config, server, token) {
setEnableVideo: (enableVideo) => {
updateState({ enableVideo });
},
setEnableBinary: (enableBinary) => {
updateState({ enableBinary });
},
setKeyType: (keyType) => {
updateState({ keyType });
},
@ -139,8 +144,9 @@ export function useDashboard(config, server, token) {
updateState({ icePassword });
},
saveConfig: async () => {
const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword } = state;
const config = { accountStorage: Number(storage), domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableIce, iceUrl, iceUsername, icePassword };
const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceUrl, iceUsername, icePassword } = state;
const accountStorage = Number(storage) * 1073741824;
const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceUrl, iceUsername, icePassword };
await setNodeConfig(server, token, config);
},
enableUser: async (accountId, enabled) => {

View File

@ -137,6 +137,7 @@ function ContactStackScreen({ addChannel }) {
const [contact, setContact] = useState(null);
const [editable, setEditable] = useState(false);
const [search, setSearch] = useState(null);
const [handle, setHandle] = useState();
const [server, setServer] = useState();
@ -146,6 +147,12 @@ function ContactStackScreen({ addChannel }) {
navigation.navigate('contact')
}
const openRegistry = (navigation) => {
if (profile.state.identity?.node) {
setEditable(true);
}
else {
setEditable(false);
}
setServer(profile.state.server);
setHandle(null);
setSearch(false);
@ -165,7 +172,7 @@ function ContactStackScreen({ addChannel }) {
</ContactStack.Screen>
<ContactStack.Screen name="registry" options={{ ...stackParams, cardStyle: {backgroundColor: Colors.screenBase}, headerTitle: (props) => (
<RegistryHeader search={search} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} />
<RegistryHeader search={search} editable={editable} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} />
)}}>
{(props) => <RegistryBody search={search} handle={handle} server={server} openContact={(contact) => openContact(props.navigation, contact)} />}
</ContactStack.Screen>

View File

@ -45,7 +45,7 @@ export function useCards() {
cardId: cardId,
name: name,
handle: handle,
username: `${handle}/${node}`,
username: node ? `${handle}/${node}` : handle,
node: node,
guid: guid,
location: location,

View File

@ -25,7 +25,8 @@ export function useAddMember(item, members) {
useEffect(() => {
const { cardId, revision, profile } = item;
const { name, handle, node } = profile;
updateState({ cardId, name, handle: `${handle}@${node}`,
const username = node ? `${handle}/${node}` : handle;
updateState({ cardId, name, handle: username,
logo: profile.imageSet ? card.actions.getCardImageUrl(cardId) : 'avatar' });
}, [card.state]);

View File

@ -191,9 +191,11 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
<MatIcons name="music-note" size={24} color={Colors.text} />
</TouchableOpacity>
)}
<TouchableOpacity style={styles.addButton} onPress={addBinary}>
<MatIcons name="file-outline" size={24} color={Colors.text} />
</TouchableOpacity>
{ state.enableBinary && (
<TouchableOpacity style={styles.addButton} onPress={addBinary}>
<MatIcons name="file-outline" size={24} color={Colors.text} />
</TouchableOpacity>
)}
<View style={styles.divider} />
<TouchableOpacity style={styles.addButton} onPress={actions.showFontSize}>
<MatIcons name="format-size" size={24} color={Colors.text} />

View File

@ -26,6 +26,7 @@ export function useAddTopic(contentKey) {
enableImage: false,
enableAudio: false,
enableVideo: false,
enableBinary: false,
locked: true,
loaded: false,
conflict: false,
@ -50,15 +51,18 @@ export function useAddTopic(contentKey) {
if (asset.type === 'image' && !state.enableImage) {
conflict = true;
}
if (asset.video === 'video' && !state.enableVideo) {
if (asset.type === 'video' && !state.enableVideo) {
conflict = true;
}
if (asset.audio === 'audio' && !state.enableAudio) {
if (asset.type === 'audio' && !state.enableAudio) {
conflict = true;
}
if (asset.type === 'binary' && !state.enableBinary) {
conflict = true;
}
});
updateState({ conflict });
}, [state.assets, state.locked, state.enableImage, state.enableAudio, state.enableVideo]);
}, [state.assets, state.locked, state.enableImage, state.enableAudio, state.enableVideo, state.enableBinary]);
useEffect(() => {
updateState({ assets: [] });
@ -105,10 +109,10 @@ export function useAddTopic(contentKey) {
}, [upload.state, conversation.state]);
useEffect(() => {
const { enableVideo, enableAudio, enableImage } = conversation.state.channel?.detail || {};
const { enableVideo, enableAudio, enableImage, enableBinary } = conversation.state.channel?.detail || {};
const locked = conversation.state.channel?.detail?.dataType === 'superbasic' ? false : true;
const loaded = conversation.state.loaded;
updateState({ enableImage, enableAudio, enableVideo, locked, loaded });
updateState({ enableImage, enableAudio, enableVideo, enableBinary, locked, loaded });
}, [conversation.state]);
const setAsset = async (file, mime, scale) => {
@ -172,9 +176,6 @@ export function useAddTopic(contentKey) {
asset.type = 'binary';
asset.extension = name.split('.').pop().toUpperCase();
asset.label = name.slice(0, -1 * (asset.extension.length + 1));
console.log(asset);
updateState({ assets: [ ...state.assets, asset ] });
},
setVideoPosition: (key, position) => {

View File

@ -7,12 +7,12 @@ import { ProfileContext } from 'context/ProfileContext';
import Colors from 'constants/Colors';
import Ionicons from 'react-native-vector-icons/AntDesign';
export function RegistryHeader({ search, setSearch, handle, setHandle, server, setServer }) {
export function RegistryHeader({ search, setSearch, handle, setHandle, server, setServer, editable }) {
return (
<View style={styles.title}>
<View style={styles.inputwrapper}>
<TextInput style={styles.inputfield} value={server} onChangeText={setServer}
<TextInput style={styles.inputfield} value={server} onChangeText={setServer} editable={editable}
autoCorrect={false} autoCapitalize="none" placeholderTextColor={Colors.disabled} placeholder="Server" />
</View>
{ !search && (
@ -60,9 +60,16 @@ export function Registry({ closeRegistry, openContact }) {
const [search, setSearch] = useState(false);
const [handle, setHandle] = useState();
const [server, setServer] = useState();
const [editable, setEditable] = useState(false);
const profile = useContext(ProfileContext);
useEffect(() => {
if (profile.state.identity?.node) {
setEditable(true);
}
else {
setEditable(false);
}
setSearch(false);
setHandle(null);
setServer(profile.state.server);
@ -71,7 +78,7 @@ export function Registry({ closeRegistry, openContact }) {
return (
<View>
<View style={styles.header}>
<RegistryHeader search={search} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} />
<RegistryHeader search={search} editable={editable} setSearch={setSearch} handle={handle} setHandle={setHandle} server={server} setServer={setServer} />
</View>
<RegistryBody search={search} handle={handle} server={server} openContact={openContact} />
</View>

View File

@ -47,7 +47,7 @@ export function useRegistry(search, handle, server) {
const { guid, name, handle, node, location, description, imageSet } = item;
const server = node ? node : profile.state.server;
const logo = imageSet ? getListingImageUrl(server, guid) : 'avatar';
const username = `${handle}/${node}`;
const username = node ? `${handle}/${node}` : handle;
return { guid, name, handle, username, node: server, location, description, guid, imageSet, logo };
};

View File

@ -4,51 +4,38 @@ These instructions assume you have the following setup:
- an AMD64 Ubuntu EC2 instance with incoming ports 443 and 80<br/>
- an EFS instance<br/>
- a domain name pointing the the IP of your EC2 instance<br/>
- security group of EFS must have security group of EC2 as incomping
## Step 1: obtain cert
sudo apt-get install certbot<br/>
sudo certbot certonly --standalone -d [dns name]<br/>
## Step 2: install databag dependencies
sudo apt-get -y install ffmpeg<br/>
sudo apt-get -y install curl<br/>
sudo apt-get -y install net-tools<br/>
sudo apt-get -y install jq<br/>
sudo apt-get -y install netcat<br/>
sudo apt-get -y install unzip<br/>
sudo apt-get -y install wget<br/>
sudo apt-get -y install git<br/>
sudo apt-get -y install vim<br/>
sudo apt-get -y install fail2ban<br/>
sudo apt-get -y install imagemagick-6.q16<br/>
sudo apt-get -y install build-essential<br/>
sudo apt-get -y install sqlite3<br/>
sudo apt-get -y install openssh-client<br/>
apt-get -y install npm<br/>
apt-get -y upgrade<br/>
npm install --global yarn<br/>
npm install -g n<br/>
n stable<br/>
sudo apt-get -y install ffmpeg curl net-tools jq netcat unzip wget git vim fail2ban imagemagick-6.q16 build-essential sqlite3 openssh-client npm<br/>
sudo apt-get -y upgrade<br/>
sudo npm install --global yarn<br/>
sudo npm install -g n<br/>
sudo n stable<br/>
## Step 3: download and install golang
wget https://go.dev/dl/go1.19.3.linux-amd64.tar.gz<br/>
sudo tar -C /usr/local -xzf go1.19.3.linux-amd64.tar.gz<br/>
## Step 4: clone and build the server
mkdir /app<br/>
sudo mkdir /app<br/>
cd /app<br/>
git clone https://github.com/balzack/databag.git<br/>
sudo git clone https://github.com/balzack/databag.git<br/>
cd /app/databag/net/web<br/>
yarn config set network-timeout 300000<br/>
yarn --cwd /app/databag/net/web install<br/>
yarn --cwd /app/databag/net/web build<br/>
sudo yarn config set network-timeout 300000<br/>
sudo yarn --cwd /app/databag/net/web install<br/>
sudo yarn --cwd /app/databag/net/web build<br/>
cd /app/databag/net/server<br/>
/usr/local/go/bin/go build databag<br/>
sudo /usr/local/go/bin/go build databag<br/>
## Step 5: setup databag paths
mkdir -p /var/lib/databag/assets<br/>
mkdir -p /opt/databag/transform<br/>
cp /app/databag/net/container/transform/* /opt/databag/transform/<br/>
sudo mkdir -p /var/lib/databag<br/>
sudo mkdir -p /opt/databag/transform<br/>
sudo cp /app/databag/net/container/transform/* /opt/databag/transform/<br/>
## Step 6: mount EFS to store assets
sudo apt-get update<br/>

View File

@ -7,7 +7,7 @@ EXPOSE 7000
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update
RUN apt-get update
RUN apt-get -y install curl net-tools jq netcat unzip wget git vim fail2ban imagemagick-6.q16 ffmpeg build-essential sqlite3 npm
@ -20,8 +20,8 @@ RUN n stable
RUN mkdir /app
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then ARCHITECTURE=amd64; elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCHITECTURE=arm64; elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCHITECTURE=aarch64; else ARCHITECTURE=unsupported; fi \
&& wget -P /app https://go.dev/dl/go1.18.10.linux-${ARCHITECTURE}.tar.gz \
&& tar -C /usr/local -xzf /app/go1.18.10.linux-${ARCHITECTURE}.tar.gz
&& wget -P /app https://go.dev/dl/go1.22.2.linux-${ARCHITECTURE}.tar.gz \
&& tar -C /usr/local -xzf /app/go1.22.2.linux-${ARCHITECTURE}.tar.gz
RUN git clone https://github.com/balzack/databag.git /app/databag
@ -57,7 +57,7 @@ RUN npm uninstall -g n
RUN rm -rf /usr/local/n
RUN rm -rf /usr/local/bin/node
RUN apt-get -y remove git build-essential npm vim nodejs
RUN apt-get -y remove git build-essential npm vim nodejs linux-libc-dev
RUN rm -rf /var/lib/apt/lists
FROM scratch

View File

@ -1,10 +0,0 @@
version: "3.9"
services:
databag:
container_name: databag
image: balzack/databag:latest
ports:
- "7000:7000"
volumes:
- ./databag-data:/var/lib/databag

View File

@ -1,6 +1,6 @@
cd /root
wget -P /app https://go.dev/dl/go1.18.10.linux-amd64.tar.gz
tar -C /usr/local -xzf /app/go1.18.10.linux-amd64.tar.gz
wget -P /app https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
tar -C /usr/local -xzf /app/go1.22.2.linux-amd64.tar.gz
apt-get update
apt-get -y install git build-essential npm vim

Some files were not shown because too many files have changed in this diff Show More