oorja 1.5.1 → 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.
Files changed (45) hide show
  1. package/README.md +5 -3
  2. package/lib/commands/signout.js +2 -2
  3. package/lib/commands/teletype/index.js +3 -3
  4. package/lib/lib/config.d.ts +5 -6
  5. package/lib/lib/config.js +12 -7
  6. package/lib/lib/encryption.d.ts +1 -1
  7. package/lib/lib/encryption.js +12 -7
  8. package/lib/lib/index.js +1 -0
  9. package/lib/lib/oorja/index.js +14 -13
  10. package/lib/lib/oorja/preflight.d.ts +1 -1
  11. package/lib/lib/oorja/preflight.js +17 -11
  12. package/lib/lib/surya/index.d.ts +2 -2
  13. package/lib/lib/surya/index.js +15 -13
  14. package/lib/lib/surya/types.d.ts +10 -10
  15. package/lib/lib/surya/vendor/phoenix/ajax.d.ts +8 -0
  16. package/lib/lib/surya/vendor/phoenix/ajax.js +85 -0
  17. package/lib/lib/surya/vendor/phoenix/channel.d.ts +154 -0
  18. package/lib/lib/surya/vendor/phoenix/channel.js +311 -0
  19. package/lib/lib/surya/vendor/phoenix/constants.d.ts +33 -0
  20. package/lib/lib/surya/vendor/phoenix/constants.js +32 -0
  21. package/lib/lib/surya/vendor/phoenix/index.d.ts +199 -0
  22. package/lib/lib/surya/vendor/phoenix/index.js +207 -0
  23. package/lib/lib/surya/vendor/phoenix/longpoll.d.ts +12 -0
  24. package/lib/lib/surya/vendor/phoenix/longpoll.js +129 -0
  25. package/lib/lib/surya/vendor/phoenix/presence.d.ts +44 -0
  26. package/lib/lib/surya/vendor/phoenix/presence.js +155 -0
  27. package/lib/lib/surya/vendor/phoenix/push.d.ts +57 -0
  28. package/lib/lib/surya/vendor/phoenix/push.js +125 -0
  29. package/lib/lib/surya/vendor/phoenix/serializer.d.ts +53 -0
  30. package/lib/lib/surya/vendor/phoenix/serializer.js +102 -0
  31. package/lib/lib/surya/vendor/phoenix/socket.d.ts +222 -0
  32. package/lib/lib/surya/vendor/phoenix/socket.js +544 -0
  33. package/lib/lib/surya/vendor/phoenix/timer.d.ts +25 -0
  34. package/lib/lib/surya/vendor/phoenix/timer.js +43 -0
  35. package/lib/lib/surya/vendor/phoenix/utils.d.ts +1 -0
  36. package/lib/lib/surya/vendor/phoenix/utils.js +15 -0
  37. package/lib/lib/teletype/auxiliary.d.ts +1 -1
  38. package/lib/lib/teletype/auxiliary.js +8 -4
  39. package/lib/lib/teletype/index.d.ts +1 -1
  40. package/lib/lib/teletype/index.js +13 -12
  41. package/lib/lib/utils.js +2 -1
  42. package/oclif.manifest.json +1 -1
  43. package/package.json +10 -9
  44. package/lib/lib/surya/vendor/phoenix.d.ts +0 -486
  45. package/lib/lib/surya/vendor/phoenix.js +0 -1299
