hackchat-engine 1.1.20 → 1.1.22

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/.gitattributes ADDED
@@ -0,0 +1,107 @@
1
+ # From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes
2
+
3
+ # Handle line endings automatically for files detected as text
4
+ # and leave all files detected as binary untouched.
5
+ * text=auto
6
+
7
+ #
8
+ # The above will handle all files NOT found below
9
+ #
10
+
11
+ #
12
+ ## These files are text and should be normalized (Convert crlf => lf)
13
+ #
14
+
15
+ # source code
16
+ *.php text
17
+ *.css text
18
+ *.sass text
19
+ *.scss text
20
+ *.less text
21
+ *.styl text
22
+ *.js text eol=lf
23
+ *.coffee text
24
+ *.json text
25
+ *.htm text
26
+ *.html text
27
+ *.xml text
28
+ *.svg text
29
+ *.txt text
30
+ *.ini text
31
+ *.inc text
32
+ *.pl text
33
+ *.rb text
34
+ *.py text
35
+ *.scm text
36
+ *.sql text
37
+ *.sh text
38
+ *.bat text
39
+
40
+ # templates
41
+ *.ejs text
42
+ *.hbt text
43
+ *.jade text
44
+ *.haml text
45
+ *.hbs text
46
+ *.dot text
47
+ *.tmpl text
48
+ *.phtml text
49
+
50
+ # server config
51
+ .htaccess text
52
+ .nginx.conf text
53
+
54
+ # git config
55
+ .gitattributes text
56
+ .gitignore text
57
+ .gitconfig text
58
+
59
+ # code analysis config
60
+ .jshintrc text
61
+ .jscsrc text
62
+ .jshintignore text
63
+ .csslintrc text
64
+
65
+ # misc config
66
+ *.yaml text
67
+ *.yml text
68
+ .editorconfig text
69
+
70
+ # build config
71
+ *.npmignore text
72
+ *.bowerrc text
73
+
74
+ # Heroku
75
+ Procfile text
76
+ .slugignore text
77
+
78
+ # Documentation
79
+ *.md text
80
+ LICENSE text
81
+ AUTHORS text
82
+
83
+
84
+ #
85
+ ## These files are binary and should be left untouched
86
+ #
87
+
88
+ # (binary is a macro for -text -diff)
89
+ *.png binary
90
+ *.jpg binary
91
+ *.jpeg binary
92
+ *.gif binary
93
+ *.ico binary
94
+ *.mov binary
95
+ *.mp4 binary
96
+ *.mp3 binary
97
+ *.flv binary
98
+ *.fla binary
99
+ *.swf binary
100
+ *.gz binary
101
+ *.zip binary
102
+ *.7z binary
103
+ *.ttf binary
104
+ *.eot binary
105
+ *.woff binary
106
+ *.pyc binary
107
+ *.pdf binary
@@ -16,6 +16,7 @@ import SignMessage from './SignMessage.js';
16
16
  import SignTransaction from './SignTransaction.js';
17
17
  import UpdateMessage from './UpdateMessage.js';
18
18
  import WalletInfo from './WalletInfo.js';
19
+ import PasswordReq from './PasswordReq.js';
19
20
 
20
21
  /**
21
22
  * This class routes incoming event data to it's proper handler
@@ -46,6 +47,7 @@ class EventsManager {
46
47
  this.SignTransaction = new SignTransaction(this.client);
47
48
  this.UpdateMessage = new UpdateMessage(this.client);
48
49
  this.WalletInfo = new WalletInfo(this.client);
50
+ this.PasswordReq = new PasswordReq(this.client);
49
51
  }
50
52
  }
51
53
 
@@ -0,0 +1,23 @@
1
+ import AbstractEvent from './AbstractEvent.js';
2
+ import PasswordReqStruct from '../structures/PasswordReqStruct.js';
3
+
4
+ /**
5
+ * This class handles an incoming `passwordreq` event from the server
6
+ * @private
7
+ */
8
+ class PasswordReq extends AbstractEvent {
9
+ /**
10
+ * Event handler function
11
+ * @param {object} data Incoming event data
12
+ * @returns {object}
13
+ */
14
+ handle(data) {
15
+ const passwordReqData = new PasswordReqStruct(this.client, data);
16
+
17
+ return {
18
+ passwordReqData,
19
+ };
20
+ }
21
+ }
22
+
23
+ export default PasswordReq;
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "lintfix": "eslint --fix --ignore-path .gitignore .",
60
60
  "test": "echo \"Error: no test specified\" && exit 1"
