mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 11:26:24 +00:00
7b8fcb3285
* Add android build workflow
* Initial webview on tsx template
* Insert ReactJS app from local
* Add Android app icon by @red_purdy (#174)
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
Co-authored-by: RedPurdy <104675727+RedPurdy@users.noreply.github.com>
* Fix local reactjs
* Add setup guide. Bundled dev main.js
* Add react native tor
* Move Android CHANGELOG.md to /mobile
* Add torified webview in react-native (#247)
* Add android build workflow
* Android Tor Requests
* Fetching internal files (i18n)
* react-native-tor does not implement PUT
* Get Files from Tor
* Revert "Add android build workflow"
This reverts commit 340bcf8d1c
.
* Fix Rebase Removals
* External sources
* react-native-tor crashes
* Last Refactor
* Fix/revert setup guide
* Add /mobile as volume to npm-dev container
On the fully dockerized dev environment the npm process cannot save files outside of /frontend directory. Now it can also save the builds to /mobile
* Fix UsafeAlert
* Run prettier
* Run lint:fix
* Main Profile Image fix
* Remove Tor Requests limitation
Co-authored-by: Reckless_Satoshi <reckless.satoshi@protonmail.com>
Co-authored-by: RedPurdy <104675727+RedPurdy@users.noreply.github.com>
Co-authored-by: KoalaSat <yv1vtrul@duck.com>
88 lines
2.1 KiB
TypeScript
88 lines
2.1 KiB
TypeScript
import Tor from 'react-native-tor';
|
|
|
|
class TorClient {
|
|
baseUrl: string;
|
|
daemon: ReturnType<typeof Tor>;
|
|
|
|
constructor() {
|
|
this.baseUrl = 'http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion';
|
|
this.daemon = Tor({
|
|
stopDaemonOnBackground: false,
|
|
numberConcurrentRequests: 0,
|
|
});
|
|
}
|
|
|
|
public startDaemon = async () => {
|
|
await this.daemon.startIfNotStarted();
|
|
};
|
|
|
|
public get: (path: string) => Promise<object> = async (path) => {
|
|
await this.startDaemon();
|
|
|
|
return await new Promise<object>(async (resolve, reject) => {
|
|
try {
|
|
const response = await this.daemon.get(`${this.baseUrl}${path}`);
|
|
|
|
resolve(response.json);
|
|
} catch (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
};
|
|
|
|
public delete: (path: string, headers: object) => Promise<object> = async (path, headers) => {
|
|
await this.startDaemon();
|
|
|
|
return await new Promise<object>(async (resolve, reject) => {
|
|
try {
|
|
const response = await this.daemon.delete(`${this.baseUrl}${path}`, '', headers);
|
|
|
|
resolve(response.json);
|
|
} catch (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
};
|
|
|
|
public request: (path: string) => Promise<object> = async (path) => {
|
|
await this.startDaemon();
|
|
|
|
return await new Promise<object>(async (resolve, reject) => {
|
|
try {
|
|
const response = await this.daemon
|
|
.request(`${this.baseUrl}${path}`, 'GET', '', {}, true)
|
|
.then((resp) => {
|
|
resolve(resp);
|
|
});
|
|
|
|
resolve(response);
|
|
} catch (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
};
|
|
|
|
public post: (path: string, body: object, headers: object) => Promise<object> = async (
|
|
path,
|
|
body,
|
|
headers,
|
|
) => {
|
|
await this.startDaemon();
|
|
|
|
return await new Promise<object>(async (resolve, reject) => {
|
|
try {
|
|
const json = JSON.stringify(body);
|
|
const response = await this.daemon.post(`${this.baseUrl}${path}`, json, headers);
|
|
|
|
resolve(response.json);
|
|
} catch (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
};
|
|
}
|
|
|
|
export const torClient = new TorClient();
|
|
|
|
export default TorClient;
|