@@ -0,0 +1,222 @@
1
+ import Channel from "./channel";
2
+ import LongPoll from "./longpoll";
3
+ /** Initializes the Socket *
4
+ *
5
+ * For IE8 support use an ES5-shim (https://github.com/es-shims/es5-shim)
6
+ *
7
+ * @param {string} endPoint - The string WebSocket endpoint, ie, `"ws://example.com/socket"`,
8
+ * `"wss://example.com"`
9
+ * `"/socket"` (inherited host & protocol)
10
+ * @param {Object} [opts] - Optional configuration
11
+ * @param {Function} [opts.transport] - The Websocket Transport, for example WebSocket or Phoenix.LongPoll.
12
+ *
13
+ * Defaults to WebSocket with automatic LongPoll fallback.
14
+ * @param {Function} [opts.encode] - The function to encode outgoing messages.
15
+ *
16
+ * Defaults to JSON encoder.
17
+ *
18
+ * @param {Function} [opts.decode] - The function to decode incoming messages.
19
+ *
20
+ * Defaults to JSON:
21
+ *
22
+ * ```javascript
23
+ * (payload, callback) => callback(JSON.parse(payload))
24
+ * ```
25
+ *
26
+ * @param {number} [opts.timeout] - The default timeout in milliseconds to trigger push timeouts.
27
+ *
28
+ * Defaults `DEFAULT_TIMEOUT`
29
+ * @param {number} [opts.heartbeatIntervalMs] - The millisec interval to send a heartbeat message
30
+ * @param {number} [opts.reconnectAfterMs] - The optional function that returns the millisec
31
+ * socket reconnect interval.
32
+ *
33
+ * Defaults to stepped backoff of:
34
+ *
35
+ * ```javascript
36
+ * function(tries){
37
+ * return [10, 50, 100, 150, 200, 250, 500, 1000, 2000][tries - 1] || 5000
38
+ * }
39
+ * ````
40
+ *
41
+ * @param {number} [opts.rejoinAfterMs] - The optional function that returns the millisec
42
+ * rejoin interval for individual channels.
43
+ *
44
+ * ```javascript
45
+ * function(tries){
46
+ * return [1000, 2000, 5000][tries - 1] || 10000
47
+ * }
48
+ * ````
49
+ *
50
+ * @param {Function} [opts.logger] - The optional function for specialized logging, ie:
51
+ *
52
+ * ```javascript
53
+ * function(kind, msg, data) {
54
+ * console.log(`${kind}: ${msg}`, data)
55
+ * }
56
+ * ```
57
+ *
58
+ * @param {number} [opts.longpollerTimeout] - The maximum timeout of a long poll AJAX request.
59
+ *
60
+ * Defaults to 20s (double the server long poll timer).
61
+ *
62
+ * @param {(Object|function)} [opts.params] - The optional params to pass when connecting
63
+ * @param {string} [opts.binaryType] - The binary type to use for binary WebSocket frames.
64
+ *
65
+ * Defaults to "arraybuffer"
66
+ *
67
+ * @param {vsn} [opts.vsn] - The serializer's protocol version to send on connect.
68
+ *
69
+ * Defaults to DEFAULT_VSN.
70
+ */
71
+ export default class Socket {
72
+ constructor(endPoint: any, opts?: {});
73
+ /**
74
+ * Returns the LongPoll transport reference
75
+ */
76
+ getLongPollTransport(): typeof LongPoll;
77
+ /**
78
+ * Disconnects and replaces the active transport
79
+ *
80
+ * @param {Function} newTransport - The new transport class to instantiate
81
+ *
82
+ */
83
+ replaceTransport(newTransport: any): void;
84
+ /**
85
+ * Returns the socket protocol
86
+ *
87
+ * @returns {string}
88
+ */
89
+ protocol(): "wss" | "ws";
90
+ /**
91
+ * The fully qualified socket url
92
+ *
93
+ * @returns {string}
94
+ */
95
+ endPointURL(): any;
96
+ /**
97
+ * Disconnects the socket
98
+ *
99
+ * See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for valid status codes.
100
+ *
101
+ * @param {Function} callback - Optional callback which is called after socket is disconnected.
102
+ * @param {integer} code - A status code for disconnection (Optional).
103
+ * @param {string} reason - A textual description of the reason to disconnect. (Optional)
104
+ */
105
+ disconnect(callback: any, code: any, reason: any): void;
106
+ /**
107
+ *
108
+ * @param {Object} params - The params to send when connecting, for example `{user_id: userToken}`
109
+ *
110
+ * Passing params to connect is deprecated; pass them in the Socket constructor instead:
111
+ * `new Socket("/socket", {params: {user_id: userToken}})`.
112
+ */
113
+ connect(params: any): void;
114
+ /**
115
+ * Logs the message. Override `this.logger` for specialized logging. noops by default
116
+ * @param {string} kind
117
+ * @param {string} msg
118
+ * @param {Object} data
119
+ */
120
+ log(kind: any, msg: any, data: any): void;
121
+ /**
122
+ * Returns true if a logger has been set on this socket.
123
+ */
124
+ hasLogger(): boolean;
125
+ /**
126
+ * Registers callbacks for connection open events
127
+ *
128
+ * @example socket.onOpen(function(){ console.info("the socket was opened") })
129
+ *
130
+ * @param {Function} callback
131
+ */
132
+ onOpen(callback: any): any;
133
+ /**
134
+ * Registers callbacks for connection close events
135
+ * @param {Function} callback
136
+ */
137
+ onClose(callback: any): any;
138
+ /**
139
+ * Registers callbacks for connection error events
140
+ *
141
+ * @example socket.onError(function(error){ alert("An error occurred") })
142
+ *
143
+ * @param {Function} callback
144
+ */
145
+ onError(callback: any): any;
146
+ /**
147
+ * Registers callbacks for connection message events
148
+ * @param {Function} callback
149
+ */
150
+ onMessage(callback: any): any;
151
+ /**
152
+ * Pings the server and invokes the callback with the RTT in milliseconds
153
+ * @param {Function} callback
154
+ *
155
+ * Returns true if the ping was pushed or false if unable to be pushed.
156
+ */
157
+ ping(callback: any): boolean;
158
+ /**
159
+ * @private
160
+ */
161
+ clearHeartbeats(): void;
162
+ onConnOpen(): void;
163
+ /**
164
+ * @private
165
+ */
166
+ heartbeatTimeout(): void;
167
+ resetHeartbeat(): void;
168
+ teardown(callback: any, code: any, reason: any): any;
169
+ waitForBufferDone(callback: any, tries?: number): void;
170
+ waitForSocketClosed(callback: any, tries?: number): void;
171
+ onConnClose(event: any): void;
172
+ /**
173
+ * @private
174
+ */
175
+ onConnError(error: any): void;
176
+ /**
177
+ * @private
178
+ */
179
+ triggerChanError(): void;
180
+ /**
181
+ * @returns {string}
182
+ */
183
+ connectionState(): "closed" | "connecting" | "open" | "closing";
184
+ /**
185
+ * @returns {boolean}
186
+ */
187
+ isConnected(): boolean;
188
+ /**
189
+ * @private
190
+ *
191
+ * @param {Channel}
192
+ */
193
+ remove(channel: any): void;
194
+ /**
195
+ * Removes `onOpen`, `onClose`, `onError,` and `onMessage` registrations.
196
+ *
197
+ * @param {refs} - list of refs returned by calls to
198
+ * `onOpen`, `onClose`, `onError,` and `onMessage`
199
+ */
200
+ off(refs: any): void;
201
+ /**
202
+ * Initiates a new channel for the given topic
203
+ *
204
+ * @param {string} topic
205
+ * @param {Object} chanParams - Parameters for the channel
206
+ * @returns {Channel}
207
+ */
208
+ channel(topic: any, chanParams?: {}): Channel;
209
+ /**
210
+ * @param {Object} data
211
+ */
212
+ push(data: any): void;
213
+ /**
214
+ * Return the next message ref, accounting for overflows
215
+ * @returns {string}
216
+ */
217
+ makeRef(): any;
218
+ sendHeartbeat(): void;
219
+ flushSendBuffer(): void;
220
+ onConnMessage(rawMessage: any): void;
221
+ leaveOpenTopic(topic: any): void;
222
+ }