iosignal 1.7.0 → 1.8.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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +254 -247
  3. package/auth_file.json +13 -13
  4. package/auth_file.mjs +23 -23
  5. package/dist/iosignal-iife.js +11 -0
  6. package/dist/iosignal-iife.js.map +1 -0
  7. package/dist/iosignal.cjs +1 -2
  8. package/dist/iosignal.js +11 -0
  9. package/dist/iosignal.js.map +1 -0
  10. package/index.js +19 -19
  11. package/indexWebBrowser.js +13 -13
  12. package/package.json +56 -59
  13. package/rollup.config.js +72 -69
  14. package/src/api/RedisAPI.js +65 -65
  15. package/src/api/api_constant.js +7 -7
  16. package/src/api/api_reply.js +31 -31
  17. package/src/api/api_sudo.js +91 -91
  18. package/src/auth/Auth_Env.js +76 -76
  19. package/src/auth/Auth_File.js +71 -71
  20. package/src/auth/Auth_Redis.js +44 -44
  21. package/src/auth/BohoAuth.js +164 -164
  22. package/src/client/CongPacket.js +141 -141
  23. package/src/client/IOCongSocket.js +81 -81
  24. package/src/client/IOCore.js +822 -822
  25. package/src/client/IOWS.js +80 -80
  26. package/src/client/IOWebSocket.js +111 -111
  27. package/src/common/constants.js +148 -148
  28. package/src/common/payload.js +81 -81
  29. package/src/common/quotaTable.js +68 -68
  30. package/src/common/util.js +61 -61
  31. package/src/server/FileLogger.js +30 -30
  32. package/src/server/Manager.js +433 -433
  33. package/src/server/Metric.js +155 -155
  34. package/src/server/Remote.js +207 -207
  35. package/src/server/RemoteCore.js +439 -439
  36. package/src/server/Server.js +163 -163
  37. package/src/server/serverOption.js +56 -56
  38. package/test-browser/favicon.ico +0 -0
  39. package/test-browser/index.html +96 -96
  40. package/test-browser/server.js +11 -11
  41. package/test-client-nodejs/client.cjs +17 -17
  42. package/test-client-nodejs/client.mjs +17 -17
  43. package/test-client-nodejs/client_api_reply.mjs +15 -15
  44. package/test-client-nodejs/stateChange.mjs +19 -19
  45. package/test-server/server-Auth_Env.js +19 -19
  46. package/test-server/server-Auth_File.js +12 -12
  47. package/test-server/server-api_reply.js +6 -6
  48. package/test-server/server-api_sudo.js +7 -7
  49. package/test-server/server-commonjs.cjs +8 -8
  50. package/test-server/server-esm.mjs +20 -20
  51. package/test-server/simple-server.mjs +11 -11
  52. package/test-signal-payloadType/signalPack.js +34 -34
  53. package/test-signal-payloadType/signaling.js +60 -60
  54. package/dist/iosignal.esm.js +0 -3
  55. package/dist/iosignal.esm.js.map +0 -1
  56. package/dist/iosignal.min.js +0 -3
  57. package/dist/iosignal.min.js.map +0 -1
