iosignal-cli 4.6.0 → 4.10.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.
@@ -3,17 +3,14 @@
3
3
  Authentication data sample.
4
4
 
5
5
  device props: ["did", "key", "cid", level ]
6
-
7
6
  did: ( device id ) authentication id. maximum 8 chars.
8
- key: ( device key ) authentication key. no size limit.
7
+ key: ( device key ) authentication key. no size limit. recommended ~44 base64 chars.
9
8
  cid: ( communication id ) signal target id. maximum 12 chars.
10
- level:( quota level) <Number> ref. /server/quotaTable.js
9
+ level:( quota level) <Number> ref. /src/common/quotaTable.js
11
10
 
12
11
  */
13
12
  export const authInfo = [
14
13
  ["did","passowrd","cid",0],
15
- ["device1","device1_key","device1_cid",0],
16
- ["device2","device2_key","device2_cid",0],
17
14
  ["uno","uno-key","uno",1],
18
15
  ["go","go-key","go",2],
19
16
  ["bro","bro-key","bro",3],
@@ -0,0 +1,9 @@
1
+ [
2
+ ["did","passowrd","cid",0],
3
+ ["uno","uno-key","uno",1],
4
+ ["go","go-key","go",2],
5
+ ["bro","bro-key","bro",3],
6
+ ["admin","admin-key","admin",255]
7
+ ]
8
+
9
+
package/bin/io-client.js CHANGED
@@ -108,7 +108,8 @@ const defaultWebSocketPort = 7777;
108
108
  console.log(options)
109
109
 
110
110
  if (!options.connect) {
111
- options.connect = 'localhost:' + defaultWebSocketPort;
111
+ // options.connect = 'localhost:' + defaultWebSocketPort;
112
+ options.connect = 'wss://io.remocon.kr/ws'
112
113
  }
113
114
 
114
115
 
@@ -167,7 +168,8 @@ io.on('ready', () => {
167
168
  })
168
169
 
169
170
  io.on('close', () => {
170
- wsConsole.print(Console.Types.Control, `closed`, Console.Colors.Yellow)
171
+ let date = new Date().toLocaleTimeString()
172
+ wsConsole.print(Console.Types.Control, `closed ${date}`, Console.Colors.Yellow)
171
173
  })
172
174
 
173
175
 
@@ -184,6 +186,14 @@ io.on('auth_fail', () => {
184
186
  `Boho auth_fail.`,
185
187
  Console.Colors.Yellow)
186
188
  })
