arifa-client 1.1.13 → 1.3.15
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/dist/arifa-client.esm.js +50 -90
- package/dist/arifa-client.iife.js +50 -90
- package/dist/types/ArifaClient.d.ts +10 -13
- package/dist/types/ArifaClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/arifa-client.esm.js
CHANGED
|
@@ -2,73 +2,31 @@ class ArifaClient {
|
|
|
2
2
|
constructor({ apiKey, client, wsUrl, apiEndpoint }) {
|
|
3
3
|
this.ws = null;
|
|
4
4
|
this.isConnected = false;
|
|
5
|
-
this.reconnectAttempts = 0;
|
|
6
5
|
this.reconnectTimer = null;
|
|
6
|
+
this.reconnectAttempts = 0;
|
|
7
7
|
this.reconnectScheduled = false;
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
8
|
+
this.MAX_BACKOFF = 60000;
|
|
9
|
+
this.MAX_RECONNECTS = 5;
|
|
10
10
|
this.recipient = null;
|
|
11
11
|
this.listeners = new Set();
|
|
12
12
|
this.connectionListeners = new Set();
|
|
13
|
-
this.
|
|
14
|
-
this.MAX_BACKOFF = 60000;
|
|
13
|
+
this.ackedEvents = new Set();
|
|
15
14
|
this.apiKey = apiKey;
|
|
16
15
|
this.client = client;
|
|
17
16
|
this.wsUrl = wsUrl || "wss://notifications.arifa.dev/ws";
|
|
18
17
|
this.apiEndpoint = apiEndpoint || "https://notifications.arifa.dev/notify";
|
|
19
|
-
this.startInternetMonitor();
|
|
20
18
|
}
|
|
19
|
+
/* ---------------- UTIL ---------------- */
|
|
21
20
|
safeParse(input) {
|
|
22
21
|
try {
|
|
23
22
|
if (typeof input === "object")
|
|
24
23
|
return input;
|
|
25
|
-
|
|
26
|
-
if (typeof parsed === "string")
|
|
27
|
-
parsed = JSON.parse(parsed);
|
|
28
|
-
return parsed;
|
|
24
|
+
return JSON.parse(String(input));
|
|
29
25
|
}
|
|
30
26
|
catch (_a) {
|
|
31
27
|
return null;
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
|
-
/* ---------------- INTERNET DETECTION ---------------- */
|
|
35
|
-
async checkInternet() {
|
|
36
|
-
try {
|
|
37
|
-
const controller = new AbortController();
|
|
38
|
-
const timeout = setTimeout(() => controller.abort(), 3000);
|
|
39
|
-
await fetch(this.HEALTH_URL, {
|
|
40
|
-
method: "HEAD",
|
|
41
|
-
cache: "no-store",
|
|
42
|
-
signal: controller.signal,
|
|
43
|
-
});
|
|
44
|
-
clearTimeout(timeout);
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
catch (_a) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
startInternetMonitor() {
|
|
52
|
-
const update = async () => {
|
|
53
|
-
var _a;
|
|
54
|
-
const online = await this.checkInternet();
|
|
55
|
-
if (online !== this.internetOnline) {
|
|
56
|
-
this.internetOnline = online;
|
|
57
|
-
if (online) {
|
|
58
|
-
this.reconnectAttempts = 0;
|
|
59
|
-
this.connect();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
63
|
-
this.emitConnection("disconnected");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
update();
|
|
68
|
-
window.addEventListener("online", update);
|
|
69
|
-
window.addEventListener("offline", update);
|
|
70
|
-
this.internetTimer = window.setInterval(update, 5000);
|
|
71
|
-
}
|
|
72
30
|
/* ---------------- PUBLIC API ---------------- */
|
|
73
31
|
subscribe(recipient) {
|
|
74
32
|
if (!this.recipient) {
|
|
@@ -78,17 +36,19 @@ class ArifaClient {
|
|
|
78
36
|
return {
|
|
79
37
|
listen: (callback) => {
|
|
80
38
|
this.listeners.add(callback);
|
|
39
|
+
return () => this.listeners.delete(callback);
|
|
81
40
|
},
|
|
82
|
-
unsubscribe: (
|
|
83
|
-
|
|
84
|
-
this.listeners.delete(callback);
|
|
85
|
-
else
|
|
86
|
-
this.listeners.clear();
|
|
41
|
+
unsubscribe: () => {
|
|
42
|
+
this.listeners.clear();
|
|
87
43
|
},
|
|
88
44
|
};
|
|
89
45
|
}
|
|
90
46
|
onConnectionChange(callback) {
|
|
91
47
|
this.connectionListeners.add(callback);
|
|
48
|
+
return () => this.connectionListeners.delete(callback);
|
|
49
|
+
}
|
|
50
|
+
connected() {
|
|
51
|
+
return this.isConnected;
|
|
92
52
|
}
|
|
93
53
|
emitConnection(state) {
|
|
94
54
|
this.connectionListeners.forEach((cb) => cb(state));
|
|
@@ -97,31 +57,30 @@ class ArifaClient {
|
|
|
97
57
|
connect() {
|
|
98
58
|
if (!this.recipient)
|
|
99
59
|
return;
|
|
100
|
-
if (!this.internetOnline)
|
|
101
|
-
return;
|
|
102
60
|
if (this.ws &&
|
|
103
61
|
(this.ws.readyState === WebSocket.OPEN ||
|
|
104
|
-
this.ws.readyState === WebSocket.CONNECTING))
|
|
62
|
+
this.ws.readyState === WebSocket.CONNECTING))
|
|
105
63
|
return;
|
|
106
|
-
}
|
|
107
|
-
this.ws = new WebSocket(`${this.wsUrl}/connect?api_key=${this.apiKey}&recipient=${this.recipient}&client=${this.client}`);
|
|
64
|
+
this.ws = new WebSocket(`${this.wsUrl}/connect?api_key=${encodeURIComponent(this.apiKey)}&recipient=${encodeURIComponent(this.recipient)}&client=${this.client}`);
|
|
108
65
|
this.ws.onopen = () => {
|
|
109
66
|
this.isConnected = true;
|
|
110
67
|
this.reconnectAttempts = 0;
|
|
111
68
|
this.reconnectScheduled = false;
|
|
112
|
-
|
|
69
|
+
this.ackedEvents.clear();
|
|
70
|
+
if (this.reconnectTimer)
|
|
113
71
|
clearTimeout(this.reconnectTimer);
|
|
114
|
-
this.reconnectTimer = null;
|
|
115
|
-
}
|
|
116
72
|
this.emitConnection("connected");
|
|
117
73
|
};
|
|
118
74
|
this.ws.onmessage = (event) => {
|
|
75
|
+
var _a, _b;
|
|
119
76
|
const parsed = this.safeParse(event.data);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
77
|
+
if (!parsed)
|
|
78
|
+
return;
|
|
79
|
+
// ACK exactly once
|
|
80
|
+
if (((_a = parsed.ack) === null || _a === void 0 ? void 0 : _a.event_id) && !this.ackedEvents.has(parsed.ack.event_id)) {
|
|
81
|
+
this.ackedEvents.add(parsed.ack.event_id);
|
|
82
|
+
(_b = this.ws) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({ kind: "ack", event_id: parsed.ack.event_id }));
|
|
83
|
+
}
|
|
125
84
|
if (parsed.event)
|
|
126
85
|
this.listeners.forEach((fn) => fn(parsed.event));
|
|
127
86
|
};
|
|
@@ -136,37 +95,43 @@ class ArifaClient {
|
|
|
136
95
|
};
|
|
137
96
|
}
|
|
138
97
|
scheduleReconnect() {
|
|
139
|
-
if (
|
|
98
|
+
if (this.reconnectScheduled ||
|
|
99
|
+
this.reconnectAttempts >= this.MAX_RECONNECTS)
|
|
140
100
|
return;
|
|
141
101
|
this.reconnectScheduled = true;
|
|
142
102
|
const base = Math.min(this.MAX_BACKOFF, 1000 * 2 ** this.reconnectAttempts);
|
|
143
103
|
const jitter = Math.random() * 1000;
|
|
144
|
-
const timeout = base + jitter;
|
|
145
104
|
this.reconnectAttempts++;
|
|
146
105
|
this.reconnectTimer = window.setTimeout(() => {
|
|
147
106
|
this.reconnectScheduled = false;
|
|
148
107
|
this.connect();
|
|
149
|
-
},
|
|
108
|
+
}, base + jitter);
|
|
150
109
|
}
|
|
151
110
|
/* ---------------- HTTP NOTIFY ---------------- */
|
|
152
111
|
async notify({ recipient, payload, client, origin, }) {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
112
|
+
const controller = new AbortController();
|
|
113
|
+
const timeout = setTimeout(() => controller.abort(), 8000);
|
|
114
|
+
let res;
|
|
115
|
+
try {
|
|
116
|
+
res = await fetch(this.apiEndpoint, {
|
|
117
|
+
method: "POST",
|
|
118
|
+
headers: { "Content-Type": "application/json" },
|
|
119
|
+
body: JSON.stringify({
|
|
120
|
+
recipient,
|
|
121
|
+
payload,
|
|
122
|
+
api_key: this.apiKey,
|
|
123
|
+
client: client || this.client,
|
|
124
|
+
origin,
|
|
125
|
+
}),
|
|
126
|
+
signal: controller.signal,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
clearTimeout(timeout);
|
|
169
131
|
}
|
|
132
|
+
const json = await res.json();
|
|
133
|
+
if (!res.ok)
|
|
134
|
+
throw new Error((json === null || json === void 0 ? void 0 : json.message) || "Notification failed");
|
|
170
135
|
return json;
|
|
171
136
|
}
|
|
172
137
|
/* ---------------- LIFECYCLE ---------------- */
|
|
@@ -174,16 +139,11 @@ class ArifaClient {
|
|
|
174
139
|
var _a;
|
|
175
140
|
if (this.reconnectTimer)
|
|
176
141
|
clearTimeout(this.reconnectTimer);
|
|
177
|
-
if (this.internetTimer)
|
|
178
|
-
clearInterval(this.internetTimer);
|
|
179
142
|
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
180
143
|
this.ws = null;
|
|
181
144
|
this.isConnected = false;
|
|
182
145
|
this.emitConnection("disconnected");
|
|
183
146
|
}
|
|
184
|
-
connected() {
|
|
185
|
-
return this.isConnected;
|
|
186
|
-
}
|
|
187
147
|
}
|
|
188
148
|
|
|
189
149
|
export { ArifaClient as default };
|
|
@@ -5,73 +5,31 @@ var ArifaClient = (function () {
|
|
|
5
5
|
constructor({ apiKey, client, wsUrl, apiEndpoint }) {
|
|
6
6
|
this.ws = null;
|
|
7
7
|
this.isConnected = false;
|
|
8
|
-
this.reconnectAttempts = 0;
|
|
9
8
|
this.reconnectTimer = null;
|
|
9
|
+
this.reconnectAttempts = 0;
|
|
10
10
|
this.reconnectScheduled = false;
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
11
|
+
this.MAX_BACKOFF = 60000;
|
|
12
|
+
this.MAX_RECONNECTS = 5;
|
|
13
13
|
this.recipient = null;
|
|
14
14
|
this.listeners = new Set();
|
|
15
15
|
this.connectionListeners = new Set();
|
|
16
|
-
this.
|
|
17
|
-
this.MAX_BACKOFF = 60000;
|
|
16
|
+
this.ackedEvents = new Set();
|
|
18
17
|
this.apiKey = apiKey;
|
|
19
18
|
this.client = client;
|
|
20
19
|
this.wsUrl = wsUrl || "wss://notifications.arifa.dev/ws";
|
|
21
20
|
this.apiEndpoint = apiEndpoint || "https://notifications.arifa.dev/notify";
|
|
22
|
-
this.startInternetMonitor();
|
|
23
21
|
}
|
|
22
|
+
/* ---------------- UTIL ---------------- */
|
|
24
23
|
safeParse(input) {
|
|
25
24
|
try {
|
|
26
25
|
if (typeof input === "object")
|
|
27
26
|
return input;
|
|
28
|
-
|
|
29
|
-
if (typeof parsed === "string")
|
|
30
|
-
parsed = JSON.parse(parsed);
|
|
31
|
-
return parsed;
|
|
27
|
+
return JSON.parse(String(input));
|
|
32
28
|
}
|
|
33
29
|
catch (_a) {
|
|
34
30
|
return null;
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
|
-
/* ---------------- INTERNET DETECTION ---------------- */
|
|
38
|
-
async checkInternet() {
|
|
39
|
-
try {
|
|
40
|
-
const controller = new AbortController();
|
|
41
|
-
const timeout = setTimeout(() => controller.abort(), 3000);
|
|
42
|
-
await fetch(this.HEALTH_URL, {
|
|
43
|
-
method: "HEAD",
|
|
44
|
-
cache: "no-store",
|
|
45
|
-
signal: controller.signal,
|
|
46
|
-
});
|
|
47
|
-
clearTimeout(timeout);
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
catch (_a) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
startInternetMonitor() {
|
|
55
|
-
const update = async () => {
|
|
56
|
-
var _a;
|
|
57
|
-
const online = await this.checkInternet();
|
|
58
|
-
if (online !== this.internetOnline) {
|
|
59
|
-
this.internetOnline = online;
|
|
60
|
-
if (online) {
|
|
61
|
-
this.reconnectAttempts = 0;
|
|
62
|
-
this.connect();
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
66
|
-
this.emitConnection("disconnected");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
update();
|
|
71
|
-
window.addEventListener("online", update);
|
|
72
|
-
window.addEventListener("offline", update);
|
|
73
|
-
this.internetTimer = window.setInterval(update, 5000);
|
|
74
|
-
}
|
|
75
33
|
/* ---------------- PUBLIC API ---------------- */
|
|
76
34
|
subscribe(recipient) {
|
|
77
35
|
if (!this.recipient) {
|
|
@@ -81,17 +39,19 @@ var ArifaClient = (function () {
|
|
|
81
39
|
return {
|
|
82
40
|
listen: (callback) => {
|
|
83
41
|
this.listeners.add(callback);
|
|
42
|
+
return () => this.listeners.delete(callback);
|
|
84
43
|
},
|
|
85
|
-
unsubscribe: (
|
|
86
|
-
|
|
87
|
-
this.listeners.delete(callback);
|
|
88
|
-
else
|
|
89
|
-
this.listeners.clear();
|
|
44
|
+
unsubscribe: () => {
|
|
45
|
+
this.listeners.clear();
|
|
90
46
|
},
|
|
91
47
|
};
|
|
92
48
|
}
|
|
93
49
|
onConnectionChange(callback) {
|
|
94
50
|
this.connectionListeners.add(callback);
|
|
51
|
+
return () => this.connectionListeners.delete(callback);
|
|
52
|
+
}
|
|
53
|
+
connected() {
|
|
54
|
+
return this.isConnected;
|
|
95
55
|
}
|
|
96
56
|
emitConnection(state) {
|
|
97
57
|
this.connectionListeners.forEach((cb) => cb(state));
|
|
@@ -100,31 +60,30 @@ var ArifaClient = (function () {
|
|
|
100
60
|
connect() {
|
|
101
61
|
if (!this.recipient)
|
|
102
62
|
return;
|
|
103
|
-
if (!this.internetOnline)
|
|
104
|
-
return;
|
|
105
63
|
if (this.ws &&
|
|
106
64
|
(this.ws.readyState === WebSocket.OPEN ||
|
|
107
|
-
this.ws.readyState === WebSocket.CONNECTING))
|
|
65
|
+
this.ws.readyState === WebSocket.CONNECTING))
|
|
108
66
|
return;
|
|
109
|
-
}
|
|
110
|
-
this.ws = new WebSocket(`${this.wsUrl}/connect?api_key=${this.apiKey}&recipient=${this.recipient}&client=${this.client}`);
|
|
67
|
+
this.ws = new WebSocket(`${this.wsUrl}/connect?api_key=${encodeURIComponent(this.apiKey)}&recipient=${encodeURIComponent(this.recipient)}&client=${this.client}`);
|
|
111
68
|
this.ws.onopen = () => {
|
|
112
69
|
this.isConnected = true;
|
|
113
70
|
this.reconnectAttempts = 0;
|
|
114
71
|
this.reconnectScheduled = false;
|
|
115
|
-
|
|
72
|
+
this.ackedEvents.clear();
|
|
73
|
+
if (this.reconnectTimer)
|
|
116
74
|
clearTimeout(this.reconnectTimer);
|
|
117
|
-
this.reconnectTimer = null;
|
|
118
|
-
}
|
|
119
75
|
this.emitConnection("connected");
|
|
120
76
|
};
|
|
121
77
|
this.ws.onmessage = (event) => {
|
|
78
|
+
var _a, _b;
|
|
122
79
|
const parsed = this.safeParse(event.data);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
80
|
+
if (!parsed)
|
|
81
|
+
return;
|
|
82
|
+
// ACK exactly once
|
|
83
|
+
if (((_a = parsed.ack) === null || _a === void 0 ? void 0 : _a.event_id) && !this.ackedEvents.has(parsed.ack.event_id)) {
|
|
84
|
+
this.ackedEvents.add(parsed.ack.event_id);
|
|
85
|
+
(_b = this.ws) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({ kind: "ack", event_id: parsed.ack.event_id }));
|
|
86
|
+
}
|
|
128
87
|
if (parsed.event)
|
|
129
88
|
this.listeners.forEach((fn) => fn(parsed.event));
|
|
130
89
|
};
|
|
@@ -139,37 +98,43 @@ var ArifaClient = (function () {
|
|
|
139
98
|
};
|
|
140
99
|
}
|
|
141
100
|
scheduleReconnect() {
|
|
142
|
-
if (
|
|
101
|
+
if (this.reconnectScheduled ||
|
|
102
|
+
this.reconnectAttempts >= this.MAX_RECONNECTS)
|
|
143
103
|
return;
|
|
144
104
|
this.reconnectScheduled = true;
|
|
145
105
|
const base = Math.min(this.MAX_BACKOFF, 1000 * 2 ** this.reconnectAttempts);
|
|
146
106
|
const jitter = Math.random() * 1000;
|
|
147
|
-
const timeout = base + jitter;
|
|
148
107
|
this.reconnectAttempts++;
|
|
149
108
|
this.reconnectTimer = window.setTimeout(() => {
|
|
150
109
|
this.reconnectScheduled = false;
|
|
151
110
|
this.connect();
|
|
152
|
-
},
|
|
111
|
+
}, base + jitter);
|
|
153
112
|
}
|
|
154
113
|
/* ---------------- HTTP NOTIFY ---------------- */
|
|
155
114
|
async notify({ recipient, payload, client, origin, }) {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
115
|
+
const controller = new AbortController();
|
|
116
|
+
const timeout = setTimeout(() => controller.abort(), 8000);
|
|
117
|
+
let res;
|
|
118
|
+
try {
|
|
119
|
+
res = await fetch(this.apiEndpoint, {
|
|
120
|
+
method: "POST",
|
|
121
|
+
headers: { "Content-Type": "application/json" },
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
recipient,
|
|
124
|
+
payload,
|
|
125
|
+
api_key: this.apiKey,
|
|
126
|
+
client: client || this.client,
|
|
127
|
+
origin,
|
|
128
|
+
}),
|
|
129
|
+
signal: controller.signal,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
clearTimeout(timeout);
|
|
172
134
|
}
|
|
135
|
+
const json = await res.json();
|
|
136
|
+
if (!res.ok)
|
|
137
|
+
throw new Error((json === null || json === void 0 ? void 0 : json.message) || "Notification failed");
|
|
173
138
|
return json;
|
|
174
139
|
}
|
|
175
140
|
/* ---------------- LIFECYCLE ---------------- */
|
|
@@ -177,16 +142,11 @@ var ArifaClient = (function () {
|
|
|
177
142
|
var _a;
|
|
178
143
|
if (this.reconnectTimer)
|
|
179
144
|
clearTimeout(this.reconnectTimer);
|
|
180
|
-
if (this.internetTimer)
|
|
181
|
-
clearInterval(this.internetTimer);
|
|
182
145
|
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
183
146
|
this.ws = null;
|
|
184
147
|
this.isConnected = false;
|
|
185
148
|
this.emitConnection("disconnected");
|
|
186
149
|
}
|
|
187
|
-
connected() {
|
|
188
|
-
return this.isConnected;
|
|
189
|
-
}
|
|
190
150
|
}
|
|
191
151
|
|
|
192
152
|
return ArifaClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type ArifaEvent =
|
|
1
|
+
type ArifaEvent = Record<string, unknown>;
|
|
2
2
|
type ConnectionState = "connected" | "disconnected";
|
|
3
3
|
interface ArifaClientOptions {
|
|
4
4
|
apiKey: string;
|
|
@@ -8,7 +8,7 @@ interface ArifaClientOptions {
|
|
|
8
8
|
}
|
|
9
9
|
interface NotifyPayload {
|
|
10
10
|
recipient: string;
|
|
11
|
-
payload: Record<string,
|
|
11
|
+
payload: Record<string, unknown>;
|
|
12
12
|
client?: "web" | "mobile";
|
|
13
13
|
origin?: string;
|
|
14
14
|
}
|
|
@@ -24,31 +24,28 @@ export declare class ArifaClient {
|
|
|
24
24
|
private apiEndpoint;
|
|
25
25
|
private ws;
|
|
26
26
|
private isConnected;
|
|
27
|
-
private reconnectAttempts;
|
|
28
27
|
private reconnectTimer;
|
|
28
|
+
private reconnectAttempts;
|
|
29
29
|
private reconnectScheduled;
|
|
30
|
-
private
|
|
31
|
-
private
|
|
30
|
+
private readonly MAX_BACKOFF;
|
|
31
|
+
private readonly MAX_RECONNECTS;
|
|
32
32
|
private recipient;
|
|
33
33
|
private listeners;
|
|
34
34
|
private connectionListeners;
|
|
35
|
-
private
|
|
36
|
-
private readonly MAX_BACKOFF;
|
|
35
|
+
private ackedEvents;
|
|
37
36
|
constructor({ apiKey, client, wsUrl, apiEndpoint }: ArifaClientOptions);
|
|
38
37
|
private safeParse;
|
|
39
|
-
private checkInternet;
|
|
40
|
-
private startInternetMonitor;
|
|
41
38
|
subscribe(recipient: string): {
|
|
42
|
-
listen: (callback: (event: ArifaEvent) => void) =>
|
|
43
|
-
unsubscribe: (
|
|
39
|
+
listen: (callback: (event: ArifaEvent) => void) => () => boolean;
|
|
40
|
+
unsubscribe: () => void;
|
|
44
41
|
};
|
|
45
|
-
onConnectionChange(callback: ConnectionCallback):
|
|
42
|
+
onConnectionChange(callback: ConnectionCallback): () => boolean;
|
|
43
|
+
connected(): boolean;
|
|
46
44
|
private emitConnection;
|
|
47
45
|
private connect;
|
|
48
46
|
private scheduleReconnect;
|
|
49
47
|
notify({ recipient, payload, client, origin, }: NotifyPayload): Promise<NotifyResponse>;
|
|
50
48
|
disconnect(): void;
|
|
51
|
-
connected(): boolean;
|
|
52
49
|
}
|
|
53
50
|
export {};
|
|
54
51
|
//# sourceMappingURL=ArifaClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArifaClient.d.ts","sourceRoot":"","sources":["../../src/ArifaClient.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"ArifaClient.d.ts","sourceRoot":"","sources":["../../src/ArifaClient.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1C,KAAK,eAAe,GAAG,WAAW,GAAG,cAAc,CAAC;AAEpD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,QAAQ,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,KAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;AAE3D,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAK;IAEpC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,mBAAmB,CAAiC;IAE5D,OAAO,CAAC,WAAW,CAAqB;gBAE5B,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,kBAAkB;IAQtE,OAAO,CAAC,SAAS;IAUjB,SAAS,CAAC,SAAS,EAAE,MAAM;2BAOJ,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI;;;IAUlD,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB;IAK/C,SAAS;IAIT,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,OAAO;IAmDf,OAAO,CAAC,iBAAiB;IAmBnB,MAAM,CAAC,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,MAAM,GACP,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA4B1C,UAAU;CAQX"}
|
package/package.json
CHANGED