@nylas/react 1.1.0-canary.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -2
- package/dist/add-circle-icon_2.entry-7165bd0e.js +25 -0
- package/dist/add-circle-icon_2.entry-f1ddca18.cjs +1 -0
- package/dist/{archive-icon_7.entry-e2954750.js → archive-icon_7.entry-7411c224.js} +16 -16
- package/dist/archive-icon_7.entry-e3df60ed.cjs +1 -0
- package/dist/{arrow-icon.entry-548b027e.cjs → arrow-icon.entry-280e18b0.cjs} +1 -1
- package/dist/{arrow-icon.entry-03a85113.js → arrow-icon.entry-38949317.js} +4 -4
- package/dist/{bold-icon_3.entry-70ffa7f0.js → bold-icon_3.entry-5963945c.js} +4 -4
- package/dist/{bold-icon_3.entry-9a7b1869.cjs → bold-icon_3.entry-5dffbedd.cjs} +1 -1
- package/dist/button-component_2.entry-237733b4.js +26 -0
- package/dist/button-component_2.entry-b29d2873.cjs +1 -0
- package/dist/calendar-agenda-fill-icon_48.entry-9afba869.js +5105 -0
- package/dist/calendar-agenda-fill-icon_48.entry-d3830dbb.cjs +7 -0
- package/dist/{calendar-cancel-icon.entry-45388fdc.cjs → calendar-cancel-icon.entry-77ccf227.cjs} +1 -1
- package/dist/{calendar-cancel-icon.entry-6bbc119f.js → calendar-cancel-icon.entry-780723a6.js} +5 -5
- package/dist/{calendar-check-icon_2.entry-f633f7a6.js → calendar-check-icon_2.entry-2c89c230.js} +7 -7
- package/dist/{calendar-check-icon_2.entry-6628456c.cjs → calendar-check-icon_2.entry-b37ac7f0.cjs} +1 -1
- package/dist/{calendar-icon.entry-62b82c27.js → calendar-icon.entry-02dd3990.js} +4 -4
- package/dist/{calendar-icon.entry-379b1fa1.cjs → calendar-icon.entry-ffc93569.cjs} +1 -1
- package/dist/checkbox-component_2.entry-00b6a1e9.cjs +1 -0
- package/dist/checkbox-component_2.entry-ee9d0e6c.js +56 -0
- package/dist/chevron-icon_3.entry-468abc26.cjs +1 -0
- package/dist/chevron-icon_3.entry-f62e9ef1.js +129 -0
- package/dist/clock-icon_4.entry-766a1b23.js +45 -0
- package/dist/clock-icon_4.entry-7dc2cc4a.cjs +1 -0
- package/dist/{constants-f34b9c6e-95a17764.js → constants-50c3e067-8a40a5fe.js} +885 -751
- package/dist/{constants-f34b9c6e-e7137e51.cjs → constants-50c3e067-9f2a6372.cjs} +5 -5
- package/dist/copy-icon.entry-2a841508.js +15 -0
- package/dist/copy-icon.entry-e5251410.cjs +1 -0
- package/dist/delete-icon_2.entry-1a5c39dc.cjs +1 -0
- package/dist/delete-icon_2.entry-64555a2f.js +25 -0
- package/dist/{document-refresh-icon.entry-32c75418.js → document-refresh-icon.entry-4bf6398b.js} +4 -4
- package/dist/document-refresh-icon.entry-fdc7ddda.cjs +1 -0
- package/dist/elements/index.d.ts +47 -1
- package/dist/{elements-dc5b338e-62fe1cf3.js → elements-dc5b338e-2da1fe61.js} +1 -1
- package/dist/{elements-dc5b338e-1f23530f.cjs → elements-dc5b338e-c8016c3d.cjs} +1 -1
- package/dist/{focus-visible-e8093c16-f0f05815.cjs → focus-visible-e8093c16-0a38a184.cjs} +1 -1
- package/dist/{focus-visible-e8093c16-1f664070.js → focus-visible-e8093c16-9d0c98c0.js} +1 -1
- package/dist/{forward-icon_6.entry-7fab04d7.js → forward-icon_6.entry-390ef70a.js} +9 -9
- package/dist/{forward-icon_6.entry-ef5e2e0f.cjs → forward-icon_6.entry-7238ef38.cjs} +3 -3
- package/dist/{globe-icon.entry-398a9826.cjs → globe-icon.entry-81f42f89.cjs} +1 -1
- package/dist/{globe-icon.entry-b8e1efae.js → globe-icon.entry-8d106260.js} +5 -5
- package/dist/google-logo-icon_4.entry-aabd3886.js +680 -0
- package/dist/google-logo-icon_4.entry-fa2b8999.cjs +1 -0
- package/dist/index-53420959-5fc8ad2b.js +5 -0
- package/dist/index-53420959-fcf45780.cjs +1 -0
- package/dist/index-5ccfd9df.js +7859 -0
- package/dist/index-6d9eeb53-58c8980a.js +4971 -0
- package/dist/index-6d9eeb53-b2a6d09f.cjs +41 -0
- package/dist/index-eb33703c.cjs +42 -0
- package/dist/{index.es-df564f87-b773d34f.js → index.es-c9454237-00ccd1e6.js} +6 -8
- package/dist/{index.es-df564f87-e4a4092a.cjs → index.es-c9454237-b64161d1.cjs} +6 -6
- package/dist/{info-icon_2.entry-2eb70f49.cjs → info-icon_2.entry-b2e11336.cjs} +1 -1
- package/dist/{info-icon_2.entry-6bbfa6dc.js → info-icon_2.entry-bb8ed71c.js} +3 -3
- package/dist/input-component.entry-378b1ccc.cjs +1 -0
- package/dist/input-component.entry-cb86170f.js +65 -0
- package/dist/input-dropdown.entry-98954c93.cjs +1 -0
- package/dist/input-dropdown.entry-a76c339e.js +134 -0
- package/dist/{mailbox-store-69c5c5f6-631eddb5.cjs → mailbox-store-edc386fc-156b7236.cjs} +1 -1
- package/dist/{mailbox-store-69c5c5f6-8ab4670b.js → mailbox-store-edc386fc-8bc7558b.js} +2 -2
- package/dist/multi-select-dropdown.entry-40b855e1.cjs +1 -0
- package/dist/multi-select-dropdown.entry-6b686695.js +91 -0
- package/dist/nylas-booked-event-card_12.entry-9d693125.cjs +1 -0
- package/dist/nylas-booked-event-card_12.entry-e861bb16.js +1134 -0
- package/dist/nylas-form-card.entry-b158d789.js +57 -0
- package/dist/nylas-form-card.entry-ca4a8746.cjs +1 -0
- package/dist/{nylas-if-state.entry-f8abd025.js → nylas-if-state.entry-8e4d922c.js} +8 -8
- package/dist/{nylas-if-state.entry-276d61ad.cjs → nylas-if-state.entry-95fac42d.cjs} +1 -1
- package/dist/{nylas-list-folders.entry-78cc680e.js → nylas-list-folders.entry-83c39684.js} +8 -8
- package/dist/{nylas-list-folders.entry-afe02f0e.cjs → nylas-list-folders.entry-8a22e0c8.cjs} +1 -1
- package/dist/{nylas-list-threads.entry-6395c12f.cjs → nylas-list-threads.entry-54c582af.cjs} +1 -1
- package/dist/{nylas-list-threads.entry-217088de.js → nylas-list-threads.entry-7ea370e1.js} +4 -4
- package/dist/{nylas-login.entry-e4d57589.js → nylas-login.entry-9115fd81.js} +7 -7
- package/dist/{nylas-login.entry-ec81e21b.cjs → nylas-login.entry-fb627e40.cjs} +1 -1
- package/dist/{nylas-mailbox-pagination.entry-d4d929f1.cjs → nylas-mailbox-pagination.entry-04626d27.cjs} +1 -1
- package/dist/{nylas-mailbox-pagination.entry-069673aa.js → nylas-mailbox-pagination.entry-3ff02cf9.js} +2 -2
- package/dist/{nylas-mailbox-toolbar-button.entry-2b9e4431.cjs → nylas-mailbox-toolbar-button.entry-8d00c789.cjs} +1 -1
- package/dist/{nylas-mailbox-toolbar-button.entry-03c5f5c8.js → nylas-mailbox-toolbar-button.entry-f752e925.js} +4 -4
- package/dist/{nylas-mailbox.entry-7e6b4791.js → nylas-mailbox.entry-99c27b6c.js} +4 -4
- package/dist/{nylas-mailbox.entry-1342178d.cjs → nylas-mailbox.entry-b3974f4e.cjs} +1 -1
- package/dist/{nylas-provider.entry-0ae8e70a.cjs → nylas-provider.entry-a3ad02a5.cjs} +1 -1
- package/dist/{nylas-provider.entry-498a7be9.js → nylas-provider.entry-c206aa32.js} +39 -39
- package/dist/nylas-reminder-emails.entry-414ce6fe.js +129 -0
- package/dist/nylas-reminder-emails.entry-59c07bfe.cjs +4 -0
- package/dist/nylas-reminder-time_2.entry-197d83a0.js +105 -0
- package/dist/nylas-reminder-time_2.entry-d79dcd85.cjs +1 -0
- package/dist/nylas-scheduler-editor.entry-7f389982.js +1447 -0
- package/dist/nylas-scheduler-editor.entry-f1c6964a.cjs +2 -0
- package/dist/nylas-scheduling.entry-1a8bd6fc.cjs +1 -0
- package/dist/nylas-scheduling.entry-4fa5381d.js +345 -0
- package/dist/{nylas-threads-refresh.entry-fc2d8028.js → nylas-threads-refresh.entry-20602e7b.js} +4 -4
- package/dist/{nylas-threads-refresh.entry-d020c89e.cjs → nylas-threads-refresh.entry-56b53449.cjs} +1 -1
- package/dist/{nylas-threads-search.entry-f92f7e30.js → nylas-threads-search.entry-8872473c.js} +12 -12
- package/dist/{nylas-threads-search.entry-0abcbc10.cjs → nylas-threads-search.entry-8e0ec3ae.cjs} +1 -1
- package/dist/nylas-time-window-picker.entry-9ac542b7.js +316 -0
- package/dist/nylas-time-window-picker.entry-ca47f721.cjs +1 -0
- package/dist/{nylas-view-thread.entry-56080c89.cjs → nylas-view-thread.entry-1f758e43.cjs} +1 -1
- package/dist/{nylas-view-thread.entry-2f1474cf.js → nylas-view-thread.entry-dcd3d5be.js} +6 -6
- package/dist/person-icon.entry-63b28ace.cjs +1 -0
- package/dist/person-icon.entry-93130c05.js +15 -0
- package/dist/{play-icon_2.entry-24ffa01f.js → play-icon_2.entry-6a99c32d.js} +6 -6
- package/dist/play-icon_2.entry-b67fb649.cjs +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.js +136 -90
- package/dist/{refresh-icon.entry-8395104b.js → refresh-icon.entry-84783c91.js} +4 -4
- package/dist/{refresh-icon.entry-cf4416b8.cjs → refresh-icon.entry-b49792fc.cjs} +1 -1
- package/dist/{register-component-b9cfcbaf-d40e1f3c.cjs → register-component-887199a9-003f96c5.cjs} +1 -1
- package/dist/{register-component-b9cfcbaf-c0147194.js → register-component-887199a9-b41dfa7a.js} +1 -1
- package/dist/scheduler-config-store-2a3b403d-73610089.js +27 -0
- package/dist/scheduler-config-store-2a3b403d-a5e3433a.cjs +1 -0
- package/dist/scheduler-store-fe281404-bddb1b6a.js +469 -0
- package/dist/scheduler-store-fe281404-c3e477f6.cjs +1 -0
- package/dist/textarea-component.entry-28c4bc05.cjs +1 -0
- package/dist/textarea-component.entry-40e959e5.js +36 -0
- package/dist/time-period-selector.entry-af71523a.cjs +1 -0
- package/dist/time-period-selector.entry-da5d8652.js +93 -0
- package/dist/{translate-icon.entry-d847f706.js → translate-icon.entry-92b83635.js} +5 -5
- package/dist/{translate-icon.entry-66533238.cjs → translate-icon.entry-a2ed4f76.cjs} +1 -1
- package/dist/warning-icon.entry-19f721c3.js +15 -0
- package/dist/warning-icon.entry-3ab9a59e.cjs +1 -0
- package/package.json +3 -3
- package/dist/add-circle-icon_22.entry-080abc71.cjs +0 -1
- package/dist/add-circle-icon_22.entry-bda9be31.js +0 -1818
- package/dist/archive-icon_7.entry-ca20da59.cjs +0 -1
- package/dist/chevron-icon_3.entry-74425e1f.js +0 -117
- package/dist/chevron-icon_3.entry-7ff803ad.cjs +0 -1
- package/dist/close-icon.entry-18e140ed.cjs +0 -1
- package/dist/close-icon.entry-6a8ea4a7.js +0 -15
- package/dist/document-refresh-icon.entry-f15f795a.cjs +0 -1
- package/dist/google-logo-icon_4.entry-38d5c2f2.cjs +0 -1
- package/dist/google-logo-icon_4.entry-5eca9538.js +0 -381
- package/dist/index-93c50de4.cjs +0 -37
- package/dist/index-f93f6948.js +0 -4006
- package/dist/loading-icon.entry-b563b2e6.js +0 -15
- package/dist/loading-icon.entry-fb04b893.cjs +0 -1
- package/dist/nylas-additional-participants.entry-33a45477.cjs +0 -1
- package/dist/nylas-additional-participants.entry-4b214308.js +0 -81
- package/dist/nylas-booked-event-card_10.entry-3e225025.cjs +0 -1
- package/dist/nylas-booked-event-card_10.entry-e93bc290.js +0 -782
- package/dist/nylas-form-card.entry-0748fdd5.js +0 -54
- package/dist/nylas-form-card.entry-eb3607bc.cjs +0 -1
- package/dist/nylas-scheduler-editor.entry-4de2bb97.js +0 -2275
- package/dist/nylas-scheduler-editor.entry-72c91b7d.cjs +0 -7
- package/dist/nylas-scheduling.entry-1a004916.cjs +0 -1
- package/dist/nylas-scheduling.entry-4e18ab43.js +0 -235
- package/dist/people-icon.entry-431e5044.cjs +0 -1
- package/dist/people-icon.entry-b4778e15.js +0 -15
- package/dist/play-icon_2.entry-f97db395.cjs +0 -1
- package/dist/scheduler-config-store-07d98279-0610e42f.cjs +0 -1
- package/dist/scheduler-config-store-07d98279-3b70606c.js +0 -24
- package/dist/scheduler-store-24fd0e91-2dba20c2.cjs +0 -1
- package/dist/scheduler-store-24fd0e91-47098841.js +0 -302
- package/dist/time-period-selector.entry-1e849c2e.js +0 -76
- package/dist/time-period-selector.entry-d8f3462f.cjs +0 -1
- package/dist/warning-icon.entry-1f0f00ed.cjs +0 -1
- package/dist/warning-icon.entry-b5db0151.js +0 -15
|
@@ -0,0 +1,1447 @@
|
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var O = (r, t, n) => t in r ? P(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
|
|
3
|
+
var b = (r, t, n) => (O(r, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
+
import { i as commonjsGlobal, r as registerInstance, c as createEvent, d as debug, N as NylasIdentityRequestWrapper, h, H as Host, g as getElement, B as Buffer, F as Fragment, j as dataResponse } from "./index-5ccfd9df.js";
|
|
5
|
+
import { N as NylasBaseProvider, X as Xr } from "./index.es-c9454237-00ccd1e6.js";
|
|
6
|
+
import { C as CreateNylasSchedulerConfigStore } from "./scheduler-config-store-2a3b403d-73610089.js";
|
|
7
|
+
import { p as process } from "./index-53420959-5fc8ad2b.js";
|
|
8
|
+
import "react";
|
|
9
|
+
import "react-dom";
|
|
10
|
+
class NylasSchedulerConfigAPIConnector {
|
|
11
|
+
constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
|
|
12
|
+
this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
|
|
13
|
+
}
|
|
14
|
+
async currentUser() {
|
|
15
|
+
return this.nylasApiRequest ? this.nylasApiRequest.currentUser() : (console.warn("Nylas API Request is not initialized"), null);
|
|
16
|
+
}
|
|
17
|
+
async getCalendars() {
|
|
18
|
+
var s;
|
|
19
|
+
if (!this.nylasApiRequest)
|
|
20
|
+
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
21
|
+
message: "Error fetching calendars: Nylas API Request is not initialized"
|
|
22
|
+
});
|
|
23
|
+
const [t, n] = await this.nylasApiRequest.request({
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: "calendars"
|
|
26
|
+
});
|
|
27
|
+
return n ? dataResponse(null, {
|
|
28
|
+
message: "Error fetching calendars: " + n.message
|
|
29
|
+
}) : Xr(t) ? dataResponse(null, {
|
|
30
|
+
message: "Error fetching calendars: " + ((s = t.error) == null ? void 0 : s.message)
|
|
31
|
+
}) : (this.nylasSchedulerConfigStore.state.calendars = t.data, dataResponse(t.data));
|
|
32
|
+
}
|
|
33
|
+
async getConfigurationById(t, n = !1) {
|
|
34
|
+
var a;
|
|
35
|
+
if (!this.nylasApiRequest)
|
|
36
|
+
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
37
|
+
message: "Error fetching configuration: Nylas API Request is not initialized"
|
|
38
|
+
});
|
|
39
|
+
if (!n) {
|
|
40
|
+
const d = this.nylasSchedulerConfigStore.state.configurations.find((l) => l.id === t);
|
|
41
|
+
if (d)
|
|
42
|
+
return this.nylasSchedulerConfigStore.state.selectedConfiguration = d, dataResponse(d);
|
|
43
|
+
}
|
|
44
|
+
const [s, c] = await this.nylasApiRequest.request({
|
|
45
|
+
method: "GET",
|
|
46
|
+
path: `scheduling/configurations/${t}`
|
|
47
|
+
});
|
|
48
|
+
return c ? dataResponse(null, {
|
|
49
|
+
message: "Error fetching configuration: " + c.message
|
|
50
|
+
}) : Xr(s) ? dataResponse(null, {
|
|
51
|
+
message: "Error fetching configuration: " + ((a = s.error) == null ? void 0 : a.message)
|
|
52
|
+
}) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = s.data, this.nylasSchedulerConfigStore.state.configurations.find((d) => d.id === t) ? this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.map((d) => d.id === t ? s.data : d) : this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, s.data], dataResponse(s.data));
|
|
53
|
+
}
|
|
54
|
+
async getConfigurations(t) {
|
|
55
|
+
var a;
|
|
56
|
+
if (!this.nylasApiRequest)
|
|
57
|
+
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
58
|
+
message: "Error fetching configurations: Nylas API Request is not initialized"
|
|
59
|
+
});
|
|
60
|
+
const n = 50, [s, c] = await this.nylasApiRequest.request({
|
|
61
|
+
method: "GET",
|
|
62
|
+
path: `scheduling/configurations?limit=${n}${t ? `&page_token=${t}` : ""}`
|
|
63
|
+
});
|
|
64
|
+
return c ? dataResponse(null, {
|
|
65
|
+
message: "Error fetching configurations: " + c.message
|
|
66
|
+
}) : Xr(s) ? dataResponse(null, {
|
|
67
|
+
message: "Error fetching configurations: " + ((a = s.error) == null ? void 0 : a.message)
|
|
68
|
+
}) : (this.nylasSchedulerConfigStore.state.configurations = s.data, this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor = s.next_cursor || null, dataResponse(s.data));
|
|
69
|
+
}
|
|
70
|
+
async createConfiguration(t) {
|
|
71
|
+
var c;
|
|
72
|
+
if (!this.nylasApiRequest)
|
|
73
|
+
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
74
|
+
message: "Error creating configuration: Nylas API Request is not initialized"
|
|
75
|
+
});
|
|
76
|
+
const [n, s] = await this.nylasApiRequest.request({
|
|
77
|
+
method: "POST",
|
|
78
|
+
path: "scheduling/configurations",
|
|
79
|
+
body: t
|
|
80
|
+
});
|
|
81
|
+
return s ? dataResponse(null, {
|
|
82
|
+
message: "Error creating configuration: " + s.message
|
|
83
|
+
}) : Xr(n) ? dataResponse(null, {
|
|
84
|
+
message: "Error creating configuration: " + ((c = n.error) == null ? void 0 : c.message)
|
|
85
|
+
}) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
|
|
86
|
+
}
|
|
87
|
+
async updateConfiguration(t) {
|
|
88
|
+
var c;
|
|
89
|
+
if (!this.nylasApiRequest)
|
|
90
|
+
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
91
|
+
message: "Error updating configuration: Nylas API Request is not initialized"
|
|
92
|
+
});
|
|
93
|
+
const [n, s] = await this.nylasApiRequest.request({
|
|
94
|
+
method: "PUT",
|
|
95
|
+
path: `scheduling/configurations/${t.id}`,
|
|
96
|
+
body: t
|
|
97
|
+
});
|
|
98
|
+
return s ? dataResponse(null, {
|
|
99
|
+
message: "Error updating configuration: " + s.message
|
|
100
|
+
}) : Xr(n) ? dataResponse(null, {
|
|
101
|
+
message: "Error updating configuration: " + ((c = n.error) == null ? void 0 : c.message)
|
|
102
|
+
}) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations.find((a) => a.id === t.id) ? this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.map((a) => a.id === t.id ? n.data : a) : this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
|
|
103
|
+
}
|
|
104
|
+
async deleteConfiguration(t) {
|
|
105
|
+
var c, a;
|
|
106
|
+
if (!this.nylasApiRequest)
|
|
107
|
+
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
108
|
+
message: "Error deleting configuration: Nylas API Request is not initialized"
|
|
109
|
+
});
|
|
110
|
+
const [n, s] = await this.nylasApiRequest.request({
|
|
111
|
+
method: "DELETE",
|
|
112
|
+
path: `scheduling/configurations/${t}`
|
|
113
|
+
});
|
|
114
|
+
return s ? dataResponse(null, {
|
|
115
|
+
message: "Error deleting configuration: " + s.message
|
|
116
|
+
}) : Xr(n) ? dataResponse(null, {
|
|
117
|
+
message: "Error deleting configuration: " + ((c = n.error) == null ? void 0 : c.message)
|
|
118
|
+
}) : (this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.filter((d) => d.id !== t), ((a = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : a.id) === t && this.nylasSchedulerConfigStore.resetSelectedConfiguration(), dataResponse(n.data));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
class NylasSchedulerConfigConnector {
|
|
122
|
+
constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
|
|
123
|
+
this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
|
|
124
|
+
}
|
|
125
|
+
init() {
|
|
126
|
+
debug("NylasSchedulerConfigConnector init");
|
|
127
|
+
}
|
|
128
|
+
get schedulerConfigStore() {
|
|
129
|
+
return this.nylasSchedulerConfigStore;
|
|
130
|
+
}
|
|
131
|
+
get schedulerConfig() {
|
|
132
|
+
return this._schedulerConfigConnector ? this._schedulerConfigConnector : (this._schedulerConfigConnector = new NylasSchedulerConfigAPIConnector({
|
|
133
|
+
nylasApiRequest: this.nylasApiRequest,
|
|
134
|
+
nylasSchedulerConfigStore: this.nylasSchedulerConfigStore
|
|
135
|
+
}), this._schedulerConfigConnector);
|
|
136
|
+
}
|
|
137
|
+
resetStores() {
|
|
138
|
+
debug("NylasSchedulerConfigConnector resetStores"), this.nylasSchedulerConfigStore.reset();
|
|
139
|
+
}
|
|
140
|
+
async logout() {
|
|
141
|
+
debug("NylasSchedulerConfigConnector logout"), this.resetStores();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
class LocalStorage {
|
|
145
|
+
get(t) {
|
|
146
|
+
return new Promise((n) => {
|
|
147
|
+
const s = window.localStorage.getItem(t);
|
|
148
|
+
n(s ? JSON.parse(s) : null);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async remove(t) {
|
|
152
|
+
return window.localStorage.removeItem(t), new Promise((n) => {
|
|
153
|
+
n(null);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
set(t, n) {
|
|
157
|
+
return window.localStorage.setItem(t, JSON.stringify(n)), new Promise((s) => {
|
|
158
|
+
s(null);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const PKCE_KEY = "pkce", GRANT_KEY = "grant", USER_KEY = "user";
|
|
163
|
+
class Storage {
|
|
164
|
+
constructor(t) {
|
|
165
|
+
b(this, "Storage", new LocalStorage());
|
|
166
|
+
if (t) {
|
|
167
|
+
this.Storage = t;
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
setPKCE(t) {
|
|
172
|
+
const n = Buffer.from(t);
|
|
173
|
+
this.Storage.set(PKCE_KEY, n.toString("base64"));
|
|
174
|
+
}
|
|
175
|
+
async getPKCE() {
|
|
176
|
+
try {
|
|
177
|
+
const t = await this.Storage.get(PKCE_KEY);
|
|
178
|
+
if (t)
|
|
179
|
+
return Buffer.from(t, "base64").toString("utf8");
|
|
180
|
+
} catch {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
removePKCE() {
|
|
186
|
+
this.Storage.remove(PKCE_KEY);
|
|
187
|
+
}
|
|
188
|
+
setGrant(t, n = !1) {
|
|
189
|
+
const { grant_id: s } = t;
|
|
190
|
+
this.Storage.set(`${GRANT_KEY}${n ? "-" + s : ""}`, t);
|
|
191
|
+
}
|
|
192
|
+
removeGrant(t, n = !1) {
|
|
193
|
+
this.Storage.remove(`${GRANT_KEY}${n ? "-" + t : ""}`);
|
|
194
|
+
}
|
|
195
|
+
async getGrant(t, n = !1) {
|
|
196
|
+
const s = await this.Storage.get(`${GRANT_KEY}${n ? "-" + t : ""}`);
|
|
197
|
+
return s || null;
|
|
198
|
+
}
|
|
199
|
+
// setUserToken is used to store the IDToken in storage
|
|
200
|
+
async setUserToken(t) {
|
|
201
|
+
const n = await this.getUserTokens();
|
|
202
|
+
if (n)
|
|
203
|
+
if (n.find((c) => c.sub === t.sub)) {
|
|
204
|
+
const c = n.map((a) => (a.sub === t.sub && (a = t), a));
|
|
205
|
+
this.Storage.set(USER_KEY, c);
|
|
206
|
+
} else {
|
|
207
|
+
const c = [...n, t];
|
|
208
|
+
this.Storage.set(USER_KEY, c);
|
|
209
|
+
}
|
|
210
|
+
else
|
|
211
|
+
this.Storage.set(USER_KEY, [t]);
|
|
212
|
+
}
|
|
213
|
+
// getUserToken is used to retrieve a specific IDToken from storage
|
|
214
|
+
async getUserToken(t = "") {
|
|
215
|
+
const n = await this.Storage.get(USER_KEY);
|
|
216
|
+
return n ? t === "" ? n[0] : n.find((c) => c.sub === t) : null;
|
|
217
|
+
}
|
|
218
|
+
// getUserTokens is used to retrieve all IDTokens from storage
|
|
219
|
+
async getUserTokens() {
|
|
220
|
+
const t = await this.Storage.get(USER_KEY);
|
|
221
|
+
return t || null;
|
|
222
|
+
}
|
|
223
|
+
// removeUserTokens is used to remove all IDTokens from storage
|
|
224
|
+
removeUserTokens() {
|
|
225
|
+
this.Storage.remove(USER_KEY);
|
|
226
|
+
}
|
|
227
|
+
// removeUserToken is used to remove a specific IDToken from storage
|
|
228
|
+
async removeUserToken(t) {
|
|
229
|
+
const n = await this.getUserTokens(), s = n == null ? void 0 : n.filter((c) => c.sub !== t);
|
|
230
|
+
this.Storage.set(USER_KEY, s);
|
|
231
|
+
}
|
|
232
|
+
async clearSession() {
|
|
233
|
+
const t = await this.getUserTokens();
|
|
234
|
+
t == null || t.forEach((n) => {
|
|
235
|
+
this.removeGrant(n.sub);
|
|
236
|
+
}), this.removePKCE(), this.removeUserTokens();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
class IndexedDBStorage {
|
|
240
|
+
constructor() {
|
|
241
|
+
b(this, "databaseName", "identity-db");
|
|
242
|
+
b(this, "storeName", "identity");
|
|
243
|
+
}
|
|
244
|
+
get(t) {
|
|
245
|
+
const n = this;
|
|
246
|
+
return new Promise((s, c) => {
|
|
247
|
+
n.openDatabase().then(function(a) {
|
|
248
|
+
const d = a.transaction(n.storeName, "readwrite"), u = d.objectStore(n.storeName).get(t);
|
|
249
|
+
u.onsuccess = () => {
|
|
250
|
+
s(u.result);
|
|
251
|
+
}, u.onerror = () => {
|
|
252
|
+
c(u.error);
|
|
253
|
+
}, d.oncomplete = () => {
|
|
254
|
+
a.close();
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
async remove(t) {
|
|
260
|
+
const n = this;
|
|
261
|
+
return new Promise((s, c) => {
|
|
262
|
+
const a = indexedDB.open(this.databaseName);
|
|
263
|
+
a.onupgradeneeded = function(d) {
|
|
264
|
+
d.target.result.createObjectStore(n.storeName);
|
|
265
|
+
}, a.onerror = () => {
|
|
266
|
+
c(a.error);
|
|
267
|
+
}, a.onsuccess = (d) => {
|
|
268
|
+
const l = d.target.result, u = l.transaction(this.storeName, "readwrite"), y = u.objectStore(this.storeName).delete(t);
|
|
269
|
+
y.onsuccess = () => {
|
|
270
|
+
s(null);
|
|
271
|
+
}, y.onerror = () => {
|
|
272
|
+
c(y.error);
|
|
273
|
+
}, u.oncomplete = () => {
|
|
274
|
+
l.close();
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
set(t, n) {
|
|
280
|
+
return new Promise((s, c) => {
|
|
281
|
+
const a = indexedDB.open(this.databaseName);
|
|
282
|
+
a.onerror = () => {
|
|
283
|
+
c(a.error);
|
|
284
|
+
}, a.onupgradeneeded = (d) => {
|
|
285
|
+
d.target.result.createObjectStore(this.storeName);
|
|
286
|
+
}, a.onsuccess = (d) => {
|
|
287
|
+
const l = d.target.result, u = l.transaction(this.storeName, "readwrite"), y = u.objectStore(this.storeName).put(n, t);
|
|
288
|
+
y.onsuccess = () => {
|
|
289
|
+
s(n);
|
|
290
|
+
}, y.onerror = () => {
|
|
291
|
+
c(y.error);
|
|
292
|
+
}, u.oncomplete = () => {
|
|
293
|
+
l.close();
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
openDatabase() {
|
|
299
|
+
const t = this;
|
|
300
|
+
return new Promise(function(n, s) {
|
|
301
|
+
const c = indexedDB.open(t.databaseName, 2);
|
|
302
|
+
c.onupgradeneeded = function(a) {
|
|
303
|
+
a.target.result.createObjectStore(t.storeName);
|
|
304
|
+
}, c.onsuccess = function(a) {
|
|
305
|
+
n(a.target.result);
|
|
306
|
+
}, c.onerror = function(a) {
|
|
307
|
+
s(a.error);
|
|
308
|
+
};
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
var sha256 = { exports: {} };
|
|
313
|
+
(function(module) {
|
|
314
|
+
(function() {
|
|
315
|
+
var ERROR = "input is invalid type", WINDOW = typeof window == "object", root = WINDOW ? window : {};
|
|
316
|
+
root.JS_SHA256_NO_WINDOW && (WINDOW = !1);
|
|
317
|
+
var WEB_WORKER = !WINDOW && typeof self == "object", NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
|
|
318
|
+
NODE_JS ? root = commonjsGlobal : WEB_WORKER && (root = self);
|
|
319
|
+
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && !0 && module.exports, ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", HEX_CHARS = "0123456789abcdef".split(""), EXTRA = [-2147483648, 8388608, 32768, 128], SHIFT = [24, 16, 8, 0], K = [
|
|
320
|
+
1116352408,
|
|
321
|
+
1899447441,
|
|
322
|
+
3049323471,
|
|
323
|
+
3921009573,
|
|
324
|
+
961987163,
|
|
325
|
+
1508970993,
|
|
326
|
+
2453635748,
|
|
327
|
+
2870763221,
|
|
328
|
+
3624381080,
|
|
329
|
+
310598401,
|
|
330
|
+
607225278,
|
|
331
|
+
1426881987,
|
|
332
|
+
1925078388,
|
|
333
|
+
2162078206,
|
|
334
|
+
2614888103,
|
|
335
|
+
3248222580,
|
|
336
|
+
3835390401,
|
|
337
|
+
4022224774,
|
|
338
|
+
264347078,
|
|
339
|
+
604807628,
|
|
340
|
+
770255983,
|
|
341
|
+
1249150122,
|
|
342
|
+
1555081692,
|
|
343
|
+
1996064986,
|
|
344
|
+
2554220882,
|
|
345
|
+
2821834349,
|
|
346
|
+
2952996808,
|
|
347
|
+
3210313671,
|
|
348
|
+
3336571891,
|
|
349
|
+
3584528711,
|
|
350
|
+
113926993,
|
|
351
|
+
338241895,
|
|
352
|
+
666307205,
|
|
353
|
+
773529912,
|
|
354
|
+
1294757372,
|
|
355
|
+
1396182291,
|
|
356
|
+
1695183700,
|
|
357
|
+
1986661051,
|
|
358
|
+
2177026350,
|
|
359
|
+
2456956037,
|
|
360
|
+
2730485921,
|
|
361
|
+
2820302411,
|
|
362
|
+
3259730800,
|
|
363
|
+
3345764771,
|
|
364
|
+
3516065817,
|
|
365
|
+
3600352804,
|
|
366
|
+
4094571909,
|
|
367
|
+
275423344,
|
|
368
|
+
430227734,
|
|
369
|
+
506948616,
|
|
370
|
+
659060556,
|
|
371
|
+
883997877,
|
|
372
|
+
958139571,
|
|
373
|
+
1322822218,
|
|
374
|
+
1537002063,
|
|
375
|
+
1747873779,
|
|
376
|
+
1955562222,
|
|
377
|
+
2024104815,
|
|
378
|
+
2227730452,
|
|
379
|
+
2361852424,
|
|
380
|
+
2428436474,
|
|
381
|
+
2756734187,
|
|
382
|
+
3204031479,
|
|
383
|
+
3329325298
|
|
384
|
+
], OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"], blocks = [];
|
|
385
|
+
(root.JS_SHA256_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(r) {
|
|
386
|
+
return Object.prototype.toString.call(r) === "[object Array]";
|
|
387
|
+
}), ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(r) {
|
|
388
|
+
return typeof r == "object" && r.buffer && r.buffer.constructor === ArrayBuffer;
|
|
389
|
+
});
|
|
390
|
+
var createOutputMethod = function(r, t) {
|
|
391
|
+
return function(n) {
|
|
392
|
+
return new Sha256(t, !0).update(n)[r]();
|
|
393
|
+
};
|
|
394
|
+
}, createMethod = function(r) {
|
|
395
|
+
var t = createOutputMethod("hex", r);
|
|
396
|
+
NODE_JS && (t = nodeWrap(t, r)), t.create = function() {
|
|
397
|
+
return new Sha256(r);
|
|
398
|
+
}, t.update = function(c) {
|
|
399
|
+
return t.create().update(c);
|
|
400
|
+
};
|
|
401
|
+
for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
|
|
402
|
+
var s = OUTPUT_TYPES[n];
|
|
403
|
+
t[s] = createOutputMethod(s, r);
|
|
404
|
+
}
|
|
405
|
+
return t;
|
|
406
|
+
}, nodeWrap = function(method, is224) {
|
|
407
|
+
var crypto = eval("require('crypto')"), Buffer = eval("require('buffer').Buffer"), algorithm = is224 ? "sha224" : "sha256", nodeMethod = function(r) {
|
|
408
|
+
if (typeof r == "string")
|
|
409
|
+
return crypto.createHash(algorithm).update(r, "utf8").digest("hex");
|
|
410
|
+
if (r == null)
|
|
411
|
+
throw new Error(ERROR);
|
|
412
|
+
return r.constructor === ArrayBuffer && (r = new Uint8Array(r)), Array.isArray(r) || ArrayBuffer.isView(r) || r.constructor === Buffer ? crypto.createHash(algorithm).update(new Buffer(r)).digest("hex") : method(r);
|
|
413
|
+
};
|
|
414
|
+
return nodeMethod;
|
|
415
|
+
}, createHmacOutputMethod = function(r, t) {
|
|
416
|
+
return function(n, s) {
|
|
417
|
+
return new HmacSha256(n, t, !0).update(s)[r]();
|
|
418
|
+
};
|
|
419
|
+
}, createHmacMethod = function(r) {
|
|
420
|
+
var t = createHmacOutputMethod("hex", r);
|
|
421
|
+
t.create = function(c) {
|
|
422
|
+
return new HmacSha256(c, r);
|
|
423
|
+
}, t.update = function(c, a) {
|
|
424
|
+
return t.create(c).update(a);
|
|
425
|
+
};
|
|
426
|
+
for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
|
|
427
|
+
var s = OUTPUT_TYPES[n];
|
|
428
|
+
t[s] = createHmacOutputMethod(s, r);
|
|
429
|
+
}
|
|
430
|
+
return t;
|
|
431
|
+
};
|
|
432
|
+
function Sha256(r, t) {
|
|
433
|
+
t ? (blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0, this.blocks = blocks) : this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], r ? (this.h0 = 3238371032, this.h1 = 914150663, this.h2 = 812702999, this.h3 = 4144912697, this.h4 = 4290775857, this.h5 = 1750603025, this.h6 = 1694076839, this.h7 = 3204075428) : (this.h0 = 1779033703, this.h1 = 3144134277, this.h2 = 1013904242, this.h3 = 2773480762, this.h4 = 1359893119, this.h5 = 2600822924, this.h6 = 528734635, this.h7 = 1541459225), this.block = this.start = this.bytes = this.hBytes = 0, this.finalized = this.hashed = !1, this.first = !0, this.is224 = r;
|
|
434
|
+
}
|
|
435
|
+
Sha256.prototype.update = function(r) {
|
|
436
|
+
if (!this.finalized) {
|
|
437
|
+
var t, n = typeof r;
|
|
438
|
+
if (n !== "string") {
|
|
439
|
+
if (n === "object") {
|
|
440
|
+
if (r === null)
|
|
441
|
+
throw new Error(ERROR);
|
|
442
|
+
if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
|
|
443
|
+
r = new Uint8Array(r);
|
|
444
|
+
else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
|
|
445
|
+
throw new Error(ERROR);
|
|
446
|
+
} else
|
|
447
|
+
throw new Error(ERROR);
|
|
448
|
+
t = !0;
|
|
449
|
+
}
|
|
450
|
+
for (var s, c = 0, a, d = r.length, l = this.blocks; c < d; ) {
|
|
451
|
+
if (this.hashed && (this.hashed = !1, l[0] = this.block, l[16] = l[1] = l[2] = l[3] = l[4] = l[5] = l[6] = l[7] = l[8] = l[9] = l[10] = l[11] = l[12] = l[13] = l[14] = l[15] = 0), t)
|
|
452
|
+
for (a = this.start; c < d && a < 64; ++c)
|
|
453
|
+
l[a >> 2] |= r[c] << SHIFT[a++ & 3];
|
|
454
|
+
else
|
|
455
|
+
for (a = this.start; c < d && a < 64; ++c)
|
|
456
|
+
s = r.charCodeAt(c), s < 128 ? l[a >> 2] |= s << SHIFT[a++ & 3] : s < 2048 ? (l[a >> 2] |= (192 | s >> 6) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s & 63) << SHIFT[a++ & 3]) : s < 55296 || s >= 57344 ? (l[a >> 2] |= (224 | s >> 12) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s >> 6 & 63) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s & 63) << SHIFT[a++ & 3]) : (s = 65536 + ((s & 1023) << 10 | r.charCodeAt(++c) & 1023), l[a >> 2] |= (240 | s >> 18) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s >> 12 & 63) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s >> 6 & 63) << SHIFT[a++ & 3], l[a >> 2] |= (128 | s & 63) << SHIFT[a++ & 3]);
|
|
457
|
+
this.lastByteIndex = a, this.bytes += a - this.start, a >= 64 ? (this.block = l[16], this.start = a - 64, this.hash(), this.hashed = !0) : this.start = a;
|
|
458
|
+
}
|
|
459
|
+
return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0, this.bytes = this.bytes % 4294967296), this;
|
|
460
|
+
}
|
|
461
|
+
}, Sha256.prototype.finalize = function() {
|
|
462
|
+
if (!this.finalized) {
|
|
463
|
+
this.finalized = !0;
|
|
464
|
+
var r = this.blocks, t = this.lastByteIndex;
|
|
465
|
+
r[16] = this.block, r[t >> 2] |= EXTRA[t & 3], this.block = r[16], t >= 56 && (this.hashed || this.hash(), r[0] = this.block, r[16] = r[1] = r[2] = r[3] = r[4] = r[5] = r[6] = r[7] = r[8] = r[9] = r[10] = r[11] = r[12] = r[13] = r[14] = r[15] = 0), r[14] = this.hBytes << 3 | this.bytes >>> 29, r[15] = this.bytes << 3, this.hash();
|
|
466
|
+
}
|
|
467
|
+
}, Sha256.prototype.hash = function() {
|
|
468
|
+
var r = this.h0, t = this.h1, n = this.h2, s = this.h3, c = this.h4, a = this.h5, d = this.h6, l = this.h7, u = this.blocks, f, y, g, w, p, m, S, x, R, _, A;
|
|
469
|
+
for (f = 16; f < 64; ++f)
|
|
470
|
+
p = u[f - 15], y = (p >>> 7 | p << 25) ^ (p >>> 18 | p << 14) ^ p >>> 3, p = u[f - 2], g = (p >>> 17 | p << 15) ^ (p >>> 19 | p << 13) ^ p >>> 10, u[f] = u[f - 16] + y + u[f - 7] + g << 0;
|
|
471
|
+
for (A = t & n, f = 0; f < 64; f += 4)
|
|
472
|
+
this.first ? (this.is224 ? (x = 300032, p = u[0] - 1413257819, l = p - 150054599 << 0, s = p + 24177077 << 0) : (x = 704751109, p = u[0] - 210244248, l = p - 1521486534 << 0, s = p + 143694565 << 0), this.first = !1) : (y = (r >>> 2 | r << 30) ^ (r >>> 13 | r << 19) ^ (r >>> 22 | r << 10), g = (c >>> 6 | c << 26) ^ (c >>> 11 | c << 21) ^ (c >>> 25 | c << 7), x = r & t, w = x ^ r & n ^ A, S = c & a ^ ~c & d, p = l + g + S + K[f] + u[f], m = y + w, l = s + p << 0, s = p + m << 0), y = (s >>> 2 | s << 30) ^ (s >>> 13 | s << 19) ^ (s >>> 22 | s << 10), g = (l >>> 6 | l << 26) ^ (l >>> 11 | l << 21) ^ (l >>> 25 | l << 7), R = s & r, w = R ^ s & t ^ x, S = l & c ^ ~l & a, p = d + g + S + K[f + 1] + u[f + 1], m = y + w, d = n + p << 0, n = p + m << 0, y = (n >>> 2 | n << 30) ^ (n >>> 13 | n << 19) ^ (n >>> 22 | n << 10), g = (d >>> 6 | d << 26) ^ (d >>> 11 | d << 21) ^ (d >>> 25 | d << 7), _ = n & s, w = _ ^ n & r ^ R, S = d & l ^ ~d & c, p = a + g + S + K[f + 2] + u[f + 2], m = y + w, a = t + p << 0, t = p + m << 0, y = (t >>> 2 | t << 30) ^ (t >>> 13 | t << 19) ^ (t >>> 22 | t << 10), g = (a >>> 6 | a << 26) ^ (a >>> 11 | a << 21) ^ (a >>> 25 | a << 7), A = t & n, w = A ^ t & s ^ _, S = a & d ^ ~a & l, p = c + g + S + K[f + 3] + u[f + 3], m = y + w, c = r + p << 0, r = p + m << 0;
|
|
473
|
+
this.h0 = this.h0 + r << 0, this.h1 = this.h1 + t << 0, this.h2 = this.h2 + n << 0, this.h3 = this.h3 + s << 0, this.h4 = this.h4 + c << 0, this.h5 = this.h5 + a << 0, this.h6 = this.h6 + d << 0, this.h7 = this.h7 + l << 0;
|
|
474
|
+
}, Sha256.prototype.hex = function() {
|
|
475
|
+
this.finalize();
|
|
476
|
+
var r = this.h0, t = this.h1, n = this.h2, s = this.h3, c = this.h4, a = this.h5, d = this.h6, l = this.h7, u = HEX_CHARS[r >> 28 & 15] + HEX_CHARS[r >> 24 & 15] + HEX_CHARS[r >> 20 & 15] + HEX_CHARS[r >> 16 & 15] + HEX_CHARS[r >> 12 & 15] + HEX_CHARS[r >> 8 & 15] + HEX_CHARS[r >> 4 & 15] + HEX_CHARS[r & 15] + HEX_CHARS[t >> 28 & 15] + HEX_CHARS[t >> 24 & 15] + HEX_CHARS[t >> 20 & 15] + HEX_CHARS[t >> 16 & 15] + HEX_CHARS[t >> 12 & 15] + HEX_CHARS[t >> 8 & 15] + HEX_CHARS[t >> 4 & 15] + HEX_CHARS[t & 15] + HEX_CHARS[n >> 28 & 15] + HEX_CHARS[n >> 24 & 15] + HEX_CHARS[n >> 20 & 15] + HEX_CHARS[n >> 16 & 15] + HEX_CHARS[n >> 12 & 15] + HEX_CHARS[n >> 8 & 15] + HEX_CHARS[n >> 4 & 15] + HEX_CHARS[n & 15] + HEX_CHARS[s >> 28 & 15] + HEX_CHARS[s >> 24 & 15] + HEX_CHARS[s >> 20 & 15] + HEX_CHARS[s >> 16 & 15] + HEX_CHARS[s >> 12 & 15] + HEX_CHARS[s >> 8 & 15] + HEX_CHARS[s >> 4 & 15] + HEX_CHARS[s & 15] + HEX_CHARS[c >> 28 & 15] + HEX_CHARS[c >> 24 & 15] + HEX_CHARS[c >> 20 & 15] + HEX_CHARS[c >> 16 & 15] + HEX_CHARS[c >> 12 & 15] + HEX_CHARS[c >> 8 & 15] + HEX_CHARS[c >> 4 & 15] + HEX_CHARS[c & 15] + HEX_CHARS[a >> 28 & 15] + HEX_CHARS[a >> 24 & 15] + HEX_CHARS[a >> 20 & 15] + HEX_CHARS[a >> 16 & 15] + HEX_CHARS[a >> 12 & 15] + HEX_CHARS[a >> 8 & 15] + HEX_CHARS[a >> 4 & 15] + HEX_CHARS[a & 15] + HEX_CHARS[d >> 28 & 15] + HEX_CHARS[d >> 24 & 15] + HEX_CHARS[d >> 20 & 15] + HEX_CHARS[d >> 16 & 15] + HEX_CHARS[d >> 12 & 15] + HEX_CHARS[d >> 8 & 15] + HEX_CHARS[d >> 4 & 15] + HEX_CHARS[d & 15];
|
|
477
|
+
return this.is224 || (u += HEX_CHARS[l >> 28 & 15] + HEX_CHARS[l >> 24 & 15] + HEX_CHARS[l >> 20 & 15] + HEX_CHARS[l >> 16 & 15] + HEX_CHARS[l >> 12 & 15] + HEX_CHARS[l >> 8 & 15] + HEX_CHARS[l >> 4 & 15] + HEX_CHARS[l & 15]), u;
|
|
478
|
+
}, Sha256.prototype.toString = Sha256.prototype.hex, Sha256.prototype.digest = function() {
|
|
479
|
+
this.finalize();
|
|
480
|
+
var r = this.h0, t = this.h1, n = this.h2, s = this.h3, c = this.h4, a = this.h5, d = this.h6, l = this.h7, u = [
|
|
481
|
+
r >> 24 & 255,
|
|
482
|
+
r >> 16 & 255,
|
|
483
|
+
r >> 8 & 255,
|
|
484
|
+
r & 255,
|
|
485
|
+
t >> 24 & 255,
|
|
486
|
+
t >> 16 & 255,
|
|
487
|
+
t >> 8 & 255,
|
|
488
|
+
t & 255,
|
|
489
|
+
n >> 24 & 255,
|
|
490
|
+
n >> 16 & 255,
|
|
491
|
+
n >> 8 & 255,
|
|
492
|
+
n & 255,
|
|
493
|
+
s >> 24 & 255,
|
|
494
|
+
s >> 16 & 255,
|
|
495
|
+
s >> 8 & 255,
|
|
496
|
+
s & 255,
|
|
497
|
+
c >> 24 & 255,
|
|
498
|
+
c >> 16 & 255,
|
|
499
|
+
c >> 8 & 255,
|
|
500
|
+
c & 255,
|
|
501
|
+
a >> 24 & 255,
|
|
502
|
+
a >> 16 & 255,
|
|
503
|
+
a >> 8 & 255,
|
|
504
|
+
a & 255,
|
|
505
|
+
d >> 24 & 255,
|
|
506
|
+
d >> 16 & 255,
|
|
507
|
+
d >> 8 & 255,
|
|
508
|
+
d & 255
|
|
509
|
+
];
|
|
510
|
+
return this.is224 || u.push(l >> 24 & 255, l >> 16 & 255, l >> 8 & 255, l & 255), u;
|
|
511
|
+
}, Sha256.prototype.array = Sha256.prototype.digest, Sha256.prototype.arrayBuffer = function() {
|
|
512
|
+
this.finalize();
|
|
513
|
+
var r = new ArrayBuffer(this.is224 ? 28 : 32), t = new DataView(r);
|
|
514
|
+
return t.setUint32(0, this.h0), t.setUint32(4, this.h1), t.setUint32(8, this.h2), t.setUint32(12, this.h3), t.setUint32(16, this.h4), t.setUint32(20, this.h5), t.setUint32(24, this.h6), this.is224 || t.setUint32(28, this.h7), r;
|
|
515
|
+
};
|
|
516
|
+
function HmacSha256(r, t, n) {
|
|
517
|
+
var s, c = typeof r;
|
|
518
|
+
if (c === "string") {
|
|
519
|
+
var a = [], d = r.length, l = 0, u;
|
|
520
|
+
for (s = 0; s < d; ++s)
|
|
521
|
+
u = r.charCodeAt(s), u < 128 ? a[l++] = u : u < 2048 ? (a[l++] = 192 | u >> 6, a[l++] = 128 | u & 63) : u < 55296 || u >= 57344 ? (a[l++] = 224 | u >> 12, a[l++] = 128 | u >> 6 & 63, a[l++] = 128 | u & 63) : (u = 65536 + ((u & 1023) << 10 | r.charCodeAt(++s) & 1023), a[l++] = 240 | u >> 18, a[l++] = 128 | u >> 12 & 63, a[l++] = 128 | u >> 6 & 63, a[l++] = 128 | u & 63);
|
|
522
|
+
r = a;
|
|
523
|
+
} else if (c === "object") {
|
|
524
|
+
if (r === null)
|
|
525
|
+
throw new Error(ERROR);
|
|
526
|
+
if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
|
|
527
|
+
r = new Uint8Array(r);
|
|
528
|
+
else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
|
|
529
|
+
throw new Error(ERROR);
|
|
530
|
+
} else
|
|
531
|
+
throw new Error(ERROR);
|
|
532
|
+
r.length > 64 && (r = new Sha256(t, !0).update(r).array());
|
|
533
|
+
var f = [], y = [];
|
|
534
|
+
for (s = 0; s < 64; ++s) {
|
|
535
|
+
var g = r[s] || 0;
|
|
536
|
+
f[s] = 92 ^ g, y[s] = 54 ^ g;
|
|
537
|
+
}
|
|
538
|
+
Sha256.call(this, t, n), this.update(y), this.oKeyPad = f, this.inner = !0, this.sharedMemory = n;
|
|
539
|
+
}
|
|
540
|
+
HmacSha256.prototype = new Sha256(), HmacSha256.prototype.finalize = function() {
|
|
541
|
+
if (Sha256.prototype.finalize.call(this), this.inner) {
|
|
542
|
+
this.inner = !1;
|
|
543
|
+
var r = this.array();
|
|
544
|
+
Sha256.call(this, this.is224, this.sharedMemory), this.update(this.oKeyPad), this.update(r), Sha256.prototype.finalize.call(this);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
var exports = createMethod();
|
|
548
|
+
exports.sha256 = exports, exports.sha224 = createMethod(!0), exports.sha256.hmac = createHmacMethod(), exports.sha224.hmac = createHmacMethod(!0), COMMON_JS ? module.exports = exports : (root.sha256 = exports.sha256, root.sha224 = exports.sha224);
|
|
549
|
+
})();
|
|
550
|
+
})(sha256);
|
|
551
|
+
var getRandomValues, rnds8 = new Uint8Array(16);
|
|
552
|
+
function rng() {
|
|
553
|
+
if (!getRandomValues && (getRandomValues = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), !getRandomValues))
|
|
554
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
555
|
+
return getRandomValues(rnds8);
|
|
556
|
+
}
|
|
557
|
+
const REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
558
|
+
function validate(r) {
|
|
559
|
+
return typeof r == "string" && REGEX.test(r);
|
|
560
|
+
}
|
|
561
|
+
var byteToHex = [];
|
|
562
|
+
for (var i = 0; i < 256; ++i)
|
|
563
|
+
byteToHex.push((i + 256).toString(16).substr(1));
|
|
564
|
+
function stringify(r) {
|
|
565
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, n = (byteToHex[r[t + 0]] + byteToHex[r[t + 1]] + byteToHex[r[t + 2]] + byteToHex[r[t + 3]] + "-" + byteToHex[r[t + 4]] + byteToHex[r[t + 5]] + "-" + byteToHex[r[t + 6]] + byteToHex[r[t + 7]] + "-" + byteToHex[r[t + 8]] + byteToHex[r[t + 9]] + "-" + byteToHex[r[t + 10]] + byteToHex[r[t + 11]] + byteToHex[r[t + 12]] + byteToHex[r[t + 13]] + byteToHex[r[t + 14]] + byteToHex[r[t + 15]]).toLowerCase();
|
|
566
|
+
if (!validate(n))
|
|
567
|
+
throw TypeError("Stringified UUID is invalid");
|
|
568
|
+
return n;
|
|
569
|
+
}
|
|
570
|
+
function v4(r, t, n) {
|
|
571
|
+
r = r || {};
|
|
572
|
+
var s = r.random || (r.rng || rng)();
|
|
573
|
+
if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, t) {
|
|
574
|
+
n = n || 0;
|
|
575
|
+
for (var c = 0; c < 16; ++c)
|
|
576
|
+
t[n + c] = s[c];
|
|
577
|
+
return t;
|
|
578
|
+
}
|
|
579
|
+
return stringify(s);
|
|
580
|
+
}
|
|
581
|
+
async function getBytes(r, t) {
|
|
582
|
+
const n = r.getReader();
|
|
583
|
+
let s;
|
|
584
|
+
for (; !(s = await n.read()).done; )
|
|
585
|
+
t(s.value);
|
|
586
|
+
}
|
|
587
|
+
function getLines(r) {
|
|
588
|
+
let t, n, s, c = !1;
|
|
589
|
+
return function(d) {
|
|
590
|
+
t === void 0 ? (t = d, n = 0, s = -1) : t = concat(t, d);
|
|
591
|
+
const l = t.length;
|
|
592
|
+
let u = 0;
|
|
593
|
+
for (; n < l; ) {
|
|
594
|
+
c && (t[n] === 10 && (u = ++n), c = !1);
|
|
595
|
+
let f = -1;
|
|
596
|
+
for (; n < l && f === -1; ++n)
|
|
597
|
+
switch (t[n]) {
|
|
598
|
+
case 58:
|
|
599
|
+
s === -1 && (s = n - u);
|
|
600
|
+
break;
|
|
601
|
+
case 13:
|
|
602
|
+
c = !0;
|
|
603
|
+
case 10:
|
|
604
|
+
f = n;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
if (f === -1)
|
|
608
|
+
break;
|
|
609
|
+
r(t.subarray(u, f), s), u = n, s = -1;
|
|
610
|
+
}
|
|
611
|
+
u === l ? t = void 0 : u !== 0 && (t = t.subarray(u), n -= u);
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function getMessages(r, t, n) {
|
|
615
|
+
let s = newMessage();
|
|
616
|
+
const c = new TextDecoder();
|
|
617
|
+
return function(d, l) {
|
|
618
|
+
if (d.length === 0)
|
|
619
|
+
n == null || n(s), s = newMessage();
|
|
620
|
+
else if (l > 0) {
|
|
621
|
+
const u = c.decode(d.subarray(0, l)), f = l + (d[l + 1] === 32 ? 2 : 1), y = c.decode(d.subarray(f));
|
|
622
|
+
switch (u) {
|
|
623
|
+
case "data":
|
|
624
|
+
s.data = s.data ? s.data + `
|
|
625
|
+
` + y : y;
|
|
626
|
+
break;
|
|
627
|
+
case "event":
|
|
628
|
+
s.event = y;
|
|
629
|
+
break;
|
|
630
|
+
case "id":
|
|
631
|
+
r(s.id = y);
|
|
632
|
+
break;
|
|
633
|
+
case "retry":
|
|
634
|
+
const g = parseInt(y, 10);
|
|
635
|
+
isNaN(g) || t(s.retry = g);
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function concat(r, t) {
|
|
642
|
+
const n = new Uint8Array(r.length + t.length);
|
|
643
|
+
return n.set(r), n.set(t, r.length), n;
|
|
644
|
+
}
|
|
645
|
+
function newMessage() {
|
|
646
|
+
return {
|
|
647
|
+
data: "",
|
|
648
|
+
event: "",
|
|
649
|
+
id: "",
|
|
650
|
+
retry: void 0
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
var __rest = function(r, t) {
|
|
654
|
+
var n = {};
|
|
655
|
+
for (var s in r)
|
|
656
|
+
Object.prototype.hasOwnProperty.call(r, s) && t.indexOf(s) < 0 && (n[s] = r[s]);
|
|
657
|
+
if (r != null && typeof Object.getOwnPropertySymbols == "function")
|
|
658
|
+
for (var c = 0, s = Object.getOwnPropertySymbols(r); c < s.length; c++)
|
|
659
|
+
t.indexOf(s[c]) < 0 && Object.prototype.propertyIsEnumerable.call(r, s[c]) && (n[s[c]] = r[s[c]]);
|
|
660
|
+
return n;
|
|
661
|
+
};
|
|
662
|
+
const EventStreamContentType = "text/event-stream", DefaultRetryInterval = 1e3, LastEventId = "last-event-id";
|
|
663
|
+
function fetchEventSource(r, t) {
|
|
664
|
+
var { signal: n, headers: s, onopen: c, onmessage: a, onclose: d, onerror: l, openWhenHidden: u, fetch: f } = t, y = __rest(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
665
|
+
return new Promise((g, w) => {
|
|
666
|
+
const p = Object.assign({}, s);
|
|
667
|
+
p.accept || (p.accept = EventStreamContentType);
|
|
668
|
+
let m;
|
|
669
|
+
function S() {
|
|
670
|
+
m.abort(), document.hidden || k();
|
|
671
|
+
}
|
|
672
|
+
u || document.addEventListener("visibilitychange", S);
|
|
673
|
+
let x = DefaultRetryInterval, R = 0;
|
|
674
|
+
function _() {
|
|
675
|
+
document.removeEventListener("visibilitychange", S), window.clearTimeout(R), m.abort();
|
|
676
|
+
}
|
|
677
|
+
n == null || n.addEventListener("abort", () => {
|
|
678
|
+
_(), g();
|
|
679
|
+
});
|
|
680
|
+
const A = f ?? window.fetch, U = c ?? defaultOnOpen;
|
|
681
|
+
async function k() {
|
|
682
|
+
var I;
|
|
683
|
+
m = new AbortController();
|
|
684
|
+
try {
|
|
685
|
+
const T = await A(r, Object.assign(Object.assign({}, y), { headers: p, signal: m.signal }));
|
|
686
|
+
await U(T), await getBytes(T.body, getLines(getMessages((v) => {
|
|
687
|
+
v ? p[LastEventId] = v : delete p[LastEventId];
|
|
688
|
+
}, (v) => {
|
|
689
|
+
x = v;
|
|
690
|
+
}, a))), d == null || d(), _(), g();
|
|
691
|
+
} catch (T) {
|
|
692
|
+
if (!m.signal.aborted)
|
|
693
|
+
try {
|
|
694
|
+
const v = (I = l == null ? void 0 : l(T)) !== null && I !== void 0 ? I : x;
|
|
695
|
+
window.clearTimeout(R), R = window.setTimeout(k, v);
|
|
696
|
+
} catch (v) {
|
|
697
|
+
_(), w(v);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
k();
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function defaultOnOpen(r) {
|
|
705
|
+
const t = r.headers.get("content-type");
|
|
706
|
+
if (!(t != null && t.startsWith(EventStreamContentType)))
|
|
707
|
+
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`);
|
|
708
|
+
}
|
|
709
|
+
function Base64EncodeUrl(r) {
|
|
710
|
+
return r.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
711
|
+
}
|
|
712
|
+
function getTimestamp() {
|
|
713
|
+
return Math.floor(Date.now() / 1e3);
|
|
714
|
+
}
|
|
715
|
+
function e(r) {
|
|
716
|
+
this.message = r;
|
|
717
|
+
}
|
|
718
|
+
e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
|
|
719
|
+
var r$1 = typeof window < "u" && window.atob && window.atob.bind(window) || function(r) {
|
|
720
|
+
var t = String(r).replace(/=+$/, "");
|
|
721
|
+
if (t.length % 4 == 1)
|
|
722
|
+
throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
723
|
+
for (var n, s, c = 0, a = 0, d = ""; s = t.charAt(a++); ~s && (n = c % 4 ? 64 * n + s : s, c++ % 4) ? d += String.fromCharCode(255 & n >> (-2 * c & 6)) : 0)
|
|
724
|
+
s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);
|
|
725
|
+
return d;
|
|
726
|
+
};
|
|
727
|
+
function t$1(r) {
|
|
728
|
+
var t = r.replace(/-/g, "+").replace(/_/g, "/");
|
|
729
|
+
switch (t.length % 4) {
|
|
730
|
+
case 0:
|
|
731
|
+
break;
|
|
732
|
+
case 2:
|
|
733
|
+
t += "==";
|
|
734
|
+
break;
|
|
735
|
+
case 3:
|
|
736
|
+
t += "=";
|
|
737
|
+
break;
|
|
738
|
+
default:
|
|
739
|
+
throw "Illegal base64url string!";
|
|
740
|
+
}
|
|
741
|
+
try {
|
|
742
|
+
return function(n) {
|
|
743
|
+
return decodeURIComponent(r$1(n).replace(/(.)/g, function(s, c) {
|
|
744
|
+
var a = c.charCodeAt(0).toString(16).toUpperCase();
|
|
745
|
+
return a.length < 2 && (a = "0" + a), "%" + a;
|
|
746
|
+
}));
|
|
747
|
+
}(t);
|
|
748
|
+
} catch {
|
|
749
|
+
return r$1(t);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function n$1(r) {
|
|
753
|
+
this.message = r;
|
|
754
|
+
}
|
|
755
|
+
function o(r, t) {
|
|
756
|
+
if (typeof r != "string")
|
|
757
|
+
throw new n$1("Invalid token specified");
|
|
758
|
+
var n = (t = t || {}).header === !0 ? 0 : 1;
|
|
759
|
+
try {
|
|
760
|
+
return JSON.parse(t$1(r.split(".")[n]));
|
|
761
|
+
} catch (s) {
|
|
762
|
+
throw new n$1("Invalid token specified: " + s.message);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
n$1.prototype = new Error(), n$1.prototype.name = "InvalidTokenError";
|
|
766
|
+
class NylasSessions {
|
|
767
|
+
constructor(t) {
|
|
768
|
+
b(this, "clientId");
|
|
769
|
+
b(this, "redirectUri");
|
|
770
|
+
b(this, "accessType", "online");
|
|
771
|
+
b(this, "domain", "http://api.nylas.com");
|
|
772
|
+
b(this, "versioned", !1);
|
|
773
|
+
b(this, "Storage");
|
|
774
|
+
b(this, "hosted", !1);
|
|
775
|
+
b(this, "multiAccount", !1);
|
|
776
|
+
b(this, "loginId", "");
|
|
777
|
+
if (this.clientId = t.clientId, this.redirectUri = t.redirectUri, t.domain && (this.domain = t.domain, this.domain.substring(this.domain.length - 3).includes("/v") && (this.versioned = !0)), t.multiAccount && (this.multiAccount = t.multiAccount), t.sw) {
|
|
778
|
+
const n = new IndexedDBStorage();
|
|
779
|
+
this.Storage = new Storage(n);
|
|
780
|
+
} else
|
|
781
|
+
this.Storage = new Storage();
|
|
782
|
+
t.accessType && (this.accessType = t.accessType), t.loginId && (this.loginId = t.loginId), t.hosted && (this.hosted = t.hosted), this.codeExchange(null);
|
|
783
|
+
}
|
|
784
|
+
// Validates access token
|
|
785
|
+
async validateAccessToken(t = "") {
|
|
786
|
+
const n = await this.Storage.getGrant(t, this.multiAccount);
|
|
787
|
+
if (!n)
|
|
788
|
+
return !1;
|
|
789
|
+
const { access_token: s } = n;
|
|
790
|
+
try {
|
|
791
|
+
return !!(await (await fetch(`${this.domain}/connect/tokeninfo?access_token=${s}`, {
|
|
792
|
+
method: "GET"
|
|
793
|
+
})).json()).data;
|
|
794
|
+
} catch {
|
|
795
|
+
return !1;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
// Validates id token
|
|
799
|
+
async validateIDToken(t = "") {
|
|
800
|
+
const n = await this.Storage.getGrant(t, this.multiAccount);
|
|
801
|
+
if (!n)
|
|
802
|
+
return !1;
|
|
803
|
+
const { id_token: s } = n;
|
|
804
|
+
try {
|
|
805
|
+
const c = await fetch(`${this.domain}/connect/tokeninfo?id_token=${s}`, {
|
|
806
|
+
method: "GET"
|
|
807
|
+
});
|
|
808
|
+
return !(c.status !== 200 || !(await c.json()).data);
|
|
809
|
+
} catch {
|
|
810
|
+
return !1;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
// Gets domain of UAS
|
|
814
|
+
getDomain() {
|
|
815
|
+
return this.domain;
|
|
816
|
+
}
|
|
817
|
+
// Gets auth link
|
|
818
|
+
async auth(t) {
|
|
819
|
+
this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)) && await this.hostedSetCodeChallenge();
|
|
820
|
+
const n = await this.generateAuthURL(t);
|
|
821
|
+
if (t.popup) {
|
|
822
|
+
this.popUp(n);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
return n;
|
|
826
|
+
}
|
|
827
|
+
// Generates auth URL
|
|
828
|
+
async generateAuthURL(t) {
|
|
829
|
+
const n = await this.getCodeChallege();
|
|
830
|
+
let s = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
|
|
831
|
+
return n && (s += `&code_challenge=${n}&code_challenge_method=S256&options=rotate_refresh_token`), t.provider && (s += `&provider=${t.provider}`), t.loginHint && (s += `&login_hint=${t.loginHint}`, t.includeGrantScopes && (s += `&include_grant_scopes=${t.includeGrantScopes}`)), t.scope && (s += `&scope=${t.scope.join(" ")}`), t.prompt && (s += `&prompt=${t.prompt}`), t.metadata && (s += `&metadata=${t.metadata}`), (t.state || this.loginId) && (s += `&state=${this.loginId ? this.loginId : t.state}`), s;
|
|
832
|
+
}
|
|
833
|
+
// Generates auth URL
|
|
834
|
+
async generateReauthURL(t, n) {
|
|
835
|
+
if (!t)
|
|
836
|
+
throw new Error("Grant ID is required");
|
|
837
|
+
const s = await this.Storage.getUserToken(t), c = await this.getCodeChallege();
|
|
838
|
+
let a = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
|
|
839
|
+
return c && (a += `&code_challenge=${c}&code_challenge_method=S256&options=rotate_refresh_token`), s != null && s.provider && (a += `&provider=${s.provider}`), s != null && s.email && (a += `&login_hint=${s.email}`), n && (a += `&scope=${n.join(" ")}`), a;
|
|
840
|
+
}
|
|
841
|
+
// Generates UUID code challenge
|
|
842
|
+
async generateCodeChallenge() {
|
|
843
|
+
if (await this.Storage.getPKCE())
|
|
844
|
+
return;
|
|
845
|
+
const n = v4();
|
|
846
|
+
this.Storage.setPKCE(n);
|
|
847
|
+
}
|
|
848
|
+
// Gets code challenge from URL query params
|
|
849
|
+
async hostedSetCodeChallenge() {
|
|
850
|
+
if (!this.hosted)
|
|
851
|
+
throw console.error("Method only used with hosted flag enabled");
|
|
852
|
+
const n = new URLSearchParams(window.location.search).get("code_challenge");
|
|
853
|
+
if (!n) {
|
|
854
|
+
if (await this.Storage.getPKCE())
|
|
855
|
+
return;
|
|
856
|
+
console.warn("Code challenge is recomended");
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
this.Storage.setPKCE(n);
|
|
860
|
+
}
|
|
861
|
+
// Gets code challenge from store
|
|
862
|
+
async getCodeChallege() {
|
|
863
|
+
if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin))) {
|
|
864
|
+
const s = new URLSearchParams(window.location.search).get("code_challenge");
|
|
865
|
+
return s || (console.warn("Code challenge is recomended"), "");
|
|
866
|
+
}
|
|
867
|
+
const t = await this.Storage.getPKCE();
|
|
868
|
+
if (t) {
|
|
869
|
+
const n = sha256.exports.sha256(t);
|
|
870
|
+
let s = Buffer.from(n).toString("base64");
|
|
871
|
+
return s = Base64EncodeUrl(s), s;
|
|
872
|
+
}
|
|
873
|
+
return "";
|
|
874
|
+
}
|
|
875
|
+
// checks if user is logged in
|
|
876
|
+
async isLoggedIn() {
|
|
877
|
+
if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)))
|
|
878
|
+
return !1;
|
|
879
|
+
const t = await this.Storage.getUserTokens();
|
|
880
|
+
return t && t.length > 0 ? (this.multiAccount && await this.generateCodeChallenge(), !0) : (await this.generateCodeChallenge(), !1);
|
|
881
|
+
}
|
|
882
|
+
// Checks if user is multi account
|
|
883
|
+
isMultiAccount() {
|
|
884
|
+
return this.multiAccount;
|
|
885
|
+
}
|
|
886
|
+
// Logs user out
|
|
887
|
+
async logout() {
|
|
888
|
+
const t = await this.getProfile();
|
|
889
|
+
await this.Storage.clearSession();
|
|
890
|
+
const n = { detail: t };
|
|
891
|
+
window.dispatchEvent(new CustomEvent("onLogoutSuccess", n));
|
|
892
|
+
}
|
|
893
|
+
// Gets profile info from ID token
|
|
894
|
+
async getProfile(t = "") {
|
|
895
|
+
let n;
|
|
896
|
+
return t ? n = await this.Storage.getUserToken(t) : n = await this.Storage.getUserToken(), n || null;
|
|
897
|
+
}
|
|
898
|
+
// Gets profile info from ID tokens
|
|
899
|
+
async getProfiles() {
|
|
900
|
+
const t = await this.Storage.getUserTokens();
|
|
901
|
+
return t || null;
|
|
902
|
+
}
|
|
903
|
+
// Remove a specific profile
|
|
904
|
+
async removeProfile(t) {
|
|
905
|
+
return await this.Storage.removeUserToken(t), await this.Storage.removeGrant(t), null;
|
|
906
|
+
}
|
|
907
|
+
// IMAP authentication
|
|
908
|
+
async authIMAP(t) {
|
|
909
|
+
const n = await this.getCodeChallege(), s = {
|
|
910
|
+
imap_username: t.username,
|
|
911
|
+
imap_password: t.password,
|
|
912
|
+
imap_host: t.hostIMAP,
|
|
913
|
+
imap_port: t.portIMAP,
|
|
914
|
+
type: t.type,
|
|
915
|
+
smtp_host: t.hostSMTP,
|
|
916
|
+
smtp_port: t.portSMTP,
|
|
917
|
+
provider: t.provider,
|
|
918
|
+
redirect_uri: this.redirectUri,
|
|
919
|
+
state: t.state,
|
|
920
|
+
public_application_id: this.clientId,
|
|
921
|
+
access_type: this.accessType
|
|
922
|
+
};
|
|
923
|
+
return this.loginId && (s.id = this.loginId), n != "" && (s.code_challenge = n, s.code_challenge_method = "S256"), await (await fetch(`${this.domain}/connect/login/imap`, {
|
|
924
|
+
method: "POST",
|
|
925
|
+
headers: new Headers({ "content-type": "application/json" }),
|
|
926
|
+
body: JSON.stringify(s)
|
|
927
|
+
})).json();
|
|
928
|
+
}
|
|
929
|
+
// EWS authentication
|
|
930
|
+
async authEWS(t) {
|
|
931
|
+
const n = await this.getCodeChallege(), s = {
|
|
932
|
+
...t,
|
|
933
|
+
redirect_uri: this.redirectUri,
|
|
934
|
+
public_application_id: this.clientId,
|
|
935
|
+
access_type: this.accessType
|
|
936
|
+
};
|
|
937
|
+
return this.loginId && (s.id = this.loginId), n != "" && (s.code_challenge = n, s.code_challenge_method = "S256"), await (await fetch(`${this.domain}/connect/login/ews`, {
|
|
938
|
+
method: "POST",
|
|
939
|
+
headers: new Headers({ "content-type": "application/json" }),
|
|
940
|
+
body: JSON.stringify(s)
|
|
941
|
+
})).json();
|
|
942
|
+
}
|
|
943
|
+
// Detects email
|
|
944
|
+
async detectEmail(t) {
|
|
945
|
+
return (await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/providers/detect?client_id=${this.clientId}&email=${t}`, {
|
|
946
|
+
method: "POST",
|
|
947
|
+
headers: new Headers({ "content-type": "application/json" })
|
|
948
|
+
})).json()).data;
|
|
949
|
+
}
|
|
950
|
+
// Gets app info from UAS
|
|
951
|
+
async applicationInfo() {
|
|
952
|
+
return (await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/applications?client_id=${this.clientId}`, {
|
|
953
|
+
method: "GET",
|
|
954
|
+
headers: new Headers({ "content-type": "application/json" })
|
|
955
|
+
})).json()).data;
|
|
956
|
+
}
|
|
957
|
+
// Gets providers form UAS
|
|
958
|
+
async getAvailableProviders() {
|
|
959
|
+
const t = await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`, {
|
|
960
|
+
method: "GET",
|
|
961
|
+
headers: new Headers({ "content-type": "application/json" })
|
|
962
|
+
});
|
|
963
|
+
return t ? (await t.json()).data : null;
|
|
964
|
+
}
|
|
965
|
+
// EVENT HOOKS
|
|
966
|
+
onLoginSuccess(t) {
|
|
967
|
+
window.addEventListener("onLoginSuccess", (n) => t(n));
|
|
968
|
+
}
|
|
969
|
+
onLogoutSuccess(t) {
|
|
970
|
+
window.addEventListener("onLogoutSuccess", (n) => t(n));
|
|
971
|
+
}
|
|
972
|
+
onLoginFail(t) {
|
|
973
|
+
window.addEventListener("onLoginFail", (n) => t(n));
|
|
974
|
+
}
|
|
975
|
+
onTokenRefreshSuccess(t) {
|
|
976
|
+
window.addEventListener("onTokenRefreshSuccess", (n) => t(n));
|
|
977
|
+
}
|
|
978
|
+
onTokenRefreshFail(t) {
|
|
979
|
+
window.addEventListener("onTokenRefreshFail", (n) => t(n));
|
|
980
|
+
}
|
|
981
|
+
onSessionExpired(t) {
|
|
982
|
+
window.addEventListener("onSessionExpired", (n) => t(n));
|
|
983
|
+
}
|
|
984
|
+
// Exchanges code for ID token and refresh and access tokens
|
|
985
|
+
async codeExchange(t) {
|
|
986
|
+
let n = new URLSearchParams(window.location.search);
|
|
987
|
+
t && (n = new URLSearchParams(t));
|
|
988
|
+
const s = n.get("code"), c = n.get("state"), a = n.get("error"), d = n.get("error_description"), l = n.get("error_code");
|
|
989
|
+
if (a && d && l) {
|
|
990
|
+
const f = {
|
|
991
|
+
detail: { error: a, error_description: d, error_code: l }
|
|
992
|
+
};
|
|
993
|
+
return window.dispatchEvent(new CustomEvent("onLoginFail", f)), window.history.pushState({}, document.title, window.location.pathname), !1;
|
|
994
|
+
}
|
|
995
|
+
if (!s)
|
|
996
|
+
return console.warn("No code found"), !1;
|
|
997
|
+
if (window.opener && window.name === "uas-popup")
|
|
998
|
+
return console.warn("Popup window detected"), !1;
|
|
999
|
+
const u = await this.Storage.getPKCE();
|
|
1000
|
+
if (!u)
|
|
1001
|
+
return console.warn("No code verifier found"), !1;
|
|
1002
|
+
try {
|
|
1003
|
+
const f = {
|
|
1004
|
+
client_id: this.clientId,
|
|
1005
|
+
redirect_uri: this.redirectUri,
|
|
1006
|
+
code: s,
|
|
1007
|
+
grant_type: "authorization_code",
|
|
1008
|
+
code_verifier: u
|
|
1009
|
+
}, g = await (await fetch(`${this.domain}/connect/token`, {
|
|
1010
|
+
method: "POST",
|
|
1011
|
+
headers: new Headers({ "content-type": "application/json" }),
|
|
1012
|
+
body: JSON.stringify(f)
|
|
1013
|
+
})).json();
|
|
1014
|
+
if (g) {
|
|
1015
|
+
if (g.error) {
|
|
1016
|
+
const p = { detail: g };
|
|
1017
|
+
return window.dispatchEvent(new CustomEvent("onLoginFail", p)), !0;
|
|
1018
|
+
}
|
|
1019
|
+
const w = await this.handleCodeExchangeResponse(g);
|
|
1020
|
+
if (w.valid) {
|
|
1021
|
+
c && (w.data.state = c);
|
|
1022
|
+
const p = { detail: w.data };
|
|
1023
|
+
window.dispatchEvent(new CustomEvent("onLoginSuccess", p)), window.history.pushState({}, document.title, window.location.pathname);
|
|
1024
|
+
} else {
|
|
1025
|
+
const p = { detail: w.data };
|
|
1026
|
+
return window.dispatchEvent(new CustomEvent("onLoginFail", p)), !0;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
return this.Storage.removePKCE(), !0;
|
|
1030
|
+
} catch (f) {
|
|
1031
|
+
const y = { detail: f };
|
|
1032
|
+
return window.dispatchEvent(new CustomEvent("onLoginFail", y)), window.history.pushState({}, document.title, window.location.pathname), !1;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
// Token Exchange for session maintenece
|
|
1036
|
+
async tokenExchange(t = "") {
|
|
1037
|
+
const n = await this.Storage.getGrant(t, this.multiAccount);
|
|
1038
|
+
if (!n)
|
|
1039
|
+
return !1;
|
|
1040
|
+
const s = n.refresh_token;
|
|
1041
|
+
try {
|
|
1042
|
+
const c = {
|
|
1043
|
+
client_id: this.clientId,
|
|
1044
|
+
redirect_uri: this.redirectUri,
|
|
1045
|
+
refresh_token: s,
|
|
1046
|
+
grant_type: "refresh_token"
|
|
1047
|
+
}, d = await (await fetch(`${this.domain}/connect/token`, {
|
|
1048
|
+
method: "POST",
|
|
1049
|
+
headers: new Headers({ "content-type": "application/json" }),
|
|
1050
|
+
body: JSON.stringify(c)
|
|
1051
|
+
})).json();
|
|
1052
|
+
if (d) {
|
|
1053
|
+
if (d.error) {
|
|
1054
|
+
const y = { detail: d };
|
|
1055
|
+
return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", y)), !0;
|
|
1056
|
+
}
|
|
1057
|
+
const l = getTimestamp();
|
|
1058
|
+
if (d.expires_in = l + d.expires_in, this.Storage.setGrant(d, this.multiAccount), !await this.validateIDToken(t)) {
|
|
1059
|
+
const y = { detail: d };
|
|
1060
|
+
return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", y)), !0;
|
|
1061
|
+
}
|
|
1062
|
+
const f = { detail: d };
|
|
1063
|
+
return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess", f)), !0;
|
|
1064
|
+
}
|
|
1065
|
+
this.Storage.removePKCE();
|
|
1066
|
+
} catch (c) {
|
|
1067
|
+
const a = { detail: c };
|
|
1068
|
+
return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", a)), !1;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
// Handles the response of code exchange
|
|
1072
|
+
async handleCodeExchangeResponse(t) {
|
|
1073
|
+
if (t.error)
|
|
1074
|
+
return {
|
|
1075
|
+
data: t,
|
|
1076
|
+
valid: !1
|
|
1077
|
+
};
|
|
1078
|
+
const s = getTimestamp();
|
|
1079
|
+
t.expires_in = s + t.expires_in, this.Storage.setGrant(t, this.multiAccount);
|
|
1080
|
+
const c = o(t.id_token);
|
|
1081
|
+
return c.status = "authenticated", this.Storage.setUserToken(c), await this.validateIDToken(c.sub) ? {
|
|
1082
|
+
data: t,
|
|
1083
|
+
valid: !0
|
|
1084
|
+
} : {
|
|
1085
|
+
data: t,
|
|
1086
|
+
valid: !1
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
// Regulates POPUP behaivior
|
|
1090
|
+
async popUp(t) {
|
|
1091
|
+
const c = window.screenX + (window.outerWidth - 500) / 2, a = window.screenY + (window.outerHeight - 600) / 2.5, d = "uas-popup", l = t, u = window.open(l, d, `width=500,height=600,left=${c},top=${a}`);
|
|
1092
|
+
if (!u)
|
|
1093
|
+
return;
|
|
1094
|
+
const f = setInterval(async () => {
|
|
1095
|
+
if (u.closed) {
|
|
1096
|
+
const y = {
|
|
1097
|
+
detail: { error_description: "OAuth provider window closed" }
|
|
1098
|
+
};
|
|
1099
|
+
window.dispatchEvent(new CustomEvent("onLoginFail", y)), f && clearInterval(f);
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
try {
|
|
1103
|
+
const y = u.location.href.split("?");
|
|
1104
|
+
if (!y[0])
|
|
1105
|
+
return;
|
|
1106
|
+
const g = u.location.search;
|
|
1107
|
+
if (u.history.pushState({}, document.title, window.location.pathname), y[0] === this.redirectUri && y.length > 1) {
|
|
1108
|
+
const w = await this.codeExchange(g);
|
|
1109
|
+
u.close(), w && location.reload(), f && clearInterval(f);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
} catch {
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
}, 1e3);
|
|
1116
|
+
}
|
|
1117
|
+
// Returns access token
|
|
1118
|
+
async getAccessToken(t = "") {
|
|
1119
|
+
const n = getTimestamp(), s = await this.Storage.getGrant(t, this.multiAccount);
|
|
1120
|
+
if (!s)
|
|
1121
|
+
return null;
|
|
1122
|
+
const { access_token: c, expires_in: a } = s, d = c;
|
|
1123
|
+
return d && a && a > getTimestamp() && a - n > 30 ? d : (await this.tokenExchange(t), (await this.Storage.getGrant(t, this.multiAccount)).access_token);
|
|
1124
|
+
}
|
|
1125
|
+
async sse(t, n) {
|
|
1126
|
+
const s = n.headers || {}, c = s["Grant-ID"];
|
|
1127
|
+
let a = "";
|
|
1128
|
+
if (this.multiAccount) {
|
|
1129
|
+
if (!c)
|
|
1130
|
+
throw this.logout(), new Error("Grant ID is required for multi account calls");
|
|
1131
|
+
a = await this.getAccessToken(c);
|
|
1132
|
+
} else
|
|
1133
|
+
a = await this.getAccessToken();
|
|
1134
|
+
return delete s["Grant-ID"], s.Authorization = `Bearer ${a}`, s["content-type"] || (s["content-type"] = "application/json"), fetchEventSource(`${this.domain}/${t}`, {
|
|
1135
|
+
...n,
|
|
1136
|
+
headers: s
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
// Used to call Nylas API endpoints
|
|
1140
|
+
async fetch(t, n, s = !0, c) {
|
|
1141
|
+
let a = "", d = 1;
|
|
1142
|
+
if (this.multiAccount) {
|
|
1143
|
+
if (!n.grant_id)
|
|
1144
|
+
throw this.logout(), new Error("Grant ID is required for multi account calls");
|
|
1145
|
+
const u = await this.getProfiles();
|
|
1146
|
+
d = u ? u.length : 1, a = await this.getAccessToken(n.grant_id);
|
|
1147
|
+
} else
|
|
1148
|
+
a = await this.getAccessToken();
|
|
1149
|
+
if (!a)
|
|
1150
|
+
throw new Error("Access token not found");
|
|
1151
|
+
let l = n.headers;
|
|
1152
|
+
Headers.prototype.isPrototypeOf(l) ? (l.append("Authorization", `Bearer ${a}`), l.has("content-type") || l.append("content-type", "application/json")) : l = new Headers({
|
|
1153
|
+
Authorization: `Bearer ${a}`,
|
|
1154
|
+
"content-type": "application/json"
|
|
1155
|
+
});
|
|
1156
|
+
try {
|
|
1157
|
+
n != null && n.body && (n.body = JSON.stringify(n == null ? void 0 : n.body));
|
|
1158
|
+
const u = await fetch(`${c || this.domain}/${t}`, {
|
|
1159
|
+
...n,
|
|
1160
|
+
headers: l
|
|
1161
|
+
});
|
|
1162
|
+
if (!s)
|
|
1163
|
+
return u;
|
|
1164
|
+
const f = await (u == null ? void 0 : u.json());
|
|
1165
|
+
if (!await this.isAuthenticatedResponse(u.status, f)) {
|
|
1166
|
+
if (d > 1) {
|
|
1167
|
+
const g = await this.getProfile(n.grant_id);
|
|
1168
|
+
if (g) {
|
|
1169
|
+
g.status = "unauthorized", await this.Storage.setUserToken(g);
|
|
1170
|
+
const w = {
|
|
1171
|
+
detail: { user: g }
|
|
1172
|
+
};
|
|
1173
|
+
window.dispatchEvent(new CustomEvent("onSessionExpired", w));
|
|
1174
|
+
}
|
|
1175
|
+
} else {
|
|
1176
|
+
const w = {
|
|
1177
|
+
detail: { user: await this.Storage.getUserToken() }
|
|
1178
|
+
};
|
|
1179
|
+
window.dispatchEvent(new CustomEvent("onSessionExpired", w));
|
|
1180
|
+
}
|
|
1181
|
+
this.logout();
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
return f;
|
|
1185
|
+
} catch (u) {
|
|
1186
|
+
throw u;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
async fetchRequest(t, n, s, c = !0, a, d) {
|
|
1190
|
+
const l = await this.isLoggedIn(), u = new URL(t, a ?? this.domain), f = new Headers();
|
|
1191
|
+
if (f.append("Accept", "application/json"), f.append("Content-Type", "application/json"), f.append("User-Agent", "nylas-identity"), l) {
|
|
1192
|
+
const w = await this.getAccessToken();
|
|
1193
|
+
f.append("Authorization", `Bearer ${w}`);
|
|
1194
|
+
}
|
|
1195
|
+
const y = await fetch(u.toString(), {
|
|
1196
|
+
method: n || "GET",
|
|
1197
|
+
headers: f,
|
|
1198
|
+
mode: "cors",
|
|
1199
|
+
referrer: location.origin,
|
|
1200
|
+
body: s ? JSON.stringify(s) : void 0,
|
|
1201
|
+
...d || {}
|
|
1202
|
+
});
|
|
1203
|
+
return c ? await y.json() : y.body;
|
|
1204
|
+
}
|
|
1205
|
+
// Checks if the response is not 401
|
|
1206
|
+
async isAuthenticatedResponse(t, n) {
|
|
1207
|
+
var s;
|
|
1208
|
+
return !(t == 401 && ((s = n == null ? void 0 : n.error) == null ? void 0 : s.type) == "token.unauthorized_access");
|
|
1209
|
+
}
|
|
1210
|
+
addAPIKey(t, n, s) {
|
|
1211
|
+
this.Storage.setUserToken({
|
|
1212
|
+
aud: "https://api-staging.us.nylas.com/",
|
|
1213
|
+
exp: 2e9,
|
|
1214
|
+
email_verified: !0,
|
|
1215
|
+
iat: getTimestamp(),
|
|
1216
|
+
iss: "",
|
|
1217
|
+
email: n,
|
|
1218
|
+
provider: "virtual-calendar",
|
|
1219
|
+
status: "authenticated",
|
|
1220
|
+
name: n,
|
|
1221
|
+
sub: t
|
|
1222
|
+
}), this.Storage.setGrant({
|
|
1223
|
+
grant_id: t,
|
|
1224
|
+
access_token: s,
|
|
1225
|
+
expires_in: 2e9
|
|
1226
|
+
}, this.multiAccount);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
var B = { isMounted: function() {
|
|
1230
|
+
return !1;
|
|
1231
|
+
}, enqueueForceUpdate: function() {
|
|
1232
|
+
}, enqueueReplaceState: function() {
|
|
1233
|
+
}, enqueueSetState: function() {
|
|
1234
|
+
} }, C = Object.assign, D = {};
|
|
1235
|
+
function E(r, t, n) {
|
|
1236
|
+
this.props = r, this.context = t, this.refs = D, this.updater = n || B;
|
|
1237
|
+
}
|
|
1238
|
+
E.prototype.isReactComponent = {};
|
|
1239
|
+
E.prototype.setState = function(r, t) {
|
|
1240
|
+
if (typeof r != "object" && typeof r != "function" && r != null)
|
|
1241
|
+
throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
|
1242
|
+
this.updater.enqueueSetState(this, r, t, "setState");
|
|
1243
|
+
};
|
|
1244
|
+
E.prototype.forceUpdate = function(r) {
|
|
1245
|
+
this.updater.enqueueForceUpdate(this, r, "forceUpdate");
|
|
1246
|
+
};
|
|
1247
|
+
function F() {
|
|
1248
|
+
}
|
|
1249
|
+
F.prototype = E.prototype;
|
|
1250
|
+
function G(r, t, n) {
|
|
1251
|
+
this.props = r, this.context = t, this.refs = D, this.updater = n || B;
|
|
1252
|
+
}
|
|
1253
|
+
var H = G.prototype = new F();
|
|
1254
|
+
H.constructor = G;
|
|
1255
|
+
C(H, E.prototype);
|
|
1256
|
+
H.isPureReactComponent = !0;
|
|
1257
|
+
const LoginRequired = ({ authenticationUrl: r }) => h(
|
|
1258
|
+
"div",
|
|
1259
|
+
{ class: "login-required", part: "login-component" },
|
|
1260
|
+
h(
|
|
1261
|
+
"div",
|
|
1262
|
+
{ class: "card" },
|
|
1263
|
+
h("p", null, "Log into your account to use the Scheduler Editor."),
|
|
1264
|
+
h(
|
|
1265
|
+
"button",
|
|
1266
|
+
{ class: "google-button", onClick: async (t) => {
|
|
1267
|
+
t.preventDefault();
|
|
1268
|
+
const n = await r("google");
|
|
1269
|
+
n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
|
|
1270
|
+
} },
|
|
1271
|
+
h(
|
|
1272
|
+
"span",
|
|
1273
|
+
{ class: "icon" },
|
|
1274
|
+
h("google-logo-icon", { width: "15", height: "15" })
|
|
1275
|
+
),
|
|
1276
|
+
"Continue with Google"
|
|
1277
|
+
),
|
|
1278
|
+
h(
|
|
1279
|
+
"button",
|
|
1280
|
+
{ class: "microsoft-button", onClick: async (t) => {
|
|
1281
|
+
t.preventDefault();
|
|
1282
|
+
const n = await r("microsoft");
|
|
1283
|
+
n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
|
|
1284
|
+
} },
|
|
1285
|
+
h(
|
|
1286
|
+
"span",
|
|
1287
|
+
{ class: "icon" },
|
|
1288
|
+
h("microsoft-logo-icon", { width: "15", height: "15" })
|
|
1289
|
+
),
|
|
1290
|
+
"Continue with Microsoft"
|
|
1291
|
+
),
|
|
1292
|
+
h(
|
|
1293
|
+
"button",
|
|
1294
|
+
{ class: "other-provider-button", onClick: async (t) => {
|
|
1295
|
+
t.preventDefault();
|
|
1296
|
+
const n = await r();
|
|
1297
|
+
n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
|
|
1298
|
+
} },
|
|
1299
|
+
"View all providers ",
|
|
1300
|
+
h("chevron-icon", { width: "17", height: "17" })
|
|
1301
|
+
),
|
|
1302
|
+
h("small", { class: "disclaimer-text" }, "* You will be redirected to authenticate your account.")
|
|
1303
|
+
)
|
|
1304
|
+
);
|
|
1305
|
+
function ExpressFlow({ selectedConfiguration: r, currentUser: t, calendars: n }) {
|
|
1306
|
+
var c;
|
|
1307
|
+
const s = ((c = r.participants) == null ? void 0 : c.find((a) => a.is_organizer)) ?? t;
|
|
1308
|
+
return h(
|
|
1309
|
+
Fragment,
|
|
1310
|
+
null,
|
|
1311
|
+
h(
|
|
1312
|
+
"nylas-event-info",
|
|
1313
|
+
null,
|
|
1314
|
+
h(
|
|
1315
|
+
"div",
|
|
1316
|
+
{ slot: "inputs" },
|
|
1317
|
+
h("nylas-event-title", null),
|
|
1318
|
+
h("nylas-event-duration", null),
|
|
1319
|
+
h("nylas-event-location", { userProvider: t.provider })
|
|
1320
|
+
)
|
|
1321
|
+
),
|
|
1322
|
+
h("nylas-booking-calendar-picker", { calendars: n, currentUser: t, defaultBookingCalendar: s == null ? void 0 : s.email }),
|
|
1323
|
+
h("nylas-scheduling-method", { exportparts: "nsm, nsm__header, nsm__input-label, nsm__dropdown, nsm__dropdown-button, nsm__dropdown-content" }),
|
|
1324
|
+
h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" })
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
const nylasSchedulerEditorCss = ':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}div.scheduler-editor-content{height:610px}div.scheduler-editor-header{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900)}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;width:858px;margin:0;font-size:18px;line-height:24px;font-weight:600}@media screen and (max-width: 768px){div.scheduler-editor-header h1.scheduler-editor-title{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary)}div.scheduler-editor-header button:disabled{cursor:not-allowed}nylas-editor-tabs{width:auto;height:inherit}nylas-editor-tabs .composable{height:inherit;overflow:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;max-width:fit-content;align-self:center}.login-required{height:inherit;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.login-required{height:auto}}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}.list-configurations{padding:2rem;height:inherit;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.list-configurations{height:auto}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}', NylasSchedulerEditorStyle0 = nylasSchedulerEditorCss, NylasSchedulerEditor = class {
|
|
1328
|
+
constructor(r) {
|
|
1329
|
+
registerInstance(this, r), this.init = createEvent(this, "init", 7), this.loggedIn = createEvent(this, "loggedIn", 7), this.loggedOut = createEvent(this, "loggedOut", 7), this.schedulerConfigCloseClicked = createEvent(this, "schedulerConfigCloseClicked", 7), this.handleSchedulerConfigCloseClicked = (t) => {
|
|
1330
|
+
const n = this.schedulerConfigCloseClicked.emit(this.host);
|
|
1331
|
+
"schedulerConfigCloseClicked" in this.eventOverrides && this.eventOverrides.schedulerConfigCloseClicked(n, this.nylasSchedulerConfigConnector), n.defaultPrevented || (localStorage.removeItem("grant"), localStorage.removeItem("user"), window.location.reload());
|
|
1332
|
+
}, this.authenticationUrl = async (t) => this.nylasApiRequest ? await this.nylasApiRequest.authenticationUrl({ provider: t }) || "" : (console.error("[nylas-scheduler-editor] Nylas API Request is not initialized."), ""), this.configurationId = void 0, this.nylasApiRequest = void 0, this.nylasSessionsConfig = void 0, this.defaultAuthArgs = void 0, this.eventOverrides = {}, this.schedulerPreviewLink = "", this.defaultSchedulerConfigState = void 0, this.mode = "app", this.additionalParticipants = void 0, this.hideEditorTabs = [], this.conferenceProviders = void 0, this.requiresSlug = !1, this.automaticComponentRegistration = !0;
|
|
1333
|
+
}
|
|
1334
|
+
connectedCallback() {
|
|
1335
|
+
debug("[nylas-scheduler-editor] connectedCallback");
|
|
1336
|
+
}
|
|
1337
|
+
async componentWillLoad() {
|
|
1338
|
+
var s, c, a, d, l, u, f, y;
|
|
1339
|
+
debug("[nylas-scheduler-editor] componentWillLoad");
|
|
1340
|
+
const r = (s = this.additionalParticipants) == null ? void 0 : s.filter((g) => {
|
|
1341
|
+
var p;
|
|
1342
|
+
const w = ((p = g.calendars) == null ? void 0 : p.length) > 0 ? g.calendars.filter((m) => m.id && m.name) : [];
|
|
1343
|
+
if (g.name && g.email && w.length > 0)
|
|
1344
|
+
return {
|
|
1345
|
+
name: g.name,
|
|
1346
|
+
email: g.email,
|
|
1347
|
+
calendars: w
|
|
1348
|
+
};
|
|
1349
|
+
});
|
|
1350
|
+
if (this.stores = {
|
|
1351
|
+
schedulerConfig: CreateNylasSchedulerConfigStore({
|
|
1352
|
+
...this.defaultSchedulerConfigState,
|
|
1353
|
+
additionalParticipants: r,
|
|
1354
|
+
conferenceProviders: this.conferenceProviders,
|
|
1355
|
+
hideEditorTabs: this.hideEditorTabs,
|
|
1356
|
+
requiresSlug: this.requiresSlug
|
|
1357
|
+
})
|
|
1358
|
+
}, !this.nylasApiRequest && this.nylasSessionsConfig) {
|
|
1359
|
+
const g = new NylasSessions(this.nylasSessionsConfig);
|
|
1360
|
+
await g.isLoggedIn(), g.onLoginSuccess(async () => {
|
|
1361
|
+
var p, m;
|
|
1362
|
+
const w = await ((m = (p = this.nylasSchedulerConfigConnector) == null ? void 0 : p.schedulerConfig) == null ? void 0 : m.currentUser());
|
|
1363
|
+
if (w) {
|
|
1364
|
+
const S = this.loggedIn.emit(this.host);
|
|
1365
|
+
"loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(S, this.nylasSchedulerConfigConnector), S.defaultPrevented || await this.loggedInHandler(w);
|
|
1366
|
+
}
|
|
1367
|
+
}), g.onLoginFail(async () => {
|
|
1368
|
+
var p, m;
|
|
1369
|
+
(m = (p = this.stores) == null ? void 0 : p.schedulerConfig) == null || m.set("currentUser", null);
|
|
1370
|
+
const w = this.loggedOut.emit(this.host);
|
|
1371
|
+
"loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(w, this.nylasSchedulerConfigConnector), w.defaultPrevented);
|
|
1372
|
+
}), this.nylasApiRequest = new NylasIdentityRequestWrapper(g);
|
|
1373
|
+
}
|
|
1374
|
+
this.nylasApiRequest && this.defaultAuthArgs && this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs), this.baseProvider = new NylasBaseProvider(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides);
|
|
1375
|
+
const t = this.baseProvider.getStore("schedulerConfig");
|
|
1376
|
+
this.nylasSchedulerConfigConnector = new NylasSchedulerConfigConnector({
|
|
1377
|
+
nylasApiRequest: this.nylasApiRequest,
|
|
1378
|
+
nylasSchedulerConfigStore: t
|
|
1379
|
+
});
|
|
1380
|
+
const n = this.init.emit(this.host);
|
|
1381
|
+
if ("init" in this.eventOverrides && await this.eventOverrides.init(n, this.nylasSchedulerConfigConnector), !n.defaultPrevented) {
|
|
1382
|
+
const g = await ((a = (c = this.nylasSchedulerConfigConnector) == null ? void 0 : c.schedulerConfig) == null ? void 0 : a.currentUser());
|
|
1383
|
+
if (g) {
|
|
1384
|
+
const w = this.loggedIn.emit(this.host);
|
|
1385
|
+
"loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(w, this.nylasSchedulerConfigConnector), w.defaultPrevented || await this.loggedInHandler(g);
|
|
1386
|
+
} else {
|
|
1387
|
+
(l = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || l.set("currentUser", null);
|
|
1388
|
+
const w = this.loggedOut.emit(this.host);
|
|
1389
|
+
if ("loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(w, this.nylasSchedulerConfigConnector), w.defaultPrevented))
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
(f = (u = this.stores) == null ? void 0 : u.schedulerConfig) == null || f.onChange("selectedConfiguration", async (g) => {
|
|
1394
|
+
g && g.id && (this.configurationId = g.id);
|
|
1395
|
+
}), (y = this.baseProvider) == null || y.componentWillLoad(this.nylasSchedulerConfigConnector);
|
|
1396
|
+
}
|
|
1397
|
+
async componentDidLoad() {
|
|
1398
|
+
var r;
|
|
1399
|
+
debug("[nylas-scheduler-editor] componentDidLoad"), (r = this.baseProvider) == null || r.componentDidLoad();
|
|
1400
|
+
}
|
|
1401
|
+
componentDisconnected() {
|
|
1402
|
+
var r;
|
|
1403
|
+
(r = this.baseProvider) == null || r.componentDisconnected();
|
|
1404
|
+
}
|
|
1405
|
+
async configurationIdChanged(r) {
|
|
1406
|
+
var t, n, s, c, a, d, l, u;
|
|
1407
|
+
r ? (await ((n = (t = this.nylasSchedulerConfigConnector) == null ? void 0 : t.schedulerConfig) == null ? void 0 : n.getConfigurationById(r)), (c = (s = this.stores) == null ? void 0 : s.schedulerConfig) == null || c.set("action", "edit")) : ((d = (a = this.stores) == null ? void 0 : a.schedulerConfig) == null || d.set("selectedConfiguration", {}), (u = (l = this.stores) == null ? void 0 : l.schedulerConfig) == null || u.set("action", null));
|
|
1408
|
+
}
|
|
1409
|
+
async store() {
|
|
1410
|
+
var r;
|
|
1411
|
+
return (r = this.stores) == null ? void 0 : r.schedulerConfig;
|
|
1412
|
+
}
|
|
1413
|
+
async schedulerConnector() {
|
|
1414
|
+
return this.nylasSchedulerConfigConnector;
|
|
1415
|
+
}
|
|
1416
|
+
async registerComponentHandler(r) {
|
|
1417
|
+
var t;
|
|
1418
|
+
(t = this.baseProvider) == null || t.registerComponent(r.detail);
|
|
1419
|
+
}
|
|
1420
|
+
async unregisterComponentHandler(r) {
|
|
1421
|
+
var t;
|
|
1422
|
+
(t = this.baseProvider) == null || t.unregisterComponent(r.detail);
|
|
1423
|
+
}
|
|
1424
|
+
async loggedInHandler(r) {
|
|
1425
|
+
var t, n, s, c, a, d, l;
|
|
1426
|
+
if ((n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("currentUser", r), !!this.nylasSchedulerConfigConnector && (await ((s = this.nylasSchedulerConfigConnector.schedulerConfig) == null ? void 0 : s.getCalendars()), this.configurationId)) {
|
|
1427
|
+
const u = await ((c = this.nylasSchedulerConfigConnector.schedulerConfig) == null ? void 0 : c.getConfigurationById(this.configurationId));
|
|
1428
|
+
u && ((a = u[0]) != null && a.id) && ((l = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || l.set("action", "edit"));
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
render() {
|
|
1432
|
+
var r, t, n, s, c, a, d, l, u, f, y, g, w, p, m, S;
|
|
1433
|
+
return h(Host, { key: "cf37fcf4f16628b3bb60faf53b3ce40ac92abe50" }, h("div", { key: "964e522aea50d644a1881699ba4ecd0bcc53d39e", class: "scheduler-editor-header", part: "nse__header" }, h("h1", { key: "0ed5df6275a84f9867658ee595c30636c2be6548", class: "scheduler-editor-title", part: "nse__title" }, h("calendar-icon", { key: "fa00ebc65af656b81d2e9100b5bed510c0f293c7", width: "18", height: "18" }), "Scheduler Editor"), h("button", { key: "c6178921ae812fa73ea16d63c4ad30c323b48e9c", class: "scheduler-editor-close", title: "logout", onClick: (x) => this.handleSchedulerConfigCloseClicked(x), part: "nse__close-button" }, h("close-icon", { key: "08393fce33207f1d468d3b15ddeb53051800a488", width: "18", height: "18" }))), h("div", { key: "fac27d5f8f0a46149bf80ebe80ec6c1344d77d23", class: "scheduler-editor-content", part: "nse__content" }, ((t = (r = this.stores) == null ? void 0 : r.schedulerConfig) == null ? void 0 : t.state.currentUser) && this.stores.schedulerConfig.state.action === null && h("div", { class: "list-configurations" }, h("nylas-list-configurations", { exportparts: "nlc__create-new-cta" })), ((s = (n = this.stores) == null ? void 0 : n.schedulerConfig) == null ? void 0 : s.state.currentUser) && this.stores.schedulerConfig.state.action === "create" && h("nylas-editor-tabs", { mode: "composable" }, h(ExpressFlow, { currentUser: (a = (c = this.stores) == null ? void 0 : c.schedulerConfig) == null ? void 0 : a.state.currentUser, calendars: (u = (l = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null ? void 0 : l.state) == null ? void 0 : u.calendars, selectedConfiguration: (g = (y = (f = this.stores) == null ? void 0 : f.schedulerConfig) == null ? void 0 : y.state) == null ? void 0 : g.selectedConfiguration })), ((p = (w = this.stores) == null ? void 0 : w.schedulerConfig) == null ? void 0 : p.state.currentUser) && this.stores.schedulerConfig.state.action === "edit" && h("nylas-editor-tabs", { mode: this.mode }, this.mode === "composable" && h("slot", null)), !((S = (m = this.stores) == null ? void 0 : m.schedulerConfig) != null && S.state.currentUser) && h("slot", { name: "login-required" }, h(LoginRequired, { authenticationUrl: this.authenticationUrl }))));
|
|
1434
|
+
}
|
|
1435
|
+
get host() {
|
|
1436
|
+
return getElement(this);
|
|
1437
|
+
}
|
|
1438
|
+
static get watchers() {
|
|
1439
|
+
return {
|
|
1440
|
+
configurationId: ["configurationIdChanged"]
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
NylasSchedulerEditor.style = NylasSchedulerEditorStyle0;
|
|
1445
|
+
export {
|
|
1446
|
+
NylasSchedulerEditor as nylas_scheduler_editor
|
|
1447
|
+
};
|