@rpcbase/client 0.49.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppProvider/index.web.js +8 -0
- package/auth/SignIn/index.js +4 -0
- package/auth/SignOut/index.js +5 -0
- package/auth/SignUp/index.js +5 -0
- package/base_url.js +16 -0
- package/helpers/post.js +1 -1
- package/package.json +1 -1
- package/rpc_post.js +1 -1
- package/rts/index.js +1 -1
package/auth/SignIn/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import page from "page"
|
|
|
6
6
|
import debug from "debug"
|
|
7
7
|
|
|
8
8
|
import post from "../../helpers/post"
|
|
9
|
+
import {reconnect as rts_reconnect} from "../../rts"
|
|
9
10
|
|
|
10
11
|
import {set_is_signed_in, set_uid} from "../index"
|
|
11
12
|
import Footer from "../Footer"
|
|
@@ -53,6 +54,9 @@ const SignIn = ({
|
|
|
53
54
|
log("redirect to:", redirect || onSuccessRedirect)
|
|
54
55
|
set_uid(res.user_id)
|
|
55
56
|
set_is_signed_in(true)
|
|
57
|
+
|
|
58
|
+
// we must now reconnect on the websocket as we now have a new cookie
|
|
59
|
+
rts_reconnect()
|
|
56
60
|
onSuccess()
|
|
57
61
|
if (redirect) {
|
|
58
62
|
page(redirect)
|
package/auth/SignOut/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import post from "../../helpers/post"
|
|
|
7
7
|
|
|
8
8
|
import {set_is_signed_in, set_uid} from "../index"
|
|
9
9
|
|
|
10
|
+
// TODO: rts_disconnect
|
|
11
|
+
// TODO: clear cache + db
|
|
10
12
|
|
|
11
13
|
const SignOut = ({
|
|
12
14
|
onSuccess = () => null
|
|
@@ -21,6 +23,9 @@ const SignOut = ({
|
|
|
21
23
|
set_uid(null)
|
|
22
24
|
set_is_signed_in(false)
|
|
23
25
|
localStorage.clear()
|
|
26
|
+
|
|
27
|
+
// TODO: clear DB
|
|
28
|
+
|
|
24
29
|
setIsSignedOut(true)
|
|
25
30
|
onSuccess()
|
|
26
31
|
} else {
|
package/auth/SignUp/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import {useState} from "react"
|
|
3
3
|
import page from "page"
|
|
4
4
|
|
|
5
|
+
import {reconnect as rts_reconnect} from "../../rts"
|
|
6
|
+
|
|
5
7
|
import {set_is_signed_in, set_uid} from "../index"
|
|
6
8
|
import post from "../../helpers/post"
|
|
7
9
|
import Footer from "../Footer"
|
|
@@ -29,6 +31,9 @@ const SignUp = ({
|
|
|
29
31
|
if (res.status === "ok") {
|
|
30
32
|
set_uid(res.user_id)
|
|
31
33
|
set_is_signed_in(true)
|
|
34
|
+
|
|
35
|
+
// we must now reconnect on the websocket as we now have a new cookie
|
|
36
|
+
rts_reconnect()
|
|
32
37
|
onSuccess()
|
|
33
38
|
page(onSuccessRedirect)
|
|
34
39
|
} else if (res.status === "error") {
|
package/base_url.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
import axios from "axios"
|
|
3
|
+
|
|
4
|
+
import {SERVER_PORT, HOSTNAME} from "env"
|
|
5
|
+
|
|
6
|
+
const protocol = (typeof window !== "undefined" && window?.location?.protocol) || "http:"
|
|
7
|
+
|
|
8
|
+
// there is no SERVER_PORT in production, as we use the default port and we are behind the gateway
|
|
9
|
+
// we assume we specify the port only when localhost or 127.0.0.1
|
|
10
|
+
const is_local = ["localhost", "127.0.0.1"].includes(HOSTNAME)
|
|
11
|
+
|
|
12
|
+
const BASE_URL = is_local ? `${protocol}//${HOSTNAME}:${SERVER_PORT}` : `https://${HOSTNAME}`
|
|
13
|
+
|
|
14
|
+
console.log("HOST", HOSTNAME, BASE_URL)
|
|
15
|
+
|
|
16
|
+
export default BASE_URL
|
package/helpers/post.js
CHANGED
package/package.json
CHANGED
package/rpc_post.js
CHANGED
|
@@ -7,7 +7,7 @@ import _set from "lodash/set"
|
|
|
7
7
|
import get_txn_id from "@rpcbase/std/get_txn_id"
|
|
8
8
|
import {add_local_txn} from "@rpcbase/client/rts"
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import BASE_URL from "./base_url"
|
|
11
11
|
|
|
12
12
|
const client = axios.create({
|
|
13
13
|
withCredentials: true,
|