@trycourier/react-provider 1.1.1-internal.91ee677.0 → 1.2.1-internal.499acc8.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.
@@ -11,13 +11,13 @@ var useCourierActions = function useCourierActions(dispatch) {
11
11
  return {
12
12
  initToast: function initToast(payload) {
13
13
  dispatch({
14
- type: "INIT_TOAST",
14
+ type: "toast/INIT",
15
15
  payload: payload
16
16
  });
17
17
  },
18
18
  initInbox: function initInbox(payload) {
19
19
  dispatch({
20
- type: "INIT_INBOX",
20
+ type: "inbox/INIT",
21
21
  payload: payload
22
22
  });
23
23
  },
package/dist/index.js CHANGED
@@ -149,7 +149,7 @@ var CourierProvider = function CourierProvider(_ref) {
149
149
  };
150
150
  }, [transport, userId]);
151
151
  (0, _react.useEffect)(function () {
152
- if (!clientKey || !userId) {
152
+ if (!_transport && (!clientKey || !userId)) {
153
153
  return;
154
154
  }
155
155
 
@@ -52,6 +52,7 @@ var CourierTransport = /*#__PURE__*/function (_Transport) {
52
52
  _this.userSignature = options.userSignature;
53
53
  _this.ws = new _ws.WS({
54
54
  clientKey: options.clientKey,
55
+ userSignature: options.userSignature,
55
56
  url: options.wsUrl || _constants.COURIER_WS_URL || "wss://1x60p1o3h8.execute-api.us-east-1.amazonaws.com/production"
56
57
  });
57
58
 
package/dist/ws.js CHANGED
@@ -26,13 +26,15 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
26
26
  var WS = /*#__PURE__*/function () {
27
27
  function WS(_ref) {
28
28
  var url = _ref.url,
29
- clientKey = _ref.clientKey;
29
+ clientKey = _ref.clientKey,
30
+ userSignature = _ref.userSignature;
30
31
  (0, _classCallCheck2["default"])(this, WS);
31
32
  this.messageCallback = null;
32
33
  this.connection = undefined;
33
34
  this.connected = false;
34
35
  this.url = url;
35
36
  this.clientKey = clientKey;
37
+ this.userSignature = userSignature;
36
38
  this.subscriptions = [];
37
39
  }
38
40
 
@@ -42,8 +44,17 @@ var WS = /*#__PURE__*/function () {
42
44
  this.connection = new _reconnectingWebsocket["default"]("".concat(this.url, "/?clientKey=").concat(this.clientKey));
43
45
  this.connection.onopen = this.onOpen.bind(this);
44
46
  this.connection.onclose = this.onClose.bind(this);
47
+ this.connection.onerror = this.onError.bind(this);
45
48
  this.connection.onmessage = this.onMessage.bind(this);
46
49
  }
50
+ }, {
51
+ key: "onError",
52
+ value: function onError() {
53
+ var _this$connection;
54
+
55
+ console.error("Error Connecting to Courier Push");
56
+ (_this$connection = this.connection) === null || _this$connection === void 0 ? void 0 : _this$connection.close();
57
+ }
47
58
  }, {
48
59
  key: "onClose",
49
60
  value: function onClose() {
@@ -63,9 +74,11 @@ var WS = /*#__PURE__*/function () {
63
74
  this.send({
64
75
  action: "subscribe",
65
76
  data: {
77
+ version: "2",
66
78
  channel: sub.channel,
67
79
  event: sub.event,
68
- clientKey: this.clientKey
80
+ clientKey: this.clientKey,
81
+ userSignature: this.userSignature
69
82
  }
70
83
  });
71
84
  }
@@ -129,9 +142,11 @@ var WS = /*#__PURE__*/function () {
129
142
  this.send({
130
143
  action: "subscribe",
131
144
  data: {
145
+ version: "2",
132
146
  channel: channel,
133
147
  event: event,
134
- clientKey: this.clientKey
148
+ clientKey: this.clientKey,
149
+ userSignature: this.userSignature
135
150
  }
136
151
  });
137
152
  }
@@ -169,18 +184,20 @@ var WS = /*#__PURE__*/function () {
169
184
  this.send({
170
185
  action: "unsubscribe",
171
186
  data: {
187
+ version: "2",
172
188
  channel: channel,
173
189
  event: event,
174
- clientKey: this.clientKey
190
+ clientKey: this.clientKey,
191
+ userSignature: this.userSignature
175
192
  }
176
193
  });
177
194
  }
178
195
  }, {
179
196
  key: "close",
180
197
  value: function close() {
181
- var _this$connection;
198
+ var _this$connection2;
182
199
 
183
- (_this$connection = this.connection) === null || _this$connection === void 0 ? void 0 : _this$connection.close();
200
+ (_this$connection2 = this.connection) === null || _this$connection2 === void 0 ? void 0 : _this$connection2.close();
184
201
  }
185
202
  }]);
186
203
  return WS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/react-provider",
3
- "version": "1.1.1-internal.91ee677.0+91ee677",
3
+ "version": "1.2.1-internal.499acc8.0+499acc8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "typings/index.d.ts",
@@ -30,5 +30,5 @@
30
30
  "dist/",
31
31
  "typings/"
32
32
  ],
33
- "gitHead": "91ee6771ec838b47d4d0412c7c9a1ae92b9490d3"
33
+ "gitHead": "499acc80f70f9d8eb4bd29e2498764c496a01a81"
34
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transports/courier/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;IACjB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACjC,UAAkB,WAAW,CAAC,EAAE,WAAW,CAAC;gBAEhC,OAAO,EAAE,iBAAiB;IAmBtC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAUpC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAchD,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;CAGnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transports/courier/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;IACjB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACjC,UAAkB,WAAW,CAAC,EAAE,WAAW,CAAC;gBAEhC,OAAO,EAAE,iBAAiB;IAoBtC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAUpC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAchD,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;CAGnD"}
package/typings/ws.d.ts CHANGED
@@ -7,11 +7,14 @@ export declare class WS {
7
7
  protected messageCallback: any;
8
8
  private url;
9
9
  private clientKey;
10
- constructor({ url, clientKey }: {
10
+ private userSignature?;
11
+ constructor({ url, clientKey, userSignature, }: {
11
12
  url: string;
12
13
  clientKey: string;
14
+ userSignature?: string;
13
15
  });
14
16
  connect(): void;
17
+ onError(): void;
15
18
  onClose(): void;
16
19
  onOpen(): void;
17
20
  onMessage({ data }: {
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../src/ws.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAmB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,qBAAqB,MAAM,wBAAwB,CAAC;AAE3D,qBAAa,EAAE;IACb,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,OAAO,CAAC,aAAa,CAIlB;IACH,SAAS,CAAC,SAAS,MAAC;IAC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