@memberstack/dom 1.9.5 → 1.9.6
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 +41 -5
- package/lib/methods/dom/main-dom.js +2336 -567
- package/lib/methods/dom/methods.d.ts +1 -1
- package/lib/methods/dom/methods.js +3 -4
- package/lib/methods/index.d.ts +42 -5
- package/lib/methods/index.js +1 -0
- package/lib/methods/requests/index.d.ts +2 -1
- package/lib/methods/requests/index.js +3 -3
- package/lib/types/utils/payloads.d.ts +13 -3
- package/lib/utils/cookies.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare type OpenModalParams = {
|
|
2
|
-
type: "LOGIN" | "SIGNUP" | "FORGOT_PASSWORD" | "RESET_PASSWORD";
|
|
2
|
+
type: "LOGIN" | "SIGNUP" | "FORGOT_PASSWORD" | "RESET_PASSWORD" | "PROFILE";
|
|
3
3
|
};
|
|
4
4
|
export declare const showMessage: (msg: any, isError: any) => void;
|
|
5
5
|
export declare const showLoader: (element?: any) => void;
|
|
@@ -88,6 +88,7 @@ exports.handleRedirect = function (redirect, redirectOverride) {
|
|
|
88
88
|
if (redirect && (window.location.pathname !== redirect))
|
|
89
89
|
return window.location.href = redirect;
|
|
90
90
|
};
|
|
91
|
+
var modal;
|
|
91
92
|
exports.openModal = function (type, params) {
|
|
92
93
|
if (params === void 0) { params = {}; }
|
|
93
94
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -96,8 +97,7 @@ exports.openModal = function (type, params) {
|
|
|
96
97
|
modalPromise = new Promise(function (resolve) {
|
|
97
98
|
resolveModal = resolve;
|
|
98
99
|
});
|
|
99
|
-
|
|
100
|
-
new main_dom_js_1.default({
|
|
100
|
+
modal = new main_dom_js_1.default({
|
|
101
101
|
target: document.body,
|
|
102
102
|
props: {
|
|
103
103
|
display: type.toLowerCase(),
|
|
@@ -110,7 +110,6 @@ exports.openModal = function (type, params) {
|
|
|
110
110
|
});
|
|
111
111
|
};
|
|
112
112
|
exports.hideModal = function () {
|
|
113
|
-
|
|
114
|
-
(_a = document.querySelector("#msOverlay")) === null || _a === void 0 ? void 0 : _a.remove();
|
|
113
|
+
modal === null || modal === void 0 ? void 0 : modal.$destroy();
|
|
115
114
|
exports.hideLoader();
|
|
116
115
|
};
|
package/lib/methods/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare type DOMConfig = {
|
|
2
2
|
publicKey: string;
|
|
3
3
|
appId?: string;
|
|
4
|
+
sessionDurationDays?: number;
|
|
4
5
|
};
|
|
5
6
|
declare const _default: {
|
|
6
7
|
init: (props: DOMConfig) => {
|
|
7
|
-
openModal: (type: "LOGIN" | "SIGNUP" | "FORGOT_PASSWORD" | "RESET_PASSWORD", params?: {}) => Promise<unknown>;
|
|
8
|
+
openModal: (type: "LOGIN" | "SIGNUP" | "FORGOT_PASSWORD" | "RESET_PASSWORD" | "PROFILE", params?: {}) => Promise<unknown>;
|
|
8
9
|
hideModal: () => void;
|
|
9
10
|
_hideLoader: (element?: any) => void;
|
|
10
11
|
_showLoader: (element?: any) => void;
|
|
@@ -56,6 +57,20 @@ declare const _default: {
|
|
|
56
57
|
id: string;
|
|
57
58
|
}[];
|
|
58
59
|
}[];
|
|
60
|
+
customField: {
|
|
61
|
+
order: number;
|
|
62
|
+
key: string;
|
|
63
|
+
label: string;
|
|
64
|
+
hidden: boolean;
|
|
65
|
+
}[];
|
|
66
|
+
branding: {
|
|
67
|
+
logo: string;
|
|
68
|
+
colors: {
|
|
69
|
+
lightMode: {
|
|
70
|
+
primaryButton: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
59
74
|
};
|
|
60
75
|
}>;
|
|
61
76
|
getAuthProviders(): Promise<{
|
|
@@ -100,6 +115,20 @@ declare const _default: {
|
|
|
100
115
|
id: string;
|
|
101
116
|
}[];
|
|
102
117
|
}[];
|
|
118
|
+
customField: {
|
|
119
|
+
order: number;
|
|
120
|
+
key: string;
|
|
121
|
+
label: string;
|
|
122
|
+
hidden: boolean;
|
|
123
|
+
}[];
|
|
124
|
+
branding: {
|
|
125
|
+
logo: string;
|
|
126
|
+
colors: {
|
|
127
|
+
lightMode: {
|
|
128
|
+
primaryButton: string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
103
132
|
};
|
|
104
133
|
}>;
|
|
105
134
|
loginMemberEmailPassword(params: import("../types").LoginMemberEmailPasswordParams): Promise<{
|
|
@@ -114,6 +143,7 @@ declare const _default: {
|
|
|
114
143
|
auth: {
|
|
115
144
|
email: string;
|
|
116
145
|
};
|
|
146
|
+
loginRedirect: string;
|
|
117
147
|
stripeCustomerId: string;
|
|
118
148
|
createdAt: string;
|
|
119
149
|
metaData: object;
|
|
@@ -139,7 +169,6 @@ declare const _default: {
|
|
|
139
169
|
}[];
|
|
140
170
|
};
|
|
141
171
|
redirect: string;
|
|
142
|
-
loginRedirect: string;
|
|
143
172
|
payment: {
|
|
144
173
|
requirePayment: string[];
|
|
145
174
|
requireAuthentication: string[];
|
|
@@ -158,6 +187,7 @@ declare const _default: {
|
|
|
158
187
|
auth: {
|
|
159
188
|
email: string;
|
|
160
189
|
};
|
|
190
|
+
loginRedirect: string;
|
|
161
191
|
stripeCustomerId: string;
|
|
162
192
|
createdAt: string;
|
|
163
193
|
metaData: object;
|
|
@@ -183,7 +213,6 @@ declare const _default: {
|
|
|
183
213
|
}[];
|
|
184
214
|
};
|
|
185
215
|
redirect: string;
|
|
186
|
-
loginRedirect: string;
|
|
187
216
|
payment: {
|
|
188
217
|
requirePayment: string[];
|
|
189
218
|
requireAuthentication: string[];
|
|
@@ -262,6 +291,7 @@ declare const _default: {
|
|
|
262
291
|
auth: {
|
|
263
292
|
email: string;
|
|
264
293
|
};
|
|
294
|
+
loginRedirect: string;
|
|
265
295
|
stripeCustomerId: string;
|
|
266
296
|
createdAt: string;
|
|
267
297
|
metaData: object;
|
|
@@ -413,6 +443,7 @@ declare const _default: {
|
|
|
413
443
|
auth: {
|
|
414
444
|
email: string;
|
|
415
445
|
};
|
|
446
|
+
loginRedirect: string;
|
|
416
447
|
stripeCustomerId: string;
|
|
417
448
|
createdAt: string;
|
|
418
449
|
metaData: object;
|
|
@@ -444,6 +475,7 @@ declare const _default: {
|
|
|
444
475
|
auth: {
|
|
445
476
|
email: string;
|
|
446
477
|
};
|
|
478
|
+
loginRedirect: string;
|
|
447
479
|
stripeCustomerId: string;
|
|
448
480
|
createdAt: string;
|
|
449
481
|
metaData: object;
|
|
@@ -475,6 +507,7 @@ declare const _default: {
|
|
|
475
507
|
auth: {
|
|
476
508
|
email: string;
|
|
477
509
|
};
|
|
510
|
+
loginRedirect: string;
|
|
478
511
|
stripeCustomerId: string;
|
|
479
512
|
createdAt: string;
|
|
480
513
|
metaData: object;
|
|
@@ -506,6 +539,7 @@ declare const _default: {
|
|
|
506
539
|
auth: {
|
|
507
540
|
email: string;
|
|
508
541
|
};
|
|
542
|
+
loginRedirect: string;
|
|
509
543
|
stripeCustomerId: string;
|
|
510
544
|
createdAt: string;
|
|
511
545
|
metaData: object;
|
|
@@ -537,6 +571,7 @@ declare const _default: {
|
|
|
537
571
|
auth: {
|
|
538
572
|
email: string;
|
|
539
573
|
};
|
|
574
|
+
loginRedirect: string;
|
|
540
575
|
stripeCustomerId: string;
|
|
541
576
|
createdAt: string;
|
|
542
577
|
metaData: object;
|
|
@@ -568,6 +603,7 @@ declare const _default: {
|
|
|
568
603
|
auth: {
|
|
569
604
|
email: string;
|
|
570
605
|
};
|
|
606
|
+
loginRedirect: string;
|
|
571
607
|
stripeCustomerId: string;
|
|
572
608
|
createdAt: string;
|
|
573
609
|
metaData: object;
|
|
@@ -605,6 +641,7 @@ declare const _default: {
|
|
|
605
641
|
auth: {
|
|
606
642
|
email: string;
|
|
607
643
|
};
|
|
644
|
+
loginRedirect: string;
|
|
608
645
|
stripeCustomerId: string;
|
|
609
646
|
createdAt: string;
|
|
610
647
|
metaData: object;
|
|
@@ -630,7 +667,6 @@ declare const _default: {
|
|
|
630
667
|
}[];
|
|
631
668
|
};
|
|
632
669
|
redirect: string;
|
|
633
|
-
loginRedirect: string;
|
|
634
670
|
payment: {
|
|
635
671
|
requirePayment: string[];
|
|
636
672
|
requireAuthentication: string[];
|
|
@@ -649,6 +685,7 @@ declare const _default: {
|
|
|
649
685
|
auth: {
|
|
650
686
|
email: string;
|
|
651
687
|
};
|
|
688
|
+
loginRedirect: string;
|
|
652
689
|
stripeCustomerId: string;
|
|
653
690
|
createdAt: string;
|
|
654
691
|
metaData: object;
|
|
@@ -674,7 +711,6 @@ declare const _default: {
|
|
|
674
711
|
}[];
|
|
675
712
|
};
|
|
676
713
|
redirect: string;
|
|
677
|
-
loginRedirect: string;
|
|
678
714
|
payment: {
|
|
679
715
|
requirePayment: string[];
|
|
680
716
|
requireAuthentication: string[];
|
|
@@ -690,6 +726,7 @@ declare const _default: {
|
|
|
690
726
|
auth: {
|
|
691
727
|
email: string;
|
|
692
728
|
};
|
|
729
|
+
loginRedirect: string;
|
|
693
730
|
stripeCustomerId: string;
|
|
694
731
|
createdAt: string;
|
|
695
732
|
metaData: object;
|
package/lib/methods/index.js
CHANGED
|
@@ -17,6 +17,7 @@ function init(props) {
|
|
|
17
17
|
var requests = requests_1.initRequest({
|
|
18
18
|
publicKey: props.publicKey,
|
|
19
19
|
appId: props.appId,
|
|
20
|
+
sessionDurationDays: props.sessionDurationDays,
|
|
20
21
|
token: cookies_1.getMemberCookie(),
|
|
21
22
|
});
|
|
22
23
|
var allMethods = Object.assign(methods, requests);
|
|
@@ -9,12 +9,13 @@ export interface GetCurrentMemberParams {
|
|
|
9
9
|
}
|
|
10
10
|
export interface ClientConfig {
|
|
11
11
|
publicKey: string;
|
|
12
|
+
sessionDurationDays?: number;
|
|
12
13
|
appId?: string;
|
|
13
14
|
token?: string;
|
|
14
15
|
customEndpoint?: string;
|
|
15
16
|
}
|
|
16
17
|
declare type BearerToken = string;
|
|
17
|
-
export declare const initRequest: ({ publicKey, appId, token, customEndpoint, }: ClientConfig) => {
|
|
18
|
+
export declare const initRequest: ({ publicKey, appId, token, customEndpoint, sessionDurationDays }: ClientConfig) => {
|
|
18
19
|
getApp(): Promise<Payloads.AppPayload>;
|
|
19
20
|
getAuthProviders(): Promise<Payloads.AppPayload>;
|
|
20
21
|
loginMemberEmailPassword(params: Params.LoginMemberEmailPasswordParams): Promise<Payloads.LoginMemberEmailPasswordPayload>;
|
|
@@ -57,7 +57,7 @@ var addHeaders = function (options) { return (__assign({}, ((options === null ||
|
|
|
57
57
|
Authorization: "Bearer " + options.token,
|
|
58
58
|
}))); };
|
|
59
59
|
exports.initRequest = function (_a) {
|
|
60
|
-
var publicKey = _a.publicKey, appId = _a.appId, token = _a.token, customEndpoint = _a.customEndpoint;
|
|
60
|
+
var publicKey = _a.publicKey, appId = _a.appId, token = _a.token, customEndpoint = _a.customEndpoint, sessionDurationDays = _a.sessionDurationDays;
|
|
61
61
|
var sendRequest = requests_1.createRequestHandler({
|
|
62
62
|
publicKey: publicKey,
|
|
63
63
|
token: token,
|
|
@@ -101,7 +101,7 @@ exports.initRequest = function (_a) {
|
|
|
101
101
|
case 1:
|
|
102
102
|
data = _a.sent();
|
|
103
103
|
auth_1.setPersistedMember(data.data.member);
|
|
104
|
-
cookies_1.setMemberCookie(data.data.tokens.accessToken);
|
|
104
|
+
cookies_1.setMemberCookie(data.data.tokens.accessToken, sessionDurationDays);
|
|
105
105
|
return [2 /*return*/, data];
|
|
106
106
|
}
|
|
107
107
|
});
|
|
@@ -523,7 +523,7 @@ exports.initRequest = function (_a) {
|
|
|
523
523
|
case 1:
|
|
524
524
|
data = _a.sent();
|
|
525
525
|
auth_1.setPersistedMember(data.data.member);
|
|
526
|
-
cookies_1.setMemberCookie(data.data.tokens.accessToken);
|
|
526
|
+
cookies_1.setMemberCookie(data.data.tokens.accessToken, sessionDurationDays);
|
|
527
527
|
return [2 /*return*/, data];
|
|
528
528
|
}
|
|
529
529
|
});
|
|
@@ -17,6 +17,16 @@ export declare namespace Payload {
|
|
|
17
17
|
mode: "live" | "sandbox";
|
|
18
18
|
plans: Transforms["Plan"][];
|
|
19
19
|
contentGroups: Transforms["RestrictedUrlGroup"][];
|
|
20
|
+
customField: Transforms["CustomField"][];
|
|
21
|
+
branding: Transforms["Branding"];
|
|
22
|
+
};
|
|
23
|
+
Branding: {
|
|
24
|
+
logo: string;
|
|
25
|
+
colors: {
|
|
26
|
+
lightMode: {
|
|
27
|
+
primaryButton: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
20
30
|
};
|
|
21
31
|
RestrictedUrlGroup: {
|
|
22
32
|
id: string;
|
|
@@ -40,7 +50,6 @@ export declare namespace Payload {
|
|
|
40
50
|
};
|
|
41
51
|
member: Transforms["Member"];
|
|
42
52
|
redirect: string;
|
|
43
|
-
loginRedirect: string;
|
|
44
53
|
payment: {
|
|
45
54
|
requirePayment: string[];
|
|
46
55
|
requireAuthentication: string[];
|
|
@@ -54,6 +63,7 @@ export declare namespace Payload {
|
|
|
54
63
|
auth: {
|
|
55
64
|
email: string;
|
|
56
65
|
};
|
|
66
|
+
loginRedirect: string;
|
|
57
67
|
stripeCustomerId: string;
|
|
58
68
|
createdAt: string;
|
|
59
69
|
metaData: object;
|
|
@@ -145,10 +155,10 @@ export declare namespace Payload {
|
|
|
145
155
|
permissions: Transforms["Permission"][];
|
|
146
156
|
};
|
|
147
157
|
CustomField: {
|
|
148
|
-
|
|
158
|
+
order: number;
|
|
149
159
|
key: string;
|
|
150
160
|
label: string;
|
|
151
|
-
|
|
161
|
+
hidden: boolean;
|
|
152
162
|
};
|
|
153
163
|
MemberPlanConnection: {
|
|
154
164
|
id: string;
|
package/lib/utils/cookies.js
CHANGED
|
@@ -8,7 +8,7 @@ var js_cookie_1 = __importDefault(require("js-cookie"));
|
|
|
8
8
|
var memberAuthCookie = "_ms-mid";
|
|
9
9
|
exports.setMemberCookie = function (token, expires) {
|
|
10
10
|
js_cookie_1.default.set(memberAuthCookie, token, {
|
|
11
|
-
expires: expires
|
|
11
|
+
expires: (expires && Number(expires)) || 3,
|
|
12
12
|
sameSite: "strict",
|
|
13
13
|
});
|
|
14
14
|
};
|