@trycourier/react-provider 5.1.3-internal.e22afd0.0 → 6.0.1-internal.00141d1.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.
- package/dist/hooks/use-courier-actions.js +8 -3
- package/dist/index.js +13 -32
- package/dist/types.js +1 -21
- package/package.json +8 -7
- package/typings/hooks/use-courier-actions.d.ts.map +1 -1
- package/typings/index.d.ts +2 -5
- package/typings/index.d.ts.map +1 -1
- package/typings/types.d.ts +10 -93
- package/typings/types.d.ts.map +1 -1
- package/dist/hooks/use-transport.js +0 -82
- package/dist/lib/index.js +0 -19
- package/dist/transports/base.js +0 -94
- package/dist/transports/courier/index.js +0 -147
- package/dist/transports/courier/types.js +0 -1
- package/dist/transports/index.js +0 -31
- package/dist/transports/types.js +0 -0
- package/dist/ws.js +0 -304
- package/typings/hooks/use-transport.d.ts +0 -13
- package/typings/hooks/use-transport.d.ts.map +0 -1
- package/typings/lib/index.d.ts +0 -2
- package/typings/lib/index.d.ts.map +0 -1
- package/typings/transports/base.d.ts +0 -27
- package/typings/transports/base.d.ts.map +0 -1
- package/typings/transports/courier/index.d.ts +0 -26
- package/typings/transports/courier/index.d.ts.map +0 -1
- package/typings/transports/courier/types.d.ts +0 -10
- package/typings/transports/courier/types.d.ts.map +0 -1
- package/typings/transports/index.d.ts +0 -3
- package/typings/transports/index.d.ts.map +0 -1
- package/typings/transports/types.d.ts +0 -50
- package/typings/transports/types.d.ts.map +0 -1
- package/typings/ws.d.ts +0 -46
- package/typings/ws.d.ts.map +0 -1
|
@@ -15,7 +15,7 @@ var _react = require("react");
|
|
|
15
15
|
|
|
16
16
|
var _clientGraphql = require("@trycourier/client-graphql");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _transport = require("@trycourier/transport");
|
|
19
19
|
|
|
20
20
|
var _courierJs = _interopRequireDefault(require("@trycourier/courier-js"));
|
|
21
21
|
|
|
@@ -29,11 +29,16 @@ var useCourierActions = function useCourierActions(state, dispatch) {
|
|
|
29
29
|
userId: state.userId,
|
|
30
30
|
userSignature: state.userSignature
|
|
31
31
|
});
|
|
32
|
+
var clientKey = state.clientKey; //ensure we always have a clientkey
|
|
33
|
+
|
|
34
|
+
if (!clientKey && state.authorization) {
|
|
35
|
+
clientKey = "JWT_AUTH";
|
|
36
|
+
}
|
|
32
37
|
|
|
33
38
|
_courierJs["default"].init({
|
|
34
39
|
baseUrl: state.apiUrl,
|
|
35
40
|
authorization: state.authorization,
|
|
36
|
-
clientKey:
|
|
41
|
+
clientKey: clientKey,
|
|
37
42
|
userId: state.userId,
|
|
38
43
|
userSignature: state.userSignature
|
|
39
44
|
});
|
|
@@ -197,7 +202,7 @@ var useCourierActions = function useCourierActions(state, dispatch) {
|
|
|
197
202
|
while (1) {
|
|
198
203
|
switch (_context6.prev = _context6.next) {
|
|
199
204
|
case 0:
|
|
200
|
-
if (state.transport instanceof
|
|
205
|
+
if (state.transport instanceof _transport.CourierTransport) {
|
|
201
206
|
state.transport.renewSession(token);
|
|
202
207
|
}
|
|
203
208
|
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
25
25
|
|
|
26
26
|
var _createReducer = _interopRequireDefault(require("react-use/lib/factory/createReducer"));
|
|
27
27
|
|
|
28
|
+
var _reactHooks = require("@trycourier/react-hooks");
|
|
29
|
+
|
|
28
30
|
var _reducer = _interopRequireWildcard(require("./reducer"));
|
|
29
31
|
|
|
30
32
|
var _middleware = _interopRequireWildcard(require("./middleware"));
|
|
@@ -33,8 +35,6 @@ var _useCourierActions = _interopRequireDefault(require("./hooks/use-courier-act
|
|
|
33
35
|
|
|
34
36
|
var _usePageVisible = require("./hooks/use-page-visible");
|
|
35
37
|
|
|
36
|
-
var _useTransport = _interopRequireDefault(require("./hooks/use-transport"));
|
|
37
|
-
|
|
38
38
|
var _useClientSourceId = _interopRequireDefault(require("./hooks/use-client-source-id"));
|
|
39
39
|
|
|
40
40
|
var _deepExtend = _interopRequireDefault(require("deep-extend"));
|
|
@@ -43,20 +43,6 @@ var _theme2 = require("./theme");
|
|
|
43
43
|
|
|
44
44
|
var _styledComponents = require("styled-components");
|
|
45
45
|
|
|
46
|
-
var _transports = require("./transports");
|
|
47
|
-
|
|
48
|
-
Object.keys(_transports).forEach(function (key) {
|
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
51
|
-
if (key in exports && exports[key] === _transports[key]) return;
|
|
52
|
-
Object.defineProperty(exports, key, {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function get() {
|
|
55
|
-
return _transports[key];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
46
|
var _hooks = require("./hooks");
|
|
61
47
|
|
|
62
48
|
Object.keys(_hooks).forEach(function (key) {
|
|
@@ -71,20 +57,6 @@ Object.keys(_hooks).forEach(function (key) {
|
|
|
71
57
|
});
|
|
72
58
|
});
|
|
73
59
|
|
|
74
|
-
var _lib = require("./lib");
|
|
75
|
-
|
|
76
|
-
Object.keys(_lib).forEach(function (key) {
|
|
77
|
-
if (key === "default" || key === "__esModule") return;
|
|
78
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
79
|
-
if (key in exports && exports[key] === _lib[key]) return;
|
|
80
|
-
Object.defineProperty(exports, key, {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function get() {
|
|
83
|
-
return _lib[key];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
60
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
89
61
|
|
|
90
62
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -119,7 +91,7 @@ var CourierContext = /*#__PURE__*/_react["default"].createContext(undefined);
|
|
|
119
91
|
|
|
120
92
|
exports.CourierContext = CourierContext;
|
|
121
93
|
|
|
122
|
-
var
|
|
94
|
+
var CourierProviderInner = function CourierProviderInner(_ref2) {
|
|
123
95
|
var _window;
|
|
124
96
|
|
|
125
97
|
var apiUrl = _ref2.apiUrl,
|
|
@@ -161,7 +133,7 @@ var CourierProvider = function CourierProvider(_ref2) {
|
|
|
161
133
|
return applyMiddleware(_middleware["default"]);
|
|
162
134
|
}, [applyMiddleware]);
|
|
163
135
|
var useReducer = (0, _react.useCallback)(_createReducer["default"].apply(void 0, (0, _toConsumableArray2["default"])(middleware)), [middleware]);
|
|
164
|
-
var transport = typeof window === "undefined" ? undefined : (0,
|
|
136
|
+
var transport = typeof window === "undefined" ? undefined : (0, _reactHooks.useTransport)({
|
|
165
137
|
tenantId: tenantId,
|
|
166
138
|
authorization: authorization,
|
|
167
139
|
clientSourceId: clientSourceId,
|
|
@@ -293,4 +265,13 @@ var CourierProvider = function CourierProvider(_ref2) {
|
|
|
293
265
|
}), children);
|
|
294
266
|
};
|
|
295
267
|
|
|
268
|
+
var CourierProvider = function CourierProvider(props) {
|
|
269
|
+
if (!props.clientKey && !props.authorization) {
|
|
270
|
+
console.warn("Missing ClientKey or Authorization Token");
|
|
271
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, props.children);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return /*#__PURE__*/_react["default"].createElement(CourierProviderInner, props);
|
|
275
|
+
};
|
|
276
|
+
|
|
296
277
|
exports.CourierProvider = CourierProvider;
|
package/dist/types.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "IInboxMessagePreview", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _clientGraphql.IInboxMessagePreview;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Interceptor", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _types.Interceptor;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _clientGraphql = require("@trycourier/client-graphql");
|
|
20
|
-
|
|
21
|
-
var _types = require("./transports/types");
|
|
1
|
+
"use strict";
|
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trycourier/react-provider",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1-internal.00141d1.0+00141d1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "typings/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "jest -c jest.config.js --runInBand",
|
|
9
8
|
"babel": "babel src -d dist --extensions \".ts,.tsx\" --ignore \"src/**/__tests__/**\" --ignore \"src/**/__mocks__/**\"",
|
|
10
9
|
"build:watch": "yarn babel --watch",
|
|
11
10
|
"build": "rimraf dist && yarn babel",
|
|
12
11
|
"clean": "rimraf dist && rimraf typings",
|
|
13
|
-
"type-check": "tsc --noEmit",
|
|
14
12
|
"readme": "concat-md --toc --decrease-title-levels --dir-name-as-title docs > README.md",
|
|
15
|
-
"
|
|
13
|
+
"type-check": "tsc --noEmit",
|
|
14
|
+
"types": "rimraf typings && tsc --emitDeclarationOnly"
|
|
16
15
|
},
|
|
17
16
|
"license": "ISC",
|
|
18
17
|
"dependencies": {
|
|
19
|
-
"@trycourier/client-graphql": "^
|
|
18
|
+
"@trycourier/client-graphql": "^6.0.1-internal.00141d1.0+00141d1",
|
|
19
|
+
"@trycourier/core": "^6.0.1-internal.00141d1.0+00141d1",
|
|
20
|
+
"@trycourier/courier-js": "^1.4.2",
|
|
21
|
+
"@trycourier/transport": "^6.0.1-internal.00141d1.0+00141d1",
|
|
20
22
|
"buffer": "^6.0.3",
|
|
21
23
|
"jwt-decode": "^3.1.2",
|
|
22
24
|
"react-use": "^17.2.1",
|
|
23
|
-
"reconnecting-websocket": "^4.4.0",
|
|
24
25
|
"rimraf": "^3.0.2",
|
|
25
26
|
"urql": "^2.0.1",
|
|
26
27
|
"uuid": "^9.0.0"
|
|
@@ -33,5 +34,5 @@
|
|
|
33
34
|
"dist/",
|
|
34
35
|
"typings/"
|
|
35
36
|
],
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "00141d141f9340b87df46100da169d0c17a79b34"
|
|
37
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-courier-actions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-courier-actions.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"use-courier-actions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-courier-actions.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,QAAA,MAAM,iBAAiB,iCAAsB,eAmH5C,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/typings/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { IActionElemental, ICourierEventMessage, IInboxMessagePreview, ITextElemental, Interceptor } from "./transports/types";
|
|
2
|
+
import { ICourierContext, ICourierProviderProps, OnEvent, ProviderTheme } from "./types";
|
|
4
3
|
import { Middleware } from "./middleware";
|
|
5
|
-
export * from "./transports";
|
|
6
4
|
export * from "./hooks";
|
|
7
|
-
export * from "./lib";
|
|
8
5
|
export declare const registerReducer: (scope: any, reducer: any) => void;
|
|
9
6
|
export declare const registerMiddleware: (id: string, middleware: Middleware) => void;
|
|
10
|
-
export type {
|
|
7
|
+
export type { Middleware, OnEvent, ProviderTheme, ICourierContext };
|
|
11
8
|
export declare const CourierContext: React.Context<ICourierContext | undefined>;
|
|
12
9
|
export declare const CourierProvider: React.FunctionComponent<PropsWithChildren<ICourierProviderProps>>;
|
|
13
10
|
//# sourceMappingURL=index.d.ts.map
|
package/typings/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAIZ,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAIZ,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,OAAO,EACP,aAAa,EAEd,MAAM,SAAS,CAAC;AAMjB,OAA0B,EACxB,UAAU,EAEX,MAAM,cAAc,CAAC;AAQtB,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,eAAe,oCAAmB,CAAC;AAChD,eAAO,MAAM,kBAAkB,8CAAsB,CAAC;AAEtD,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAkBpE,eAAO,MAAM,cAAc,4CACkC,CAAC;AA+N9D,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,iBAAiB,CACnD,iBAAiB,CAAC,qBAAqB,CAAC,CAQzC,CAAC"}
|
package/typings/types.d.ts
CHANGED
|
@@ -1,96 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export { Interceptor } from "./transports/types";
|
|
6
|
-
export declare type ErrorEventHandler = (event: ErrorEvent) => void;
|
|
7
|
-
export declare type PreferenceStatus = "OPTED_IN" | "OPTED_OUT" | "REQUIRED";
|
|
8
|
-
export declare type RepeatOn = {
|
|
9
|
-
sunday?: boolean;
|
|
10
|
-
monday?: boolean;
|
|
11
|
-
tuesday?: boolean;
|
|
12
|
-
wednesday?: boolean;
|
|
13
|
-
thursday?: boolean;
|
|
14
|
-
friday?: boolean;
|
|
15
|
-
saturday?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export interface DigestSchedule {
|
|
18
|
-
period: string;
|
|
19
|
-
repetition: string;
|
|
20
|
-
scheduleId: string;
|
|
21
|
-
default?: boolean;
|
|
22
|
-
start: string;
|
|
23
|
-
recurrence: string;
|
|
24
|
-
repeat?: {
|
|
25
|
-
frequency: number;
|
|
26
|
-
interval: "day" | "week" | "month" | "year";
|
|
27
|
-
on?: string | RepeatOn;
|
|
28
|
-
};
|
|
29
|
-
end?: number | string;
|
|
30
|
-
}
|
|
31
|
-
export interface IPreferenceTemplate {
|
|
32
|
-
templateName: string;
|
|
33
|
-
templateId: string;
|
|
34
|
-
defaultStatus: PreferenceStatus;
|
|
35
|
-
digestSchedules?: DigestSchedule[];
|
|
36
|
-
}
|
|
37
|
-
export declare type WSOptions = {
|
|
38
|
-
url?: string;
|
|
39
|
-
onError?: ErrorEventHandler;
|
|
40
|
-
onClose?: () => void;
|
|
41
|
-
onReconnect?: () => void;
|
|
42
|
-
connectionTimeout?: number;
|
|
43
|
-
};
|
|
44
|
-
export declare type OnEvent = (eventParams: {
|
|
45
|
-
messageId?: string;
|
|
46
|
-
message?: IInboxMessagePreview;
|
|
47
|
-
event: EventType;
|
|
48
|
-
data?: Record<string, unknown>;
|
|
49
|
-
}) => void;
|
|
50
|
-
export interface PinDetails {
|
|
51
|
-
id: string;
|
|
52
|
-
label: {
|
|
53
|
-
value: string;
|
|
54
|
-
color: string;
|
|
55
|
-
};
|
|
56
|
-
icon: {
|
|
57
|
-
value: string;
|
|
58
|
-
color: string;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
export interface Brand {
|
|
62
|
-
inapp?: {
|
|
63
|
-
disableCourierFooter?: boolean;
|
|
64
|
-
borderRadius?: string;
|
|
65
|
-
disableMessageIcon?: boolean;
|
|
66
|
-
placement?: "top" | "bottom" | "left" | "right";
|
|
67
|
-
emptyState?: {
|
|
68
|
-
textColor?: string;
|
|
69
|
-
text?: string;
|
|
70
|
-
};
|
|
71
|
-
widgetBackground?: {
|
|
72
|
-
topColor?: string;
|
|
73
|
-
bottomColor?: string;
|
|
74
|
-
};
|
|
75
|
-
icons?: {
|
|
76
|
-
bell?: string;
|
|
77
|
-
message?: string;
|
|
78
|
-
};
|
|
79
|
-
slots?: Array<PinDetails>;
|
|
80
|
-
toast?: {
|
|
81
|
-
borderRadius?: string;
|
|
82
|
-
timerAutoClose?: number;
|
|
83
|
-
};
|
|
84
|
-
renderActionsAsButtons?: boolean;
|
|
85
|
-
};
|
|
86
|
-
preferenceTemplates?: Array<IPreferenceTemplate>;
|
|
87
|
-
colors?: {
|
|
88
|
-
primary?: string;
|
|
89
|
-
secondary?: string;
|
|
90
|
-
tertiary?: string;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
export declare type EventType = "add-tag" | "archive" | "click" | "mark-all-read" | "opened" | "read" | "remove-tag" | "unpin" | "unread";
|
|
1
|
+
import { CourierTransport, Transport, WSOptions } from "@trycourier/transport";
|
|
2
|
+
import { Interceptor } from "@trycourier/core";
|
|
3
|
+
import { Brand } from "@trycourier/core";
|
|
4
|
+
import { IInboxMessagePreview } from "@trycourier/core";
|
|
94
5
|
export interface ThemeVariables {
|
|
95
6
|
background?: string;
|
|
96
7
|
textColor?: string;
|
|
@@ -99,6 +10,12 @@ export interface ThemeVariables {
|
|
|
99
10
|
structure?: string;
|
|
100
11
|
icon?: string;
|
|
101
12
|
}
|
|
13
|
+
export declare type OnEvent = (eventParams: {
|
|
14
|
+
messageId?: string;
|
|
15
|
+
message?: IInboxMessagePreview;
|
|
16
|
+
event: string;
|
|
17
|
+
data?: Record<string, unknown>;
|
|
18
|
+
}) => void;
|
|
102
19
|
export interface ProviderTheme {
|
|
103
20
|
colorMode?: "dark" | "light";
|
|
104
21
|
variables?: ThemeVariables;
|
package/typings/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,OAAO,GAAG,CAAC,WAAW,EAAE;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,KAAK,IAAI,CAAC;AAEX,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AACD,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,CAAC,iBAAiB,EAAE,GAAG,KAAK,GAAG,EAAE,CAAC;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AACD,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,EAAE,CACT,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
|
|
12
|
-
var _transports = require("../transports");
|
|
13
|
-
|
|
14
|
-
var _jwtDecode = _interopRequireDefault(require("jwt-decode"));
|
|
15
|
-
|
|
16
|
-
var useTransport = function useTransport(_ref) {
|
|
17
|
-
var tenantId = _ref.tenantId,
|
|
18
|
-
authorization = _ref.authorization,
|
|
19
|
-
clientSourceId = _ref.clientSourceId,
|
|
20
|
-
clientKey = _ref.clientKey,
|
|
21
|
-
transport = _ref.transport,
|
|
22
|
-
userSignature = _ref.userSignature,
|
|
23
|
-
wsOptions = _ref.wsOptions;
|
|
24
|
-
var transportRef = (0, _react.useRef)();
|
|
25
|
-
var newTransport = (0, _react.useMemo)(function () {
|
|
26
|
-
var _transportRef$current;
|
|
27
|
-
|
|
28
|
-
if (transport) {
|
|
29
|
-
return transport;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (authorization && transportRef !== null && transportRef !== void 0 && (_transportRef$current = transportRef.current) !== null && _transportRef$current !== void 0 && _transportRef$current.authorization && transportRef !== null && transportRef !== void 0 && transportRef.current.transport) {
|
|
33
|
-
var _transportRef$current2;
|
|
34
|
-
|
|
35
|
-
var oldDecodedAuth = (0, _jwtDecode["default"])(transportRef === null || transportRef === void 0 ? void 0 : (_transportRef$current2 = transportRef.current) === null || _transportRef$current2 === void 0 ? void 0 : _transportRef$current2.authorization);
|
|
36
|
-
var newDecodedAuth = (0, _jwtDecode["default"])(authorization);
|
|
37
|
-
|
|
38
|
-
if (oldDecodedAuth.scope === newDecodedAuth.scope && oldDecodedAuth.tenantId === newDecodedAuth.tenantId) {
|
|
39
|
-
transportRef.current.transport.renewSession(authorization);
|
|
40
|
-
return transportRef.current.transport;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!clientKey && !authorization) {
|
|
45
|
-
if (undefined !== "production") {
|
|
46
|
-
console.warn("Courier: Missing ClientKey or Authorization");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!clientSourceId) {
|
|
53
|
-
if (undefined !== "production") {
|
|
54
|
-
console.warn("Courier: Missing ClientSourceId");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var newTransport = new _transports.CourierTransport({
|
|
61
|
-
tenantId: tenantId,
|
|
62
|
-
authorization: authorization,
|
|
63
|
-
clientSourceId: clientSourceId,
|
|
64
|
-
clientKey: clientKey,
|
|
65
|
-
userSignature: userSignature,
|
|
66
|
-
wsOptions: wsOptions
|
|
67
|
-
}); // keep track of the transport so we don't reconnect when we don't have to
|
|
68
|
-
|
|
69
|
-
if (authorization) {
|
|
70
|
-
transportRef.current = {
|
|
71
|
-
authorization: authorization,
|
|
72
|
-
transport: newTransport
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return newTransport;
|
|
77
|
-
}, [tenantId, authorization, clientKey, transport, userSignature, wsOptions]);
|
|
78
|
-
return newTransport;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
var _default = useTransport;
|
|
82
|
-
exports["default"] = _default;
|
package/dist/lib/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDateDiff = void 0;
|
|
7
|
-
|
|
8
|
-
var getDateDiff = function getDateDiff(date) {
|
|
9
|
-
if (!date) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
var now = new Date().getTime();
|
|
14
|
-
var dateDiff = now - date; // if datediff is 0, return 1 so we can do "!datediff"
|
|
15
|
-
|
|
16
|
-
return Math.max(dateDiff, 1);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.getDateDiff = getDateDiff;
|
package/dist/transports/base.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.Transport = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
15
|
-
|
|
16
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
-
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
19
|
-
|
|
20
|
-
var ListenerType;
|
|
21
|
-
|
|
22
|
-
(function (ListenerType) {
|
|
23
|
-
ListenerType["message"] = "message";
|
|
24
|
-
ListenerType["event"] = "event";
|
|
25
|
-
})(ListenerType || (ListenerType = {}));
|
|
26
|
-
|
|
27
|
-
var Transport = function Transport() {
|
|
28
|
-
var _this = this;
|
|
29
|
-
|
|
30
|
-
(0, _classCallCheck2["default"])(this, Transport);
|
|
31
|
-
|
|
32
|
-
this.emit = function (courierEvent) {
|
|
33
|
-
var _courierEvent$type;
|
|
34
|
-
|
|
35
|
-
var eventType = (_courierEvent$type = courierEvent.type) !== null && _courierEvent$type !== void 0 ? _courierEvent$type : "message";
|
|
36
|
-
var listeners = _this.listeners[eventType];
|
|
37
|
-
|
|
38
|
-
if (!listeners.length) {
|
|
39
|
-
console.warn("No Listeners Registered");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var _iterator = _createForOfIteratorHelper(listeners),
|
|
44
|
-
_step;
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
|
-
var listener = _step.value.listener;
|
|
49
|
-
listener(courierEvent);
|
|
50
|
-
}
|
|
51
|
-
} catch (err) {
|
|
52
|
-
_iterator.e(err);
|
|
53
|
-
} finally {
|
|
54
|
-
_iterator.f();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
this.listen = function (listener) {
|
|
59
|
-
var _listener$type;
|
|
60
|
-
|
|
61
|
-
var didReplaceListener = false;
|
|
62
|
-
var eventType = (_listener$type = listener.type) !== null && _listener$type !== void 0 ? _listener$type : "message";
|
|
63
|
-
var listeners = _this.listeners[eventType];
|
|
64
|
-
listeners = listeners.map(function (l) {
|
|
65
|
-
if (l.id === listener.id) {
|
|
66
|
-
didReplaceListener = true;
|
|
67
|
-
return listener;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return l;
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
if (didReplaceListener) {
|
|
74
|
-
_this.listeners[eventType] = listeners;
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
_this.listeners[eventType] = [].concat((0, _toConsumableArray2["default"])(_this.listeners[eventType]), [listener]);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
this.intercept = function (cb) {
|
|
82
|
-
_this.interceptor = cb;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
this.listeners = {
|
|
86
|
-
message: [],
|
|
87
|
-
event: []
|
|
88
|
-
};
|
|
89
|
-
this.interceptor = undefined;
|
|
90
|
-
}
|
|
91
|
-
/** Callback for emitted events */
|
|
92
|
-
;
|
|
93
|
-
|
|
94
|
-
exports.Transport = Transport;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.CourierTransport = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _ws = require("../../ws");
|
|
23
|
-
|
|
24
|
-
var _base = require("../base");
|
|
25
|
-
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
31
|
-
|
|
32
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
-
|
|
34
|
-
var CourierTransport = /*#__PURE__*/function (_Transport) {
|
|
35
|
-
(0, _inherits2["default"])(CourierTransport, _Transport);
|
|
36
|
-
|
|
37
|
-
var _super = _createSuper(CourierTransport);
|
|
38
|
-
|
|
39
|
-
function CourierTransport(options) {
|
|
40
|
-
var _options$wsOptions;
|
|
41
|
-
|
|
42
|
-
var _this;
|
|
43
|
-
|
|
44
|
-
(0, _classCallCheck2["default"])(this, CourierTransport);
|
|
45
|
-
_this = _super.call(this);
|
|
46
|
-
|
|
47
|
-
if (!options.clientKey && !options.authorization) {
|
|
48
|
-
throw new Error("Missing Authorization");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_this.authorization = options.authorization;
|
|
52
|
-
_this.clientSourceId = options.clientSourceId;
|
|
53
|
-
_this.clientKey = options.clientKey;
|
|
54
|
-
_this.userSignature = options.userSignature;
|
|
55
|
-
_this.ws = new _ws.WS({
|
|
56
|
-
tenantId: options.tenantId,
|
|
57
|
-
authorization: options.authorization,
|
|
58
|
-
clientSourceId: options.clientSourceId,
|
|
59
|
-
clientKey: options.clientKey,
|
|
60
|
-
options: options.wsOptions,
|
|
61
|
-
userSignature: options.userSignature
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
_this.ws.connect();
|
|
65
|
-
|
|
66
|
-
if ((_options$wsOptions = options.wsOptions) !== null && _options$wsOptions !== void 0 && _options$wsOptions.onReconnect) {
|
|
67
|
-
var _options$wsOptions2;
|
|
68
|
-
|
|
69
|
-
_this.ws.onReconnection({
|
|
70
|
-
id: "propReconnect",
|
|
71
|
-
callback: (_options$wsOptions2 = options.wsOptions) === null || _options$wsOptions2 === void 0 ? void 0 : _options$wsOptions2.onReconnect
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return _this;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
(0, _createClass2["default"])(CourierTransport, [{
|
|
79
|
-
key: "closeConnection",
|
|
80
|
-
value: function closeConnection() {
|
|
81
|
-
this.ws.close();
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "connect",
|
|
85
|
-
value: function connect() {
|
|
86
|
-
this.ws.connect();
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "keepAlive",
|
|
90
|
-
value: function keepAlive() {
|
|
91
|
-
this.ws.send({
|
|
92
|
-
action: "keepAlive"
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
key: "send",
|
|
97
|
-
value: function send(message) {
|
|
98
|
-
this.ws.send(_objectSpread(_objectSpread({}, message), {}, {
|
|
99
|
-
data: _objectSpread(_objectSpread({}, message.data), {}, {
|
|
100
|
-
clientKey: this.clientKey
|
|
101
|
-
})
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "subscribe",
|
|
106
|
-
value: function subscribe(channel, event) {
|
|
107
|
-
var _this2 = this;
|
|
108
|
-
|
|
109
|
-
this.ws.subscribe(channel, event !== null && event !== void 0 ? event : "*", function (_ref) {
|
|
110
|
-
var _courierEvent$type;
|
|
111
|
-
|
|
112
|
-
var courierEvent = _ref.data;
|
|
113
|
-
|
|
114
|
-
if (_this2.interceptor) {
|
|
115
|
-
courierEvent = _this2.interceptor(courierEvent);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!courierEvent) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
_this2.emit({
|
|
123
|
-
type: (_courierEvent$type = courierEvent.type) !== null && _courierEvent$type !== void 0 ? _courierEvent$type : "message",
|
|
124
|
-
data: courierEvent
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "unsubscribe",
|
|
130
|
-
value: function unsubscribe(channel, event) {
|
|
131
|
-
this.ws.unsubscribe(channel, event !== null && event !== void 0 ? event : "*");
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
key: "onReconnection",
|
|
135
|
-
value: function onReconnection(handler) {
|
|
136
|
-
this.ws.onReconnection(handler);
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
key: "renewSession",
|
|
140
|
-
value: function renewSession(token) {
|
|
141
|
-
this.ws.renewSession(token);
|
|
142
|
-
}
|
|
143
|
-
}]);
|
|
144
|
-
return CourierTransport;
|
|
145
|
-
}(_base.Transport);
|
|
146
|
-
|
|
147
|
-
exports.CourierTransport = CourierTransport;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/transports/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _courier = require("./courier");
|
|
8
|
-
|
|
9
|
-
Object.keys(_courier).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _courier[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _courier[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _base = require("./base");
|
|
21
|
-
|
|
22
|
-
Object.keys(_base).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _base[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function get() {
|
|
28
|
-
return _base[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
package/dist/transports/types.js
DELETED
|
File without changes
|
package/dist/ws.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.WS = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
|
-
var _reconnectingWebsocket = _interopRequireDefault(require("reconnecting-websocket"));
|
|
19
|
-
|
|
20
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
21
|
-
|
|
22
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
-
|
|
24
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
-
|
|
26
|
-
var SUBSCRIPTION_VERSION = 5;
|
|
27
|
-
|
|
28
|
-
var WS = /*#__PURE__*/function () {
|
|
29
|
-
function WS(_ref) {
|
|
30
|
-
var tenantId = _ref.tenantId,
|
|
31
|
-
authorization = _ref.authorization,
|
|
32
|
-
clientKey = _ref.clientKey,
|
|
33
|
-
options = _ref.options,
|
|
34
|
-
clientSourceId = _ref.clientSourceId,
|
|
35
|
-
userSignature = _ref.userSignature;
|
|
36
|
-
(0, _classCallCheck2["default"])(this, WS);
|
|
37
|
-
this.tenantId = tenantId;
|
|
38
|
-
this.connectionCount = 0;
|
|
39
|
-
this.authorization = authorization;
|
|
40
|
-
this.messageCallback = null;
|
|
41
|
-
this.connection = undefined;
|
|
42
|
-
this.connected = false;
|
|
43
|
-
this.url = (options === null || options === void 0 ? void 0 : options.url) || "" || "wss://realtime.courier.com";
|
|
44
|
-
this.clientSourceId = clientSourceId;
|
|
45
|
-
this.clientKey = clientKey;
|
|
46
|
-
this.userSignature = userSignature;
|
|
47
|
-
this.subscriptions = [];
|
|
48
|
-
this.onReconnectionHandlers = [];
|
|
49
|
-
this.connectionTimeout = options === null || options === void 0 ? void 0 : options.connectionTimeout;
|
|
50
|
-
this.onError = options === null || options === void 0 ? void 0 : options.onError;
|
|
51
|
-
this.onClose = options === null || options === void 0 ? void 0 : options.onClose;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
(0, _createClass2["default"])(WS, [{
|
|
55
|
-
key: "close",
|
|
56
|
-
value: function close() {
|
|
57
|
-
if (!this.connected || !this.connection) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
this.connection.close();
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "getUrl",
|
|
65
|
-
value: function getUrl() {
|
|
66
|
-
return "".concat(this.url, "/?").concat(this.authorization ? "auth=".concat(this.authorization) : "clientKey=".concat(this.clientKey));
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "connect",
|
|
70
|
-
value: function connect() {
|
|
71
|
-
this.connection = new _reconnectingWebsocket["default"](this.getUrl.bind(this), [], {
|
|
72
|
-
connectionTimeout: this.connectionTimeout
|
|
73
|
-
});
|
|
74
|
-
this.connection.onopen = this._onOpen.bind(this);
|
|
75
|
-
this.connection.onclose = this._onClose.bind(this);
|
|
76
|
-
this.connection.onerror = this._onError.bind(this);
|
|
77
|
-
this.connection.onmessage = this._onMessage.bind(this);
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "_onError",
|
|
81
|
-
value: function _onError(event) {
|
|
82
|
-
var _this$connection;
|
|
83
|
-
|
|
84
|
-
if (this.onError) {
|
|
85
|
-
this.onError(event);
|
|
86
|
-
} else {
|
|
87
|
-
console.error("Error Connecting to Courier Push");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
(_this$connection = this.connection) === null || _this$connection === void 0 ? void 0 : _this$connection.close();
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "_onClose",
|
|
94
|
-
value: function _onClose() {
|
|
95
|
-
this.connected = false;
|
|
96
|
-
|
|
97
|
-
if (this.onClose) {
|
|
98
|
-
this.onClose();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "_onOpen",
|
|
103
|
-
value: function _onOpen() {
|
|
104
|
-
this.connected = true;
|
|
105
|
-
this.connectionCount++;
|
|
106
|
-
|
|
107
|
-
if (this.connectionCount > 1) {
|
|
108
|
-
var _iterator = _createForOfIteratorHelper(this.onReconnectionHandlers),
|
|
109
|
-
_step;
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
113
|
-
var reconnectHandler = _step.value;
|
|
114
|
-
reconnectHandler.callback();
|
|
115
|
-
}
|
|
116
|
-
} catch (err) {
|
|
117
|
-
_iterator.e(err);
|
|
118
|
-
} finally {
|
|
119
|
-
_iterator.f();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
var _iterator2 = _createForOfIteratorHelper(this.subscriptions),
|
|
124
|
-
_step2;
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
128
|
-
var sub = _step2.value;
|
|
129
|
-
this.send({
|
|
130
|
-
action: "subscribe",
|
|
131
|
-
data: {
|
|
132
|
-
// [HACK] map tenantId to accountId in order to keep this backwards compatible
|
|
133
|
-
accountId: this.tenantId,
|
|
134
|
-
channel: sub.channel,
|
|
135
|
-
clientSourceId: this.clientSourceId,
|
|
136
|
-
clientKey: this.clientKey,
|
|
137
|
-
event: sub.event,
|
|
138
|
-
userSignature: this.userSignature,
|
|
139
|
-
version: SUBSCRIPTION_VERSION
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
} catch (err) {
|
|
144
|
-
_iterator2.e(err);
|
|
145
|
-
} finally {
|
|
146
|
-
_iterator2.f();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "_onMessage",
|
|
151
|
-
value: function _onMessage(_ref2) {
|
|
152
|
-
var data = _ref2.data;
|
|
153
|
-
var message;
|
|
154
|
-
|
|
155
|
-
try {
|
|
156
|
-
message = JSON.parse(data);
|
|
157
|
-
} catch (_unused) {
|
|
158
|
-
console.error("Error Parsing Courier Message");
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (message.error) {
|
|
163
|
-
console.error(message.error);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
var _iterator3 = _createForOfIteratorHelper(this.subscriptions),
|
|
168
|
-
_step3;
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
172
|
-
var _message, _message$type;
|
|
173
|
-
|
|
174
|
-
var sub = _step3.value;
|
|
175
|
-
|
|
176
|
-
if (sub.event !== "*" && sub.event !== ((_message = message) === null || _message === void 0 ? void 0 : _message.event)) {
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
sub.callback({
|
|
181
|
-
type: (_message$type = message.type) !== null && _message$type !== void 0 ? _message$type : "message",
|
|
182
|
-
data: message
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
} catch (err) {
|
|
186
|
-
_iterator3.e(err);
|
|
187
|
-
} finally {
|
|
188
|
-
_iterator3.f();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}, {
|
|
192
|
-
key: "subscribe",
|
|
193
|
-
value: function () {
|
|
194
|
-
var _subscribe = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(channel, event, callback) {
|
|
195
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
196
|
-
while (1) {
|
|
197
|
-
switch (_context.prev = _context.next) {
|
|
198
|
-
case 0:
|
|
199
|
-
this.subscriptions.push({
|
|
200
|
-
channel: channel,
|
|
201
|
-
event: event,
|
|
202
|
-
callback: callback
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
if (this.connected) {
|
|
206
|
-
this.send({
|
|
207
|
-
action: "subscribe",
|
|
208
|
-
data: {
|
|
209
|
-
// [HACK] map tenantId to accountId in order to keep this backwards compatible
|
|
210
|
-
accountId: this.tenantId,
|
|
211
|
-
channel: channel,
|
|
212
|
-
clientKey: this.clientKey,
|
|
213
|
-
clientSourceId: this.clientSourceId,
|
|
214
|
-
event: event,
|
|
215
|
-
userSignature: this.userSignature,
|
|
216
|
-
version: SUBSCRIPTION_VERSION
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
case 2:
|
|
222
|
-
case "end":
|
|
223
|
-
return _context.stop();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}, _callee, this);
|
|
227
|
-
}));
|
|
228
|
-
|
|
229
|
-
function subscribe(_x, _x2, _x3) {
|
|
230
|
-
return _subscribe.apply(this, arguments);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return subscribe;
|
|
234
|
-
}()
|
|
235
|
-
}, {
|
|
236
|
-
key: "send",
|
|
237
|
-
value: function send(message) {
|
|
238
|
-
if (!this.connected || !this.connection) {
|
|
239
|
-
console.warn("WS Not Connected");
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
this.connection.send(JSON.stringify(message));
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "unsubscribe",
|
|
247
|
-
value: function unsubscribe(channel, event) {
|
|
248
|
-
this.subscriptions = this.subscriptions.filter(function (sub) {
|
|
249
|
-
return !(sub.channel === channel && sub.event === event);
|
|
250
|
-
});
|
|
251
|
-
this.send({
|
|
252
|
-
action: "unsubscribe",
|
|
253
|
-
data: {
|
|
254
|
-
channel: channel,
|
|
255
|
-
clientKey: this.clientKey,
|
|
256
|
-
event: event,
|
|
257
|
-
userSignature: this.userSignature,
|
|
258
|
-
version: SUBSCRIPTION_VERSION
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
}, {
|
|
263
|
-
key: "renewSession",
|
|
264
|
-
value: function renewSession(newAuthorization) {
|
|
265
|
-
this.authorization = newAuthorization;
|
|
266
|
-
|
|
267
|
-
if (!this.connected || !this.connection) {
|
|
268
|
-
this.connect();
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
this.send({
|
|
273
|
-
action: "renewSession",
|
|
274
|
-
data: {
|
|
275
|
-
auth: newAuthorization,
|
|
276
|
-
version: SUBSCRIPTION_VERSION
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}, {
|
|
281
|
-
key: "onReconnection",
|
|
282
|
-
value: function onReconnection(handler) {
|
|
283
|
-
if (this.onReconnectionHandlers.find(function (h) {
|
|
284
|
-
return h.id === handler.id;
|
|
285
|
-
})) {
|
|
286
|
-
var _this$onReconnectionH;
|
|
287
|
-
|
|
288
|
-
this.onReconnectionHandlers = (_this$onReconnectionH = this.onReconnectionHandlers) === null || _this$onReconnectionH === void 0 ? void 0 : _this$onReconnectionH.map(function (h) {
|
|
289
|
-
if (h.id === handler.id) {
|
|
290
|
-
return handler;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return h;
|
|
294
|
-
});
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
this.onReconnectionHandlers.push(handler);
|
|
299
|
-
}
|
|
300
|
-
}]);
|
|
301
|
-
return WS;
|
|
302
|
-
}();
|
|
303
|
-
|
|
304
|
-
exports.WS = WS;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CourierTransport, Transport } from "~/transports";
|
|
2
|
-
import { ITransportOptions } from "~/transports/courier/types";
|
|
3
|
-
declare const useTransport: ({ tenantId, authorization, clientSourceId, clientKey, transport, userSignature, wsOptions, }: {
|
|
4
|
-
tenantId?: string | undefined;
|
|
5
|
-
authorization?: string | undefined;
|
|
6
|
-
clientSourceId?: string | undefined;
|
|
7
|
-
clientKey?: string | undefined;
|
|
8
|
-
transport?: Transport | CourierTransport | undefined;
|
|
9
|
-
userSignature?: string | undefined;
|
|
10
|
-
wsOptions?: ITransportOptions["wsOptions"];
|
|
11
|
-
}) => CourierTransport | Transport | undefined;
|
|
12
|
-
export default useTransport;
|
|
13
|
-
//# sourceMappingURL=use-transport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-transport.d.ts","sourceRoot":"","sources":["../../src/hooks/use-transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAM/D,QAAA,MAAM,YAAY;;;;;;;gBAeJ,iBAAiB,CAAC,WAAW,CAAC;MACxC,gBAAgB,GAAG,SAAS,GAAG,SAiElC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/typings/lib/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,mDAUvB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ICourierEvent, Interceptor } from "./types";
|
|
2
|
-
declare enum ListenerType {
|
|
3
|
-
message = "message",
|
|
4
|
-
event = "event"
|
|
5
|
-
}
|
|
6
|
-
export declare class Transport {
|
|
7
|
-
constructor();
|
|
8
|
-
/** Callback for emitted events */
|
|
9
|
-
protected listeners: {
|
|
10
|
-
[key in ListenerType]: Array<{
|
|
11
|
-
id: string;
|
|
12
|
-
listener: (courierEvent: ICourierEvent) => void;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
|
-
protected interceptor?: Interceptor;
|
|
16
|
-
/** Wrapper method for emitted events */
|
|
17
|
-
protected emit: (courierEvent: ICourierEvent) => void;
|
|
18
|
-
/** Setter method for a listener */
|
|
19
|
-
listen: (listener: {
|
|
20
|
-
id: string;
|
|
21
|
-
type?: "event" | "message" | undefined;
|
|
22
|
-
listener: (courierEvent: ICourierEvent) => void;
|
|
23
|
-
}) => void;
|
|
24
|
-
intercept: (cb: Interceptor) => void;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/transports/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAErD,aAAK,YAAY;IACf,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AACD,qBAAa,SAAS;;IASpB,mCAAmC;IACnC,SAAS,CAAC,SAAS,EAAE;SAClB,GAAG,IAAI,YAAY,GAAG,KAAK,CAAC;YAC3B,EAAE,EAAE,MAAM,CAAC;YACX,QAAQ,EAAE,CAAC,YAAY,EAAE,aAAa,KAAK,IAAI,CAAC;SACjD,CAAC;KACH,CAAC;IAEF,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACpC,yCAAyC;IACzC,SAAS,CAAC,IAAI,iBAAkB,aAAa,KAAG,IAAI,CAYlD;IAEF,mCAAmC;IACnC,MAAM;YACA,MAAM;;iCAEe,aAAa,KAAK,IAAI;UAC7C,IAAI,CAoBN;IAEF,SAAS,OAAQ,WAAW,KAAG,IAAI,CAEjC;CACH"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { WS } from "../../ws";
|
|
2
|
-
import { Transport } from "../base";
|
|
3
|
-
import { Interceptor } from "../types";
|
|
4
|
-
import { ITransportOptions } from "./types";
|
|
5
|
-
export declare class CourierTransport extends Transport {
|
|
6
|
-
protected tenantId?: string;
|
|
7
|
-
protected authorization?: string;
|
|
8
|
-
protected clientSourceId: string;
|
|
9
|
-
protected clientKey?: string;
|
|
10
|
-
protected interceptor?: Interceptor;
|
|
11
|
-
protected userSignature?: string;
|
|
12
|
-
protected ws: WS;
|
|
13
|
-
constructor(options: ITransportOptions);
|
|
14
|
-
closeConnection(): void;
|
|
15
|
-
connect(): void;
|
|
16
|
-
keepAlive(): void;
|
|
17
|
-
send(message: any): void;
|
|
18
|
-
subscribe(channel: string, event?: string): void;
|
|
19
|
-
unsubscribe(channel: string, event?: string): void;
|
|
20
|
-
onReconnection(handler: {
|
|
21
|
-
id: string;
|
|
22
|
-
callback: () => void;
|
|
23
|
-
}): void;
|
|
24
|
-
renewSession(token: string): void;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAkB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC5C,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;gBAEL,OAAO,EAAE,iBAAiB;IA+BtC,eAAe,IAAI,IAAI;IAIvB,OAAO,IAAI,IAAI;IAIf,SAAS,IAAI,IAAI;IAMjB,IAAI,CAAC,OAAO,KAAA,GAAG,IAAI;IAUnB,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;IAIlD,cAAc,CAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;KAAE,GAAG,IAAI;IAInE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAGlC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { WSOptions } from "~/types";
|
|
2
|
-
export interface ITransportOptions {
|
|
3
|
-
tenantId?: string;
|
|
4
|
-
authorization?: string;
|
|
5
|
-
clientKey?: string;
|
|
6
|
-
clientSourceId: string;
|
|
7
|
-
userSignature?: string;
|
|
8
|
-
wsOptions?: WSOptions;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/transports/courier/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transports/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export interface ICourierEventMessage {
|
|
2
|
-
event: "read" | "unread" | "archive" | "mark-all-read" | "opened" | "unpin";
|
|
3
|
-
type: "event";
|
|
4
|
-
messageId?: string;
|
|
5
|
-
error?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ITextElemental {
|
|
8
|
-
type: "text";
|
|
9
|
-
content: string;
|
|
10
|
-
}
|
|
11
|
-
export interface IActionElemental {
|
|
12
|
-
background_color?: string;
|
|
13
|
-
type: "action";
|
|
14
|
-
content: string;
|
|
15
|
-
href: string;
|
|
16
|
-
data?: Record<string, any>;
|
|
17
|
-
}
|
|
18
|
-
export interface IInboxMessagePreview {
|
|
19
|
-
type: "message";
|
|
20
|
-
archived?: string;
|
|
21
|
-
created: string;
|
|
22
|
-
messageId: string;
|
|
23
|
-
pinned?: {
|
|
24
|
-
slotId?: string;
|
|
25
|
-
};
|
|
26
|
-
actions?: Array<IActionElemental>;
|
|
27
|
-
preview?: string;
|
|
28
|
-
icon?: string;
|
|
29
|
-
opened?: string;
|
|
30
|
-
data?: Record<string, any>;
|
|
31
|
-
/** ISO 8601 date the message was read */
|
|
32
|
-
read?: string;
|
|
33
|
-
tags?: string[];
|
|
34
|
-
title?: string;
|
|
35
|
-
trackingIds?: {
|
|
36
|
-
openTrackingId?: string;
|
|
37
|
-
archiveTrackingId?: string;
|
|
38
|
-
clickTrackingId?: string;
|
|
39
|
-
deliverTrackingId?: string;
|
|
40
|
-
readTrackingId?: string;
|
|
41
|
-
unreadTrackingId?: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export interface ICourierEvent {
|
|
45
|
-
type?: "message" | "event";
|
|
46
|
-
data?: IInboxMessagePreview | ICourierEventMessage;
|
|
47
|
-
}
|
|
48
|
-
export declare type ICourierEventCallback = (event: ICourierEvent) => void;
|
|
49
|
-
export declare type Interceptor = (message?: ICourierEventMessage | IInboxMessagePreview) => IInboxMessagePreview | ICourierEventMessage | undefined;
|
|
50
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/transports/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,eAAe,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC5E,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE;QACZ,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,CAAC;CACpD;AAED,oBAAY,qBAAqB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAEnE,oBAAY,WAAW,GAAG,CACxB,OAAO,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,KAClD,oBAAoB,GAAG,oBAAoB,GAAG,SAAS,CAAC"}
|
package/typings/ws.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ICourierEventCallback } from "./transports/types";
|
|
2
|
-
import ReconnectingWebSocket from "reconnecting-websocket";
|
|
3
|
-
import { WSOptions } from "./types";
|
|
4
|
-
export declare class WS {
|
|
5
|
-
connection?: ReconnectingWebSocket;
|
|
6
|
-
private subscriptions;
|
|
7
|
-
private tenantId?;
|
|
8
|
-
private clientSourceId?;
|
|
9
|
-
private authorization?;
|
|
10
|
-
private clientKey?;
|
|
11
|
-
private connectionTimeout?;
|
|
12
|
-
private onError?;
|
|
13
|
-
private onClose?;
|
|
14
|
-
private onReconnectionHandlers;
|
|
15
|
-
private url;
|
|
16
|
-
private userSignature?;
|
|
17
|
-
private connectionCount;
|
|
18
|
-
protected connected: any;
|
|
19
|
-
protected messageCallback: any;
|
|
20
|
-
constructor({ tenantId, authorization, clientKey, options, clientSourceId, userSignature, }: {
|
|
21
|
-
tenantId?: string;
|
|
22
|
-
authorization?: string;
|
|
23
|
-
clientSourceId?: string;
|
|
24
|
-
clientKey?: string;
|
|
25
|
-
options?: WSOptions;
|
|
26
|
-
userSignature?: string;
|
|
27
|
-
});
|
|
28
|
-
close(): void;
|
|
29
|
-
getUrl(): string;
|
|
30
|
-
connect(): void;
|
|
31
|
-
private _onError;
|
|
32
|
-
private _onClose;
|
|
33
|
-
private _onOpen;
|
|
34
|
-
private _onMessage;
|
|
35
|
-
subscribe(channel: string, event: string, callback: ICourierEventCallback): Promise<void>;
|
|
36
|
-
send(message: {
|
|
37
|
-
[key: string]: any;
|
|
38
|
-
}): void;
|
|
39
|
-
unsubscribe(channel: string, event: string): void;
|
|
40
|
-
renewSession(newAuthorization: string): void;
|
|
41
|
-
onReconnection(handler: {
|
|
42
|
-
id: string;
|
|
43
|
-
callback: () => void;
|
|
44
|
-
}): void;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=ws.d.ts.map
|
package/typings/ws.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../src/ws.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,qBAAqC,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAC;AAGvD,qBAAa,EAAE;IACb,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,OAAO,CAAC,aAAa,CAIlB;IACH,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAS;IACnC,OAAO,CAAC,OAAO,CAAC,CAAoB;IACpC,OAAO,CAAC,OAAO,CAAC,CAAa;IAC7B,OAAO,CAAC,sBAAsB,CAG3B;IACH,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,eAAe,CAAS;IAChC,SAAS,CAAC,SAAS,MAAC;IACpB,SAAS,CAAC,eAAe,MAAC;gBAEd,EACV,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,cAAc,EACd,aAAa,GACd,EAAE;QACD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,SAAS,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;IAqBD,KAAK,IAAI,IAAI;IAQb,MAAM,IAAI,MAAM;IAQhB,OAAO,IAAI,IAAI;IAWf,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,OAAO;IA2Bf,OAAO,CAAC,UAAU;IA2BZ,SAAS,CACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,IAAI,CAAC;IAwBhB,IAAI,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,IAAI;IAS3C,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAiBjD,YAAY,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAgB5C,cAAc,CAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;KAAE,GAAG,IAAI;CAcpE"}
|