@vuu-ui/vuu-data-react 1.0.1 → 1.0.3
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/cjs/datasource-provider/useAutoLoginToVuuServer.js +5 -3
- package/cjs/datasource-provider/useAutoLoginToVuuServer.js.map +1 -1
- package/esm/datasource-provider/useAutoLoginToVuuServer.js +5 -3
- package/esm/datasource-provider/useAutoLoginToVuuServer.js.map +1 -1
- package/package.json +14 -14
- package/types/datasource-provider/useAutoLoginToVuuServer.d.ts +14 -1
|
@@ -9,15 +9,17 @@ const useAutoLoginToVuuServer = ({
|
|
|
9
9
|
autoConnect = true,
|
|
10
10
|
// autoLogin = true,
|
|
11
11
|
secure = true,
|
|
12
|
+
token: tokenProp = "no-token",
|
|
13
|
+
user = "steve",
|
|
12
14
|
websocketUrl
|
|
13
15
|
} = {}) => {
|
|
14
16
|
const [errorMessage, setErrorMessage] = react.useState("");
|
|
15
17
|
react.useEffect(() => {
|
|
16
18
|
const connect = async () => {
|
|
17
19
|
try {
|
|
18
|
-
let token =
|
|
20
|
+
let token = tokenProp;
|
|
19
21
|
if (authenticate) {
|
|
20
|
-
const response = await vuuDataRemote.authenticate(
|
|
22
|
+
const response = await vuuDataRemote.authenticate(user, "xyz", "/api/authn");
|
|
21
23
|
token = response.token;
|
|
22
24
|
}
|
|
23
25
|
const url = websocketUrl ?? `${secure ? "wss" : "ws"}://localhost/8090/websocket`;
|
|
@@ -40,7 +42,7 @@ const useAutoLoginToVuuServer = ({
|
|
|
40
42
|
vuuDataRemote.ConnectionManager.disconnect();
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
|
-
}, [authenticate, autoConnect, secure, websocketUrl]);
|
|
45
|
+
}, [authenticate, autoConnect, secure, tokenProp, user, websocketUrl]);
|
|
44
46
|
if (errorMessage) {
|
|
45
47
|
return /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Unable to authenticate against Vuu Server A Vuu Server instance must be running to show this example." });
|
|
46
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n websocketUrl,\n}: {\n authenticate?: boolean;\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token =
|
|
1
|
+
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n token: tokenProp = \"no-token\",\n user = \"steve\",\n websocketUrl,\n}: {\n /**\n * if true, auth url on vuuserver will be used to get token\n * auth url is \"/api/authn\"\n */\n authenticate?: boolean;\n /**\n * true by default, will go ahead and open websocket connection\n */\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n /**\n * use with no authenticate step, to provide auth token.\n * Used when vuu server is performing no token check\n */\n token?: string;\n user?: string;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token = tokenProp;\n if (authenticate) {\n const response = await vuuAuthenticate(user, \"xyz\", \"/api/authn\");\n token = response.token;\n }\n\n const url =\n websocketUrl ?? `${secure ? \"wss\" : \"ws\"}://localhost/8090/websocket`;\n\n ConnectionManager.connect({\n url,\n token,\n });\n } catch (e: unknown) {\n if (e instanceof Error) {\n console.error(e.message);\n setErrorMessage(e.message);\n }\n }\n };\n if (autoConnect) {\n connect();\n }\n\n return () => {\n if (autoConnect) {\n ConnectionManager.disconnect();\n }\n };\n }, [authenticate, autoConnect, secure, tokenProp, user, websocketUrl]);\n\n if (errorMessage) {\n return (\n <p>\n Unable to authenticate against Vuu Server A Vuu Server instance must be\n running to show this example.\n </p>\n );\n }\n};\n"],"names":["useState","useEffect","vuuAuthenticate","ConnectionManager","jsx"],"mappings":";;;;;;AAMO,MAAM,0BAA0B,CAAC;AAAA,EACtC,YAAe,GAAA,IAAA;AAAA,EACf,WAAc,GAAA,IAAA;AAAA;AAAA,EAEd,MAAS,GAAA,IAAA;AAAA,EACT,OAAO,SAAY,GAAA,UAAA;AAAA,EACnB,IAAO,GAAA,OAAA;AAAA,EACP;AACF,CAAA,GAmBI,EAAO,KAAA;AACT,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAIA,eAAS,EAAE,CAAA;AACnD,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,YAAY;AAC1B,MAAI,IAAA;AACF,QAAA,IAAI,KAAQ,GAAA,SAAA;AACZ,QAAA,IAAI,YAAc,EAAA;AAChB,UAAA,MAAM,QAAW,GAAA,MAAMC,0BAAgB,CAAA,IAAA,EAAM,OAAO,YAAY,CAAA;AAChE,UAAA,KAAA,GAAQ,QAAS,CAAA,KAAA;AAAA;AAGnB,QAAA,MAAM,GACJ,GAAA,YAAA,IAAgB,CAAG,EAAA,MAAA,GAAS,QAAQ,IAAI,CAAA,2BAAA,CAAA;AAE1C,QAAAC,+BAAA,CAAkB,OAAQ,CAAA;AAAA,UACxB,GAAA;AAAA,UACA;AAAA,SACD,CAAA;AAAA,eACM,CAAY,EAAA;AACnB,QAAA,IAAI,aAAa,KAAO,EAAA;AACtB,UAAQ,OAAA,CAAA,KAAA,CAAM,EAAE,OAAO,CAAA;AACvB,UAAA,eAAA,CAAgB,EAAE,OAAO,CAAA;AAAA;AAC3B;AACF,KACF;AACA,IAAA,IAAI,WAAa,EAAA;AACf,MAAQ,OAAA,EAAA;AAAA;AAGV,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,WAAa,EAAA;AACf,QAAAA,+BAAA,CAAkB,UAAW,EAAA;AAAA;AAC/B,KACF;AAAA,GACF,EAAG,CAAC,YAAc,EAAA,WAAA,EAAa,QAAQ,SAAW,EAAA,IAAA,EAAM,YAAY,CAAC,CAAA;AAErE,EAAA,IAAI,YAAc,EAAA;AAChB,IACE,uBAAAC,cAAA,CAAC,OAAE,QAGH,EAAA,uGAAA,EAAA,CAAA;AAAA;AAGN;;;;"}
|
|
@@ -7,15 +7,17 @@ const useAutoLoginToVuuServer = ({
|
|
|
7
7
|
autoConnect = true,
|
|
8
8
|
// autoLogin = true,
|
|
9
9
|
secure = true,
|
|
10
|
+
token: tokenProp = "no-token",
|
|
11
|
+
user = "steve",
|
|
10
12
|
websocketUrl
|
|
11
13
|
} = {}) => {
|
|
12
14
|
const [errorMessage, setErrorMessage] = useState("");
|
|
13
15
|
useEffect(() => {
|
|
14
16
|
const connect = async () => {
|
|
15
17
|
try {
|
|
16
|
-
let token =
|
|
18
|
+
let token = tokenProp;
|
|
17
19
|
if (authenticate$1) {
|
|
18
|
-
const response = await authenticate(
|
|
20
|
+
const response = await authenticate(user, "xyz", "/api/authn");
|
|
19
21
|
token = response.token;
|
|
20
22
|
}
|
|
21
23
|
const url = websocketUrl ?? `${secure ? "wss" : "ws"}://localhost/8090/websocket`;
|
|
@@ -38,7 +40,7 @@ const useAutoLoginToVuuServer = ({
|
|
|
38
40
|
ConnectionManager.disconnect();
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
|
-
}, [authenticate$1, autoConnect, secure, websocketUrl]);
|
|
43
|
+
}, [authenticate$1, autoConnect, secure, tokenProp, user, websocketUrl]);
|
|
42
44
|
if (errorMessage) {
|
|
43
45
|
return /* @__PURE__ */ jsx("p", { children: "Unable to authenticate against Vuu Server A Vuu Server instance must be running to show this example." });
|
|
44
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n websocketUrl,\n}: {\n authenticate?: boolean;\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token =
|
|
1
|
+
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n token: tokenProp = \"no-token\",\n user = \"steve\",\n websocketUrl,\n}: {\n /**\n * if true, auth url on vuuserver will be used to get token\n * auth url is \"/api/authn\"\n */\n authenticate?: boolean;\n /**\n * true by default, will go ahead and open websocket connection\n */\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n /**\n * use with no authenticate step, to provide auth token.\n * Used when vuu server is performing no token check\n */\n token?: string;\n user?: string;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token = tokenProp;\n if (authenticate) {\n const response = await vuuAuthenticate(user, \"xyz\", \"/api/authn\");\n token = response.token;\n }\n\n const url =\n websocketUrl ?? `${secure ? \"wss\" : \"ws\"}://localhost/8090/websocket`;\n\n ConnectionManager.connect({\n url,\n token,\n });\n } catch (e: unknown) {\n if (e instanceof Error) {\n console.error(e.message);\n setErrorMessage(e.message);\n }\n }\n };\n if (autoConnect) {\n connect();\n }\n\n return () => {\n if (autoConnect) {\n ConnectionManager.disconnect();\n }\n };\n }, [authenticate, autoConnect, secure, tokenProp, user, websocketUrl]);\n\n if (errorMessage) {\n return (\n <p>\n Unable to authenticate against Vuu Server A Vuu Server instance must be\n running to show this example.\n </p>\n );\n }\n};\n"],"names":["authenticate","vuuAuthenticate"],"mappings":";;;;AAMO,MAAM,0BAA0B,CAAC;AAAA,gBACtCA,cAAe,GAAA,IAAA;AAAA,EACf,WAAc,GAAA,IAAA;AAAA;AAAA,EAEd,MAAS,GAAA,IAAA;AAAA,EACT,OAAO,SAAY,GAAA,UAAA;AAAA,EACnB,IAAO,GAAA,OAAA;AAAA,EACP;AACF,CAAA,GAmBI,EAAO,KAAA;AACT,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAS,EAAE,CAAA;AACnD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,YAAY;AAC1B,MAAI,IAAA;AACF,QAAA,IAAI,KAAQ,GAAA,SAAA;AACZ,QAAA,IAAIA,cAAc,EAAA;AAChB,UAAA,MAAM,QAAW,GAAA,MAAMC,YAAgB,CAAA,IAAA,EAAM,OAAO,YAAY,CAAA;AAChE,UAAA,KAAA,GAAQ,QAAS,CAAA,KAAA;AAAA;AAGnB,QAAA,MAAM,GACJ,GAAA,YAAA,IAAgB,CAAG,EAAA,MAAA,GAAS,QAAQ,IAAI,CAAA,2BAAA,CAAA;AAE1C,QAAA,iBAAA,CAAkB,OAAQ,CAAA;AAAA,UACxB,GAAA;AAAA,UACA;AAAA,SACD,CAAA;AAAA,eACM,CAAY,EAAA;AACnB,QAAA,IAAI,aAAa,KAAO,EAAA;AACtB,UAAQ,OAAA,CAAA,KAAA,CAAM,EAAE,OAAO,CAAA;AACvB,UAAA,eAAA,CAAgB,EAAE,OAAO,CAAA;AAAA;AAC3B;AACF,KACF;AACA,IAAA,IAAI,WAAa,EAAA;AACf,MAAQ,OAAA,EAAA;AAAA;AAGV,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,WAAa,EAAA;AACf,QAAA,iBAAA,CAAkB,UAAW,EAAA;AAAA;AAC/B,KACF;AAAA,GACF,EAAG,CAACD,cAAc,EAAA,WAAA,EAAa,QAAQ,SAAW,EAAA,IAAA,EAAM,YAAY,CAAC,CAAA;AAErE,EAAA,IAAI,YAAc,EAAA;AAChB,IACE,uBAAA,GAAA,CAAC,OAAE,QAGH,EAAA,uGAAA,EAAA,CAAA;AAAA;AAGN;;;;"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.3",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@vuu-ui/vuu-data-types": "1.0.
|
|
7
|
-
"@vuu-ui/vuu-filter-types": "1.0.
|
|
8
|
-
"@vuu-ui/vuu-protocol-types": "1.0.
|
|
9
|
-
"@vuu-ui/vuu-table-types": "1.0.
|
|
6
|
+
"@vuu-ui/vuu-data-types": "1.0.3",
|
|
7
|
+
"@vuu-ui/vuu-filter-types": "1.0.3",
|
|
8
|
+
"@vuu-ui/vuu-protocol-types": "1.0.3",
|
|
9
|
+
"@vuu-ui/vuu-table-types": "1.0.3"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@vuu-ui/vuu-context-menu": "1.0.
|
|
13
|
-
"@vuu-ui/vuu-data-remote": "1.0.
|
|
14
|
-
"@vuu-ui/vuu-filter-parser": "1.0.
|
|
15
|
-
"@vuu-ui/vuu-filters": "1.0.
|
|
16
|
-
"@vuu-ui/vuu-layout": "1.0.
|
|
17
|
-
"@vuu-ui/vuu-notifications": "1.0.
|
|
18
|
-
"@vuu-ui/vuu-ui-controls": "1.0.
|
|
19
|
-
"@vuu-ui/vuu-utils": "1.0.
|
|
20
|
-
"@vuu-ui/vuu-table": "1.0.
|
|
12
|
+
"@vuu-ui/vuu-context-menu": "1.0.3",
|
|
13
|
+
"@vuu-ui/vuu-data-remote": "1.0.3",
|
|
14
|
+
"@vuu-ui/vuu-filter-parser": "1.0.3",
|
|
15
|
+
"@vuu-ui/vuu-filters": "1.0.3",
|
|
16
|
+
"@vuu-ui/vuu-layout": "1.0.3",
|
|
17
|
+
"@vuu-ui/vuu-notifications": "1.0.3",
|
|
18
|
+
"@vuu-ui/vuu-ui-controls": "1.0.3",
|
|
19
|
+
"@vuu-ui/vuu-utils": "1.0.3",
|
|
20
|
+
"@vuu-ui/vuu-table": "1.0.3",
|
|
21
21
|
"@salt-ds/core": "1.54.1",
|
|
22
22
|
"@salt-ds/styles": "0.2.1",
|
|
23
23
|
"@salt-ds/window": "0.1.1"
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
export declare const useAutoLoginToVuuServer: ({ authenticate, autoConnect, secure, websocketUrl, }?: {
|
|
1
|
+
export declare const useAutoLoginToVuuServer: ({ authenticate, autoConnect, secure, token: tokenProp, user, websocketUrl, }?: {
|
|
2
|
+
/**
|
|
3
|
+
* if true, auth url on vuuserver will be used to get token
|
|
4
|
+
* auth url is "/api/authn"
|
|
5
|
+
*/
|
|
2
6
|
authenticate?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* true by default, will go ahead and open websocket connection
|
|
9
|
+
*/
|
|
3
10
|
autoConnect?: boolean;
|
|
4
11
|
autoLogin?: boolean;
|
|
5
12
|
secure?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* use with no authenticate step, to provide auth token.
|
|
15
|
+
* Used when vuu server is performing no token check
|
|
16
|
+
*/
|
|
17
|
+
token?: string;
|
|
18
|
+
user?: string;
|
|
6
19
|
websocketUrl?: string;
|
|
7
20
|
}) => import("react/jsx-runtime").JSX.Element | undefined;
|