189
+
190
+ io.on('auth_clear', () => {
191
+ wsConsole.print(
192
+ Console.Types.Control,
193
+ `Boho auth_clear.`,
194
+ Console.Colors.Yellow)
195
+ })
196
+
187
197
  io.on('over_size', () => {
188
198
  wsConsole.print(
189
199
  Console.Types.Control,
@@ -206,7 +216,13 @@ io.on('iam_res', (...args) => {
206
216
  })
207
217
 
208
218
  io.on('message',(tag,...args)=>{
209
- wsConsole.print(Console.Types.Incoming, `message: ${tag} ${args}`, Console.Colors.Green)
219
+ let msg ;
220
+ if(typeof args[0] == 'object'){
221
+ msg = JSON.stringify( args[0])
222
+ }else{
223
+ msg = args;
224
+ }
225
+ wsConsole.print(Console.Types.Incoming, `message: ${tag} ${msg}`, Console.Colors.Green)
210
226
  })
211
227
 
212
228
  wsConsole.on('line', (data) => {
@@ -249,13 +265,13 @@ wsConsole.on('line', (data) => {
249
265
  break;
250
266
 
251
267
  case 'id':
252
- console.log(`cid: ${io.cid} level: ${io.level}`)
268
+ console.log(`state: ${io.stateName} cid: ${io.cid} level: ${io.level}`)
253
269
  break;
254
270
 
255
271
  case 'sudo':
256
272
  toks.shift()
257
273
  console.log('sudo toks', toks)
258
- io.req('sudo', ...toks).then(res => {
274
+ io.call('sudo', ...toks).then(res => {
259
275
  if (res.ok) {
260
276
  console.log('>> sudo response:', res.body)
261
277
  } else {
@@ -304,18 +320,17 @@ wsConsole.on('line', (data) => {
304
320
  io.set(toks[1])
305
321
  break;
306
322
 
307
- case 'api':
308
- case 'req':
323
+ case 'call':
309
324
  toks.shift()
310
325
  if (toks.length < 2) {
311
326
  wsConsole.print(
312
327
  Console.Types.Error,
313
- '[.req need at least two params] req target command [, ..args]',
328
+ '[.call need at least two params] call target command [, ..args]',
314
329
  Console.Colors.Yellow
315
330
  )
316
331
  return
317
332
  }
318
- io.req(...toks).then(result => {
333
+ io.call(...toks).then(result => {
319
334
  console.log('>> response:', result)
320
335
  }).catch(e => {
321
336
  console.log(e)
@@ -328,13 +343,13 @@ wsConsole.on('line', (data) => {
328
343
  case 'listen':
329
344
  toks.shift()
330
345
  let tag = toks[0]
331
- io.subscribe( tag )
332
- console.log('subscribe tag', tag)
333
- // io.listen(tag, (tag, ...args) => {
334
- // console.log(`subscribe & listen tag: ${tag} args:`, args)
335
-
336
- // })
337
- // io.subscribe_memory_channels()
346
+ if(tag){
347
+ io.subscribe( tag )
348
+ let tagList = tag.split(',')
349
+ tagList.forEach( (v)=>{
350
+ io.channels.add( v )
351
+ })
352
+ }
338
353
  break;
339
354
 
340
355
 
package/bin/io-server.js CHANGED
@@ -4,7 +4,7 @@ import { createClient } from 'redis';
4
4
  import { program } from 'commander'
5
5
  import { serverInfo } from './serverInfo.js';
6
6
  import {
7
- Server, serverOption, api_reply, api_sudo, RedisAPI, version as iosignal_version,
7
+ Server, serverOption, replyService, sudoService, RedisService, version as iosignal_version,
8
8
  BohoAuth, FileKeyProvider, StringKeyProvider, RedisKeyProvider
9
9
  } from 'iosignal'
10
10
 
@@ -19,14 +19,13 @@ program
19
19
  .option('-l, --listen <port>', 'listen on port (start WebSocket Server)')
20
20
  .option('-L, --listen-congport <port>', 'listen on cong port (start CongSocket Server)')
21
21
  .option('-d, --auth-file <path>', 'auth data file path')
22
- .option('-e, --auth-param <id.key.level>', 'auth data from argument: id.key.level,id2.key2.level2')
23
- .option('-E, --auth-env', 'auth data from shell env BOHO_AUTH')
22
+ .option('-e, --auth-param <id.key.level>', 'auth data from argument: id1.key.cid1.level1,id2.key2.cid2.level2')
24
23
  .option('-r, --auth-redis', 'connect to redis. if exist use env REDIS_HOST, REDIS_PORT or localhost:6379')
25
24
  .option('-t, --timeout <milliseconds>', 'ping period & timeout')
26
25
  .option('-m, --metric <type>', 'show metric <number> 1:traffic, 2:echo')
27
26
  .option('-s, --show-message <none|message>', 'show receive message. ')
28
27
  .option('-f, --file-logger', 'write log files.')
29
- .option('-a, --api-list [list...]', 'one or multiple api names: -a api_1 api_2 ')
28
+ .option('-a, --attach-services [list...]', 'one or multiple service module names: -a service1 service2')
30
29
  .option('-o, --show-options', 'show server init options.')
31
30
  .parse(process.argv)
32
31
 
@@ -70,8 +69,6 @@ if (options.authFile) {
70
69
  authManager = new BohoAuth( new FileKeyProvider(authFilePath) )
71
70
  } else if (options.authParam) {
72
71
  authManager = new BohoAuth( new StringKeyProvider(options.authParam) )
73
- } else if (options.authEnv) {
74
- authManager = new BohoAuth( new StringKeyProvider(options.authEnv) )
75
72
  } else if (options.authRedis) {
76
73
  console.log("auth data origin: redis")
77
74
  // console.log('####### default redis server url: redis://localhost:6379 ' )
@@ -87,26 +84,29 @@ if (options.authFile) {
87
84
 
88
85
  const server = new Server( privateServerOptions , authManager);
89
86
 
90
- if (options.apiList && options.apiList.length > 0) {
91
- let apiList = options.apiList
92
- console.log('api list', apiList)
93
- if (apiList.includes('reply')) server.api('reply', api_reply)
94
- if (apiList.includes('sudo')) server.api('sudo', api_sudo)
95
- if (apiList.includes('redis')){
87
+ if (options.attachServices && options.attachServices.length > 0) {
88
+ let attachServices = options.attachServices
89
+ if (attachServices.includes('reply')){
90
+ server.attach('reply', replyService)
91
+ }
92
+ if (attachServices.includes('sudo')){
93
+ server.attach('sudo', sudoService)
94
+ }
95
+ if (attachServices.includes('redis')){
96
96
  if(!redisClient){
97
97
  redisClient = createClient();
98
98
  redisClient.on('error', (err) => console.log('Redis Client Error', err));
99
99
  redisClient.connect();
100
100
  }
101
- server.api('redis', new RedisAPI(redisClient))
101
+ server.attach('redis', new RedisService(redisClient))
102
102
  }
103
-
103
+ console.log('registed service names', server.serviceNames)
104
104
  }
105
105
 
106
106
  if (options.showOptions) {
107
107
  console.log('global ServerOptions:', serverOption)
108
108
  console.log('private ServerOptions:', privateServerOptions)
109
- console.log('server api list', server.apiNames)
109
+ console.log('server serviceNames:', server.serviceNames)
110
110
  }
111
111
 
112
112
  setTimeout(()=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iosignal-cli",
3
- "version": "4.6.0",
3
+ "version": "4.10.0",
4
4
  "description": "IOSignal server and client CLI program.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "boxen": "8.0.1",
22
22
  "chalk": "5.6.2",
23
23
  "commander": "13.1.0",
24
- "iosignal": "^4.6.0",
24
+ "iosignal": "^4.10.0",
25
25
  "redis": "4.7.1"
26
26
  },
27
27
  "repository": {
package/auth_file.json DELETED
@@ -1,13 +0,0 @@
1
- [
2
- ["sampleid","samplekey","sample_cid",0],
3
- ["id_max8","no_key_size_limit","communication_id",0],
4
- ["device1","device1_key","device1_cid",0],
5
- ["device2","device2_key","device2_cid",0],
6
- ["uno","uno","uno",1],
7
- ["go","go","go",2],
8
- ["bro","bro","bro",3],
9
- ["admin","admin","admin",255],
10
- ["adminb","adminb","adminb",255]
11
- ]
12
-
13
-