@memberstack/dom 1.6.0 → 1.7.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/lib/index.d.ts +1 -0
- package/lib/methods/dom/methods.js +5 -2
- package/lib/methods/index.d.ts +1 -0
- package/lib/methods/index.js +6 -0
- package/lib/utils/proxy.js +5 -1
- package/package.json +4 -3
package/lib/index.d.ts
CHANGED
|
@@ -227,7 +227,7 @@ var openModal = function (props) { return __awaiter(void 0, void 0, void 0, func
|
|
|
227
227
|
div.append(iframe);
|
|
228
228
|
document.body.appendChild(div);
|
|
229
229
|
window.addEventListener("message", function (e) {
|
|
230
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
230
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
231
231
|
if (e.data.type === "CLOSE") {
|
|
232
232
|
return (0, exports.hideModal)();
|
|
233
233
|
}
|
|
@@ -237,7 +237,10 @@ var openModal = function (props) { return __awaiter(void 0, void 0, void 0, func
|
|
|
237
237
|
if (props.useCookie && ((_f = (_e = (_d = e.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.tokens) === null || _f === void 0 ? void 0 : _f.accessToken)) {
|
|
238
238
|
(0, cookies_1.setMemberCookie)(e.data.data.tokens.accessToken);
|
|
239
239
|
}
|
|
240
|
-
|
|
240
|
+
// added to prevent non memberstack messages being sent from window
|
|
241
|
+
if (e.origin === endpoint_1.endpoints.hostedUI && ((_g = e.data) === null || _g === void 0 ? void 0 : _g.data)) {
|
|
242
|
+
(_j = (_h = props.options) === null || _h === void 0 ? void 0 : _h.onCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, (_k = e.data) === null || _k === void 0 ? void 0 : _k.data);
|
|
243
|
+
}
|
|
241
244
|
});
|
|
242
245
|
return [2 /*return*/, iframe];
|
|
243
246
|
}
|
package/lib/methods/index.d.ts
CHANGED
package/lib/methods/index.js
CHANGED
|
@@ -50,12 +50,14 @@ var DOM = __importStar(require("./dom/methods"));
|
|
|
50
50
|
var client_1 = require("./client");
|
|
51
51
|
var interceptor_1 = require("../utils/interceptor");
|
|
52
52
|
var logger_1 = require("../utils/logger");
|
|
53
|
+
var cookies_1 = require("../utils/cookies");
|
|
53
54
|
var DOMMethods = function (_a) {
|
|
54
55
|
var _b = _a.useCookie, useCookie = _b === void 0 ? true : _b, _c = _a.persistence, persistence = _c === void 0 ? persistence_1.Persistence.LOCAL : _c, props = __rest(_a, ["useCookie", "persistence"]);
|
|
55
56
|
return ({
|
|
56
57
|
load: function () { return DOM.load({ publicKey: props.publicKey }); },
|
|
57
58
|
hideModal: DOM.hideModal,
|
|
58
59
|
onAuthChange: persistence_1.onAuthChange,
|
|
60
|
+
getMemberCookie: function () { return (0, cookies_1.getMemberCookie)(); },
|
|
59
61
|
_showLoader: DOM.showLoader,
|
|
60
62
|
_hideLoader: DOM.hideLoader,
|
|
61
63
|
_showMessage: DOM.showMessage,
|
|
@@ -64,6 +66,10 @@ var DOMMethods = function (_a) {
|
|
|
64
66
|
};
|
|
65
67
|
function init(props) {
|
|
66
68
|
(0, logger_1.initializeLogger)(props.debug);
|
|
69
|
+
// added because default persistence is not being set in DOMMethods above
|
|
70
|
+
if (!props.persistence) {
|
|
71
|
+
props.persistence = persistence_1.Persistence.LOCAL;
|
|
72
|
+
}
|
|
67
73
|
var client = (0, proxy_1.default)((0, client_1.initClient)(__assign(__assign({}, props), { onMemberToken: function (token) { return (0, interceptor_1.handleMemberToken)({ persistence: props.persistence, token: token }); } })), props);
|
|
68
74
|
var methods = DOMMethods(props);
|
|
69
75
|
return Object.assign(client, methods);
|
package/lib/utils/proxy.js
CHANGED
|
@@ -71,11 +71,15 @@ var handleResponse = function (fn, props) {
|
|
|
71
71
|
var result = fn.apply(void 0, __spreadArray([], __read(args), false));
|
|
72
72
|
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
73
73
|
return result.then(function (res) {
|
|
74
|
-
var _a, _b, _c, _d;
|
|
74
|
+
var _a, _b, _c, _d, _e;
|
|
75
75
|
if ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.member) {
|
|
76
76
|
(0, persistence_1.setPersistedMember)((_b = res.data) === null || _b === void 0 ? void 0 : _b.member, props.persistence);
|
|
77
77
|
}
|
|
78
78
|
if ((_d = (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.startsWith("mem_")) {
|
|
79
|
+
// added to prevent setting persisted member value with payload from logout response
|
|
80
|
+
if (!((_e = res === null || res === void 0 ? void 0 : res.data) === null || _e === void 0 ? void 0 : _e.member)) {
|
|
81
|
+
return res;
|
|
82
|
+
}
|
|
79
83
|
(0, persistence_1.setPersistedMember)(res.data, props.persistence);
|
|
80
84
|
}
|
|
81
85
|
return res;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberstack/dom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib/**/*"
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
"author": "Lydia Hallie",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@memberstack/client": "^1.
|
|
11
|
+
"@memberstack/client": "^1.7.0",
|
|
12
12
|
"js-cookie": "^3.0.1"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"prepublishOnly": "npx tsc",
|
|
16
|
-
"watch": "tsc-watch
|
|
16
|
+
"watch": "tsc-watch",
|
|
17
|
+
"watch:dev": "tsc-watch --onSuccess 'yarn replace:vars:local'",
|
|
17
18
|
"clean": "rm -rf node_modules",
|
|
18
19
|
"replace:vars:local": "ts-node utils/replaceDynamicVars -development",
|
|
19
20
|
"deploy:latest": "npx np --tag latest --no-tests --any-branch",
|