@memberstack/dom 1.9.4 → 1.9.7
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/auth/index.js +4 -0
- package/lib/index.d.ts +62 -58
- 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 +64 -58
- package/lib/methods/index.js +2 -0
- package/lib/methods/requests/index.d.ts +5 -2
- package/lib/methods/requests/index.js +44 -13
- package/lib/methods/requests/requests.d.ts +3 -1
- package/lib/methods/requests/requests.js +15 -14
- package/lib/types/params.d.ts +3 -1
- package/lib/types/payloads.d.ts +1 -0
- package/lib/types/utils/payloads.d.ts +16 -9
- 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,9 +1,11 @@
|
|
|
1
1
|
export declare type DOMConfig = {
|
|
2
2
|
publicKey: string;
|
|
3
|
+
appId?: string;
|
|
4
|
+
sessionDurationDays?: number;
|
|
3
5
|
};
|
|
4
6
|
declare const _default: {
|
|
5
7
|
init: (props: DOMConfig) => {
|
|
6
|
-
openModal: (type: "LOGIN" | "SIGNUP" | "FORGOT_PASSWORD" | "RESET_PASSWORD", params?: {}) => Promise<unknown>;
|
|
8
|
+
openModal: (type: "LOGIN" | "SIGNUP" | "FORGOT_PASSWORD" | "RESET_PASSWORD" | "PROFILE", params?: {}) => Promise<unknown>;
|
|
7
9
|
hideModal: () => void;
|
|
8
10
|
_hideLoader: (element?: any) => void;
|
|
9
11
|
_showLoader: (element?: any) => void;
|
|
@@ -17,10 +19,7 @@ declare const _default: {
|
|
|
17
19
|
data: {
|
|
18
20
|
id: string;
|
|
19
21
|
name: string;
|
|
20
|
-
|
|
21
|
-
url: string;
|
|
22
|
-
verified: boolean;
|
|
23
|
-
}[];
|
|
22
|
+
mode: "live" | "sandbox";
|
|
24
23
|
plans: {
|
|
25
24
|
id: string;
|
|
26
25
|
name: string;
|
|
@@ -44,44 +43,41 @@ declare const _default: {
|
|
|
44
43
|
currency: string;
|
|
45
44
|
}[];
|
|
46
45
|
}[];
|
|
47
|
-
|
|
46
|
+
contentGroups: {
|
|
48
47
|
id: string;
|
|
48
|
+
name: string;
|
|
49
49
|
key: string;
|
|
50
|
-
|
|
50
|
+
allowAllMembers: boolean;
|
|
51
|
+
redirect: string;
|
|
52
|
+
urls: {
|
|
53
|
+
url: string;
|
|
54
|
+
filter: string;
|
|
55
|
+
}[];
|
|
51
56
|
plans: {
|
|
52
57
|
id: string;
|
|
53
|
-
name: string;
|
|
54
|
-
description: string;
|
|
55
|
-
status: string;
|
|
56
|
-
redirects: {
|
|
57
|
-
afterLogin: string;
|
|
58
|
-
afterLogout: string;
|
|
59
|
-
afterSignup: string;
|
|
60
|
-
};
|
|
61
|
-
prices?: [] | {
|
|
62
|
-
id: string;
|
|
63
|
-
amount: string;
|
|
64
|
-
interval: {
|
|
65
|
-
type: string;
|
|
66
|
-
count: number;
|
|
67
|
-
};
|
|
68
|
-
name: string;
|
|
69
|
-
type: string;
|
|
70
|
-
status: string;
|
|
71
|
-
currency: string;
|
|
72
|
-
}[];
|
|
73
58
|
}[];
|
|
74
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
|
+
};
|
|
75
74
|
};
|
|
76
75
|
}>;
|
|
77
76
|
getAuthProviders(): Promise<{
|
|
78
77
|
data: {
|
|
79
78
|
id: string;
|
|
80
79
|
name: string;
|
|
81
|
-
|
|
82
|
-
url: string;
|
|
83
|
-
verified: boolean;
|
|
84
|
-
}[];
|
|
80
|
+
mode: "live" | "sandbox";
|
|
85
81
|
plans: {
|
|
86
82
|
id: string;
|
|
87
83
|
name: string;
|
|
@@ -105,34 +101,34 @@ declare const _default: {
|
|
|
105
101
|
currency: string;
|
|
106
102
|
}[];
|
|
107
103
|
}[];
|
|
108
|
-
|
|
104
|
+
contentGroups: {
|
|
109
105
|
id: string;
|
|
106
|
+
name: string;
|
|
110
107
|
key: string;
|
|
111
|
-
|
|
108
|
+
allowAllMembers: boolean;
|
|
109
|
+
redirect: string;
|
|
110
|
+
urls: {
|
|
111
|
+
url: string;
|
|
112
|
+
filter: string;
|
|
113
|
+
}[];
|
|
112
114
|
plans: {
|
|
113
115
|
id: string;
|
|
114
|
-
name: string;
|
|
115
|
-
description: string;
|
|
116
|
-
status: string;
|
|
117
|
-
redirects: {
|
|
118
|
-
afterLogin: string;
|
|
119
|
-
afterLogout: string;
|
|
120
|
-
afterSignup: string;
|
|
121
|
-
};
|
|
122
|
-
prices?: [] | {
|
|
123
|
-
id: string;
|
|
124
|
-
amount: string;
|
|
125
|
-
interval: {
|
|
126
|
-
type: string;
|
|
127
|
-
count: number;
|
|
128
|
-
};
|
|
129
|
-
name: string;
|
|
130
|
-
type: string;
|
|
131
|
-
status: string;
|
|
132
|
-
currency: string;
|
|
133
|
-
}[];
|
|
134
116
|
}[];
|
|
135
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
|
+
};
|
|
136
132
|
};
|
|
137
133
|
}>;
|
|
138
134
|
loginMemberEmailPassword(params: import("../types").LoginMemberEmailPasswordParams): Promise<{
|
|
@@ -147,6 +143,7 @@ declare const _default: {
|
|
|
147
143
|
auth: {
|
|
148
144
|
email: string;
|
|
149
145
|
};
|
|
146
|
+
loginRedirect: string;
|
|
150
147
|
stripeCustomerId: string;
|
|
151
148
|
createdAt: string;
|
|
152
149
|
metaData: object;
|
|
@@ -172,7 +169,6 @@ declare const _default: {
|
|
|
172
169
|
}[];
|
|
173
170
|
};
|
|
174
171
|
redirect: string;
|
|
175
|
-
loginRedirect: string;
|
|
176
172
|
payment: {
|
|
177
173
|
requirePayment: string[];
|
|
178
174
|
requireAuthentication: string[];
|
|
@@ -191,6 +187,7 @@ declare const _default: {
|
|
|
191
187
|
auth: {
|
|
192
188
|
email: string;
|
|
193
189
|
};
|
|
190
|
+
loginRedirect: string;
|
|
194
191
|
stripeCustomerId: string;
|
|
195
192
|
createdAt: string;
|
|
196
193
|
metaData: object;
|
|
@@ -216,7 +213,6 @@ declare const _default: {
|
|
|
216
213
|
}[];
|
|
217
214
|
};
|
|
218
215
|
redirect: string;
|
|
219
|
-
loginRedirect: string;
|
|
220
216
|
payment: {
|
|
221
217
|
requirePayment: string[];
|
|
222
218
|
requireAuthentication: string[];
|
|
@@ -248,7 +244,7 @@ declare const _default: {
|
|
|
248
244
|
}[];
|
|
249
245
|
};
|
|
250
246
|
}>;
|
|
251
|
-
getPlans(
|
|
247
|
+
getPlans(): Promise<{
|
|
252
248
|
data: {
|
|
253
249
|
id: string;
|
|
254
250
|
name: string;
|
|
@@ -278,6 +274,7 @@ declare const _default: {
|
|
|
278
274
|
id: string;
|
|
279
275
|
name: string;
|
|
280
276
|
key: string;
|
|
277
|
+
allowAllMembers: boolean;
|
|
281
278
|
redirect: string;
|
|
282
279
|
urls: {
|
|
283
280
|
url: string;
|
|
@@ -294,6 +291,7 @@ declare const _default: {
|
|
|
294
291
|
auth: {
|
|
295
292
|
email: string;
|
|
296
293
|
};
|
|
294
|
+
loginRedirect: string;
|
|
297
295
|
stripeCustomerId: string;
|
|
298
296
|
createdAt: string;
|
|
299
297
|
metaData: object;
|
|
@@ -439,12 +437,14 @@ declare const _default: {
|
|
|
439
437
|
url: string;
|
|
440
438
|
};
|
|
441
439
|
}>;
|
|
440
|
+
removePlan(params: import("../types").RemovePlanParams, options?: import("./requests").MemberstackOptions): Promise<null>;
|
|
442
441
|
cancelPlan(params: import("../types").CancelPlanParams, options?: import("./requests").MemberstackOptions): Promise<{
|
|
443
442
|
data: {
|
|
444
443
|
id: string;
|
|
445
444
|
auth: {
|
|
446
445
|
email: string;
|
|
447
446
|
};
|
|
447
|
+
loginRedirect: string;
|
|
448
448
|
stripeCustomerId: string;
|
|
449
449
|
createdAt: string;
|
|
450
450
|
metaData: object;
|
|
@@ -476,6 +476,7 @@ declare const _default: {
|
|
|
476
476
|
auth: {
|
|
477
477
|
email: string;
|
|
478
478
|
};
|
|
479
|
+
loginRedirect: string;
|
|
479
480
|
stripeCustomerId: string;
|
|
480
481
|
createdAt: string;
|
|
481
482
|
metaData: object;
|
|
@@ -507,6 +508,7 @@ declare const _default: {
|
|
|
507
508
|
auth: {
|
|
508
509
|
email: string;
|
|
509
510
|
};
|
|
511
|
+
loginRedirect: string;
|
|
510
512
|
stripeCustomerId: string;
|
|
511
513
|
createdAt: string;
|
|
512
514
|
metaData: object;
|
|
@@ -538,6 +540,7 @@ declare const _default: {
|
|
|
538
540
|
auth: {
|
|
539
541
|
email: string;
|
|
540
542
|
};
|
|
543
|
+
loginRedirect: string;
|
|
541
544
|
stripeCustomerId: string;
|
|
542
545
|
createdAt: string;
|
|
543
546
|
metaData: object;
|
|
@@ -569,6 +572,7 @@ declare const _default: {
|
|
|
569
572
|
auth: {
|
|
570
573
|
email: string;
|
|
571
574
|
};
|
|
575
|
+
loginRedirect: string;
|
|
572
576
|
stripeCustomerId: string;
|
|
573
577
|
createdAt: string;
|
|
574
578
|
metaData: object;
|
|
@@ -600,6 +604,7 @@ declare const _default: {
|
|
|
600
604
|
auth: {
|
|
601
605
|
email: string;
|
|
602
606
|
};
|
|
607
|
+
loginRedirect: string;
|
|
603
608
|
stripeCustomerId: string;
|
|
604
609
|
createdAt: string;
|
|
605
610
|
metaData: object;
|
|
@@ -637,6 +642,7 @@ declare const _default: {
|
|
|
637
642
|
auth: {
|
|
638
643
|
email: string;
|
|
639
644
|
};
|
|
645
|
+
loginRedirect: string;
|
|
640
646
|
stripeCustomerId: string;
|
|
641
647
|
createdAt: string;
|
|
642
648
|
metaData: object;
|
|
@@ -662,7 +668,6 @@ declare const _default: {
|
|
|
662
668
|
}[];
|
|
663
669
|
};
|
|
664
670
|
redirect: string;
|
|
665
|
-
loginRedirect: string;
|
|
666
671
|
payment: {
|
|
667
672
|
requirePayment: string[];
|
|
668
673
|
requireAuthentication: string[];
|
|
@@ -681,6 +686,7 @@ declare const _default: {
|
|
|
681
686
|
auth: {
|
|
682
687
|
email: string;
|
|
683
688
|
};
|
|
689
|
+
loginRedirect: string;
|
|
684
690
|
stripeCustomerId: string;
|
|
685
691
|
createdAt: string;
|
|
686
692
|
metaData: object;
|
|
@@ -706,7 +712,6 @@ declare const _default: {
|
|
|
706
712
|
}[];
|
|
707
713
|
};
|
|
708
714
|
redirect: string;
|
|
709
|
-
loginRedirect: string;
|
|
710
715
|
payment: {
|
|
711
716
|
requirePayment: string[];
|
|
712
717
|
requireAuthentication: string[];
|
|
@@ -722,6 +727,7 @@ declare const _default: {
|
|
|
722
727
|
auth: {
|
|
723
728
|
email: string;
|
|
724
729
|
};
|
|
730
|
+
loginRedirect: string;
|
|
725
731
|
stripeCustomerId: string;
|
|
726
732
|
createdAt: string;
|
|
727
733
|
metaData: object;
|
package/lib/methods/index.js
CHANGED
|
@@ -16,6 +16,8 @@ var methods = {
|
|
|
16
16
|
function init(props) {
|
|
17
17
|
var requests = requests_1.initRequest({
|
|
18
18
|
publicKey: props.publicKey,
|
|
19
|
+
appId: props.appId,
|
|
20
|
+
sessionDurationDays: props.sessionDurationDays,
|
|
19
21
|
token: cookies_1.getMemberCookie(),
|
|
20
22
|
});
|
|
21
23
|
var allMethods = Object.assign(methods, requests);
|
|
@@ -9,17 +9,19 @@ export interface GetCurrentMemberParams {
|
|
|
9
9
|
}
|
|
10
10
|
export interface ClientConfig {
|
|
11
11
|
publicKey: string;
|
|
12
|
+
sessionDurationDays?: number;
|
|
13
|
+
appId?: string;
|
|
12
14
|
token?: string;
|
|
13
15
|
customEndpoint?: string;
|
|
14
16
|
}
|
|
15
17
|
declare type BearerToken = string;
|
|
16
|
-
export declare const initRequest: ({ publicKey, token, customEndpoint, }: ClientConfig) => {
|
|
18
|
+
export declare const initRequest: ({ publicKey, appId, token, customEndpoint, sessionDurationDays }: ClientConfig) => {
|
|
17
19
|
getApp(): Promise<Payloads.AppPayload>;
|
|
18
20
|
getAuthProviders(): Promise<Payloads.AppPayload>;
|
|
19
21
|
loginMemberEmailPassword(params: Params.LoginMemberEmailPasswordParams): Promise<Payloads.LoginMemberEmailPasswordPayload>;
|
|
20
22
|
loginMemberAuthProvider(params: Params.LoginMemberAuthProviderParams): Promise<Payloads.LoginMemberAuthProviderPayload>;
|
|
21
23
|
getPlan(params: Params.GetPlanParams): Promise<Payloads.GetPlanPayload>;
|
|
22
|
-
getPlans(
|
|
24
|
+
getPlans(): Promise<Payloads.GetPlansPayload>;
|
|
23
25
|
getRestrictedUrlGroups(): Promise<Payloads.GetRestrictedUrlGroupsPayload>;
|
|
24
26
|
getCurrentMember(options?: GetCurrentMemberParams): Promise<Payloads.GetCurrentMemberPayload>;
|
|
25
27
|
getMemberJSON(options?: MemberstackOptions): Promise<Payloads.GetMemberJSONPayload>;
|
|
@@ -33,6 +35,7 @@ export declare const initRequest: ({ publicKey, token, customEndpoint, }: Client
|
|
|
33
35
|
addPlan(params: Params.AddPlanParams, options?: MemberstackOptions): Promise<Payloads.AddPlanPayload>;
|
|
34
36
|
purchasePlansWithCheckout(params: Params.PurchasePlansWithCheckoutParams, options?: MemberstackOptions): Promise<Payloads.PurchasePlansWithCheckoutPayload>;
|
|
35
37
|
launchStripeCustomerPortal(params: Params.LaunchStripeCustomerPortalParams, options?: MemberstackOptions): Promise<Payloads.LaunchStripeCustomerPortalPayload>;
|
|
38
|
+
removePlan(params: Params.RemovePlanParams, options?: MemberstackOptions): Promise<null>;
|
|
36
39
|
cancelPlan(params: Params.CancelPlanParams, options?: MemberstackOptions): Promise<Payloads.CancelPlanPayload>;
|
|
37
40
|
updateMember(params: Params.UpdateMemberParams, options?: MemberstackOptions): Promise<Payloads.UpdateMemberPayload>;
|
|
38
41
|
updateMemberAuth(params: Params.UpdateMemberAuthParams, options?: MemberstackOptions): Promise<Payloads.UpdateMemberAuthPayload>;
|
|
@@ -57,11 +57,12 @@ 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, 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,
|
|
64
64
|
customEndpoint: customEndpoint,
|
|
65
|
+
appId: appId,
|
|
65
66
|
}).sendRequest;
|
|
66
67
|
return {
|
|
67
68
|
getApp: function () {
|
|
@@ -100,7 +101,7 @@ exports.initRequest = function (_a) {
|
|
|
100
101
|
case 1:
|
|
101
102
|
data = _a.sent();
|
|
102
103
|
auth_1.setPersistedMember(data.data.member);
|
|
103
|
-
cookies_1.setMemberCookie(data.data.tokens.accessToken);
|
|
104
|
+
cookies_1.setMemberCookie(data.data.tokens.accessToken, sessionDurationDays);
|
|
104
105
|
return [2 /*return*/, data];
|
|
105
106
|
}
|
|
106
107
|
});
|
|
@@ -130,23 +131,39 @@ exports.initRequest = function (_a) {
|
|
|
130
131
|
});
|
|
131
132
|
});
|
|
132
133
|
},
|
|
133
|
-
getPlans: function (
|
|
134
|
+
getPlans: function () {
|
|
134
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var data;
|
|
135
137
|
return __generator(this, function (_a) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0: return [4 /*yield*/, sendRequest({
|
|
140
|
+
method: requests_2.HttpMethod.GET,
|
|
141
|
+
url: "/app",
|
|
142
|
+
})];
|
|
143
|
+
case 1:
|
|
144
|
+
data = (_a.sent()).data;
|
|
145
|
+
return [2 /*return*/, {
|
|
146
|
+
data: data.plans
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
140
149
|
});
|
|
141
150
|
});
|
|
142
151
|
},
|
|
143
152
|
getRestrictedUrlGroups: function () {
|
|
144
153
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
var data;
|
|
145
155
|
return __generator(this, function (_a) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0: return [4 /*yield*/, sendRequest({
|
|
158
|
+
method: requests_2.HttpMethod.GET,
|
|
159
|
+
url: "/app",
|
|
160
|
+
})];
|
|
161
|
+
case 1:
|
|
162
|
+
data = (_a.sent()).data;
|
|
163
|
+
return [2 /*return*/, {
|
|
164
|
+
data: data.contentGroups
|
|
165
|
+
}];
|
|
166
|
+
}
|
|
150
167
|
});
|
|
151
168
|
});
|
|
152
169
|
},
|
|
@@ -403,6 +420,20 @@ exports.initRequest = function (_a) {
|
|
|
403
420
|
});
|
|
404
421
|
});
|
|
405
422
|
},
|
|
423
|
+
removePlan: function (params, options) {
|
|
424
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
425
|
+
return __generator(this, function (_a) {
|
|
426
|
+
return [2 /*return*/, sendRequest({
|
|
427
|
+
method: requests_2.HttpMethod.POST,
|
|
428
|
+
url: "/member/plans/remove",
|
|
429
|
+
data: {
|
|
430
|
+
planId: params.planId,
|
|
431
|
+
},
|
|
432
|
+
headers: addHeaders(options),
|
|
433
|
+
})];
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
},
|
|
406
437
|
cancelPlan: function (params, options) {
|
|
407
438
|
return __awaiter(this, void 0, void 0, function () {
|
|
408
439
|
return __generator(this, function (_a) {
|
|
@@ -423,7 +454,7 @@ exports.initRequest = function (_a) {
|
|
|
423
454
|
return [2 /*return*/, sendRequest({
|
|
424
455
|
method: requests_2.HttpMethod.POST,
|
|
425
456
|
url: "/member",
|
|
426
|
-
data: __assign(
|
|
457
|
+
data: __assign({}, (params.customFields && { customFields: params.customFields })),
|
|
427
458
|
headers: addHeaders(options),
|
|
428
459
|
})];
|
|
429
460
|
});
|
|
@@ -506,7 +537,7 @@ exports.initRequest = function (_a) {
|
|
|
506
537
|
case 1:
|
|
507
538
|
data = _a.sent();
|
|
508
539
|
auth_1.setPersistedMember(data.data.member);
|
|
509
|
-
cookies_1.setMemberCookie(data.data.tokens.accessToken);
|
|
540
|
+
cookies_1.setMemberCookie(data.data.tokens.accessToken, sessionDurationDays);
|
|
510
541
|
return [2 /*return*/, data];
|
|
511
542
|
}
|
|
512
543
|
});
|
|
@@ -5,11 +5,13 @@ export declare enum HttpMethod {
|
|
|
5
5
|
export declare enum HttpHeaders {
|
|
6
6
|
AUTHORIZATION = "Authorization",
|
|
7
7
|
API_KEY = "X-API-Key",
|
|
8
|
+
APP_ID = "X-APP-ID",
|
|
8
9
|
API_VERSION = "X-API-Version",
|
|
9
10
|
USER_AGENT = "X-User-Agent"
|
|
10
11
|
}
|
|
11
|
-
export declare const createRequestHandler: ({ publicKey, token, customEndpoint, }: {
|
|
12
|
+
export declare const createRequestHandler: ({ publicKey, appId, token, customEndpoint, }: {
|
|
12
13
|
publicKey: any;
|
|
14
|
+
appId: any;
|
|
13
15
|
token: any;
|
|
14
16
|
customEndpoint: any;
|
|
15
17
|
}) => {
|
|
@@ -62,48 +62,49 @@ var HttpHeaders;
|
|
|
62
62
|
(function (HttpHeaders) {
|
|
63
63
|
HttpHeaders["AUTHORIZATION"] = "Authorization";
|
|
64
64
|
HttpHeaders["API_KEY"] = "X-API-Key";
|
|
65
|
+
HttpHeaders["APP_ID"] = "X-APP-ID";
|
|
65
66
|
HttpHeaders["API_VERSION"] = "X-API-Version";
|
|
66
67
|
HttpHeaders["USER_AGENT"] = "X-User-Agent";
|
|
67
68
|
})(HttpHeaders = exports.HttpHeaders || (exports.HttpHeaders = {}));
|
|
68
69
|
exports.createRequestHandler = function (_a) {
|
|
69
|
-
var publicKey = _a.publicKey, token = _a.token, customEndpoint = _a.customEndpoint;
|
|
70
|
+
var publicKey = _a.publicKey, appId = _a.appId, token = _a.token, customEndpoint = _a.customEndpoint;
|
|
70
71
|
return {
|
|
71
72
|
sendRequest: function (data, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
73
|
var url, authHeader, formattedUrl, res, e_1;
|
|
73
|
-
var _a;
|
|
74
|
-
var
|
|
75
|
-
return __generator(this, function (
|
|
76
|
-
switch (
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
76
|
+
return __generator(this, function (_m) {
|
|
77
|
+
switch (_m.label) {
|
|
77
78
|
case 0:
|
|
78
|
-
|
|
79
|
+
_m.trys.push([0, 2, , 3]);
|
|
79
80
|
url = data.url;
|
|
80
81
|
authHeader = [
|
|
81
|
-
(
|
|
82
|
+
(_e = (_d = data.headers) === null || _d === void 0 ? void 0 : _d["Authorization"]) === null || _e === void 0 ? void 0 : _e.replace("Bearer ", ""),
|
|
82
83
|
token,
|
|
83
84
|
options === null || options === void 0 ? void 0 : options.token,
|
|
84
85
|
].find(function (x) { return x; });
|
|
85
86
|
formattedUrl = "" + (customEndpoint || endpoints_1.endpoints.API) + url;
|
|
86
|
-
return [4 /*yield*/, axios_1.default(__assign(__assign({}, data), { url: formattedUrl, headers: __assign(__assign({}, (authHeader && { authorization: "Bearer " + authHeader })), (_a = {}, _a[HttpHeaders.API_KEY] = publicKey, _a[HttpHeaders.USER_AGENT] = "@memberstack/client@1.2.0",
|
|
87
|
+
return [4 /*yield*/, axios_1.default(__assign(__assign({}, data), { url: formattedUrl, headers: __assign(__assign(__assign(__assign({}, (authHeader && { authorization: "Bearer " + authHeader })), (publicKey && (_a = {}, _a[HttpHeaders.API_KEY] = publicKey, _a))), (appId && (_b = {}, _b[HttpHeaders.APP_ID] = appId, _b))), (_c = {}, _c[HttpHeaders.USER_AGENT] = "@memberstack/client@1.2.0", _c)), withCredentials: true }))];
|
|
87
88
|
case 1:
|
|
88
|
-
res =
|
|
89
|
-
if ((
|
|
89
|
+
res = _m.sent();
|
|
90
|
+
if ((_f = res === null || res === void 0 ? void 0 : res.headers) === null || _f === void 0 ? void 0 : _f["ms-mid"]) {
|
|
90
91
|
token = res.headers["ms-mid"];
|
|
91
92
|
}
|
|
92
|
-
if ((
|
|
93
|
+
if ((_g = res === null || res === void 0 ? void 0 : res.data) === null || _g === void 0 ? void 0 : _g.error) {
|
|
93
94
|
if (res.data.error.name === "JsonWebTokenError") {
|
|
94
95
|
throw {
|
|
95
96
|
code: "client/invalid-token",
|
|
96
97
|
message: "An invalid token has been provided. Please make sure the token is valid.",
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
|
-
throw (
|
|
100
|
+
throw (_h = res.data) === null || _h === void 0 ? void 0 : _h.error;
|
|
100
101
|
}
|
|
101
102
|
return [2 /*return*/, res === null || res === void 0 ? void 0 : res.data];
|
|
102
103
|
case 2:
|
|
103
|
-
e_1 =
|
|
104
|
+
e_1 = _m.sent();
|
|
104
105
|
if (!e_1.response)
|
|
105
106
|
throw e_1;
|
|
106
|
-
throw ((
|
|
107
|
+
throw ((_k = (_j = e_1.response) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.error) || ((_l = e_1.response) === null || _l === void 0 ? void 0 : _l.data);
|
|
107
108
|
case 3: return [2 /*return*/];
|
|
108
109
|
}
|
|
109
110
|
});
|
package/lib/types/params.d.ts
CHANGED
|
@@ -38,7 +38,6 @@ export declare type LoginMemberAuthProviderParams = {
|
|
|
38
38
|
provider: "GOOGLE" | "FACEBOOK";
|
|
39
39
|
};
|
|
40
40
|
export declare type UpdateMemberParams = {
|
|
41
|
-
metaData?: Record<string, any>;
|
|
42
41
|
customFields?: Record<string, any>;
|
|
43
42
|
};
|
|
44
43
|
export declare type UpdateMemberAuthParams = {
|
|
@@ -78,6 +77,9 @@ export declare type OpenStripeCustomerPortalParams = {
|
|
|
78
77
|
returnUrl?: string;
|
|
79
78
|
autoRedirect?: boolean;
|
|
80
79
|
};
|
|
80
|
+
export declare type RemovePlanParams = {
|
|
81
|
+
planId: string;
|
|
82
|
+
};
|
|
81
83
|
export declare type CancelPlanParams = {
|
|
82
84
|
planConnectionId: string;
|
|
83
85
|
};
|
package/lib/types/payloads.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Payload } from "./utils/payloads";
|
|
|
2
2
|
export declare type AppPayload = Response<Payload.Transforms["App"]>;
|
|
3
3
|
export declare type AddMemberCardPayload = Response<Payload.Transforms["Member"]>;
|
|
4
4
|
export declare type CancelPlanPayload = Response<Payload.Transforms["Member"]>;
|
|
5
|
+
export declare type RemovePlanPayload = Response<Payload.Transforms["Member"]>;
|
|
5
6
|
export declare type GetCurrentMemberPayload = Response<Payload.Transforms["Member"]>;
|
|
6
7
|
export declare type GetMemberJSONPayload = Response<Payload.Transforms["MemberJSON"]>;
|
|
7
8
|
export declare type GetMemberCardsPayload = Response<Payload.Transforms["MemberCard"][]>;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
declare type Domain = {
|
|
2
|
-
url: string;
|
|
3
|
-
verified: boolean;
|
|
4
|
-
};
|
|
5
1
|
export declare namespace Payload {
|
|
6
2
|
interface PaginatedResponse<T> {
|
|
7
3
|
hasNext: boolean;
|
|
@@ -18,14 +14,25 @@ export declare namespace Payload {
|
|
|
18
14
|
App: {
|
|
19
15
|
id: string;
|
|
20
16
|
name: string;
|
|
21
|
-
|
|
17
|
+
mode: "live" | "sandbox";
|
|
22
18
|
plans: Transforms["Plan"][];
|
|
23
|
-
|
|
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
|
+
};
|
|
24
30
|
};
|
|
25
31
|
RestrictedUrlGroup: {
|
|
26
32
|
id: string;
|
|
27
33
|
name: string;
|
|
28
34
|
key: string;
|
|
35
|
+
allowAllMembers: boolean;
|
|
29
36
|
redirect: string;
|
|
30
37
|
urls: {
|
|
31
38
|
url: string;
|
|
@@ -43,7 +50,6 @@ export declare namespace Payload {
|
|
|
43
50
|
};
|
|
44
51
|
member: Transforms["Member"];
|
|
45
52
|
redirect: string;
|
|
46
|
-
loginRedirect: string;
|
|
47
53
|
payment: {
|
|
48
54
|
requirePayment: string[];
|
|
49
55
|
requireAuthentication: string[];
|
|
@@ -57,6 +63,7 @@ export declare namespace Payload {
|
|
|
57
63
|
auth: {
|
|
58
64
|
email: string;
|
|
59
65
|
};
|
|
66
|
+
loginRedirect: string;
|
|
60
67
|
stripeCustomerId: string;
|
|
61
68
|
createdAt: string;
|
|
62
69
|
metaData: object;
|
|
@@ -148,10 +155,10 @@ export declare namespace Payload {
|
|
|
148
155
|
permissions: Transforms["Permission"][];
|
|
149
156
|
};
|
|
150
157
|
CustomField: {
|
|
151
|
-
|
|
158
|
+
order: number;
|
|
152
159
|
key: string;
|
|
153
160
|
label: string;
|
|
154
|
-
|
|
161
|
+
hidden: boolean;
|
|
155
162
|
};
|
|
156
163
|
MemberPlanConnection: {
|
|
157
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
|
};
|