@memberstack/dom 1.0.0-beta.28 → 1.0.0-beta.31

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.
@@ -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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./methods"), exports);
@@ -15,9 +15,14 @@ var __read = (this && this.__read) || function (o, n) {
15
15
  }
16
16
  return ar;
17
17
  };
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;
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
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));
21
26
  };
22
27
  Object.defineProperty(exports, "__esModule", { value: true });
23
28
  exports.onAuthChange = exports.unsetPersistedMember = exports.getPersistedMember = exports.setPersistedMember = exports.Persistence = void 0;
@@ -40,7 +45,7 @@ var createObservable = function () {
40
45
  return observer.delete(key);
41
46
  },
42
47
  notify: function (data) {
43
- return __spread(observer.values()).forEach(function (fn) { return fn(data); });
48
+ return __spreadArray([], __read(observer.values()), false).forEach(function (fn) { return fn(data); });
44
49
  },
45
50
  };
46
51
  };
@@ -53,26 +58,30 @@ var getPersistence = function (persistence) {
53
58
  return session_1.sessionStoragePersistence;
54
59
  }
55
60
  };
56
- exports.setPersistedMember = function (member, persistence) {
61
+ var setPersistedMember = function (member, persistence) {
57
62
  var _a;
58
63
  if (member) {
59
64
  (_a = getPersistence(persistence)) === null || _a === void 0 ? void 0 : _a.setMember(member);
60
65
  observable.notify(member);
61
66
  }
62
67
  };
63
- exports.getPersistedMember = function (persistence) {
68
+ exports.setPersistedMember = setPersistedMember;
69
+ var getPersistedMember = function (persistence) {
64
70
  var _a;
65
71
  return (_a = getPersistence(persistence)) === null || _a === void 0 ? void 0 : _a.getMember();
66
72
  };
67
- exports.unsetPersistedMember = function (persistence) {
73
+ exports.getPersistedMember = getPersistedMember;
74
+ var unsetPersistedMember = function (persistence) {
68
75
  var _a;
69
76
  (_a = getPersistence(persistence)) === null || _a === void 0 ? void 0 : _a.unsetMember();
70
77
  observable.notify(null);
71
78
  };
72
- exports.onAuthChange = function (cb) {
79
+ exports.unsetPersistedMember = unsetPersistedMember;
80
+ var onAuthChange = function (cb) {
73
81
  var id = Math.floor(Math.random() * 1000);
74
82
  observable.subscribe(id, cb);
75
83
  return {
76
84
  unsubscribe: function () { return observable.unsubscribe(id); },
77
85
  };
78
86
  };
87
+ exports.onAuthChange = onAuthChange;
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.endpoints = void 0;
4
4
  exports.endpoints = {
5
- parentOrigin: "https://ui.memberstack.com",
6
- loaderScript: "https://ui.memberstack.com/loader.cjs.production.min.js",
5
+ parentOrigin: "https://ui-parent.vercel.app",
6
+ loaderScript: "https://ui-parent.vercel.app/loader.cjs.production.min.js",
7
7
  };
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { Persistence } from "./auth/persistence";
2
- import { Methods } from "./methods";
3
- export default Methods;
1
+ declare const _default: {
2
+ init: (props: any) => any;
3
+ };
4
+ export default _default;
package/lib/index.js CHANGED
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var persistence_1 = require("./auth/persistence");
4
- Object.defineProperty(exports, "Persistence", { enumerable: true, get: function () { return persistence_1.Persistence; } });
5
3
  var methods_1 = require("./methods");
6
- exports.default = methods_1.Methods;
4
+ exports.default = { init: methods_1.init };
@@ -1,642 +1,34 @@
1
1
  import msClient from "@memberstack/client";
2
- export declare type ClientConfig = Parameters<typeof msClient["init"]>[0];
3
- export declare const initClient: (props: ClientConfig) => {
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
- }>;
2
+ export declare type ClientConfig = Parameters<typeof msClient["init"]>[0] & {
3
+ useCookie?: boolean;
4
+ };
5
+ export declare const initClient: ({ useCookie, ...props }: ClientConfig) => {
6
+ getApp(): Promise<import("@memberstack/client/lib/types/payloads").AppPayload>;
7
+ getAuthProviders(): Promise<import("@memberstack/client/lib/types/payloads").AppPayload>;
8
+ loginMemberEmailPassword(params: import("@memberstack/client/lib/types/params").LoginMemberEmailPasswordParams): Promise<import("@memberstack/client/lib/types/payloads").LoginMemberEmailPasswordPayload>;
9
+ loginMemberAuthProvider(params: import("@memberstack/client/lib/types/params").LoginMemberAuthProviderParams): Promise<import("@memberstack/client/lib/types/payloads").LoginMemberAuthProviderPayload>;
10
+ getPlan(params: import("@memberstack/client/lib/types/params").GetPlanParams): Promise<import("@memberstack/client/lib/types/payloads").GetPlanPayload>;
11
+ getPlans(params?: import("@memberstack/client/lib/types/params").GetPlansParams): Promise<import("@memberstack/client/lib/types/payloads").GetPlansPayload>;
12
+ getCurrentMember(options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").GetCurrentMemberPayload>;
13
+ getMemberCards(options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").GetMemberCardsPayload>;
14
+ getMemberInvoices(params?: import("@memberstack/client/lib/types/params").GetMemberInvoicesParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").GetMemberInvoicesPayload>;
15
+ getMemberReceipts(params?: import("@memberstack/client/lib/types/params").GetMemberReceiptsParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").GetMemberReceiptsPayload>;
16
+ getAuthenticationClientSecret(params: import("@memberstack/client/lib/types/params").GetAuthenticationClientSecretParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").GetAuthenticationClientSecretPayload>;
17
+ getTotalCheckoutAmount(params: import("@memberstack/client/lib/types/params").GetTotalCheckoutAmountParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").GetTotalCheckoutAmountPayload>;
18
+ purchasePlans(params: import("@memberstack/client/lib/types/params").PurchasePlansParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").PurchasePlansPayload>;
19
+ cancelPlan(params: import("@memberstack/client/lib/types/params").CancelPlanParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").CancelPlanPayload>;
20
+ updateMember(params: import("@memberstack/client/lib/types/params").UpdateMemberParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").UpdateMemberPayload>;
21
+ updateMemberAuth(params: import("@memberstack/client/lib/types/params").UpdateMemberAuthParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").UpdateMemberAuthPayload>;
22
+ addCard(params: import("@memberstack/client/lib/types/params").AddMemberCardParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").AddMemberCardPayload>;
23
+ updateDefaultCard(params: import("@memberstack/client/lib/types/params").UpdateDefaultCardParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").UpdateDefaultCardPayload>;
24
+ updatePlanPayment(params: import("@memberstack/client/lib/types/params").UpdatePlanPaymentParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").UpdatePlanPaymentPayload>;
25
+ signupMemberEmailPassword(params: import("@memberstack/client/lib/types/params").SignupMemberEmailPasswordParams): Promise<import("@memberstack/client/lib/types/payloads").SignupMemberEmailPasswordPayload>;
26
+ signupMemberAuthProvider(params: import("@memberstack/client/lib/types/params").SignupMemberAuthProviderParams): Promise<import("@memberstack/client/lib/types/payloads").SignupMemberAuthProviderPayload>;
27
+ refreshMemberTokens(params: import("@memberstack/client/lib/types/params").RefreshMemberTokensParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").RefreshMemberTokensPayload>;
28
+ sendMemberResetPasswordEmail(params: import("@memberstack/client/lib/types/params").SendMemberResetPasswordEmailParams): Promise<import("@memberstack/client/lib/types/payloads").SendMemberResetPasswordEmailPayload>;
29
+ resetMemberPassword(params: import("@memberstack/client/lib/types/params").ResetMemberPasswordParams): Promise<import("@memberstack/client/lib/types/payloads").ResetMemberPasswordPayload>;
30
+ logout(options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").LogoutMemberPayload>;
31
+ replacePlan(params: import("@memberstack/client/lib/types/params").ReplacePlanParams, options?: import("@memberstack/client/lib/methods").MemberstackOptions): Promise<import("@memberstack/client/lib/types/payloads").ReplacePlanPayload>;
640
32
  verifyToken({ token }: {
641
33
  token: string;
642
34
  }): Promise<Pick<import("jose").JWTPayload, "iat" | "exp"> & {
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
13
24
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
26
  };
@@ -17,6 +28,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
28
  exports.initClient = void 0;
18
29
  var client_1 = __importDefault(require("@memberstack/client"));
19
30
  var cookies_1 = require("../utils/cookies");
20
- exports.initClient = function (props) {
21
- return client_1.default.init(__assign({ token: cookies_1.getMemberCookie() }, props));
31
+ var initClient = function (_a) {
32
+ var _b = _a.useCookie, useCookie = _b === void 0 ? true : _b, props = __rest(_a, ["useCookie"]);
33
+ return client_1.default.init(__assign(__assign(__assign({}, (props.token && { token: props.token })), (useCookie && { token: (0, cookies_1.getMemberCookie)() })), props));
22
34
  };
35
+ exports.initClient = initClient;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialize = exports.openModal = exports.load = exports.hideModal = void 0;
3
4
  var methods_1 = require("./methods");
4
5
  Object.defineProperty(exports, "hideModal", { enumerable: true, get: function () { return methods_1.hideModal; } });
5
6
  Object.defineProperty(exports, "load", { enumerable: true, get: function () { return methods_1.load; } });
@@ -3,7 +3,7 @@ export declare type OpenModalParams = {
3
3
  type: "LOGIN" | "SIGNUP" | "FORGOT_PASSWORD";
4
4
  params?: {
5
5
  planId?: string;
6
- planPaymentOptionId?: string;
6
+ priceId?: string;
7
7
  };
8
8
  options?: {
9
9
  onCompleted?: (x: any) => any;
@@ -13,5 +13,5 @@ export declare type OpenModalParams = {
13
13
  export declare const load: (props: {
14
14
  publicKey: string;
15
15
  }) => void;
16
- export declare const openModal: (props: OpenModalParams & DOMConfig) => void;
16
+ export declare const openModal: (props: OpenModalParams & DOMConfig) => Promise<void>;
17
17
  export declare const hideModal: () => void;
@@ -1,10 +1,48 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.hideModal = exports.openModal = exports.load = void 0;
4
40
  var window_1 = require("../../constants/window");
5
41
  var endpoint_1 = require("../../constants/endpoint");
6
42
  var cookies_1 = require("../../utils/cookies");
7
43
  var persistence_1 = require("../../auth/persistence");
44
+ var logger_1 = require("../../utils/logger");
45
+ var script_1 = require("./script");
8
46
  var isBrowser = typeof window !== "undefined";
9
47
  var isInitialized = function () {
10
48
  if (!isBrowser)
@@ -26,36 +64,50 @@ var hasIFrame = function () {
26
64
  }
27
65
  return true;
28
66
  };
29
- exports.load = function (props) {
67
+ var load = function (props) {
30
68
  var _a;
31
69
  if (isInitialized()) {
32
70
  (_a = window[window_1.Window.MSDOM]) === null || _a === void 0 ? void 0 : _a.load({ publicKey: props.publicKey });
33
71
  }
34
72
  };
35
- exports.openModal = function (props) {
73
+ exports.load = load;
74
+ var openModal = function (props) { return __awaiter(void 0, void 0, void 0, function () {
36
75
  var _a;
37
- if (hasIFrame()) {
38
- (_a = window[window_1.Window.MSDOM]) === null || _a === void 0 ? void 0 : _a.show(props.type, props.params);
39
- window.addEventListener("message", function (e) {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
41
- if (e.origin === endpoint_1.endpoints.parentOrigin) {
42
- if (e.data.type === "CLOSE") {
43
- return exports.hideModal();
76
+ return __generator(this, function (_b) {
77
+ switch (_b.label) {
78
+ case 0:
79
+ (0, logger_1.log)("call openModal()");
80
+ return [4 /*yield*/, script_1.hostedUIReady.isReady];
81
+ case 1:
82
+ _b.sent();
83
+ if (hasIFrame()) {
84
+ (_a = window[window_1.Window.MSDOM]) === null || _a === void 0 ? void 0 : _a.show(props.type, props.params);
85
+ window.addEventListener("message", function (e) {
86
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
87
+ if (e.origin === endpoint_1.endpoints.parentOrigin) {
88
+ if (e.data.type === "CLOSE") {
89
+ return (0, exports.hideModal)();
90
+ }
91
+ if ((_b = (_a = e.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.member) {
92
+ (0, persistence_1.setPersistedMember)((_c = e.data) === null || _c === void 0 ? void 0 : _c.data.member, props.persistence);
93
+ }
94
+ 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)) {
95
+ (0, cookies_1.setMemberCookie)(e.data.data.tokens.accessToken);
96
+ }
97
+ (_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);
98
+ }
99
+ });
44
100
  }
45
- if ((_b = (_a = e.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.member) {
46
- persistence_1.setPersistedMember((_c = e.data) === null || _c === void 0 ? void 0 : _c.data.member, props.persistence);
47
- }
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)) {
49
- cookies_1.setMemberCookie(e.data.data.tokens.accessToken);
50
- }
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);
52
- }
53
- });
54
- }
55
- };
56
- exports.hideModal = function () {
101
+ return [2 /*return*/];
102
+ }
103
+ });
104
+ }); };
105
+ exports.openModal = openModal;
106
+ var hideModal = function () {
57
107
  var _a;
108
+ (0, logger_1.log)("call hideModal()");
58
109
  if (hasIFrame()) {
59
110
  (_a = window[window_1.Window.MSDOM]) === null || _a === void 0 ? void 0 : _a.hide();
60
111
  }
61
112
  };
113
+ exports.hideModal = hideModal;
@@ -1,3 +1,11 @@
1
1
  export declare function initialize(props: {
2
2
  publicKey: string;
3
3
  }): Promise<any>;
4
+ export declare class HostedUI {
5
+ private __globalResolver;
6
+ private __isReady;
7
+ constructor();
8
+ get isReady(): Promise<void>;
9
+ resolve(): void;
10
+ }
11
+ export declare const hostedUIReady: HostedUI;
@@ -36,14 +36,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.initialize = void 0;
39
+ exports.hostedUIReady = exports.HostedUI = exports.initialize = void 0;
40
40
  var endpoint_1 = require("../../constants/endpoint");
41
41
  var window_1 = require("../../constants/window");
42
+ var logger_1 = require("../../utils/logger");
42
43
  var isBrowser = typeof window !== "undefined";
43
44
  var SCRIPT_URL = endpoint_1.endpoints.loaderScript;
44
45
  var SCRIPT_URL_REGEX = new RegExp(SCRIPT_URL);
45
46
  var getScript = function () {
46
- var existingScript = document.querySelector("script[src^=\"" + SCRIPT_URL + "\"]");
47
+ var existingScript = document.querySelector("script[src^=\"".concat(SCRIPT_URL, "\"]"));
47
48
  if (existingScript && SCRIPT_URL_REGEX.test(existingScript.src)) {
48
49
  return existingScript;
49
50
  }
@@ -55,26 +56,61 @@ var getScript = function () {
55
56
  throw new Error("Memberstack requires a <body> element.");
56
57
  }
57
58
  document.body.appendChild(script);
59
+ (0, logger_1.log)("Appending script to load parent hosted UI");
58
60
  return script;
59
61
  };
60
62
  function initialize(props) {
61
63
  return __awaiter(this, void 0, void 0, function () {
62
64
  var script;
65
+ var _this = this;
63
66
  return __generator(this, function (_a) {
64
67
  if (!isBrowser)
65
68
  return [2 /*return*/, null];
66
69
  script = getScript();
67
- script.addEventListener("load", function () {
68
- if (window[window_1.Window.MSDOM]) {
69
- window[window_1.Window.MSDOM].load({ publicKey: props.publicKey });
70
- console.info("\x1b[36m%s\x1b[0m", "Memberstack has been initialized");
71
- }
72
- else {
73
- console.warn("Could not initialize Memberstack.");
74
- }
75
- });
70
+ (0, logger_1.log)("Add script event listener for load");
71
+ script.addEventListener("load", function () { return __awaiter(_this, void 0, void 0, function () {
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0:
75
+ (0, logger_1.log)("Hosted UI parent script loaded");
76
+ if (!window[window_1.Window.MSDOM]) return [3 /*break*/, 2];
77
+ (0, logger_1.log)("Call MSDOM load function, pass public key");
78
+ return [4 /*yield*/, window[window_1.Window.MSDOM].load({ publicKey: props.publicKey })];
79
+ case 1:
80
+ _a.sent();
81
+ exports.hostedUIReady.resolve();
82
+ console.info("\x1b[36m%s\x1b[0m", "Memberstack has been initialized");
83
+ return [3 /*break*/, 3];
84
+ case 2:
85
+ console.warn("Could not initialize Memberstack.");
86
+ _a.label = 3;
87
+ case 3: return [2 /*return*/];
88
+ }
89
+ });
90
+ }); });
76
91
  return [2 /*return*/];
77
92
  });
78
93
  });
79
94
  }
80
95
  exports.initialize = initialize;
96
+ var HostedUI = /** @class */ (function () {
97
+ function HostedUI() {
98
+ var _this = this;
99
+ this.__isReady = new Promise(function (resolve) {
100
+ _this.__globalResolver = resolve;
101
+ });
102
+ }
103
+ Object.defineProperty(HostedUI.prototype, "isReady", {
104
+ get: function () {
105
+ return this.__isReady;
106
+ },
107
+ enumerable: false,
108
+ configurable: true
109
+ });
110
+ HostedUI.prototype.resolve = function () {
111
+ this.__globalResolver();
112
+ };
113
+ return HostedUI;
114
+ }());
115
+ exports.HostedUI = HostedUI;
116
+ exports.hostedUIReady = new HostedUI();
@@ -1,26 +1,18 @@
1
1
  import { Persistence } from "../auth/persistence";
2
- import * as DOM from "./dom/methods";
3
- import { initClient, ClientConfig } from "./client";
2
+ import { ClientConfig } from "./client";
4
3
  declare global {
5
4
  interface Window {
6
5
  __MSDOM: any;
6
+ __MSDOMREADY: any;
7
7
  APP_ID: string;
8
8
  }
9
9
  }
10
10
  export declare type DOMConfig = ClientConfig & {
11
11
  persistence?: Persistence;
12
12
  useCookie: boolean;
13
+ debug?: boolean;
13
14
  };
14
- declare const DOMMethods: ({ useCookie, persistence, ...props }: DOMConfig) => {
15
- load: () => void;
16
- hideModal: () => void;
17
- onAuthChange: (cb: any) => {
18
- unsubscribe: () => boolean;
19
- };
20
- openModal: (type: DOM.OpenModalParams["type"], params?: DOM.OpenModalParams["params"], options?: DOM.OpenModalParams["options"]) => void;
21
- };
22
- export declare const init: (props: DOMConfig) => ReturnType<typeof initClient> & ReturnType<typeof DOMMethods>;
15
+ export declare const init: (props: any) => any;
23
16
  export declare const Methods: {
24
- init: (props: DOMConfig) => ReturnType<typeof initClient> & ReturnType<typeof DOMMethods>;
17
+ init: (props: any) => any;
25
18
  };
26
- export {};
@@ -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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
29
  __setModuleDefault(result, mod);
30
30
  return result;
31
31
  };
@@ -51,6 +51,7 @@ var DOM = __importStar(require("./dom/methods"));
51
51
  var script_1 = require("./dom/script");
52
52
  var client_1 = require("./client");
53
53
  var interceptor_1 = require("../utils/interceptor");
54
+ var logger_1 = require("../utils/logger");
54
55
  var DOMMethods = function (_a) {
55
56
  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"]);
56
57
  return ({
@@ -63,13 +64,14 @@ var DOMMethods = function (_a) {
63
64
  var withScript = function (fn) {
64
65
  return function (props) {
65
66
  var config = __assign({ persistence: persistence_1.Persistence.LOCAL, useCookie: true }, props);
66
- script_1.initialize({ publicKey: props.publicKey });
67
+ (0, logger_1.log)("Calling Function that initializes hosted UI script");
68
+ (0, script_1.initialize)({ publicKey: props.publicKey });
67
69
  return fn(config);
68
70
  };
69
71
  };
70
- exports.init = withScript(function (props) {
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);
72
+ exports.init = (0, logger_1.withLogger)(withScript(function (props) {
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);
72
74
  var methods = DOMMethods(props);
73
75
  return Object.assign(client, methods);
74
- });
76
+ }));
75
77
  exports.Methods = { init: exports.init };
@@ -6,12 +6,14 @@ 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
- exports.setMemberCookie = function (token, expires) {
9
+ var 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.getMemberCookie = function () {
15
+ exports.setMemberCookie = setMemberCookie;
16
+ var getMemberCookie = function () {
16
17
  return js_cookie_1.default.get(cookies_1.MemberCookies.AUTH);
17
18
  };
19
+ exports.getMemberCookie = getMemberCookie;
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleMemberToken = void 0;
4
4
  var cookies_1 = require("./cookies");
5
5
  var persistence_1 = require("../auth/persistence");
6
- exports.handleMemberToken = function (_a) {
6
+ var handleMemberToken = function (_a) {
7
7
  var persistence = _a.persistence, token = _a.token;
8
8
  if (token === "null") {
9
- cookies_1.setMemberCookie("", -1);
10
- if (persistence_1.getPersistedMember(persistence)) {
11
- persistence_1.unsetPersistedMember(persistence);
9
+ (0, cookies_1.setMemberCookie)("", -1);
10
+ if ((0, persistence_1.getPersistedMember)(persistence)) {
11
+ (0, persistence_1.unsetPersistedMember)(persistence);
12
12
  }
13
13
  }
14
14
  else {
15
- cookies_1.setMemberCookie(token);
15
+ (0, cookies_1.setMemberCookie)(token);
16
16
  }
17
17
  };
18
+ exports.handleMemberToken = handleMemberToken;
@@ -0,0 +1,3 @@
1
+ export declare const initializeLogger: (debugFlag: boolean) => void;
2
+ export declare const log: (...msg: any[]) => void;
3
+ export declare const withLogger: (fn: any) => (props: any) => any;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
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));
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.withLogger = exports.log = exports.initializeLogger = void 0;
29
+ var debug;
30
+ var initializeLogger = function (debugFlag) {
31
+ debug = !!debugFlag;
32
+ };
33
+ exports.initializeLogger = initializeLogger;
34
+ var log = function () {
35
+ var msg = [];
36
+ for (var _i = 0; _i < arguments.length; _i++) {
37
+ msg[_i] = arguments[_i];
38
+ }
39
+ if (!debug)
40
+ return;
41
+ var timestamp = '[' + Date.now() + ']';
42
+ console.log.apply(console, __spreadArray(['\x1b[33m%s\x1b[0m', "@memberstack/dom ".concat(timestamp)], __read(msg), false));
43
+ };
44
+ exports.log = log;
45
+ var withLogger = function (fn) {
46
+ return function (props) {
47
+ (0, exports.initializeLogger)(props.debug);
48
+ return fn(props);
49
+ };
50
+ };
51
+ exports.withLogger = withLogger;
@@ -51,9 +51,14 @@ var __read = (this && this.__read) || function (o, n) {
51
51
  }
52
52
  return ar;
53
53
  };
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;
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
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));
57
62
  };
58
63
  Object.defineProperty(exports, "__esModule", { value: true });
59
64
  var persistence_1 = require("../auth/persistence");
@@ -63,15 +68,15 @@ var handleResponse = function (fn, props) {
63
68
  for (var _i = 0; _i < arguments.length; _i++) {
64
69
  args[_i] = arguments[_i];
65
70
  }
66
- var result = fn.apply(void 0, __spread(args));
71
+ var result = fn.apply(void 0, __spreadArray([], __read(args), false));
67
72
  if (result === null || result === void 0 ? void 0 : result.then) {
68
73
  return result.then(function (res) {
69
74
  var _a, _b, _c, _d;
70
75
  if ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.member) {
71
- persistence_1.setPersistedMember((_b = res.data) === null || _b === void 0 ? void 0 : _b.member, props.persistence);
76
+ (0, persistence_1.setPersistedMember)((_b = res.data) === null || _b === void 0 ? void 0 : _b.member, props.persistence);
72
77
  }
73
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_")) {
74
- persistence_1.setPersistedMember(res.data, props.persistence);
79
+ (0, persistence_1.setPersistedMember)(res.data, props.persistence);
75
80
  }
76
81
  return res;
77
82
  });
@@ -83,7 +88,7 @@ var handler = function (props) { return ({
83
88
  get: function (target, prop, receiver) {
84
89
  var _this = this;
85
90
  if (prop === "getCurrentMember") {
86
- var persistedMember_1 = persistence_1.getPersistedMember(props.persistence);
91
+ var persistedMember_1 = (0, persistence_1.getPersistedMember)(props.persistence);
87
92
  if (persistedMember_1) {
88
93
  return function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
89
94
  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.28",
3
+ "version": "1.0.0-beta.31",
4
4
  "main": "./lib/index.js",
5
5
  "files": [
6
6
  "lib/**/*"
@@ -8,9 +8,8 @@
8
8
  "author": "Lydia Hallie",
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
- "@memberstack/client": "^1.0.1-beta.10",
12
- "js-cookie": "^3.0.1",
13
- "node-request-interceptor": "^0.6.3"
11
+ "@memberstack/client": "^1.0.1-beta.12",
12
+ "js-cookie": "^3.0.1"
14
13
  },
15
14
  "scripts": {
16
15
  "prepublishOnly": "npx tsc",