@memberstack/dom 1.0.0-beta.15 → 1.0.0-beta.19

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