61
61
  },
62
- "version": "1.1.20"
62
+ "version": "1.1.22"
63
63
  }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * This class handles parsing of the data of a `passwordreq` event
3
+ */
4
+ class PasswordReqStruct {
5
+ /**
6
+ * @param {Client} client Main client reference
7
+ * @param {object} data Incoming event data
8
+ */
9
+ constructor(client, data) {
10
+ /**
11
+ * Add client reference
12
+ * @type {Client}
13
+ * @readonly
14
+ */
15
+ Object.defineProperty(this, 'client', { value: client });
16
+
17
+ this.setup(data);
18
+ }
19
+
20
+ /**
21
+ * Fill in this structure with provided data
22
+ * @param {object} data Incoming event data
23
+ * @returns {void}
24
+ */
25
+ setup(data) {
26
+ /**
27
+ * The channel the password request occurred in
28
+ * @type {string}
29
+ */
30
+ this.channel = data.channel;
31
+ }
32
+ }
33
+
34
+ export default PasswordReqStruct;
package/util/Constants.js CHANGED
@@ -112,6 +112,7 @@ export const Events = {
112
112
  SIGN_TRANSACTION: 'signTransaction',
113
113
  UPDATE_MESSAGE: 'updateMessage',
114
114
  WALLET_INFO: 'walletInfo',
115
+ CHANNEL_PASSWORD_REQ: 'gotPasswordReq',
115
116
  };
116
117
 
117
118
  /**
@@ -137,4 +138,5 @@ export const WSEvents = {
137
138
  SIGN_TRANSACTION: 'signTransaction',
138
139
  UPDATE_MESSAGE: 'updateMessage',
139
140
  WALLET_INFO: 'walletInfo',
141
+ CHANNEL_PASSWORD_REQ: 'passwordreq',
140
142
  };
@@ -23,11 +23,16 @@ import SignMessageHandler from './handlers/SignMessageHandler.js';
23
23
  import SignTransactionHandler from './handlers/SignTransactionHandler.js';
24
24
  import UpdateMessageHandler from './handlers/UpdateMessageHandler.js';
25
25
  import WalletInfoHandler from './handlers/WalletInfoHandler.js';
26
+ import PasswordReqHandler from './handlers/PasswordReqHandler.js';
26
27
 
27
28
  const BeforeReadyWhitelist = [
28
29
  WSEvents.SESSION,
29
30
  WSEvents.ONLINE_SET,
30
31
  WSEvents.PUB_CHANS,
32
+ WSEvents.CHANNEL_WARN,
33
+ WSEvents.CHANNEL_INFO,
34
+ WSEvents.CHANNEL_CAPTCHA,
35
+ WSEvents.CHANNEL_PASSWORD_REQ,
31
36
  ];
32
37
 
33
38
  /**
@@ -82,6 +87,7 @@ class PacketRouter {
82
87
  this.registerEvent(WSEvents.SIGN_TRANSACTION, SignTransactionHandler);
83
88
  this.registerEvent(WSEvents.UPDATE_MESSAGE, UpdateMessageHandler);
84
89
  this.registerEvent(WSEvents.WALLET_INFO, WalletInfoHandler);
90
+ this.registerEvent(WSEvents.CHANNEL_PASSWORD_REQ, PasswordReqHandler);
85
91
  }
86
92
 
87
93
  /**
@@ -0,0 +1,30 @@
1
+ import AbstractHandler from './AbstractHandler.js';
2
+ import { Events } from '../../../util/Constants.js';
3
+
4
+ /**
5
+ * Handles a password request received while attempting to join a channel
6
+ * @private
7
+ */
8
+ class PasswordReqHandler extends AbstractHandler {
9
+ /**
10
+ * Parses incoming packet data and emits related events
11
+ * @param {object} packet Incoming packet data
12
+ * @returns {void}
13
+ */
14
+ handle(packet) {
15
+ const { client } = this.packetRouter;
16
+ const response = client.events.PasswordReq.handle(packet);
17
+
18
+ /**
19
+ * Emitted when a password request is encountered
20
+ * @event Client#gotPasswordReq
21
+ * @param {PasswordReqStruct} passwordReqData The password request data
22
+ */
23
+ client.emit(Events.CHANNEL_PASSWORD_REQ, response);
24
+
25
+ // Emit debug info
26
+ client.emit(Events.DEBUG, `[${Events.CHANNEL_PASSWORD_REQ}]: ${JSON.stringify(packet)}`);
27
+ }
28
+ }
29
+
30
+ export default PasswordReqHandler;