@iobroker/socket-classes 1.5.6 → 1.6.2
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/README.md +59 -53
- package/lib/socketAdmin.js +3 -1
- package/lib/socketCommands.js +3 -1
- package/lib/socketCommon.js +4 -1
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @iobroker/socket-classes
|
|
2
2
|
|
|
3
|
-
This library is used for following adapters:
|
|
3
|
+
This library is used at least for the following adapters:
|
|
4
4
|
- [iobroker.admin](https://github.com/ioBroker/ioBroker.admin)
|
|
5
5
|
- [iobroker.cloud](https://github.com/ioBroker/ioBroker.cloud)
|
|
6
6
|
- [iobroker.socketio](https://github.com/ioBroker/ioBroker.socketio)
|
|
@@ -9,7 +9,7 @@ This library is used for following adapters:
|
|
|
9
9
|
- [iobroker.iot](https://github.com/ioBroker/ioBroker.iot)
|
|
10
10
|
|
|
11
11
|
## Usage as admin
|
|
12
|
-
```
|
|
12
|
+
```js
|
|
13
13
|
const TTL_SEC = 3600;
|
|
14
14
|
|
|
15
15
|
const SocketAdmin = require('@iobroker/socket-classes').SocketAdmin;
|
|
@@ -40,7 +40,7 @@ io.close();
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Usage as socket (ws or socketio)
|
|
43
|
-
```
|
|
43
|
+
```js
|
|
44
44
|
const TTL_SEC = 3600;
|
|
45
45
|
|
|
46
46
|
const ws = require('@iobroker/ws-server');
|
|
@@ -65,12 +65,12 @@ io.close();
|
|
|
65
65
|
|
|
66
66
|
## GUI subscribes
|
|
67
67
|
GUI client can send to desired instance the `subscribe` message
|
|
68
|
-
```
|
|
68
|
+
```js
|
|
69
69
|
socket.emit('clientSubscribe', 'cameras.0', 'startCamera', {width: 640, height: 480}, result => console.log('Started: ' + result));
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
The instance 'cameras.0' will receive message `clientSubscribe` with information who want to receive messages.
|
|
73
|
-
```
|
|
73
|
+
```js
|
|
74
74
|
adapter.on('message', obj => {
|
|
75
75
|
if (obj?.command === 'clientSubscribe') {
|
|
76
76
|
if (obj?.message.type && obj.message.type.startsWith('startCamera/')) {
|
|
@@ -103,7 +103,7 @@ adapter.on('message', obj => {
|
|
|
103
103
|
|
|
104
104
|
and after that client will receive messages from instance
|
|
105
105
|
|
|
106
|
-
```
|
|
106
|
+
```js
|
|
107
107
|
function sendImage(camera, data) {
|
|
108
108
|
this.subscribes.forEach(it => {
|
|
109
109
|
if (it.camera !== camera) {
|
|
@@ -979,32 +979,38 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
979
979
|
-->
|
|
980
980
|
|
|
981
981
|
## Changelog
|
|
982
|
+
### 1.6.2 (2024-12-01)
|
|
983
|
+
* (@GermanBluefox) Caught the error if no authentication and logout called
|
|
984
|
+
|
|
985
|
+
### 1.6.1 (2024-10-05)
|
|
986
|
+
* (@GermanBluefox) Added support of iobroker.SocketIO with typescript
|
|
987
|
+
|
|
982
988
|
### 1.5.6 (2024-06-26)
|
|
983
|
-
* (
|
|
989
|
+
* (@GermanBluefox) Corrected call of getObjectView with null parameter
|
|
984
990
|
|
|
985
991
|
### 1.5.5 (2024-06-26)
|
|
986
|
-
* (
|
|
992
|
+
* (@GermanBluefox) updated packages
|
|
987
993
|
|
|
988
994
|
### 1.5.4 (2024-06-02)
|
|
989
|
-
* (
|
|
995
|
+
* (@GermanBluefox) extend `getCompactInstances`method with version information
|
|
990
996
|
|
|
991
997
|
### 1.5.2 (2024-05-28)
|
|
992
998
|
* (foxriver76) ensure compatible `adapter-core` version
|
|
993
999
|
|
|
994
1000
|
### 1.5.0 (2024-02-22)
|
|
995
|
-
* (
|
|
1001
|
+
* (@GermanBluefox) Extended getObjects function with the possibility to read the list of IDs in admin
|
|
996
1002
|
|
|
997
1003
|
### 1.4.6 (2023-10-19)
|
|
998
|
-
* (
|
|
1004
|
+
* (@GermanBluefox) Added `publishInstanceMessageAll` command
|
|
999
1005
|
|
|
1000
1006
|
### 1.4.4 (2023-10-11)
|
|
1001
|
-
* (
|
|
1007
|
+
* (@GermanBluefox) Caught errors by subscribe/unsubscribe
|
|
1002
1008
|
|
|
1003
1009
|
### 1.4.3 (2023-10-07)
|
|
1004
1010
|
* (foxriver76) do not await the subscribes anymore
|
|
1005
1011
|
|
|
1006
1012
|
### 1.4.2 (2023-09-28)
|
|
1007
|
-
* (
|
|
1013
|
+
* (@GermanBluefox) Corrected error by unsubscribing on client disconnect
|
|
1008
1014
|
|
|
1009
1015
|
### 1.4.1 (2023-09-12)
|
|
1010
1016
|
* (foxriver76) do not cancel follow subscribes if one subscribe has an error
|
|
@@ -1013,126 +1019,126 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
1013
1019
|
* (foxriver76) fixed crash on invalid patterns with js-controller version 5
|
|
1014
1020
|
|
|
1015
1021
|
### 1.3.3 (2023-08-01)
|
|
1016
|
-
* (
|
|
1017
|
-
* (
|
|
1022
|
+
* (@GermanBluefox) Implemented subscribing of a client on messages from specific instance
|
|
1023
|
+
* (@GermanBluefox) Moved checkFeatureSupported to regular connection and not only admin
|
|
1018
1024
|
|
|
1019
1025
|
### 1.2.0 (2023-07-07)
|
|
1020
1026
|
* (foxriver76) fixed crash on invalid patterns with js-controller version 5
|
|
1021
|
-
* (
|
|
1027
|
+
* (@GermanBluefox) extended the getObjects function with the possibility to read the list of IDs
|
|
1022
1028
|
|
|
1023
1029
|
### 1.1.5 (2023-03-13)
|
|
1024
|
-
* (
|
|
1030
|
+
* (@GermanBluefox) Added command `name`
|
|
1025
1031
|
|
|
1026
1032
|
### 1.1.3 (2023-03-12)
|
|
1027
|
-
* (
|
|
1033
|
+
* (@GermanBluefox) Treat `json5` as `json`
|
|
1028
1034
|
|
|
1029
1035
|
### 1.1.2 (2023-03-03)
|
|
1030
|
-
* (
|
|
1036
|
+
* (@GermanBluefox) Allow deletion of fullcalendar objects
|
|
1031
1037
|
|
|
1032
1038
|
### 1.1.1 (2022-12-22)
|
|
1033
|
-
* (
|
|
1039
|
+
* (@GermanBluefox) Corrected error with subscribe
|
|
1034
1040
|
|
|
1035
1041
|
### 1.1.0 (2022-12-22)
|
|
1036
|
-
* (
|
|
1037
|
-
* (
|
|
1042
|
+
* (@GermanBluefox) Added user check to many commands
|
|
1043
|
+
* (@GermanBluefox) Downgrade axios to 0.27.2
|
|
1038
1044
|
|
|
1039
1045
|
### 1.0.2 (2022-11-08)
|
|
1040
|
-
* (
|
|
1046
|
+
* (@GermanBluefox) Function `getObjects`for web was extended by devices, channels and enums
|
|
1041
1047
|
|
|
1042
1048
|
### 1.0.1 (2022-10-10)
|
|
1043
|
-
* (
|
|
1049
|
+
* (@GermanBluefox) Fixed error with delObject
|
|
1044
1050
|
|
|
1045
1051
|
### 0.5.5 (2022-10-09)
|
|
1046
1052
|
* (Apollon77) Prepare for future js-controller versions
|
|
1047
1053
|
|
|
1048
1054
|
### 0.5.4 (2022-09-23)
|
|
1049
|
-
* (
|
|
1055
|
+
* (@GermanBluefox) Fixed error in `delObjects` method
|
|
1050
1056
|
|
|
1051
1057
|
### 0.5.3 (2022-08-24)
|
|
1052
|
-
* (
|
|
1058
|
+
* (@GermanBluefox) Caught error by subscribing
|
|
1053
1059
|
|
|
1054
1060
|
### 0.5.2 (2022-08-19)
|
|
1055
|
-
* (
|
|
1061
|
+
* (@GermanBluefox) Added command `getCompactSystemRepositories`
|
|
1056
1062
|
|
|
1057
1063
|
### 0.5.0 (2022-07-20)
|
|
1058
|
-
* (
|
|
1064
|
+
* (@GermanBluefox) Buffer conversion errors caught and handled
|
|
1059
1065
|
|
|
1060
1066
|
### 0.4.12 (2022-07-08)
|
|
1061
|
-
* (
|
|
1067
|
+
* (@GermanBluefox) Corrected getAdapterInstances method
|
|
1062
1068
|
|
|
1063
1069
|
### 0.4.11 (2022-07-05)
|
|
1064
|
-
* (
|
|
1070
|
+
* (@GermanBluefox) Corrected log transportation
|
|
1065
1071
|
|
|
1066
1072
|
### 0.4.10 (2022-06-22)
|
|
1067
|
-
* (
|
|
1073
|
+
* (@GermanBluefox) Corrected getAdapterInstances
|
|
1068
1074
|
|
|
1069
1075
|
### 0.4.9 (2022-06-20)
|
|
1070
|
-
* (
|
|
1076
|
+
* (@GermanBluefox) Do not show error with failed authentication
|
|
1071
1077
|
|
|
1072
1078
|
### 0.4.7 (2022-06-20)
|
|
1073
|
-
* (
|
|
1079
|
+
* (@GermanBluefox) Allowed overloading system language
|
|
1074
1080
|
|
|
1075
1081
|
### 0.4.6 (2022-06-20)
|
|
1076
|
-
* (
|
|
1082
|
+
* (@GermanBluefox) updated `passport`
|
|
1077
1083
|
|
|
1078
1084
|
### 0.4.5 (2022-06-20)
|
|
1079
|
-
* (
|
|
1085
|
+
* (@GermanBluefox) allowed running socket.io behind reverse proxy
|
|
1080
1086
|
|
|
1081
1087
|
### 0.4.4 (2022-06-09)
|
|
1082
|
-
* (
|
|
1088
|
+
* (@GermanBluefox) Do not show requireLog message
|
|
1083
1089
|
|
|
1084
1090
|
### 0.4.3 (2022-06-03)
|
|
1085
|
-
* (
|
|
1091
|
+
* (@GermanBluefox) Allowed call of getAdapterInstances for non admin
|
|
1086
1092
|
|
|
1087
1093
|
### 0.4.2 (2022-05-23)
|
|
1088
|
-
* (
|
|
1094
|
+
* (@GermanBluefox) Corrected renameFile command for admin
|
|
1089
1095
|
|
|
1090
1096
|
### 0.4.1 (2022-05-23)
|
|
1091
|
-
* (
|
|
1097
|
+
* (@GermanBluefox) Corrected changePassword command for admin
|
|
1092
1098
|
|
|
1093
1099
|
### 0.4.0 (2022-05-19)
|
|
1094
|
-
* (
|
|
1100
|
+
* (@GermanBluefox) Added support of socket.io 4.x
|
|
1095
1101
|
|
|
1096
1102
|
### 0.3.2 (2022-05-19)
|
|
1097
|
-
* (
|
|
1103
|
+
* (@GermanBluefox) Hide warn messages
|
|
1098
1104
|
|
|
1099
1105
|
### 0.3.1 (2022-05-16)
|
|
1100
|
-
* (
|
|
1106
|
+
* (@GermanBluefox) Added back compatibility with js-controller@4.0 for `writeDirAsZip`
|
|
1101
1107
|
|
|
1102
1108
|
### 0.3.0 (2022-05-16)
|
|
1103
|
-
* (
|
|
1109
|
+
* (@GermanBluefox) Process `writeDirAsZip` locally
|
|
1104
1110
|
|
|
1105
1111
|
### 0.2.1 (2022-05-12)
|
|
1106
|
-
* (
|
|
1112
|
+
* (@GermanBluefox) fixed `getObjects` command
|
|
1107
1113
|
|
|
1108
1114
|
### 0.2.0 (2022-05-09)
|
|
1109
|
-
* (
|
|
1115
|
+
* (@GermanBluefox) fixed `delObjects` command
|
|
1110
1116
|
|
|
1111
1117
|
### 0.1.10 (2022-05-09)
|
|
1112
|
-
* (
|
|
1118
|
+
* (@GermanBluefox) Added support for fileChanges
|
|
1113
1119
|
|
|
1114
1120
|
### 0.1.9 (2022-05-07)
|
|
1115
|
-
* (
|
|
1121
|
+
* (@GermanBluefox) Corrected readLogs command and implement file subscriptions
|
|
1116
1122
|
|
|
1117
1123
|
### 0.1.7 (2022-05-05)
|
|
1118
|
-
* (
|
|
1124
|
+
* (@GermanBluefox) Caught some sentry errors
|
|
1119
1125
|
|
|
1120
1126
|
### 0.1.6 (2022-05-05)
|
|
1121
|
-
* (
|
|
1127
|
+
* (@GermanBluefox) fixed `delObject` command
|
|
1122
1128
|
|
|
1123
1129
|
### 0.1.5 (2022-04-25)
|
|
1124
|
-
* (
|
|
1130
|
+
* (@GermanBluefox) added updateRatings
|
|
1125
1131
|
|
|
1126
1132
|
### 0.1.4 (2022-04-24)
|
|
1127
|
-
* (
|
|
1133
|
+
* (@GermanBluefox) added passportSocket
|
|
1128
1134
|
|
|
1129
1135
|
### 0.1.2 (2022-04-24)
|
|
1130
|
-
* (
|
|
1136
|
+
* (@GermanBluefox) initial commit
|
|
1131
1137
|
|
|
1132
1138
|
## License
|
|
1133
1139
|
The MIT License (MIT)
|
|
1134
1140
|
|
|
1135
|
-
Copyright (c) 2020-2024
|
|
1141
|
+
Copyright (c) 2020-2024 @GermanBluefox <dogafox@gmail.com>
|
|
1136
1142
|
|
|
1137
1143
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1138
1144
|
of this software and associated documentation files (the "Software"), to deal
|
package/lib/socketAdmin.js
CHANGED
|
@@ -72,7 +72,9 @@ class SocketAdmin extends SocketCommon {
|
|
|
72
72
|
// Get user for session
|
|
73
73
|
return this.adapter.getSession(socket.conn.request.sessionID, obj => {
|
|
74
74
|
if (!obj || !obj.passport) {
|
|
75
|
-
socket._acl
|
|
75
|
+
if (socket._acl) {
|
|
76
|
+
socket._acl.user = '';
|
|
77
|
+
}
|
|
76
78
|
socket.emit(SocketCommon.COMMAND_RE_AUTHENTICATE);
|
|
77
79
|
callback('Cannot detect user');
|
|
78
80
|
} else {
|
package/lib/socketCommands.js
CHANGED
|
@@ -886,7 +886,9 @@ class SocketCommands {
|
|
|
886
886
|
this.commands['logout'] = (socket, callback) => {
|
|
887
887
|
// Logout user
|
|
888
888
|
// @param {function} callback - function (error)
|
|
889
|
-
|
|
889
|
+
if (socket.id) {
|
|
890
|
+
this.adapter.destroySession(socket.id, callback);
|
|
891
|
+
}
|
|
890
892
|
};
|
|
891
893
|
|
|
892
894
|
this.commands['listPermissions'] = (socket, callback) => {
|
package/lib/socketCommon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Class Socket
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2014-
|
|
4
|
+
* Copyright 2014-2024 bluefox <dogafox@gmail.com>,
|
|
5
5
|
* MIT License
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
@@ -71,6 +71,9 @@ class SocketCommon {
|
|
|
71
71
|
if (typeof socketClass.listen === 'function') {
|
|
72
72
|
// old socket.io@2.x and ws
|
|
73
73
|
this.server = socketClass.listen(server, socketOptions);
|
|
74
|
+
} else if (socketClass.constructor) {
|
|
75
|
+
// iobroker socket
|
|
76
|
+
this.server = new socketClass(server, socketOptions);
|
|
74
77
|
} else {
|
|
75
78
|
// socket.io 4.x
|
|
76
79
|
this.server = socketClass(server, socketOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/socket-classes",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "ioBroker server-side web sockets",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"url": "https://github.com/ioBroker/ioBroker.socket-classes"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@iobroker/adapter-core": "^3.
|
|
25
|
-
"axios": "^1.7.
|
|
26
|
-
"cookie-parser": "^1.4.
|
|
24
|
+
"@iobroker/adapter-core": "^3.2.2",
|
|
25
|
+
"axios": "^1.7.8",
|
|
26
|
+
"cookie-parser": "^1.4.7",
|
|
27
27
|
"passport": "^0.7.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@alcalzone/release-script": "^3.
|
|
30
|
+
"@alcalzone/release-script": "^3.8.0",
|
|
31
31
|
"@alcalzone/release-script-plugin-license": "^3.7.0",
|
|
32
|
-
"@foxriver76/eslint-config": "^1.0.
|
|
33
|
-
"chai": "^4.
|
|
32
|
+
"@foxriver76/eslint-config": "^1.0.5",
|
|
33
|
+
"chai": "^4.5.0",
|
|
34
34
|
"gulp": "^4.0.2",
|
|
35
|
-
"iobroker.js-controller": "^6.0.
|
|
36
|
-
"mocha": "^10.
|
|
35
|
+
"iobroker.js-controller": "^6.0.11",
|
|
36
|
+
"mocha": "^10.8.2"
|
|
37
37
|
},
|
|
38
38
|
"bugs": {
|
|
39
39
|
"url": "https://github.com/ioBroker/ioBroker.web/issues"
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"release-minor": "release-script minor --no-update-lockfile --yes",
|
|
55
55
|
"release-major": "release-script major --no-update-lockfile --yes",
|
|
56
56
|
"update-packages": "ncu --upgrade",
|
|
57
|
+
"npm": "npm install --ignore-script",
|
|
57
58
|
"docs": "gulp"
|
|
58
59
|
},
|
|
59
60
|
"license": "MIT",
|
|
@@ -62,8 +63,5 @@
|
|
|
62
63
|
"name": "bluefox",
|
|
63
64
|
"email": "dogafox@gmail.com"
|
|
64
65
|
}
|
|
65
|
-
]
|
|
66
|
-
"overrides": {
|
|
67
|
-
"@iobroker/adapter-core": "^3.1.6"
|
|
68
|
-
}
|
|
66
|
+
]
|
|
69
67
|
}
|