iosignal 1.8.0 → 2.1.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 (39) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +47 -52
  3. package/dist/iosignal.cjs +25 -1
  4. package/dist/iosignal.js +19 -4
  5. package/dist/iosignal.js.map +1 -1
  6. package/dist/iosignal.min.js +26 -0
  7. package/dist/iosignal.min.js.map +1 -0
  8. package/dist/iosignal.mjs +25 -0
  9. package/index.js +7 -2
  10. package/package.json +16 -14
  11. package/rollup.config.js +16 -41
  12. package/src/auth/Auth_Env.js +2 -2
  13. package/src/auth/Auth_File.js +2 -2
  14. package/src/auth/Auth_Redis.js +2 -2
  15. package/src/auth/BohoAuth.js +5 -5
  16. package/src/client/CongPacket.js +1 -1
  17. package/src/client/IOCore.js +12 -11
  18. package/src/client/IOWebSocket.js +11 -4
  19. package/src/common/payload.js +1 -1
  20. package/src/server/Manager.js +1 -1
  21. package/src/server/RemoteCore.js +12 -13
  22. package/test-browser/index.html +11 -13
  23. package/test-browser/server.js +2 -1
  24. package/{test-client-nodejs → test-nodejs}/client.cjs +2 -2
  25. package/{test-client-nodejs → test-nodejs}/client.mjs +2 -2
  26. package/{test-client-nodejs → test-nodejs}/client_api_reply.mjs +2 -2
  27. package/{test-server → test-nodejs}/server-Auth_Env.js +1 -1
  28. package/{test-server → test-nodejs}/server-Auth_File.js +1 -1
  29. package/{test-server → test-nodejs}/server-esm.mjs +1 -1
  30. package/{test-signal-payloadType → test-nodejs}/signaling.js +3 -3
  31. package/{test-server → test-nodejs}/simple-server.mjs +2 -1
  32. package/dist/iosignal-iife.js +0 -11
  33. package/dist/iosignal-iife.js.map +0 -1
  34. package/indexWebBrowser.js +0 -13
  35. package/test-client-nodejs/stateChange.mjs +0 -19
  36. /package/{test-server → test-nodejs}/server-api_reply.js +0 -0
  37. /package/{test-server → test-nodejs}/server-api_sudo.js +0 -0
  38. /package/{test-server → test-nodejs}/server-commonjs.cjs +0 -0
  39. /package/{test-signal-payloadType → test-nodejs}/signalPack.js +0 -0
package/package.json CHANGED
@@ -1,39 +1,41 @@
1
1
  {
2
2
  "name": "iosignal",
3
- "version": "1.8.0",
3
+ "version": "2.1.0",
4
4
  "description": "iosignal",
5
5
  "type": "module",
6
- "main": "./dist/iosignal.cjs",
7
6
  "exports": {
8
- "import": "./index.js",
9
- "require": "./dist/iosignal.cjs"
10
- },
11
- "browser": "./dist/iosignal.js",
7
+ ".": {
8
+ "import": "./dist/iosignal.mjs",
9
+ "require": "./dist/iosignal.cjs"
10
+ },
11
+ "./iosignal.js": "./dist/iosignal.js"
12
+ },
13
+ "browser": "./dist/iosignal.min.js",
14
+ "jsdelivr": "./dist/iosignal.min.js",
15
+ "unpkg": "./dist/iosignal.min.js",
12
16
  "devDependencies": {
17
+ "@rollup/plugin-json": "^6.1.0",
13
18
  "@rollup/plugin-commonjs": "^26.0.1",
14
- "@rollup/plugin-json": "^6.1.0",
15
19
  "@rollup/plugin-node-resolve": "^15.2.3",
16
- "@rollup/plugin-replace": "^5.0.7",
17
20
  "@rollup/plugin-terser": "^0.4.4",
18
- "redis": "^4.7.0",
19
- "rollup": "^4.21.0"
21
+ "rollup": "^4.21.2"
20
22
  },
