quidproquo-web-react 0.0.239 → 0.0.241
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/lib/commonjs/auth/RefreshAuthTokensProvider.d.ts +8 -0
- package/lib/commonjs/auth/RefreshAuthTokensProvider.js +12 -0
- package/lib/commonjs/auth/hooks/useRefreshTokens.d.ts +2 -2
- package/lib/commonjs/auth/hooks/useRefreshTokens.js +8 -7
- package/lib/commonjs/auth/index.d.ts +1 -0
- package/lib/commonjs/auth/index.js +1 -0
- package/lib/commonjs/hooks/useRunEvery.d.ts +1 -1
- package/lib/commonjs/hooks/useRunEvery.js +3 -3
- package/lib/commonjs/index.d.ts +1 -0
- package/lib/commonjs/index.js +1 -0
- package/lib/commonjs/webSocketQueue/hooks/index.d.ts +2 -0
- package/lib/commonjs/webSocketQueue/hooks/index.js +18 -0
- package/lib/commonjs/webSocketQueue/hooks/useSubscribeToWebSocketQueueEvent.d.ts +3 -0
- package/lib/commonjs/webSocketQueue/hooks/useSubscribeToWebSocketQueueEvent.js +8 -0
- package/lib/commonjs/webSocketQueue/hooks/useWebsocketQueueSendEvent.d.ts +2 -0
- package/lib/commonjs/webSocketQueue/hooks/useWebsocketQueueSendEvent.js +9 -0
- package/lib/commonjs/webSocketQueue/index.d.ts +1 -0
- package/lib/commonjs/webSocketQueue/index.js +17 -0
- package/lib/commonjs/websocket/WebSocketAuthSync/hooks/useWebsocketAuthSync.js +2 -2
- package/lib/commonjs/websocket/WebSocketAuthSync/hooks/useWebsocketPingPong.js +8 -13
- package/lib/commonjs/websocket/hooks/useWebsocketSendEvent.d.ts +1 -1
- package/lib/esm/auth/RefreshAuthTokensProvider.d.ts +8 -0
- package/lib/esm/auth/RefreshAuthTokensProvider.js +9 -0
- package/lib/esm/auth/hooks/useRefreshTokens.d.ts +2 -2
- package/lib/esm/auth/hooks/useRefreshTokens.js +8 -7
- package/lib/esm/auth/index.d.ts +1 -0
- package/lib/esm/auth/index.js +1 -0
- package/lib/esm/hooks/useRunEvery.d.ts +1 -1
- package/lib/esm/hooks/useRunEvery.js +3 -3
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/webSocketQueue/hooks/index.d.ts +2 -0
- package/lib/esm/webSocketQueue/hooks/index.js +2 -0
- package/lib/esm/webSocketQueue/hooks/useSubscribeToWebSocketQueueEvent.d.ts +3 -0
- package/lib/esm/webSocketQueue/hooks/useSubscribeToWebSocketQueueEvent.js +4 -0
- package/lib/esm/webSocketQueue/hooks/useWebsocketQueueSendEvent.d.ts +2 -0
- package/lib/esm/webSocketQueue/hooks/useWebsocketQueueSendEvent.js +5 -0
- package/lib/esm/webSocketQueue/index.d.ts +1 -0
- package/lib/esm/webSocketQueue/index.js +1 -0
- package/lib/esm/websocket/WebSocketAuthSync/hooks/useWebsocketAuthSync.js +3 -3
- package/lib/esm/websocket/WebSocketAuthSync/hooks/useWebsocketPingPong.js +7 -12
- package/lib/esm/websocket/hooks/useWebsocketSendEvent.d.ts +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AuthenticationInfo } from 'quidproquo-core';
|
|
3
|
+
export type RefreshAuthTokensProviderProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
authenticationInfo?: AuthenticationInfo;
|
|
6
|
+
refreshTokens: (authenticationInfo: AuthenticationInfo) => Promise<any>;
|
|
7
|
+
};
|
|
8
|
+
export declare const RefreshAuthTokensProvider: import("react").NamedExoticComponent<RefreshAuthTokensProviderProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RefreshAuthTokensProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const hooks_1 = require("./hooks");
|
|
7
|
+
const RefreshAuthTokensProviderComponent = ({ children, authenticationInfo, refreshTokens }) => {
|
|
8
|
+
(0, hooks_1.useRefreshTokens)(authenticationInfo, refreshTokens);
|
|
9
|
+
// This fragment is not useless!
|
|
10
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
11
|
+
};
|
|
12
|
+
exports.RefreshAuthTokensProvider = (0, react_1.memo)(RefreshAuthTokensProviderComponent);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useRefreshTokens: (
|
|
1
|
+
import { AuthenticationInfo } from 'quidproquo-core';
|
|
2
|
+
export declare const useRefreshTokens: (authenticationInfo: AuthenticationInfo | undefined, refreshTokens: (authenticationInfo: AuthenticationInfo) => Promise<any>) => void;
|
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRefreshTokens = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const useRefreshTokens = (
|
|
5
|
+
const useRefreshTokens = (authenticationInfo, refreshTokens) => {
|
|
6
6
|
const refresh = () => {
|
|
7
|
-
|
|
8
|
-
if (refreshToken && expiresAt) {
|
|
7
|
+
if (authenticationInfo && authenticationInfo.refreshToken && authenticationInfo.expiresAt) {
|
|
9
8
|
const now = new Date().toISOString();
|
|
10
|
-
const timeToExpire = new Date(expiresAt).getTime() - new Date(now).getTime();
|
|
9
|
+
const timeToExpire = new Date(authenticationInfo.expiresAt).getTime() - new Date(now).getTime();
|
|
11
10
|
// Refresh the token 10 minutes before it expires to ensure there's a buffer
|
|
12
11
|
const bufferTime = 10 * 60 * 1000;
|
|
13
12
|
const refreshTime = timeToExpire - bufferTime;
|
|
14
13
|
if (refreshTime > 0) {
|
|
15
|
-
return setTimeout(() =>
|
|
14
|
+
return setTimeout(() => {
|
|
15
|
+
refreshTokens(authenticationInfo);
|
|
16
|
+
}, refreshTime);
|
|
16
17
|
}
|
|
17
18
|
else {
|
|
18
19
|
// If the token is already expired or very close to expiration, refresh immediately
|
|
19
|
-
refreshTokens(
|
|
20
|
+
refreshTokens(authenticationInfo);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
return null;
|
|
@@ -29,6 +30,6 @@ const useRefreshTokens = (authState, refreshTokens) => {
|
|
|
29
30
|
clearTimeout(timerId);
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
|
-
}, [
|
|
33
|
+
}, [authenticationInfo, refreshTokens]);
|
|
33
34
|
};
|
|
34
35
|
exports.useRefreshTokens = useRefreshTokens;
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./authContext"), exports);
|
|
18
18
|
__exportStar(require("./hooks"), exports);
|
|
19
|
+
__exportStar(require("./RefreshAuthTokensProvider"), exports);
|
|
19
20
|
__exportStar(require("./types"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useRunEvery<T>(func: () => T,
|
|
1
|
+
export declare function useRunEvery<T>(func: () => T, intervalSeconds: number): T;
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRunEvery = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
function useRunEvery(func,
|
|
5
|
+
function useRunEvery(func, intervalSeconds) {
|
|
6
6
|
const [value, setValue] = (0, react_1.useState)(func);
|
|
7
7
|
const intervalRef = (0, react_1.useRef)(null);
|
|
8
8
|
(0, react_1.useEffect)(() => {
|
|
9
9
|
intervalRef.current = window.setInterval(() => {
|
|
10
10
|
const newValue = func();
|
|
11
11
|
setValue(newValue);
|
|
12
|
-
},
|
|
12
|
+
}, intervalSeconds * 1000);
|
|
13
13
|
return () => {
|
|
14
14
|
if (intervalRef.current !== null) {
|
|
15
15
|
window.clearInterval(intervalRef.current);
|
|
16
16
|
intervalRef.current = null;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
}, [
|
|
19
|
+
}, [intervalSeconds]);
|
|
20
20
|
return value;
|
|
21
21
|
}
|
|
22
22
|
exports.useRunEvery = useRunEvery;
|
package/lib/commonjs/index.d.ts
CHANGED
package/lib/commonjs/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useSubscribeToWebSocketQueueEvent"), exports);
|
|
18
|
+
__exportStar(require("./useWebsocketQueueSendEvent"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { WebSocketServiceEventSubscriptionFunction } from 'quidproquo-web';
|
|
2
|
+
import { AnyWebSocketQueueEventMessageWithCorrelation } from 'quidproquo-webserver';
|
|
3
|
+
export declare const useSubscribeToWebSocketQueueEvent: <E extends AnyWebSocketQueueEventMessageWithCorrelation>(subscriptionType: E["type"], callback: WebSocketServiceEventSubscriptionFunction<E>) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSubscribeToWebSocketQueueEvent = void 0;
|
|
4
|
+
const websocket_1 = require("../../websocket");
|
|
5
|
+
const useSubscribeToWebSocketQueueEvent = (subscriptionType, callback) => {
|
|
6
|
+
(0, websocket_1.useSubscribeToWebSocketEvent)(subscriptionType, callback);
|
|
7
|
+
};
|
|
8
|
+
exports.useSubscribeToWebSocketQueueEvent = useSubscribeToWebSocketQueueEvent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWebsocketQueueSendEvent = void 0;
|
|
4
|
+
const websocket_1 = require("../../websocket");
|
|
5
|
+
const useWebsocketQueueSendEvent = () => {
|
|
6
|
+
const sendMessage = (0, websocket_1.useWebsocketSendEvent)();
|
|
7
|
+
return sendMessage;
|
|
8
|
+
};
|
|
9
|
+
exports.useWebsocketQueueSendEvent = useWebsocketQueueSendEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hooks';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./hooks"), exports);
|
|
@@ -15,7 +15,7 @@ const useWebsocketAuthSync = (accessToken) => {
|
|
|
15
15
|
}
|
|
16
16
|
if (accessToken) {
|
|
17
17
|
const authMessage = {
|
|
18
|
-
type: quidproquo_webserver_1.
|
|
18
|
+
type: quidproquo_webserver_1.WebSocketQueueClientMessageEventType.Authenticate,
|
|
19
19
|
payload: {
|
|
20
20
|
accessToken: accessToken,
|
|
21
21
|
},
|
|
@@ -24,7 +24,7 @@ const useWebsocketAuthSync = (accessToken) => {
|
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
const authMessage = {
|
|
27
|
-
type: quidproquo_webserver_1.
|
|
27
|
+
type: quidproquo_webserver_1.WebSocketQueueClientMessageEventType.Unauthenticate,
|
|
28
28
|
};
|
|
29
29
|
sendMessage(authMessage);
|
|
30
30
|
}
|
|
@@ -2,20 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useWebsocketPingPong = void 0;
|
|
4
4
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const hooks_1 = require("../../../hooks");
|
|
6
|
+
const hooks_2 = require("../../hooks");
|
|
7
7
|
const useWebsocketPingPong = () => {
|
|
8
|
-
const sendMessage = (0,
|
|
9
|
-
(0,
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
type: quidproquo_webserver_1.WebsocketClientMessageEventType.Ping,
|
|
13
|
-
};
|
|
14
|
-
sendMessage(pingEvent);
|
|
15
|
-
}, 8 * 60 * 1000);
|
|
16
|
-
return () => {
|
|
17
|
-
clearInterval(intervalId);
|
|
8
|
+
const sendMessage = (0, hooks_2.useWebsocketSendEvent)();
|
|
9
|
+
(0, hooks_1.useRunEvery)(() => {
|
|
10
|
+
const pingEvent = {
|
|
11
|
+
type: quidproquo_webserver_1.WebSocketQueueClientMessageEventType.Ping,
|
|
18
12
|
};
|
|
19
|
-
|
|
13
|
+
sendMessage(pingEvent);
|
|
14
|
+
}, 8 * 60);
|
|
20
15
|
};
|
|
21
16
|
exports.useWebsocketPingPong = useWebsocketPingPong;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnyEventMessage } from 'quidproquo-core';
|
|
2
|
-
export declare const useWebsocketSendEvent: () => (event:
|
|
2
|
+
export declare const useWebsocketSendEvent: <E extends AnyEventMessage = AnyEventMessage>() => (event: E) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AuthenticationInfo } from 'quidproquo-core';
|
|
3
|
+
export type RefreshAuthTokensProviderProps = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
authenticationInfo?: AuthenticationInfo;
|
|
6
|
+
refreshTokens: (authenticationInfo: AuthenticationInfo) => Promise<any>;
|
|
7
|
+
};
|
|
8
|
+
export declare const RefreshAuthTokensProvider: import("react").NamedExoticComponent<RefreshAuthTokensProviderProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { useRefreshTokens } from './hooks';
|
|
4
|
+
const RefreshAuthTokensProviderComponent = ({ children, authenticationInfo, refreshTokens }) => {
|
|
5
|
+
useRefreshTokens(authenticationInfo, refreshTokens);
|
|
6
|
+
// This fragment is not useless!
|
|
7
|
+
return _jsx(_Fragment, { children: children });
|
|
8
|
+
};
|
|
9
|
+
export const RefreshAuthTokensProvider = memo(RefreshAuthTokensProviderComponent);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useRefreshTokens: (
|
|
1
|
+
import { AuthenticationInfo } from 'quidproquo-core';
|
|
2
|
+
export declare const useRefreshTokens: (authenticationInfo: AuthenticationInfo | undefined, refreshTokens: (authenticationInfo: AuthenticationInfo) => Promise<any>) => void;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
export const useRefreshTokens = (
|
|
2
|
+
export const useRefreshTokens = (authenticationInfo, refreshTokens) => {
|
|
3
3
|
const refresh = () => {
|
|
4
|
-
|
|
5
|
-
if (refreshToken && expiresAt) {
|
|
4
|
+
if (authenticationInfo && authenticationInfo.refreshToken && authenticationInfo.expiresAt) {
|
|
6
5
|
const now = new Date().toISOString();
|
|
7
|
-
const timeToExpire = new Date(expiresAt).getTime() - new Date(now).getTime();
|
|
6
|
+
const timeToExpire = new Date(authenticationInfo.expiresAt).getTime() - new Date(now).getTime();
|
|
8
7
|
// Refresh the token 10 minutes before it expires to ensure there's a buffer
|
|
9
8
|
const bufferTime = 10 * 60 * 1000;
|
|
10
9
|
const refreshTime = timeToExpire - bufferTime;
|
|
11
10
|
if (refreshTime > 0) {
|
|
12
|
-
return setTimeout(() =>
|
|
11
|
+
return setTimeout(() => {
|
|
12
|
+
refreshTokens(authenticationInfo);
|
|
13
|
+
}, refreshTime);
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
15
16
|
// If the token is already expired or very close to expiration, refresh immediately
|
|
16
|
-
refreshTokens(
|
|
17
|
+
refreshTokens(authenticationInfo);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
return null;
|
|
@@ -26,5 +27,5 @@ export const useRefreshTokens = (authState, refreshTokens) => {
|
|
|
26
27
|
clearTimeout(timerId);
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
|
-
}, [
|
|
30
|
+
}, [authenticationInfo, refreshTokens]);
|
|
30
31
|
};
|
package/lib/esm/auth/index.d.ts
CHANGED
package/lib/esm/auth/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useRunEvery<T>(func: () => T,
|
|
1
|
+
export declare function useRunEvery<T>(func: () => T, intervalSeconds: number): T;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
export function useRunEvery(func,
|
|
2
|
+
export function useRunEvery(func, intervalSeconds) {
|
|
3
3
|
const [value, setValue] = useState(func);
|
|
4
4
|
const intervalRef = useRef(null);
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
intervalRef.current = window.setInterval(() => {
|
|
7
7
|
const newValue = func();
|
|
8
8
|
setValue(newValue);
|
|
9
|
-
},
|
|
9
|
+
}, intervalSeconds * 1000);
|
|
10
10
|
return () => {
|
|
11
11
|
if (intervalRef.current !== null) {
|
|
12
12
|
window.clearInterval(intervalRef.current);
|
|
13
13
|
intervalRef.current = null;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
}, [
|
|
16
|
+
}, [intervalSeconds]);
|
|
17
17
|
return value;
|
|
18
18
|
}
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { WebSocketServiceEventSubscriptionFunction } from 'quidproquo-web';
|
|
2
|
+
import { AnyWebSocketQueueEventMessageWithCorrelation } from 'quidproquo-webserver';
|
|
3
|
+
export declare const useSubscribeToWebSocketQueueEvent: <E extends AnyWebSocketQueueEventMessageWithCorrelation>(subscriptionType: E["type"], callback: WebSocketServiceEventSubscriptionFunction<E>) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hooks';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hooks';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebsocketServiceEvent } from 'quidproquo-web';
|
|
2
|
-
import {
|
|
2
|
+
import { WebSocketQueueClientMessageEventType, } from 'quidproquo-webserver';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { useFastCallback } from '../../../hooks';
|
|
5
5
|
import { useSubscribeToWebsocket, useWebsocketApi, useWebsocketSendEvent } from '../../hooks';
|
|
@@ -12,7 +12,7 @@ export const useWebsocketAuthSync = (accessToken) => {
|
|
|
12
12
|
}
|
|
13
13
|
if (accessToken) {
|
|
14
14
|
const authMessage = {
|
|
15
|
-
type:
|
|
15
|
+
type: WebSocketQueueClientMessageEventType.Authenticate,
|
|
16
16
|
payload: {
|
|
17
17
|
accessToken: accessToken,
|
|
18
18
|
},
|
|
@@ -21,7 +21,7 @@ export const useWebsocketAuthSync = (accessToken) => {
|
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
const authMessage = {
|
|
24
|
-
type:
|
|
24
|
+
type: WebSocketQueueClientMessageEventType.Unauthenticate,
|
|
25
25
|
};
|
|
26
26
|
sendMessage(authMessage);
|
|
27
27
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { WebSocketQueueClientMessageEventType } from 'quidproquo-webserver';
|
|
2
|
+
import { useRunEvery } from '../../../hooks';
|
|
3
3
|
import { useWebsocketSendEvent } from '../../hooks';
|
|
4
4
|
export const useWebsocketPingPong = () => {
|
|
5
5
|
const sendMessage = useWebsocketSendEvent();
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
type: WebsocketClientMessageEventType.Ping,
|
|
10
|
-
};
|
|
11
|
-
sendMessage(pingEvent);
|
|
12
|
-
}, 8 * 60 * 1000);
|
|
13
|
-
return () => {
|
|
14
|
-
clearInterval(intervalId);
|
|
6
|
+
useRunEvery(() => {
|
|
7
|
+
const pingEvent = {
|
|
8
|
+
type: WebSocketQueueClientMessageEventType.Ping,
|
|
15
9
|
};
|
|
16
|
-
|
|
10
|
+
sendMessage(pingEvent);
|
|
11
|
+
}, 8 * 60);
|
|
17
12
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnyEventMessage } from 'quidproquo-core';
|
|
2
|
-
export declare const useWebsocketSendEvent: () => (event:
|
|
2
|
+
export declare const useWebsocketSendEvent: <E extends AnyEventMessage = AnyEventMessage>() => (event: E) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-web-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.241",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"quidproquo-core": "0.0.
|
|
36
|
-
"quidproquo-tsconfig": "0.0.
|
|
37
|
-
"quidproquo-webserver": "0.0.
|
|
38
|
-
"quidproquo-web": "0.0.
|
|
35
|
+
"quidproquo-core": "0.0.241",
|
|
36
|
+
"quidproquo-tsconfig": "0.0.241",
|
|
37
|
+
"quidproquo-webserver": "0.0.241",
|
|
38
|
+
"quidproquo-web": "0.0.241",
|
|
39
39
|
"typescript": "^4.9.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|