@memberstack/dom 1.0.0-beta.24 → 1.0.0-beta.28
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/persistence/index.js +1 -1
- package/lib/auth/persistence/methods.js +8 -17
- package/lib/index.js +0 -1
- package/lib/methods/client.d.ts +638 -32
- package/lib/methods/client.js +2 -3
- package/lib/methods/dom/index.js +0 -1
- package/lib/methods/dom/methods.js +6 -9
- package/lib/methods/index.d.ts +1 -0
- package/lib/methods/index.js +3 -4
- package/lib/utils/cookies.js +2 -4
- package/lib/utils/interceptor.d.ts +2 -1
- package/lib/utils/interceptor.js +11 -22
- package/lib/utils/proxy.js +7 -12
- package/package.json +2 -2
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./methods"), exports);
|
|
@@ -15,14 +15,9 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
15
15
|
}
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18
|
+
var __spread = (this && this.__spread) || function () {
|
|
19
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
20
|
+
return ar;
|
|
26
21
|
};
|
|
27
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
23
|
exports.onAuthChange = exports.unsetPersistedMember = exports.getPersistedMember = exports.setPersistedMember = exports.Persistence = void 0;
|
|
@@ -45,7 +40,7 @@ var createObservable = function () {
|
|
|
45
40
|
return observer.delete(key);
|
|
46
41
|
},
|
|
47
42
|
notify: function (data) {
|
|
48
|
-
return
|
|
43
|
+
return __spread(observer.values()).forEach(function (fn) { return fn(data); });
|
|
49
44
|
},
|
|
50
45
|
};
|
|
51
46
|
};
|
|
@@ -58,30 +53,26 @@ var getPersistence = function (persistence) {
|
|
|
58
53
|
return session_1.sessionStoragePersistence;
|
|
59
54
|
}
|
|
60
55
|
};
|
|
61
|
-
|
|
56
|
+
exports.setPersistedMember = function (member, persistence) {
|
|
62
57
|
var _a;
|
|
63
58
|
if (member) {
|
|
64
59
|
(_a = getPersistence(persistence)) === null || _a === void 0 ? void 0 : _a.setMember(member);
|
|
65
60
|
observable.notify(member);
|
|
66
61
|
}
|
|
67
62
|
};
|
|
68
|
-
exports.
|
|
69
|
-
var getPersistedMember = function (persistence) {
|
|
63
|
+
exports.getPersistedMember = function (persistence) {
|
|
70
64
|
var _a;
|
|
71
65
|
return (_a = getPersistence(persistence)) === null || _a === void 0 ? void 0 : _a.getMember();
|
|
72
66
|
};
|
|
73
|
-
exports.
|
|
74
|
-
var unsetPersistedMember = function (persistence) {
|
|
67
|
+
exports.unsetPersistedMember = function (persistence) {
|
|
75
68
|
var _a;
|
|
76
69
|
(_a = getPersistence(persistence)) === null || _a === void 0 ? void 0 : _a.unsetMember();
|
|
77
70
|
observable.notify(null);
|
|
78
71
|
};
|
|
79
|
-
exports.
|
|
80
|
-
var onAuthChange = function (cb) {
|
|
72
|
+
exports.onAuthChange = function (cb) {
|
|
81
73
|
var id = Math.floor(Math.random() * 1000);
|
|
82
74
|
observable.subscribe(id, cb);
|
|
83
75
|
return {
|
|
84
76
|
unsubscribe: function () { return observable.unsubscribe(id); },
|
|
85
77
|
};
|
|
86
78
|
};
|
|
87
|
-
exports.onAuthChange = onAuthChange;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Persistence = void 0;
|
|
4
3
|
var persistence_1 = require("./auth/persistence");
|
|
5
4
|
Object.defineProperty(exports, "Persistence", { enumerable: true, get: function () { return persistence_1.Persistence; } });
|
|
6
5
|
var methods_1 = require("./methods");
|
package/lib/methods/client.d.ts
CHANGED
|
@@ -1,36 +1,642 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
useCookie?: boolean;
|
|
4
|
-
token?: string;
|
|
5
|
-
apiVersion?: "2021-01-07";
|
|
6
|
-
}
|
|
1
|
+
import msClient from "@memberstack/client";
|
|
2
|
+
export declare type ClientConfig = Parameters<typeof msClient["init"]>[0];
|
|
7
3
|
export declare const initClient: (props: ClientConfig) => {
|
|
8
|
-
getApp(): Promise<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
getApp(): Promise<{
|
|
5
|
+
data: {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
domains?: {
|
|
9
|
+
url: string;
|
|
10
|
+
verified: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
plans: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
status: string;
|
|
17
|
+
prices?: [] | {
|
|
18
|
+
id: string;
|
|
19
|
+
amount: string;
|
|
20
|
+
interval: {
|
|
21
|
+
type: string;
|
|
22
|
+
count: number;
|
|
23
|
+
};
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
status: string;
|
|
27
|
+
currency: string;
|
|
28
|
+
}[];
|
|
29
|
+
}[];
|
|
30
|
+
customFields: {
|
|
31
|
+
id: string;
|
|
32
|
+
key: string;
|
|
33
|
+
label: string;
|
|
34
|
+
plans: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
status: string;
|
|
39
|
+
prices?: [] | {
|
|
40
|
+
id: string;
|
|
41
|
+
amount: string;
|
|
42
|
+
interval: {
|
|
43
|
+
type: string;
|
|
44
|
+
count: number;
|
|
45
|
+
};
|
|
46
|
+
name: string;
|
|
47
|
+
type: string;
|
|
48
|
+
status: string;
|
|
49
|
+
currency: string;
|
|
50
|
+
}[];
|
|
51
|
+
}[];
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
getAuthProviders(): Promise<{
|
|
56
|
+
data: {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
domains?: {
|
|
60
|
+
url: string;
|
|
61
|
+
verified: boolean;
|
|
62
|
+
}[];
|
|
63
|
+
plans: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
status: string;
|
|
68
|
+
prices?: [] | {
|
|
69
|
+
id: string;
|
|
70
|
+
amount: string;
|
|
71
|
+
interval: {
|
|
72
|
+
type: string;
|
|
73
|
+
count: number;
|
|
74
|
+
};
|
|
75
|
+
name: string;
|
|
76
|
+
type: string;
|
|
77
|
+
status: string;
|
|
78
|
+
currency: string;
|
|
79
|
+
}[];
|
|
80
|
+
}[];
|
|
81
|
+
customFields: {
|
|
82
|
+
id: string;
|
|
83
|
+
key: string;
|
|
84
|
+
label: string;
|
|
85
|
+
plans: {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
description: string;
|
|
89
|
+
status: string;
|
|
90
|
+
prices?: [] | {
|
|
91
|
+
id: string;
|
|
92
|
+
amount: string;
|
|
93
|
+
interval: {
|
|
94
|
+
type: string;
|
|
95
|
+
count: number;
|
|
96
|
+
};
|
|
97
|
+
name: string;
|
|
98
|
+
type: string;
|
|
99
|
+
status: string;
|
|
100
|
+
currency: string;
|
|
101
|
+
}[];
|
|
102
|
+
}[];
|
|
103
|
+
}[];
|
|
104
|
+
};
|
|
105
|
+
}>;
|
|
106
|
+
loginMemberEmailPassword(params: import("@memberstack/client/lib/types/params").LoginMemberEmailPasswordParams): Promise<{
|
|
107
|
+
data: {
|
|
108
|
+
tokens: {
|
|
109
|
+
accessToken: string;
|
|
110
|
+
refreshToken: string;
|
|
111
|
+
expires: number;
|
|
112
|
+
type: "bearer";
|
|
113
|
+
};
|
|
114
|
+
member: {
|
|
115
|
+
id: string;
|
|
116
|
+
auth: {
|
|
117
|
+
email: string;
|
|
118
|
+
};
|
|
119
|
+
metaData: object;
|
|
120
|
+
customFields: object;
|
|
121
|
+
permissions: string[] | [];
|
|
122
|
+
planConnections: {
|
|
123
|
+
id: string;
|
|
124
|
+
active: boolean;
|
|
125
|
+
status: string;
|
|
126
|
+
planId: string;
|
|
127
|
+
type: string;
|
|
128
|
+
payment: {
|
|
129
|
+
amount: number;
|
|
130
|
+
currency: string;
|
|
131
|
+
status: string;
|
|
132
|
+
lastBillingDate: number;
|
|
133
|
+
nextBillingDate: number;
|
|
134
|
+
cancelAtDate: number;
|
|
135
|
+
lastInvoice: string;
|
|
136
|
+
lastReceipt: string;
|
|
137
|
+
card: string;
|
|
138
|
+
};
|
|
139
|
+
}[];
|
|
140
|
+
};
|
|
141
|
+
payment: {
|
|
142
|
+
requirePayment: string[];
|
|
143
|
+
requireAuthentication: string[];
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
147
|
+
loginMemberAuthProvider(params: import("@memberstack/client/lib/types/params").LoginMemberAuthProviderParams): Promise<{
|
|
148
|
+
data: {
|
|
149
|
+
tokens: {
|
|
150
|
+
accessToken: string;
|
|
151
|
+
refreshToken: string;
|
|
152
|
+
expires: number;
|
|
153
|
+
type: "bearer";
|
|
154
|
+
};
|
|
155
|
+
member: {
|
|
156
|
+
id: string;
|
|
157
|
+
auth: {
|
|
158
|
+
email: string;
|
|
159
|
+
};
|
|
160
|
+
metaData: object;
|
|
161
|
+
customFields: object;
|
|
162
|
+
permissions: string[] | [];
|
|
163
|
+
planConnections: {
|
|
164
|
+
id: string;
|
|
165
|
+
active: boolean;
|
|
166
|
+
status: string;
|
|
167
|
+
planId: string;
|
|
168
|
+
type: string;
|
|
169
|
+
payment: {
|
|
170
|
+
amount: number;
|
|
171
|
+
currency: string;
|
|
172
|
+
status: string;
|
|
173
|
+
lastBillingDate: number;
|
|
174
|
+
nextBillingDate: number;
|
|
175
|
+
cancelAtDate: number;
|
|
176
|
+
lastInvoice: string;
|
|
177
|
+
lastReceipt: string;
|
|
178
|
+
card: string;
|
|
179
|
+
};
|
|
180
|
+
}[];
|
|
181
|
+
};
|
|
182
|
+
payment: {
|
|
183
|
+
requirePayment: string[];
|
|
184
|
+
requireAuthentication: string[];
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
}>;
|
|
188
|
+
getPlan(params: import("@memberstack/client/lib/types/params").GetPlanParams): Promise<{
|
|
189
|
+
data: {
|
|
190
|
+
id: string;
|
|
191
|
+
name: string;
|
|
192
|
+
description: string;
|
|
193
|
+
status: string;
|
|
194
|
+
prices?: [] | {
|
|
195
|
+
id: string;
|
|
196
|
+
amount: string;
|
|
197
|
+
interval: {
|
|
198
|
+
type: string;
|
|
199
|
+
count: number;
|
|
200
|
+
};
|
|
201
|
+
name: string;
|
|
202
|
+
type: string;
|
|
203
|
+
status: string;
|
|
204
|
+
currency: string;
|
|
205
|
+
}[];
|
|
206
|
+
};
|
|
207
|
+
}>;
|
|
208
|
+
getPlans(params?: import("@memberstack/client/lib/types/params").GetPlansParams): Promise<{
|
|
209
|
+
data: {
|
|
210
|
+
id: string;
|
|
211
|
+
name: string;
|
|
212
|
+
description: string;
|
|
213
|
+
status: string;
|
|
214
|
+
prices?: [] | {
|
|
215
|
+
id: string;
|
|
216
|
+
amount: string;
|
|
217
|
+
interval: {
|
|
218
|
+
type: string;
|
|
219
|
+
count: number;
|
|
220
|
+
};
|
|
221
|
+
name: string;
|
|
222
|
+
type: string;
|
|
223
|
+
status: string;
|
|
224
|
+
currency: string;
|
|
225
|
+
}[];
|
|
226
|
+
}[];
|
|
227
|
+
}>;
|
|
228
|
+
getCurrentMember(options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
229
|
+
data: {
|
|
230
|
+
id: string;
|
|
231
|
+
auth: {
|
|
232
|
+
email: string;
|
|
233
|
+
};
|
|
234
|
+
metaData: object;
|
|
235
|
+
customFields: object;
|
|
236
|
+
permissions: string[] | [];
|
|
237
|
+
planConnections: {
|
|
238
|
+
id: string;
|
|
239
|
+
active: boolean;
|
|
240
|
+
status: string;
|
|
241
|
+
planId: string;
|
|
242
|
+
type: string;
|
|
243
|
+
payment: {
|
|
244
|
+
amount: number;
|
|
245
|
+
currency: string;
|
|
246
|
+
status: string;
|
|
247
|
+
lastBillingDate: number;
|
|
248
|
+
nextBillingDate: number;
|
|
249
|
+
cancelAtDate: number;
|
|
250
|
+
lastInvoice: string;
|
|
251
|
+
lastReceipt: string;
|
|
252
|
+
card: string;
|
|
253
|
+
};
|
|
254
|
+
}[];
|
|
255
|
+
};
|
|
256
|
+
}>;
|
|
257
|
+
getMemberCards(options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
258
|
+
data: {
|
|
259
|
+
id: string;
|
|
260
|
+
brand: string;
|
|
261
|
+
expMonth: string;
|
|
262
|
+
expYear: string;
|
|
263
|
+
last4: string;
|
|
264
|
+
default: boolean;
|
|
265
|
+
}[];
|
|
266
|
+
}>;
|
|
267
|
+
getMemberInvoices(params?: import("@memberstack/client/lib/types/params").GetMemberInvoicesParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
268
|
+
hasNext: boolean;
|
|
269
|
+
endCursor: string;
|
|
270
|
+
totalCount: number;
|
|
271
|
+
data: {
|
|
272
|
+
id: string;
|
|
273
|
+
status: string;
|
|
274
|
+
amount: number;
|
|
275
|
+
url: string;
|
|
276
|
+
description: string;
|
|
277
|
+
number: string;
|
|
278
|
+
planConnection: string;
|
|
279
|
+
}[];
|
|
280
|
+
}>;
|
|
281
|
+
getMemberReceipts(params?: import("@memberstack/client/lib/types/params").GetMemberReceiptsParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
282
|
+
hasNext: boolean;
|
|
283
|
+
endCursor: string;
|
|
284
|
+
totalCount: number;
|
|
285
|
+
data: {
|
|
286
|
+
id: string;
|
|
287
|
+
amount: number;
|
|
288
|
+
url: string;
|
|
289
|
+
stripe?: {
|
|
290
|
+
url: string;
|
|
291
|
+
};
|
|
292
|
+
number: string;
|
|
293
|
+
purchase: string;
|
|
294
|
+
invoice: string;
|
|
295
|
+
}[];
|
|
296
|
+
}>;
|
|
297
|
+
getAuthenticationClientSecret(params: import("@memberstack/client/lib/types/params").GetAuthenticationClientSecretParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
298
|
+
data: string;
|
|
299
|
+
}>;
|
|
300
|
+
getTotalCheckoutAmount(params: import("@memberstack/client/lib/types/params").GetTotalCheckoutAmountParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
301
|
+
data: {
|
|
302
|
+
total: number;
|
|
303
|
+
subTotal: number;
|
|
304
|
+
currency: string;
|
|
305
|
+
setupFee?: {
|
|
306
|
+
enabled: boolean;
|
|
307
|
+
amount: number;
|
|
308
|
+
name: string;
|
|
309
|
+
};
|
|
310
|
+
freeTrial?: {
|
|
311
|
+
days: number;
|
|
312
|
+
enabled: boolean;
|
|
313
|
+
};
|
|
314
|
+
tax?: {
|
|
315
|
+
name: string;
|
|
316
|
+
percent: number;
|
|
317
|
+
description: string;
|
|
318
|
+
}[];
|
|
319
|
+
};
|
|
320
|
+
}>;
|
|
321
|
+
purchasePlan(params: import("@memberstack/client/lib/types/params").PurchasePlanParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
322
|
+
data: {
|
|
323
|
+
plan: string;
|
|
324
|
+
payment: {
|
|
325
|
+
requiresPayment: boolean;
|
|
326
|
+
requiresAuthentication: boolean;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
}>;
|
|
330
|
+
cancelPlan(params: import("@memberstack/client/lib/types/params").CancelPlanParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
331
|
+
data: {
|
|
332
|
+
id: string;
|
|
333
|
+
auth: {
|
|
334
|
+
email: string;
|
|
335
|
+
};
|
|
336
|
+
metaData: object;
|
|
337
|
+
customFields: object;
|
|
338
|
+
permissions: string[] | [];
|
|
339
|
+
planConnections: {
|
|
340
|
+
id: string;
|
|
341
|
+
active: boolean;
|
|
342
|
+
status: string;
|
|
343
|
+
planId: string;
|
|
344
|
+
type: string;
|
|
345
|
+
payment: {
|
|
346
|
+
amount: number;
|
|
347
|
+
currency: string;
|
|
348
|
+
status: string;
|
|
349
|
+
lastBillingDate: number;
|
|
350
|
+
nextBillingDate: number;
|
|
351
|
+
cancelAtDate: number;
|
|
352
|
+
lastInvoice: string;
|
|
353
|
+
lastReceipt: string;
|
|
354
|
+
card: string;
|
|
355
|
+
};
|
|
356
|
+
}[];
|
|
357
|
+
};
|
|
358
|
+
}>;
|
|
359
|
+
updateMember(params: import("@memberstack/client/lib/types/params").UpdateMemberParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
360
|
+
data: {
|
|
361
|
+
id: string;
|
|
362
|
+
auth: {
|
|
363
|
+
email: string;
|
|
364
|
+
};
|
|
365
|
+
metaData: object;
|
|
366
|
+
customFields: object;
|
|
367
|
+
permissions: string[] | [];
|
|
368
|
+
planConnections: {
|
|
369
|
+
id: string;
|
|
370
|
+
active: boolean;
|
|
371
|
+
status: string;
|
|
372
|
+
planId: string;
|
|
373
|
+
type: string;
|
|
374
|
+
payment: {
|
|
375
|
+
amount: number;
|
|
376
|
+
currency: string;
|
|
377
|
+
status: string;
|
|
378
|
+
lastBillingDate: number;
|
|
379
|
+
nextBillingDate: number;
|
|
380
|
+
cancelAtDate: number;
|
|
381
|
+
lastInvoice: string;
|
|
382
|
+
lastReceipt: string;
|
|
383
|
+
card: string;
|
|
384
|
+
};
|
|
385
|
+
}[];
|
|
386
|
+
};
|
|
387
|
+
}>;
|
|
388
|
+
updateMemberAuth(params: import("@memberstack/client/lib/types/params").UpdateMemberAuthParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
389
|
+
data: {
|
|
390
|
+
id: string;
|
|
391
|
+
auth: {
|
|
392
|
+
email: string;
|
|
393
|
+
};
|
|
394
|
+
metaData: object;
|
|
395
|
+
customFields: object;
|
|
396
|
+
permissions: string[] | [];
|
|
397
|
+
planConnections: {
|
|
398
|
+
id: string;
|
|
399
|
+
active: boolean;
|
|
400
|
+
status: string;
|
|
401
|
+
planId: string;
|
|
402
|
+
type: string;
|
|
403
|
+
payment: {
|
|
404
|
+
amount: number;
|
|
405
|
+
currency: string;
|
|
406
|
+
status: string;
|
|
407
|
+
lastBillingDate: number;
|
|
408
|
+
nextBillingDate: number;
|
|
409
|
+
cancelAtDate: number;
|
|
410
|
+
lastInvoice: string;
|
|
411
|
+
lastReceipt: string;
|
|
412
|
+
card: string;
|
|
413
|
+
};
|
|
414
|
+
}[];
|
|
415
|
+
};
|
|
416
|
+
}>;
|
|
417
|
+
addCard(params: import("@memberstack/client/lib/types/params").AddMemberCardParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
418
|
+
data: {
|
|
419
|
+
id: string;
|
|
420
|
+
auth: {
|
|
421
|
+
email: string;
|
|
422
|
+
};
|
|
423
|
+
metaData: object;
|
|
424
|
+
customFields: object;
|
|
425
|
+
permissions: string[] | [];
|
|
426
|
+
planConnections: {
|
|
427
|
+
id: string;
|
|
428
|
+
active: boolean;
|
|
429
|
+
status: string;
|
|
430
|
+
planId: string;
|
|
431
|
+
type: string;
|
|
432
|
+
payment: {
|
|
433
|
+
amount: number;
|
|
434
|
+
currency: string;
|
|
435
|
+
status: string;
|
|
436
|
+
lastBillingDate: number;
|
|
437
|
+
nextBillingDate: number;
|
|
438
|
+
cancelAtDate: number;
|
|
439
|
+
lastInvoice: string;
|
|
440
|
+
lastReceipt: string;
|
|
441
|
+
card: string;
|
|
442
|
+
};
|
|
443
|
+
}[];
|
|
444
|
+
};
|
|
445
|
+
}>;
|
|
446
|
+
updateDefaultCard(params: import("@memberstack/client/lib/types/params").UpdateDefaultCardParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
447
|
+
data: {
|
|
448
|
+
id: string;
|
|
449
|
+
auth: {
|
|
450
|
+
email: string;
|
|
451
|
+
};
|
|
452
|
+
metaData: object;
|
|
453
|
+
customFields: object;
|
|
454
|
+
permissions: string[] | [];
|
|
455
|
+
planConnections: {
|
|
456
|
+
id: string;
|
|
457
|
+
active: boolean;
|
|
458
|
+
status: string;
|
|
459
|
+
planId: string;
|
|
460
|
+
type: string;
|
|
461
|
+
payment: {
|
|
462
|
+
amount: number;
|
|
463
|
+
currency: string;
|
|
464
|
+
status: string;
|
|
465
|
+
lastBillingDate: number;
|
|
466
|
+
nextBillingDate: number;
|
|
467
|
+
cancelAtDate: number;
|
|
468
|
+
lastInvoice: string;
|
|
469
|
+
lastReceipt: string;
|
|
470
|
+
card: string;
|
|
471
|
+
};
|
|
472
|
+
}[];
|
|
473
|
+
};
|
|
474
|
+
}>;
|
|
475
|
+
updatePlanPayment(params: import("@memberstack/client/lib/types/params").UpdatePlanPaymentParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
476
|
+
data: {
|
|
477
|
+
id: string;
|
|
478
|
+
auth: {
|
|
479
|
+
email: string;
|
|
480
|
+
};
|
|
481
|
+
metaData: object;
|
|
482
|
+
customFields: object;
|
|
483
|
+
permissions: string[] | [];
|
|
484
|
+
planConnections: {
|
|
485
|
+
id: string;
|
|
486
|
+
active: boolean;
|
|
487
|
+
status: string;
|
|
488
|
+
planId: string;
|
|
489
|
+
type: string;
|
|
490
|
+
payment: {
|
|
491
|
+
amount: number;
|
|
492
|
+
currency: string;
|
|
493
|
+
status: string;
|
|
494
|
+
lastBillingDate: number;
|
|
495
|
+
nextBillingDate: number;
|
|
496
|
+
cancelAtDate: number;
|
|
497
|
+
lastInvoice: string;
|
|
498
|
+
lastReceipt: string;
|
|
499
|
+
card: string;
|
|
500
|
+
};
|
|
501
|
+
}[];
|
|
502
|
+
};
|
|
503
|
+
}>;
|
|
504
|
+
signupMemberEmailPassword(params: import("@memberstack/client/lib/types/params").SignupMemberEmailPasswordParams): Promise<{
|
|
505
|
+
data: {
|
|
506
|
+
tokens: {
|
|
507
|
+
accessToken: string;
|
|
508
|
+
refreshToken: string;
|
|
509
|
+
expires: number;
|
|
510
|
+
type: "bearer";
|
|
511
|
+
};
|
|
512
|
+
member: {
|
|
513
|
+
id: string;
|
|
514
|
+
auth: {
|
|
515
|
+
email: string;
|
|
516
|
+
};
|
|
517
|
+
metaData: object;
|
|
518
|
+
customFields: object;
|
|
519
|
+
permissions: string[] | [];
|
|
520
|
+
planConnections: {
|
|
521
|
+
id: string;
|
|
522
|
+
active: boolean;
|
|
523
|
+
status: string;
|
|
524
|
+
planId: string;
|
|
525
|
+
type: string;
|
|
526
|
+
payment: {
|
|
527
|
+
amount: number;
|
|
528
|
+
currency: string;
|
|
529
|
+
status: string;
|
|
530
|
+
lastBillingDate: number;
|
|
531
|
+
nextBillingDate: number;
|
|
532
|
+
cancelAtDate: number;
|
|
533
|
+
lastInvoice: string;
|
|
534
|
+
lastReceipt: string;
|
|
535
|
+
card: string;
|
|
536
|
+
};
|
|
537
|
+
}[];
|
|
538
|
+
};
|
|
539
|
+
payment: {
|
|
540
|
+
requirePayment: string[];
|
|
541
|
+
requireAuthentication: string[];
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
}>;
|
|
545
|
+
signupMemberAuthProvider(params: import("@memberstack/client/lib/types/params").SignupMemberAuthProviderParams): Promise<{
|
|
546
|
+
data: {
|
|
547
|
+
tokens: {
|
|
548
|
+
accessToken: string;
|
|
549
|
+
refreshToken: string;
|
|
550
|
+
expires: number;
|
|
551
|
+
type: "bearer";
|
|
552
|
+
};
|
|
553
|
+
member: {
|
|
554
|
+
id: string;
|
|
555
|
+
auth: {
|
|
556
|
+
email: string;
|
|
557
|
+
};
|
|
558
|
+
metaData: object;
|
|
559
|
+
customFields: object;
|
|
560
|
+
permissions: string[] | [];
|
|
561
|
+
planConnections: {
|
|
562
|
+
id: string;
|
|
563
|
+
active: boolean;
|
|
564
|
+
status: string;
|
|
565
|
+
planId: string;
|
|
566
|
+
type: string;
|
|
567
|
+
payment: {
|
|
568
|
+
amount: number;
|
|
569
|
+
currency: string;
|
|
570
|
+
status: string;
|
|
571
|
+
lastBillingDate: number;
|
|
572
|
+
nextBillingDate: number;
|
|
573
|
+
cancelAtDate: number;
|
|
574
|
+
lastInvoice: string;
|
|
575
|
+
lastReceipt: string;
|
|
576
|
+
card: string;
|
|
577
|
+
};
|
|
578
|
+
}[];
|
|
579
|
+
};
|
|
580
|
+
payment: {
|
|
581
|
+
requirePayment: string[];
|
|
582
|
+
requireAuthentication: string[];
|
|
583
|
+
};
|
|
584
|
+
};
|
|
585
|
+
}>;
|
|
586
|
+
refreshMemberTokens(params: import("@memberstack/client/lib/types/params").RefreshMemberTokensParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
587
|
+
data: {
|
|
588
|
+
accessToken: string;
|
|
589
|
+
refreshToken: string;
|
|
590
|
+
expires: number;
|
|
591
|
+
type: "bearer";
|
|
592
|
+
};
|
|
593
|
+
}>;
|
|
594
|
+
sendMemberResetPasswordEmail(params: import("@memberstack/client/lib/types/params").SendMemberResetPasswordEmailParams): Promise<{
|
|
595
|
+
data: string;
|
|
596
|
+
}>;
|
|
597
|
+
resetMemberPassword(params: import("@memberstack/client/lib/types/params").ResetMemberPasswordParams): Promise<{
|
|
598
|
+
data: {
|
|
599
|
+
id: string;
|
|
600
|
+
auth: {
|
|
601
|
+
email: string;
|
|
602
|
+
};
|
|
603
|
+
metaData: object;
|
|
604
|
+
customFields: object;
|
|
605
|
+
permissions: string[] | [];
|
|
606
|
+
planConnections: {
|
|
607
|
+
id: string;
|
|
608
|
+
active: boolean;
|
|
609
|
+
status: string;
|
|
610
|
+
planId: string;
|
|
611
|
+
type: string;
|
|
612
|
+
payment: {
|
|
613
|
+
amount: number;
|
|
614
|
+
currency: string;
|
|
615
|
+
status: string;
|
|
616
|
+
lastBillingDate: number;
|
|
617
|
+
nextBillingDate: number;
|
|
618
|
+
cancelAtDate: number;
|
|
619
|
+
lastInvoice: string;
|
|
620
|
+
lastReceipt: string;
|
|
621
|
+
card: string;
|
|
622
|
+
};
|
|
623
|
+
}[];
|
|
624
|
+
};
|
|
625
|
+
}>;
|
|
626
|
+
logout(options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
627
|
+
data: {
|
|
628
|
+
redirect?: string;
|
|
629
|
+
};
|
|
630
|
+
}>;
|
|
631
|
+
replacePlan(params: import("@memberstack/client/lib/types/params").ReplacePlanParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<{
|
|
632
|
+
data: {
|
|
633
|
+
plan: string;
|
|
634
|
+
payment: {
|
|
635
|
+
requiresPayment: boolean;
|
|
636
|
+
requiresAuthentication: boolean;
|
|
637
|
+
};
|
|
638
|
+
};
|
|
639
|
+
}>;
|
|
34
640
|
verifyToken({ token }: {
|
|
35
641
|
token: string;
|
|
36
642
|
}): Promise<Pick<import("jose").JWTPayload, "iat" | "exp"> & {
|
package/lib/methods/client.js
CHANGED
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.initClient = void 0;
|
|
18
18
|
var client_1 = __importDefault(require("@memberstack/client"));
|
|
19
19
|
var cookies_1 = require("../utils/cookies");
|
|
20
|
-
|
|
21
|
-
return client_1.default.init(__assign({ token:
|
|
20
|
+
exports.initClient = function (props) {
|
|
21
|
+
return client_1.default.init(__assign({ token: cookies_1.getMemberCookie() }, props));
|
|
22
22
|
};
|
|
23
|
-
exports.initClient = initClient;
|
package/lib/methods/dom/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initialize = exports.openModal = exports.load = exports.hideModal = void 0;
|
|
4
3
|
var methods_1 = require("./methods");
|
|
5
4
|
Object.defineProperty(exports, "hideModal", { enumerable: true, get: function () { return methods_1.hideModal; } });
|
|
6
5
|
Object.defineProperty(exports, "load", { enumerable: true, get: function () { return methods_1.load; } });
|
|
@@ -26,14 +26,13 @@ var hasIFrame = function () {
|
|
|
26
26
|
}
|
|
27
27
|
return true;
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
exports.load = function (props) {
|
|
30
30
|
var _a;
|
|
31
31
|
if (isInitialized()) {
|
|
32
32
|
(_a = window[window_1.Window.MSDOM]) === null || _a === void 0 ? void 0 : _a.load({ publicKey: props.publicKey });
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
exports.
|
|
36
|
-
var openModal = function (props) {
|
|
35
|
+
exports.openModal = function (props) {
|
|
37
36
|
var _a;
|
|
38
37
|
if (hasIFrame()) {
|
|
39
38
|
(_a = window[window_1.Window.MSDOM]) === null || _a === void 0 ? void 0 : _a.show(props.type, props.params);
|
|
@@ -41,24 +40,22 @@ var openModal = function (props) {
|
|
|
41
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
42
41
|
if (e.origin === endpoint_1.endpoints.parentOrigin) {
|
|
43
42
|
if (e.data.type === "CLOSE") {
|
|
44
|
-
return
|
|
43
|
+
return exports.hideModal();
|
|
45
44
|
}
|
|
46
45
|
if ((_b = (_a = e.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.member) {
|
|
47
|
-
|
|
46
|
+
persistence_1.setPersistedMember((_c = e.data) === null || _c === void 0 ? void 0 : _c.data.member, props.persistence);
|
|
48
47
|
}
|
|
49
48
|
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)) {
|
|
50
|
-
|
|
49
|
+
cookies_1.setMemberCookie(e.data.data.tokens.accessToken);
|
|
51
50
|
}
|
|
52
51
|
(_h = (_g = props.options) === null || _g === void 0 ? void 0 : _g.onCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, (_j = e.data) === null || _j === void 0 ? void 0 : _j.data);
|
|
53
52
|
}
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
55
|
};
|
|
57
|
-
exports.
|
|
58
|
-
var hideModal = function () {
|
|
56
|
+
exports.hideModal = function () {
|
|
59
57
|
var _a;
|
|
60
58
|
if (hasIFrame()) {
|
|
61
59
|
(_a = window[window_1.Window.MSDOM]) === null || _a === void 0 ? void 0 : _a.hide();
|
|
62
60
|
}
|
|
63
61
|
};
|
|
64
|
-
exports.hideModal = hideModal;
|
package/lib/methods/index.d.ts
CHANGED
package/lib/methods/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
25
25
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
26
|
if (mod && mod.__esModule) return mod;
|
|
27
27
|
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
29
|
__setModuleDefault(result, mod);
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
@@ -63,13 +63,12 @@ var DOMMethods = function (_a) {
|
|
|
63
63
|
var withScript = function (fn) {
|
|
64
64
|
return function (props) {
|
|
65
65
|
var config = __assign({ persistence: persistence_1.Persistence.LOCAL, useCookie: true }, props);
|
|
66
|
-
|
|
67
|
-
(0, interceptor_1.initializeInterceptors)({ persistence: config.persistence });
|
|
66
|
+
script_1.initialize({ publicKey: props.publicKey });
|
|
68
67
|
return fn(config);
|
|
69
68
|
};
|
|
70
69
|
};
|
|
71
70
|
exports.init = withScript(function (props) {
|
|
72
|
-
var client =
|
|
71
|
+
var client = proxy_1.default(client_1.initClient(__assign(__assign({}, props), { onMemberToken: function (token) { return interceptor_1.handleMemberToken({ persistence: props.persistence, token: token }); } })), props);
|
|
73
72
|
var methods = DOMMethods(props);
|
|
74
73
|
return Object.assign(client, methods);
|
|
75
74
|
});
|
package/lib/utils/cookies.js
CHANGED
|
@@ -6,14 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getMemberCookie = exports.setMemberCookie = void 0;
|
|
7
7
|
var js_cookie_1 = __importDefault(require("js-cookie"));
|
|
8
8
|
var cookies_1 = require("../constants/cookies");
|
|
9
|
-
|
|
9
|
+
exports.setMemberCookie = function (token, expires) {
|
|
10
10
|
js_cookie_1.default.set(cookies_1.MemberCookies.AUTH, token, {
|
|
11
11
|
expires: expires || new Date(Date.now() + 604800000),
|
|
12
12
|
sameSite: "strict",
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
|
-
exports.
|
|
16
|
-
var getMemberCookie = function () {
|
|
15
|
+
exports.getMemberCookie = function () {
|
|
17
16
|
return js_cookie_1.default.get(cookies_1.MemberCookies.AUTH);
|
|
18
17
|
};
|
|
19
|
-
exports.getMemberCookie = getMemberCookie;
|
package/lib/utils/interceptor.js
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var node_request_interceptor_1 = require("node-request-interceptor");
|
|
8
|
-
var default_1 = __importDefault(require("node-request-interceptor/lib/presets/default"));
|
|
3
|
+
exports.handleMemberToken = void 0;
|
|
9
4
|
var cookies_1 = require("./cookies");
|
|
10
5
|
var persistence_1 = require("../auth/persistence");
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
(0, cookies_1.setMemberCookie)("", -1);
|
|
18
|
-
if ((0, persistence_1.getPersistedMember)(persistence)) {
|
|
19
|
-
(0, persistence_1.unsetPersistedMember)(persistence);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
(0, cookies_1.setMemberCookie)(response.headers["ms-mid"]);
|
|
24
|
-
}
|
|
6
|
+
exports.handleMemberToken = function (_a) {
|
|
7
|
+
var persistence = _a.persistence, token = _a.token;
|
|
8
|
+
if (token === "null") {
|
|
9
|
+
cookies_1.setMemberCookie("", -1);
|
|
10
|
+
if (persistence_1.getPersistedMember(persistence)) {
|
|
11
|
+
persistence_1.unsetPersistedMember(persistence);
|
|
25
12
|
}
|
|
26
|
-
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
cookies_1.setMemberCookie(token);
|
|
16
|
+
}
|
|
27
17
|
};
|
|
28
|
-
exports.initializeInterceptors = initializeInterceptors;
|
package/lib/utils/proxy.js
CHANGED
|
@@ -51,14 +51,9 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
51
51
|
}
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
54
|
+
var __spread = (this && this.__spread) || function () {
|
|
55
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
56
|
+
return ar;
|
|
62
57
|
};
|
|
63
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
59
|
var persistence_1 = require("../auth/persistence");
|
|
@@ -68,15 +63,15 @@ var handleResponse = function (fn, props) {
|
|
|
68
63
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
69
64
|
args[_i] = arguments[_i];
|
|
70
65
|
}
|
|
71
|
-
var result = fn.apply(void 0,
|
|
66
|
+
var result = fn.apply(void 0, __spread(args));
|
|
72
67
|
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
73
68
|
return result.then(function (res) {
|
|
74
69
|
var _a, _b, _c, _d;
|
|
75
70
|
if ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.member) {
|
|
76
|
-
|
|
71
|
+
persistence_1.setPersistedMember((_b = res.data) === null || _b === void 0 ? void 0 : _b.member, props.persistence);
|
|
77
72
|
}
|
|
78
73
|
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
|
-
|
|
74
|
+
persistence_1.setPersistedMember(res.data, props.persistence);
|
|
80
75
|
}
|
|
81
76
|
return res;
|
|
82
77
|
});
|
|
@@ -88,7 +83,7 @@ var handler = function (props) { return ({
|
|
|
88
83
|
get: function (target, prop, receiver) {
|
|
89
84
|
var _this = this;
|
|
90
85
|
if (prop === "getCurrentMember") {
|
|
91
|
-
var persistedMember_1 =
|
|
86
|
+
var persistedMember_1 = persistence_1.getPersistedMember(props.persistence);
|
|
92
87
|
if (persistedMember_1) {
|
|
93
88
|
return function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
94
89
|
return [2 /*return*/, ({ data: persistedMember_1 })];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberstack/dom",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.28",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib/**/*"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"author": "Lydia Hallie",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@memberstack/client": "^1.0.1-beta.
|
|
11
|
+
"@memberstack/client": "^1.0.1-beta.10",
|
|
12
12
|
"js-cookie": "^3.0.1",
|
|
13
13
|
"node-request-interceptor": "^0.6.3"
|
|
14
14
|
},
|