21
23
  "scripts": {
22
24
  "build": "rollup -c",
23
25
  "start": "node ./test-browser/server.js"
24
26
  },
25
27
  "engines": {
26
- "node": ">=15.0.0"
28
+ "node": ">=19.0.0"
27
29
  },
28
30
  "author": {
29
- "name": "Taeo Lee",
31
+ "name": "Lee Taeo",
30
32
  "email": "taeo.mocha@gmail.com"
31
33
  },
32
34
  "license": "MIT",
33
35
  "dependencies": {
34
- "boho": "^0.9.0",
36
+ "boho": "^1.0.2",
35
37
  "eventemitter3": "^5.0.1",
36
- "meta-buffer-pack": "^1.4.0",
38
+ "meta-buffer-pack": "^2.0.3",
37
39
  "ws": "^8.18.0"
38
40
  },
39
41
  "optionalDependencies": {
package/rollup.config.js CHANGED
@@ -1,69 +1,44 @@
1
- import replace from '@rollup/plugin-replace'
2
1
  import resolve from '@rollup/plugin-node-resolve'
3
2
  import commonjs from '@rollup/plugin-commonjs'
3
+ import json from '@rollup/plugin-json'
4
4
  import terser from '@rollup/plugin-terser'
5
- // import json from '@rollup/plugin-json'
6
5
 
7
6
  export default [
8
7
  {
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
8
  input: './src/client/IOWebSocket.js',
34
9
  output: [
35
10
  {
36
11
  file: './dist/iosignal.js',
37
- format: 'es', //
12
+ format: 'es',
13
+ sourcemap: true,
14
+ },
15
+ {
16
+ file: './dist/iosignal.min.js',
17
+ format: 'umd',
18
+ name: 'IO',
38
19
  sourcemap: true,
39
20
  }
40
21
  ],
41
22
  plugins: [
42
- replace({
43
- crypto: '',
44
- delimiters: ['import { webcrypto } from \'', '\''],
45
- preventAssignment: true
46
- }),
47
23
  resolve({
48
24
  preferBuiltins: false
49
- }),
50
- commonjs()
25
+ }),
26
+ json(),
27
+ commonjs()
51
28
  ,terser()
52
29
  ]
53
- }
54
-
55
- ,{
30
+ },
31
+ {
56
32
  input: './index.js',
57
33
  output: [
58
- { file: './dist/iosignal.cjs',
59
- format: 'cjs'
60
- }
34
+ { file: './dist/iosignal.cjs', format: 'cjs' },
35
+ { file: './dist/iosignal.mjs', format: 'es' }
61
36
  ],
62
37
  plugins: [
63
38
  resolve({
64
39
  preferBuiltins: true
65
40
  }),
66
- // json(),
41
+ json(),
67
42
  commonjs()
68
43
  ,terser()
69
44
  ]
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  import { BohoAuth } from './BohoAuth.js';
21
- import { sha256 } from 'boho'
21
+ import Boho from 'boho'
22
22
 
23
23
  export class Auth_Env extends BohoAuth {
24
24
  constructor(authInfo) {
@@ -68,7 +68,7 @@ export class Auth_Env extends BohoAuth {
68
68
  }
69
69
 
70
70
  addAuth(id, keyStr, cid, level = 0) {
71
- let Base64hashKey = Buffer.from(sha256.hash(keyStr)).toString('base64')
71
+ let Base64hashKey = Buffer.from(Boho.sha256.hash(keyStr)).toString('base64')
72
72
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level })
73
73
  }
74
74
 
@@ -1,6 +1,6 @@
1
1
  import { BohoAuth } from './BohoAuth.js';
2
2
  import { readFileSync } from 'fs'
3
- import { sha256 } from 'boho'
3
+ import Boho from 'boho'
4
4
  import path from 'path'
5
5
 
6
6
  export class Auth_File extends BohoAuth {
@@ -61,7 +61,7 @@ export class Auth_File extends BohoAuth {
61
61
  }
62
62
 
63
63
  addAuth(id, keyStr, cid, level = 0) {
64
- let Base64hashKey = Buffer.from(sha256.hash(keyStr)).toString('base64')
64
+ let Base64hashKey = Buffer.from(Boho.sha256.hash(keyStr)).toString('base64')
65
65
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level })
66
66
  }
