@rpcbase/client 0.96.0 → 0.98.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.
@@ -0,0 +1,11 @@
1
+ /* @flow */
2
+
3
+ const redirect_sign_in = (ctx) => {
4
+ console.log("REDIRECT SIGN IN NYI NATIVE")
5
+ console.log("CTX", ctx)
6
+
7
+ // const redirect_path = ctx.canonicalPath
8
+ // page.redirect(`/signin?redirect=${encodeURIComponent(redirect_path)}`)
9
+ }
10
+
11
+ export default redirect_sign_in
@@ -0,0 +1,9 @@
1
+ /* @flow */
2
+ import page from "page"
3
+
4
+ const redirect_sign_in = (ctx) => {
5
+ const redirect_path = ctx.canonicalPath
6
+ page.redirect(`/signin?redirect=${encodeURIComponent(redirect_path)}`)
7
+ }
8
+
9
+ export default redirect_sign_in
package/auth/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  /* @flow */
2
- import page from "page"
3
2
  import debug from "debug"
3
+ import {Platform} from "react-native"
4
4
  import isHexadecimal from "validator/lib/isHexadecimal"
5
5
 
6
6
  import {disconnect as rts_disconnect} from "../rts"
7
7
  import post from "../helpers/post"
8
8
 
9
+ import redirect_sign_in from "./helpers/redirect_sign_in"
10
+
9
11
  const LAST_TENANT_KEY = "rb.last_tenant_id"
10
12
  const uid_storage_key = (tenant_id) => `rb.${tenant_id}.user_id`
11
13
 
@@ -31,6 +33,12 @@ const get_querystring_auth_id = () => {
31
33
 
32
34
 
33
35
  const run_session_check = async() => {
36
+ // TODO: TMP: we're skipping the session check on mobile for now,
37
+ // this assumes having a token on mobile means we're authenticated
38
+ if (Platform.OS !== "web") {
39
+ return
40
+ }
41
+
34
42
  const auth_user_id = get_querystring_auth_id()
35
43
 
36
44
  if (auth_user_id) {
@@ -66,15 +74,9 @@ const run_session_check = async() => {
66
74
  }
67
75
  }
68
76
 
69
- // Force trigger run first session check (when we are not in a webworker)
70
- if (typeof window !== "undefined") run_session_check()
71
77
 
72
- // manually run first check
73
- // TODO: this should come from localStorage
74
- const redirect_sign_in = (ctx) => {
75
- const redirect_path = ctx.canonicalPath
76
- page.redirect(`/signin?redirect=${encodeURIComponent(redirect_path)}`)
77
- }
78
+ // Force trigger run first session check (when we are not in a webworker (or mobile))
79
+ if (typeof window !== "undefined") run_session_check()
78
80
 
79
81
 
80
82
  export const session_restrict = (ctx, next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.96.0",
3
+ "version": "0.98.0",
4
4
  "scripts": {
5
5
  "build-firebase": "webpack -c firebase/webpack.config.js",
6
6
  "build": "yarn build-firebase",