package/index.js CHANGED
@@ -1,19 +1,19 @@
1
- export { IOCongSocket } from './src/client/IOCongSocket.js'
2
- export { IOWS as IO } from './src/client/IOWS.js'
3
- export { pack, CongRx } from './src/client/CongPacket.js'
4
- export { Server } from './src/server/Server.js'
5
- export { serverOption } from './src/server/serverOption.js'
6
- export { FileLogger } from './src/server/FileLogger.js'
7
- export * from './src/common/constants.js'
8
-
9
- // boho auth
10
- export * from 'boho'
11
- export { BohoAuth } from './src/auth/BohoAuth.js'
12
- export { Auth_File } from './src/auth/Auth_File.js'
13
- export { Auth_Env } from './src/auth/Auth_Env.js'
14
- export { Auth_Redis } from './src/auth/Auth_Redis.js'
15
-
16
- // api
17
- export * as api_reply from './src/api/api_reply.js'
18
- export * as api_sudo from './src/api/api_sudo.js'
19
- export { RedisAPI } from './src/api/RedisAPI.js'
1
+ export { IOCongSocket } from './src/client/IOCongSocket.js'
2
+ export { IOWS as IO } from './src/client/IOWS.js'
3
+ export { pack, CongRx } from './src/client/CongPacket.js'
4
+ export { Server } from './src/server/Server.js'
5
+ export { serverOption } from './src/server/serverOption.js'
6
+ export { FileLogger } from './src/server/FileLogger.js'
7
+ export * from './src/common/constants.js'
8
+
9
+ // boho auth
10
+ export * from 'boho'
11
+ export { BohoAuth } from './src/auth/BohoAuth.js'
12
+ export { Auth_File } from './src/auth/Auth_File.js'
13
+ export { Auth_Env } from './src/auth/Auth_Env.js'
14
+ export { Auth_Redis } from './src/auth/Auth_Redis.js'
15
+
16
+ // api
17
+ export * as api_reply from './src/api/api_reply.js'
18
+ export * as api_sudo from './src/api/api_sudo.js'
19
+ export { RedisAPI } from './src/api/RedisAPI.js'
@@ -1,13 +1,13 @@
1
- import { IO } from './src/client/IOWebSocket.js'
2
- import { Boho, RAND, MBP, BohoMsg, Meta, MetaSize, sha256, Buffer } from 'boho'
3
-
4
- Boho.RAND = RAND;
5
- Boho.BohoMsg = BohoMsg;
6
- Boho.Meta = Meta;
7
- Boho.MetaSize = MetaSize;
8
- Boho.sha256 = sha256;
9
- IO.Boho = Boho;
10
- IO.MBP = MBP;
11
- IO.Buffer = Buffer;
12
-
13
- export default IO;
1
+ import { IO } from './src/client/IOWebSocket.js'
2
+ import { Boho, RAND, MBP, BohoMsg, Meta, MetaSize, sha256, Buffer } from 'boho'
3
+
4
+ Boho.RAND = RAND;
5
+ Boho.BohoMsg = BohoMsg;
6
+ Boho.Meta = Meta;
7
+ Boho.MetaSize = MetaSize;
8
+ Boho.sha256 = sha256;
9
+ IO.Boho = Boho;
10
+ IO.MBP = MBP;
11
+ IO.Buffer = Buffer;
12
+
13
+ export default IO;
package/package.json CHANGED
@@ -1,59 +1,56 @@
1
- {
2
- "name": "iosignal",
3
- "version": "1.7.0",
4
- "description": "iosignal",
5
- "type": "module",
6
- "main": "./dist/iosignal.cjs",
7
- "exports": {
8
- "import": "./index.js",
9
- "require": "./dist/iosignal.cjs"
10
- },
11
- "browser": "./dist/iosignal.min.js",
12
- "browser_esm": "./dist/iosignal.esm.js",
13
- "esm": "./dist/iosignal.mjs",
14
- "devDependencies": {
15
- "@rollup/plugin-commonjs": "^17.1.0",
16
- "@rollup/plugin-json": "^6.0.1",
17
- "@rollup/plugin-node-resolve": "^11.2.1",
18
- "@rollup/plugin-replace": "^4.0.0",
19
- "@rollup/plugin-terser": "^0.4.4",
20
- "mocha": "^9.2.2",
21
- "redis": "^4.6.12",
22
- "rollup": "^2.79.1"
23
- },
24
- "scripts": {
25
- "build": "rollup -c",
26
- "start": "node ./test-browser/server.js"
27
- },
28
- "engines": {
29
- "node": ">=15.0.0"
30
- },
31
- "author": {
32
- "name": "Lee Dongeun",
33
- "email": "sixgen@gmail.com"
34
- },
35
- "license": "MIT",
36
- "dependencies": {
37
- "boho": "^0.8.2",
38
- "eventemitter3": "^5.0.1",
39
- "meta-buffer-pack": "^1.4.0",
40
- "ws": "^8.17.1"
41
- },
42
- "optionalDependencies": {
43
- "bufferutil": "^4.0.8",
44
- "utf-8-validate": "^6.0.3"
45
- },
46
- "repository": {
47
- "type": "git",
48
- "url": "git://github.com/remocons/iosignal.git"
49
- },
50
- "homepage": "https://iosignal.net",
51
- "keywords": [
52
- "websocket",
53
- "pubsub",
54
- "arduino",
55
- "iot",
56
- "auth",
57
- "signal"
58
- ]
59
- }
1
+ {
2
+ "name": "iosignal",
3
+ "version": "1.8.0",
4
+ "description": "iosignal",
5
+ "type": "module",
6
+ "main": "./dist/iosignal.cjs",
7
+ "exports": {
8
+ "import": "./index.js",
9
+ "require": "./dist/iosignal.cjs"
10
+ },
11
+ "browser": "./dist/iosignal.js",
12
+ "devDependencies": {
13
+ "@rollup/plugin-commonjs": "^26.0.1",
14
+ "@rollup/plugin-json": "^6.1.0",
15
+ "@rollup/plugin-node-resolve": "^15.2.3",
16
+ "@rollup/plugin-replace": "^5.0.7",
17
+ "@rollup/plugin-terser": "^0.4.4",
18
+ "redis": "^4.7.0",
19
+ "rollup": "^4.21.0"
20
+ },
21
+ "scripts": {
22
+ "build": "rollup -c",
23
+ "start": "node ./test-browser/server.js"
24
+ },
25
+ "engines": {
26
+ "node": ">=15.0.0"
27
+ },
28
+ "author": {
29
+ "name": "Taeo Lee",
30
+ "email": "taeo.mocha@gmail.com"
31
+ },
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "boho": "^0.9.0",
35
+ "eventemitter3": "^5.0.1",
36
+ "meta-buffer-pack": "^1.4.0",
37
+ "ws": "^8.18.0"
38
+ },
39
+ "optionalDependencies": {
40
+ "bufferutil": "^4.0.8",
41
+ "utf-8-validate": "^6.0.4"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git://github.com/remocons/iosignal.git"
46
+ },
47
+ "homepage": "https://iosignal.net",
48
+ "keywords": [
49
+ "websocket",
50
+ "pubsub",
51
+ "arduino",
52
+ "iot",
53
+ "auth",
54
+ "signal"
55
+ ]
56
+ }
package/rollup.config.js CHANGED
@@ -1,69 +1,72 @@
1
- import replace from '@rollup/plugin-replace'
2
- import resolve from '@rollup/plugin-node-resolve'
3
- import commonjs from '@rollup/plugin-commonjs'
4
- import terser from '@rollup/plugin-terser'
5
- import json from '@rollup/plugin-json'
6
- import pkg from './package.json'
7
-
8
- export default [
9
- {
10
- input: './indexWebBrowser.js',
11
- output: [
12
- {
13
- file: pkg.browser,
14
- format: 'iife',
15
- name: 'IO',
16
- sourcemap: true,
17
- }
18
-
19
- ],
20
- plugins: [
21
- replace({
22
- crypto: '',
23
- delimiters: ['import { webcrypto } from \'', '\''],
24
- preventAssignment: true
25
- }),
26
- resolve(),
27
- commonjs()
28
- ,terser()
29
- ]
30
- }
31
- ,{
32
- input: './src/client/IOWebSocket.js',
33
- output: [
34
- {
35
- file: pkg.browser_esm,
36
- format: 'es', //
37
- sourcemap: true,
38
- }
39
- ],
40
- plugins: [
41
- replace({
42
- crypto: '',
43
- delimiters: ['import { webcrypto } from \'', '\''],
44
- preventAssignment: true
45
- }),
46
- resolve(),
47
- commonjs()
48
- ,terser()
49
- ]
50
- }
51
-
52
- ,{
53
- input: './index.js',
54
- output: [
55
- { file: pkg.main,
56
- format: 'cjs'
57
- }
58
- ],
59
- plugins: [
60
- resolve({
61
- preferBuiltins: true
62
- }),
63
- json(),
64
- commonjs()
65
- ,terser()
66
- ]
67
- }
68
-
69
- ]
1
+ import replace from '@rollup/plugin-replace'
2
+ import resolve from '@rollup/plugin-node-resolve'
3
+ import commonjs from '@rollup/plugin-commonjs'
4
+ import terser from '@rollup/plugin-terser'
5
+ // import json from '@rollup/plugin-json'
6
+
7
+ export default [
8
+ {
9
+ input: './indexWebBrowser.js',
10
+ output: [
11
+ {
12
+ file: './dist/iosignal-iife.js',
13
+ format: 'iife',
14
+ name: 'IO',
15
+ sourcemap: true,
16
+ }
17
+
18
+ ],
19
+ plugins: [
20
+ replace({
21
+ crypto: '',
22
+ delimiters: ['import { webcrypto } from \'', '\''],
23
+ preventAssignment: true
24
+ }),
25
+ resolve({
26
+ preferBuiltins: false
27
+ }),
28
+ commonjs()
29
+ ,terser()
30
+ ]
31
+ }
32
+ ,{
33
+ input: './src/client/IOWebSocket.js',
34
+ output: [
35
+ {
36
+ file: './dist/iosignal.js',
37
+ format: 'es', //
38
+ sourcemap: true,
39
+ }
40
+ ],
41
+ plugins: [
42
+ replace({
43
+ crypto: '',
44
+ delimiters: ['import { webcrypto } from \'', '\''],
45
+ preventAssignment: true
46
+ }),
47
+ resolve({
48
+ preferBuiltins: false
49
+ }),
50
+ commonjs()
51
+ ,terser()
52
+ ]
53
+ }
54
+
55
+ ,{
56
+ input: './index.js',
57
+ output: [
58
+ { file: './dist/iosignal.cjs',
59
+ format: 'cjs'
60
+ }
61
+ ],
62
+ plugins: [
63
+ resolve({
64
+ preferBuiltins: true
65
+ }),
66
+ // json(),
67
+ commonjs()
68
+ ,terser()
69
+ ]
70
+ }
71
+
72
+ ]
@@ -1,65 +1,65 @@
1
- import { STATUS } from './api_constant.js'
2
-
3
- const MIN_LEVEL = 200;
4
- const COMMANDS = [
5
- 'GET', 'SET',
6
- 'HGETALL', 'HGET',
7
- 'HSET', 'SADD',
8
- 'SISMEMBER', 'SMEMBERS',
9
- 'EXISTS', 'SREM',
10
- 'DEL', 'KEYS',
11
- 'SAVE'
12
- ]
13
-
14
- export class RedisAPI {
15
- constructor(redisClient, _minLevel) {
16
- if (!redisClient) {
17
- throw new Error("RedisAPI constructor: no redisClient")
18
- }
19
- this.redisClient = redisClient
20
- this.minLevel = _minLevel ? _minLevel : MIN_LEVEL
21
- this.commands = COMMANDS
22
- }
23
-
24
-
25
- checkPermission(remote, req) {
26
- console.log('checkPermission', remote.level, 'vs', this.minLevel)
27
- if (remote.level >= this.minLevel) {
28
- return true
29
- } else {
30
- return false
31
- }
32
- }
33
-
34
-
35
- async request(remote, req) {
36
-
37
- let result;
38
- let status = STATUS.OK;
39
- try {
40
- let cmd = req.topic
41
- cmd = cmd.toUpperCase()
42
- if (COMMANDS.includes(cmd)) {
43
- console.log('RedisAPI call:', cmd, req.args)
44
-
45
- if (req.args.length > 0) {
46
- result = await this.redisClient[cmd](...req.args)
47
- } else {
48
- result = await this.redisClient[cmd]()
49
- }
50
-
51
-
52
- } else {
53
- status = STATUS.ERROR;
54
- }
55
- remote.response(req.mid, status, result)
56
- } catch (e) {
57
- remote.response(req.mid, STATUS.ERROR, e.message)
58
- }
59
-
60
- }
61
-
62
- }
63
-
64
-
65
-
1
+ import { STATUS } from './api_constant.js'
2
+
3
+ const MIN_LEVEL = 200;
4
+ const COMMANDS = [
5
+ 'GET', 'SET',
6
+ 'HGETALL', 'HGET',
7
+ 'HSET', 'SADD',
8
+ 'SISMEMBER', 'SMEMBERS',
9
+ 'EXISTS', 'SREM',
10
+ 'DEL', 'KEYS',
11
+ 'SAVE'
12
+ ]
13
+
14
+ export class RedisAPI {
15
+ constructor(redisClient, _minLevel) {
16
+ if (!redisClient) {
17
+ throw new Error("RedisAPI constructor: no redisClient")
18
+ }
19
+ this.redisClient = redisClient
20
+ this.minLevel = _minLevel ? _minLevel : MIN_LEVEL
21
+ this.commands = COMMANDS
22
+ }
23
+
24
+
25
+ checkPermission(remote, req) {
26
+ console.log('checkPermission', remote.level, 'vs', this.minLevel)
27
+ if (remote.level >= this.minLevel) {
28
+ return true
29
+ } else {
30
+ return false
31
+ }
32
+ }
33
+
34
+
35
+ async request(remote, req) {
36
+
37
+ let result;
38
+ let status = STATUS.OK;
39
+ try {
40
+ let cmd = req.topic
41
+ cmd = cmd.toUpperCase()
42
+ if (COMMANDS.includes(cmd)) {
43
+ console.log('RedisAPI call:', cmd, req.args)
44
+
45
+ if (req.args.length > 0) {
46
+ result = await this.redisClient[cmd](...req.args)
47
+ } else {
48
+ result = await this.redisClient[cmd]()
49
+ }
50
+
51
+
52
+ } else {
53
+ status = STATUS.ERROR;
54
+ }
55
+ remote.response(req.mid, status, result)
56
+ } catch (e) {
57
+ remote.response(req.mid, STATUS.ERROR, e.message)
58
+ }
59
+
60
+ }
61
+
62
+ }
63
+
64
+
65
+
@@ -1,7 +1,7 @@
1
-
2
- export const STATUS = {
3
- OK: 0,
4
- //0~127: success
5
- //128~255: fail
6
- ERROR: 255
7
- }
1
+
2
+ export const STATUS = {
3
+ OK: 0,
4
+ //0~127: success
5
+ //128~255: fail
6
+ ERROR: 255
7
+ }
@@ -1,31 +1,31 @@
1
-
2
-
3
- import { STATUS } from './api_constant.js'
4
-
5
- const MIN_LEVEL = 0;
6
-
7
- export function checkPermission(remote) {
8
- if (remote.level >= MIN_LEVEL) {
9
- return true
10
- } else {
11
- return false
12
- }
13
- }
14
-
15
- export async function echo(remote, req) {
16
- if (!req.args)
17
- remote.response(req.mid, STATUS.ERROR, 'no message to echo')
18
- else
19
- remote.response(req.mid, STATUS.OK, req.args)
20
- }
21
-
22
- export async function date(remote, req) {
23
- let r = new Date().toUTCString()
24
- remote.response(req.mid, STATUS.OK, r)
25
- }
26
-
27
- export async function unixtime(remote, req) {
28
- let r = Math.floor(Date.now() / 1000)
29
- remote.response(req.mid, STATUS.OK, r)
30
- }
31
-
1
+
2
+
3
+ import { STATUS } from './api_constant.js'
4
+
5
+ const MIN_LEVEL = 0;
6
+
7
+ export function checkPermission(remote) {
8
+ if (remote.level >= MIN_LEVEL) {
9
+ return true
10
+ } else {
11
+ return false
12
+ }
13
+ }
14
+
15
+ export async function echo(remote, req) {
16
+ if (!req.args)
17
+ remote.response(req.mid, STATUS.ERROR, 'no message to echo')
18
+ else
19
+ remote.response(req.mid, STATUS.OK, req.args)
20
+ }
21
+
22
+ export async function date(remote, req) {
23
+ let r = new Date().toUTCString()
24
+ remote.response(req.mid, STATUS.OK, r)
25
+ }
26
+
27
+ export async function unixtime(remote, req) {
28
+ let r = Math.floor(Date.now() / 1000)
29
+ remote.response(req.mid, STATUS.OK, r)
30
+ }
31
+