67
67
 
@@ -1,5 +1,5 @@
1
1
  import { BohoAuth } from './BohoAuth.js';
2
- import { sha256 } from 'boho'
2
+ import Boho from 'boho'
3
3
  const DEVICE_PREFIX = "device:"
4
4
 
5
5
  export class Auth_Redis extends BohoAuth {
@@ -28,7 +28,7 @@ export class Auth_Redis extends BohoAuth {
28
28
 
29
29
  // add device auth info
30
30
  async addAuth(id, keyStr, cid = '', level = 0) {
31
- let Base64hashKey = Buffer.from(sha256.hash(keyStr)).toString('base64')
31
+ let Base64hashKey = Buffer.from(Boho.sha256.hash(keyStr)).toString('base64')
32
32
  return this.redis.hSet(DEVICE_PREFIX + id, { 'key': Base64hashKey, 'cid': cid, 'level': level })
33
33
  }
34
34
 
@@ -1,5 +1,5 @@
1
- import { MBP } from 'meta-buffer-pack'
2
- import { BohoMsg, Meta } from 'boho'
1
+ import MBP from 'meta-buffer-pack'
2
+ import Boho from 'boho'
3
3
  import { quotaTable } from '../common/quotaTable.js'
4
4
  import { serverOption } from '../server/serverOption.js'
5
5
  import { IOMsg, CLIENT_STATE } from '../common/constants.js'
@@ -22,17 +22,17 @@ export class BohoAuth {
22
22
  }
23
23
 
24
24
  console.log('## AUTH_FAIL reason:', reason)
25
- // peer.send( Buffer.from( [BohoMsg.AUTH_FAIL] ))
25
+ // peer.send( Buffer.from( [Boho.BohoMsg.AUTH_FAIL] ))
26
26
  peer.setState(CLIENT_STATE.AUTH_FAIL)
27
27
  setTimeout(e => {
28
- peer.send(Buffer.from([BohoMsg.AUTH_FAIL]))
28
+ peer.send(Buffer.from([Boho.BohoMsg.AUTH_FAIL]))
29
29
  }, serverOption.auth.delay_auth_fail)
30
30
  }
31
31
 
32
32
  async verify_auth_hmac(auth_hmac, peer) {
33
33
  try {
34
34
  //1. unpack
35
- let infoPack = MBP.unpack(auth_hmac, Meta.AUTH_HMAC)
35
+ let infoPack = MBP.unpack(auth_hmac, Boho.Meta.AUTH_HMAC)
36
36
  if (!infoPack) {
37
37
  this.send_auth_fail(peer, 'unpack auth_pack fail');
38
38
  return
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'stream'
2
- import { MBP } from 'meta-buffer-pack'
2
+ import MBP from 'meta-buffer-pack'
3
3
 
4
4
  export const CongType = {
5
5
  TYPE_LEN1: 1,
@@ -1,10 +1,11 @@
1
- import { MBP, Buffer } from 'meta-buffer-pack'
1
+ import MBP from 'meta-buffer-pack'
2
2
  import EventEmitter from "eventemitter3";
3
- import { Boho, BohoMsg, MetaSize } from "boho";
4
3
  import { IOMsg, PAYLOAD_TYPE, SIZE_LIMIT, ENC_MODE, STATES } from '../common/constants.js'
5
4
  import { quotaTable } from '../common/quotaTable.js'
6
5
  import { getSignalPack } from '../common/payload.js';
6
+ import Boho from "boho";
7
7
 
8
+ const Buffer = MBP.Buffer;
8
9
  const encoder = new TextEncoder()
9
10
  const decoder = new TextDecoder()
10
11
 
@@ -146,7 +147,7 @@ export class IOCore extends EventEmitter {
146
147
  let msgType = buffer[0];
147
148
  let decoded;
148
149
 
149
- if (msgType === BohoMsg.ENC_488) {
150
+ if (msgType === Boho.BohoMsg.ENC_488) {
150
151
  decoded = this.boho.decrypt_488(buffer)
151
152
  if (decoded) {
152
153
  msgType = decoded[0]
@@ -154,7 +155,7 @@ export class IOCore extends EventEmitter {
154
155
  } else {
155
156
  // console.log('DEC_FAIL', buffer.byteLength)
156
157
  }
157
- } else if (msgType === BohoMsg.ENC_E2E) {
158
+ } else if (msgType === Boho.BohoMsg.ENC_E2E) {
158
159
 
159
160
  try {
160
161
  decoded = this.boho.decrypt_488(buffer)
@@ -162,8 +163,8 @@ export class IOCore extends EventEmitter {
162
163
  // console.log( 'ENC_E2E decoded ', decoded )
163
164
  msgType = decoded[0]
164
165
  // decoded has msg_header only.
165
- buffer.set(decoded, MetaSize.ENC_488) // set decoded signal_e2e headaer.
166
- buffer = buffer.subarray(MetaSize.ENC_488) // reset offset.
166
+ buffer.set(decoded, Boho.MetaSize.ENC_488) // set decoded signal_e2e headaer.
167
+ buffer = buffer.subarray(Boho.MetaSize.ENC_488) // reset offset.
167
168
  // console.log('DECODED MsgType:', IOMsg[ msgType ] )
168
169
  } else {
169
170
  // console.log('488 DEC_FAIL', buffer)
@@ -178,7 +179,7 @@ export class IOCore extends EventEmitter {
178
179
  }
179
180
 
180
181
  let type = IOMsg[msgType]
181
- if (!type) type = BohoMsg[msgType]
182
+ if (!type) type = Boho.BohoMsg[msgType]
182
183
 
183
184
  // console.log( "MsgType: ", type , " LEN ", buffer.byteLength)
184
185
 
@@ -355,7 +356,7 @@ export class IOCore extends EventEmitter {
355
356
  this.testPromise(buffer)
356
357
  break;
357
358
 
358
- case BohoMsg.AUTH_NONCE:
359
+ case Boho.BohoMsg.AUTH_NONCE:
359
360
  let auth_hmac = this.boho.auth_hmac(buffer)
360
361
  if (auth_hmac) {
361
362
  this.send(auth_hmac)
@@ -364,11 +365,11 @@ export class IOCore extends EventEmitter {
364
365
  }
365
366
  break;
366
367
 
367
- case BohoMsg.AUTH_FAIL:
368
+ case Boho.BohoMsg.AUTH_FAIL:
368
369
  this.stateChange('auth_fail', 'server reject auth.')
369
370
  break;
370
371
 
371
- case BohoMsg.AUTH_ACK:
372
+ case Boho.BohoMsg.AUTH_ACK:
372
373
  if (this.boho.check_auth_ack_hmac(buffer)) {
373
374
  this.stateChange('auth_ready', 'server sent auth_ack')
374
375
  this.send(Buffer.from([IOMsg.CID_REQ]))
@@ -484,7 +485,7 @@ export class IOCore extends EventEmitter {
484
485
  // encrypt signal_header area only. payload is encrypted with e2e key already.
485
486
  let tagLen = data[1]
486
487
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen))
487
- encHeader[0] = BohoMsg.ENC_E2E
488
+ encHeader[0] = Boho.BohoMsg.ENC_E2E
488
489
  this.send(Buffer.concat([encHeader, data.subarray(3 + tagLen)]))
489
490
  // console.log('<< send_enc_mode [ ENC_E2E ]')
490
491
 
@@ -1,11 +1,18 @@
1
+ import {version} from "../../package.json";
1
2
  import { IOCore } from "./IOCore.js";
2
- import { Buffer } from 'meta-buffer-pack'
3
- export { Boho, RAND, BohoMsg, Meta, MetaSize, sha256, MBP, Buffer } from 'boho'
4
- export * from '../common/constants.js'
3
+ import Boho from 'boho'
4
+ import * as constants from '../common/constants.js'
5
+
6
+ const Buffer = Boho.Buffer
5
7
 
6
8
  // Browser WebSocket
7
- export class IO extends IOCore {
9
+ export default class IO extends IOCore {
10
+ static version = version
8
11
  static binaryType = "arraybuffer"
12
+ static Boho = Boho;
13
+ static MBP = Boho.MBP;
14
+ static Buffer = Boho.Buffer;
15
+ static constants = constants
9
16
 
10
17
  constructor(url) {
11
18
  super(url);
@@ -1,4 +1,4 @@
1
- import { MBP } from 'meta-buffer-pack'
1
+ import MBP from 'meta-buffer-pack'
2
2
  import { PAYLOAD_TYPE, IOMsg } from "./constants.js";
3
3
  const encoder = new TextEncoder()
4
4
 
@@ -1,4 +1,4 @@
1
- import { MBP } from 'meta-buffer-pack'
1
+ import MBP from 'meta-buffer-pack'
2
2
  import { Remote } from './Remote.js'
3
3
  import { serverOption } from './serverOption.js'
4
4
  import { IOMsg, CLIENT_STATE } from '../common/constants.js'
@@ -1,6 +1,5 @@
1
- import { webcrypto } from 'crypto';
2
- import { MBP } from 'meta-buffer-pack'
3
- import { Boho, BohoMsg, MetaSize } from 'boho'
1
+ import MBP from 'meta-buffer-pack'
2
+ import Boho from 'boho'
4
3
  import { serverOption } from './serverOption.js';
5
4
  import { IOMsg, ENC_MODE, CLIENT_STATE } from '../common/constants.js'
6
5
  import { quotaTable } from '../common/quotaTable.js'
@@ -70,7 +69,7 @@ export class RemoteCore {
70
69
  let from = this.boho.isAuthorized ? `did: ${this.did} ${this.cid}@` : `${this.cid}@`
71
70
  if (isBinary) {
72
71
  let msgTypeName = IOMsg[message[0]]
73
- if (!msgTypeName) msgTypeName = BohoMsg[message[0]]
72
+ if (!msgTypeName) msgTypeName = Boho.BohoMsg[message[0]]
74
73
  msgTypeName = ' [' + msgTypeName + ']';
75
74
  if (message.byteLength > 40) {
76
75
  console.log(from + msgTypeName + ' LEN:', message.length);
@@ -119,7 +118,7 @@ export class RemoteCore {
119
118
  if (isBinary) {
120
119
  msgType = message[0]
121
120
 
122
- if (msgType === BohoMsg.ENC_488) {
121
+ if (msgType === Boho.BohoMsg.ENC_488) {
123
122
 
124
123
  try {
125
124
  decoded = this.boho.decrypt_488(message)
@@ -135,7 +134,7 @@ export class RemoteCore {
135
134
  return
136
135
  }
137
136
 
138
- } else if (msgType === BohoMsg.ENC_E2E) { // symetric E2EE Signal
137
+ } else if (msgType === Boho.BohoMsg.ENC_E2E) { // symetric E2EE Signal
139
138
  try {
140
139
  decoded = this.boho.decrypt_488(message)
141
140
  } catch (err) {
@@ -145,14 +144,14 @@ export class RemoteCore {
145
144
  // console.log('e2e unpack:', decoded )
146
145
  if (decoded) {
147
146
  msgType = decoded[0]
148
- message.set(decoded, MetaSize.ENC_488) // set decoded signal_e2e headaer.
149
- message = message.subarray(MetaSize.ENC_488) // reset offset.
147
+ message.set(decoded, Boho.MetaSize.ENC_488) // set decoded signal_e2e headaer.
148
+ message = message.subarray(Boho.MetaSize.ENC_488) // reset offset.
150
149
  } else {
151
150
  return
152
151
  }
153
152
 
154
153
  } else {
155
- // console.log( `[P] ${ IOMsg[ msgType] || BohoMsg[cmd]} LEN: ${message.byteLength}` )
154
+ // console.log( `[P] ${ IOMsg[ msgType] || Boho.BohoMsg[cmd]} LEN: ${message.byteLength}` )
156
155
  }
157
156
 
158
157
  switch (msgType) {
@@ -170,7 +169,7 @@ export class RemoteCore {
170
169
  }
171
170
 
172
171
  if (!this.cid) {
173
- this.cid = '?' + webcrypto.getRandomValues(Buffer.alloc(3)).toString('base64url')
172
+ this.cid = '?' + globalThis.crypto.getRandomValues(Buffer.alloc(3)).toString('base64url')
174
173
  this.manager.cid2remote.set(this.cid, this)
175
174
  }
176
175
 
@@ -290,7 +289,7 @@ export class RemoteCore {
290
289
 
291
290
 
292
291
  // Auth
293
- case BohoMsg.AUTH_REQ:
292
+ case Boho.BohoMsg.AUTH_REQ:
294
293
  if (!this.manager.authManager) return
295
294
  if (this.state < CLIENT_STATE.SENT_SERVER_READY) {
296
295
  // console.log('protocol error. auth_req before server_ready')
@@ -303,7 +302,7 @@ export class RemoteCore {
303
302
  this.setState(CLIENT_STATE.SENT_SERVER_NONCE)
304
303
  break;
305
304
 
306
- case BohoMsg.AUTH_HMAC:
305
+ case Boho.BohoMsg.AUTH_HMAC:
307
306
  if (!this.manager.authManager) return
308
307
  if (this.state < CLIENT_STATE.SENT_SERVER_NONCE) {
309
308
  // console.log('protocol error. auth_hmac before server_nonce')
@@ -387,7 +386,7 @@ export class RemoteCore {
387
386
  // console.log('server bypass E2E signal taginfo:', tagInfo )
388
387
 
389
388
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen))
390
- encHeader[0] = BohoMsg.ENC_E2E
389
+ encHeader[0] = Boho.BohoMsg.ENC_E2E
391
390
  let newEncBuffer = Buffer.concat([encHeader, data.subarray(3 + tagLen)])
392
391
  this.send(newEncBuffer)
393
392
 
@@ -18,17 +18,16 @@
18
18
  <h2>Simple pub sub example.</h2>
19
19
  <p>you should start server first.</p>
20
20
  <p>this index.html load two types of modules. </p>
21
- <h5>1. IIFE: iosignal-iife.js</h5>
21
+ <h5>1. UMD(IIFE): iosignal.min.js</h5>
22
22
  <p>use global name: IO </p>
23
23
  <p>IO has props: Boho, MBP, Buffer,, </p>
24
24
  <h5>2. ESM: iosignal.js</h5>
25
25
  <p> check the console.</p>
26
26
  <h2>message log</h2>
27
27
  <div id="messageView">...</div>
28
- <script src="../dist/iosignal-iife.js"></script>
28
+ <script src="../dist/iosignal.min.js"></script>
29
29
  <script>
30
- console.log('IIFE:')
31
- console.log('IO', IO)
30
+ console.log('IO.version: ', IO.version)
32
31
  console.log('MBP', IO.MBP)
33
32
  console.log('Buffer', IO.Buffer)
34
33
  console.log('Boho', IO.Boho)
@@ -82,16 +81,15 @@
82
81
  addMessage('ws.error')
83
82
  }
84
83
  </script>
85
- <!-- <script type="module">
86
- import { IO, Boho, MBP, Buffer, sha256 } from "../dist/iosignal.js"
84
+ <script type="module">
85
+ import IO from "../dist/iosignal.js"
87
86
  ESM_IO = IO
88
- console.log('ESM:')
89
- console.log('IO', IO)
90
- console.log('Boho', Boho )
91
- console.log('MBP', MBP )
92
- console.log('Buffer', Buffer)
93
- console.log('sha256.hash("hi")', sha256.hash('hi'))
94
- </script> -->
87
+ console.log('ESM IO.version: ', IO.version)
88
+ console.log('Boho', IO.Boho )
89
+ console.log('MBP', IO.MBP )
90
+ console.log('Buffer', IO.Buffer)
91
+ console.log('sha256.hash("hi")', IO.Boho.sha256.hash('hi'))
92
+ </script>
95
93
  </body>
96
94
 
97
95
  </html>
@@ -1,4 +1,4 @@
1
- import { Server } from 'iosignal'
1
+ import { Server, version } from 'iosignal'
2
2
 
3
3
  const options = {
4
4
  port: 7777,
@@ -7,5 +7,6 @@ const options = {
7
7
  }
8
8
 
9
9
  const server = new Server(options)
10
+ console.log( 'iosignal version: ', version )
10
11
 
11
12
 
@@ -1,7 +1,7 @@
1
1
 
2
- const { IO } = require('iosignal')
2
+ const { IOWS } = require('iosignal')
3
3
 
4
- const io = new IO('ws://localhost:7777')
4
+ const io = new IOWS('ws://localhost:7777')
5
5
 
6
6
  io.on('ready', () => {
7
7
  console.log('ready cid:', io.cid)
@@ -1,7 +1,7 @@
1
1
 
2
- import { IO } from "iosignal"
2
+ import { IOWS } from "iosignal"
3
3
 
4
- const io = new IO('ws://localhost:7777')
4
+ const io = new IOWS('ws://localhost:7777')
5
5
 
6
6
  io.on('ready', () => {
7
7
  console.log('ready cid:', io.cid)
@@ -1,7 +1,7 @@
1
1
 
2
- import { IO } from "iosignal"
2
+ import { IOWS } from "iosignal"
3
3
 
4
- const io = new IO('ws://localhost:7777')
4
+ const io = new IOWS('ws://localhost:7777')
5
5
 
6
6
  io.on('ready', async () => {
7
7
  let res_echo = await io.req('reply', 'echo', 'hello')
@@ -1,4 +1,4 @@
1
- import { Server, Auth_Env } from '../index.js'
1
+ import { Server, Auth_Env } from 'iosignal'
2
2
 
3
3
  const options = {
4
4
  port: 7777,
@@ -1,4 +1,4 @@
1
- import { Server, Auth_File } from '../index.js'
1
+ import { Server, Auth_File } from 'iosignal'
2
2
 
3
3
  const options = {
4
4
  port: 7777,
@@ -1,4 +1,4 @@
1
- import { Server } from '../index.js'
1
+ import { Server } from 'iosignal'
2
2
 
3
3
  const server = new Server(
4
4
  {
@@ -1,4 +1,4 @@
1
- import { IO, Server } from 'iosignal'
1
+ import { IOWS, Server } from 'iosignal'
2
2
 
3
3
  let url = 'ws://localhost:5555'
4
4
  let server = new Server({
@@ -7,13 +7,13 @@ let server = new Server({
7
7
  })
8
8
  let done = false;
9
9
 
10
- let tx = new IO(url)
10
+ let tx = new IOWS(url)
11
11
  tx.on('ready', () => {
12
12
  console.log('tx ready', tx.cid)
13
13
  })
14
14
 
15
15
 
16
- let rx = new IO(url)
16
+ let rx = new IOWS(url)
17
17
  rx.on('ready', () => {
18
18
  console.log('rx ready', rx.cid)
19
19
  })
@@ -1,4 +1,4 @@
1
- import { Server } from '../index.js'
1
+ import { Server, version } from 'iosignal'
2
2
 
3
3
  const server = new Server({
4
4
  port: 7777,
@@ -6,6 +6,7 @@ const server = new Server({
6
6
  showMessage: 'message'
7
7
  })
8
8
 
9
+ console.log( 'iosignal version', version )
9
10
  server.on('text_message', (data, client) => {
10
11
  console.log('text_message', data, 'from', client.cid)
11
12
  client.send('from server. your cid is ' + client.cid + ".")